summaryrefslogtreecommitdiff
path: root/orkaudio/audiocaptureplugins
diff options
context:
space:
mode:
Diffstat (limited to 'orkaudio/audiocaptureplugins')
-rw-r--r--orkaudio/audiocaptureplugins/voip/RtpSession.cpp95
-rw-r--r--orkaudio/audiocaptureplugins/voip/RtpSession.h4
-rw-r--r--orkaudio/audiocaptureplugins/voip/VoIp.cpp67
-rw-r--r--orkaudio/audiocaptureplugins/voip/VoIpConfig.cpp173
-rw-r--r--orkaudio/audiocaptureplugins/voip/VoIpConfig.h11
5 files changed, 292 insertions, 58 deletions
diff --git a/orkaudio/audiocaptureplugins/voip/RtpSession.cpp b/orkaudio/audiocaptureplugins/voip/RtpSession.cpp
index b7fe114..2e74786 100644
--- a/orkaudio/audiocaptureplugins/voip/RtpSession.cpp
+++ b/orkaudio/audiocaptureplugins/voip/RtpSession.cpp
@@ -30,12 +30,6 @@ extern VoIpConfigTopObjectRef g_VoIpConfigTopObjectRef;
#define DLLCONFIG g_VoIpConfigTopObjectRef.get()->m_config
-SipInviteInfo::SipInviteInfo()
-{
- m_fromIp.s_addr = 0;
-}
-
-
RtpSession::RtpSession(CStdString& trackingId)
{
m_trackingId = trackingId;
@@ -54,9 +48,10 @@ RtpSession::RtpSession(CStdString& trackingId)
void RtpSession::Stop()
{
+ LOG4CXX_INFO(m_log, m_trackingId + ": " + m_capturePort + " Session stop");
+
if(m_started)
{
- LOG4CXX_INFO(m_log, m_trackingId + ": " + m_capturePort + " Session stop");
CaptureEventRef stopEvent(new CaptureEvent);
stopEvent->m_type = CaptureEvent::EtStop;
stopEvent->m_timestamp = time(NULL);
@@ -152,13 +147,13 @@ void RtpSession::ProcessMetadataSip(RtpPacketInfoRef& rtpPacket)
bool done = false;
// work out invitee IP address
- if(rtpPacket->m_sourceIp.s_addr == m_invitorIp.s_addr)
+ if((unsigned int)rtpPacket->m_sourceIp.s_addr == (unsigned int)m_invitorIp.s_addr)
{
m_inviteeIp = rtpPacket->m_destIp;
m_inviteeTcpPort = rtpPacket->m_destPort;
m_invitorTcpPort = rtpPacket->m_sourcePort;
}
- else if(rtpPacket->m_destIp.s_addr == m_invitorIp.s_addr)
+ 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;
@@ -281,7 +276,7 @@ void RtpSession::AddRtpPacket(RtpPacketInfoRef& rtpPacket)
}
else
{
- if(rtpPacket->m_sourceIp.s_addr == m_lastRtpPacketSide1->m_sourceIp.s_addr)
+ if((unsigned int)rtpPacket->m_sourceIp.s_addr == (unsigned int)m_lastRtpPacketSide1->m_sourceIp.s_addr)
{
m_lastRtpPacketSide1 = rtpPacket;
channel = 1;
@@ -355,8 +350,7 @@ void RtpSession::AddRtpPacket(RtpPacketInfoRef& rtpPacket)
details.m_encoding = AlawAudio;
AudioChunkRef chunk(new AudioChunk());
chunk->SetBuffer(rtpPacket->m_payload, rtpPacket->m_payloadSize, details);
- g_audioChunkCallBack(chunk, m_capturePort); // ##### after
- //m_rtpRingBuffer.AddRtpPacket(rtpPacket); // ##### before
+ g_audioChunkCallBack(chunk, m_capturePort);
m_lastUpdated = rtpPacket->m_arrivalTimestamp;
}
@@ -366,7 +360,7 @@ void RtpSession::AddRtpPacket(RtpPacketInfoRef& rtpPacket)
void RtpSession::ReportSipInvite(SipInviteInfoRef& invite)
{
m_invite = invite;
- m_invitorIp = invite->m_fromIp;
+ m_invitorIp = invite->m_fromRtpIp;
}
int RtpSession::ProtocolToEnum(CStdString& protocol)
@@ -416,34 +410,36 @@ RtpSessions::RtpSessions()
void RtpSessions::ReportSipInvite(SipInviteInfoRef& invite)
{
- char szFromIp[16];
- ACE_OS::inet_ntop(AF_INET, (void*)&invite->m_fromIp, szFromIp, sizeof(szFromIp));
+ char szFromRtpIp[16];
+ ACE_OS::inet_ntop(AF_INET, (void*)&invite->m_fromRtpIp, szFromRtpIp, sizeof(szFromRtpIp));
- CStdString ipAndPort = CStdString(szFromIp) + "," + invite->m_fromRtpPort;
+ CStdString ipAndPort = CStdString(szFromRtpIp) + "," + invite->m_fromRtpPort;
std::map<CStdString, RtpSessionRef>::iterator pair;
pair = m_byIpAndPort.find(ipAndPort);
if (pair != m_byIpAndPort.end())
{
- // #### old behaviour
- // A session exists ont the same IP+port, stop old session
- //RtpSessionRef session = pair->second;
- //Stop(session);
-
- // #### new behaviour
// The session already exists, do nothing
return;
}
pair = m_byCallId.find(invite->m_callId);
if (pair != m_byCallId.end())
{
- // #### old behaviour
- // A session exists ont the same CallId, stop old session
- //RtpSessionRef session = pair->second;
- //Stop(session);
+ // The session already exists
+ RtpSessionRef session = pair->second;
+ if(!session->m_ipAndPort.Equals(ipAndPort))
+ {
+ // The session RTP connection address has changed
+ // Remove session from IP and Port map
+ m_byIpAndPort.erase(session->m_ipAndPort);
+ // ... update
+ session->m_ipAndPort = ipAndPort;
+ session->ReportSipInvite(invite);
+ // ... and reinsert
+ m_byIpAndPort.insert(std::make_pair(session->m_ipAndPort, session));
- // #### new behaviour
- // The session already exists, do nothing
+ LOG4CXX_INFO(m_log, session->m_trackingId + ": updated with new INVITE data");
+ }
return;
}
@@ -456,6 +452,11 @@ void RtpSessions::ReportSipInvite(SipInviteInfoRef& invite)
session->ReportSipInvite(invite);
m_byIpAndPort.insert(std::make_pair(session->m_ipAndPort, session));
m_byCallId.insert(std::make_pair(session->m_callId, session));
+
+ CStdString numSessions = IntToString(m_byIpAndPort.size());
+ LOG4CXX_DEBUG(m_log, CStdString("ByIpAndPort: ") + numSessions);
+
+ LOG4CXX_INFO(m_log, trackingId + ": created by SIP INVITE");
}
void RtpSessions::ReportSipBye(SipByeInfo bye)
@@ -515,6 +516,10 @@ void RtpSessions::ReportSkinnyCallInfo(SkCallInfoStruct* callInfo, IpHeaderStruc
}
m_byCallId.insert(std::make_pair(session->m_callId, session));
+
+ CStdString numSessions = IntToString(m_byIpAndPort.size());
+ LOG4CXX_DEBUG(m_log, CStdString("ByIpAndPort: ") + numSessions);
+
}
void RtpSessions::ReportSkinnyStartMediaTransmission(SkStartMediaTransmissionStruct* startMedia, IpHeaderStruct* ipHeader)
@@ -532,7 +537,7 @@ void RtpSessions::ReportSkinnyStartMediaTransmission(SkStartMediaTransmissionStr
{
RtpSessionRef tmpSession = pair->second;
- if(tmpSession->m_endPointIp.s_addr == ipHeader->ip_dest.s_addr)
+ if((unsigned int)tmpSession->m_endPointIp.s_addr == (unsigned int)ipHeader->ip_dest.s_addr)
{
if(tmpSession->m_ipAndPort.size() == 0)
{
@@ -608,6 +613,9 @@ void RtpSessions::ReportSkinnyStartMediaTransmission(SkStartMediaTransmissionStr
session->m_ipAndPort = ipAndPort;
m_byIpAndPort.insert(std::make_pair(session->m_ipAndPort, session));
+
+ CStdString numSessions = IntToString(m_byIpAndPort.size());
+ LOG4CXX_DEBUG(m_log, CStdString("ByIpAndPort: ") + numSessions);
}
else
{
@@ -658,6 +666,9 @@ void RtpSessions::Stop(RtpSessionRef& session)
if(session->m_ipAndPort.size() > 0)
{
m_byIpAndPort.erase(session->m_ipAndPort);
+
+ CStdString numSessions = IntToString(m_byIpAndPort.size());
+ LOG4CXX_DEBUG(m_log, CStdString("ByIpAndPort: ") + numSessions);
}
if(session->m_callId.size() > 0)
{
@@ -687,7 +698,7 @@ void RtpSessions::ReportRtpPacket(RtpPacketInfoRef& rtpPacket)
if (pair != m_byIpAndPort.end())
{
session1 = pair->second;
- if (!session1.get() == NULL)
+ if (session1.get() != NULL)
{
// Found a session give it the RTP packet info
session1->AddRtpPacket(rtpPacket);
@@ -705,7 +716,7 @@ void RtpSessions::ReportRtpPacket(RtpPacketInfoRef& rtpPacket)
if (pair != m_byIpAndPort.end())
{
session2 = pair->second;
- if (!session2.get() == NULL)
+ if (session2.get() != NULL)
{
// Found a session give it the RTP packet info
session2->AddRtpPacket(rtpPacket);
@@ -764,6 +775,11 @@ void RtpSessions::ReportRtpPacket(RtpPacketInfoRef& rtpPacket)
session->m_ipAndPort = ipAndPort;
session->AddRtpPacket(rtpPacket);
m_byIpAndPort.insert(std::make_pair(ipAndPort, session));
+
+ CStdString numSessions = IntToString(m_byIpAndPort.size());
+ LOG4CXX_DEBUG(m_log, CStdString("ByIpAndPort: ") + numSessions);
+
+ LOG4CXX_INFO(m_log, trackingId + ": created by RTP packet");
}
}
@@ -820,12 +836,23 @@ void RtpSessions::Hoover(time_t now)
}
//==========================================================
+SipInviteInfo::SipInviteInfo()
+{
+ m_fromRtpIp.s_addr = 0;
+}
+
void SipInviteInfo::ToString(CStdString& string)
{
- char fromIp[16];
- ACE_OS::inet_ntop(AF_INET, (void*)&m_fromIp, fromIp, sizeof(fromIp));
+ char fromRtpIp[16];
+ ACE_OS::inet_ntop(AF_INET, (void*)&m_fromRtpIp, fromRtpIp, sizeof(fromRtpIp));
+
+ char senderIp[16];
+ ACE_OS::inet_ntop(AF_INET, (void*)&m_senderIp, senderIp, sizeof(senderIp));
+
+ char receiverIp[16];
+ ACE_OS::inet_ntop(AF_INET, (void*)&m_receiverIp, receiverIp, sizeof(receiverIp));
- string.Format("from:%s %s,%s to:%s callid:%s", m_from, fromIp, m_fromRtpPort, m_to, m_callId);
+ 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);
}
diff --git a/orkaudio/audiocaptureplugins/voip/RtpSession.h b/orkaudio/audiocaptureplugins/voip/RtpSession.h
index 50e979b..6e9c739 100644
--- a/orkaudio/audiocaptureplugins/voip/RtpSession.h
+++ b/orkaudio/audiocaptureplugins/voip/RtpSession.h
@@ -26,7 +26,9 @@ public:
SipInviteInfo();
void ToString(CStdString& string);
- struct in_addr m_fromIp;
+ struct in_addr m_senderIp;
+ struct in_addr m_receiverIp;
+ struct in_addr m_fromRtpIp;
CStdString m_fromRtpPort;
CStdString m_from;
CStdString m_to;
diff --git a/orkaudio/audiocaptureplugins/voip/VoIp.cpp b/orkaudio/audiocaptureplugins/voip/VoIp.cpp
index f9124c8..e8702c0 100644
--- a/orkaudio/audiocaptureplugins/voip/VoIp.cpp
+++ b/orkaudio/audiocaptureplugins/voip/VoIp.cpp
@@ -44,6 +44,7 @@ static LoggerPtr s_rtpPacketLog;
static LoggerPtr s_sipPacketLog;
static LoggerPtr s_skinnyPacketLog;
static LoggerPtr s_sipExtractionLog;
+static LoggerPtr s_voipPluginLog;
static time_t s_lastHooveringTime;
static ACE_Thread_Mutex s_mutex;
static bool s_liveCapture;
@@ -212,9 +213,12 @@ bool TrySipBye(EthernetHeaderStruct* ethernetHeader, IpHeaderStruct* ipHeader, U
if(callIdField)
{
GrabToken(callIdField, info.m_callId);
- RtpSessionsSingleton::instance()->ReportSipBye(info);
}
LOG4CXX_INFO(s_sipPacketLog, "BYE: callid:" + info.m_callId);
+ if(callIdField)
+ {
+ RtpSessionsSingleton::instance()->ReportSipBye(info);
+ }
}
return result;
}
@@ -222,6 +226,7 @@ bool TrySipBye(EthernetHeaderStruct* ethernetHeader, IpHeaderStruct* ipHeader, U
bool TrySipInvite(EthernetHeaderStruct* ethernetHeader, IpHeaderStruct* ipHeader, UdpHeaderStruct* udpHeader, u_char* udpPayload)
{
bool result = false;
+ bool drop = false;
if (memcmp("INVITE", (void*)udpPayload, 6) == 0)
{
result = true;
@@ -260,13 +265,9 @@ bool TrySipInvite(EthernetHeaderStruct* ethernetHeader, IpHeaderStruct* ipHeader
}
if(toField)
{
- char* toFieldEnd = NULL;
- if(s_sipExtractionLog->isDebugEnabled())
- {
- CStdString to;
- toFieldEnd = GrabLine(toField, sipEnd, to);
- LOG4CXX_DEBUG(s_sipExtractionLog, "to: " + to);
- }
+ CStdString to;
+ char* toFieldEnd = GrabLine(toField, sipEnd, to);
+ LOG4CXX_DEBUG(s_sipExtractionLog, "to: " + to);
char* sipUser = memFindAfter("sip:", toField, toFieldEnd);
if(sipUser)
@@ -297,25 +298,36 @@ bool TrySipInvite(EthernetHeaderStruct* ethernetHeader, IpHeaderStruct* ipHeader
{
if(ACE_OS::inet_aton((PCSTR)connectionAddress, &fromIp))
{
- info->m_fromIp = fromIp;
+ info->m_fromRtpIp = fromIp;
+
+ if (DLLCONFIG.m_sipDropIndirectInvite)
+ {
+ if((unsigned int)fromIp.s_addr != (unsigned int)ipHeader->ip_src.s_addr)
+ {
+ // SIP invite SDP connection address does not match with SIP packet origin
+ drop =true;
+ }
+ }
}
}
}
- if(info->m_fromIp.s_addr == 0)
+ if((unsigned int)info->m_fromRtpIp.s_addr == 0)
{
// In case connection address could not be extracted, use SIP invite sender IP address
- info->m_fromIp = ipHeader->ip_src;
- }
-
- if(info->m_fromRtpPort.size() && info->m_from.size() && info->m_to.size() && info->m_callId.size())
- {
- RtpSessionsSingleton::instance()->ReportSipInvite(info);
+ info->m_fromRtpIp = ipHeader->ip_src;
}
+ info->m_senderIp = ipHeader->ip_src;
+ info->m_receiverIp = ipHeader->ip_dest;
CStdString logMsg;
info->ToString(logMsg);
logMsg = "INVITE: " + logMsg;
LOG4CXX_INFO(s_sipPacketLog, logMsg);
+
+ if(drop == false && info->m_fromRtpPort.size() && info->m_from.size() && info->m_to.size() && info->m_callId.size())
+ {
+ RtpSessionsSingleton::instance()->ReportSipInvite(info);
+ }
}
return result;
}
@@ -378,9 +390,20 @@ void HandlePacket(u_char *param, const struct pcap_pkthdr *header, const u_char
{
// This is a pcap file replay, make sure Orkaudio won't be flooded by too many
// packets at a time by yielding control to other threads.
- ACE_Time_Value yield;
- yield.set(0,1); // 1 us
- ACE_OS::sleep(yield);
+ //ACE_Time_Value yield;
+ //yield.set(0,1); // 1 us
+ //ACE_OS::sleep(yield);
+
+ // Use nanosleep instead
+ struct timespec ts;
+ ts.tv_sec = 0;
+ ts.tv_nsec = 1;
+ ACE_OS::nanosleep (&ts, NULL);
+ }
+
+ if(DLLCONFIG.IsPacketWanted(ipHeader) == false)
+ {
+ return;
}
if(ipHeader->ip_p == IPPROTO_UDP)
@@ -496,6 +519,8 @@ VoIp::VoIp()
void Configure(DOMNode* node)
{
+ s_voipPluginLog = Logger::getLogger("voipplugin");
+
if (node)
{
VoIpConfigTopObjectRef VoIpConfigTopObjectRef(new VoIpConfigTopObject);
@@ -506,12 +531,12 @@ void Configure(DOMNode* node)
}
catch (CStdString& e)
{
- LOG4CXX_WARN(g_logManager->rootLog, "VoIp.dll: " + e);
+ LOG4CXX_ERROR(s_voipPluginLog, e);
}
}
else
{
- LOG4CXX_WARN(g_logManager->rootLog, "VoIp.dll: got empty DOM tree");
+ LOG4CXX_ERROR(s_voipPluginLog, "Got empty DOM tree");
}
}
diff --git a/orkaudio/audiocaptureplugins/voip/VoIpConfig.cpp b/orkaudio/audiocaptureplugins/voip/VoIpConfig.cpp
index 7cb6dde..5a12214 100644
--- a/orkaudio/audiocaptureplugins/voip/VoIpConfig.cpp
+++ b/orkaudio/audiocaptureplugins/voip/VoIpConfig.cpp
@@ -24,6 +24,8 @@ VoIpConfig::VoIpConfig()
m_asciiLanMasks.push_back("192.168.255.255");
m_asciiLanMasks.push_back("10.255.255.255");
m_asciiLanMasks.push_back("172.31.255.255");
+
+ m_sipDropIndirectInvite = false;
}
void VoIpConfig::Define(Serializer* s)
@@ -32,8 +34,13 @@ void VoIpConfig::Define(Serializer* s)
s->CsvValue("Devices", m_devices);
s->CsvValue("LanMasks", m_asciiLanMasks);
s->CsvValue("MediaGateways", m_asciiMediaGateways);
+
+ s->CsvValue("BlockedIpRanges", m_asciiBlockedIpRanges);
+ s->CsvValue("AllowedIpRanges", m_asciiAllowedIpRanges);
+
s->StringValue("PcapFile", m_pcapFile);
s->StringValue("PcapDirectory", m_pcapDirectory);
+ s->BoolValue("SipDropIndirectInvite", m_sipDropIndirectInvite);
}
void VoIpConfig::Validate()
@@ -50,7 +57,7 @@ void VoIpConfig::Validate()
}
else
{
- throw (CStdString("VoIpConfig: invalid IP address in LanMasks:" + *it));
+ throw (CStdString("VoIpConfig: invalid IP address in LanMasks:" + *it) + " please fix config.xml");
}
}
@@ -65,7 +72,100 @@ void VoIpConfig::Validate()
}
else
{
- throw (CStdString("VoIpConfig: invalid IP address in MediaGateways:" + *it));
+ throw (CStdString("VoIpConfig: invalid IP address in MediaGateways:" + *it) + " please fix config.xml");
+ }
+ }
+
+ // Iterate over ascii allowed IP ranges and populate the bit width and prefix lists
+ m_allowedIpRangePrefixes.clear();
+ m_allowedIpRangeBitWidths.clear();
+ for(it = m_asciiAllowedIpRanges.begin(); it != m_asciiAllowedIpRanges.end(); it++)
+ {
+ CStdString cidrPrefixLengthString;
+ unsigned int cidrPrefixLength = 32; // by default, x.x.x.x/32
+ CStdString cidrIpAddressString;
+ struct in_addr cidrIpAddress;
+
+ CStdString entry = *it;
+ int slashPosition = entry.Find('/');
+ if(slashPosition > 0)
+ {
+ cidrIpAddressString = entry.Left(slashPosition);
+ cidrPrefixLengthString = entry.Mid(slashPosition+1);
+
+ bool notAnInt = false;
+ try
+ {
+ cidrPrefixLength = StringToInt(cidrPrefixLengthString);
+ }
+ catch (...) {notAnInt = true;}
+ if(cidrPrefixLength < 1 || cidrPrefixLength > 32 || notAnInt)
+ {
+ throw (CStdString("VoIpConfig: invalid CIDR prefix length in AllowedIpRanges:" + entry) + " please fix config.xml");
+ }
+ }
+ else
+ {
+ cidrIpAddressString = entry;
+ }
+
+ if(ACE_OS::inet_aton((PCSTR)cidrIpAddressString, &cidrIpAddress))
+ {
+ unsigned int rangeBitWidth = 32-cidrPrefixLength;
+ unsigned int prefix = ntohl((unsigned int)cidrIpAddress.s_addr) >> (rangeBitWidth);
+ m_allowedIpRangePrefixes.push_back(prefix);
+ m_allowedIpRangeBitWidths.push_back(rangeBitWidth);
+ }
+ else
+ {
+ throw (CStdString("VoIpConfig: invalid IP range in AllowedIpRanges:" + entry) + " please fix config.xml");
+ }
+ }
+
+
+ // Iterate over ascii blocked IP ranges and populate the bit width and prefix lists
+ m_blockedIpRangePrefixes.clear();
+ m_blockedIpRangeBitWidths.clear();
+ for(it = m_asciiBlockedIpRanges.begin(); it != m_asciiBlockedIpRanges.end(); it++)
+ {
+ CStdString cidrPrefixLengthString;
+ unsigned int cidrPrefixLength = 32; // by default, x.x.x.x/32
+ CStdString cidrIpAddressString;
+ struct in_addr cidrIpAddress;
+
+ CStdString entry = *it;
+ int slashPosition = entry.Find('/');
+ if(slashPosition > 0)
+ {
+ cidrIpAddressString = entry.Left(slashPosition);
+ cidrPrefixLengthString = entry.Mid(slashPosition+1);
+
+ bool notAnInt = false;
+ try
+ {
+ cidrPrefixLength = StringToInt(cidrPrefixLengthString);
+ }
+ catch (...) {notAnInt = true;}
+ if(cidrPrefixLength < 1 || cidrPrefixLength > 32 || notAnInt)
+ {
+ throw (CStdString("VoIpConfig: invalid CIDR prefix length in blockedIpRanges:" + entry) + " please fix config.xml");
+ }
+ }
+ else
+ {
+ cidrIpAddressString = entry;
+ }
+
+ if(ACE_OS::inet_aton((PCSTR)cidrIpAddressString, &cidrIpAddress))
+ {
+ unsigned int rangeBitWidth = 32-cidrPrefixLength;
+ unsigned int prefix = ntohl((unsigned int)cidrIpAddress.s_addr) >> (rangeBitWidth);
+ m_blockedIpRangePrefixes.push_back(prefix);
+ m_blockedIpRangeBitWidths.push_back(rangeBitWidth);
+ }
+ else
+ {
+ throw (CStdString("VoIpConfig: invalid IP range in BlockedIpRanges:" + entry) + " please fix config.xml");
}
}
}
@@ -94,6 +194,75 @@ bool VoIpConfig::IsMediaGateway(struct in_addr addr)
return false;
}
+bool VoIpConfig::IsPacketWanted(IpHeaderStruct* ipHeader)
+{
+ bool wanted = true; // keep packet by default
+
+ // If source or destination IP address does not match any existing allowing mask, drop packet
+ if(m_allowedIpRangePrefixes.size() > 0)
+ {
+ wanted = false; // Presence of allowing ranges -> drop packet by default
+
+ bool sourceWanted = false;
+ std::list<unsigned int>::iterator bitWidthIt = m_allowedIpRangeBitWidths.begin();
+ std::list<unsigned int>::iterator prefixIt = m_allowedIpRangePrefixes.begin();
+ while(prefixIt != m_allowedIpRangePrefixes.end())
+ {
+ unsigned int bitWidth = *bitWidthIt;
+ unsigned int prefix = *prefixIt;
+ unsigned int packetSourcePrefix = ntohl((unsigned int)ipHeader->ip_src.s_addr) >> bitWidth;
+ if(packetSourcePrefix == prefix)
+ {
+ sourceWanted = true;
+ break;
+ }
+ prefixIt++;
+ bitWidthIt++;
+ }
+ if(sourceWanted)
+ {
+ std::list<unsigned int>::iterator bitWidthIt = m_allowedIpRangeBitWidths.begin();
+ std::list<unsigned int>::iterator prefixIt = m_allowedIpRangePrefixes.begin();
+ while(prefixIt != m_allowedIpRangePrefixes.end())
+ {
+ unsigned int bitWidth = *bitWidthIt;
+ unsigned int prefix = *prefixIt;
+ unsigned int packetDestPrefix = ntohl((unsigned int)ipHeader->ip_dest.s_addr) >> bitWidth;
+ if(packetDestPrefix == prefix)
+ {
+ wanted = true;
+ break;
+ }
+ prefixIt++;
+ bitWidthIt++;
+ }
+ }
+ }
+ // If source or destination IP address does match any existing blocking range, drop packet
+ std::list<unsigned int>::iterator bitWidthIt = m_blockedIpRangeBitWidths.begin();
+ std::list<unsigned int>::iterator prefixIt = m_blockedIpRangePrefixes.begin();
+
+ while(prefixIt != m_blockedIpRangePrefixes.end() && wanted == true)
+ {
+ unsigned int bitWidth = *bitWidthIt;
+ unsigned int prefix = *prefixIt;
+ unsigned int packetSourcePrefix = ntohl((unsigned int)ipHeader->ip_src.s_addr) >> bitWidth;
+ unsigned int packetDestPrefix = ntohl((unsigned int)ipHeader->ip_dest.s_addr) >> bitWidth;
+
+ if(packetSourcePrefix == prefix)
+ {
+ wanted = false;
+ }
+ if(packetDestPrefix == prefix)
+ {
+ wanted = false;
+ }
+ prefixIt++;
+ bitWidthIt++;
+ }
+ return wanted;
+}
+
bool VoIpConfig::IsDeviceWanted(CStdString device)
{
if(device.Equals(m_device))
diff --git a/orkaudio/audiocaptureplugins/voip/VoIpConfig.h b/orkaudio/audiocaptureplugins/voip/VoIpConfig.h
index 4a9ce83..5313389 100644
--- a/orkaudio/audiocaptureplugins/voip/VoIpConfig.h
+++ b/orkaudio/audiocaptureplugins/voip/VoIpConfig.h
@@ -18,6 +18,7 @@
#include "StdString.h"
#include "Object.h"
#include "boost/shared_ptr.hpp"
+#include "PacketHeaderDefs.h"
#define DEVICE_PARAM "Device"
@@ -36,6 +37,7 @@ public:
bool IsPartOfLan(struct in_addr);
bool IsMediaGateway(struct in_addr);
bool IsDeviceWanted(CStdString device);
+ bool IsPacketWanted(IpHeaderStruct* ipHeader);
CStdString m_device; // old style but can still be used for specifying single device
std::list<CStdString> m_devices; // new style devices csv
@@ -43,8 +45,17 @@ public:
std::list<CStdString> m_asciiMediaGateways;
std::list<unsigned int> m_lanMasks;
std::list<CStdString> m_asciiLanMasks;
+
+ std::list<CStdString> m_asciiAllowedIpRanges; // CIDR notation
+ std::list<unsigned int> m_allowedIpRangePrefixes;
+ std::list<unsigned int> m_allowedIpRangeBitWidths;
+ std::list<CStdString> m_asciiBlockedIpRanges; // CIDR notation
+ std::list<unsigned int> m_blockedIpRangePrefixes;
+ std::list<unsigned int> m_blockedIpRangeBitWidths;
+
CStdString m_pcapFile;
CStdString m_pcapDirectory;
+ bool m_sipDropIndirectInvite;
};
//========================================