summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--anytun.cpp48
-rw-r--r--connectionParam.cpp10
-rw-r--r--connectionParam.h9
-rw-r--r--keyDerivation.cpp7
-rw-r--r--keyDerivation.h8
-rw-r--r--seqWindow.cpp7
-rw-r--r--seqWindow.h12
-rw-r--r--syncBuffer.cpp12
-rw-r--r--syncBuffer.h6
-rw-r--r--syncSocket.cpp6
10 files changed, 45 insertions, 80 deletions
diff --git a/anytun.cpp b/anytun.cpp
index 8ea3d75..a165534 100644
--- a/anytun.cpp
+++ b/anytun.cpp
@@ -66,22 +66,21 @@ struct Param
ConnectionList& cl;
};
+uint8_t key[] = {
+ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h',
+ 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',
+ 'q', 'r', 's', 't'
+};
+
+uint8_t salt[] = {
+ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h',
+ 'i', 'j', 'k', 'l', 'm', 'n'
+};
+
void createConnection(const std::string & remote_host , u_int16_t remote_port, ConnectionList & cl, u_int16_t seqSize)
{
SeqWindow seq(seqSize);
-
- uint8_t key[] = {
- 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h',
- 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',
- 'q', 'r', 's', 't'
- };
-
- uint8_t salt[] = {
- 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h',
- 'i', 'j', 'k', 'l', 'm', 'n'
- };
-
seq_nr_t seq_nr_=0;
KeyDerivation kd;
// kd.init(Buffer(key, sizeof(key)), Buffer(salt, sizeof(salt)));
@@ -100,18 +99,6 @@ void encryptPacket(Packet & pack, Cypher & c, ConnectionParam & conn, void* p)
// conn.kd_.generate(label_satp_encryption, conn.seq_nr_, tmp_key, tmp_key.getLength());
// conn.kd_.generate(label_satp_salt, conn.seq_nr_, tmp_salt, tmp_salt.getLength());
-
- uint8_t key[] = {
- 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h',
- 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',
- 'q', 'r', 's', 't'
- };
-
- uint8_t salt[] = {
- 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h',
- 'i', 'j', 'k', 'l', 'm', 'n'
- };
-
Buffer tmp_key(key, sizeof(key));
Buffer tmp_salt(salt, sizeof(salt));
@@ -135,19 +122,6 @@ bool decryptPacket(Packet & pack, Cypher & c, ConnectionParam & conn)
// conn.kd_.generate(label_satp_encryption, seq, tmp_key, tmp_key.getLength());
// conn.kd_.generate(label_satp_salt, seq, tmp_salt, tmp_salt.getLength());
-
-
- uint8_t key[] = {
- 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h',
- 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',
- 'q', 'r', 's', 't'
- };
-
- uint8_t salt[] = {
- 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h',
- 'i', 'j', 'k', 'l', 'm', 'n'
- };
-
Buffer tmp_key(key, sizeof(key));
Buffer tmp_salt(salt, sizeof(salt));
diff --git a/connectionParam.cpp b/connectionParam.cpp
index ca3d767..04330b3 100644
--- a/connectionParam.cpp
+++ b/connectionParam.cpp
@@ -34,13 +34,3 @@ ConnectionParam::ConnectionParam(KeyDerivation& kd, SeqWindow& seq_window,seq_nr
{
}
-template<class Archive>
-void ConnectionParam::serialize(Archive & ar, const unsigned int version)
-{
- ar & kd_;
- ar & seq_window_;
- ar & seq_nr_;
- ar & remote_host_;
- ar & remote_port_;
-}
-
diff --git a/connectionParam.h b/connectionParam.h
index 4bd58ab..b73d49e 100644
--- a/connectionParam.h
+++ b/connectionParam.h
@@ -53,7 +53,14 @@ public:
private:
friend class boost::serialization::access;
template<class Archive>
- void serialize(Archive & ar, const unsigned int version);
+ void serialize(Archive & ar, const unsigned int version)
+ {
+ ar & kd_;
+ ar & seq_window_;
+ ar & seq_nr_;
+ ar & remote_host_;
+ ar & remote_port_;
+ }
};
#endif
diff --git a/keyDerivation.cpp b/keyDerivation.cpp
index 3c25ae3..2c3d84b 100644
--- a/keyDerivation.cpp
+++ b/keyDerivation.cpp
@@ -144,10 +144,3 @@ void KeyDerivation::clear()
Lock lock(mutex_);
gcry_cipher_close( cipher_ );
}
-
-template<class Archive>
-void KeyDerivation::serialize(Archive & ar, const unsigned int version)
-{
- ar & ld_kdr_;
- ar & salt_;
-}
diff --git a/keyDerivation.h b/keyDerivation.h
index f7a4068..8bce85c 100644
--- a/keyDerivation.h
+++ b/keyDerivation.h
@@ -58,9 +58,15 @@ public:
void setLogKDRate(const u_int8_t ld_rate);
void generate(satp_prf_label label, seq_nr_t seq_nr, Buffer& key, u_int32_t length);
void clear();
+
private:
+ friend class boost::serialization::access;
template<class Archive>
- void serialize(Archive & ar, const unsigned int version);
+ void serialize(Archive & ar, const unsigned int version)
+ {
+ ar & ld_kdr_;
+ //ar & salt_;
+ }
protected:
int8_t ld_kdr_; // ld(key_derivation_rate)
diff --git a/seqWindow.cpp b/seqWindow.cpp
index 478efbf..20973b5 100644
--- a/seqWindow.cpp
+++ b/seqWindow.cpp
@@ -89,10 +89,3 @@ void SeqWindow::clear()
sender_.clear();
}
-template<class Archive>
-void SeqWindow::serialize(Archive & ar, const unsigned int version)
-{
- ar & window_size_;
- //TODO: Do not sync complete Sender Map!
- ar & sender_;
-}
diff --git a/seqWindow.h b/seqWindow.h
index 8f94b7c..f2ad347 100644
--- a/seqWindow.h
+++ b/seqWindow.h
@@ -53,12 +53,22 @@ public:
void clear(sender_id_t sender);
void clear();
+
private:
SeqWindow(const SeqWindow &s);
void operator=(const SeqWindow &s);
+ friend class boost::serialization::access;
template<class Archive>
- void serialize(Archive & ar, const unsigned int version);
+ void serialize(Archive & ar, const unsigned int version)
+ {
+ //unsigned int serial = (unsigned int) window_size_;
+ //window_size_t serial = (window_size_t) window_size_;
+ ar & window_size_;
+ //TODO: Do not sync complete Sender Map!
+ // ar & sender_;
+ }
+
window_size_t window_size_;
Mutex mutex_;
diff --git a/syncBuffer.cpp b/syncBuffer.cpp
index 5af8cb5..bebc19b 100644
--- a/syncBuffer.cpp
+++ b/syncBuffer.cpp
@@ -28,17 +28,5 @@
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <stdexcept>
-#include <string>
-#include <cstdio>
-#include <iostream>
-#include "datatypes.h"
#include "syncBuffer.h"
-template<class Archive>
-void SyncBuffer::serialize(Archive & ar, const unsigned int version)
-{
- ar & length_;
- ar & buf_;
-}
-
diff --git a/syncBuffer.h b/syncBuffer.h
index 1d4fc9f..222c197 100644
--- a/syncBuffer.h
+++ b/syncBuffer.h
@@ -45,7 +45,11 @@ public:
private:
friend class boost::serialization::access;
template<class Archive>
- void serialize(Archive & ar, const unsigned int version);
+ void serialize(Archive & ar, const unsigned int version)
+ {
+ ar & length_;
+ ar & buf_;
+ }
};
#endif
diff --git a/syncSocket.cpp b/syncSocket.cpp
index b74b365..99f2afb 100644
--- a/syncSocket.cpp
+++ b/syncSocket.cpp
@@ -42,9 +42,9 @@ void SyncSocket::OnAccept()
Send("Number of sockets in list : " + Utility::l2string(Handler().GetCount()) + "\n");
Send("\n");
std::ostringstream sout;
-// boost::archive::text_oarchive oa(sout);
- ConnectionParam conn = cl_.getConnection();
-// oa << conn;
+ boost::archive::text_oarchive oa(sout);
+ const ConnectionParam conn = cl_.getConnection();
+ oa << conn;
Send(sout.str()+"\n");
}