1 /* 2 Copyright (C) 2002-2009 Thomas Ries <tries@gmx.net> 3 4 This file is part of Siproxd. 5 6 Siproxd is free software; you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation; either version 2 of the License, or 9 (at your option) any later version. 10 11 Siproxd is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with Siproxd; if not, write to the Free Software 18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 */ 20 21 /* $Id: plugins.h 532 2015-10-15 08:38:20Z hb9xar $ */ 22 23 #ifdef LTDL_CONVLIB 24 /* fetch local version of ltdl */ 25 #include "../libltdl/ltdl.h" 26 #else 27 /* fetch system version of libltdl */ 28 #include <ltdl.h> 29 #endif 30 31 #ifdef WITH_LTDL_FIX 32 /* workaround for some broken libtool 2.2.6 (and others?) versions 33 * that cause an 34 * undefined reference to `lt__PROGRAM__LTX_preloaded_symbols' 35 * error during linking state */ 36 #ifndef lt__PROGRAM__LTX_preloaded_symbols 37 #define lt__PROGRAM__LTX_preloaded_symbols lt_libltdl_LTX_preloaded_symbols 38 //extern const void *lt_preloaded_symbols[]; 39 #endif 40 #endif 41 42 /* Plugins must return STS_SUCCESS / SUCCESS_FAILURE */ 43 44 45 /* 46 * Processing stages for Plugins 47 */ 48 /* get cyclic trigger */ 49 /* NO ticket is present (ticket = NULL pointer) */ 50 #define PLUGIN_TIMER 0x00000001 51 52 /* Process RAW data received */ 53 /* may end the current SIP processing in siproxd by returning STS_FALSE * 54 * may be used to intercept other traffic on SIP port */ 55 /* ticket with NO sipmsg is present (ticket.sipmsg = NULL pointer) */ 56 #define PLUGIN_PROCESS_RAW 0x00000005 57 58 /*--------- below here a valid sip message (ticket->sipmsg) is present ---*/ 59 60 /* Validation of SIP packet */ 61 /* may end the current SIP processing in siproxd by returning STS_FALSE * 62 * may be used to intercept other traffic on SIP port */ 63 #define PLUGIN_VALIDATE 0x00000010 64 65 /* Determining Request Targets */ 66 /* may end the current SIP processing in siproxd by returning STS_SIP_SENT 67 * see plugin_shortcut that sends a redirect back to the client */ 68 #define PLUGIN_DETERMINE_TARGET 0x00000020 /* Determining Request Targets */ 69 70 /* SIP package before siproxd starts the proxying process */ 71 #define PLUGIN_PRE_PROXY 0x00000040 /* before MASQuerading */ 72 73 /* to/from unregistered UA */ 74 #define PLUGIN_PROXY_UNK 0x00000080 /* e.g. incoming call to unknown UA */ 75 76 /* before sending the SIP message */ 77 #define PLUGIN_POST_PROXY 0x00000100 /* after MASQuerading */ 78 79 80 /* Plugin "database" */ 81 typedef struct { 82 void *next; /* link to next plugin element, NULL if last */ 83 int api_version; /* API version that PLUGIN uses */ 84 char *name; /* Plugin name */ 85 char *desc; /* Description */ 86 int exe_mask; /* bitmask for activation of different processing 87 stages during SIP processing that a plugin wants 88 to be called */ 89 lt_ptr plugin_process;/* Plugin processing entry point */ 90 lt_ptr plugin_end; /* de-initialization function */ 91 lt_ptr dlhandle; /* handle returned by dlopen() */ 92 } plugin_def_t; 93 94 #define SIPROXD_API_VERSION 0x0101 95 96 97 /* The plugin must provide the following entry points */ 98 /* Plugin is responsable for its dynamic memory management. 99 - Storage allocated in _init must be released in _end. 100 - manipulation of SIP messages (sip_ticket structure) must 101 be made in a way to ensure that no memleaks do exist. 102 If you want to change a field, first osip_malloc() new space, 103 move the pointer in the osip structure to the new place and then 104 osip_free() the old area. 105 */ 106 /* plugin_init must define the following fields of the plugin_def_t structure: 107 - api_version (= SIPROXD_API_VERSION) 108 - name 109 - desc 110 - exe_mask 111 The rest will be initialized by siproxd and must not be fumbled with. 112 */ 113 int plugin_init(plugin_def_t *plugin_def); 114 int plugin_process(int stage, sip_ticket_t *ticket); 115 int plugin_end(plugin_def_t *plugin_def); 116 117 /* libltdl symbol name magic... 118 convert plugin_init into <module>_LTX_plugin_init */ 119 120 #if defined (PLUGIN_NAME) 121 #define JOIN(x, y) JOIN_AGAIN(x, y) 122 #define JOIN_AGAIN(x, y) x ## y 123 #define PLUGIN_INIT JOIN(PLUGIN_NAME, _LTX_plugin_init) 124 #define PLUGIN_PROCESS JOIN(PLUGIN_NAME, _LTX_plugin_process) 125 #define PLUGIN_END JOIN(PLUGIN_NAME, _LTX_plugin_end) 126 #endif 127