diff options
author | Gerald Begumisa <ben_g@users.sourceforge.net> | 2008-03-06 17:52:46 +0000 |
---|---|---|
committer | Gerald Begumisa <ben_g@users.sourceforge.net> | 2008-03-06 17:52:46 +0000 |
commit | c8218d259f148e5eb267369a2e508d43570291c0 (patch) | |
tree | 7b6b1243e3e72dc5efa3f24704226e4ff72cb1a0 | |
parent | 0937742d2f5689c93efca3a5a56e8b36f81152c7 (diff) |
Changed the way direction is determined while recording SIP-based VoIP sessions. A new configuration parameter, SipDomains, has been created and should be set under the VoIpPlugin section in config.xml. This parameter should contain a comma separated list of domains. So, if the domain of the SIP "from" URI matches any entry in this list, direction is set to "out". If the domain of the SIP "to" URI matches any entry in this list, direction is set to "in". If both domains of the "from" and "to" URIs match entries in this list, direction is set to "out" which is also the default case.
git-svn-id: https://oreka.svn.sourceforge.net/svnroot/oreka/trunk@527 09dcff7a-b715-0410-9601-b79a96267cd0
-rw-r--r-- | orkaudio/audiocaptureplugins/voip/RtpSession.cpp | 62 | ||||
-rw-r--r-- | orkaudio/audiocaptureplugins/voip/RtpSession.h | 3 | ||||
-rw-r--r-- | orkaudio/audiocaptureplugins/voip/VoIp.cpp | 30 | ||||
-rw-r--r-- | orkaudio/audiocaptureplugins/voip/VoIpConfig.cpp | 2 | ||||
-rw-r--r-- | orkaudio/audiocaptureplugins/voip/VoIpConfig.h | 1 |
5 files changed, 65 insertions, 33 deletions
diff --git a/orkaudio/audiocaptureplugins/voip/RtpSession.cpp b/orkaudio/audiocaptureplugins/voip/RtpSession.cpp index 31517d8..a15d355 100644 --- a/orkaudio/audiocaptureplugins/voip/RtpSession.cpp +++ b/orkaudio/audiocaptureplugins/voip/RtpSession.cpp @@ -193,6 +193,21 @@ void RtpSession::ProcessMetadataRawRtp(RtpPacketInfoRef& rtpPacket) } } +bool RtpSession::MatchesSipDomain(CStdString& domain) +{ + for(std::list<CStdString>::iterator it = DLLCONFIG.m_sipDomains.begin(); it != DLLCONFIG.m_sipDomains.end(); it++) + { + CStdString element = *it; + + if(element.CompareNoCase(domain) == 0) + { + return true; + } + } + + return false; +} + void RtpSession::ProcessMetadataSipIncoming() { m_remoteParty = m_invite->m_from; @@ -325,45 +340,26 @@ void RtpSession::ProcessMetadataSip(RtpPacketInfoRef& rtpPacket) } // work out capture port and direction - if(DLLCONFIG.IsMediaGateway(m_invitorIp)) + if(MatchesSipDomain(m_invite->m_fromDomain) && MatchesSipDomain(m_invite->m_toDomain)) { - if(DLLCONFIG.IsMediaGateway(m_inviteeIp)) - { - // Media gateway talking to media gateway, this is probably incoming - ProcessMetadataSipIncoming(); - } - else if(DLLCONFIG.IsPartOfLan(m_inviteeIp)) - { - // Gateway to LAN, this is pobably incoming - ProcessMetadataSipIncoming(); - } - else - { - // Gateway to outside address, probably outgoing but treat as incoming for now because - // It can be due to misconfigured LAN Mask, odds are it's still incoming. - ProcessMetadataSipIncoming(); - } + // Both match at least one entry + ProcessMetadataSipOutgoing(); } - else if (DLLCONFIG.IsPartOfLan(m_invitorIp)) + else if(MatchesSipDomain(m_invite->m_fromDomain)) { + // Only from domain matches ProcessMetadataSipOutgoing(); } + else if(MatchesSipDomain(m_invite->m_toDomain)) + { + // Only to domain matches + ProcessMetadataSipIncoming(); + } else { - // SIP invitor media IP address is an outside IP address - if(DLLCONFIG.IsMediaGateway(m_inviteeIp)) - { - ProcessMetadataSipIncoming(); - } - else if(DLLCONFIG.IsPartOfLan(m_inviteeIp)) - { - ProcessMetadataSipIncoming(); - } - else - { - // SIP invitee media address is an outside IP address - ProcessMetadataSipOutgoing(); - } + // Default to outgoing whereby m_from is the local party and m_to is + // the remote party - neither from nor to domains match + ProcessMetadataSipOutgoing(); } } @@ -1909,7 +1905,7 @@ void SipInviteInfo::ToString(CStdString& string) MemMacToHumanReadable((unsigned char*)m_senderMac, senderMac); MemMacToHumanReadable((unsigned char*)m_receiverMac, receiverMac); - string.Format("sender:%s from:%s RTP:%s,%s to:%s rcvr:%s callid:%s smac:%s rmac:%s", senderIp, m_from, fromRtpIp, m_fromRtpPort, m_to, receiverIp, m_callId, senderMac, receiverMac); + string.Format("sender:%s from:%s@%s RTP:%s,%s to:%s@%s rcvr:%s callid:%s smac:%s rmac:%s", senderIp, m_from, m_fromDomain, fromRtpIp, m_fromRtpPort, m_to, m_toDomain, receiverIp, m_callId, senderMac, receiverMac); } //========================================================== diff --git a/orkaudio/audiocaptureplugins/voip/RtpSession.h b/orkaudio/audiocaptureplugins/voip/RtpSession.h index 392d7bf..82515d5 100644 --- a/orkaudio/audiocaptureplugins/voip/RtpSession.h +++ b/orkaudio/audiocaptureplugins/voip/RtpSession.h @@ -44,6 +44,8 @@ public: std::map<CStdString, CStdString> m_extractedFields; CStdString m_telephoneEventPayloadType; bool m_telephoneEventPtDefined; + CStdString m_fromDomain; + CStdString m_toDomain; time_t m_recvTime; }; @@ -158,6 +160,7 @@ private: void GenerateOrkUid(); void HandleRtpEvent(RtpPacketInfoRef& rtpPacket); void RecordRtpEvent(); + bool MatchesSipDomain(CStdString& domain); RtpPacketInfoRef m_lastRtpPacket; RtpPacketInfoRef m_lastRtpPacketSide1; diff --git a/orkaudio/audiocaptureplugins/voip/VoIp.cpp b/orkaudio/audiocaptureplugins/voip/VoIp.cpp index 03725c9..a2a07a4 100644 --- a/orkaudio/audiocaptureplugins/voip/VoIp.cpp +++ b/orkaudio/audiocaptureplugins/voip/VoIp.cpp @@ -196,6 +196,32 @@ char* SkipWhitespaces(char* in, char* limit) return c; } +void GrabSipUriDomain(char* in, char* limit, CStdString& out) +{ + char* userStart = SkipWhitespaces(in, limit); + if(userStart >= limit) + { + return; + } + + char* domainStart = strchr(userStart, '@'); + if(!domainStart) + { + return; + } + + domainStart += 1; + if(*domainStart == '\0' || domainStart >= limit) + { + return; + } + + for(char *c = domainStart; (ACE_OS::ace_isalnum(*c) || *c == '.' || *c == '-' || *c == '_') && (c < limit); c = c+1) + { + out += *c; + } +} + void GrabSipUserAddress(char* in, char* limit, CStdString& out) { char* userStart = SkipWhitespaces(in, limit); @@ -1613,6 +1639,7 @@ bool TrySipInvite(EthernetHeaderStruct* ethernetHeader, IpHeaderStruct* ipHeader { GrabSipUriUser(sipUser, fromFieldEnd, info->m_from); } + GrabSipUriDomain(sipUser, fromFieldEnd, info->m_fromDomain); } else { @@ -1624,6 +1651,7 @@ bool TrySipInvite(EthernetHeaderStruct* ethernetHeader, IpHeaderStruct* ipHeader { GrabSipUriUser(fromField, fromFieldEnd, info->m_from); } + GrabSipUriDomain(fromField, fromFieldEnd, info->m_fromDomain); } } if(toField) @@ -1643,6 +1671,7 @@ bool TrySipInvite(EthernetHeaderStruct* ethernetHeader, IpHeaderStruct* ipHeader { GrabSipUriUser(sipUser, toFieldEnd, info->m_to); } + GrabSipUriDomain(sipUser, toFieldEnd, info->m_toDomain); } else { @@ -1654,6 +1683,7 @@ bool TrySipInvite(EthernetHeaderStruct* ethernetHeader, IpHeaderStruct* ipHeader { GrabSipUriUser(toField, toFieldEnd, info->m_to); } + GrabSipUriDomain(toField, toFieldEnd, info->m_toDomain); } } if(callIdField) diff --git a/orkaudio/audiocaptureplugins/voip/VoIpConfig.cpp b/orkaudio/audiocaptureplugins/voip/VoIpConfig.cpp index 79462ae..ddd1758 100644 --- a/orkaudio/audiocaptureplugins/voip/VoIpConfig.cpp +++ b/orkaudio/audiocaptureplugins/voip/VoIpConfig.cpp @@ -109,6 +109,8 @@ void VoIpConfig::Define(Serializer* s) s->IntValue("SangomaRxTcpPortStart", m_sangomaRxTcpPortStart); s->IntValue("SangomaTxTcpPortStart", m_sangomaTxTcpPortStart); + + s->CsvValue("SipDomains", m_sipDomains); } void VoIpConfig::Validate() diff --git a/orkaudio/audiocaptureplugins/voip/VoIpConfig.h b/orkaudio/audiocaptureplugins/voip/VoIpConfig.h index fba1345..962a552 100644 --- a/orkaudio/audiocaptureplugins/voip/VoIpConfig.h +++ b/orkaudio/audiocaptureplugins/voip/VoIpConfig.h @@ -97,6 +97,7 @@ public: int m_sangomaRxTcpPortStart; int m_sangomaTxTcpPortStart; int m_skinnyTcpPort; + std::list<CStdString> m_sipDomains; }; //======================================== |