From ebc305b6a49d24f8bcf05ed10efac42c4398bd5b Mon Sep 17 00:00:00 2001 From: Othmar Gsenger Date: Fri, 7 Dec 2007 14:51:53 +0000 Subject: serialisation of buffer und connection param --- buffer.cpp | 10 +++++++++- buffer.h | 11 ++++++++++- connectionParam.cpp | 12 ++++++++++++ connectionParam.h | 10 ++++++++++ keyDerivation.h | 9 ++------- 5 files changed, 43 insertions(+), 9 deletions(-) diff --git a/buffer.cpp b/buffer.cpp index 4bcb9b8..a21ebb3 100644 --- a/buffer.cpp +++ b/buffer.cpp @@ -32,7 +32,8 @@ #include #include #include - +#include +#include #include "datatypes.h" #include "buffer.h" @@ -247,3 +248,10 @@ Buffer Buffer::rightByteShift(u_int32_t width) const return res; } +template +void Buffer::serialize(Archive & ar, const unsigned int version) +{ + ar & length_; + ar & buf_; +} + diff --git a/buffer.h b/buffer.h index 37bbc29..85f539b 100644 --- a/buffer.h +++ b/buffer.h @@ -36,6 +36,12 @@ class TunDevice; class UDPPacketSource; +namespace boost { + namespace serialization { + class access; + } +} + class Buffer { public: @@ -70,7 +76,10 @@ protected: u_int8_t *buf_; u_int32_t length_; - +private: + friend class boost::serialization::access; + template + void serialize(Archive & ar, const unsigned int version); }; #endif diff --git a/connectionParam.cpp b/connectionParam.cpp index d7dd3a4..4c1175a 100644 --- a/connectionParam.cpp +++ b/connectionParam.cpp @@ -29,7 +29,19 @@ */ #include "connectionParam.h" +#include +#include ConnectionParam::ConnectionParam(KeyDerivation& kd, SeqWindow& seq, std::string remote_host, u_int16_t remote_port) : kd_(kd),seq_(seq),remote_host_(remote_host), remote_port_(remote_port) { } + +template +void ConnectionParam::serialize(Archive & ar, const unsigned int version) +{ + ar & kd_; + ar & seq_; + ar & remote_host_; + ar & remote_port_; +} + diff --git a/connectionParam.h b/connectionParam.h index 0129a03..c786db9 100644 --- a/connectionParam.h +++ b/connectionParam.h @@ -37,6 +37,12 @@ #include "authAlgo.h" #include "seqWindow.h" +namespace boost { + namespace serialization { + class access; + } +} + class ConnectionParam { public: @@ -45,6 +51,10 @@ public: SeqWindow& seq_; std::string remote_host_; u_int16_t remote_port_; +private: + friend class boost::serialization::access; + template + void serialize(Archive & ar, const unsigned int version); }; #endif diff --git a/keyDerivation.h b/keyDerivation.h index a1a2987..a9939a3 100644 --- a/keyDerivation.h +++ b/keyDerivation.h @@ -33,8 +33,7 @@ #include "datatypes.h" #include "buffer.h" -//#include -//#include + extern "C" { @@ -60,11 +59,7 @@ public: void clear(); private: template - void serialize(Archive & ar, const unsigned int version) - { - ar & ld_kdr_; - ar & salt_; - } + void serialize(Archive & ar, const unsigned int version); protected: int8_t ld_kdr_; // ld(key_derivation_rate) -- cgit v1.2.3