From dbbdd8c6168ff91aa2972c325599706576fbe6f7 Mon Sep 17 00:00:00 2001 From: Stefan Sayer Date: Fri, 15 Dec 2006 14:45:35 +0000 Subject: [PATCH] * UserAgent/Server header * Max-Forwards header (bugfix) * documentation for Signature, listen_ip, sip_port * small fix in auth (algorithm not quoted) git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@178 8eb893ce-cfd4-0310-b710-fb5ebe64c474 --- core/AmConfig.cpp | 7 +++++ core/AmConfig.h | 2 ++ core/AmRtpAudio.cpp | 5 ++-- core/AmSipDialog.cpp | 11 +++++++ core/Makefile.defs | 36 ++++++++++++++++++++--- core/plug-in/uac_auth/UACAuth.cpp | 2 +- core/sems.conf.sample | 49 ++++++++++++++++++++++++++++++- core/sems.h | 9 ++++-- 8 files changed, 110 insertions(+), 11 deletions(-) diff --git a/core/AmConfig.cpp b/core/AmConfig.cpp index 4a88296c..d6bfebc7 100644 --- a/core/AmConfig.cpp +++ b/core/AmConfig.cpp @@ -53,6 +53,7 @@ int AmConfig::RtpHighPort = RTP_HIGHPORT; int AmConfig::MediaProcessorThreads = NUM_MEDIA_PROCESSORS; int AmConfig::LocalSIPPort = 5060; string AmConfig::LocalSIPIP = ""; +string AmConfig::Signature = ""; AmSessionTimerConfig AmConfig::defaultSessionTimerConfig; @@ -175,6 +176,12 @@ int AmConfig::readConfiguration() // plugin_path PlugInPath = cfg.getParameter("plugin_path"); + // user_agent + if (cfg.getParameter("use_default_signature")=="yes") + Signature = DEFAULT_SIGNATURE; + else + Signature = cfg.getParameter("signature"); + // log_level if(cfg.hasParameter("loglevel")){ if(!setLoglevel(cfg.getParameter("loglevel"))){ diff --git a/core/AmConfig.h b/core/AmConfig.h index 17b53100..bd4fdee1 100644 --- a/core/AmConfig.h +++ b/core/AmConfig.h @@ -81,6 +81,8 @@ struct AmConfig static string LocalSIPIP; /** the port SIP requests are sent from - optional (default 5060) */ static int LocalSIPPort; + /** Server/User-Agent header (optional) */ + static string Signature; /** Init function. Resolves SMTP server address. */ static int init(); diff --git a/core/AmRtpAudio.cpp b/core/AmRtpAudio.cpp index 196e55a7..809da512 100644 --- a/core/AmRtpAudio.cpp +++ b/core/AmRtpAudio.cpp @@ -97,9 +97,8 @@ int AmRtpAudio::receive(unsigned int audio_buffer_ts) } else { - if (!last_ts_i) { - last_ts_i = true; - } + last_ts_i = true; + size = decode(size); if (size <= 0) { diff --git a/core/AmSipDialog.cpp b/core/AmSipDialog.cpp index f6a3c05e..cf2e0fa6 100644 --- a/core/AmSipDialog.cpp +++ b/core/AmSipDialog.cpp @@ -3,6 +3,7 @@ #include "AmSession.h" #include "AmUtils.h" #include "AmServer.h" +#include "sems.h" AmSipDialog::~AmSipDialog() { @@ -273,6 +274,8 @@ int AmSipDialog::reply(const AmSipRequest& req, if(!body.empty()) msg += "Content-Type: " + content_type + "\n"; + if (AmConfig::Signature.length()) + msg += "Server: " + AmConfig::Signature + "\n"; msg += ".\n"; @@ -303,6 +306,9 @@ int AmSipDialog::reply_error(const AmSipRequest& req, unsigned int code, if(!hdrs.empty()) msg += hdrs; + if (AmConfig::Signature.length()) + msg += "Server: " + AmConfig::Signature + "\n"; + msg += ".\n.\n\n"; return AmServer::send_msg(msg,reply_sock, 500); @@ -494,6 +500,11 @@ int AmSipDialog::sendRequest(const string& method, if(!body.empty()) msg += "Content-Type: " + content_type + "\n"; + msg += "Max-Forwards: " MAX_FORWARDS "\n"; + + if (AmConfig::Signature.length()) + msg += "User-Agent: " + AmConfig::Signature + "\n"; + msg += ".\n" // EoH + body + ".\n\n"; diff --git a/core/Makefile.defs b/core/Makefile.defs index d227b072..65ae7702 100644 --- a/core/Makefile.defs +++ b/core/Makefile.defs @@ -1,14 +1,42 @@ + +#version number +VERSION = 0 +PATCHLEVEL = 10 +SUBLEVEL = 0 +EXTRAVERSION = -rc2 + +RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) + +LD_FLAGS = -lm + +OS = $(shell uname -s | sed -e s/SunOS/solaris/ | tr "[A-Z]" "[a-z]") + +ifeq ($(OS),solaris) + GETARCH=uname -p +else + GETARCH=uname -m +endif + +ARCH := $(shell $(GETARCH) |sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \ + -e s/armv4l/arm/ -e "s/Power Macintosh/ppc/" \ + -e "s/cobalt/mips2/" \ + -e s/amd64/x86_64/ ) +# fix sparc -> sparc64 +ifeq ($(ARCH),sparc) + ifeq ($(shell uname -m),sun4u) + ARCH := sparc64 + endif +endif + CPP_FLAGS = -Wall -Wno-reorder -fPIC -g \ -O2 \ -D_DEBUG \ -D_THREAD_SAFE -D_REENTRANT \ + -DVERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"'\ + -DOS='"$(OS)"' \ # -DSUPPORT_IPV6 -LD_FLAGS = -lm - -OS = $(shell uname -s | sed -e s/SunOS/solaris/ | tr "[A-Z]" "[a-z]") TARGET = - ifeq ($(OS), linux) LD_FLAGS += -ldl -rdynamic -lpthread else diff --git a/core/plug-in/uac_auth/UACAuth.cpp b/core/plug-in/uac_auth/UACAuth.cpp index ab958536..087c2bf0 100644 --- a/core/plug-in/uac_auth/UACAuth.cpp +++ b/core/plug-in/uac_auth/UACAuth.cpp @@ -294,7 +294,7 @@ bool UACAuth::do_auth(const unsigned int code, const string& auth_hdr, if (challenge.opaque.length()) result+="opaque=\""+challenge.opaque+"\", "; - result+="response=\""+string((char*)response)+"\", algorithm=\"MD5\"\n"; + result+="response=\""+string((char*)response)+"\", algorithm=MD5\n"; DBG("Auth req hdr: '%s'\n", result.c_str()); diff --git a/core/sems.conf.sample b/core/sems.conf.sample index fea08231..27fd5c1e 100644 --- a/core/sems.conf.sample +++ b/core/sems.conf.sample @@ -54,7 +54,7 @@ plugin_path=/usr/local/lib/sems/plug-in # optional parameter: smtp_server= # # - sets address of smtp server -smtp_server=safekeeper +smtp_server=mail # optional parameter: smtp_port= # @@ -79,3 +79,50 @@ rtp_high_port=60000 # value media_processor_threads=1 +# optional parameter: listen= +# +# - this informs SEMS about the interface where its SER is +# bound to. SEMS needs this information to correctly set +# the contact header in outgoing calls and registrations. +# Should be set to equal the 'listen' configuration option +# in ser_sems.cfg. +# This does not need to be set if outgoing calls and +# registrations from SEMS are not used. +# If not set, this defaults to the interface SEMS binds to. +# +# listen=10.0.0.34 + +# optional parameter: sip_port= +# +# - this informs SEMS about the port where its SER is +# bound to. SEMS needs this information to correctly set +# the contact header in outgoing calls and registrations. +# Should be set to equal the 'port' configuration option +# in ser_sems.cfg. +# This does not need to be set if outgoing calls and +# registrations from SEMS are not used. +# +# default: 5060 +# +#sip_port=5060 + +# optional parameter: use_default_signature={yes|no} +# +# - use a Server/User-Agent header with the SEMS server +# signature and version. +# Set server_signature=0 in ser_sems.cfg if you use it. +# +# default=no +# +# use_default_signature=no + +# optional parameter: signature= +# +# - use a Server/User-Agent header with a custom user agent +# signature. +# Overridden by default signature if +# use_default_signature is set. +# Set server_signature=0 in ser_sems.cfg if you use it. +# +# +# signature="SEMS media server 1.0" diff --git a/core/sems.h b/core/sems.h index 91babc7a..cf02601b 100644 --- a/core/sems.h +++ b/core/sems.h @@ -44,10 +44,15 @@ #define PREFIX_SEPARATOR "" #define RTP_LOWPORT 1024 #define RTP_HIGHPORT 0xffff +#define MAX_FORWARDS "70" -/* Session Timer: -ssa */ +#define DEFAULT_SIGNATURE "Sip Express Media Server " \ + "(" VERSION " (" ARCH "/" OS"))" + + +/* Session Timer defaul configuration: */ #define DEFAULT_ENABLE_SESSION_TIMER 1 -#define SESSION_EXPIRES 10 // seconds +#define SESSION_EXPIRES 60 // seconds #define MINIMUM_TIMER 5 //seconds #define NUM_MEDIA_PROCESSORS 1