- Introduced the use of gethostbyname_r() if available. As siproxd
uses threads it probably is a very good idea (some funny things seen with Linux 2.4.18 kernel & RTP proxy - gethostbyname() did return a NULL result but has h_errno set to 0 "every fine, thanks") Future will show it this helps. - Had overlooked one inet_aton in register.c - replaced to utils_inet_aton - Fixed a compiler warning in log.c for Solaris. Siproxd now at least builds on Solaris (tested on: SunOS 5.9 sun4u sparc SUNW,Ultra-60)
This commit is contained in:
parent
ccc0401850
commit
00dfe93a0d
@ -1,5 +1,8 @@
|
|||||||
0.5.0
|
0.5.0
|
||||||
=====
|
=====
|
||||||
|
22-Nov-2003: - utils.c: use gethostbyname_r() in favor of
|
||||||
|
gethostbyname - if available (siproxd uses threads!)
|
||||||
|
- some small items & cleanup
|
||||||
19-Nov-2003: - Integrated a patch from Chris Ross:
|
19-Nov-2003: - Integrated a patch from Chris Ross:
|
||||||
* have siproxd compile on Solaris and BSD/OS (more to come)
|
* have siproxd compile on Solaris and BSD/OS (more to come)
|
||||||
* ./configure option --with-libosip-prefix
|
* ./configure option --with-libosip-prefix
|
||||||
|
|||||||
5
README
5
README
@ -60,8 +60,11 @@ PROBLEM REPORTING
|
|||||||
If you encounter problems/crashes and ask for support, please include
|
If you encounter problems/crashes and ask for support, please include
|
||||||
as much information as possible. Very helpful is a debug log that
|
as much information as possible. Very helpful is a debug log that
|
||||||
has been recorded at the time of the misbehaviour.
|
has been recorded at the time of the misbehaviour.
|
||||||
|
Also include the exact versions of the siproxd package and libosip2
|
||||||
|
that you are using. You should also include your siproxd.conf.
|
||||||
|
|
||||||
|
|
||||||
The easiest way to do this:
|
The easiest way to generate a debug log is:
|
||||||
1) make sure siproxd is not started as daemon.
|
1) make sure siproxd is not started as daemon.
|
||||||
-> 'daemonize = 0' in the config file.
|
-> 'daemonize = 0' in the config file.
|
||||||
2) start siproxd:
|
2) start siproxd:
|
||||||
|
|||||||
2
TODO
2
TODO
@ -29,7 +29,7 @@ TODOs, in random order:
|
|||||||
- feature: don't bind to 0.0.0.0 address, but only to inbound/outbound IF's
|
- feature: don't bind to 0.0.0.0 address, but only to inbound/outbound IF's
|
||||||
(defined by IFNAME)
|
(defined by IFNAME)
|
||||||
|
|
||||||
- support IPTABLES for RTP proxying
|
- support IPTABLES for RTP proxying -> use libiptc
|
||||||
|
|
||||||
- rtpproxy_masq:
|
- rtpproxy_masq:
|
||||||
RACE CONDITIONS! A slot may be timed out, even if the actual
|
RACE CONDITIONS! A slot may be timed out, even if the actual
|
||||||
|
|||||||
71
acinclude.m4
71
acinclude.m4
@ -224,3 +224,74 @@ fi
|
|||||||
|
|
||||||
])dnl ACX_PTHREAD
|
])dnl ACX_PTHREAD
|
||||||
|
|
||||||
|
dnl @synopsis ACX_WHICH_GETHOSTBYNAME_R
|
||||||
|
dnl
|
||||||
|
dnl Provides a test to determine the correct
|
||||||
|
dnl way to call gethostbyname_r
|
||||||
|
dnl
|
||||||
|
dnl defines HAVE_FUNC_GETHOSTBYNAME_R_6 if it needs 6 arguments (e.g linux)
|
||||||
|
dnl defines HAVE_FUNC_GETHOSTBYNAME_R_5 if it needs 5 arguments (e.g. solaris)
|
||||||
|
dnl defines HAVE_FUNC_GETHOSTBYNAME_R_3 if it needs 3 arguments (e.g. osf/1)
|
||||||
|
dnl
|
||||||
|
dnl if used in conjunction in gethostname.c the api demonstrated
|
||||||
|
dnl in test.c can be used regardless of which gethostbyname_r
|
||||||
|
dnl exists. These example files found at
|
||||||
|
dnl http://www.csn.ul.ie/~caolan/publink/gethostbyname_r
|
||||||
|
dnl
|
||||||
|
dnl @version $Id$
|
||||||
|
dnl @author Caolan McNamara <caolan@skynet.ie>
|
||||||
|
dnl
|
||||||
|
dnl based on David Arnold's autoconf suggestion in the threads faq
|
||||||
|
dnl
|
||||||
|
AC_DEFUN([ACX_WHICH_GETHOSTBYNAME_R], [
|
||||||
|
|
||||||
|
AC_CHECK_FUNC(gethostbyname_r, [
|
||||||
|
AC_MSG_CHECKING(how many arguments takes gethostbyname_r)
|
||||||
|
AC_TRY_COMPILE([
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <netdb.h>], [
|
||||||
|
char *name;
|
||||||
|
struct hostent *he;
|
||||||
|
struct hostent_data data;
|
||||||
|
(void) gethostbyname_r(name, he, &data);
|
||||||
|
],acx_which_gethostname_r=three, [
|
||||||
|
dnl
|
||||||
|
AC_TRY_COMPILE([
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <netdb.h>], [
|
||||||
|
char *name;
|
||||||
|
struct hostent *he, *res;
|
||||||
|
char buffer[2048];
|
||||||
|
int buflen = 2048;
|
||||||
|
int h_errnop;
|
||||||
|
(void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
|
||||||
|
],acx_which_gethostname_r=six, [
|
||||||
|
dnl
|
||||||
|
AC_TRY_COMPILE([
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <netdb.h>], [
|
||||||
|
char *name;
|
||||||
|
struct hostent *he;
|
||||||
|
char buffer[2048];
|
||||||
|
int buflen = 2048;
|
||||||
|
int h_errnop;
|
||||||
|
(void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
|
||||||
|
],acx_which_gethostname_r=five,acx_which_gethostname_r=no)
|
||||||
|
|
||||||
|
])
|
||||||
|
])
|
||||||
|
], acx_which_gethostname_r=no)
|
||||||
|
|
||||||
|
if test $acx_which_gethostname_r = six; then
|
||||||
|
AC_DEFINE(HAVE_FUNC_GETHOSTBYNAME_R_6,,[gethostbyname_r takes 6 arguments])
|
||||||
|
elif test $acx_which_gethostname_r = five; then
|
||||||
|
AC_DEFINE(HAVE_FUNC_GETHOSTBYNAME_R_5,,[gethostbyname_r takes 5 arguments])
|
||||||
|
elif test $acx_which_gethostname_r = three; then
|
||||||
|
AC_DEFINE(HAVE_FUNC_GETHOSTBYNAME_R_3,,[gethostbyname_r takes 3 arguments])
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
AC_MSG_RESULT($acx_which_gethostname_r)
|
||||||
|
|
||||||
|
])dnl ACX_WHICH_GETHOSTBYNAME_R
|
||||||
|
|
||||||
|
|||||||
12
config.h.in
12
config.h.in
@ -39,6 +39,9 @@
|
|||||||
/* Define if you have the gethostbyname function. */
|
/* Define if you have the gethostbyname function. */
|
||||||
#undef HAVE_GETHOSTBYNAME
|
#undef HAVE_GETHOSTBYNAME
|
||||||
|
|
||||||
|
/* Define if you have the gethostbyname_r function. */
|
||||||
|
#undef HAVE_GETHOSTBYNAME_R
|
||||||
|
|
||||||
/* Define if you have the getopt_long function. */
|
/* Define if you have the getopt_long function. */
|
||||||
#undef HAVE_GETOPT_LONG
|
#undef HAVE_GETOPT_LONG
|
||||||
|
|
||||||
@ -190,6 +193,15 @@
|
|||||||
/* typedef socklen_t available */
|
/* typedef socklen_t available */
|
||||||
#undef socklen_t
|
#undef socklen_t
|
||||||
|
|
||||||
|
/* gethostbyname_r takes 6 arguments */
|
||||||
|
#undef HAVE_FUNC_GETHOSTBYNAME_R_6
|
||||||
|
|
||||||
|
/* gethostbyname_r takes 5 arguments */
|
||||||
|
#undef HAVE_FUNC_GETHOSTBYNAME_R_5
|
||||||
|
|
||||||
|
/* gethostbyname_r takes 3 arguments */
|
||||||
|
#undef HAVE_FUNC_GETHOSTBYNAME_R_3
|
||||||
|
|
||||||
/* will search for config file here */
|
/* will search for config file here */
|
||||||
#undef SIPROXDCONFPATH
|
#undef SIPROXDCONFPATH
|
||||||
|
|
||||||
|
|||||||
14
configure.in
14
configure.in
@ -19,6 +19,7 @@ dnl 19-Sep-2003 tries DMALLOC support
|
|||||||
dnl 1-Nov-2003 tries check for NETFILTER (IPTABLES)
|
dnl 1-Nov-2003 tries check for NETFILTER (IPTABLES)
|
||||||
dnl 18-Nov-2003 tries include sysconfdir to search for config
|
dnl 18-Nov-2003 tries include sysconfdir to search for config
|
||||||
dnl 19-Nov-2003 tries changes to support Solaris & BSD/OS
|
dnl 19-Nov-2003 tries changes to support Solaris & BSD/OS
|
||||||
|
dnl 22-Nov-2003 tries test for gethostbyname_r() & # of args
|
||||||
dnl
|
dnl
|
||||||
dnl
|
dnl
|
||||||
dnl
|
dnl
|
||||||
@ -87,13 +88,19 @@ done
|
|||||||
dnl
|
dnl
|
||||||
dnl add
|
dnl add
|
||||||
dnl --enable-dmalloc
|
dnl --enable-dmalloc
|
||||||
AC_MSG_CHECKING("building with DMALLOC support")
|
AC_MSG_CHECKING(building with DMALLOC support)
|
||||||
AC_ARG_ENABLE(dmalloc,
|
AC_ARG_ENABLE(dmalloc,
|
||||||
[ --enable-dmalloc build with DMALLOC support],
|
[ --enable-dmalloc build with DMALLOC support],
|
||||||
CFLAGS="$CFLAGS -DDMALLOC ";LIBS="-ldmallocth $LIBS";
|
CFLAGS="$CFLAGS -DDMALLOC ";LIBS="-ldmallocth $LIBS";
|
||||||
AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
|
AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
|
||||||
|
|
||||||
|
|
||||||
|
dnl
|
||||||
|
dnl general stuff
|
||||||
|
dnl _POSIX_THREAD_SAFE_FUNCTIONS needed by some platforms to make
|
||||||
|
dnl reentrant functions available (gethostbyname_r)
|
||||||
|
CFLAGS="$CFLAGS -D_POSIX_THREAD_SAFE_FUNCTIONS"
|
||||||
|
|
||||||
dnl
|
dnl
|
||||||
dnl system specific stuff
|
dnl system specific stuff
|
||||||
dnl
|
dnl
|
||||||
@ -304,7 +311,10 @@ dnl
|
|||||||
AC_FUNC_MEMCMP
|
AC_FUNC_MEMCMP
|
||||||
AC_FUNC_VPRINTF
|
AC_FUNC_VPRINTF
|
||||||
AC_CHECK_FUNCS(strerror)
|
AC_CHECK_FUNCS(strerror)
|
||||||
AC_CHECK_FUNCS(gethostbyname)
|
|
||||||
|
AC_CHECK_FUNCS(gethostbyname gethostbyname_r)
|
||||||
|
ACX_WHICH_GETHOSTBYNAME_R()
|
||||||
|
|
||||||
AC_CHECK_FUNCS(getopt_long daemon syslog)
|
AC_CHECK_FUNCS(getopt_long daemon syslog)
|
||||||
AC_CHECK_FUNCS(getuid setuid getgid setgid getpwnam chroot)
|
AC_CHECK_FUNCS(getuid setuid getgid setgid getpwnam chroot)
|
||||||
AC_CHECK_FUNCS(socket bind select read send sendto)
|
AC_CHECK_FUNCS(socket bind select read send sendto)
|
||||||
|
|||||||
@ -205,7 +205,7 @@ void log_dump_buffer(int class, char *file, int line,
|
|||||||
for (j=0;(j<16) && (i+j)<length ;j++) {
|
for (j=0;(j<16) && (i+j)<length ;j++) {
|
||||||
sprintf(tmp,"%2.2x ",(unsigned char)buffer[i+j]);
|
sprintf(tmp,"%2.2x ",(unsigned char)buffer[i+j]);
|
||||||
strcat(tmplin1, tmp);
|
strcat(tmplin1, tmp);
|
||||||
sprintf(tmp, "%c",(isprint(buffer[i+j]))? buffer[i+j]: '.');
|
sprintf(tmp, "%c",(isprint((int)buffer[i+j]))? buffer[i+j]: '.');
|
||||||
strcat(tmplin2, tmp);
|
strcat(tmplin2, tmp);
|
||||||
}
|
}
|
||||||
fprintf(stderr, " %-47.47s %-16.16s\n",tmplin1, tmplin2);
|
fprintf(stderr, " %-47.47s %-16.16s\n",tmplin1, tmplin2);
|
||||||
|
|||||||
@ -328,7 +328,7 @@ int register_response(osip_message_t *request, int flag) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* name resolution needed? */
|
/* name resolution needed? */
|
||||||
if (inet_aton (via->host,&addr) == 0) {
|
if (utils_inet_aton(via->host,&addr) == 0) {
|
||||||
/* yes, get IP address */
|
/* yes, get IP address */
|
||||||
sts = get_ip_by_host(via->host, &addr);
|
sts = get_ip_by_host(via->host, &addr);
|
||||||
if (sts == STS_FAILURE) {
|
if (sts == STS_FAILURE) {
|
||||||
|
|||||||
@ -167,6 +167,12 @@ struct siproxd_config {
|
|||||||
#define USERNAME_SIZE 64 /* max string length of a username (auth) */
|
#define USERNAME_SIZE 64 /* max string length of a username (auth) */
|
||||||
#define PASSWORD_SIZE 64 /* max string length of a password (auth) */
|
#define PASSWORD_SIZE 64 /* max string length of a password (auth) */
|
||||||
|
|
||||||
|
/* scratch buffer for gethostbyname_r() */
|
||||||
|
#if defined(PR_NETDB_BUF_SIZE)
|
||||||
|
#define GETHOSTBYNAME_BUFLEN PR_NETDB_BUF_SIZE
|
||||||
|
#else
|
||||||
|
#define GETHOSTBYNAME_BUFLEN 1024
|
||||||
|
#endif
|
||||||
|
|
||||||
#define ACCESSCTL_SIP 1 /* for access control - SIP allowed */
|
#define ACCESSCTL_SIP 1 /* for access control - SIP allowed */
|
||||||
#define ACCESSCTL_REG 2 /* --"-- - registr. allowed */
|
#define ACCESSCTL_REG 2 /* --"-- - registr. allowed */
|
||||||
|
|||||||
44
src/utils.c
44
src/utils.c
@ -65,6 +65,7 @@ int get_ip_by_host(char *hostname, struct in_addr *addr) {
|
|||||||
int i, j;
|
int i, j;
|
||||||
time_t t;
|
time_t t;
|
||||||
struct hostent *hostentry;
|
struct hostent *hostentry;
|
||||||
|
int error;
|
||||||
static struct {
|
static struct {
|
||||||
time_t timestamp;
|
time_t timestamp;
|
||||||
struct in_addr addr;
|
struct in_addr addr;
|
||||||
@ -113,7 +114,50 @@ int get_ip_by_host(char *hostname, struct in_addr *addr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* did not find it in cache, so I have to resolve it */
|
/* did not find it in cache, so I have to resolve it */
|
||||||
|
|
||||||
|
/* need to deal with reentrant versions of gethostbyname_r()
|
||||||
|
* as we may use threads... */
|
||||||
|
#if defined(HAVE_GETHOSTBYNAME_R)
|
||||||
|
{
|
||||||
|
struct hostent result_buffer;
|
||||||
|
char tmp[GETHOSTBYNAME_BUFLEN];
|
||||||
|
|
||||||
|
/* gethostbyname_r() with 3 arguments (e.g. osf/1) */
|
||||||
|
#if defined(HAVE_FUNC_GETHOSTBYNAME_R_3)
|
||||||
|
gethostbyname_r(hostname, /* the FQDN */
|
||||||
|
&result_buffer, /* the result buffer */
|
||||||
|
&hostentry
|
||||||
|
);
|
||||||
|
if (hostentry == NULL) my_error = h_errno;
|
||||||
|
|
||||||
|
/* gethostbyname_r() with 5 arguments (e.g. solaris, linux libc5) */
|
||||||
|
#elif defined(HAVE_FUNC_GETHOSTBYNAME_R_5)
|
||||||
|
hostentry = gethostbyname_r(hostname, /* the FQDN */
|
||||||
|
&result_buffer, /* the result buffer */
|
||||||
|
tmp,
|
||||||
|
GETHOSTBYNAME_BUFLEN - 1,
|
||||||
|
&error);
|
||||||
|
|
||||||
|
/* gethostbyname_r() with 6 arguments (e.g. linux glibc) */
|
||||||
|
#elif defined(HAVE_FUNC_GETHOSTBYNAME_R_6)
|
||||||
|
gethostbyname_r(hostname, /* the FQDN */
|
||||||
|
&result_buffer, /* the result buffer */
|
||||||
|
tmp,
|
||||||
|
GETHOSTBYNAME_BUFLEN - 1,
|
||||||
|
&hostentry,
|
||||||
|
&error);
|
||||||
|
#else
|
||||||
|
#error "gethostbyname_s() with 3, 5 or 6 arguments supported only"
|
||||||
|
#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);
|
hostentry=gethostbyname(hostname);
|
||||||
|
if (hostentry == NULL) error = h_errno;
|
||||||
|
#else
|
||||||
|
#error "need gethostbyname() or gethostbyname_r()"
|
||||||
|
#endif
|
||||||
|
|
||||||
if (hostentry==NULL) {
|
if (hostentry==NULL) {
|
||||||
if (h_errno == HOST_NOT_FOUND) {
|
if (h_errno == HOST_NOT_FOUND) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user