sr_module.h
a7524985
 /*
53c7e0f1
  * Copyright (C) 2001-2003 FhG Fokus
7dd0b342
  *
  * This file is part of ser, a free SIP server.
  *
  * ser is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version
  *
  * For a license to use the ser software under conditions
  * other than those described here, or to purchase support for this
  * software, please contact iptel.org by e-mail at the following addresses:
  *    info@iptel.org
  *
  * ser is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
fb851d7e
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
7dd0b342
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
3bf76e49
  */
a7524985
 
6419a43f
 /*
  * History:
  * --------
  *  2003-03-10  changed module exports interface: added struct cmd_export
  *               and param_export (andrei)
f9add4f7
  *  2003-03-16  Added flags field to cmd_export_ (janakj)
87405423
  *  2003-04-05  s/reply_route/failure_route, onreply_route introduced (jiri)
78878540
  *  2004-03-12  extra flag USE_FUNC_PARAM added to modparam type -
  *              instead of copying the param value, a func is called (bogdan)
dd0e65a8
  *  2004-09-19  switched to version.h for the module versions checks (andrei)
d7a3fdea
  *  2004-12-03  changed param_func_t to (modparam_t, void*), killed
  *               param_func_param_t   (andrei)
8390f722
  *  2007-06-07  added PROC_INIT, called in the main process context
  *               (same as PROC_MAIN), buf guaranteed to be called before
  *               any other process is forked (andrei)
1dd086b9
  *  2008-11-17  sip-router version: includes some of the openser/kamailio
  *               changes: f(void) instead of f(), free_fixup_function()
2873d384
  *              dual module interface support: ser & kamailio (andrei)
ca19a01e
  *  2008-11-18  prototypes for various fixed parameters numbers module
  *               functions (3, 4, 5 & 6) and variable parameters (andrei)
bf9d1c43
  *  2008-11-26  added fparam_free_contents() and fix_param_types (andrei)
1dd086b9
  */
 
a7524985
 /**
  * @file
  * @brief SIP-Router core :: modules loading, structures declarations and utilities
  * @ingroup core
  * Module: \ref core
6419a43f
  */
3bf76e49
 
7dd0b342
 
4042f646
 #ifndef sr_module_h
 #define sr_module_h
3bf76e49
 
feef2d2e
 #include <dlfcn.h>
 
3881f12c
 #include "parser/msg_parser.h" /* for sip_msg */
1ef55a09
 #include "ver_defs.h"
300b0f50
 #include "rpc.h"
f141bc93
 #include "route_struct.h"
1dfe92cb
 #include "route.h"
c16e9887
 #include "str.h"
3bf76e49
 
2873d384
 /* kamailio compat */
742ce3ae
 #include "kstats_types.h"
627a1969
 #include "mi/mi_types.h"
2873d384
 #include "pvar.h"
 
 
 
 #if defined KAMAILIO_MOD_INTERFACE || defined OPENSER_MOD_INTERFACE || \
 	defined MOD_INTERFACE_V1
 
 #define MODULE_INTERFACE_VER 1
 #define cmd_export_t kam_cmd_export_t
 #define module_exports kam_module_exports
 
 #elif defined SER_MOD_INTERFACE || defined MOD_INTERFACE_V0
 
 #define MODULE_INTERFACE_VER 0
 #define cmd_export_t ser_cmd_export_t
 #define module_exports ser_module_exports
 
 #else
 
 /* do nothing for core */
 
 #endif
 
a7524985
 /**
  * @brief type used for the mod_register function export
  * 
  * mod_register is a function called when loading a module
  * (if present), prior to registering the module exports.
  * @param path path to the module, including file name
  * @param 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.
  * @param reserved1 - reserved for future use.
  * @param reserved2 - reserved for future use
  * @return 0 on success, -1 on error, all the other values are reserved
ea31876f
  *                      for future use (<0 meaning error and >0 success)
  */
a7524985
 typedef  int (*mod_register_function)(char* path, int* dlflags, void* reserved1, void* reserved2);
ea31876f
 
1dd086b9
 typedef  struct module_exports* (*module_register)(void);
a7524985
 
 /**
  * @brief main two parameter module function
  * 
  * Main two parameter module function, default and oldest version.
  * @param sip_msg SIP message
  * @param param1 first parameter
  * @param param2 second parameter
  * @return positive on success, negative on error, 0 to stop processing (drop message)
  */
 typedef  int (*cmd_function)(struct sip_msg*, char* param1, char* param2);
ca19a01e
 typedef  int (*cmd_function3)(struct sip_msg*, char*, char*, char*);
 typedef  int (*cmd_function4)(struct sip_msg*, char*, char*, char*, char*);
 typedef  int (*cmd_function5)(struct sip_msg*,  char*, char*, char*,
 												char*, char*);
 typedef  int (*cmd_function6)(struct sip_msg*,  char*, char*, char*,
 												char*, char*, char*);
a7524985
 /**
  * @brief variable number of parameter module function
  * 
  * Variable number of parameter module function, takes as param the sip_msg,
  * extra parameters number and a pointer to an array of parameters
  * @param sip_msg SIP message
  * @param no extra parameters number
  * @param vals extra parameters
  * @return positive on success, negative on error, 0 to stop processing (drop message)
  */
 typedef int (*cmd_function_var)(struct sip_msg*, int no, action_u_t* vals );
 typedef int (*fixup_function)(void** param, int param_no);
 typedef int (*free_fixup_function)(void** param, int param_no);
 
 /**
  * @brief response module function prototype
  * @param sip_msg SIP message
  * @return positive if ok, 0 to stop processing
  */
 typedef int (*response_function)(struct sip_msg*);
 typedef void (*onbreak_function)(struct sip_msg*);
1dd086b9
 typedef void (*destroy_function)(void);
 
31309a3a
 typedef int (*init_function)(void);
192ac55b
 typedef int (*child_init_function)(int rank);
3bf76e49
 
31309a3a
 
a7524985
 #define PARAM_STRING     (1U<<0)  /**< String (char *) parameter type */
 #define PARAM_INT        (1U<<1)  /**< Integer parameter type */
 #define PARAM_STR        (1U<<2)  /**< struct str parameter type */
fb851d7e
 #define PARAM_USE_FUNC   (1U<<(8*sizeof(int)-1))
 #define PARAM_TYPE_MASK(_x)   ((_x)&(~PARAM_USE_FUNC))
 
 /* temporary, for backward compatibility only until all modules adjust it */
 #define STR_PARAM PARAM_STRING
 #define INT_PARAM PARAM_INT
 #define USE_FUNC_PARAM PARAM_USE_FUNC
78878540
 
d7a3fdea
 typedef unsigned int modparam_t;
78878540
 
d7a3fdea
 typedef int (*param_func_t)( modparam_t type, void* val);
31309a3a
 
ca19a01e
 /* magic parameter number values */
 
a7524985
 #define NO_SCRIPT     -1    /**< export not usable from scripts */
 #define VAR_PARAM_NO  -128  /**< function has variable number of parameters
ca19a01e
 							   (see cmd_function_var for the prototype) */
 
a7524985
 /**
  * special fixup function flags fparam fixup, rve ready,
  * they are kept in the first 2 bits inside the pointer
8f3db98b
  */
a7524985
 #define FIXUP_F_FPARAM_RVE (unsigned long)1
8f3db98b
 
 #define call_fixup(fixup, param, param_no) \
dee21fff
 	((fixup) ? (fixup)(param, param_no) : 0)
8f3db98b
 
cb87691a
 /* Macros - used as rank in child_init function */
a7524985
 #define PROC_MAIN      0  /**< Main ser process */
 #define PROC_TIMER    -1  /**< Timer attendant process */
 #define PROC_RPC      -2  /**< RPC type process */
 #define PROC_FIFO      PROC_RPC  /**< FIFO attendant process */
 #define PROC_TCP_MAIN -4  /**< TCP main process */
 #define PROC_UNIXSOCK -5  /**< Unix socket server */
 #define PROC_ATTENDANT -10  /**< main "attendant process */
 #define PROC_INIT     -127 /**< special rank, the context is the main ser
8390f722
 							  process, but this is guaranteed to be executed
 							  before any process is forked, so it can be used
 							  to setup shared variables that depend on some
 							  after mod_init available information (e.g.
 							  total number of processes).
a7524985
 							  @warning child_init(PROC_MAIN) is again called
8390f722
 							 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 */
a7524985
 #define PROC_NOCHLDINIT -128 /**< no child init functions will be called
37209e14
                                 if this rank is used in fork_process() */
cb87691a
 
119ad6aa
 #define PROC_SIPINIT      1  /**< First SIP worker - some modules do special
 							 processing in this child, like loading db data */
 #define PROC_SIPRPC       127  /**< Used to init RPC worker as SIP commands
 							   handler. Don't do any special processing in the
 							   child init with this rank - just bare child
 							   initialization */
 
a7524985
 #define PROC_MIN PROC_NOCHLDINIT /**< Minimum process rank */
bd52d9b9
 
2873d384
 
a7524985
 #define DEFAULT_DLFLAGS	0 /**< value that signals to module loader to
2873d384
 							use default dlopen flags in Kamailio */
 #ifndef RTLD_NOW
 /* for openbsd */
 #define RTLD_NOW DL_LAZY
 #endif
 
 #define KAMAILIO_DLFLAGS	RTLD_NOW
 
 
dd0e65a8
 #define MODULE_VERSION \
 	char *module_version=SER_FULL_VERSION; \
2873d384
 	char *module_flags=SER_COMPILE_FLAGS; \
 	unsigned int module_interface_ver=MODULE_INTERFACE_VER; 
2dcb8b67
 
a7524985
 /** ser version */
2873d384
 struct ser_cmd_export_ {
a7524985
 	char* name;             /**< null terminated command name */
 	cmd_function function;  /**< pointer to the corresponding function */
 	int param_no;           /**< number of parameters used by the function */
 	fixup_function fixup;   /**< pointer to the function called to "fix" the
6419a43f
 							   parameters */
a7524985
 	int flags;              /**< Function flags */
6419a43f
 };
 
 
a7524985
 /** kamailo/openser version */
2873d384
 struct kam_cmd_export_ {
a7524985
 	char* name;             /**< null terminated command name */
 	cmd_function function;  /**< pointer to the corresponding function */
 	int param_no;           /**< number of parameters used by the function */
 	fixup_function fixup;   /**< pointer to the function called to "fix" the
2873d384
 							   parameters */
a7524985
 	free_fixup_function free_fixup; /**< function called to free the "fixed"
2873d384
 									   parameters */
a7524985
 	int flags;              /**< Function flags */
2873d384
 };
 
a7524985
 /** sip-router version */
dee21fff
 struct sr31_cmd_export_ {
a7524985
 	char* name;             /**< null terminated command name */
 	cmd_function function;  /**< pointer to the corresponding function */
 	int param_no;           /**< number of parameters used by the function */
 	fixup_function fixup;   /**< pointer to the function called to "fix" the
dee21fff
 							   parameters */
a7524985
 	free_fixup_function free_fixup; /**< function called to free the "fixed"
dee21fff
 									   parameters */
a7524985
 	int flags;              /**< Function flags */
dee21fff
 	int fixup_flags;
a7524985
 	void* module_exports; /**< pointer to module structure */
dee21fff
 };
 
 
a7524985
 /** members situated at the same place in memory in both ser & kamailio
2873d384
    cmd_export */
 struct cmd_export_common_ {
 	char* name;
 	cmd_function function; 
 	int param_no;
 	fixup_function fixup;
 };
 
 
6419a43f
 struct param_export_ {
a7524985
 	char* name;             /**< null terminated param. name */
 	modparam_t type;        /**< param. type */
 	void* param_pointer;    /**< pointer to the param. memory location */
6419a43f
 };
 
 
a7524985
 /*
  * Allowed parameter types, the types _must_ be in "fallback" order,
  * e.g. FPARAM_STR should be the last to allow fallback to it,
  * F_PARAM_PVS should be in front of F_PARAM_AVP (so that
  * for fix_param_types(FPARAM_AVP|FPARAM_PVS|FPARAM_STR, param) and $foo
  * the pvars will be checked first and only if no pvar is found the
  * param will be resolved to an avp)
  */
b91364c6
 enum {
 	FPARAM_UNSPEC = 0,
bf9d1c43
 	FPARAM_INT    = (1 << 0),
b25e31aa
 	FPARAM_SELECT = (1 << 1),
 	FPARAM_PVS    = (1 << 2),
 	FPARAM_AVP    = (1 << 3),
 	FPARAM_STRING = (1 << 4),
 	FPARAM_STR    = (1 << 5),
 	/* special types: no fallback between them possible */
 	FPARAM_REGEX  = (1 << 6),
 	FPARAM_SUBST  = (1 << 7),
 	FPARAM_PVE    = (1 << 8)
b91364c6
 };
 
a7524985
 /**
b91364c6
  * Function parameter
  */
 typedef struct fparam {
a7524985
 	char* orig;                       /**< The original value */
 	int type;                         /**< Type of parameter */
d64c1c71
 	union {
a7524985
 		char* asciiz;             /**< Zero terminated ASCII string */
 		struct _str str;          /**< pointer/len string */
 		int i;                    /**< Integer value */
 		regex_t* regex;           /**< Compiled regular expression */
 		avp_ident_t avp;          /**< AVP identifier */
 		select_t* select;         /**< select structure */ 
 		struct subst_expr* subst; /**< Regex substitution */
 		pv_spec_t* pvs;    /**< kamailio pseudo-vars */
 		pv_elem_t* pve;    /**< kamailio pseudo-vars in a string */
b91364c6
 	} v;
d64c1c71
 	void *fixed;
b91364c6
 } fparam_t;
 
 
2873d384
 typedef struct param_export_ param_export_t;  
 typedef struct ser_cmd_export_ ser_cmd_export_t;
 typedef struct kam_cmd_export_ kam_cmd_export_t;
 typedef struct cmd_export_common_ cmd_export_common_t;
dee21fff
 typedef struct sr31_cmd_export_ sr31_cmd_export_t;
2873d384
 
fb851d7e
 
a7524985
 /** ser module exports version */
2873d384
 struct ser_module_exports {
a7524985
 	char* name;			/**< null terminated module name */
 	ser_cmd_export_t* cmds;         /**< null terminated array of the exported
6419a43f
 									   commands */
a7524985
 	rpc_export_t* rpc_methods;      /**< null terminated array of exported rpc methods */
 	param_export_t* params;         /**< null terminated array of the exported
6419a43f
 									   module parameters */
a7524985
 	init_function init_f;           /**< Initialization function */
 	response_function response_f;   /**< function used for responses,
6419a43f
 									   returns yes or no; can be null */
a7524985
 	destroy_function destroy_f;     /**< function called when the module should
6419a43f
 									   be "destroyed", e.g: on ser exit;
 									   can be null */
4bd1673d
 	onbreak_function onbreak_f;
a7524985
 	child_init_function init_child_f;  /**< function called by all processes
e3fc93f4
 										  after the fork */
3bf76e49
 };
 
6419a43f
 
a7524985
 /** kamailio/openser proc_export (missing from ser) */
2873d384
 typedef void (*mod_proc)(int no);
 
 typedef int (*mod_proc_wrapper)(void);
 
 struct proc_export_ {
 	char *name;
 	mod_proc_wrapper pre_fork_function;
 	mod_proc_wrapper post_fork_function;
 	mod_proc function;
 	unsigned int no;
 };
 
 typedef struct proc_export_ proc_export_t;
 
 
a7524985
 /** kamailio/openser module exports version */
2873d384
 struct kam_module_exports {
a7524985
 	char* name;				/**< null terminated module name */
 	unsigned int dlflags;			/**< flags for dlopen  */
 	kam_cmd_export_t* cmds;			/**< null terminated array of the exported
2873d384
 									   commands */
a7524985
 	param_export_t* params;			/**< null terminated array of the exported
2873d384
 									   module parameters */
a7524985
 	stat_export_t* stats;			/**< null terminated array of the exported
2873d384
 									  module statistics */
a7524985
 	mi_export_t* mi_cmds;			/**< null terminated array of the exported
2873d384
 									  MI functions */
 	pv_export_t* items;				/*!< null terminated array of the exported
 									   module items (pseudo-variables) */
a7524985
 	proc_export_t* procs;			/**< null terminated array of the
2873d384
 									  additional processes required by the
 									  module */
a7524985
 	init_function init_f;			/**< Initialization function */
 	response_function response_f;		/**< function used for responses,
2873d384
 									   returns yes or no; can be null */
a7524985
 	destroy_function destroy_f;			/**< function called when the module should
2873d384
 									   be "destroyed", e.g: on ser exit;
 									   can be null */
a7524985
 	child_init_function init_child_f;	/**< function called by all processes
2873d384
 										  after the fork */
 };
 
 
 
a7524985
 /**
  * @brief sr/ser 3.1+ module exports version
  * 
  * sr/ser 3.1+ module exports version, Includes ser and kamailio versions,
  * re-arraranged + some extras.
  * @note Some of the members will be obsoleted and are kept only for
dee21fff
  * backward compatibility (avoid re-writing all the modules exports
  * declarations).
  */
 struct sr31_module_exports {
a7524985
 	char* name;			/**< null terminated module name */
 	sr31_cmd_export_t* cmds;	/**< null terminated array of the exported
dee21fff
 									   commands */
a7524985
 	param_export_t* params;         /**< null terminated array of the exported
dee21fff
 									   module parameters */
a7524985
 	init_function init_f;           /**< Initialization function */
 	response_function response_f;   /**< function used for responses,
dee21fff
 									   returns yes or no; can be null */
a7524985
 	destroy_function destroy_f;     /**< function called when the module should
dee21fff
 									   be "destroyed", e.g: on ser exit;
 									   can be null */
 	onbreak_function onbreak_f;
a7524985
 	child_init_function init_child_f;/**< function called by all processes
dee21fff
 										  after the fork */
a7524985
 	unsigned int dlflags;		/**< flags for dlopen */
dee21fff
 	/* ser specific exports
 	   (to be obsoleted and replaced by register_...) */
a7524985
 	rpc_export_t* rpc_methods;	/**< null terminated array of exported
 							rpc methods */
dee21fff
 	/* kamailio specific exports
 	   (to be obsoleted and replaced by register_...) */
a7524985
 	stat_export_t* stats;			/**< null terminated array of the exported
dee21fff
 									  module statistics */
a7524985
 	mi_export_t* mi_cmds;			/**< null terminated array of the exported
dee21fff
 									  MI functions */
a7524985
 	pv_export_t* items;			/**< null terminated array of the exported
dee21fff
 									   module items (pseudo-variables) */
a7524985
 	proc_export_t* procs;			/**< null terminated array of the
dee21fff
 									  additional processes required by the
 									  module */
 };
 
 
 
a7524985
 /** module exports in the same place in memory in both ser & kamailio */
 struct module_exports_common {
2873d384
 	char* name;
 };
 
 
 union module_exports_u {
a7524985
 		struct module_exports_common c; /**< common members for all the versions */
2873d384
 		struct ser_module_exports v0;
 		struct kam_module_exports v1;
 };
 
 
a7524985
 struct sr_module {
3bf76e49
 	char* path;
 	void* handle;
dee21fff
 	unsigned int orig_mod_interface_ver;
 	struct sr31_module_exports exports;
3bf76e49
 	struct sr_module* next;
 };
6419a43f
 
 
a7524985
 extern struct sr_module* modules; /**< global module list*/
 extern response_function* mod_response_cbks; /**< response callback array */
 extern int mod_response_cbk_no; /**< size of reponse callbacks array */
3bf76e49
 
1dd086b9
 int register_builtin_modules(void);
3bf76e49
 int load_module(char* path);
dee21fff
 sr31_cmd_export_t* find_export_record(char* name, int param_no, int flags,
2873d384
 										unsigned *ver);
51c38611
 cmd_function find_export(char* name, int param_no, int flags);
49b28ea4
 cmd_function find_mod_export(char* mod, char* name, int param_no, int flags);
300b0f50
 rpc_export_t* find_rpc_export(char* name, int flags);
1dd086b9
 void destroy_modules(void);
192ac55b
 int init_child(int rank);
31309a3a
 int init_modules(void);
fb851d7e
 struct sr_module* find_module_by_name(char* mod);
34fd2612
 
a7524985
 /**< true if the module with name 'mod_name' is loaded */
4627c2f4
 #define module_loaded(mod_name) (find_module_by_name(mod_name)!=0)
 
 
a7524985
 /**
  * @brief Find a parameter with given type
  * @param mod module
  * @param name parameter name
  * @param type_mask parameter mask
  * @param param_type parameter type
  * @return parameter address in memory, if there is no such parameter, NULL is returned
31309a3a
  */
fb851d7e
 void* find_param_export(struct sr_module* mod, char* name, modparam_t type_mask, modparam_t *param_type);
3bf76e49
 
 
a7524985
 /** API function to get other parameters from fixup */
d0ce0ebd
 action_u_t *fixup_get_param(void **cur_param, int cur_param_no, int required_param_no);
 int fixup_get_param_count(void **cur_param, int cur_param_no);
 
 int fix_flag( modparam_t type, void* val,
 					char* mod_name, char* param_name, int* flag);
 
 
bb6575cd
 /*
d0ce0ebd
  * Common function parameter fixups
bb6575cd
  */
 
a7524985
 /**
  * @brief Generic parameter fixup function
  * 
  * Generic parameter fixup function which creates fparam_t structure.
  * Type parameter contains allowed parameter types.
  * @param type parameter type
  * @param param fixed parameter
  * @return 0 on success, -1 on error
d0ce0ebd
  */
 int fix_param(int type, void** param);
ad4f08c9
 void fparam_free_contents(fparam_t* fp);
bb6575cd
 
bf9d1c43
 /** fix a param to one of the given types (mask).
   */
 int fix_param_types(int types, void** param);
 
a7524985
 /**
  * @brief Fixup variable string, 
  * 
  * 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.
  * @param param fixed parameter value
  * @param param_no number of parameter
  * @return 0 on success, -1 on an error
d0ce0ebd
  */
 int fixup_var_str_12(void** param, int param_no);
bb6575cd
 
a7524985
 /** Same as fixup_var_str_12 but applies to the 1st parameter only */
d0ce0ebd
 int fixup_var_str_1(void** param, int param_no);
bb6575cd
 
a7524985
 /** Same as fixup_var_str_12 but applies to the 2nd parameter only */
d0ce0ebd
 int fixup_var_str_2(void** param, int param_no);
bb6575cd
 
4c52cf05
 /** fixup variable-pve-only-string. */
 int fixup_var_pve_12(void** param, int param_no);
 
a5b499a4
 /** fixup variable-pve-string.
  * The parameter can be a PVAR, AVP, SELECT, PVE (pv based format string)
  * or string.
  */
 int fixup_var_pve_str_12(void** param, int param_no);
 
a7524985
 /** same as fixup_var_pve_str_12 but applies to the 1st parameter only */
a5b499a4
 int fixup_var_pve_str_1(void** param, int param_no);
 
a7524985
 /** same as fixup_var_pve_str_12 but applies to the 2nd parameter only */
a5b499a4
 int fixup_var_pve_str_2(void** param, int param_no);
 
a7524985
 /**
  * @brief Fixup variable integer
d0ce0ebd
  *
a7524985
  * 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
  * @param param fixed parameter value
  * @param param_no number of parameter
  * @return 0 on success, -1 on an error
d0ce0ebd
  */
 int fixup_var_int_12(void** param, int param_no);
bb6575cd
 
a7524985
 /** Same as fixup_var_int_12 but applies to the 1st parameter only */
d0ce0ebd
 int fixup_var_int_1(void** param, int param_no);
bb6575cd
 
a7524985
 /** Same as fixup_var_int_12 but applies to the 2nd parameter only */
d0ce0ebd
 int fixup_var_int_2(void** param, int param_no);
 
a7524985
 /**
d0ce0ebd
  * The parameter must be a regular expression which must compile, the
  * parameter will be converted to compiled regex
  */
f6712967
 int fixup_regex_12(void** param, int param_no);
 
a7524985
 /** Same as fixup_regex_12 but applies to the 1st parameter only */
f6712967
 int fixup_regex_1(void** param, int param_no);
 
a7524985
 /** Same as fixup_regex_12 but applies to the 2nd parameter only */
f6712967
 int fixup_regex_2(void** param, int param_no);
 
a7524985
 /**
d0ce0ebd
  * The string parameter will be converted to integer
b91364c6
  */
d0ce0ebd
 int fixup_int_12(void** param, int param_no);
 
a7524985
 /** Same as fixup_int_12 but applies to the 1st parameter only */
d0ce0ebd
 int fixup_int_1(void** param, int param_no);
 
a7524985
 /** Same as fixup_int_12 but applies to the 2nd parameter only */
d0ce0ebd
 int fixup_int_2(void** param, int param_no);
 
a7524985
 /**
d0ce0ebd
  * Parse the parameter as static string, do not resolve
  * AVPs or selects, convert the parameter to str structure
  */
 int fixup_str_12(void** param, int param_no);
 
a7524985
 /** Same as fixup_str_12 but applies to the 1st parameter only */
d0ce0ebd
 int fixup_str_1(void** param, int param_no);
 
a7524985
 /** Same as fixup_str_12 but applies to the 2nd parameter only */
d0ce0ebd
 int fixup_str_2(void** param, int param_no);
b91364c6
 
a7524985
 /**
  * @brief Get the function parameter value as string
  * @param dst string destination
  * @param msg SIP message
  * @param param function parameters
  * @return 0 on success, 1 on error, e.g. cannot get value
c16e9887
  */
 int get_str_fparam(str* dst, struct sip_msg* msg, fparam_t* param);
 
a7524985
 /**
  * @brief Get the function parameter value as integer
  * @param dst string destination
  * @param msg SIP message
  * @param param function parameters
  * @return 0 on success, 1 on error, e.g. cannot get value
d0ce0ebd
  */
 int get_int_fparam(int* dst, struct sip_msg* msg, fparam_t* param);
6d35d70e
 
44c65404
 /**
a7524985
  * @brief Get the function parameter value as compiled regular expression
  * @param dst string destination
  * @param msg SIP message
  * @param param function parameters
  * @return 0 on success, 1 on error, e.g. cannot get value
44c65404
  */
 int get_regex_fparam(regex_t *dst, struct sip_msg* msg, fparam_t* param);
2873d384
 
 
8f3db98b
 int is_fparam_rve_fixup(fixup_function f);
 
a7524985
 /**
  * @brief Generic free fixup type function for a fixed fparam
  * 
  * 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.
  * @param param freed parameters
6a40b4bd
  */
 void fparam_free_restore(void** param);
 int fixup_free_fparam_all(void** param, int param_no);
 int fixup_free_fparam_1(void** param, int param_no);
 int fixup_free_fparam_2(void** param, int param_no);
0b52bcff
 
a7524985
 /**
  * @brief returns the corresponding fixup_free* for various known fixup types
  * 
  * Returns the corresponding fixup_free* for various known fixup types.
  * Used to automatically fill in free_fixup* functions.
  * @param f fixup function pointer
  * @return free fixup function pointer on success, 0 on failure (unknown
  * fixup or no free fixup function).
  */
0b52bcff
 free_fixup_function get_fixup_free(fixup_function f);
 
df1958c0
 void set_child_sip_rpc_mode(void);
 void set_child_rpc_sip_mode(void);
 int is_sip_worker(int rank);
37db0ca7
 int is_rpc_worker(int rank);
 
52d33940
 unsigned int set_modinit_delay(unsigned int v);
 
bb6575cd
 #endif /* sr_module_h */