Functions | Variables

sr_module.c File Reference

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

#include "sr_module.h"
#include "mod_fix.h"
#include "dprint.h"
#include "error.h"
#include "mem/mem.h"
#include "core_cmd.h"
#include "ut.h"
#include "re.h"
#include "route_struct.h"
#include "flags.h"
#include "trim.h"
#include "pvapi.h"
#include "globals.h"
#include "rpc_lookup.h"
#include "sr_compat.h"
#include <sys/stat.h>
#include <regex.h>
#include <dlfcn.h>
#include <strings.h>
#include <stdlib.h>
#include <string.h>
#include <stddef.h>
Include dependency graph for sr_module.c:

Go to the source code of this file.

Functions

Variables


Detailed Description

Definition in file sr_module.c.


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

Definition at line 759 of file sr_module.c.

int fix_param ( int  type,
void **  param 
)

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:

action_param_type* fixup_get_param_ptype ( void **  param  ) 
Parameters:
param 
Returns:
pointer to the parameter internal type.

Definition at line 1014 of file sr_module.c.

Referenced by fixup_get_param_type().

Here is the caller graph for this function:

action_param_type fixup_get_param_type ( void **  param  ) 
See also:
fixup_get_param_ptype().
Returns:
paramter internal type.

Definition at line 1026 of file sr_module.c.

References fixup_get_param_ptype().

Referenced by fix_param_types(), 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 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. 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 
)
Returns:
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 
)

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 
)
Returns:
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.

static sr31_cmd_export_t* sr_cmd_exports_convert ( unsigned  ver,
void *  src,
void *  mod 
) [static]
Parameters:
ver - module interface versions (0 == ser, 1 == kam).
src - null terminated array of cmd exports (either ser_cmd_export_t or kam_cmd_export_t, depending on ver).
mod - pointer to module exports structure.
Returns:
- pkg_malloc'ed null terminated sr_cmd_export_v31_t array with the converted cmd exports or 0 on error.

Definition at line 213 of file sr_module.c.

References kam_cmd_export_::fixup, ser_cmd_export_::fixup, sr31_cmd_export_::fixup, kam_cmd_export_::flags, ser_cmd_export_::flags, sr31_cmd_export_::flags, kam_cmd_export_::free_fixup, sr31_cmd_export_::free_fixup, kam_cmd_export_::function, ser_cmd_export_::function, sr31_cmd_export_::function, get_fixup_free(), sr31_cmd_export_::module_exports, sr31_cmd_export_::name, kam_cmd_export_::name, ser_cmd_export_::name, kam_cmd_export_::param_no, ser_cmd_export_::param_no, and sr31_cmd_export_::param_no.

Here is the call graph for this function: