diff options
author | Gerald Begumisa <ben_g@users.sourceforge.net> | 2007-08-10 09:04:31 +0000 |
---|---|---|
committer | Gerald Begumisa <ben_g@users.sourceforge.net> | 2007-08-10 09:04:31 +0000 |
commit | 526cb3fffa3fc1e8091af575b224c081eb798f16 (patch) | |
tree | f3e4db3d62b34092438fe722823cf641ac6f89eb /orkaudio/audiocaptureplugins | |
parent | f514b2da9713da1dc3fd5fca983bdcfaeeefed3d (diff) |
Changed the method of logging failed calls so that the failed calls are associated with a session
git-svn-id: https://oreka.svn.sourceforge.net/svnroot/oreka/trunk@463 09dcff7a-b715-0410-9601-b79a96267cd0
Diffstat (limited to 'orkaudio/audiocaptureplugins')
-rw-r--r-- | orkaudio/audiocaptureplugins/voip/Rtp.cpp | 15 | ||||
-rw-r--r-- | orkaudio/audiocaptureplugins/voip/Rtp.h | 1 | ||||
-rw-r--r-- | orkaudio/audiocaptureplugins/voip/RtpSession.cpp | 95 | ||||
-rw-r--r-- | orkaudio/audiocaptureplugins/voip/RtpSession.h | 19 | ||||
-rw-r--r-- | orkaudio/audiocaptureplugins/voip/VoIp.cpp | 50 | ||||
-rw-r--r-- | orkaudio/audiocaptureplugins/voip/VoIpConfig.cpp | 2 | ||||
-rw-r--r-- | orkaudio/audiocaptureplugins/voip/VoIpConfig.h | 1 |
7 files changed, 152 insertions, 31 deletions
diff --git a/orkaudio/audiocaptureplugins/voip/Rtp.cpp b/orkaudio/audiocaptureplugins/voip/Rtp.cpp index 9360bc2..5e53f3e 100644 --- a/orkaudio/audiocaptureplugins/voip/Rtp.cpp +++ b/orkaudio/audiocaptureplugins/voip/Rtp.cpp @@ -16,6 +16,21 @@ #include "ace/OS_NS_arpa_inet.h" #include "Rtp.h" +RtpPacketInfo::RtpPacketInfo() +{ + memset(m_sourceMac, 0, sizeof(m_sourceMac)); + memset(m_destMac, 0, sizeof(m_destMac)); + m_sourceIp.s_addr = 0; + m_destIp.s_addr = 0; + m_sourcePort = 0; + m_destPort = 0; + m_payloadSize = 0; + m_payloadType = 0; + m_payload = NULL; + m_seqNum = 0; + m_timestamp = 0; + m_arrivalTimestamp = 0; +} void RtpPacketInfo::ToString(CStdString& string) { diff --git a/orkaudio/audiocaptureplugins/voip/Rtp.h b/orkaudio/audiocaptureplugins/voip/Rtp.h index d902b98..0e50979 100644 --- a/orkaudio/audiocaptureplugins/voip/Rtp.h +++ b/orkaudio/audiocaptureplugins/voip/Rtp.h @@ -24,6 +24,7 @@ class RtpPacketInfo { public: void ToString(CStdString& string); + RtpPacketInfo(); //CStdString m_sourceMac; //CStdString m_destMac; diff --git a/orkaudio/audiocaptureplugins/voip/RtpSession.cpp b/orkaudio/audiocaptureplugins/voip/RtpSession.cpp index 871c586..189b0ce 100644 --- a/orkaudio/audiocaptureplugins/voip/RtpSession.cpp +++ b/orkaudio/audiocaptureplugins/voip/RtpSession.cpp @@ -705,6 +705,49 @@ void RtpSession::ReportSipInvite(SipInviteInfoRef& invite) std::copy(invite->m_extractedFields.begin(), invite->m_extractedFields.end(), std::inserter(m_tags, m_tags.begin())); } +void RtpSession::ReportSipErrorPacket(SipFailureMessageInfoRef& info) +{ + if(!DLLCONFIG.m_sipReportZeroDurationWhenFailed) + { + return; + } + + /* + * We make sure that before we set the duration to 0, + * the session has already reported its meta data. If + * it hasn't then we do not attempt to report anything + * beyond the plugin. + */ + + if(!((DLLCONFIG.m_lookBackRecording == false) && (m_numRtpPackets > 0))) + { + // Not reported + return; + } + + if( ( ((m_protocol == ProtRawRtp) && m_numRtpPackets < 50) || + ((m_protocol == ProtSkinny) && m_numRtpPackets < 2) || + ((m_protocol == ProtSip) && m_numRtpPackets < 2)) && + DLLCONFIG.m_lookBackRecording == true) + { + // Not reported + return; + } + + CaptureEventRef event(new CaptureEvent()); + event->m_type = CaptureEvent::EtKeyValue; + event->m_key = CStdString("duration"); + event->m_value = CStdString("0"); + g_captureEventCallBack(event, m_capturePort); + + // Trigger metadata update + event.reset(new CaptureEvent()); + event->m_type = CaptureEvent::EtUpdate; + g_captureEventCallBack(event, m_capturePort); + + ReportMetadata(); +} + int RtpSession::ProtocolToEnum(CStdString& protocol) { int protocolEnum = ProtUnkn; @@ -834,6 +877,30 @@ void RtpSessions::ReportSipInvite(SipInviteInfoRef& invite) LOG4CXX_INFO(m_log, "[" + trackingId + "] created by INVITE:" + inviteString); } +void RtpSessions::ReportSipErrorPacket(SipFailureMessageInfoRef& info) +{ + std::map<CStdString, RtpSessionRef>::iterator pair; + + pair = m_byCallId.find(info->m_callId); + if (pair != m_byCallId.end()) + { + RtpSessionRef session = pair->second; + + session->ReportSipErrorPacket(info); + LOG4CXX_INFO(m_log, "[" + session->m_trackingId + "] stopped by SIP \"" + info->m_errorCode + " " + info->m_errorString + "\""); + Stop(session); + + return; + } + + CStdString errorString; + + info->ToString(errorString); + LOG4CXX_INFO(m_log, "Could not associate SIP error packet [" + errorString + "] with any RTP session"); + + return; +} + void RtpSessions::ReportSipBye(SipByeInfo bye) { std::map<CStdString, RtpSessionRef>::iterator pair; @@ -1638,7 +1705,33 @@ void SipInviteInfo::ToString(CStdString& string) char receiverIp[16]; ACE_OS::inet_ntop(AF_INET, (void*)&m_receiverIp, receiverIp, sizeof(receiverIp)); - string.Format("sender:%s from:%s RTP:%s,%s to:%s rcvr:%s callid:%s", senderIp, m_from, fromRtpIp, m_fromRtpPort, m_to, receiverIp, m_callId); + CStdString senderMac, receiverMac; + + 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); +} + +//========================================================== +SipFailureMessageInfo::SipFailureMessageInfo() +{ + m_senderIp.s_addr = 0; + m_receiverIp.s_addr = 0; + memset(m_senderMac, 0, sizeof(m_senderMac)); + memset(m_receiverMac, 0, sizeof(m_receiverMac)); } +void SipFailureMessageInfo::ToString(CStdString& string) +{ + char senderIp[16], receiverIp[16]; + CStdString senderMac, receiverMac; + + MemMacToHumanReadable((unsigned char*)m_senderMac, senderMac); + MemMacToHumanReadable((unsigned char*)m_receiverMac, receiverMac); + ACE_OS::inet_ntop(AF_INET, (void*)&m_senderIp, senderIp, sizeof(senderIp)); + ACE_OS::inet_ntop(AF_INET, (void*)&m_receiverIp, receiverIp, sizeof(receiverIp)); + + string.Format("sender:%s rcvr:%s smac:%s rmac:%s callid:%s errorcode:%s errorstr:\"%s\"", senderIp, receiverIp, senderMac, receiverMac, m_callId, m_errorCode, m_errorString); +} diff --git a/orkaudio/audiocaptureplugins/voip/RtpSession.h b/orkaudio/audiocaptureplugins/voip/RtpSession.h index 98464f1..74460ef 100644 --- a/orkaudio/audiocaptureplugins/voip/RtpSession.h +++ b/orkaudio/audiocaptureplugins/voip/RtpSession.h @@ -46,6 +46,23 @@ public: }; typedef boost::shared_ptr<SipInviteInfo> SipInviteInfoRef; +class SipFailureMessageInfo +{ +public: + SipFailureMessageInfo(); + void ToString(CStdString& string); + + struct in_addr m_senderIp; + struct in_addr m_receiverIp; + char m_senderMac[6]; + char m_receiverMac[6]; + CStdString m_callId; + + CStdString m_errorCode; + CStdString m_errorString; +}; +typedef boost::shared_ptr<SipFailureMessageInfo> SipFailureMessageInfoRef; + class SipByeInfo { public: @@ -80,6 +97,7 @@ public: void Start(); bool AddRtpPacket(RtpPacketInfoRef& rtpPacket); void ReportSipInvite(SipInviteInfoRef& invite); + void ReportSipErrorPacket(SipFailureMessageInfoRef& info); bool OrkUidMatches(CStdString &oUid); bool PartyMatches(CStdString &party); @@ -160,6 +178,7 @@ public: void ReportSkinnySoftKeyHold(SkSoftKeyEventMessageStruct* skEvent, IpHeaderStruct* ipHeader); void ReportSkinnySoftKeyResume(SkSoftKeyEventMessageStruct* skEvent, IpHeaderStruct* ipHeader); void ReportRtpPacket(RtpPacketInfoRef& rtpPacket); + void ReportSipErrorPacket(SipFailureMessageInfoRef& sipError); void Hoover(time_t now); EndpointInfoRef GetEndpointInfo(struct in_addr endpointIp); void StartCapture(CStdString& party); diff --git a/orkaudio/audiocaptureplugins/voip/VoIp.cpp b/orkaudio/audiocaptureplugins/voip/VoIp.cpp index 9b357b1..b4ecff7 100644 --- a/orkaudio/audiocaptureplugins/voip/VoIp.cpp +++ b/orkaudio/audiocaptureplugins/voip/VoIp.cpp @@ -68,7 +68,6 @@ static unsigned int s_numPacketsPerSecond; static unsigned int s_minPacketsPerSecond; static unsigned int s_maxPacketsPerSecond; static std::list<SipTcpStreamRef> s_SipTcpStreams; -static std::list<SipInviteInfoRef> s_SipInvites; VoIpConfigTopObjectRef g_VoIpConfigTopObjectRef; #define DLLCONFIG g_VoIpConfigTopObjectRef.get()->m_config @@ -1092,13 +1091,11 @@ bool TryLogFailedSip(EthernetHeaderStruct* ethernetHeader, IpHeaderStruct* ipHea int sipLength = ntohs(udpHeader->len) - sizeof(UdpHeaderStruct); char* sipEnd = (char*)udpPayload + sipLength; - CStdString callId, errorCode, logMsg; - std::list<SipInviteInfoRef> toErase; - bool result = false; + CStdString callId, errorCode, logMsg, errorString; if(sipLength < 9 || sipEnd > (char*)packetEnd) { - return false; + return false; } if((memcmp("SIP/2.0 4", (void*)udpPayload, 9) == 0) || @@ -1117,46 +1114,40 @@ bool TryLogFailedSip(EthernetHeaderStruct* ethernetHeader, IpHeaderStruct* ipHea if((memcmp("CANCEL ", (void*)udpPayload, 7) == 0)) { errorCode.Format("CANCEL"); + errorString.Format("User Agent CANCEL"); } else { if(eCode) { - GrabLine(eCode, sipEnd, errorCode); + GrabTokenSkipLeadingWhitespaces(eCode, sipEnd, errorCode); + GrabLine((eCode+errorCode.size()+1), sipEnd, errorString); } } } - if(callId.size() && errorCode.size()) + if(!(callId.size() && errorCode.size())) { - result = true; + return false; } - int found = 0; + SipFailureMessageInfoRef info(new SipFailureMessageInfo()); + info->m_senderIp = ipHeader->ip_src; + info->m_receiverIp = ipHeader->ip_dest; + memcpy(info->m_senderMac, ethernetHeader->sourceMac, sizeof(info->m_senderMac)); + memcpy(info->m_receiverMac, ethernetHeader->destinationMac, sizeof(info->m_receiverMac)); + info->m_callId = callId; + info->m_errorCode = errorCode; + info->m_errorString = errorString; - for(std::list<SipInviteInfoRef>::iterator it = s_SipInvites.begin(); it != s_SipInvites.end(); it++) - { - SipInviteInfoRef inviteInfo = *it; + CStdString sipError; - if(callId.size() && (inviteInfo->m_callId.CompareNoCase(callId) == 0) && !found) { - found = 1; - logMsg.Format("SIP INVITE (call-id:%s) failed (\"%s\")", - inviteInfo->m_callId, errorCode); - LOG4CXX_INFO(s_sipPacketLog, logMsg); - toErase.push_back(inviteInfo); - } else { - if((time(NULL) - inviteInfo->m_recvTime) >= 60) - toErase.push_back(inviteInfo); - } - } + info->ToString(sipError); + LOG4CXX_INFO(s_sipPacketLog, "SIP Error packet: " + sipError); - for(std::list<SipInviteInfoRef>::iterator it2 = toErase.begin(); it2 != toErase.end(); it2++) - { - SipInviteInfoRef inviteInfo = *it2; - s_SipInvites.remove(inviteInfo); - } + RtpSessionsSingleton::instance()->ReportSipErrorPacket(info); - return result; + return true; } static bool SipByeTcpToUdp(EthernetHeaderStruct* ethernetHeader, IpHeaderStruct* ipHeader,TcpHeaderStruct* tcpHeader, u_char *pBuffer, int bLength) @@ -1479,7 +1470,6 @@ bool TrySipInvite(EthernetHeaderStruct* ethernetHeader, IpHeaderStruct* ipHeader if(drop == false && info->m_fromRtpPort.size() && info->m_from.size() && info->m_to.size() && info->m_callId.size()) { RtpSessionsSingleton::instance()->ReportSipInvite(info); - s_SipInvites.push_back(info); } } return result; diff --git a/orkaudio/audiocaptureplugins/voip/VoIpConfig.cpp b/orkaudio/audiocaptureplugins/voip/VoIpConfig.cpp index bdced26..daa41d1 100644 --- a/orkaudio/audiocaptureplugins/voip/VoIpConfig.cpp +++ b/orkaudio/audiocaptureplugins/voip/VoIpConfig.cpp @@ -40,6 +40,7 @@ VoIpConfig::VoIpConfig() m_rtpDetectOnOddPorts = false; m_sipOverTcpSupport = false; // Disabled by default m_sipLogFailedCalls = false; + m_sipReportZeroDurationWhenFailed = false; m_useMacIfNoLocalParty = false; // Uses IP address by default m_skinnyIgnoreStopMediaTransmission = false; @@ -84,6 +85,7 @@ void VoIpConfig::Define(Serializer* s) s->CsvValue("SipExtractFields", m_sipExtractFields); s->BoolValue("SipOverTcpSupport", m_sipOverTcpSupport); s->BoolValue("SipLogFailedCalls", m_sipLogFailedCalls); + s->BoolValue("SipReportZeroDurationWhenFailed", m_sipReportZeroDurationWhenFailed); s->BoolValue("UseMacIfNoLocalParty", m_useMacIfNoLocalParty); s->BoolValue("SkinnyIgnoreStopMediaTransmission", m_skinnyIgnoreStopMediaTransmission); diff --git a/orkaudio/audiocaptureplugins/voip/VoIpConfig.h b/orkaudio/audiocaptureplugins/voip/VoIpConfig.h index c1e8b48..24177a0 100644 --- a/orkaudio/audiocaptureplugins/voip/VoIpConfig.h +++ b/orkaudio/audiocaptureplugins/voip/VoIpConfig.h @@ -74,6 +74,7 @@ public: bool m_iax2Support; bool m_sipOverTcpSupport; bool m_sipLogFailedCalls; + bool m_sipReportZeroDurationWhenFailed; bool m_useMacIfNoLocalParty; bool m_skinnyIgnoreStopMediaTransmission; |