3bf76e49 |
/* $Id$
*
* modules/plugin strtuctures declarations
*
|
7dd0b342 |
*
* Copyright (C) 2001-2003 Fhg Fokus
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
3bf76e49 |
*/
|
7dd0b342 |
|
4042f646 |
#ifndef sr_module_h
#define sr_module_h
|
3bf76e49 |
|
3881f12c |
#include "parser/msg_parser.h" /* for sip_msg */
|
3bf76e49 |
|
404073d3 |
typedef struct module_exports* (*module_register)();
|
34fd2612 |
typedef int (*cmd_function)(struct sip_msg*, char*, char*);
typedef int (*fixup_function)(void** param, int param_no);
|
3bf76e49 |
typedef int (*response_function)(struct sip_msg*);
|
4bd1673d |
typedef void (*onbreak_function)(struct sip_msg*);
|
bf08223a |
typedef void (*destroy_function)();
|
31309a3a |
typedef int (*init_function)(void);
|
192ac55b |
typedef int (*child_init_function)(int rank);
|
3bf76e49 |
|
31309a3a |
typedef enum {
STR_PARAM, /* String parameter type */
INT_PARAM, /* Integer parameter type */
} modparam_t; /* Allowed types of parameters */
|
3bf76e49 |
struct module_exports{
|
31309a3a |
char* name; /* null terminated module name */
char** cmd_names; /* cmd names registered by this modules */
|
e3fc93f4 |
cmd_function* cmd_pointers; /* pointers to the corresponding
functions */
int* param_no; /* number of parameters used
by the function */
|
34fd2612 |
fixup_function* fixup_pointers; /* pointers to functions called to "fix"
|
e3fc93f4 |
the params, e.g: precompile a re */
int cmd_no; /* number of registered commands
(size of cmd_{names,pointers} */
|
31309a3a |
char** param_names; /* parameter names registered by this modules */
modparam_t* param_types; /* Type of parameters */
void** param_pointers; /* Pointers to the corresponding memory locations */
|
e3fc93f4 |
int par_no; /* number of registered parameters */
|
31309a3a |
init_function init_f; /* Initilization function */
|
3bf76e49 |
response_function response_f; /* function used for responses,
|
e3fc93f4 |
returns yes or no; can be null */
|
31309a3a |
destroy_function destroy_f; /* function called when the module should
|
e3fc93f4 |
be "destroyed", e.g: on ser exit;
can be null */
|
4bd1673d |
onbreak_function onbreak_f;
|
e3fc93f4 |
child_init_function init_child_f; /* function called by all processes
after the fork */
|
3bf76e49 |
};
struct sr_module{
char* path;
void* handle;
struct module_exports* exports;
struct sr_module* next;
};
|
031e278e |
struct sr_module* modules; /* global module list*/
|
3bf76e49 |
|
31309a3a |
int register_builtin_modules();
int register_module(struct module_exports*, char*, void*);
|
3bf76e49 |
int load_module(char* path);
|
34fd2612 |
cmd_function find_export(char* name, int param_no);
struct sr_module* find_module(void *f, int* r);
|
bf08223a |
void destroy_modules();
|
192ac55b |
int init_child(int rank);
|
31309a3a |
int init_modules(void);
|
34fd2612 |
|
31309a3a |
/*
* Find a parameter with given type and return it's
* address in memory
* If there is no such parameter, NULL is returned
*/
void* find_param_export(char* mod, char* name, modparam_t type);
|
3bf76e49 |
/* modules function prototypes:
|
404073d3 |
* struct module_exports* mod_register(); (type module_register)
|
3bf76e49 |
* int foo_cmd(struct sip_msg* msg, char* param);
* - returns >0 if ok , <0 on error, 0 to stop processing (==DROP)
* int response_f(struct sip_msg* msg)
* - returns >0 if ok, 0 to drop message
*/
#endif
|