From db2d3e22d85eb1fc6d85b300333453cb670d1750 Mon Sep 17 00:00:00 2001 From: Thomas Ries Date: Mon, 24 Nov 2003 22:58:44 +0000 Subject: [PATCH] - some fixes in sockbind() (FreeBSD) by Jeremy Shaw - added doc/devel.txt with issues to keep the code portable --- ChangeLog | 1 + doc/devel.txt | 8 ++++++++ src/rtpproxy.c | 3 --- src/rtpproxy_relay.c | 4 ++-- src/sock.c | 5 +++-- src/utils.c | 4 +--- 6 files changed, 15 insertions(+), 10 deletions(-) create mode 100644 doc/devel.txt diff --git a/ChangeLog b/ChangeLog index a7a64dd..424a848 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,6 @@ 0.5.0 ===== + 24-Nov-2003: - some fixes in sockbind() (FreeBSD) by Jeremy Shaw 23-Nov-2003: - got the gethostbyname() failure problem solved. (the resolver needs a shared lib that was tried to load AFTER chrooting...) diff --git a/doc/devel.txt b/doc/devel.txt new file mode 100644 index 0000000..5f182b1 --- /dev/null +++ b/doc/devel.txt @@ -0,0 +1,8 @@ +Portability issues: + + +FreeBSD: +- #include + before + #include + diff --git a/src/rtpproxy.c b/src/rtpproxy.c index 42338e1..7d06741 100644 --- a/src/rtpproxy.c +++ b/src/rtpproxy.c @@ -20,10 +20,7 @@ #include "config.h" -#ifdef _BSD #include -#endif - #include #include diff --git a/src/rtpproxy_relay.c b/src/rtpproxy_relay.c index e233bec..70fdcb1 100644 --- a/src/rtpproxy_relay.c +++ b/src/rtpproxy_relay.c @@ -348,8 +348,8 @@ int rtp_relay_start_fwd (osip_call_id_t *callid, int media_stream_no, port, sock, freeidx); /* found an unused port? No -> RTP port pool fully allocated */ - if (port == 0) { - ERROR("rtp_relay_start_fwd: no RTP port available. Check rtp_port_* config!"); + if ((port == 0) || (sock == 0)) { + ERROR("rtp_relay_start_fwd: no RTP port available or bind() failed"); sts = STS_FAILURE; goto unlock_and_exit; } diff --git a/src/sock.c b/src/sock.c index 9417fa7..7518009 100644 --- a/src/sock.c +++ b/src/sock.c @@ -28,7 +28,6 @@ #include #include -#include #include #include #include @@ -56,7 +55,7 @@ static int listen_socket=0; int sipsock_listen (void) { struct in_addr ipaddr; - memset(&ipaddr, 0, sizeof(struct in_addr)); + memset(&ipaddr, 0, sizeof(ipaddr)); listen_socket=sockbind(ipaddr, configuration.sip_listen_port, 1); if (listen_socket == 0) return STS_FAILURE; /* failure*/ @@ -180,6 +179,8 @@ int sockbind(struct in_addr ipaddr, int localport, int errflg) { int sts; int sock; + memset(&my_addr, 0, sizeof(my_addr)); + my_addr.sin_family = AF_INET; memcpy(&my_addr.sin_addr.s_addr, &ipaddr, sizeof(struct in_addr)); my_addr.sin_port = htons(localport); diff --git a/src/utils.c b/src/utils.c index d05f65d..3bc8595 100644 --- a/src/utils.c +++ b/src/utils.c @@ -151,8 +151,6 @@ int get_ip_by_host(char *hostname, struct in_addr *addr) { #endif } #elif defined(HAVE_GETHOSTBYNAME) - #warning "did not find reentrant version of gethostbyname_r()" - #warning "depending of your OS this may or may not work" hostentry=gethostbyname(hostname); if (hostentry == NULL) error = h_errno; #else @@ -234,7 +232,7 @@ void secure_enviroment (void) { */ if (configuration.chrootjail) { /* !!! - * Before chrooting I must at leat once trigger the resolver + * Before chrooting I must at least once trigger the resolver * as it loads some dynamic libraries. Once chrootet * these libraries will *not* be found and gethostbyname() * calls will simply fail (return NULL pointer and h_errno=0).