summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOthmar Gsenger <otti@anytun.org>2007-12-23 12:55:43 +0000
committerOthmar Gsenger <otti@anytun.org>2007-12-23 12:55:43 +0000
commit2d299769941907cb55df955754f0ca6869c0b1ae (patch)
tree5c886d636a816bfd520e2a9edd706083e2d02c40
parentadded SyncQueue and SyncSocketHandler (diff)
activated online syncing
-rw-r--r--anytun.cpp11
-rw-r--r--syncQueue.cpp17
-rw-r--r--syncQueue.h3
3 files changed, 27 insertions, 4 deletions
diff --git a/anytun.cpp b/anytun.cpp
index 5a0578a..13c5371 100644
--- a/anytun.cpp
+++ b/anytun.cpp
@@ -55,6 +55,7 @@
#include "syncSocket.h"
#include "syncClientSocket.h"
+#include "syncCommand.h"
#define PAYLOAD_TYPE_TAP 0x6558
#define PAYLOAD_TYPE_TUN 0x0800
@@ -83,7 +84,7 @@ uint8_t salt[] = {
'i', 'j', 'k', 'l', 'm', 'n'
};
-void createConnection(const std::string & remote_host , u_int16_t remote_port, ConnectionList & cl, u_int16_t seqSize)
+void createConnection(const std::string & remote_host , u_int16_t remote_port, ConnectionList & cl, u_int16_t seqSize, SyncQueue & queue)
{
SeqWindow * seq= new SeqWindow(seqSize);
@@ -93,6 +94,7 @@ void createConnection(const std::string & remote_host , u_int16_t remote_port, C
cLog.msg(Log::PRIO_NOTICE) << "added connection remote host " << remote_host << ":" << remote_port;
ConnectionParam connparam ( (*kd), (*seq), seq_nr_, remote_host, remote_port);
cl.addConnection(connparam,0);
+ queue.push(SyncCommand(cl,0));
}
@@ -278,7 +280,7 @@ void* receiver(void* p)
if(param->opt.getRemoteAddr() == "" && param->cl.empty())
{
cLog.msg(Log::PRIO_NOTICE) << "autodetected remote host " << remote_host << ":" << remote_port;
- createConnection(remote_host, remote_port, param->cl,param->opt.getSeqWindowSize());
+ createConnection(remote_host, remote_port, param->cl,param->opt.getSeqWindowSize(),param->queue);
}
//TODO Add multi connection support here
@@ -342,10 +344,11 @@ int main(int argc, char* argv[])
ConnectionList cl;
+ SyncQueue queue;
+
if(opt.getRemoteAddr() != "")
- createConnection(opt.getRemoteAddr(),opt.getRemotePort(),cl,opt.getSeqWindowSize());
+ createConnection(opt.getRemoteAddr(),opt.getRemotePort(),cl,opt.getSeqWindowSize(), queue);
- SyncQueue queue;
struct Param p = {opt, dev, *src, cl, queue};
diff --git a/syncQueue.cpp b/syncQueue.cpp
index ba858ee..7d3c35f 100644
--- a/syncQueue.cpp
+++ b/syncQueue.cpp
@@ -31,7 +31,24 @@
#include "threadUtils.hpp"
#include "datatypes.h"
+#include <sstream>
+#include <iostream>
+#include <string>
+
+#include <boost/archive/text_oarchive.hpp>
+#include <boost/archive/text_iarchive.hpp>
+
+
#include "syncQueue.h"
+void SyncQueue::push(const SyncCommand & scom )
+{
+ std::ostringstream sout;
+ boost::archive::text_oarchive oa(sout);
+ oa << scom;
+
+ Lock lock(mutex_);
+ queue_.push(sout.str());
+}
void SyncQueue::push(const std::string & str )
{
diff --git a/syncQueue.h b/syncQueue.h
index d76565b..6aa6fe0 100644
--- a/syncQueue.h
+++ b/syncQueue.h
@@ -34,6 +34,8 @@
#include <deque>
#include <queue>
+#include "syncCommand.h"
+
#include "threadUtils.hpp"
#include "datatypes.h"
@@ -44,6 +46,7 @@ public:
~SyncQueue() {};
void push(const std::string & );
+ void push(const SyncCommand & );
std::string pop();
bool empty();