- Converting to use libosip2-3.x.x

This commit is contained in:
Thomas Ries
2008-01-19 15:51:25 +00:00
parent 37ba3bd7c0
commit 6a64b680d2
17 changed files with 416 additions and 206 deletions
+6
View File
@@ -1,3 +1,9 @@
0.7.0
=====
19-Jan-2007: - Converting to use libosip2-3.x.x
This means older libosip2 versions before 3.0.0
are no longer supported and will fail to build!
0.6.1
=====
19-Jan-2008: - Released 0.6.1
+13 -16
View File
@@ -1,8 +1,9 @@
Release Notes for siproxd-0.6.1
Release Notes for siproxd-0.7.0
===============================
Major changes since 0.6.0:
- only small corrections. Check the Changelog for details.
Major changes since 0.6.1:
- Switch to libosip2-3.x.x
NOTE that older versions of libosip2 will not longer work!
General Overview:
- SIP (RFC3261) Proxy for SIP based softphones hidden behind a
@@ -41,7 +42,7 @@ General Overview:
Requirements:
- pthreads (Linux)
- glibc2 / libc5 / uClibc
- libosip2 (2.x.x, 3.x.x not yet supported due to API changes)
- libosip2 (3.x.x)
Currently tested on:
- Fedora Core1 (Kernel 2.4.x, Glibc)
@@ -57,8 +58,8 @@ Builds on (tested by dev-team or reported to build):
(- SunOS: SunOS 5.9 )*
(- Mac OS X: Darwin 6.8 )*
* Note: As the compile farm of sourceforge.net has been discontinued the
build test possibilities are now very limited. Currently
* Note: As the compile farm of sourceforge.net has been discontinued our
building test possibilities are now very limited. Currently
no explicit testing for systems/distributions other than
Fedora (x86 architecture) are made. We'll be looking into
possibilities to perform some broader testing in future.
@@ -80,6 +81,8 @@ Reported interoperability with SIP service providers:
- Sipgate (http://www.sipgate.de)
- Stanaphone (SIP Gateway to PSTN)
- Sipcall.ch (Swiss VoIP provider)
- Ekiga
- Gizmo (actually sipphone.com)
If you have siproxd successfully running with another SIP phone
and/or service provider, please drop me a short note so I can update
@@ -96,17 +99,11 @@ distribution I'd be happy to get a short notice.
-----
md5sum siproxd-0.6.1.tar.gz: 8dcc0b29e68d495e040f867207074bc1
sha1sum 6e1353c3d9179caa7a33c6c9a7da84ea3a79d01b
Signatures for siproxd-0.7.0.tar.gz archive:
MD5 Hash:
SHA-256 Hash:
GnuPG signature for siproxd-0.6.1.tar.gz archive:
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.4 (GNU/Linux)
iD8DBQBHkhY5CfzBioe83JQRAsDzAKCRcMpCg8TnaIqty59g4XdkJtsKcwCdElTZ
S2vbyD51AeQdJqfY5hTVwMQ=
=jf1e
-----END PGP SIGNATURE-----
GnuPG signature:
GnuPG: pub 1024D/87BCDC94 2000-03-19 Thomas Ries (tries at gmx.net)
+29 -58
View File
@@ -2,7 +2,8 @@ dnl
dnl History
dnl -------
dnl before time a lot happend before start of history
dnl 13-Sep-2002 tries test for libosip2 finctions (number of args)
dnl 13-Sep-2002 tries test for libosip2 functions (number of args)
dnl 18-Dec-2007 tries test for new osip_message_t structure
dnl
dnl
dnl --------------------------------------------------------------------
@@ -304,68 +305,38 @@ AC_MSG_RESULT($acx_which_gethostname_r)
])dnl ACX_WHICH_GETHOSTBYNAME_R
dnl --------------------------------------------------------------------
dnl @synopsis ACX_WHICH_LIBOSIP
dnl @synopsis ACX_CHECK_LIBOSIP_VERSION
dnl
dnl Provides a test to determine the correct
dnl way to call libosip2
dnl Provides a test to determine the version of libosip installed.
dnl
dnl defines HAVE_FUNC_OSIP_MESSAGE_PARSE_3
dnl Fails ./configure if a version < 3.0.0
dnl
nl
AC_DEFUN([ACX_WHICH_LIBOSIP], [
dnl Actually, this is quite some guesswork as libosip2 does not include
dnl any version info in its header files. So I just look for the new data
dnl structures in osip_message_t structure.
dnl
AC_DEFUN([ACX_CHECK_LIBOSIP_VERSION], [
acx_check_libosip_version=fail
dnl -----------------------------------
AC_CHECK_FUNC(osip_message_parse, [
AC_MSG_CHECKING(how many arguments takes osip_message_parse)
AC_TRY_COMPILE([#include <osipparser2/osip_parser.h>], [
int sts;sts=osip_message_parse ( NULL, NULL, 0);
],acx_which_osip_message_parse=three, acx_which_osip_message_parse=two)
], )
if test $acx_which_osip_message_parse = three; then
AC_DEFINE(HAVE_FUNC_OSIP_MESSAGE_PARSE_3,,
[osip_message_parse takes 3 arguments])
AC_MSG_CHECKING(libosip2 version > 3.0.0)
dnl check if contacts member is a structure with nb_elt (ok) or a
dnl pointer to the structure (bad)
AC_COMPILE_IFELSE([
#include <osipparser2/osip_parser.h>
main() {
osip_message_t t;
int e;
e=t.contacts.nb_elt;
}
],acx_check_libosip_version=ok, )
if test $acx_check_libosip_version = fail; then
echo "*** ERROR: libosip2-3.x.x is required!";exit 1;
fi
AC_MSG_RESULT($acx_which_osip_message_parse)
AC_MSG_RESULT(ok)
dnl -----------------------------------
AC_CHECK_FUNC(osip_message_to_str, [
AC_MSG_CHECKING(how many arguments takes osip_message_to_str)
AC_TRY_COMPILE([#include <osipparser2/osip_parser.h>], [
int sts;sts=osip_message_to_str( NULL, NULL, NULL);
],acx_which_osip_message_to_str=three, acx_which_osip_message_to_str=two)
], )
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 -----------------------------------
AC_CHECK_FUNC(osip_body_to_str, [
AC_MSG_CHECKING(how many arguments takes osip_body_to_str)
AC_TRY_COMPILE([#include <osipparser2/osip_parser.h>], [
int sts;sts=osip_body_to_str( NULL, NULL, NULL);
],acx_which_osip_body_to_str=three, acx_which_osip_body_to_str=two)
], )
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 -----------------------------------
AC_CHECK_FUNC(osip_message_set_body, [
AC_MSG_CHECKING(how many arguments takes osip_message_set_body)
AC_TRY_COMPILE([#include <osipparser2/osip_parser.h>], [
int sts;sts=osip_message_set_body( NULL, NULL, NULL);
],acx_which_osip_message_set_body=three, acx_which_osip_message_set_body=two)
], )
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 ACX_WHICH_LIBOSIP
])dnl ACX_CHECK_LIBOSIP_VERSION
-12
View File
@@ -36,18 +36,6 @@
/* 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
+5 -4
View File
@@ -37,6 +37,7 @@ dnl 10-Apr-2005 tries check for docbook
dnl 18-Apr-2005 tries added libresolv
dnl 9-Oct-2005 tries libresolv is now included in static build
dnl 10-Jun-2007 tries test more .h files (DNS resolver related)
dnl 18-Dec-2007 tries requires libosip2-3.x.x
dnl
dnl
@@ -49,8 +50,8 @@ dnl
dnl Release Version
dnl
SPD_MAJOR_VERSION=0
SPD_MINOR_VERSION=6
SPD_MICRO_VERSION=1
SPD_MINOR_VERSION=7
SPD_MICRO_VERSION=0
SPD_VERSION=$SPD_MAJOR_VERSION.$SPD_MINOR_VERSION.$SPD_MICRO_VERSION
@@ -324,8 +325,8 @@ else
fi
fi
dnl which version of libosip2?
ACX_WHICH_LIBOSIP()
dnl correct version of libosip2?
ACX_CHECK_LIBOSIP_VERSION()
dnl
+3 -3
View File
@@ -12,7 +12,7 @@ Name: %{name}
Summary: A SIP masquerading proxy with RTP support
Version: %{ver}
Release: %{release}
License: GPL, (c) 2002-2007 Thomas Ries
License: GPL, (c) 2002-2008 Thomas Ries
Group: Applications/Communications
Source0: %{name}-%{ver}.tar.gz
@@ -20,8 +20,8 @@ URL: http://siproxd.sourceforge.net/
BuildRoot: %{_tmppath}/%{name}-%{ver}-root
Docdir: %{_docdir}
Requires: libosip2 >= 2.0.2
BuildRequires: libosip2 >= 2.0.2
Requires: libosip2 >= 3.0.0
BuildRequires: libosip2 >= 3.0.0
Vendor: Thomas Ries
+230
View File
@@ -0,0 +1,230 @@
/*
Copyright (C) 2005 Hans Carlos Hofmann <carlos@hchs.de>
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
*/
#include "config.h"
#include <sys/types.h>
#include <netinet/in.h>
#include <string.h>
#include <osipparser2/osip_parser.h>
#include "siproxd.h"
#include "log.h"
#include "addrcache.h"
typedef struct
{
osip_message_t *sipmsg;
int direction;
int channel;
struct sockaddr_in source;
int lastused;
} addrcache_t ;
/*
* count the request's
*/
static int tacount;
/*
* table to remember the sources
*/
static addrcache_t cachetable[SOURCECACHE_SIZE];
/*
* We caching the address as function of from and to header to
* find the correct path where to send the sip-responses
*/
/*
* initialize internal variables
*/
int adr_cache_init(void)
{
tacount = 1 ;
memset(&cachetable, 0, sizeof(cachetable));
return STS_SUCCESS;
}
int my_cseq_match (osip_cseq_t * cseq1, osip_cseq_t * cseq2)
{
if (cseq1 == NULL || cseq2 == NULL) return -1;
if (cseq1->number == NULL || cseq2->number == NULL ||
cseq1->method == NULL || cseq2->method == NULL) return -1 ;
if (0 != strcmp (cseq1->number, cseq2->number)) return -1 ;
if (0 != strcmp (cseq1->method, cseq2->method)) return -1 ;
return 0;
}
/*
* We seek for an existing entry
* if not found, we return a suggest which entry shoud be overwritten
*/
int seek_for_entry (osip_message_t *sipmsg, addrcache_t **entry_out)
{
int i;
addrcache_t *entry;
addrcache_t *suggest;
for (suggest=entry=&cachetable[0],i=0;i<SOURCECACHE_SIZE;i++,entry++)
{
if (entry->sipmsg)
{
if ((0 == osip_call_id_match (sipmsg->call_id, entry->sipmsg->call_id)) &&
(0 == osip_from_tag_match (sipmsg->from,entry->sipmsg->from)) &&
(0 == my_cseq_match (sipmsg->cseq, sipmsg->cseq)) )
{
int level = 0 ;
int isequal = 1 ;
osip_via_t *via1;
osip_via_t *via2;
while ( isequal &&
(level == 0 || entry->direction == DIR_INCOMING) &&
!osip_list_eol (sipmsg->vias, level) &&
!osip_list_eol (entry->sipmsg->vias, level) &&
(via1 = (osip_via_t *) osip_list_get (sipmsg->vias, level)) &&
(via2 = (osip_via_t *) osip_list_get (entry->sipmsg->vias, level)) &&
(level < 70))
{
/*
* This must be, because of legal loop backs in case of
* calling one party behind this prox from behind this
* proxy :-/
*/
osip_generic_param_t *branch ;
char *branch_value = "\0";
char *branch_compare = "\0";
osip_via_param_get_byname (via1, "branch", &branch);
if (branch && branch->gvalue) branch_value = branch->gvalue ;
osip_via_param_get_byname (via2, "branch", &branch);
if (branch && branch->gvalue) branch_compare = branch->gvalue ;
if (0 != strcmp(branch_value,branch_compare)) isequal = 0 ;
level ++ ;
} ;
if (isequal &&
osip_list_eol (sipmsg->vias, level) &&
(osip_list_eol (entry->sipmsg->vias, level) ||
entry->direction == DIR_OUTGOING ) )
{
*entry_out = entry ;
return STS_SUCCESS;
}
}
if (suggest->lastused > entry->lastused)
{
suggest = entry ;
} ;
}
else
{
suggest = entry ;
suggest->lastused = 0 ;
} ;
} ;
*entry_out = suggest ;
return STS_FAILURE ;
}
int store_address (osip_message_t *sipmsg, int direction, int channel, const struct sockaddr_in *source)
{
int sts;
addrcache_t *entry;
sts = seek_for_entry (sipmsg,&entry) ;
if (entry->sipmsg)
{
osip_message_free (entry->sipmsg) ;
entry->sipmsg = NULL ;
} ;
if (osip_message_clone (sipmsg,&(entry->sipmsg)))
{
entry->sipmsg = NULL ;
return STS_FAILURE ;
} ;
entry->lastused = tacount ++ ;
entry->direction = direction ;
entry->channel = channel ;
memcpy(&(entry->source), source, sizeof (*source));
return STS_SUCCESS;
}
int load_address (osip_message_t *sipmsg, osip_message_t ** initsipmsg,
int *direction, int *channel, struct sockaddr_in *source)
{
int sts;
addrcache_t *entry;
sts = seek_for_entry (sipmsg,&entry) ;
if (sts == STS_FAILURE)
{
return STS_FAILURE ;
} ;
*initsipmsg = entry->sipmsg ;
*direction = entry->direction ;
*channel = entry->channel ;
memcpy(source, &(entry->source), sizeof (*source));
return STS_SUCCESS;
}
/*
not yet used:
int adr_cache_kill(void)
{
int i;
addrcache_t *entry;
for (entry=&cachetable[0],i=0;i<SOURCECACHE_SIZE;i++,entry++)
{
if (entry->sipmsg)
{
osip_message_free (entry->sipmsg) ;
entry->sipmsg = NULL ;
} ;
} ;
return STS_SUCCESS;
}
*/
+46
View File
@@ -0,0 +1,46 @@
/*
Copyright (C) 2005 Hans Carlos Hofmann <carlos@hchs.de>
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
*/
#ifndef ADDRCACHE_H
#define ADDRCACHE_H 1
#include <sys/types.h>
#include <netinet/in.h>
#include <osipparser2/osip_parser.h>
/*
* We caching the address as function of from and to header to
* find the correct path where to send the sip-responses
*/
int adr_cache_init(void);
int store_address (osip_message_t *sipmsg, int direction, int channel, const struct sockaddr_in *source);
int load_address (osip_message_t *sipmsg, osip_message_t ** initsipmsg,
int *direction, int *channel, struct sockaddr_in *source);
/* not used: int adr_cache_kill(void);*/
#endif
+1 -1
View File
@@ -112,7 +112,7 @@ int auth_include_authrq(osip_message_t *sipmsg) {
return STS_FAILURE;
}
osip_list_add (sipmsg->proxy_authenticates, p_auth, -1);
osip_list_add (&(sipmsg->proxy_authenticates), p_auth, -1);
DEBUGC(DBCLASS_AUTH,"added authentication header");
+2 -2
View File
@@ -329,7 +329,7 @@ void log_warn(char *file, int line, const char *format, ...) {
output_to_syslog("WARNING:", LOG_NOTICE, ap, file, line, format);
}
output_to_TCP("WARNING", ap, file, line, format);
output_to_TCP("WARNING:", ap, file, line, format);
pthread_mutex_unlock(&log_mutex);
va_end(ap);
@@ -348,7 +348,7 @@ void log_info(char *file, int line, const char *format, ...) {
output_to_syslog("INFO:", LOG_NOTICE, ap, file, line, format);
}
output_to_TCP("INFO", ap, file, line, format);
output_to_TCP("INFO:", ap, file, line, format);
pthread_mutex_unlock(&log_mutex);
va_end(ap);
+3 -2
View File
@@ -21,6 +21,7 @@
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <netinet/in.h>
@@ -127,7 +128,7 @@ static int plugin_shortdial_redirect(sip_ticket_t *ticket, int shortcut_no) {
for (i=0; (contact != NULL) || (i == 0); i++) {
osip_message_get_contact(ticket->sipmsg, 0, &contact);
if (contact) {
osip_list_remove(ticket->sipmsg->contacts,0);
osip_list_remove(&(ticket->sipmsg->contacts),0);
osip_contact_free(contact);
}
} /* for i */
@@ -139,7 +140,7 @@ static int plugin_shortdial_redirect(sip_ticket_t *ticket, int shortcut_no) {
contact->url->username=osip_malloc(len);
strcpy(contact->url->username, new_to_user);
osip_list_add(ticket->sipmsg->contacts,contact,0);
osip_list_add(&(ticket->sipmsg->contacts),contact,0);
/* sent redirect message back to local client */
sip_gen_response(ticket, 302 /*Moved temporarily*/);
+8 -8
View File
@@ -125,7 +125,7 @@ int proxy_request (sip_ticket_t *ticket) {
if (request->from->url) {
from_url = request->from->url;
} else {
from_url = (osip_uri_t *)osip_list_get(request->contacts, 0);
from_url = (osip_uri_t *)osip_list_get(&(request->contacts), 0);
}
to_url = request->to->url;
@@ -397,7 +397,7 @@ sts=sip_obscure_callid(ticket);
* If so, fetch address from topmost Route: header and remove it.
*/
} else if ((type == REQTYP_OUTGOING) &&
(request->routes && !osip_list_eol(request->routes, 0))) {
(!osip_list_eol(&(request->routes), 0))) {
sts=route_determine_nexthop(ticket, &sendto_addr, &port);
if (sts == STS_FAILURE) {
DEBUGC(DBCLASS_PROXY, "proxy_request: route_determine_nexthop failed");
@@ -407,7 +407,7 @@ sts=sip_obscure_callid(ticket);
utils_inet_ntoa(sendto_addr), port);
#else
if ((type == REQTYP_OUTGOING) &&
(request->routes && !osip_list_eol(request->routes, 0))) {
(!osip_list_eol(&(request->routes), 0))) {
sts=route_determine_nexthop(ticket, &sendto_addr, &port);
if (sts == STS_FAILURE) {
DEBUGC(DBCLASS_PROXY, "proxy_request: route_determine_nexthop failed");
@@ -721,7 +721,7 @@ sts=sip_obscure_callid(ticket);
* If so, fetch address from topmost Route: header and remove it.
*/
} else if ((type == RESTYP_OUTGOING) &&
(response->routes && !osip_list_eol(response->routes, 0))) {
(!osip_list_eol(&(response->routes), 0))) {
sts=route_determine_nexthop(ticket, &sendto_addr, &port);
if (sts == STS_FAILURE) {
DEBUGC(DBCLASS_PROXY, "proxy_response: route_determine_nexthop failed");
@@ -731,7 +731,7 @@ sts=sip_obscure_callid(ticket);
utils_inet_ntoa(sendto_addr), port);
#else
if ((type == RESTYP_OUTGOING) &&
(response->routes && !osip_list_eol(response->routes, 0))) {
(!osip_list_eol(&(response->routes), 0))) {
sts=route_determine_nexthop(ticket, &sendto_addr, &port);
if (sts == STS_FAILURE) {
DEBUGC(DBCLASS_PROXY, "proxy_response: route_determine_nexthop failed");
@@ -750,7 +750,7 @@ sts=sip_obscure_callid(ticket);
#endif
} else {
/* get target address and port from VIA header */
via = (osip_via_t *) osip_list_get (response->vias, 0);
via = (osip_via_t *) osip_list_get (&(response->vias), 0);
if (via == NULL) {
ERROR("proxy_response: list_get via failed");
return STS_FAILURE;
@@ -1106,7 +1106,7 @@ if (configuration.debuglevel)
if (sts == STS_SUCCESS) {
/* and rewrite the port */
sdp_med=osip_list_get(sdp->m_medias, media_stream_no);
sdp_med=osip_list_get(&(sdp->m_medias), media_stream_no);
if (sdp_med && sdp_med->m_port) {
osip_free(sdp_med->m_port);
sdp_med->m_port=osip_malloc(8); /* 5 digits, \0 + align */
@@ -1127,7 +1127,7 @@ if (configuration.debuglevel)
} /* for media_stream_no */
/* remove old body */
sts = osip_list_remove(mymsg->bodies, 0);
sts = osip_list_remove(&(mymsg->bodies), 0);
osip_body_free(body);
/* dump new body */
+7 -7
View File
@@ -135,6 +135,7 @@ void register_save(void) {
FILE *stream;
if (configuration.registrationfile) {
DEBUGC(DBCLASS_REG,"saving registration table");
/* write urlmap back to file */
stream = fopen(configuration.registrationfile, "w+");
if (!stream) {
@@ -244,7 +245,7 @@ int register_client(sip_ticket_t *ticket, int force_lcl_masq) {
* Libosip parses an:
* "Contact: *"
* the following way (Note: Display name!! and URL is NULL)
* (gdb) p *((osip_contact_t*)(sip->contacts->node->element))
* (gdb) p *((osip_contact_t*)(sip->contacts.node->element))
* $5 = {displayname = 0x8af8848 "*", url = 0x0, gen_params = 0x8af8838}
*/
@@ -282,10 +283,10 @@ int register_client(sip_ticket_t *ticket, int force_lcl_masq) {
* look for an Contact expires parameter - in case of REGISTER
* these two are equal. The Contact expires has higher priority!
*/
if (ticket->sipmsg->contacts && ticket->sipmsg->contacts->node &&
ticket->sipmsg->contacts->node->element) {
if (ticket->sipmsg->contacts.node &&
ticket->sipmsg->contacts.node->element) {
osip_contact_param_get_byname(
(osip_contact_t*) ticket->sipmsg->contacts->node->element,
(osip_contact_t*) ticket->sipmsg->contacts.node->element,
EXPIRES, &expires_param);
}
@@ -364,7 +365,7 @@ int register_client(sip_ticket_t *ticket, int force_lcl_masq) {
urlmap[i].active=1;
/* Contact: field */
osip_uri_clone( ((osip_contact_t*)
(ticket->sipmsg->contacts->node->element))->url,
(ticket->sipmsg->contacts.node->element))->url,
&urlmap[i].true_url);
/* To: field */
osip_uri_clone( ticket->sipmsg->to->url,
@@ -419,7 +420,7 @@ int register_client(sip_ticket_t *ticket, int force_lcl_masq) {
/* Contact: field (true_url) */
osip_uri_free(urlmap[i].true_url);
osip_uri_clone( ((osip_contact_t*)
(ticket->sipmsg->contacts->node->element))->url,
(ticket->sipmsg->contacts.node->element))->url,
&urlmap[i].true_url);
/* To: field (reg_url) */
osip_uri_free(urlmap[i].reg_url);
@@ -519,7 +520,6 @@ void register_agemap(void) {
/* auto-save of registration table */
if ((configuration.autosave_registrations > 0) &&
((last_save + configuration.autosave_registrations) < t)) {
DEBUGC(DBCLASS_REG,"auto-saving registration table");
register_save();
last_save = t;
}
+47 -49
View File
@@ -59,7 +59,7 @@ int route_preprocess(sip_ticket_t *ticket){
osip_route_t *route;
osip_uri_param_t *param=NULL;
if ((mymsg->routes==NULL) || (osip_list_size(mymsg->routes)<=0)) {
if (osip_list_size(&(mymsg->routes))<=0) {
DEBUGC(DBCLASS_PROXY, "route_preprocess: no Route header present");
return STS_SUCCESS;
}
@@ -96,8 +96,8 @@ int route_preprocess(sip_ticket_t *ticket){
(url->host)?url->host:"*NULL*",
(url->port)?atoi(url->port):SIP_PORT);
/* get last route in list */
last=osip_list_size(mymsg->routes)-1;
route = (osip_route_t *) osip_list_get(mymsg->routes, last);
last=osip_list_size(&(mymsg->routes))-1;
route = (osip_route_t *) osip_list_get(&(mymsg->routes), last);
DEBUGC(DBCLASS_PROXY, "moving last Route [%s@%s:%i] to URI",
(route->url->username)?route->url->username:"*NULL*",
(route->url->host)?route->url->host:"*NULL*",
@@ -118,7 +118,7 @@ int route_preprocess(sip_ticket_t *ticket){
osip_uri_clone(route->url, &(mymsg->req_uri));
/* remove from list */
osip_list_remove(mymsg->routes, last);
osip_list_remove(&(mymsg->routes), last);
osip_route_free(route);
}
} else {
@@ -133,7 +133,7 @@ int route_preprocess(sip_ticket_t *ticket){
*/
DEBUGC(DBCLASS_PROXY, "route_preprocess: checking topmost "
"Route header");
route = (osip_route_t *) osip_list_get(mymsg->routes, 0);
route = (osip_route_t *) osip_list_get(&(mymsg->routes), 0);
if ((route != NULL) && (route->url != NULL) &&
(route->url->host != NULL)) {
sts = get_ip_by_host(route->url->host, &addr1);
@@ -145,9 +145,8 @@ int route_preprocess(sip_ticket_t *ticket){
(route->url->port ?
configuration.sip_listen_port == atoi(route->url->port):
configuration.sip_listen_port == SIP_PORT)) {
osip_list_remove(mymsg->routes, 0);
osip_list_remove(&(mymsg->routes), 0);
osip_route_free(route);
/* request->routes will be freed by osip_message_free() */
DEBUGC(DBCLASS_PROXY, "removed Route header pointing to myself");
}
}
@@ -187,9 +186,9 @@ int route_postprocess(sip_ticket_t *ticket){
* header field.
*/
if (mymsg->routes && !osip_list_eol(mymsg->routes, 0)) {
if (!osip_list_eol(&(mymsg->routes), 0)) {
route = (osip_route_t *) osip_list_get(mymsg->routes, 0);
route = (osip_route_t *) osip_list_get(&(mymsg->routes), 0);
if (route->url) {
/* check for non existing lr parameter */
if (osip_uri_uparam_get_byname(route->url, "lr", &param) != 0) {
@@ -199,7 +198,7 @@ int route_postprocess(sip_ticket_t *ticket){
/* push Request URI into Route header list at the last position */
osip_route_init(&new_route);
osip_uri_clone(url, &new_route->url);
osip_list_add(mymsg->routes, new_route, -1);
osip_list_add(&(mymsg->routes), new_route, -1);
/* rewrite request URI to now topmost Route header */
DEBUGC(DBCLASS_PROXY, "Route header w/o 'lr': rewriting request "
@@ -208,7 +207,7 @@ int route_postprocess(sip_ticket_t *ticket){
url=NULL;
osip_uri_clone(route->url, &url);
/* remove first Route header from list & free */
osip_list_remove(mymsg->routes, 0);
osip_list_remove(&(mymsg->routes), 0);
osip_route_free(route);
route = NULL;
}
@@ -289,7 +288,7 @@ int route_add_recordroute(sip_ticket_t *ticket){
}
/* insert into record-route list*/
osip_list_add (mymsg->record_routes, r_route, position);
osip_list_add (&(mymsg->record_routes), r_route, position);
} else {
osip_record_route_free(r_route);
@@ -315,45 +314,44 @@ int route_purge_recordroute(sip_ticket_t *ticket){
int last, i, sts;
struct in_addr addr1, addr2, addr3;
if (mymsg->record_routes) {
last=osip_list_size(mymsg->record_routes)-1;
/* I *MUST NOT* purge any alien (non-mine) Record-Route headers,
* only the ones I've put in myself! */
if (last >= 0) {
for (i=last; i>=0; i--) {
r_route = (osip_record_route_t *)
osip_list_get(mymsg->record_routes, i);
last=osip_list_size(&(mymsg->record_routes))-1;
/* I *MUST NOT* purge any alien (non-mine) Record-Route headers,
* only the ones I've put in myself! */
if (last >= 0) {
for (i=last; i>=0; i--) {
r_route = (osip_record_route_t *)
osip_list_get(&(mymsg->record_routes), i);
/* skip empty entries */
if (r_route == NULL) continue;
if (r_route->url == NULL) continue;
if (r_route->url->host == NULL) continue;
/* skip empty entries */
if (r_route == NULL) continue;
if (r_route->url == NULL) continue;
if (r_route->url->host == NULL) continue;
/* resolve IP addresses (of RR header, inbound & outbound IF) */
sts = get_ip_by_host(r_route->url->host, &addr1);
if (get_interface_ip(IF_INBOUND, &addr2) != STS_SUCCESS) {
return STS_FAILURE;
}
if (get_interface_ip(IF_OUTBOUND, &addr3) != STS_SUCCESS) {
return STS_FAILURE;
}
/* resolve IP addresses (of RR header, inbound & outbound IF) */
sts = get_ip_by_host(r_route->url->host, &addr1);
if (get_interface_ip(IF_INBOUND, &addr2) != STS_SUCCESS) {
return STS_FAILURE;
}
if (get_interface_ip(IF_OUTBOUND, &addr3) != STS_SUCCESS) {
return STS_FAILURE;
}
/* check if my own route header? */
if ((sts == STS_SUCCESS) &&
((memcmp(&addr1, &addr2, sizeof(addr1)) == 0) ||
(memcmp(&addr1, &addr3, sizeof(addr1)) == 0)) &&
(r_route->url->port ?
configuration.sip_listen_port == atoi(r_route->url->port):
configuration.sip_listen_port == SIP_PORT)) {
/* check if my own route header? */
if ((sts == STS_SUCCESS) &&
((memcmp(&addr1, &addr2, sizeof(addr1)) == 0) ||
(memcmp(&addr1, &addr3, sizeof(addr1)) == 0)) &&
(r_route->url->port ?
configuration.sip_listen_port == atoi(r_route->url->port):
configuration.sip_listen_port == SIP_PORT)) {
osip_list_remove(&(mymsg->record_routes), i);
osip_record_route_free(r_route);
DEBUGC(DBCLASS_PROXY, "removed Record-Route header pointing "
"to myself");
}
} // for
} // if
osip_list_remove(mymsg->record_routes, i);
osip_record_route_free(r_route);
DEBUGC(DBCLASS_PROXY, "removed Record-Route header pointing "
"to myself");
}
} // for
} // if
}
return STS_SUCCESS;
}
@@ -379,10 +377,10 @@ int route_determine_nexthop(sip_ticket_t *ticket,
* If this route header does NOT have a lr parameter set, rewrite
* the SIP URI to point to the destination of the route (NOT IMPLEMENTED)
*/
if (mymsg->routes && !osip_list_eol(mymsg->routes, 0)) {
if (!osip_list_eol(&(mymsg->routes), 0)) {
/* get the destination from the Route Header */
route = (osip_route_t *) osip_list_get(mymsg->routes, 0);
route = (osip_route_t *) osip_list_get(&(mymsg->routes), 0);
if (route==NULL || route->url==NULL || route->url->host==NULL) {
DEBUGC(DBCLASS_PROXY, "route_determine_nexthop: got broken Route "
"header - discarding packet");
-6
View File
@@ -276,12 +276,6 @@ RFC 3261 SIP: Session Initiation Protocol June 2002
return STS_FAILURE;
}
/* check for existing Via: header list */
if (sip->vias==NULL) {
ERROR("security check failed: No Via Headers");
return STS_FAILURE;
}
/* TODO: still way to go here ... */
-22
View File
@@ -31,15 +31,10 @@ static char const ident[]="$Id$";
*/
int sip_message_parse(osip_message_t * sip, const char *buf, size_t len) {
#ifdef HAVE_FUNC_OSIP_MESSAGE_PARSE_3
return osip_message_parse(sip, buf, len);
#else
return osip_message_parse(sip, buf);
#endif
}
int sip_message_to_str(osip_message_t * sip, char **dest, size_t *len) {
#ifdef HAVE_FUNC_OSIP_MESSAGE_TO_STR_3
int sts;
sts = osip_message_to_str(sip, dest, len);
/*
@@ -48,16 +43,9 @@ int sip_message_to_str(osip_message_t * sip, char **dest, size_t *len) {
*/
(*dest)[*len]='\0';
return sts;
#else
int sts;
sts = osip_message_to_str(sip, dest);
*len = strlen(*dest);
return sts;
#endif
}
int sip_body_to_str(const osip_body_t * body, char **dest, size_t *len) {
#ifdef HAVE_FUNC_OSIP_BODY_TO_STR_3
int sts;
sts = osip_body_to_str(body, dest, len);
/*
@@ -66,19 +54,9 @@ int sip_body_to_str(const osip_body_t * body, char **dest, size_t *len) {
*/
(*dest)[*len]='\0';
return sts;
#else
int sts;
sts = osip_body_to_str(body, dest);
*len = strlen(*dest);
return sts;
#endif
}
int sip_message_set_body(osip_message_t * sip, const char *buf, size_t len) {
#ifdef HAVE_FUNC_OSIP_MESSAGE_SET_BODY_3
return osip_message_set_body(sip, buf, len);
#else
return osip_message_set_body(sip, buf);
#endif
}
+16 -16
View File
@@ -94,15 +94,15 @@ osip_message_t *msg_make_template_reply (sip_ticket_t *ticket, int code) {
osip_contact_t *res_contact = NULL;
osip_message_get_contact(request, 0, &req_contact);
if (req_contact) osip_contact_clone (req_contact, &res_contact);
if (res_contact) osip_list_add(response->contacts,res_contact,0);
if (res_contact) osip_list_add(&(response->contacts),res_contact,0);
}
/* via headers */
pos = 0;
while (!osip_list_eol (request->vias, pos)) {
while (!osip_list_eol (&(request->vias), pos)) {
char *tmp;
osip_via_t *via;
via = (osip_via_t *) osip_list_get (request->vias, pos);
via = (osip_via_t *) osip_list_get (&(request->vias), pos);
osip_via_to_str (via, &tmp);
osip_message_set_via (response, tmp);
@@ -153,9 +153,9 @@ int check_vialoop (sip_ticket_t *ticket) {
found_own_via=0;
pos = 1; /* for detecting a loop, don't check the first entry
as this is my own VIA! */
while (!osip_list_eol (my_msg->vias, pos)) {
while (!osip_list_eol (&(my_msg->vias), pos)) {
osip_via_t *via;
via = (osip_via_t *) osip_list_get (my_msg->vias, pos);
via = (osip_via_t *) osip_list_get (&(my_msg->vias), pos);
sts = is_via_local (via);
if (sts == STS_TRUE) found_own_via+=1;
pos++;
@@ -178,7 +178,7 @@ int check_vialoop (sip_ticket_t *ticket) {
/*
* check if a given osip_via_t is local. I.e. its address is owned
* by my inbound or outbound interface (or externally defined using
* teh host_outbound directive
* the host_outbound directive
*
* RETURNS
* STS_TRUE if the given VIA is one of my interfaces
@@ -224,9 +224,9 @@ int is_via_local (osip_via_t *via) {
}
} else {
/* check against a possible defined 'host_outbound' */
DEBUGC(DBCLASS_BABBLE,"resolving IP of interface ''host_outbound'");
/* defined? */
if (configuration.outbound_host == NULL) continue;
DEBUGC(DBCLASS_BABBLE,"resolving IP of interface 'host_outbound'");
/* lookup */
if (get_ip_by_host(configuration.outbound_host,
&addr_myself) != STS_SUCCESS) continue;
@@ -591,7 +591,7 @@ int sip_add_myvia (sip_ticket_t *ticket, int interface) {
sts = osip_via_parse(via, tmp);
if (sts!=0) return STS_FAILURE;
osip_list_add(ticket->sipmsg->vias,via,0);
osip_list_add(&(ticket->sipmsg->vias),via,0);
return STS_SUCCESS;
}
@@ -609,7 +609,7 @@ int sip_del_myvia (sip_ticket_t *ticket) {
int sts;
DEBUGC(DBCLASS_PROXY,"deleting topmost VIA");
via = osip_list_get (ticket->sipmsg->vias, 0);
via = osip_list_get (&(ticket->sipmsg->vias), 0);
if ( via == NULL ) {
ERROR("Got empty VIA list - is your UA configured properly?");
@@ -621,7 +621,7 @@ int sip_del_myvia (sip_ticket_t *ticket) {
return STS_FAILURE;
}
sts = osip_list_remove(ticket->sipmsg->vias, 0);
sts = osip_list_remove(&(ticket->sipmsg->vias), 0);
osip_via_free (via);
return STS_SUCCESS;
}
@@ -680,7 +680,7 @@ int sip_rewrite_contact (sip_ticket_t *ticket, int direction) {
}
/* remove old entry */
osip_list_remove(sip_msg->contacts,j);
osip_list_remove(&(sip_msg->contacts),j);
osip_contact_to_str(contact, &tmp);
osip_contact_free(contact);
@@ -697,7 +697,7 @@ int sip_rewrite_contact (sip_ticket_t *ticket, int direction) {
osip_uri_clone(urlmap[i].true_url, &contact->url);
}
osip_list_add(sip_msg->contacts,contact,j);
osip_list_add(&(sip_msg->contacts),contact,j);
replaced=1;
}
@@ -760,7 +760,7 @@ int sip_calculate_branch_id (sip_ticket_t *ticket, char *id) {
* If it is there, I use THIS branch parameter as input for
* our hash calculation
*/
via = osip_list_get (sip_msg->vias, 0);
via = osip_list_get (&(sip_msg->vias), 0);
if (via == NULL) {
ERROR("have a SIP message without any via header");
return STS_FAILURE;
@@ -1057,13 +1057,13 @@ int sip_find_direction(sip_ticket_t *ticket, int *urlidx) {
Maybe I should put in a 'siproxd' ftag value to recognize it as a header
inserted by myself
*/
if ((type == 0) && (!osip_list_eol(response->vias, 0))) {
if ((type == 0) && (!osip_list_eol(&(response->vias), 0))) {
osip_via_t *via;
struct in_addr addr_via, addr_myself;
int port_via, port_ua;
/* get the via address */
via = (osip_via_t *) osip_list_get (response->vias, 0);
via = (osip_via_t *) osip_list_get (&(response->vias), 0);
DEBUGC(DBCLASS_SIP, "sip_find_direction: check via [%s] for "
"registered UA",via->host);
sts=get_ip_by_host(via->host, &addr_via);
@@ -1107,7 +1107,7 @@ int sip_find_direction(sip_ticket_t *ticket, int *urlidx) {
} /* is response */
/*
* if the telegram is received from 127.0.0.1 of my inbound IP as sender,
* if the telegram is received from 127.0.0.1 use my inbound IP as sender,
* this likely is a locally REDIRECTED/DNATed (by iptables) packet.
* So it is a local UA.
* Example Scenario: