diff options
author | Henri Herscher <henri@oreka.org> | 2009-06-23 21:22:57 +0000 |
---|---|---|
committer | Henri Herscher <henri@oreka.org> | 2009-06-23 21:22:57 +0000 |
commit | 37af020b54aea14ebb12cfe5aafd612c10e23214 (patch) | |
tree | 7a144cabe66488d1b44194d72af8fef30035310c | |
parent | 79bc58f84cecf79b2f451f4488adb4460b0f0d92 (diff) |
Added SipDirectionReferenceUserAgents VoIp config parameter. Any SIP INVITE with User Agent field matching an entry in this list will be considered incoming. Populated by default with "Asterisk".
git-svn-id: https://oreka.svn.sourceforge.net/svnroot/oreka/trunk@624 09dcff7a-b715-0410-9601-b79a96267cd0
-rw-r--r-- | orkaudio/audiocaptureplugins/voip/RtpSession.cpp | 9 | ||||
-rw-r--r-- | orkaudio/audiocaptureplugins/voip/RtpSession.h | 1 | ||||
-rw-r--r-- | orkaudio/audiocaptureplugins/voip/VoIp.cpp | 5 | ||||
-rw-r--r-- | orkaudio/audiocaptureplugins/voip/VoIpConfig.cpp | 6 | ||||
-rw-r--r-- | orkaudio/audiocaptureplugins/voip/VoIpConfig.h | 1 | ||||
-rw-r--r-- | orkbasecxx/Utils.cpp | 17 | ||||
-rw-r--r-- | orkbasecxx/Utils.h | 1 |
7 files changed, 37 insertions, 3 deletions
diff --git a/orkaudio/audiocaptureplugins/voip/RtpSession.cpp b/orkaudio/audiocaptureplugins/voip/RtpSession.cpp index 666030d..ec1f37a 100644 --- a/orkaudio/audiocaptureplugins/voip/RtpSession.cpp +++ b/orkaudio/audiocaptureplugins/voip/RtpSession.cpp @@ -308,7 +308,6 @@ bool RtpSession::MatchesSipDomain(CStdString& domain) return true; } } - return false; } @@ -622,10 +621,14 @@ void RtpSession::ProcessMetadataSip(RtpPacketInfoRef& rtpPacket) // Only to domain matches ProcessMetadataSipIncoming(); } + else if(MatchesStringList(m_invite->m_userAgent, DLLCONFIG.m_sipDirectionReferenceUserAgents)) + { + ProcessMetadataSipIncoming(); + } else { // Default to outgoing whereby m_from is the local party and m_to is - // the remote party - neither from nor to domains match + // the remote party ProcessMetadataSipOutgoing(); } } @@ -2695,7 +2698,7 @@ void SipInviteInfo::ToString(CStdString& string) MemMacToHumanReadable((unsigned char*)m_senderMac, senderMac); MemMacToHumanReadable((unsigned char*)m_receiverMac, receiverMac); - string.Format("sender:%s from:%s@%s RTP:%s,%s to:%s@%s rcvr:%s callid:%s smac:%s rmac:%s fromname:%s toname:%s", senderIp, m_from, m_fromDomain, fromRtpIp, m_fromRtpPort, m_to, m_toDomain, receiverIp, m_callId, senderMac, receiverMac, m_fromName, m_toName); + string.Format("sender:%s from:%s@%s RTP:%s,%s to:%s@%s rcvr:%s callid:%s smac:%s rmac:%s fromname:%s toname:%s ua:%s", senderIp, m_from, m_fromDomain, fromRtpIp, m_fromRtpPort, m_to, m_toDomain, receiverIp, m_callId, senderMac, receiverMac, m_fromName, m_toName, m_userAgent); } //========================================================== diff --git a/orkaudio/audiocaptureplugins/voip/RtpSession.h b/orkaudio/audiocaptureplugins/voip/RtpSession.h index 765b803..221c771 100644 --- a/orkaudio/audiocaptureplugins/voip/RtpSession.h +++ b/orkaudio/audiocaptureplugins/voip/RtpSession.h @@ -49,6 +49,7 @@ public: CStdString m_toDomain; CStdString m_fromName; CStdString m_toName; + CStdString m_userAgent; time_t m_recvTime; }; diff --git a/orkaudio/audiocaptureplugins/voip/VoIp.cpp b/orkaudio/audiocaptureplugins/voip/VoIp.cpp index 8c45c51..aa0d811 100644 --- a/orkaudio/audiocaptureplugins/voip/VoIp.cpp +++ b/orkaudio/audiocaptureplugins/voip/VoIp.cpp @@ -2082,6 +2082,7 @@ bool TrySipInvite(EthernetHeaderStruct* ethernetHeader, IpHeaderStruct* ipHeader char* connectionAddressField = NULL; char* attribSendonly = memFindAfter("a=sendonly", (char*)udpPayload, sipEnd); char* rtpmapAttribute = memFindAfter("\na=rtpmap:", (char*)udpPayload, sipEnd); + char* userAgentField = memFindAfter("\nUser-Agent:", (char*)udpPayload, sipEnd); if(DLLCONFIG.m_sipRequestUriAsLocalParty == true) { @@ -2217,6 +2218,10 @@ bool TrySipInvite(EthernetHeaderStruct* ethernetHeader, IpHeaderStruct* ipHeader info->m_from = localExtension; } } + if(userAgentField) + { + GrabTokenSkipLeadingWhitespaces(userAgentField, sipEnd, info->m_userAgent); + } if(audioField) { GrabToken(audioField, sipEnd, info->m_fromRtpPort); diff --git a/orkaudio/audiocaptureplugins/voip/VoIpConfig.cpp b/orkaudio/audiocaptureplugins/voip/VoIpConfig.cpp index 5f4646d..4c3f22d 100644 --- a/orkaudio/audiocaptureplugins/voip/VoIpConfig.cpp +++ b/orkaudio/audiocaptureplugins/voip/VoIpConfig.cpp @@ -147,6 +147,8 @@ void VoIpConfig::Define(Serializer* s) s->CsvValue("SipDomains", m_sipDomains); s->CsvValue("SipDirectionReferenceIpAddresses", m_sipDirectionReferenceIpAddresses); + s->CsvValue("SipDirectionReferenceUserAgents", m_sipDirectionReferenceUserAgents); + s->IpRangesValue("LanIpRanges", m_lanIpRanges); s->IpRangesValue("MediaAddressBlockedIpRanges", m_mediaAddressBlockedIpRanges); } @@ -367,6 +369,10 @@ void VoIpConfig::Validate() m_rtcpDetect = true; m_sipExtractFields.push_back(inInVar); } + if(m_sipDirectionReferenceUserAgents.size() == 0) + { + m_sipDirectionReferenceUserAgents.push_back("Asterisk"); + } } bool VoIpConfig::IsPartOfLan(struct in_addr addr) diff --git a/orkaudio/audiocaptureplugins/voip/VoIpConfig.h b/orkaudio/audiocaptureplugins/voip/VoIpConfig.h index 202b92f..3ff66e7 100644 --- a/orkaudio/audiocaptureplugins/voip/VoIpConfig.h +++ b/orkaudio/audiocaptureplugins/voip/VoIpConfig.h @@ -115,6 +115,7 @@ public: int m_skinnyTcpPort; std::list<CStdString> m_sipDomains; std::list<CStdString> m_sipDirectionReferenceIpAddresses; + std::list<CStdString> m_sipDirectionReferenceUserAgents; IpRanges m_lanIpRanges; IpRanges m_mediaAddressBlockedIpRanges; }; diff --git a/orkbasecxx/Utils.cpp b/orkbasecxx/Utils.cpp index dca2200..f06d673 100644 --- a/orkbasecxx/Utils.cpp +++ b/orkbasecxx/Utils.cpp @@ -24,6 +24,23 @@ bool StringIsDigit(CStdString& string) return true; } +bool MatchesStringList(CStdString& string, std::list<CStdString>& stringList) +{ + if(string.size() == 0) + { + return false; + } + for(std::list<CStdString>::iterator it = stringList.begin(); it != stringList.end(); it++) + { + CStdString element = *it; + + if(element.CompareNoCase(string) == 0) + { + return true; + } + } + return false; +} //======================================================== // file related stuff diff --git a/orkbasecxx/Utils.h b/orkbasecxx/Utils.h index 31f059d..19115c8 100644 --- a/orkbasecxx/Utils.h +++ b/orkbasecxx/Utils.h @@ -67,6 +67,7 @@ inline double StringToDouble(CStdString& value) } bool DLL_IMPORT_EXPORT_ORKBASE StringIsDigit(CStdString& string); +bool DLL_IMPORT_EXPORT_ORKBASE MatchesStringList(CStdString& string, std::list<CStdString>& stringList); //======================================================== // file related stuff |