From 503bb1cbfd003bb272ab952245905b0093160559 Mon Sep 17 00:00:00 2001 From: Gerald Begumisa Date: Tue, 12 Jun 2007 11:15:29 +0000 Subject: Added support for a configuration value, UseMacIfNoLocalParty, which sets the local party to the MAC address, instead of the IP address, if local party is not present from signalling information git-svn-id: https://oreka.svn.sourceforge.net/svnroot/oreka/trunk@446 09dcff7a-b715-0410-9601-b79a96267cd0 --- orkaudio/audiocaptureplugins/voip/Rtp.h | 3 ++ orkaudio/audiocaptureplugins/voip/RtpSession.cpp | 54 +++++++++++++++++++++--- orkaudio/audiocaptureplugins/voip/RtpSession.h | 6 +++ orkaudio/audiocaptureplugins/voip/VoIp.cpp | 5 ++- orkaudio/audiocaptureplugins/voip/VoIpConfig.cpp | 2 + orkaudio/audiocaptureplugins/voip/VoIpConfig.h | 1 + 6 files changed, 65 insertions(+), 6 deletions(-) (limited to 'orkaudio/audiocaptureplugins/voip') diff --git a/orkaudio/audiocaptureplugins/voip/Rtp.h b/orkaudio/audiocaptureplugins/voip/Rtp.h index 242c21a..d902b98 100644 --- a/orkaudio/audiocaptureplugins/voip/Rtp.h +++ b/orkaudio/audiocaptureplugins/voip/Rtp.h @@ -27,6 +27,9 @@ public: //CStdString m_sourceMac; //CStdString m_destMac; + char m_sourceMac[6]; + char m_destMac[6]; + struct in_addr m_sourceIp; struct in_addr m_destIp; unsigned short m_sourcePort; diff --git a/orkaudio/audiocaptureplugins/voip/RtpSession.cpp b/orkaudio/audiocaptureplugins/voip/RtpSession.cpp index 0271526..3bf117e 100644 --- a/orkaudio/audiocaptureplugins/voip/RtpSession.cpp +++ b/orkaudio/audiocaptureplugins/voip/RtpSession.cpp @@ -22,6 +22,7 @@ #include "ConfigManager.h" #include "VoIpConfig.h" #include "ace/OS_NS_arpa_inet.h" +#include "MemUtils.h" extern AudioChunkCallBackFunction g_audioChunkCallBack; extern CaptureEventCallBackFunction g_captureEventCallBack; @@ -29,7 +30,6 @@ extern CaptureEventCallBackFunction g_captureEventCallBack; extern VoIpConfigTopObjectRef g_VoIpConfigTopObjectRef; #define DLLCONFIG g_VoIpConfigTopObjectRef.get()->m_config - RtpSession::RtpSession(CStdString& trackingId) { m_trackingId = trackingId; @@ -50,6 +50,8 @@ RtpSession::RtpSession(CStdString& trackingId) m_highestRtpSeqNumDelta = 0; m_minRtpSeqDelta = (double)DLLCONFIG.m_rtpDiscontinuityMinSeqDelta; m_minRtpTimestampDelta = (double)DLLCONFIG.m_rtpDiscontinuityMinSeqDelta * 160; // arbitrarily based on 160 samples per packet (does not need to be precise) + memset(m_localMac, 0, sizeof(m_localMac)); + memset(m_remoteMac, 0, sizeof(m_remoteMac)); } void RtpSession::Stop() @@ -134,20 +136,43 @@ void RtpSession::ProcessMetadataRawRtp(RtpPacketInfoRef& rtpPacket) if(sourceIsLocal) { - m_localParty = szSourceIp; + /* With Raw RTP, the local party is not obtained through any intelligent + * signalling so we should probably do this check here? */ + if(DLLCONFIG.m_useMacIfNoLocalParty) + { + MemMacToHumanReadable((unsigned char*)rtpPacket->m_sourceMac, m_localParty); + } + else + { + m_localParty = szSourceIp; + } + m_remoteParty = szDestIp; //m_capturePort.Format("%s,%d", szSourceIp, rtpPacket->m_sourcePort); m_localIp = rtpPacket->m_sourceIp; m_remoteIp = rtpPacket->m_destIp; + memcpy(m_localMac, rtpPacket->m_sourceMac, sizeof(m_localMac)); + memcpy(m_remoteMac, rtpPacket->m_destMac, sizeof(m_remoteMac)); } else { - m_localParty = szDestIp; + /* With Raw RTP, the local party is not obtained through any intelligent + * signalling so we should probably do this check here? */ + if(DLLCONFIG.m_useMacIfNoLocalParty) + { + MemMacToHumanReadable((unsigned char*)rtpPacket->m_destMac, m_localParty); + } + else + { + m_localParty = szDestIp; + } + m_remoteParty = szSourceIp; //m_capturePort.Format("%s,%d", szDestIp, rtpPacket->m_destPort); m_localIp = rtpPacket->m_destIp; m_remoteIp = rtpPacket->m_sourceIp; - + memcpy(m_localMac, rtpPacket->m_destMac, sizeof(m_localMac)); + memcpy(m_remoteMac, rtpPacket->m_sourceMac, sizeof(m_remoteMac)); } } @@ -161,6 +186,8 @@ void RtpSession::ProcessMetadataSipIncoming() m_capturePort.Format("%s,%d", szInviteeIp, m_inviteeTcpPort); m_localIp = m_inviteeIp; m_remoteIp = m_invitorIp; + memcpy(m_localMac, m_inviteeMac, sizeof(m_localMac)); + memcpy(m_remoteMac, m_invitorMac, sizeof(m_remoteMac)); } void RtpSession::ProcessMetadataSipOutgoing() @@ -173,6 +200,8 @@ void RtpSession::ProcessMetadataSipOutgoing() m_capturePort.Format("%s,%d", szInvitorIp, m_invitorTcpPort); m_localIp = m_invitorIp; m_remoteIp = m_inviteeIp; + memcpy(m_localMac, m_invitorMac, sizeof(m_localMac)); + memcpy(m_remoteMac, m_inviteeMac, sizeof(m_remoteMac)); } void RtpSession::UpdateMetadataSip(RtpPacketInfoRef& rtpPacket, bool sourceRtpAddressIsNew) @@ -212,6 +241,7 @@ void RtpSession::UpdateMetadataSip(RtpPacketInfoRef& rtpPacket, bool sourceRtpAd m_remoteParty = invite->m_from; m_localParty = invite->m_to; m_localIp = invite->m_receiverIp; + memcpy(m_localMac, invite->m_receiverMac, sizeof(m_localMac)); // Do some logging CStdString inviteString; @@ -257,12 +287,14 @@ void RtpSession::ProcessMetadataSip(RtpPacketInfoRef& rtpPacket) m_inviteeIp = rtpPacket->m_destIp; m_inviteeTcpPort = rtpPacket->m_destPort; m_invitorTcpPort = rtpPacket->m_sourcePort; + memcpy(m_inviteeMac, rtpPacket->m_destMac, sizeof(m_inviteeMac)); } else if((unsigned int)rtpPacket->m_destIp.s_addr == (unsigned int)m_invitorIp.s_addr) { m_inviteeIp = rtpPacket->m_sourceIp; m_inviteeTcpPort = rtpPacket->m_sourcePort; m_invitorTcpPort = rtpPacket->m_destPort; + memcpy(m_inviteeMac, rtpPacket->m_sourceMac, sizeof(m_inviteeMac)); } else { @@ -324,6 +356,8 @@ void RtpSession::ProcessMetadataSkinny(RtpPacketInfoRef& rtpPacket) m_localIp = rtpPacket->m_destIp; m_remoteIp = rtpPacket->m_sourceIp; + memcpy(m_localMac, rtpPacket->m_destMac, sizeof(m_localMac)); + memcpy(m_remoteMac, rtpPacket->m_sourceMac, sizeof(m_remoteMac)); } else { @@ -331,6 +365,8 @@ void RtpSession::ProcessMetadataSkinny(RtpPacketInfoRef& rtpPacket) m_localIp = rtpPacket->m_sourceIp; m_remoteIp = rtpPacket->m_destIp; + memcpy(m_localMac, rtpPacket->m_sourceMac, sizeof(m_localMac)); + memcpy(m_remoteMac, rtpPacket->m_destMac, sizeof(m_remoteMac)); } } @@ -358,7 +394,14 @@ void RtpSession::ReportMetadata() // Make sure Local Party is always reported if(m_localParty.IsEmpty()) { - m_localParty = szLocalIp; + if(DLLCONFIG.m_useMacIfNoLocalParty) + { + MemMacToHumanReadable((unsigned char*)m_localMac, m_localParty); + } + else + { + m_localParty = szLocalIp; + } } // Report Local party @@ -616,6 +659,7 @@ void RtpSession::ReportSipInvite(SipInviteInfoRef& invite) { m_invite = invite; m_invitorIp = invite->m_fromRtpIp; + memcpy(m_invitorMac, invite->m_senderMac, sizeof(m_invitorMac)); } else { diff --git a/orkaudio/audiocaptureplugins/voip/RtpSession.h b/orkaudio/audiocaptureplugins/voip/RtpSession.h index 41495af..fe7e17a 100644 --- a/orkaudio/audiocaptureplugins/voip/RtpSession.h +++ b/orkaudio/audiocaptureplugins/voip/RtpSession.h @@ -32,6 +32,8 @@ public: struct in_addr m_senderIp; struct in_addr m_receiverIp; struct in_addr m_fromRtpIp; + char m_senderMac[6]; + char m_receiverMac[6]; CStdString m_fromRtpPort; CStdString m_from; CStdString m_to; @@ -108,8 +110,12 @@ private: int m_invitorTcpPort; struct in_addr m_inviteeIp; int m_inviteeTcpPort; + char m_invitorMac[6]; + char m_inviteeMac[6]; struct in_addr m_localIp; struct in_addr m_remoteIp; + char m_localMac[6]; + char m_remoteMac[6]; //struct in_addr m_localMac; //struct in_addr m_remoteMac; LoggerPtr m_log; diff --git a/orkaudio/audiocaptureplugins/voip/VoIp.cpp b/orkaudio/audiocaptureplugins/voip/VoIp.cpp index c008bfc..f5f70e0 100644 --- a/orkaudio/audiocaptureplugins/voip/VoIp.cpp +++ b/orkaudio/audiocaptureplugins/voip/VoIp.cpp @@ -136,7 +136,6 @@ char* memFindEOL(char* start, char* limit) return start; } - // Grabs a string in memory until encountering null char, a space a CR or LF chars void GrabToken(char* in, char* limit, CStdString& out) { @@ -1014,6 +1013,8 @@ bool TryRtp(EthernetHeaderStruct* ethernetHeader, IpHeaderStruct* ipHeader, UdpH rtpInfo->m_timestamp = ntohl(rtpHeader->ts); rtpInfo->m_payload = payload; rtpInfo->m_arrivalTimestamp = time(NULL); + memcpy(rtpInfo->m_sourceMac, ethernetHeader->sourceMac, sizeof(rtpInfo->m_sourceMac)); + memcpy(rtpInfo->m_destMac, ethernetHeader->destinationMac, sizeof(rtpInfo->m_destMac)); if(s_rtpPacketLog->isDebugEnabled()) { @@ -1352,6 +1353,8 @@ bool TrySipInvite(EthernetHeaderStruct* ethernetHeader, IpHeaderStruct* ipHeader } 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)); CStdString logMsg; info->ToString(logMsg); diff --git a/orkaudio/audiocaptureplugins/voip/VoIpConfig.cpp b/orkaudio/audiocaptureplugins/voip/VoIpConfig.cpp index 53aeb6d..7471ad0 100644 --- a/orkaudio/audiocaptureplugins/voip/VoIpConfig.cpp +++ b/orkaudio/audiocaptureplugins/voip/VoIpConfig.cpp @@ -39,6 +39,7 @@ VoIpConfig::VoIpConfig() m_iax2Support = false; // Disabled by default m_rtpDetectOnOddPorts = false; m_sipOverTcpSupport = false; // Disabled by default + m_useMacIfNoLocalParty = false; // Uses IP address by default m_skinnyIgnoreStopMediaTransmission = false; m_skinnyIgnoreOpenReceiveChannelAck = false; @@ -73,6 +74,7 @@ void VoIpConfig::Define(Serializer* s) s->BoolValue("RtpDetectOnOddPorts", m_rtpDetectOnOddPorts); s->CsvValue("SipExtractFields", m_sipExtractFields); s->BoolValue("SipOverTcpSupport", m_sipOverTcpSupport); + s->BoolValue("UseMacIfNoLocalParty", m_useMacIfNoLocalParty); s->BoolValue("SkinnyIgnoreStopMediaTransmission", m_skinnyIgnoreStopMediaTransmission); s->BoolValue("SkinnyIgnoreOpenReceiveChannelAck", m_skinnyIgnoreOpenReceiveChannelAck); diff --git a/orkaudio/audiocaptureplugins/voip/VoIpConfig.h b/orkaudio/audiocaptureplugins/voip/VoIpConfig.h index b66fd7e..31bbea9 100644 --- a/orkaudio/audiocaptureplugins/voip/VoIpConfig.h +++ b/orkaudio/audiocaptureplugins/voip/VoIpConfig.h @@ -72,6 +72,7 @@ public: bool m_rtpDetectOnOddPorts; bool m_iax2Support; bool m_sipOverTcpSupport; + bool m_useMacIfNoLocalParty; bool m_skinnyIgnoreStopMediaTransmission; bool m_skinnyIgnoreOpenReceiveChannelAck; -- cgit v1.2.3