summaryrefslogtreecommitdiff
path: root/orkbasecxx
diff options
context:
space:
mode:
authorHenri Herscher <henri@oreka.org>2006-12-27 18:26:52 +0000
committerHenri Herscher <henri@oreka.org>2006-12-27 18:26:52 +0000
commit320f2a9dd5fd59b09e1977aa1f9344e219bf3d1a (patch)
tree0fddefd965d6816418a02cc3a25937636cb975fc /orkbasecxx
parent4da9cdff7f824859048184371fc524fbe5d326f3 (diff)
1. Subsequent SIP INVITES that could be associated to an existing session now disregarded because they could be disrupting valid sessions. We need to store the new INVITES and only use them when they are validated by a matching RTP stream.
2. New RTP streams are now logged within one session by the VoIP plugin. 3. Added a Debug config boolean that has the trackingId alpha counter reset to 0 (AAA) when enabled. git-svn-id: https://oreka.svn.sourceforge.net/svnroot/oreka/trunk@380 09dcff7a-b715-0410-9601-b79a96267cd0
Diffstat (limited to 'orkbasecxx')
-rw-r--r--orkbasecxx/Config.cpp2
-rw-r--r--orkbasecxx/Config.h3
-rw-r--r--orkbasecxx/Utils.cpp44
-rw-r--r--orkbasecxx/Utils.h46
4 files changed, 89 insertions, 6 deletions
diff --git a/orkbasecxx/Config.cpp b/orkbasecxx/Config.cpp
index 199b301..2dfa2f3 100644
--- a/orkbasecxx/Config.cpp
+++ b/orkbasecxx/Config.cpp
@@ -53,6 +53,7 @@ Config::Config()
m_reportingRetryDelay = 5;
m_clientTimeout = 5;
+ m_debug = DEBUG_DEFAULT;
}
void Config::Define(Serializer* s)
@@ -86,6 +87,7 @@ void Config::Define(Serializer* s)
s->CsvValue(CAPTURE_PORT_FILTERS_PARAM, m_capturePortFilters);
s->CsvValue(TAPE_PROCESSORS_PARAM, m_tapeProcessors);
s->IntValue(CAPTURE_FILE_BATCH_SIZE_KBYTE_PARAM, m_captureFileBatchSizeKByte);
+ s->BoolValue(DEBUG_PARAM, m_debug);
}
void Config::Validate()
diff --git a/orkbasecxx/Config.h b/orkbasecxx/Config.h
index 09fe6a4..30b74c5 100644
--- a/orkbasecxx/Config.h
+++ b/orkbasecxx/Config.h
@@ -73,6 +73,8 @@
#define TAPE_PROCESSORS_PARAM "TapeProcessors"
#define CAPTURE_FILE_BATCH_SIZE_KBYTE_PARAM "CaptureFileBatchSizeKByte"
#define CAPTURE_FILE_BATCH_SIZE_KBYTE_DEFAULT 4
+#define DEBUG_PARAM "Debug"
+#define DEBUG_DEFAULT false
class DLL_IMPORT_EXPORT_ORKBASE Config : public Object
{
@@ -114,6 +116,7 @@ public:
std::list<CStdString> m_capturePortFilters;
std::list<CStdString> m_tapeProcessors;
int m_captureFileBatchSizeKByte;
+ bool m_debug;
private:
log4cxx::LoggerPtr m_log;
diff --git a/orkbasecxx/Utils.cpp b/orkbasecxx/Utils.cpp
index cec44eb..d4e7f8a 100644
--- a/orkbasecxx/Utils.cpp
+++ b/orkbasecxx/Utils.cpp
@@ -1,5 +1,6 @@
#include "Utils.h"
#include "ace/OS_NS_stdio.h"
+#include "ace/OS_NS_arpa_inet.h"
//========================================================
// file related stuff
@@ -63,3 +64,46 @@ bool FileCanOpen(CStdString& path)
}
return false;
}
+
+//=====================================================
+// Network related stuff
+
+void TcpAddress::ToString(CStdString& string)
+{
+ char szIp[16];
+ ACE_OS::inet_ntop(AF_INET, (void*)&ip, szIp, sizeof(szIp));
+
+ string.Format("%s,%u", szIp, port);
+}
+
+
+void TcpAddressList::AddAddress(struct in_addr ip, unsigned short port)
+{
+ TcpAddress addr;
+ addr.ip = ip;
+ addr.port = port;
+ m_addresses.push_back(addr);
+}
+
+bool TcpAddressList::HasAddress(struct in_addr ip, unsigned short port)
+{
+ for(std::list<TcpAddress>::iterator it = m_addresses.begin(); it != m_addresses.end(); it++)
+ {
+ if ((unsigned int)((*it).ip.s_addr) == (unsigned int)ip.s_addr && (*it).port == port)
+ {
+ return true;
+ }
+ }
+ return false;
+}
+
+bool TcpAddressList::HasAddressOrAdd(struct in_addr ip, unsigned short port)
+{
+ if(HasAddress(ip, port) == false)
+ {
+ AddAddress(ip, port);
+ return false;
+ }
+ return true;
+}
+
diff --git a/orkbasecxx/Utils.h b/orkbasecxx/Utils.h
index 31abf5d..67f141e 100644
--- a/orkbasecxx/Utils.h
+++ b/orkbasecxx/Utils.h
@@ -14,6 +14,8 @@
#ifndef __UTILS_H__
#define __UTILS_H__
+#include <list>
+
#include "ace/Guard_T.h" // For some reason, this include must always come before the StdString include
// otherwise it gives the following compile error:
// error C2039: 'TryEnterCriticalSection' : is not a member of '`global namespace''
@@ -80,6 +82,26 @@ typedef ACE_Guard<ACE_Thread_Mutex> MutexSentinel;
//=====================================================
+// Network related stuff
+typedef struct
+{
+ void ToString(CStdString& string);
+
+ in_addr ip;
+ unsigned short port;
+} TcpAddress;
+
+class DLL_IMPORT_EXPORT_ORKBASE TcpAddressList
+{
+public:
+ void AddAddress(struct in_addr ip, unsigned short port);
+ bool HasAddress(struct in_addr ip, unsigned short port);
+ bool HasAddressOrAdd(struct in_addr ip, unsigned short port);
+private:
+ std::list<TcpAddress> m_addresses;
+};
+
+//=====================================================
// Miscellanous stuff
/** A counter that generates a "counting" 3 character strings, i.e. aaa, aab, ..., zzz
@@ -90,14 +112,21 @@ typedef ACE_Guard<ACE_Thread_Mutex> MutexSentinel;
class AlphaCounter
{
public:
- inline AlphaCounter::AlphaCounter()
+ inline AlphaCounter::AlphaCounter(int start = 0)
{
- // Generate pseudo-random number from high resolution time least significant two bytes
- ACE_hrtime_t hrtime = ACE_OS::gethrtime();
- unsigned short srandom = (short)hrtime;
- double drandom = (double)srandom/65536.0; // 0 <= random < 1
+ if(start)
+ {
+ m_counter = start;
+ }
+ else
+ {
+ // Generate pseudo-random number from high resolution time least significant two bytes
+ ACE_hrtime_t hrtime = ACE_OS::gethrtime();
+ unsigned short srandom = (short)hrtime;
+ double drandom = (double)srandom/65536.0; // 0 <= random < 1
- m_counter = (unsigned int)(drandom*(26*26*26));
+ m_counter = (unsigned int)(drandom*(26*26*26));
+ }
}
inline CStdString AlphaCounter::GetNext()
@@ -120,6 +149,11 @@ public:
string.Format("%c%c%c", char1val, char2val, char3val);
return string;
}
+
+ inline void AlphaCounter::Reset()
+ {
+ m_counter = 0;
+ }
private:
unsigned int m_counter;
};