src/modules/posops/README
f485a1b2
 POSOPS Module
 
 Daniel-Constantin Mierla
 
    asipto.com
    <miconda@gmail.com>
 
 Edited by
 
 Daniel-Constantin Mierla
 
    <miconda@gmail.com>
 
a9ef78b7
    Copyright © 2021 http://www.asipto.com
f485a1b2
      __________________________________________________________________
 
    Table of Contents
 
    1. Admin Guide
 
         1. Overview
         2. Dependencies
 
               2.1. Kamailio Modules
               2.2. External Libraries or Applications
 
23a2bc69
         3. Parameters
f485a1b2
 
23a2bc69
               3.1. idx0 (int)
 
         4. Functions
 
               4.1. pos_append(idx, val)
               4.2. pos_insert(idx, val)
               4.3. pos_rm(idx, len)
               4.4. pos_headers_start()
               4.5. pos_headers_end()
               4.6. pos_body_start()
               4.7. pos_body_end()
f485a1b2
 
    List of Examples
 
23a2bc69
    1.1. Set idx0 parameter
    1.2. pos_append() usage
    1.3. pos_insert() usage
    1.4. pos_rm() usage
    1.5. pos_headers_start() usage
    1.6. pos_headers_end() usage
    1.7. pos_body_start() usage
    1.8. pos_body_end() usage
f485a1b2
 
 Chapter 1. Admin Guide
 
    Table of Contents
 
    1. Overview
    2. Dependencies
 
         2.1. Kamailio Modules
         2.2. External Libraries or Applications
 
23a2bc69
    3. Parameters
 
         3.1. idx0 (int)
f485a1b2
 
23a2bc69
    4. Functions
 
         4.1. pos_append(idx, val)
         4.2. pos_insert(idx, val)
         4.3. pos_rm(idx, len)
         4.4. pos_headers_start()
         4.5. pos_headers_end()
         4.6. pos_body_start()
         4.7. pos_body_end()
f485a1b2
 
 1. Overview
 
    The module exports utility functions to work with position inside the
    SIP message buffer.
 
    Among them are function to add or remove content at a specific
    position.
 
 2. Dependencies
 
    2.1. Kamailio Modules
    2.2. External Libraries or Applications
 
 2.1. Kamailio Modules
 
    The following modules must be installed (but not loaded) to use this
    module:
      * none.
 
 2.2. External Libraries or Applications
 
    The following libraries or applications must be installed before
    running Kamailio with this module loaded:
      * none.
 
23a2bc69
 3. Parameters
 
    3.1. idx0 (int)
 
 3.1. idx0 (int)
 
    The value to return by functions seeking a position when the index is 0
    (note: returning 0 is stopping the execution of configuration file like
    'exit', but for KEMI usage it is ok).
 
    Default value is -255.
 
    Example 1.1. Set idx0 parameter
 ...
 modparam("posops", "idx0", -200)
 ...
 
 4. Functions
f485a1b2
 
23a2bc69
    4.1. pos_append(idx, val)
    4.2. pos_insert(idx, val)
    4.3. pos_rm(idx, len)
    4.4. pos_headers_start()
    4.5. pos_headers_end()
    4.6. pos_body_start()
    4.7. pos_body_end()
f485a1b2
 
23a2bc69
 4.1.  pos_append(idx, val)
f485a1b2
 
    Append the value val after the position idx in the SIP message buffer.
 
    The idx can be an integer value or a variable holding an integer. If
    the value is negative, the position is counted from the end of the
    buffer.
 
    The val can be a static string or variables.
 
    This function can be used from ANY_ROUTE.
 
23a2bc69
    Example 1.2. pos_append() usage
f485a1b2
 ...
 pos_append("100", "kamailio-$si");
 ...
 
23a2bc69
 4.2.  pos_insert(idx, val)
f485a1b2
 
    Insert the value val at the position idx in the SIP message buffer.
 
    The idx can be an integer value or a variable holding an integer. If
    the value is negative, the position is counted from the end of the
    buffer.
 
    The val can be a static string or variables.
 
    This function can be used from ANY_ROUTE.
 
23a2bc69
    Example 1.3. pos_insert() usage
f485a1b2
 ...
 pos_insert("100", "kamailio-$si");
 ...
 
23a2bc69
 4.3.  pos_rm(idx, len)
f485a1b2
 
    Remove len characters starting at the position idx in the SIP message
    buffer.
 
    The idx can be an integer value or a variable holding an integer. If
    the value is negative, the position is counted from the end of the
    buffer.
 
    The idx can be a positive integer value or a variable holding a
    positive integer.
 
    This function can be used from ANY_ROUTE.
 
23a2bc69
    Example 1.4. pos_rm() usage
f485a1b2
 ...
 pos_insert("100", "10");
 ...
a9ef78b7
 
23a2bc69
 4.4.  pos_headers_start()
a9ef78b7
 
    Return the position in the message buffer where headers start.
 
    This function can be used from ANY_ROUTE.
 
23a2bc69
    Example 1.5. pos_headers_start() usage
a9ef78b7
 ...
 $var(pos) = pos_headers_start();
 ...
 
23a2bc69
 4.5.  pos_headers_end()
a9ef78b7
 
    Return the position in the message buffer where headers end.
 
    This function can be used from ANY_ROUTE.
 
23a2bc69
    Example 1.6. pos_headers_end() usage
a9ef78b7
 ...
 $var(pos) = pos_headers_end();
 ...
 
23a2bc69
 4.6.  pos_body_start()
a9ef78b7
 
    Return the position in the message buffer where body starts.
 
    This function can be used from ANY_ROUTE.
 
23a2bc69
    Example 1.7. pos_body_start() usage
a9ef78b7
 ...
 $var(pos) = pos_body_start();
 ...
 
23a2bc69
 4.7.  pos_body_end()
a9ef78b7
 
    Return the position in the message buffer where body ends.
 
    This function can be used from ANY_ROUTE.
 
23a2bc69
    Example 1.8. pos_body_end() usage
a9ef78b7
 ...
 $var(pos) = pos_body_end();
 ...