From c4c926bd690b695343f2dfe6fcae90824cb8fb52 Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Tue, 27 Apr 2010 08:56:57 +0000 Subject: [PATCH] added the max_forwards configuration option. git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@1835 8eb893ce-cfd4-0310-b710-fb5ebe64c474 --- core/AmConfig.cpp | 11 +++++++++++ core/AmConfig.h | 2 ++ core/AmSipDialog.cpp | 7 +++---- core/sems.h | 2 +- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/core/AmConfig.cpp b/core/AmConfig.cpp index 7ab74d67..0138e323 100644 --- a/core/AmConfig.cpp +++ b/core/AmConfig.cpp @@ -59,6 +59,7 @@ string AmConfig::LocalSIPIP = ""; string AmConfig::OutboundProxy = ""; bool AmConfig::ForceOutboundProxy = false; string AmConfig::Signature = ""; +unsigned int AmConfig::MaxForwards = MAX_FORWARDS; bool AmConfig::SingleCodecInOK = false; unsigned int AmConfig::DeadRtpTime = DEAD_RTP_TIME; bool AmConfig::IgnoreRTPXHdrs = false; @@ -243,6 +244,16 @@ int AmConfig::readConfiguration() else Signature = cfg.getParameter("signature"); + if (cfg.hasParameter("max_forwards")) { + unsigned int mf=0; + if(str2i(cfg.getParameter("max_forwards"), mf)) { + ERROR("invalid max_forwards specified\n"); + } + else { + MaxForwards = mf; + } + } + // log_level if(cfg.hasParameter("loglevel")){ if(!setLoglevel(cfg.getParameter("loglevel"))){ diff --git a/core/AmConfig.h b/core/AmConfig.h index 411a25ff..e5138d49 100644 --- a/core/AmConfig.h +++ b/core/AmConfig.h @@ -91,6 +91,8 @@ struct AmConfig static bool ForceOutboundProxy; /** Server/User-Agent header (optional) */ static string Signature; + /** Value of Max-Forward header field for new requests */ + static unsigned int MaxForwards; /** If 200 OK reply should be limited to preferred codec only */ static bool SingleCodecInOK; static vector CodecOrder; diff --git a/core/AmSipDialog.cpp b/core/AmSipDialog.cpp index 67e499ee..936166f8 100644 --- a/core/AmSipDialog.cpp +++ b/core/AmSipDialog.cpp @@ -585,7 +585,7 @@ int AmSipDialog::sendRequest(const string& method, if (AmConfig::Signature.length()) req.hdrs += SIP_HDR_COLSP(SIP_HDR_USER_AGENT) + AmConfig::Signature + CRLF; - req.hdrs += SIP_HDR_COLSP(SIP_HDR_MAX_FORWARDS) /*TODO: configurable?!*/ MAX_FORWARDS CRLF; + req.hdrs += SIP_HDR_COLSP(SIP_HDR_MAX_FORWARDS) + int2str(AmConfig::MaxForwards) + CRLF; } @@ -686,12 +686,11 @@ int AmSipDialog::send_200_ack(const AmSipTransaction& t, if (AmConfig::Signature.length()) req.hdrs += SIP_HDR_COLSP(SIP_HDR_USER_AGENT) + AmConfig::Signature + CRLF; - req.hdrs += SIP_HDR_COLSP(SIP_HDR_MAX_FORWARDS) /*TODO: configurable?!*/MAX_FORWARDS CRLF; - + req.hdrs += SIP_HDR_COLSP(SIP_HDR_MAX_FORWARDS) + int2str(AmConfig::MaxForwards) + CRLF; } if(!route.empty()) - req.route = route; //getRoute(); + req.route = route; if(!body.empty()) { req.content_type = content_type; diff --git a/core/sems.h b/core/sems.h index af7a7007..3c15b9d3 100644 --- a/core/sems.h +++ b/core/sems.h @@ -39,7 +39,7 @@ #define PREFIX_SEPARATOR "" #define RTP_LOWPORT 1024 #define RTP_HIGHPORT 0xffff -#define MAX_FORWARDS "70" +#define MAX_FORWARDS 70 #define DEFAULT_SIGNATURE "Sip Express Media Server " \ "(" SEMS_VERSION " (" ARCH "/" OS"))"