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"))"