aboutsummaryrefslogtreecommitdiffstats
path: root/net/siproxd
diff options
context:
space:
mode:
authorpav <pav@FreeBSD.org>2005-04-10 04:04:22 +0800
committerpav <pav@FreeBSD.org>2005-04-10 04:04:22 +0800
commit8f16ee4551f101a56c2474edc849e1862d53e657 (patch)
tree4598057b2ec60cde574f2b9836d471044569a7e7 /net/siproxd
parent4eb549925e92f4ce737310bdcb4ae29eef58de65 (diff)
downloadfreebsd-ports-gnome-8f16ee4551f101a56c2474edc849e1862d53e657.tar.gz
freebsd-ports-gnome-8f16ee4551f101a56c2474edc849e1862d53e657.tar.zst
freebsd-ports-gnome-8f16ee4551f101a56c2474edc849e1862d53e657.zip
- Update to 0.5.10
- Patch for libosip2-2.2.x PR: ports/79720 Submitted by: Frank W. Josellis <frank@dynamical-systems.org> (maintainer)
Diffstat (limited to 'net/siproxd')
-rw-r--r--net/siproxd/Makefile5
-rw-r--r--net/siproxd/distinfo4
-rw-r--r--net/siproxd/files/patch-doc_siproxd.conf.example4
-rw-r--r--net/siproxd/files/patch-src_proxy.c218
-rw-r--r--net/siproxd/files/patch-src_register.c145
-rw-r--r--net/siproxd/files/patch-src_sip_utilc.c154
-rw-r--r--net/siproxd/files/patch-src_siproxd.c84
-rw-r--r--net/siproxd/files/patch-src_siproxd.h80
-rw-r--r--net/siproxd/files/patch-src_utils.c60
9 files changed, 746 insertions, 8 deletions
diff --git a/net/siproxd/Makefile b/net/siproxd/Makefile
index f145ee8baf9f..20332e3ef6f6 100644
--- a/net/siproxd/Makefile
+++ b/net/siproxd/Makefile
@@ -6,8 +6,7 @@
#
PORTNAME= siproxd
-PORTVERSION= 0.5.9
-PORTREVISION= 1
+PORTVERSION= 0.5.10
CATEGORIES= net
MASTER_SITES= ${MASTER_SITE_SOURCEFORGE}
MASTER_SITE_SUBDIR= siproxd
@@ -17,8 +16,6 @@ COMMENT= A proxy/masquerading daemon for the SIP protocol
LIB_DEPENDS= osip2.3:${PORTSDIR}/net/libosip2
-BROKEN= does not compile with libosip2-2.2.0 or newer
-
USE_REINPLACE= yes
USE_GETOPT_LONG=yes
USE_RC_SUBR= yes
diff --git a/net/siproxd/distinfo b/net/siproxd/distinfo
index 8a3ab109fe05..f85097f6bfd0 100644
--- a/net/siproxd/distinfo
+++ b/net/siproxd/distinfo
@@ -1,2 +1,2 @@
-MD5 (siproxd-0.5.9.tar.gz) = 7428bc04eb8d60a5741d68190b06f10b
-SIZE (siproxd-0.5.9.tar.gz) = 198530
+MD5 (siproxd-0.5.10.tar.gz) = f7c867affe6f1c6674bf174af6c9dd32
+SIZE (siproxd-0.5.10.tar.gz) = 201888
diff --git a/net/siproxd/files/patch-doc_siproxd.conf.example b/net/siproxd/files/patch-doc_siproxd.conf.example
index bef9561bf5c6..eb3f1d7903a4 100644
--- a/net/siproxd/files/patch-doc_siproxd.conf.example
+++ b/net/siproxd/files/patch-doc_siproxd.conf.example
@@ -1,5 +1,5 @@
---- doc/siproxd.conf.example.orig Sun May 9 14:53:06 2004
-+++ doc/siproxd.conf.example Mon Oct 11 21:25:41 2004
+--- doc/siproxd.conf.example.orig Thu Dec 30 12:26:17 2004
++++ doc/siproxd.conf.example Fri Apr 8 21:02:45 2005
@@ -9,8 +9,8 @@
######################################################################
# The interface names of INBOUND and OUTBOUND interface.
diff --git a/net/siproxd/files/patch-src_proxy.c b/net/siproxd/files/patch-src_proxy.c
new file mode 100644
index 000000000000..8c9fc2f8a135
--- /dev/null
+++ b/net/siproxd/files/patch-src_proxy.c
@@ -0,0 +1,218 @@
+--- src/proxy.c.orig Mon Jan 24 20:12:40 2005
++++ src/proxy.c Sat Apr 9 16:01:02 2005
+@@ -35,7 +35,7 @@
+ #include "siproxd.h"
+ #include "log.h"
+
+-static char const ident[]="$Id: proxy.c,v 1.80 2005/01/24 19:12:40 hb9xar Exp $";
++static char const ident[]="$Id: proxy.c,v 1.85 2005/03/27 16:05:16 hb9xar Exp $";
+
+ /* configuration storage */
+ extern struct siproxd_config configuration; /* defined in siproxd.c */
+@@ -81,6 +81,7 @@
+ osip_uri_t *url;
+ int port;
+ char *buffer;
++ int buflen;
+ osip_message_t *request;
+ struct sockaddr_in *from;
+
+@@ -516,14 +517,14 @@
+ * RFC 3261, Section 16.6 step 10
+ * Proxy Behavior - Forward the new request
+ */
+- sts = osip_message_to_str(request, &buffer);
++ sts = osip_message_to_str(request, &buffer, &buflen);
+ if (sts != 0) {
+ ERROR("proxy_request: osip_message_to_str failed");
+ return STS_FAILURE;
+ }
+
+ sipsock_send(sendto_addr, port, ticket->protocol,
+- buffer, strlen(buffer));
++ buffer, buflen);
+ osip_free (buffer);
+
+ /*
+@@ -565,6 +566,7 @@
+ osip_via_t *via;
+ int port;
+ char *buffer;
++ int buflen;
+ osip_message_t *response;
+ struct sockaddr_in *from;
+
+@@ -669,8 +671,8 @@
+ (e.g 1393xxx@proxy01.sipphone.com for calls made sipphone -> FWD)
+ How can we deal with this? Should I take into consideration the 'Via'
+ headers? This is the only clue I have, pointing to the *real* UA.
+- Maybe I should put in a 'siproxd' ftag value to recognize it a header
+- put in by myself
++ 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))) {
+ osip_via_t *via;
+@@ -910,14 +912,14 @@
+ }
+ }
+
+- sts = osip_message_to_str(response, &buffer);
++ sts = osip_message_to_str(response, &buffer, &buflen);
+ if (sts != 0) {
+ ERROR("proxy_response: osip_message_to_str failed");
+ return STS_FAILURE;
+ }
+
+ sipsock_send(sendto_addr, port, ticket->protocol,
+- buffer, strlen(buffer));
++ buffer, buflen);
+ osip_free (buffer);
+ return STS_SUCCESS;
+ }
+@@ -938,6 +940,7 @@
+ struct in_addr map_addr, addr_sess, addr_media, outside_addr, inside_addr;
+ int sts;
+ char *bodybuff;
++ int bodybuflen;
+ char clen[8]; /* content length: probably never more than 7 digits !*/
+ int map_port, msg_port;
+ int media_stream_no;
+@@ -966,25 +969,31 @@
+ }
+ }
+
+- sts = osip_body_to_str(body, &bodybuff);
++ sts = osip_body_to_str(body, &bodybuff, &bodybuflen);
++ if (sts != 0) {
++ ERROR("rewrite_invitation_body: unable to osip_body_to_str");
++ }
+ sts = sdp_message_init(&sdp);
+ sts = sdp_message_parse (sdp, bodybuff);
+- osip_free(bodybuff);
+ if (sts != 0) {
+ ERROR("rewrite_invitation_body: unable to sdp_message_parse body");
++ DUMP_BUFFER(-1, bodybuff, bodybuflen);
++ osip_free(bodybuff);
+ sdp_message_free(sdp);
+ return STS_FAILURE;
+ }
++ osip_free(bodybuff);
+
+
+ if (configuration.debuglevel)
+ { /* just dump the buffer */
+ char *tmp, *tmp2;
++ int tmplen;
+ sts = osip_message_get_body(mymsg, 0, &body);
+- sts = osip_body_to_str(body, &tmp);
++ sts = osip_body_to_str(body, &tmp, &tmplen);
+ osip_content_length_to_str(mymsg->content_length, &tmp2);
+ DEBUG("Body before rewrite (clen=%s, strlen=%i):\n%s\n----",
+- tmp2, strlen(tmp), tmp);
++ tmp2, tmplen, tmp);
+ osip_free(tmp);
+ osip_free(tmp2);
+ }
+@@ -995,22 +1004,16 @@
+ */
+
+ /* get outbound address */
+- if (get_ip_by_ifname(configuration.outbound_if, &outside_addr) !=
+- STS_SUCCESS) {
+- ERROR("can't find outbound interface %s - configuration error?",
+- configuration.outbound_if);
++ if (get_interface_ip(IF_OUTBOUND, &outside_addr) != STS_SUCCESS) {
+ sdp_message_free(sdp);
+ return STS_FAILURE;
+ }
+
+ /* get inbound address */
+- if (get_ip_by_ifname(configuration.inbound_if, &inside_addr) !=
+- STS_SUCCESS) {
+- ERROR("can't find inbound interface %s - configuration error?",
+- configuration.inbound_if);
++ if (get_interface_ip(IF_INBOUND, &inside_addr) != STS_SUCCESS) {
+ sdp_message_free(sdp);
+- return STS_FAILURE;
+- }
++ return STS_FAILURE;
++ }
+
+ /* figure out what address to use for RTP masquerading */
+ if (MSG_IS_REQUEST(mymsg)) {
+@@ -1081,7 +1084,6 @@
+ * Rewrite
+ * an IP address of 0.0.0.0 means *MUTE*, don't rewrite such
+ */
+- /*&&&& should use gethostbyname here */
+ if (strcmp(sdp->c_connection->c_addr, "0.0.0.0") != 0) {
+ osip_free(sdp->c_connection->c_addr);
+ sdp->c_connection->c_addr=osip_malloc(HOSTNAME_SIZE);
+@@ -1126,7 +1128,6 @@
+ have_c_media=0;
+ sdp_conn=sdp_message_connection_get(sdp, media_stream_no, 0);
+ if (sdp_conn && sdp_conn->c_addr) {
+- /*&&&& should use gethostbyname here as well */
+ if (strcmp(sdp_conn->c_addr, "0.0.0.0") != 0) {
+ sts = get_ip_by_host(sdp_conn->c_addr, &addr_media);
+ have_c_media=1;
+@@ -1170,6 +1171,19 @@
+ memcpy(&addr_media, &addr_sess, sizeof(addr_sess));
+ }
+
++ /*
++ * Am I running in front of the routing device? Then I cannot
++ * use the external IP to bind a listen socket to, so force
++ * the use of my inbound IP for listening.
++ */
++ if ((rtp_direction == DIR_INCOMING) &&
++ (configuration.outbound_host) &&
++ (strcmp(configuration.outbound_host, "")!=0)) {
++ DEBUGC(DBCLASS_PROXY, "proxy_rewrite_invitation_body: "
++ "in-front-of-NAT-Router");
++ memcpy(&map_addr, &inside_addr, sizeof (map_addr));
++ }
++
+ sts = rtp_start_fwd(osip_message_get_call_id(mymsg),
+ client_id,
+ rtp_direction,
+@@ -1205,17 +1219,21 @@
+
+ /* dump new body */
+ sdp_message_to_str(sdp, &bodybuff);
++ bodybuflen=strlen(bodybuff);
+
+ /* free sdp structure */
+ sdp_message_free(sdp);
+
+ /* include new body */
+- osip_message_set_body(mymsg, bodybuff);
++ osip_message_set_body(mymsg, bodybuff, bodybuflen);
++ if (sts != 0) {
++ ERROR("rewrite_invitation_body: unable to osip_message_set_body body");
++ }
+
+ /* free content length resource and include new one*/
+ osip_content_length_free(mymsg->content_length);
+ mymsg->content_length=NULL;
+- sprintf(clen,"%i",strlen(bodybuff));
++ sprintf(clen,"%i",bodybuflen);
+ sts = osip_message_set_content_length(mymsg, clen);
+
+ /* free old body */
+@@ -1224,11 +1242,12 @@
+ if (configuration.debuglevel)
+ { /* just dump the buffer */
+ char *tmp, *tmp2;
++ int tmplen;
+ sts = osip_message_get_body(mymsg, 0, &body);
+- sts = osip_body_to_str(body, &tmp);
++ sts = osip_body_to_str(body, &tmp, &tmplen);
+ osip_content_length_to_str(mymsg->content_length, &tmp2);
+ DEBUG("Body after rewrite (clen=%s, strlen=%i):\n%s\n----",
+- tmp2, strlen(tmp), tmp);
++ tmp2, tmplen, tmp);
+ osip_free(tmp);
+ osip_free(tmp2);
+ }
diff --git a/net/siproxd/files/patch-src_register.c b/net/siproxd/files/patch-src_register.c
new file mode 100644
index 000000000000..df8cf92d8dde
--- /dev/null
+++ b/net/siproxd/files/patch-src_register.c
@@ -0,0 +1,145 @@
+--- src/register.c.orig Sat Jan 8 11:05:12 2005
++++ src/register.c Sat Apr 9 16:16:48 2005
+@@ -35,7 +35,7 @@
+ #include "siproxd.h"
+ #include "log.h"
+
+-static char const ident[]="$Id: register.c,v 1.46 2005/01/08 10:05:12 hb9xar Exp $";
++static char const ident[]="$Id: register.c,v 1.50 2005/04/03 20:55:30 hb9xar Exp $";
+
+ /* configuration storage */
+ extern struct siproxd_config configuration;
+@@ -255,7 +255,7 @@
+ */
+ if (expires > 0) {
+ /*
+- * First make sure, we have a prober Contact header:
++ * First make sure, we have a proper Contact header:
+ * - url
+ * - url -> hostname
+ *
+@@ -367,57 +367,56 @@
+ strlen(configuration.masked_host.string[j])+1);
+ strcpy(urlmap[i].masq_url->host, configuration.masked_host.string[j]);
+ }
+-
++ } else { /* if new entry */
++ /* This is an existing entry */
+ /*
+- * for transparent proxying: force device to be masqueraded
+- * as with the outbound IP
++ * Some phones (like BudgeTones *may* dynamically grab a SIP port
++ * so we might want to update the true_url and reg_url each time
++ * we get an REGISTER
+ */
+- if (force_lcl_masq) {
+- struct in_addr addr;
+- char *addrstr;
+-
+- if (get_ip_by_ifname(configuration.outbound_if, &addr) !=
+- STS_SUCCESS) {
+- ERROR("can't find outbound interface %s - configuration error?",
+- configuration.outbound_if);
+- return STS_FAILURE;
+- }
+-
+- /* host part */
+- addrstr = utils_inet_ntoa(addr);
+- DEBUGC(DBCLASS_REG,"masquerading UA %s@%s local %s@%s",
+- (url1_contact->username) ? url1_contact->username : "*NULL*",
+- (url1_contact->host) ? url1_contact->host : "*NULL*",
+- (url1_contact->username) ? url1_contact->username : "*NULL*",
+- addrstr);
+- urlmap[i].masq_url->host=realloc(urlmap[i].masq_url->host,
+- strlen(addrstr)+1);
+- strcpy(urlmap[i].masq_url->host, addrstr);
+
+- /* port number if required */
+- if (configuration.sip_listen_port != SIP_PORT) {
+- urlmap[i].masq_url->port=realloc(urlmap[i].masq_url->port, 16);
+- sprintf(urlmap[i].masq_url->port, "%i",
+- configuration.sip_listen_port);
+- }
+- }
+-
+- } else { /* if new entry */
+- /*
+- * Some phones (like BudgeTones *may* dynamically grab a SIP port
+- * so we might want to update the true_url and reg_url each time
+- * we get an REGISTER
+- */
+- /* Contact: field */
++ /* Contact: field (true_url) */
+ osip_uri_free(urlmap[i].true_url);
+ osip_uri_clone( ((osip_contact_t*)
+ (ticket->sipmsg->contacts->node->element))->url,
+- &urlmap[i].true_url);
+- /* To: field */
++ &urlmap[i].true_url);
++ /* To: field (reg_url) */
+ osip_uri_free(urlmap[i].reg_url);
+ osip_uri_clone( ticket->sipmsg->to->url,
+- &urlmap[i].reg_url);
++ &urlmap[i].reg_url);
+ }
++
++ /*
++ * for proxying: force device to be masqueraded
++ * as with the outbound IP (masq_url)
++ */
++ if (force_lcl_masq) {
++ struct in_addr addr;
++ char *addrstr;
++
++ if (get_interface_ip(IF_OUTBOUND, &addr) != STS_SUCCESS) {
++ return STS_FAILURE;
++ }
++
++ /* host part */
++ addrstr = utils_inet_ntoa(addr);
++ DEBUGC(DBCLASS_REG,"masquerading UA %s@%s local %s@%s",
++ (url1_contact->username) ? url1_contact->username : "*NULL*",
++ (url1_contact->host) ? url1_contact->host : "*NULL*",
++ (url1_contact->username) ? url1_contact->username : "*NULL*",
++ addrstr);
++ urlmap[i].masq_url->host=realloc(urlmap[i].masq_url->host,
++ strlen(addrstr)+1);
++ strcpy(urlmap[i].masq_url->host, addrstr);
++
++ /* port number if required */
++ if (configuration.sip_listen_port != SIP_PORT) {
++ urlmap[i].masq_url->port=realloc(urlmap[i].masq_url->port, 16);
++ sprintf(urlmap[i].masq_url->port, "%i",
++ configuration.sip_listen_port);
++ }
++ }
++
+ /* give some safety margin for the next update */
+ if (expires > 0) expires+=30;
+
+@@ -495,6 +494,7 @@
+ osip_via_t *via;
+ int port;
+ char *buffer;
++ int buflen;
+ struct in_addr addr;
+ osip_header_t *expires_hdr;
+
+@@ -550,7 +550,7 @@
+ }
+ }
+
+- sts = osip_message_to_str(response, &buffer);
++ sts = osip_message_to_str(response, &buffer, &buflen);
+ if (sts != 0) {
+ ERROR("register_response: msg_2char failed");
+ return STS_FAILURE;
+@@ -563,7 +563,7 @@
+ port=configuration.sip_listen_port;
+ }
+
+- sipsock_send(addr, port, ticket->protocol, buffer, strlen(buffer));
++ sipsock_send(addr, port, ticket->protocol, buffer, buflen);
+
+ /* free the resources */
+ osip_message_free(response);
diff --git a/net/siproxd/files/patch-src_sip_utilc.c b/net/siproxd/files/patch-src_sip_utilc.c
new file mode 100644
index 000000000000..e525def7ec5a
--- /dev/null
+++ b/net/siproxd/files/patch-src_sip_utilc.c
@@ -0,0 +1,154 @@
+--- src/sip_utils.c.orig Sat Jan 8 11:05:13 2005
++++ src/sip_utils.c Sat Apr 9 16:19:28 2005
+@@ -43,7 +43,7 @@
+ #include "rewrite_rules.h"
+ #include "log.h"
+
+-static char const ident[]="$Id: sip_utils.c,v 1.34 2005/01/08 10:05:13 hb9xar Exp $";
++static char const ident[]="$Id: sip_utils.c,v 1.37 2005/03/01 21:36:48 hb9xar Exp $";
+
+
+ /* configuration storage */
+@@ -174,11 +174,8 @@
+ int is_via_local (osip_via_t *via) {
+ int sts, found;
+ struct in_addr addr_via, addr_myself;
+- char *my_interfaces[]=
+- { configuration.inbound_if, configuration.outbound_if, (char*)-1 };
+ int port;
+ int i;
+- char *ptr;
+
+ if (via==NULL) {
+ ERROR("called is_via_local with NULL via");
+@@ -197,19 +194,14 @@
+ }
+
+ found=0;
+- for (i=0; ; i++) {
++ for (i=0; i<2; i++) {
+ /*
+- * try to search by interface name first
++ * search my in/outbound interfaces
+ */
+- ptr=my_interfaces[i];
+- if (ptr==(char*)-1) break; /* end of list mark */
+-
+- if (ptr) {
+- DEBUGC(DBCLASS_BABBLE,"resolving IP of interface %s",ptr);
+- if (get_ip_by_ifname(ptr, &addr_myself) != STS_SUCCESS) {
+- ERROR("can't find interface %s - configuration error?", ptr);
+- continue;
+- }
++ DEBUGC(DBCLASS_BABBLE,"resolving IP of interface %s",
++ (i==IF_INBOUND)? "inbound":"outbound");
++ if (get_interface_ip(i, &addr_myself) != STS_SUCCESS) {
++ continue;
+ }
+
+ /* check the extracted VIA against my own host addresses */
+@@ -390,11 +382,8 @@
+ osip_message_t *sip=ticket->sipmsg;
+ int found;
+ struct in_addr addr_uri, addr_myself;
+- char *my_interfaces[]=
+- { configuration.inbound_if, configuration.outbound_if, (char*)-1 };
+ int port;
+ int i;
+- char *ptr;
+
+ if (sip==NULL) {
+ ERROR("called is_sipuri_local with NULL sip");
+@@ -416,19 +405,14 @@
+ }
+
+ found=0;
+- for (i=0; ; i++) {
++ for (i=0; i<2; i++) {
+ /*
+- * try to search by interface name first
++ * search my in/outbound interfaces
+ */
+- ptr=my_interfaces[i];
+- if (ptr==(char*)-1) break; /* end of list mark */
+-
+- if (ptr) {
+- DEBUGC(DBCLASS_BABBLE,"resolving IP of interface %s",ptr);
+- if (get_ip_by_ifname(ptr, &addr_myself) != STS_SUCCESS) {
+- ERROR("can't find interface %s - configuration error?", ptr);
+- continue;
+- }
++ DEBUGC(DBCLASS_BABBLE,"resolving IP of interface %s",
++ (i==IF_INBOUND)? "inbound":"outbound");
++ if (get_interface_ip(i, &addr_myself) != STS_SUCCESS) {
++ continue;
+ }
+
+ /* check the extracted HOST against my own host addresses */
+@@ -533,6 +517,7 @@
+ osip_via_t *via;
+ int port;
+ char *buffer;
++ int buflen;
+ struct in_addr addr;
+
+ /* create the response template */
+@@ -563,7 +548,7 @@
+ }
+ }
+
+- sts = osip_message_to_str(response, &buffer);
++ sts = osip_message_to_str(response, &buffer, &buflen);
+ if (sts != 0) {
+ ERROR("sip_gen_response: msg_2char failed");
+ return STS_FAILURE;
+@@ -577,7 +562,7 @@
+ }
+
+ /* send to destination */
+- sipsock_send(addr, port, ticket->protocol, buffer, strlen(buffer));
++ sipsock_send(addr, port, ticket->protocol, buffer, buflen);
+
+ /* free the resources */
+ osip_message_free(response);
+@@ -601,25 +586,26 @@
+ osip_via_t *via;
+ int sts;
+ char branch_id[VIA_BRANCH_SIZE];
++ char *myaddr;
+
+- if (interface == IF_OUTBOUND) {
+- if (get_ip_by_ifname(configuration.outbound_if, &addr) != STS_SUCCESS) {
+- ERROR("can't find interface %s - configuration error?",
+- configuration.outbound_if);
+- return STS_FAILURE;
+- }
+- } else {
+- if (get_ip_by_ifname(configuration.inbound_if, &addr) != STS_SUCCESS) {
+- ERROR("can't find inbound interface %s - configuration error?",
+- configuration.inbound_if);
+- return STS_FAILURE;
+- }
++ if (get_interface_ip(interface, &addr) != STS_SUCCESS) {
++ return STS_FAILURE;
+ }
+
+ sts = sip_calculate_branch_id(ticket, branch_id);
+
+- sprintf(tmp, "SIP/2.0/UDP %s:%i;branch=%s;", utils_inet_ntoa(addr),
+- configuration.sip_listen_port, branch_id);
++ myaddr=utils_inet_ntoa(addr);
++//&&&&
++#if 0
++ sprintf(tmp, "SIP/2.0/UDP %s:%i;branch=%s;sent-by=%s:%i",
++ myaddr, configuration.sip_listen_port,
++ branch_id,
++ myaddr, configuration.sip_listen_port);
++#else
++ sprintf(tmp, "SIP/2.0/UDP %s:%i;branch=%s",
++ myaddr, configuration.sip_listen_port,
++ branch_id);
++#endif
+ DEBUGC(DBCLASS_BABBLE,"adding VIA:%s",tmp);
+
+ sts = osip_via_init(&via);
diff --git a/net/siproxd/files/patch-src_siproxd.c b/net/siproxd/files/patch-src_siproxd.c
new file mode 100644
index 000000000000..45542c7193b4
--- /dev/null
+++ b/net/siproxd/files/patch-src_siproxd.c
@@ -0,0 +1,84 @@
+--- src/siproxd.c.orig Sat Jan 8 11:41:46 2005
++++ src/siproxd.c Sat Apr 9 15:50:49 2005
+@@ -38,7 +38,7 @@
+ #include "siproxd.h"
+ #include "log.h"
+
+-static char const ident[]="$Id: siproxd.c,v 1.57 2005/01/08 10:41:46 hb9xar Exp $";
++static char const ident[]="$Id: siproxd.c,v 1.60 2005/03/01 21:36:48 hb9xar Exp $";
+
+ /* configuration storage */
+ struct siproxd_config configuration;
+@@ -82,6 +82,7 @@
+ {
+ int sts;
+ int i;
++ int buflen;
+ int access;
+ char buff [BUFFER_SIZE];
+ sip_ticket_t ticket;
+@@ -291,8 +292,9 @@
+ /* got input, process */
+ DEBUGC(DBCLASS_BABBLE,"back from sipsock_wait");
+
+- i=sipsock_read(&buff, sizeof(buff)-1, &ticket.from, &ticket.protocol);
+- buff[i]='\0';
++ buflen=sipsock_read(&buff, sizeof(buff)-1, &ticket.from,
++ &ticket.protocol);
++ buff[buflen]='\0';
+
+ /* evaluate the access lists (IP based filter)*/
+ access=accesslist_check(ticket.from);
+@@ -302,7 +304,7 @@
+ }
+
+ /* integrity checks */
+- sts=security_check_raw(buff, i);
++ sts=security_check_raw(buff, buflen);
+ if (sts != STS_SUCCESS) {
+ DEBUGC(DBCLASS_SIP,"security check (raw) failed");
+ continue; /* there are no resources to free */
+@@ -321,10 +323,10 @@
+ * Proxy Behavior - Request Validation - Reasonable Syntax
+ * (parse the received message)
+ */
+- sts=osip_message_parse(ticket.sipmsg, buff);
++ sts=osip_message_parse(ticket.sipmsg, buff, buflen);
+ if (sts != 0) {
+ ERROR("osip_message_parse() failed... this is not good");
+- DUMP_BUFFER(-1, buff, i);
++ DUMP_BUFFER(-1, buff, buflen);
+ goto end_loop; /* skip and free resources */
+ }
+
+@@ -332,7 +334,7 @@
+ sts=security_check_sip(&ticket);
+ if (sts != STS_SUCCESS) {
+ ERROR("security_check_sip() failed... this is not good");
+- DUMP_BUFFER(-1, buff, i);
++ DUMP_BUFFER(-1, buff, buflen);
+ goto end_loop; /* skip and free resources */
+ }
+
+@@ -422,10 +424,8 @@
+ dest_port= (url->port)?atoi(url->port):SIP_PORT;
+
+ if ( (get_ip_by_host(url->host, &addr1) == STS_SUCCESS) &&
+- (get_ip_by_ifname(configuration.inbound_if,&addr2) ==
+- STS_SUCCESS) &&
+- (get_ip_by_ifname(configuration.outbound_if,&addr3) ==
+- STS_SUCCESS)) {
++ (get_interface_ip(IF_INBOUND,&addr2) == STS_SUCCESS) &&
++ (get_interface_ip(IF_OUTBOUND,&addr3) == STS_SUCCESS)) {
+
+ if ((configuration.sip_listen_port == dest_port) &&
+ ((memcmp(&addr1, &addr2, sizeof(addr1)) == 0) ||
+@@ -455,7 +455,7 @@
+ * If not, send back error to UA and
+ * skip any proxying attempt
+ */
+- } else if (get_ip_by_ifname(configuration.outbound_if,NULL) !=
++ } else if (get_interface_ip(IF_OUTBOUND,NULL) !=
+ STS_SUCCESS) {
+ DEBUGC(DBCLASS_SIP, "got a %s to proxy, but outbound interface "
+ "is down", (MSG_IS_REQUEST(ticket.sipmsg))? "REQ" : "RES");
diff --git a/net/siproxd/files/patch-src_siproxd.h b/net/siproxd/files/patch-src_siproxd.h
new file mode 100644
index 000000000000..843de58c883a
--- /dev/null
+++ b/net/siproxd/files/patch-src_siproxd.h
@@ -0,0 +1,80 @@
+--- src/siproxd.h.orig Sat Jan 8 11:05:13 2005
++++ src/siproxd.h Tue Mar 1 22:36:48 2005
+@@ -18,7 +18,7 @@
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+-/* $Id: siproxd.h,v 1.48 2005/01/08 10:05:13 hb9xar Exp $ */
++/* $Id: siproxd.h,v 1.51 2005/03/01 21:36:48 hb9xar Exp $ */
+
+ #ifdef DMALLOC
+ #include <dmalloc.h>
+@@ -60,6 +60,7 @@
+ int debugport;
+ char *inbound_if;
+ char *outbound_if;
++ char *outbound_host;
+ int sip_listen_port;
+ int daemonize;
+ int silence_log;
+@@ -147,6 +148,7 @@
+ int get_ip_by_host(char *hostname, struct in_addr *addr); /*X*/
+ void secure_enviroment (void);
+ int get_ip_by_ifname(char *ifname, struct in_addr *retaddr); /*X*/
++int get_interface_ip(int interface, struct in_addr *retaddr); /*X*/
+ char *utils_inet_ntoa(struct in_addr in);
+ int utils_inet_aton(const char *cp, struct in_addr *inp);
+
+@@ -159,8 +161,6 @@
+ 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*/
+-#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*/
+@@ -176,7 +176,7 @@
+ int rtpproxy_init( void ); /*X*/
+ int rtp_start_fwd (osip_call_id_t *callid, char *client_id, /*X*/
+ int direction, int media_stream_no,
+- struct in_addr outbound_ipaddr, int *outboundport,
++ struct in_addr outbound_ipaddr, int *outboundport,
+ struct in_addr lcl_client_ipaddr, int lcl_clientport);
+ int rtp_stop_fwd (osip_call_id_t *callid, int direction); /*X*/
+ void rtpproxy_kill( void ); /*X*/
+@@ -201,6 +201,12 @@
+ struct in_addr local_ipaddr, int local_port,
+ struct in_addr remote_ipaddr, int remote_port);
+
++/* sip_layer.c */
++int sip_message_parse(osip_message_t * sip, const char *buf, int len);
++int sip_message_to_str(osip_message_t * sip, char **dest, int *len);
++int sip_body_to_str(const osip_body_t * body, char **dest, int *len);
++int sip_message_set_body(osip_message_t * sip, const char *buf, int len);
++
+
+ /*
+ * some constant definitions
+@@ -236,8 +242,8 @@
+ #define SEC_MINLEN 16 /* minimum received length */
+ #define SEC_MAXLINELEN 1024 /* maximum acceptable length of one line
+ in the SIP telegram (security check)
+- Careful: Proxy-Authorization lines may
+- get quite long */
++ Careful: Proxy-Authorization lines may
++ get quite long */
+
+ /* symbols for access control */
+ #define ACCESSCTL_SIP 1 /* for access control - SIP allowed */
+@@ -253,6 +259,10 @@
+ /* symbolic direction of data */
+ #define DIR_INCOMING 1
+ #define DIR_OUTGOING 2
++
++/* Interfaces */
++#define IF_OUTBOUND 0
++#define IF_INBOUND 1
+
+ /* various */
+ #ifndef satoi
diff --git a/net/siproxd/files/patch-src_utils.c b/net/siproxd/files/patch-src_utils.c
new file mode 100644
index 000000000000..346d40a23e73
--- /dev/null
+++ b/net/siproxd/files/patch-src_utils.c
@@ -0,0 +1,60 @@
+--- src/utils.c.orig Sat Jan 8 11:05:13 2005
++++ src/utils.c Tue Mar 1 22:36:48 2005
+@@ -44,7 +44,7 @@
+ #include "siproxd.h"
+ #include "log.h"
+
+-static char const ident[]="$Id: utils.c,v 1.41 2005/01/08 10:05:13 hb9xar Exp $";
++static char const ident[]="$Id: utils.c,v 1.42 2005/03/01 21:36:48 hb9xar Exp $";
+
+ /* configuration storage */
+ extern struct siproxd_config configuration;
+@@ -288,6 +288,48 @@
+ passwd->pw_uid, (sts==0)?"Ok":"Failed");
+ }
+ }
++}
++
++
++/*
++ * get_interface_ip:
++ * fetches own IP address by interface INBOUND/OUTBOUND
++ *
++ * STS_SUCCESS on returning a valid IP and interface is UP
++ * STS_FAILURE if interface is DOWN or other problem
++ */
++int get_interface_ip(int interface, struct in_addr *retaddr) {
++ int sts=STS_FAILURE;
++ char *tmp=NULL;
++
++ if (interface == IF_INBOUND) {
++ tmp = configuration.inbound_if;
++ } else if (interface == IF_OUTBOUND) {
++ tmp = configuration.outbound_if;
++ }
++
++ if ((interface == IF_OUTBOUND) &&
++ (configuration.outbound_host) &&
++ (strcmp(configuration.outbound_host, "")!=0)) {
++ DEBUGC(DBCLASS_DNS, "fetching outbound IP by HOSTNAME");
++ if (retaddr) {
++ sts = get_ip_by_host(configuration.outbound_host, retaddr);
++ } else {
++ sts = STS_SUCCESS;
++ }
++
++ } else if (tmp && (strcmp(tmp, "")!=0)) {
++ DEBUGC(DBCLASS_DNS, "fetching interface IP by INTERFACE [%i]", interface);
++ sts = get_ip_by_ifname(tmp, retaddr);
++ if (sts != STS_SUCCESS) {
++ ERROR("can't find interface %s - configuration error?", tmp);
++ }
++
++ } else {
++ ERROR("Don't know what interface to look for - configuration error?");
++ }
++
++ return sts;
+ }
+
+