2 Copyright (C) 2004-2005 Thomas Ries <tries@gmx.net>
4 This file is part of Siproxd.
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.
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.
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
22 * This is just an example of how to build your custom
23 * interface between siproxd and your firewall.
25 * Take this as a starting point for your own code.
27 * To build siproxd with you own firewall control module:
28 * 1) compile your interface module (e.g. this example code)
29 * and make an static library out of it.
30 * 2) configure siproxd with:
31 * ./configure --with-custom-fwmodule=<path>/<library>.a
32 * (for example: --with-custom-fwmodule=`pwd`/src/libcustom_fw_module.a)
35 * The START_RTP action will be called BEFORE the RTP stream
36 * actually is started. The STOP_RTP action will be called after
37 * the RTP stream has been stopped.
38 * START_RTP will only be called once for an starting RTP stream,
39 * in case of repetitions (SIP INVITE sequence) it will not
40 * be called multiple times.
42 * The code here is called synchroneously, means the time you spend
43 * in here doing things, siproxd will not do anything else, so
44 * try to do thins as fast as possible and don't wait for something
49 #include <stdio.h> /* sprintf */
50 #include <string.h> /* strcat */
53 #include <sys/types.h>
54 #include <netinet/in.h>
58 static char const ident[]="$Id: custom_fw_module.c,v 1.6 2005/01/08 10:05:12 hb9xar Exp $";
61 * some prototypes of util.c - so I don't have to suck in the
62 * whole bunch of include files. You probably will not use this
63 * in your code anyway - or then should make it in a proper way.
65 char *utils_inet_ntoa(struct in_addr in);
68 * Should return with 0 on success.
69 * If return status is != 0, siproxd will complain with an
70 * an ERROR() but continue.
72 int custom_fw_control(fw_ctl_t fwdata) {
76 switch (fwdata.action) {
78 strcat(tmp, "ACT_START_RTP: ");
81 strcat(tmp, "ACT_STOP_RTP: ");
84 strcat(tmp, "ACT_unknown: ");
88 switch (fwdata.direction) {
90 strcat(tmp, "DIR_IN ");
93 strcat(tmp, "DIR_OUT ");
96 strcat(tmp, "DIR_unknown ");
100 sprintf(&tmp[strlen(tmp)],"[lcl %s:%i] ",
101 utils_inet_ntoa(fwdata.local_ipaddr),
104 sprintf(&tmp[strlen(tmp)],"[rem %s:%i] ",
105 utils_inet_ntoa(fwdata.remote_ipaddr),
108 INFO("CUSTOM: %s", tmp);