Data Structures | Defines | Typedefs | Functions | Variables

sr_module.h File Reference

SIP-Router core :: modules loading, structures declarations and utilitiesModule: SIP-router core. More...

#include <dlfcn.h>
#include "parser/msg_parser.h"
#include "ver_defs.h"
#include "rpc.h"
#include "route_struct.h"
#include "route.h"
#include "str.h"
#include "kstats_types.h"
#include "mi/mi_types.h"
#include "pvar.h"
Include dependency graph for sr_module.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

Defines

Typedefs

Functions

Variables


Detailed Description

Definition in file sr_module.h.


Define Documentation

#define PROC_INIT   -127

total number of processes).

Warning:
child_init(PROC_MAIN) is again called in the same process (main), but latter (before tcp), so make sure you don't init things twice, bot in PROC_MAIN and PROC_INT

Definition at line 194 of file sr_module.h.

Referenced by child_init().

#define PROC_SIPRPC   127

Don't do any special processing in the child init with this rank - just bare child initialization

Definition at line 209 of file sr_module.h.

Referenced by init_mi_child().


Typedef Documentation

typedef int(* cmd_function)(struct sip_msg *, char *param1, char *param2)

Main two parameter module function, default and oldest version.

Parameters:
sip_msg SIP message
param1 first parameter
param2 second parameter
Returns:
positive on success, negative on error, 0 to stop processing (drop message)

Definition at line 122 of file sr_module.h.

typedef int(* cmd_function_var)(struct sip_msg *, int no, action_u_t *vals)

Variable number of parameter module function, takes as param the sip_msg, extra parameters number and a pointer to an array of parameters

Parameters:
sip_msg SIP message
no extra parameters number
vals extra parameters
Returns:
positive on success, negative on error, 0 to stop processing (drop message)

Definition at line 139 of file sr_module.h.

typedef int(* mod_register_function)(char *path, int *dlflags, void *reserved1, void *reserved2)

mod_register is a function called when loading a module (if present), prior to registering the module exports.

Parameters:
path path to the module, including file name
dlflags pointer to the dlflags used when loading the module. If the value is changed to a different and non-zero value, the module will be reloaded with the new flags.
reserved1 - reserved for future use.
reserved2 - reserved for future use
Returns:
0 on success, -1 on error, all the other values are reserved for future use (<0 meaning error and >0 success)

Definition at line 109 of file sr_module.h.

typedef int(* response_function)(struct sip_msg *)
Parameters:
sip_msg SIP message
Returns:
positive if ok, 0 to stop processing

Definition at line 148 of file sr_module.h.


Function Documentation

void* find_param_export ( struct sr_module *  mod,
char *  name,
modparam_t  type_mask,
modparam_t *  param_type 
)
Parameters:
mod module
name parameter name
type_mask parameter mask
param_type parameter type
Returns:
parameter address in memory, if there is no such parameter, NULL is returned
Parameters:
mod module
name parameter name
type_mask parameter mask
param_type parameter type
Returns:
parameter address in memory, if there is no such parameter, NULL is returned

Definition at line 759 of file sr_module.c.

int fix_param ( int  type,
void **  param 
)

Generic parameter fixup function which creates fparam_t structure. Type parameter contains allowed parameter types.

Parameters:
type parameter type
param fixed parameter
Returns:
0 on success, -1 on error

Creates a fparam_t structure.

Parameters:
type contains allowed parameter types
param is the parameter that will be fixed-up
Returns:
0 on success, 1 if the param doesn't match the specified type <0 on failure

Definition at line 1101 of file sr_module.c.

References fparam::asciiz, fparam::avp, fparam::i, _str::len, fparam::orig, parse_avp_ident(), parse_select(), fparam::pve, fparam::pvs, fparam::regex, _str::s, fparam::select, fparam::str, fparam::subst, and fparam::type.

Referenced by fix_param_types(), fixup_int_12(), fixup_regex_12(), fixup_str_12(), fixup_var_int_12(), fixup_var_pve_12(), fixup_var_pve_str_12(), and fixup_var_str_12().

Here is the call graph for this function:

Here is the caller graph for this function:

int fix_param_types ( int  types,
void **  param 
)
Parameters:
types - bitmap of the allowed types (e.g. FPARAM_INT|FPARAM_STR)
param - value/result
Returns:
- 0 on success, -1 on error, 1 if param doesn't match any of the types

Definition at line 1328 of file sr_module.c.

References fix_param(), and fixup_get_param_type().

Here is the call graph for this function:

int fixup_free_fparam_1 ( void **  param,
int  param_no 
)
Parameters:
param - double pointer to param, as for normal fixup functions.
param_no - parameter number: the function will work only for param_no == 1 (first parameter).
Returns:
0 on success (always).

Definition at line 1774 of file sr_module.c.

References fparam_free_restore().

Here is the call graph for this function:

int fixup_free_fparam_2 ( void **  param,
int  param_no 
)
Parameters:
param - double pointer to param, as for normal fixup functions.
param_no - parameter number: the function will work only for param_no == 2 (2nd parameter).
Returns:
0 on success (always).

Definition at line 1789 of file sr_module.c.

References fparam_free_restore().

Here is the call graph for this function:

int fixup_free_fparam_all ( void **  param,
int  param_no 
)
Parameters:
param - double pointer to param, as for normal fixup functions.
param_no - parameter number, ignored.
Returns:
0 on success (always).

Definition at line 1760 of file sr_module.c.

References fparam_free_restore().

Here is the call graph for this function:

int fixup_var_int_12 ( void **  param,
int  param_no 
)

Fixup variable integer, the parameter can be AVP, SELECT, or ordinary integer. AVP and select identifiers will be resolved to their values and converted to int if necessary during runtime. The parameter value will be converted to fparam structure

Parameters:
param fixed parameter value
param_no number of parameter
Returns:
0 on success, -1 on an error

Definition at line 1493 of file sr_module.c.

References fix_param(), and fixup_get_param_type().

Referenced by fixup_sl_reply(), fixup_var_int_1(), fixup_var_int_2(), get_fixup_free(), and is_fparam_rve_fixup().

Here is the call graph for this function:

Here is the caller graph for this function:

int fixup_var_pve_12 ( void **  param,
int  param_no 
)

The parameter can be a PVE (pv based format string) or string. non-static PVEs identifiers will be resolved to their values during runtime. The parameter value will be converted to fparam structure

Parameters:
param - double pointer to param, as for normal fixup functions.
param_no - parameter number, ignored.
Returns:
-1 on an error, 0 on success.

Definition at line 1398 of file sr_module.c.

References fix_param(), fixup_get_param_type(), fparam_free_restore(), and fparam::pve.

Here is the call graph for this function:

int fixup_var_pve_str_12 ( void **  param,
int  param_no 
)

The parameter can be a PVAR, AVP, SELECT, PVE (pv based format string) or string.

The parameter can be a PVAR, AVP, SELECT, PVE (pv based format string) or string. PVAR, AVP and select and non-static PVEs identifiers will be resolved to their values during runtime. The parameter value will be converted to fparam structure

Parameters:
param - double pointer to param, as for normal fixup functions.
param_no - parameter number, ignored.
Returns:
-1 on an error, 0 on success.

Definition at line 1437 of file sr_module.c.

References fix_param(), fixup_get_param_type(), fparam_free_restore(), and fparam::pve.

Referenced by fixup_sl_reply(), fixup_var_pve_str_1(), fixup_var_pve_str_2(), get_fixup_free(), and is_fparam_rve_fixup().

Here is the call graph for this function:

Here is the caller graph for this function:

int fixup_var_str_12 ( void **  param,
int  param_no 
)

Fixup variable string, the parameter can be AVP, SELECT, or ordinary string. AVP and select identifiers will be resolved to their values during runtime. The parameter value will be converted to fparam structure.

Parameters:
param fixed parameter value
param_no number of parameter
Returns:
0 on success, -1 on an error

Definition at line 1357 of file sr_module.c.

References fix_param(), and fixup_get_param_type().

Referenced by fixup_var_str_1(), fixup_var_str_2(), get_fixup_free(), and is_fparam_rve_fixup().

Here is the call graph for this function:

Here is the caller graph for this function:

void fparam_free_contents ( fparam_t fp  ) 

Frees the "content" of a fparam, but not the fparam itself. Note: it doesn't free fp->orig! Assumes pkg_malloc'ed content.

Parameters:
fp - fparam to be freed

Definition at line 1248 of file sr_module.c.

References fparam::avp, free_select(), pv_spec_free(), fparam::pve, fparam::pvs, fparam::regex, fparam::select, fparam::subst, and fparam::type.

Referenced by fparam_free_restore().

Here is the call graph for this function:

Here is the caller graph for this function:

void fparam_free_restore ( void **  param  ) 

Generic free fixup type function for a fixed fparam. It will free whatever was allocated during the initial fparam fixup and restore the original param value.

Parameters:
param freed parameters

Definition at line 1306 of file sr_module.c.

References fparam_free_contents(), and fparam::orig.

Referenced by fixup_free_fparam_1(), fixup_free_fparam_2(), fixup_free_fparam_all(), fixup_var_pve_12(), and fixup_var_pve_str_12().

Here is the call graph for this function:

Here is the caller graph for this function:

free_fixup_function get_fixup_free ( fixup_function  f  ) 

Returns the corresponding fixup_free* for various known fixup types. Used to automatically fill in free_fixup* functions.

Parameters:
f fixup function pointer
Returns:
free fixup function pointer on success, 0 on failure (unknown fixup or no free fixup function).

Definition at line 1839 of file sr_module.c.

References fixup_int_1(), fixup_int_12(), fixup_int_2(), fixup_regex_1(), fixup_regex_12(), fixup_regex_2(), fixup_str_1(), fixup_str_12(), fixup_str_2(), fixup_var_int_1(), fixup_var_int_12(), fixup_var_int_2(), fixup_var_pve_str_1(), fixup_var_pve_str_12(), fixup_var_pve_str_2(), fixup_var_str_1(), fixup_var_str_12(), fixup_var_str_2(), and mod_fix_get_fixup_free().

Referenced by sr_cmd_exports_convert().

Here is the call graph for this function:

Here is the caller graph for this function:

int get_int_fparam ( int *  dst,
struct sip_msg msg,
fparam_t param 
)
Parameters:
dst string destination
msg SIP message
param function parameters
Returns:
0 on success, 1 on error, e.g. cannot get value
0 - Success -1 - Cannot get value

Definition at line 1679 of file sr_module.c.

References fparam::avp, fparam::i, fparam::orig, fparam::pvs, fparam::select, and fparam::type.

Referenced by w_send_reply(), w_sl_send_reply(), and xmlrpc_reply().

Here is the caller graph for this function:

int get_regex_fparam ( regex_t *  dst,
struct sip_msg msg,
fparam_t param 
)
Parameters:
dst string destination
msg SIP message
param function parameters
Returns:
0 on success, 1 on error, e.g. cannot get value

Get the function parameter value as compiled regular expression.

Returns:
: 0 for success, negative on error.

Definition at line 1740 of file sr_module.c.

References fparam::regex, and fparam::type.

int get_str_fparam ( str dst,
struct sip_msg msg,
fparam_t param 
)
Parameters:
dst string destination
msg SIP message
param function parameters
Returns:
0 on success, 1 on error, e.g. cannot get value
0 - Success -1 - Cannot get value

Definition at line 1612 of file sr_module.c.

References fparam::asciiz, fparam::avp, int2str(), _str::len, fparam::orig, fparam::pve, fparam::pvs, _str::s, fparam::select, fparam::str, and fparam::type.

Referenced by w_send_reply(), w_sl_send_reply(), and xmlrpc_reply().

Here is the call graph for this function:

Here is the caller graph for this function:

int is_fparam_rve_fixup ( fixup_function  f  ) 

Used to automatically detect "pure" fparam fixups that can be used with non contant RVEs.

Parameters:
f - function pointer
Returns:
1 for fparam fixups, 0 for others.

Definition at line 1804 of file sr_module.c.

References fixup_int_1(), fixup_int_12(), fixup_int_2(), fixup_regex_1(), fixup_regex_12(), fixup_regex_2(), fixup_str_1(), fixup_str_12(), fixup_str_2(), fixup_var_int_1(), fixup_var_int_12(), fixup_var_int_2(), fixup_var_pve_str_1(), fixup_var_pve_str_12(), fixup_var_pve_str_2(), fixup_var_str_1(), fixup_var_str_12(), and fixup_var_str_2().

Here is the call graph for this function:

int load_module ( char *  mod_path  ) 

tries to load the module specified by mod_path. If mod_path is 'modname' or 'modname.so' then <MODS_DIR>/<modname>.so will be tried and if this fails <MODS_DIR>/<modname>/<modname>.so If mod_path contain a '/' it is assumed to be the path to the module and tried first. If fails and mod_path is not absolute path (not starting with '/') then will try: <MODS_DIR>/mod_path

Parameters:
mod_path path or module name
Returns:
0 on success , <0 on error

Definition at line 440 of file sr_module.c.

References DEFAULT_DLFLAGS, and modules.