From 73d206c551c8af905f24336695d457ca3986c6e9 Mon Sep 17 00:00:00 2001 From: Henri Herscher Date: Tue, 1 Aug 2006 14:43:56 +0000 Subject: Applying changeset 269 from 0.5 to trunk: Can now get local party info from the Skinny LineStatMessage. git-svn-id: https://oreka.svn.sourceforge.net/svnroot/oreka/trunk@320 09dcff7a-b715-0410-9601-b79a96267cd0 --- .../audiocaptureplugins/voip/PacketHeaderDefs.cpp | 22 ++++++++ .../audiocaptureplugins/voip/PacketHeaderDefs.h | 15 ++++++ orkaudio/audiocaptureplugins/voip/RtpSession.cpp | 58 ++++++++++++++++++++++ orkaudio/audiocaptureplugins/voip/RtpSession.h | 29 ++++------- orkaudio/audiocaptureplugins/voip/VoIp.cpp | 19 +++++++ 5 files changed, 123 insertions(+), 20 deletions(-) (limited to 'orkaudio') diff --git a/orkaudio/audiocaptureplugins/voip/PacketHeaderDefs.cpp b/orkaudio/audiocaptureplugins/voip/PacketHeaderDefs.cpp index 2d3cfe3..d0fa8a4 100644 --- a/orkaudio/audiocaptureplugins/voip/PacketHeaderDefs.cpp +++ b/orkaudio/audiocaptureplugins/voip/PacketHeaderDefs.cpp @@ -23,6 +23,10 @@ int SkinnyMessageToEnum(CStdString& msg) { msgEnum = SkCloseReceiveChannel; } + else if (msg.CompareNoCase(SKINNY_MSG_LINE_STAT_MESSAGE) == 0) + { + msgEnum = SkLineStatMessage; + } return msgEnum; } @@ -46,6 +50,9 @@ CStdString SkinnyMessageToString(int msgEnum) case SkCloseReceiveChannel: msgString = SKINNY_MSG_CLOSE_RECEIVE_CHANNEL; break; + case SkLineStatMessage: + msgString = SKINNY_MSG_LINE_STAT_MESSAGE; + break; default: msgString = SKINNY_MSG_UNKN; } @@ -121,3 +128,18 @@ bool SkinnyValidateOpenReceiveChannelAck(SkOpenReceiveChannelAckStruct* orca) } return valid; } + +bool SkinnyValidateLineStat(SkLineStatStruct* lineStat) +{ + bool valid = true; + if(valid) + { + valid = checkPartyString(lineStat->displayName, SKINNY_DISPLAY_NAME_SIZE); + } + if(valid) + { + valid = checkPartyString(lineStat->lineDirNumber, SKINNY_LINE_DIR_NUMBER_SIZE); + } + return valid; +} + diff --git a/orkaudio/audiocaptureplugins/voip/PacketHeaderDefs.h b/orkaudio/audiocaptureplugins/voip/PacketHeaderDefs.h index 57a9d8e..c861f66 100644 --- a/orkaudio/audiocaptureplugins/voip/PacketHeaderDefs.h +++ b/orkaudio/audiocaptureplugins/voip/PacketHeaderDefs.h @@ -90,6 +90,7 @@ typedef struct //unsigned int csrc[1]; // optional CSRC list } RtpHeaderStruct; +//=================================================================== // Cisco Callmanager -> endpoint messages typedef struct { @@ -154,6 +155,18 @@ typedef struct char parties[76]; } SkNewCallInfoStruct; +#define SKINNY_LINE_DIR_NUMBER_SIZE 24 +#define SKINNY_DISPLAY_NAME_SIZE 40 +typedef struct +{ + SkinnyHeaderStruct header; + unsigned int lineNumber; + char lineDirNumber[SKINNY_LINE_DIR_NUMBER_SIZE]; + char displayName[SKINNY_DISPLAY_NAME_SIZE]; +} SkLineStatStruct; + +bool SkinnyValidateLineStat(SkLineStatStruct*); + // Endpoint -> Cisco Callmanager messages typedef struct { @@ -177,6 +190,7 @@ bool SkinnyValidateOpenReceiveChannelAck(SkOpenReceiveChannelAckStruct *); #define SKINNY_MSG_CLOSE_RECEIVE_CHANNEL "CloseReceiveChannel" #define SKINNY_MSG_CALL_INFO_MESSAGE "CallInfoMessage" #define SKINNY_MSG_OPEN_RECEIVE_CHANNEL_ACK "OpenReceiveChannelAck" +#define SKINNY_MSG_LINE_STAT_MESSAGE "LineStatMessage" #define SKINNY_CALL_TYPE_INBOUND 1 #define SKINNY_CALL_TYPE_OUTBOUND 2 @@ -188,6 +202,7 @@ typedef enum SkStartMediaTransmission = 0x008A, SkStopMediaTransmission = 0x008B, SkCallInfoMessage = 0x008F, + SkLineStatMessage = 0x0092, SkCloseReceiveChannel = 0x0106, SkUnkn = 0x0 } SkinnyMessageEnum; diff --git a/orkaudio/audiocaptureplugins/voip/RtpSession.cpp b/orkaudio/audiocaptureplugins/voip/RtpSession.cpp index f05ec17..f3b9d12 100644 --- a/orkaudio/audiocaptureplugins/voip/RtpSession.cpp +++ b/orkaudio/audiocaptureplugins/voip/RtpSession.cpp @@ -248,6 +248,19 @@ void RtpSession::ReportMetadata() char szRemoteIp[16]; ACE_OS::inet_ntop(AF_INET, (void*)&m_remoteIp, szRemoteIp, sizeof(szRemoteIp)); + // Check if we don't have the local party based on the endpoint IP address + if(m_localParty.IsEmpty()) + { + if(m_protocol == ProtSkinny) + { + EndpointInfoRef endpointInfo = RtpSessionsSingleton::instance()->GetEndpointInfo(m_endPointIp); + if(endpointInfo.get()) + { + m_localParty = endpointInfo->m_extension; + } + } + } + // Make sure Local Party is always reported if(m_localParty.IsEmpty()) { @@ -777,6 +790,51 @@ void RtpSessions::ReportSkinnyStopMediaTransmission(SkStopMediaTransmissionStruc } } +void RtpSessions::ReportSkinnyLineStat(SkLineStatStruct* lineStat, IpHeaderStruct* ipHeader) +{ + if(strlen(lineStat->lineDirNumber) > 1) + { + EndpointInfoRef endpoint; + std::map::iterator pair; + pair = m_endpoints.find((unsigned int)(ipHeader->ip_dest.s_addr)); + if(pair != m_endpoints.end()) + { + // Update the existing endpoint info + endpoint = pair->second; + endpoint->m_extension = lineStat->lineDirNumber; + + } + else + { + // Create endpoint info for the new endpoint + endpoint.reset(new EndpointInfo()); + endpoint->m_extension = lineStat->lineDirNumber; + m_endpoints.insert(std::make_pair((unsigned int)(ipHeader->ip_dest.s_addr), endpoint)); + } + if(endpoint.get()) + { + CStdString logMsg; + char szEndpointIp[16]; + ACE_OS::inet_ntop(AF_INET, (void*)&ipHeader->ip_dest, szEndpointIp, sizeof(szEndpointIp)); + + logMsg.Format("Extension:%s is on endpoint:%s", endpoint->m_extension, szEndpointIp); + LOG4CXX_INFO(m_log, logMsg); + } + } +} + +EndpointInfoRef RtpSessions::GetEndpointInfo(struct in_addr endpointIp) +{ + std::map::iterator pair; + pair = m_endpoints.find((unsigned int)(endpointIp.s_addr)); + if(pair != m_endpoints.end()) + { + return pair->second; + } + return EndpointInfoRef(); +} + + void RtpSessions::Stop(RtpSessionRef& session) { session->Stop(); diff --git a/orkaudio/audiocaptureplugins/voip/RtpSession.h b/orkaudio/audiocaptureplugins/voip/RtpSession.h index 194db61..96ed18c 100644 --- a/orkaudio/audiocaptureplugins/voip/RtpSession.h +++ b/orkaudio/audiocaptureplugins/voip/RtpSession.h @@ -45,31 +45,17 @@ public: CStdString m_callId; }; +//============================================================= -class SccpCallInfoMessageInfo +class EndpointInfo { - CStdString m_callingParty; - CStdString m_calledParty; - CStdString m_callId; -}; -typedef boost::shared_ptr SccpCallInfoMessageInfoRef; - - -class SccpStartMediaTransmissionInfo -{ - struct in_addr m_remoteIp; - int m_remoteTcpPort; - CStdString m_callId; +public: + CStdString m_extension; }; -typedef boost::shared_ptr SccpStartMediaTransmissionInfoRef; - +typedef boost::shared_ptr EndpointInfoRef; -class SccpStopMediaTransmissionInfo -{ - CStdString m_callId; -}; -typedef boost::shared_ptr SccpStopMediaTransmissionInfoRef; +// ============================================================ class RtpSession { @@ -142,8 +128,10 @@ public: void ReportSkinnyStartMediaTransmission(SkStartMediaTransmissionStruct*, IpHeaderStruct* ipHeader); void ReportSkinnyStopMediaTransmission(SkStopMediaTransmissionStruct*, IpHeaderStruct* ipHeader); void ReportSkinnyOpenReceiveChannelAck(SkOpenReceiveChannelAckStruct*); + void ReportSkinnyLineStat(SkLineStatStruct*, IpHeaderStruct* ipHeader); void ReportRtpPacket(RtpPacketInfoRef& rtpPacket); void Hoover(time_t now); + EndpointInfoRef GetEndpointInfo(struct in_addr endpointIp); private: RtpSessionRef findByEndpointIp(struct in_addr); void ChangeCallId(RtpSessionRef& session, unsigned int newId); @@ -152,6 +140,7 @@ private: std::map m_byIpAndPort; std::map m_byCallId; + std::map m_endpoints; LoggerPtr m_log; AlphaCounter alphaCounter; }; diff --git a/orkaudio/audiocaptureplugins/voip/VoIp.cpp b/orkaudio/audiocaptureplugins/voip/VoIp.cpp index 1be3b25..77a9dc6 100644 --- a/orkaudio/audiocaptureplugins/voip/VoIp.cpp +++ b/orkaudio/audiocaptureplugins/voip/VoIp.cpp @@ -366,6 +366,7 @@ void HandleSkinnyMessage(SkinnyHeaderStruct* skinnyHeader, IpHeaderStruct* ipHea SkStopMediaTransmissionStruct* stopMedia; SkCallInfoStruct* callInfo; SkOpenReceiveChannelAckStruct* openReceiveAck; + SkLineStatStruct* lineStat; char szEndpointIp[16]; struct in_addr endpointIp = ipHeader->ip_dest; // most of the interesting skinny messages are CCM -> phone @@ -434,6 +435,24 @@ void HandleSkinnyMessage(SkinnyHeaderStruct* skinnyHeader, IpHeaderStruct* ipHea useful = false; LOG4CXX_WARN(s_skinnyPacketLog, "Invalid OpenReceiveChannelAck."); } + break; + case SkLineStatMessage: + lineStat = (SkLineStatStruct*)skinnyHeader; + if(SkinnyValidateLineStat(lineStat)) + { + if(s_skinnyPacketLog->isInfoEnabled()) + { + logMsg.Format(" line:%u extension:%s display name:%s", lineStat->lineNumber, lineStat->lineDirNumber, lineStat->displayName); + } + endpointIp = ipHeader->ip_dest; // this skinny message is CCM -> phone + RtpSessionsSingleton::instance()->ReportSkinnyLineStat(lineStat, ipHeader); + } + else + { + useful = false; + LOG4CXX_WARN(s_skinnyPacketLog, "Invalid LineStatMessage."); + } + break; default: useful = false; -- cgit v1.2.3