release 0.3.2
This commit is contained in:
parent
c5fc06836a
commit
d3c28ae5bc
@ -1,5 +1,8 @@
|
||||
0.3.2
|
||||
=====
|
||||
4-Apr-2003: - introduced config option 'silence_log' - this allows
|
||||
to control how much logging is done to syslog -
|
||||
logging can even completely be switched off...
|
||||
1-Apr-2003: - should now be able to deal with an outbound interface
|
||||
that is "temporary" DOWN (dial up internet access)
|
||||
if outbounf IF is down, send back a response to
|
||||
@ -10,8 +13,12 @@
|
||||
- rtpproxy: prepared for proper thread termination on exit
|
||||
- introduced short term caching for get_ip_by_ifname
|
||||
- fixed in check for socket() return status
|
||||
- fixed bug in RTP Proxy (timeout of inactive streams)
|
||||
that produced a bunch of "ERROR:Error in close(0): Bad file
|
||||
descriptor" errors each time a RTP stream timed out
|
||||
- fixed daemonizing (libc5) - now it properly detaches
|
||||
30-May-2003: - always log ERROR, WARNING and INFO to syslog (also
|
||||
of not running as daemon)
|
||||
if not running as daemon)
|
||||
- minor corrections on ERROR printouts
|
||||
|
||||
0.3.1
|
||||
|
||||
5
TODO
5
TODO
@ -1,6 +1,11 @@
|
||||
TODOs, in random order:
|
||||
=======================
|
||||
|
||||
- siproxd daemonized: looks like clashes between threads
|
||||
- Daemonizing: daemon() f*** up a following pthread_create
|
||||
- is select() really tread safe? libc bug?
|
||||
- lost 200 ACK immediately before RTP starts...
|
||||
|
||||
- TERM handler
|
||||
|
||||
- /var/run PID file
|
||||
|
||||
@ -48,7 +48,17 @@ sip_listen_port = 5060
|
||||
######################################################################
|
||||
# Shall we daemonize?
|
||||
#
|
||||
daemonize = 0
|
||||
daemonize = 1
|
||||
|
||||
######################################################################
|
||||
# What shall I log to syslog?
|
||||
# 0 - DEBUGs, INFOs, WARNINGs and ERRORs (this is the default)
|
||||
# 1 - INFOs, WARNINGs and ERRORs
|
||||
# 2 - WARNINGs and ERRORs
|
||||
# 3 - only ERRORs
|
||||
# 4 - absolutely nothing (be careful - you will have no way to
|
||||
# see what siproxd is doing - or NOT doing)
|
||||
silence_log = 0
|
||||
|
||||
######################################################################
|
||||
# Secure Enviroment settings:
|
||||
|
||||
44
src/log.c
44
src/log.c
@ -34,8 +34,17 @@ static char const ident[]="$Id: " __FILE__ ": " PACKAGE "-" VERSION "-"\
|
||||
BUILDSTR " $";
|
||||
|
||||
|
||||
int log_to_syslog=0;
|
||||
int debug_pattern=0;
|
||||
static int log_to_syslog=0;
|
||||
static int debug_pattern=0;
|
||||
/*
|
||||
* What shall I log to syslog?
|
||||
* 0 - DEBUGs, INFOs, WARNINGs and ERRORs (this is the default)
|
||||
* 1 - INFOs, WARNINGs and ERRORs
|
||||
* 2 - WARNINGs and ERRORs
|
||||
* 3 - only ERRORs
|
||||
* 4 - absolutely nothing (be careful - you will have no way to
|
||||
*/
|
||||
static int silence_level=0;
|
||||
|
||||
|
||||
void log_set_pattern(int pattern) {
|
||||
@ -50,6 +59,11 @@ void log_set_tosyslog(int tosyslog) {
|
||||
log_to_syslog=tosyslog;
|
||||
}
|
||||
|
||||
void log_set_silence(int level) {
|
||||
silence_level=level;
|
||||
}
|
||||
|
||||
|
||||
/* for all the LOGGING routines:
|
||||
They should figure out if we are running as a daemon, then write
|
||||
their stuff to syslog or something like that
|
||||
@ -75,7 +89,7 @@ void log_debug(int class, char *file, int line, const char *format, ...) {
|
||||
tim->tm_min, tim->tm_sec, file, line);
|
||||
vfprintf(stderr, format, ap);
|
||||
fprintf(stderr,"\n");
|
||||
} else {
|
||||
} else if (silence_level < 1) {
|
||||
/* running as daemon - log via SYSLOG facility */
|
||||
vsnprintf(string, sizeof(string), format, ap);
|
||||
syslog(LOG_USER|LOG_DEBUG, "%s:%i %s", file, line, string);
|
||||
@ -104,13 +118,11 @@ void log_error(char *file, int line, const char *format, ...) {
|
||||
tim->tm_min, tim->tm_sec, file, line);
|
||||
vfprintf(stderr, format, ap);
|
||||
fprintf(stderr,"\n");
|
||||
}
|
||||
// always log INFO, WARN, ERROR to syslog
|
||||
// } else {
|
||||
} else if (silence_level < 4) {
|
||||
/* running as daemon - log via SYSLOG facility */
|
||||
vsnprintf(string, sizeof(string), format, ap);
|
||||
syslog(LOG_USER|LOG_WARNING, "%s:%i ERROR:%s", file, line, string);
|
||||
// }
|
||||
}
|
||||
|
||||
va_end(ap);
|
||||
fflush(stderr);
|
||||
@ -135,13 +147,11 @@ void log_warn(char *file, int line, const char *format, ...) {
|
||||
tim->tm_min, tim->tm_sec,file,line);
|
||||
vfprintf(stderr, format, ap);
|
||||
fprintf(stderr,"\n");
|
||||
}
|
||||
// always log INFO, WARN, ERROR to syslog
|
||||
// } else {
|
||||
} else if (silence_level < 3) {
|
||||
/* running as daemon - log via SYSLOG facility */
|
||||
vsnprintf(string, sizeof(string), format, ap);
|
||||
syslog(LOG_USER|LOG_NOTICE, "%s:%i WARNING:%s", file, line, string);
|
||||
// }
|
||||
}
|
||||
|
||||
va_end(ap);
|
||||
fflush(stderr);
|
||||
@ -166,13 +176,11 @@ void log_info(char *file, int line, const char *format, ...) {
|
||||
tim->tm_min, tim->tm_sec,file,line);
|
||||
vfprintf(stderr, format, ap);
|
||||
fprintf(stderr,"\n");
|
||||
}
|
||||
// always log INFO, WARN, ERROR to syslog
|
||||
// } else {
|
||||
} else if (silence_level < 2) {
|
||||
/* running as daemon - log via SYSLOG facility */
|
||||
vsnprintf(string, sizeof(string), format, ap);
|
||||
syslog(LOG_USER|LOG_NOTICE, "%s:%i INFO:%s", file, line, string);
|
||||
// }
|
||||
}
|
||||
|
||||
va_end(ap);
|
||||
fflush(stderr);
|
||||
@ -190,11 +198,7 @@ void log_dump_buffer(int class, char *file, int line,
|
||||
if (log_to_syslog) return;
|
||||
|
||||
fprintf(stderr,"---BUFFER DUMP follows---\n");
|
||||
/*
|
||||
for (i=0;i<length;i++) {
|
||||
fprintf(stderr,"%c",buffer[i]);
|
||||
}
|
||||
*/
|
||||
|
||||
for (i=0; i<length; i+=16) {
|
||||
strcpy(tmplin1,"");
|
||||
strcpy(tmplin2,"");
|
||||
|
||||
@ -37,6 +37,7 @@
|
||||
void log_set_pattern(int pattern);
|
||||
int log_get_pattern(void);
|
||||
void log_set_tosyslog(int tosyslog);
|
||||
void log_set_silence(int level);
|
||||
|
||||
#undef DEBUG
|
||||
#define DEBUG(F...) log_debug(1,__FILE__, __LINE__,F)
|
||||
|
||||
@ -165,6 +165,10 @@ int proxy_request (sip_t *request) {
|
||||
|
||||
/* if this is CANCEL/BYE request, stop RTP proxying */
|
||||
if (MSG_IS_BYE(request) || MSG_IS_CANCEL(request)) {
|
||||
#ifdef MODEDEBUG /*&&&&*/
|
||||
INFO("stopping RTP proxy stream for: %s@%s",
|
||||
msg_getcall_id(request)->number, msg_getcall_id(request)->host);
|
||||
#endif
|
||||
/* stop the RTP proxying stream */
|
||||
rtp_stop_fwd(msg_getcall_id(request), 0);
|
||||
}
|
||||
|
||||
@ -130,6 +130,7 @@ static int parse_config (FILE *configfile) {
|
||||
{ "debug_level", TYP_INT4, &configuration.debuglevel },
|
||||
{ "sip_listen_port", TYP_INT4, &configuration.sip_listen_port },
|
||||
{ "daemonize", TYP_INT4, &configuration.daemonize },
|
||||
{ "silence_log", TYP_INT4, &configuration.silence_log },
|
||||
{ "if_inbound", TYP_STRING, &configuration.inbound_if },
|
||||
{ "if_outbound", TYP_STRING, &configuration.outbound_if },
|
||||
{ "rtp_port_low", TYP_INT4, &configuration.rtp_port_low },
|
||||
|
||||
@ -72,8 +72,8 @@ struct {
|
||||
pthread_t rtpproxy_tid=0;
|
||||
|
||||
/* master fd_set */
|
||||
fd_set master_fdset;
|
||||
int master_fd_max;
|
||||
static fd_set master_fdset;
|
||||
static int master_fd_max;
|
||||
|
||||
/* forward declarations */
|
||||
void *rtpproxy_main(void *i);
|
||||
@ -110,8 +110,8 @@ int rtpproxy_init( void ) {
|
||||
DEBUGC(DBCLASS_RTP,"created, sts=%i", sts);
|
||||
|
||||
#if 0 /* don't detach */
|
||||
sts=pthread_detach(rtpproxy_tid);
|
||||
DEBUGC(DBCLASS_RTP,"detached, sts=%i", sts);
|
||||
// sts=pthread_detach(rtpproxy_tid);
|
||||
// DEBUGC(DBCLASS_RTP,"detached, sts=%i", sts);
|
||||
#endif
|
||||
|
||||
return STS_SUCCESS;
|
||||
@ -173,8 +173,8 @@ void *rtpproxy_main(void *arg) {
|
||||
} /* for i */
|
||||
|
||||
|
||||
/* age and clean rtp_proxytable */
|
||||
if (t > (last_t+configuration.rtp_timeout) ) {
|
||||
/* age and clean rtp_proxytable (check every 10 seconds)*/
|
||||
if (t > (last_t+10) ) {
|
||||
last_t = t;
|
||||
for (i=0;i<RTPPROXY_SIZE; i++) {
|
||||
if ( (rtp_proxytable[i].sock != 0) &&
|
||||
@ -182,6 +182,11 @@ void *rtpproxy_main(void *arg) {
|
||||
/* time one has expired, clean it up */
|
||||
callid.number=rtp_proxytable[i].callid_number;
|
||||
callid.host=rtp_proxytable[i].callid_host;
|
||||
#ifdef MODEDEBUG /*&&&&*/
|
||||
INFO("RTP stream sock=%i %s@%s (idx=%i) "
|
||||
"has expired", rtp_proxytable[i].sock,
|
||||
callid.number, callid.host, i);
|
||||
#endif
|
||||
DEBUGC(DBCLASS_RTP,"RTP stream sock=%i %s@%s (idx=%i) "
|
||||
"has expired", rtp_proxytable[i].sock,
|
||||
callid.number, callid.host, i);
|
||||
@ -234,6 +239,10 @@ int rtp_start_fwd (call_id_t *callid, int media_stream_no,
|
||||
return STS_FAILURE;
|
||||
}
|
||||
|
||||
#ifdef MODEDEBUG /*&&&&*/
|
||||
INFO("starting RTP proxy stream for: %s@%s #=%i",
|
||||
callid->number, callid->host, media_stream_no);
|
||||
#endif
|
||||
DEBUGC(DBCLASS_RTP,"starting RTP proxy stream for: %s@%s #=%i",
|
||||
callid->number, callid->host, media_stream_no);
|
||||
|
||||
@ -393,7 +402,7 @@ int rtp_stop_fwd (call_id_t *callid, int nolock) {
|
||||
int i, sts;
|
||||
int retsts=STS_SUCCESS;
|
||||
int got_match=0;
|
||||
|
||||
|
||||
if (configuration.rtp_proxy_enable == 0) return STS_SUCCESS;
|
||||
|
||||
if (callid == NULL) {
|
||||
@ -401,6 +410,10 @@ int rtp_stop_fwd (call_id_t *callid, int nolock) {
|
||||
return STS_FAILURE;
|
||||
}
|
||||
|
||||
#ifdef MODEDEBUG /*&&&&*/
|
||||
INFO("stopping RTP proxy stream for: %s@%s",
|
||||
callid->number, callid->host);
|
||||
#endif
|
||||
DEBUGC(DBCLASS_RTP,"stopping RTP proxy stream for: %s@%s",
|
||||
callid->number, callid->host);
|
||||
|
||||
@ -428,14 +441,18 @@ int rtp_stop_fwd (call_id_t *callid, int nolock) {
|
||||
* media strema active for the same callid (audio + video stream)
|
||||
*/
|
||||
for (i=0; i<RTPPROXY_SIZE; i++) {
|
||||
if((strcmp(rtp_proxytable[i].callid_number, callid->number)==0) &&
|
||||
if ((callid->number==NULL) && (callid->host==NULL)) break;
|
||||
if( rtp_proxytable[i].sock &&
|
||||
(strcmp(rtp_proxytable[i].callid_number, callid->number)==0) &&
|
||||
(strcmp(rtp_proxytable[i].callid_host, callid->host)==0) ) {
|
||||
|
||||
/* match: close socket and clean slot in rtp_proxytable */
|
||||
sts = close(rtp_proxytable[i].sock);
|
||||
if (sts < 0) {
|
||||
ERROR("Error in close(%i): %s\n", rtp_proxytable[i].sock,
|
||||
strerror(errno));
|
||||
ERROR("Error in close(%i): %s nolock=%i %s:%s\n",
|
||||
rtp_proxytable[i].sock,
|
||||
strerror(errno), nolock,
|
||||
callid->number, callid->host);
|
||||
}
|
||||
|
||||
DEBUGC(DBCLASS_RTP,"closing socket %i for RTP stream "
|
||||
|
||||
@ -256,9 +256,9 @@ int compare_url(url_t *url1, url_t *url2) {
|
||||
/* Broken(?) MSN messenger - does not supply a user name part.
|
||||
So we simply compare the host part then */
|
||||
if ((url1->username == NULL) || (url2->username == NULL)) {
|
||||
// let's be nice to Billy boy and don't complain evey time ;-)
|
||||
/* let's be nice to Billy boy and don't complain evey time ;-)
|
||||
// WARN("compare_url: NULL username pointer: MSN messenger is known to "
|
||||
// "trigger this one!");
|
||||
// "trigger this one!"); */
|
||||
DEBUGC(DBCLASS_DNS, "comparing broken urls (no user): "
|
||||
"%s[%s] -> %s[%s]",
|
||||
url1->host, inet_ntoa(addr1), url2->host, inet_ntoa(addr2));
|
||||
|
||||
@ -130,9 +130,6 @@ int main (int argc, char *argv[])
|
||||
* Init stuff
|
||||
*/
|
||||
|
||||
/* cancel RTP thread at exit */
|
||||
atexit(rtpproxy_kill);
|
||||
|
||||
/* read the config file */
|
||||
if (read_config(configfile, config_search) == STS_FAILURE) exit(1);
|
||||
|
||||
@ -148,6 +145,36 @@ int main (int argc, char *argv[])
|
||||
/* change user and group IDs */
|
||||
secure_enviroment();
|
||||
|
||||
/* daemonize if requested to */
|
||||
if (configuration.daemonize) {
|
||||
DEBUGC(DBCLASS_CONFIG,"daemonizing");
|
||||
/* daemon() seems to be broken! starting the threads afterwards
|
||||
with pthread_create will get stuck... */
|
||||
#if HAVE_DAEMONxxSICK
|
||||
if (daemon(1,0) == -1) {
|
||||
ERROR("unable to daemonize: %s", strerror(errno));
|
||||
};
|
||||
# else
|
||||
if (fork()!=0) exit(0);
|
||||
setsid();
|
||||
if (fork()!=0) exit(0);
|
||||
#endif
|
||||
log_set_tosyslog(1);
|
||||
}
|
||||
#ifdef MODEDEBUG /*&&&&*/
|
||||
INFO("daemonizing done (pid=%i)", getpid());
|
||||
#endif
|
||||
|
||||
/* initialize the RTP proxy thread */
|
||||
#ifdef MODEDEBUG /*&&&&*/
|
||||
INFO("b4 rtpproxy_init");
|
||||
#endif
|
||||
atexit(rtpproxy_kill); /* cancel RTP thread at exit */
|
||||
rtpproxy_init();
|
||||
#ifdef MODEDEBUG /*&&&&*/
|
||||
INFO("rtpproxy_init done");
|
||||
#endif
|
||||
|
||||
/* init the oSIP parser */
|
||||
parser_init();
|
||||
|
||||
@ -159,30 +186,18 @@ int main (int argc, char *argv[])
|
||||
if (sts == STS_FAILURE) {
|
||||
/* failure to allocate SIP socket... */
|
||||
ERROR("unable to bind to SIP listening socket - aborting");
|
||||
return 0;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* initialize the RTP proxy thread */
|
||||
rtpproxy_init();
|
||||
|
||||
/* daemonize if requested to */
|
||||
if (configuration.daemonize) {
|
||||
DEBUGC(DBCLASS_CONFIG,"daemonizing");
|
||||
#if HAVE_DAEMON
|
||||
if (daemon(1,0) == -1) {
|
||||
ERROR("unable to daemonize: %s", strerror(errno));
|
||||
};
|
||||
# else
|
||||
|
||||
if (fork()!=0) exit(0);
|
||||
/* close STDIN, STDOUT, STDERR */
|
||||
close(0);close(1);close(2);
|
||||
#ifdef MODEDEBUG /*&&&&*/
|
||||
INFO("sipsock_listen done");
|
||||
#endif
|
||||
log_set_tosyslog(1);
|
||||
}
|
||||
|
||||
|
||||
INFO(PACKAGE"-"VERSION"-"BUILDSTR" ("LIBOSIPVER") started");
|
||||
/*
|
||||
* silence the log - if so required...
|
||||
*/
|
||||
log_set_silence(configuration.silence_log);
|
||||
|
||||
/*
|
||||
* Main loop
|
||||
*/
|
||||
@ -199,6 +214,12 @@ int main (int argc, char *argv[])
|
||||
|
||||
i=sipsock_read(&buff, sizeof(buff), &from);
|
||||
|
||||
#ifdef MODEDEBUG /*&&&&*/
|
||||
{char tmp[32];
|
||||
strncpy(tmp, buff, 30);
|
||||
tmp[30]='\0';
|
||||
INFO("got packet from %s [%s]", inet_ntoa(from.sin_addr), tmp);}
|
||||
#endif
|
||||
/* evaluate the access lists (IP based filter)*/
|
||||
access=accesslist_check(from);
|
||||
if (access == 0) continue; /* there are no resources to free */
|
||||
|
||||
@ -102,7 +102,7 @@ struct urlmap_s {
|
||||
|
||||
|
||||
/*
|
||||
* configuration option table
|
||||
* Array of strings - used withing configuration store
|
||||
*/
|
||||
#define CFG_STRARR_SIZE 128
|
||||
typedef struct {
|
||||
@ -110,12 +110,16 @@ typedef struct {
|
||||
char *string[CFG_STRARR_SIZE];
|
||||
} stringa_t;
|
||||
|
||||
/*
|
||||
* configuration option table
|
||||
*/
|
||||
struct siproxd_config {
|
||||
int debuglevel;
|
||||
char *inbound_if;
|
||||
char *outbound_if;
|
||||
int sip_listen_port;
|
||||
int daemonize;
|
||||
int silence_log;
|
||||
int rtp_port_low;
|
||||
int rtp_port_high;
|
||||
int rtp_timeout;
|
||||
@ -177,3 +181,5 @@ struct siproxd_config {
|
||||
Port (!!!) are kept from the SIP address given by the user.
|
||||
This issue is fixed in linphone-0.9.1pre1
|
||||
*/
|
||||
|
||||
//#define MOREDEBUG
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user