summaryrefslogtreecommitdiff
path: root/orkaudio/audiocaptureplugins/voip
diff options
context:
space:
mode:
authorHenri Herscher <henri@oreka.org>2006-09-12 20:57:52 +0000
committerHenri Herscher <henri@oreka.org>2006-09-12 20:57:52 +0000
commit4b30474b50b5282705eabe481b850e0bf80bcfae (patch)
tree349217343a8dac5bde20ee73ac7a2d75b7a8c601 /orkaudio/audiocaptureplugins/voip
parentfb2bbcf30b8df02ec8487f3b2ebd6ddc865c4fca (diff)
pcap socket buffer size now configurable under Linux only (<PcapSocketBufferSize> config parameter).
git-svn-id: https://oreka.svn.sourceforge.net/svnroot/oreka/trunk@334 09dcff7a-b715-0410-9601-b79a96267cd0
Diffstat (limited to 'orkaudio/audiocaptureplugins/voip')
-rw-r--r--orkaudio/audiocaptureplugins/voip/VoIp.cpp30
-rw-r--r--orkaudio/audiocaptureplugins/voip/VoIpConfig.cpp9
-rw-r--r--orkaudio/audiocaptureplugins/voip/VoIpConfig.h1
3 files changed, 39 insertions, 1 deletions
diff --git a/orkaudio/audiocaptureplugins/voip/VoIp.cpp b/orkaudio/audiocaptureplugins/voip/VoIp.cpp
index 802aa04..2b9e02a 100644
--- a/orkaudio/audiocaptureplugins/voip/VoIp.cpp
+++ b/orkaudio/audiocaptureplugins/voip/VoIp.cpp
@@ -13,6 +13,10 @@
#define _WINSOCKAPI_ // prevents the inclusion of winsock.h
+#ifndef WIN32
+#include "sys/socket.h"
+#endif
+
#include <list>
#include "ace/OS_NS_unistd.h"
#include "ace/OS_NS_string.h"
@@ -70,7 +74,8 @@ public:
private:
void OpenDevices();
void OpenPcapFile(CStdString& filename);
- void VoIp::OpenPcapDirectory(CStdString& path);
+ void OpenPcapDirectory(CStdString& path);
+ void SetPcapSocketBufferSize(pcap_t* pcapHandle);
pcap_t* m_pcapHandle;
std::list<pcap_t*> m_pcapHandles;
@@ -742,6 +747,27 @@ void VoIp::OpenPcapFile(CStdString& filename)
}
}
+void VoIp::SetPcapSocketBufferSize(pcap_t* pcapHandle)
+{
+#ifndef WIN32
+ CStdString logMsg = "failure";
+ int pcapFileno = pcap_fileno(m_pcapHandle);
+ size_t bufSize = DLLCONFIG.m_pcapSocketBufferSize;
+ if(bufSize < 1)
+ {
+ return;
+ }
+ if(pcapFileno)
+ {
+ if(setsockopt(pcapFileno, SOL_SOCKET, SO_RCVBUF, &bufSize, sizeof(bufSize)) == 0)
+ {
+ logMsg = "success";
+ }
+ }
+ logMsg.Format("Setting pcap socket buffer size:%u bytes ... %s", bufSize, logMsg);
+ LOG4CXX_INFO(s_packetLog, logMsg);
+#endif
+}
void VoIp::OpenDevices()
{
@@ -789,6 +815,7 @@ void VoIp::OpenDevices()
CStdString logMsg;
logMsg.Format("Successfully opened device. pcap handle:%x", m_pcapHandle);
LOG4CXX_INFO(s_packetLog, logMsg);
+ SetPcapSocketBufferSize(m_pcapHandle);
m_pcapHandles.push_back(m_pcapHandle);
}
@@ -814,6 +841,7 @@ void VoIp::OpenDevices()
{
logMsg.Format("Successfully opened default device:%s pcap handle:%x", defaultDevice->name, m_pcapHandle);
LOG4CXX_INFO(s_packetLog, logMsg);
+ SetPcapSocketBufferSize(m_pcapHandle);
m_pcapHandles.push_back(m_pcapHandle);
}
diff --git a/orkaudio/audiocaptureplugins/voip/VoIpConfig.cpp b/orkaudio/audiocaptureplugins/voip/VoIpConfig.cpp
index 9863b5a..17e64c0 100644
--- a/orkaudio/audiocaptureplugins/voip/VoIpConfig.cpp
+++ b/orkaudio/audiocaptureplugins/voip/VoIpConfig.cpp
@@ -27,6 +27,7 @@ VoIpConfig::VoIpConfig()
m_sipDropIndirectInvite = false;
m_pcapRepeat = false;
+ m_pcapSocketBufferSize = 0;
}
void VoIpConfig::Define(Serializer* s)
@@ -43,6 +44,7 @@ void VoIpConfig::Define(Serializer* s)
s->StringValue("PcapDirectory", m_pcapDirectory);
s->BoolValue("PcapRepeat", m_pcapRepeat);
s->BoolValue("SipDropIndirectInvite", m_sipDropIndirectInvite);
+ s->IntValue("PcapSocketBufferSize", m_pcapSocketBufferSize);
}
void VoIpConfig::Validate()
@@ -170,6 +172,13 @@ void VoIpConfig::Validate()
throw (CStdString("VoIpConfig: invalid IP range in BlockedIpRanges:" + entry) + " please fix config.xml");
}
}
+ if(m_pcapSocketBufferSize < 0)
+ {
+ CStdString exception;
+ exception.Format("VoIpConfig: PcapSocketBufferSize must be a positive number (currently:%d) please fix config.xml", m_pcapSocketBufferSize);
+ throw (exception);
+
+ }
}
bool VoIpConfig::IsPartOfLan(struct in_addr addr)
diff --git a/orkaudio/audiocaptureplugins/voip/VoIpConfig.h b/orkaudio/audiocaptureplugins/voip/VoIpConfig.h
index 751d339..33821ac 100644
--- a/orkaudio/audiocaptureplugins/voip/VoIpConfig.h
+++ b/orkaudio/audiocaptureplugins/voip/VoIpConfig.h
@@ -57,6 +57,7 @@ public:
CStdString m_pcapDirectory;
bool m_pcapRepeat;
bool m_sipDropIndirectInvite;
+ int m_pcapSocketBufferSize;
};
//========================================