[Serusers] response function in a module

Jiri Kuthan jiri at iptel.org
Tue Mar 4 14:47:29 CET 2003


At 02:25 PM 3/4/2003, Mario Kolberg wrote:
>Hi,
>
>I'm writing a module which requires to see request messages and also responses. So I have declared a response_function. The function looks like:
>
>static int fi_response(struct sip_msg* msg, char* str1, char* str2);
>
>and I put it into the module_exports structure like this:
>
>#ifdef STATIC_FI
>struct module_exports fi_exports = {
>#else
>struct module_exports exports= {
>#endif
>        "fi_module",
>        (char*[]){ "fi_request", "fi_response" },
>        (cmd_function[]){ fi_request, fi_response },
>        (int[]){ 0, 0 },
>        (fixup_function[]){ 0 },
>        2,              /* Number of exported functions*/
>        NULL,           /* Module parameter names */
>        NULL,           /* Module parameter types */
>        NULL,           /* Module parameter variable pointers */
>        0,              /* Number of module paramers */
>        mod_init,
>        fi_response,
>        (destroy_function) 0,
>        0,
>        0
>};
>
>I'm wondering if I correctly declared the function as I'm getting a warning during compilation about incompatible pointer types (4th last line in structure where the function is declared as response function).

Well -- you either use the function for request script processing, then it is
of type 
   typedef  int (*cmd_function)(struct sip_msg*, char*, char*);
or you use it for reply processing and then it is of type
   typedef  int (*response_function)(struct sip_msg*);

If you want to have a function serving two purposes, which does not
need to look at parameters, you may enforce type-casting. (But then
really don't change your mind and do not access the parameters from
the function.) You would have to declare fi_reponse to be response_function 
in your registration of response function.

-Jiri 




More information about the sr-users mailing list