diff --git a/ChangeLog b/ChangeLog index a9fcd86..951ebe6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,19 @@ +0.5.9 +===== + 09-Oct-2004: - comp_osip.c: libosip2-2.0.9 compatibility (There SEEM + to happen some API changes forward and backward: + osip_message_to_str, osip_body_to_str, + osip_message_set_body, osip_message_parse) + - included startup script (by Guido Trentalancia) + - siproxd.spec: create PID and registrations directories + and install startup script + 0.5.8 ===== + 22-Sep-2004: - Released 0.5.8 05-Sep-2004: - Cross-provider calls (e.g. sipphone <-> FWD, with dial prefixes) did not work properly - 04-Sep-2004: - more on Route Headers + 04-Sep-2004: - more on Route headers 27-Aug-2004: - preliminary (and reduced) support for Route Headers 26-Aug-2004: - more DEBUG output 22-Aug-2004: - fix: secure_enviroment - set proper EGID (by Daniel Mueller) diff --git a/Makefile.am b/Makefile.am index f7d0fd6..49a24cb 100644 --- a/Makefile.am +++ b/Makefile.am @@ -19,6 +19,6 @@ # -SUBDIRS = src doc scripts +SUBDIRS = src doc scripts contrib EXTRA_DIST = TODO RELNOTES siproxd.spec diff --git a/README b/README index c338bbd..54e23aa 100644 --- a/README +++ b/README @@ -10,13 +10,16 @@ Siproxd is an proxy/masquerading daemon for the SIP protocol. It handles registrations of SIP clients on a private IP network and performs rewriting of the SIP message bodies to make SIP connections possible via an masquerading firewall. -It allows SIP clients (like kphone, linphone) to work behind +It allows SIP software clients (like kphone, linphone) or SIP +hardware clients (Voice over IP phones which are SIP-compatible, +such as those from Cisco, Grandstream or Snom) to work behind an IP masquerading firewall or router. -SIP (Session Initiation Protocol, RFC3261) is used by Softphones -(Voice over IP) to initiate communication. By itself, SIP does not -work via masquerading firewalls as the transfered data contains -IP addresses and port numbers. +SIP (Session Initiation Protocol, RFC3261) is the protocol of +choiche for most VoIP (Voice over IP) phones to initiate +communication. By itself, SIP does not work via masquerading +firewalls as the transfered data contains IP addresses and +port numbers. @@ -184,7 +187,7 @@ CONTACTS Please feel free to contact the author to: - provide feedback, report bugs, - request for additional features - - report interoperability with softphones + - report interoperability with various phones - ... and visit the website at http://siproxd.sourceforge.net/ diff --git a/RELNOTES b/RELNOTES index 1f2b83e..65fac31 100644 --- a/RELNOTES +++ b/RELNOTES @@ -1,7 +1,8 @@ Release Notes for siproxd-0.5.8 =============================== -Major changes since 0.5.8: +Major changes since 0.5.7: + Several bugfixes and preliminary support for Record-Route headers. General Overview: - SIP (RFC3261) Proxy for SIP based softphones hidden behind a @@ -78,9 +79,16 @@ distribution I'd be happy to get a short notice. ----- -md5sum for siproxd-0.5.8.tar.gz: +md5sum for siproxd-0.5.8.tar.gz: b987151719fced722b6df7d16c06f58d GnuPG signature for siproxd-0.5.8.tar.gz archive: +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.3 (GNU/Linux) + +iD8DBQBBUcuoCfzBioe83JQRAkywAJ4t/fijGYFbEnEN9n/Qe+/mRtTD2QCgkNCP +yu88yMfHeUWUbdd7AusGZK8= +=/Rgd +-----END PGP SIGNATURE----- GnuPG: pub 1024D/87BCDC94 2000-03-19 Thomas Ries diff --git a/TODO b/TODO index 38a491d..74645da 100644 --- a/TODO +++ b/TODO @@ -28,3 +28,5 @@ TODOs, in random order: RFC3261 non-compliance: - Record-Route header handling + +- OpenBSD: Warning for redefinition of MACROS diff --git a/acinclude.m4 b/acinclude.m4 index 6c81b99..588b799 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -295,3 +295,113 @@ AC_MSG_RESULT($acx_which_gethostname_r) ])dnl ACX_WHICH_GETHOSTBYNAME_R +dnl @synopsis ACX_WHICH_OSIP +dnl +dnl Provides a test to determine the correct +dnl way to call various osip_* functions +dnl +dnl defines HAVE_FUNC_OSIP_MESSAGE_TO_STR_3 if it needs 3 arguments +dnl defines HAVE_FUNC_OSIP_BODY_TO_STR_3 if it needs 3 arguments +dnl (libosip2 >= 2.0.9) +dnl +dnl @version $Id$ +dnl @author Thomas Ries +dnl +AC_DEFUN([ACX_WHICH_OSIP], [ + +dnl +dnl osip_message_to_str +dnl +AC_CHECK_FUNC(osip_message_to_str, [ + AC_MSG_CHECKING(how many arguments takes osip_message_to_str) + AC_TRY_COMPILE([ + #include ], [ + osip_message_t *sip; + char **dest; + int length; + (void) osip_message_to_str(sip, dest, &length); + ],acx_which_osip_message_to_str=three, + acx_which_osip_message_to_str=two) +], acx_which_osip_message_to_str=no) + +if test $acx_which_osip_message_to_str = three; then + AC_DEFINE(HAVE_FUNC_OSIP_MESSAGE_TO_STR_3,, + [osip_message_to_str takes 3 arguments]) +fi + +AC_MSG_RESULT($acx_which_osip_message_to_str) + + +dnl +dnl osip_body_to_str +dnl +AC_CHECK_FUNC(osip_body_to_str, [ + AC_MSG_CHECKING(how many arguments takes osip_body_to_str) + AC_TRY_COMPILE([ + #include ], [ + osip_message_t *sip; + char **dest; + int length; + (void) osip_body_to_str(sip, dest, &length); + ],acx_which_osip_body_to_str=three, + acx_which_osip_body_to_str=two) +], acx_which_osip_body_to_str=no) + + +if test $acx_which_osip_body_to_str = three; then + AC_DEFINE(HAVE_FUNC_OSIP_BODY_TO_STR_3,, + [osip_body_to_str takes 3 arguments]) +fi + +AC_MSG_RESULT($acx_which_osip_body_to_str) + + +dnl +dnl osip_message_set_body +dnl +AC_CHECK_FUNC(osip_message_set_body, [ + AC_MSG_CHECKING(how many arguments takes osip_message_set_body) + AC_TRY_COMPILE([ + #include ], [ + osip_message_t *sip; + char **buf; + int length; + (void) osip_message_set_body(sip, buf, length); + ],acx_which_osip_message_set_body=three, + acx_which_osip_message_set_body=two) +], acx_which_osip_message_set_body=no) + + +if test $acx_which_osip_message_set_body = three; then + AC_DEFINE(HAVE_FUNC_OSIP_MESSAGE_SET_BODY_3,, + [osip_message_set_body takes 3 arguments]) +fi + +AC_MSG_RESULT($acx_which_osip_message_set_body) + + +dnl +dnl osip_message_parse +dnl +AC_CHECK_FUNC(osip_message_parse, [ + AC_MSG_CHECKING(how many arguments takes osip_message_parse) + AC_TRY_COMPILE([ + #include ], [ + osip_message_t *sip; + char **buf; + int length; + (void) osip_message_parse(sip, buf, length); + ],acx_which_osip_message_parse=three, + acx_which_osip_message_parse=two) +], acx_which_osip_message_parse=no) + + +if test $acx_which_osip_message_parse = three; then + AC_DEFINE(HAVE_FUNC_OSIP_MESSAGE_PARSE_3,, + [osip_message_parse takes 3 arguments]) +fi + +AC_MSG_RESULT($acx_which_osip_message_parse) + +])dnl ACX_WHICH_OSIP + diff --git a/config.h.in b/config.h.in index b544963..92a2c4f 100644 --- a/config.h.in +++ b/config.h.in @@ -30,6 +30,18 @@ /* gethostbyname_r takes 6 arguments */ #undef HAVE_FUNC_GETHOSTBYNAME_R_6 +/* osip_body_to_str takes 3 arguments */ +#undef HAVE_FUNC_OSIP_BODY_TO_STR_3 + +/* osip_message_parse takes 3 arguments */ +#undef HAVE_FUNC_OSIP_MESSAGE_PARSE_3 + +/* osip_message_set_body takes 3 arguments */ +#undef HAVE_FUNC_OSIP_MESSAGE_SET_BODY_3 + +/* osip_message_to_str takes 3 arguments */ +#undef HAVE_FUNC_OSIP_MESSAGE_TO_STR_3 + /* Define to 1 if you have the `getgid' function. */ #undef HAVE_GETGID diff --git a/configure.in b/configure.in index b4676e3..2259842 100644 --- a/configure.in +++ b/configure.in @@ -30,6 +30,7 @@ dnl (there seems to be a bug somewhere) dnl 18-Aug-2004 tries fli4l-uclibc -> fli4l-21-uclibc, fli4l-22-uclibc dnl 2.1.x has no pthread support, link -static dnl 2.2.x has (maybe) pthread support +dnl 09-Oct-2004 tries libosip2 compatibility >= 2.0.9 dnl dnl dnl @@ -44,7 +45,7 @@ dnl Release Version dnl SPD_MAJOR_VERSION=0 SPD_MINOR_VERSION=5 -SPD_MICRO_VERSION=8 +SPD_MICRO_VERSION=9 SPD_VERSION=$SPD_MAJOR_VERSION.$SPD_MINOR_VERSION.$SPD_MICRO_VERSION @@ -348,6 +349,12 @@ AC_CHECK_TYPE(socklen_t, dnl dnl Checks for library functions. dnl + +dnl +dnl libosip specifics: version dependencies +ACX_WHICH_OSIP() + + AC_FUNC_MEMCMP AC_FUNC_VPRINTF AC_CHECK_FUNCS(strerror) @@ -402,4 +409,5 @@ Makefile \ src/Makefile \ doc/Makefile \ scripts/Makefile \ +contrib/Makefile \ ) diff --git a/contrib/Makefile.am b/contrib/Makefile.am new file mode 100644 index 0000000..1373008 --- /dev/null +++ b/contrib/Makefile.am @@ -0,0 +1,23 @@ +# +# Copyright (C) 2002 Thomas Ries +# +# This file is part of Siproxd. +# +# Siproxd 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. +# +# Siproxd 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 Siproxd; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + + +EXTRA_DIST = siproxd.init + diff --git a/contrib/siproxd.init b/contrib/siproxd.init new file mode 100644 index 0000000..c17296d --- /dev/null +++ b/contrib/siproxd.init @@ -0,0 +1,81 @@ +#!/bin/bash +# +# /etc/rc.d/init.d/siproxd +# +# Starts the siproxd daemon +# +# chkconfig: 345 94 80 +# +# description: Listen and dispatch SIP messages +# processname: siproxd + +# Source function library. +. /etc/rc.d/init.d/functions + +[ -x /usr/sbin/siproxd ] || exit 0 + +RETVAL=0 + +# +# See how we were called. +# + +start() { + # Check if it is already running + if [ ! -f /var/lock/subsys/siproxd ]; then + echo -n $"Starting sip proxy: " + daemon /usr/sbin/siproxd + RETVAL=$? + [ $RETVAL -eq 0 ] && touch /var/lock/subsys/siproxd + echo + fi + return $RETVAL +} + +stop() { + echo -n $"Stopping sip proxy: " + killproc /usr/sbin/siproxd + RETVAL=$? + [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/siproxd + echo + return $RETVAL +} + + +restart() { + stop + start +} + +reload() { + trap "" SIGHUP + killall -HUP siproxd +} + +case "$1" in +start) + start + ;; +stop) + stop + ;; +reload) + reload + ;; +restart) + restart + ;; +condrestart) + if [ -f /var/lock/subsys/siproxd ]; then + restart + fi + ;; +status) + status siproxd + ;; +*) + echo $"Usage: $0 {start|stop|status|restart|condrestart|reload}" + exit 1 +esac + +exit $RETVAL diff --git a/siproxd.spec.in b/siproxd.spec.in index 1f40c06..ef5f09d 100644 --- a/siproxd.spec.in +++ b/siproxd.spec.in @@ -4,6 +4,9 @@ %define serial 1 %define prefix %{_prefix} %define sysconfdir /etc +%define piddir /var/run/siproxd/ +%define regdir /var/lib/siproxd/ +%define siproxduser nobody Name: %{name} Summary: A SIP masquerading proxy with RTP support @@ -48,21 +51,42 @@ make prefix=$RPM_BUILD_ROOT%{prefix} \ mv $RPM_BUILD_ROOT%{sysconfdir}/siproxd.conf.example \ $RPM_BUILD_ROOT%{sysconfdir}/siproxd.conf +install -d $RPM_BUILD_ROOT%{_initrddir}/ +install contrib/siproxd.init $RPM_BUILD_ROOT%{_initrddir}/siproxd + +install -d $RPM_BUILD_ROOT%{piddir} +install -d $RPM_BUILD_ROOT%{regdir} + + %clean rm -rf $RPM_BUILD_ROOT %files %defattr(-, root, root) %doc COPYING README AUTHORS INSTALL NEWS ChangeLog doc/FAQ doc/FLI4L_HOWTO.txt -%{_sbindir}/siproxd +%attr(0755,root,root) %{_sbindir}/siproxd %config %{sysconfdir}/siproxd.conf %config %{sysconfdir}/siproxd_passwd.cfg +%attr(0755,root,root) %{_initrddir}/siproxd + +%attr(0700,%{siproxduser},root) %{piddir} +%attr(0700,%{siproxduser},root) %{regdir} + %post echo "Edit the config file %{sysconfigdir}/siproxd.conf!" +/sbin/chkconfig --add %{name} +%preun +if [ $1 = 0 ]; then + /sbin/chkconfig --del %{name} +fi %changelog +* Fri Oct 09 2004 Thomas Ries +- startup script in /etc/rc.d/init.d/siproxd +- create directories for PID and registration files + * Fri Oct 31 2003 Thomas Ries - siproxd is now installed to sbin directory diff --git a/src/Makefile.am b/src/Makefile.am index 4005ce3..2240b41 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -28,7 +28,7 @@ sbin_PROGRAMS = siproxd siproxd_SOURCES = siproxd.c proxy.c register.c sock.c utils.c \ sip_utils.c log.c readconf.c rtpproxy.c \ rtpproxy_relay.c accessctl.c route_processing.c \ - security.c auth.c fwapi.c + security.c auth.c fwapi.c comp_osip.c # # an example for a custom firewall control module diff --git a/src/proxy.c b/src/proxy.c index 887861e..2680233 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -530,7 +530,7 @@ int proxy_request (sip_ticket_t *ticket) { * RFC 3261, Section 16.6 step 10 * Proxy Behavior - Forward the new request */ - sts = osip_message_to_str(request, &buffer); + sts = comp_osip_message_to_str(request, &buffer); if (sts != 0) { ERROR("proxy_request: osip_message_to_str failed"); return STS_FAILURE; @@ -908,7 +908,7 @@ int proxy_response (sip_ticket_t *ticket) { } } - sts = osip_message_to_str(response, &buffer); + sts = comp_osip_message_to_str(response, &buffer); if (sts != 0) { ERROR("proxy_response: osip_message_to_str failed"); return STS_FAILURE; @@ -964,7 +964,7 @@ int proxy_rewrite_invitation_body(osip_message_t *mymsg, int direction){ } } - sts = osip_body_to_str(body, &bodybuff); + sts = comp_osip_body_to_str(body, &bodybuff); sts = sdp_message_init(&sdp); sts = sdp_message_parse (sdp, bodybuff); osip_free(bodybuff); @@ -979,7 +979,7 @@ if (configuration.debuglevel) { /* just dump the buffer */ char *tmp, *tmp2; sts = osip_message_get_body(mymsg, 0, &body); - sts = osip_body_to_str(body, &tmp); + sts = comp_osip_body_to_str(body, &tmp); osip_content_length_to_str(mymsg->content_length, &tmp2); DEBUG("Body before rewrite (clen=%s, strlen=%i):\n%s\n----", tmp2, strlen(tmp), tmp); @@ -1202,7 +1202,7 @@ if (configuration.debuglevel) sdp_message_free(sdp); /* include new body */ - osip_message_set_body(mymsg, bodybuff); + comp_osip_message_set_body(mymsg, bodybuff); /* free content length resource and include new one*/ osip_content_length_free(mymsg->content_length); @@ -1217,7 +1217,7 @@ if (configuration.debuglevel) { /* just dump the buffer */ char *tmp, *tmp2; sts = osip_message_get_body(mymsg, 0, &body); - sts = osip_body_to_str(body, &tmp); + sts = comp_osip_body_to_str(body, &tmp); osip_content_length_to_str(mymsg->content_length, &tmp2); DEBUG("Body after rewrite (clen=%s, strlen=%i):\n%s\n----", tmp2, strlen(tmp), tmp); diff --git a/src/register.c b/src/register.c index e67eaac..b242c22 100644 --- a/src/register.c +++ b/src/register.c @@ -547,7 +547,7 @@ int register_response(sip_ticket_t *ticket, int flag) { } } - sts = osip_message_to_str(response, &buffer); + sts = comp_osip_message_to_str(response, &buffer); if (sts != 0) { ERROR("register_response: msg_2char failed"); return STS_FAILURE; diff --git a/src/sip_utils.c b/src/sip_utils.c index 00f73bb..7dab6a1 100644 --- a/src/sip_utils.c +++ b/src/sip_utils.c @@ -563,7 +563,7 @@ int sip_gen_response(sip_ticket_t *ticket, int code) { } } - sts = osip_message_to_str(response, &buffer); + sts = comp_osip_message_to_str(response, &buffer); if (sts != 0) { ERROR("sip_gen_response: msg_2char failed"); return STS_FAILURE; diff --git a/src/siproxd.c b/src/siproxd.c index b0dae63..9699e13 100644 --- a/src/siproxd.c +++ b/src/siproxd.c @@ -309,7 +309,7 @@ int main (int argc, char *argv[]) * Proxy Behavior - Request Validation - Reasonable Syntax * (parse the received message) */ - sts=osip_message_parse(ticket.sipmsg, buff); + sts=comp_osip_message_parse(ticket.sipmsg, buff); if (sts != 0) { ERROR("osip_message_parse() failed... this is not good"); DUMP_BUFFER(-1, buff, i); diff --git a/src/siproxd.h b/src/siproxd.h index 79a61e9..80ad6d1 100644 --- a/src/siproxd.h +++ b/src/siproxd.h @@ -153,13 +153,13 @@ int compare_url(osip_uri_t *url1, osip_uri_t *url2); /*X*/ int compare_callid(osip_call_id_t *cid1, osip_call_id_t *cid2); /*X*/ int is_sipuri_local (sip_ticket_t *ticket); /*X*/ int check_rewrite_rq_uri (osip_message_t *sip); /*X*/ -int sip_gen_response(sip_ticket_t *ticket, int code); /*X*/ +int sip_gen_response(sip_ticket_t *ticket, int code); /*X*/ #define IF_OUTBOUND 0 #define IF_INBOUND 1 int sip_add_myvia (sip_ticket_t *ticket, int interface); /*X*/ int sip_del_myvia (sip_ticket_t *ticket); /*X*/ -int sip_rewrite_contact (sip_ticket_t *ticket, int direction); /*X*/ -int sip_calculate_branch_id (sip_ticket_t *ticket, char *id); /*X*/ +int sip_rewrite_contact (sip_ticket_t *ticket, int direction); /*X*/ +int sip_calculate_branch_id (sip_ticket_t *ticket, char *id); /*X*/ /* readconf.c */ int read_config(char *name, int search); /*X*/ @@ -182,7 +182,7 @@ int security_check_sip(sip_ticket_t *ticket); /*X*/ /* auth.c */ int authenticate_proxy(sip_ticket_t *ticket); /*X*/ -int auth_include_authrq(sip_ticket_t *ticket); /*X*/ +int auth_include_authrq(sip_ticket_t *ticket); /*X*/ void CvtHex(char *hash, char *hashstring); /* fwapi.c */ @@ -193,6 +193,13 @@ int fwapi_stop_rtp(int rtp_direction, struct in_addr local_ipaddr, int local_port, struct in_addr remote_ipaddr, int remote_port); +/* osip_comp.c */ +int comp_osip_message_to_str (osip_message_t *sip, char **dest); +int comp_osip_body_to_str (const osip_body_t *body, char **dest); +int comp_osip_message_set_body(osip_message_t *sip, const char *buf); +int comp_osip_message_parse (osip_message_t *sip, const char *message); + + /* * some constant definitions */