summaryrefslogtreecommitdiff
path: root/encryptedPacket.h
diff options
context:
space:
mode:
authorChristian Pointner <equinox@anytun.org>2008-02-23 23:05:43 +0000
committerChristian Pointner <equinox@anytun.org>2008-02-23 23:05:43 +0000
commitb8766a2041d57a3aa49c3855902953f8de0b0ec1 (patch)
treece3fd0496bbcc9c71b8a16ec1333f574e3fe51a5 /encryptedPacket.h
parentadded routing table basic structure (diff)
- keyderivation and cipher should work now
however it needs further testing - rewrite of Buffer and Packets
Diffstat (limited to 'encryptedPacket.h')
-rw-r--r--encryptedPacket.h50
1 files changed, 23 insertions, 27 deletions
diff --git a/encryptedPacket.h b/encryptedPacket.h
index afc7d0e..0b934f6 100644
--- a/encryptedPacket.h
+++ b/encryptedPacket.h
@@ -41,14 +41,15 @@ public:
/**
* Packet constructor
- * @param max_payload_length maximum length of encrypted payload
+ * @param the length of the payload
+ * @param allow reallocation of buffer
*/
- EncryptedPacket(u_int32_t max_payload_length);
+ EncryptedPacket(u_int32_t payload_length, bool allow_realloc = false);
/**
* Packet destructor
*/
- ~EncryptedPacket();
+ ~EncryptedPacket() {};
/**
* Get the sequence number
@@ -94,36 +95,36 @@ public:
*/
void setHeader(seq_nr_t seq_nr, sender_id_t sender_id, mux_t mux);
- /**
- * Get the maximum payload size
- * @return maximum payload size
+ /**
+ * Get the length of the payload
+ * @return the length of the payload
+ */
+ u_int32_t getPayloadLength() const;
+
+ /**
+ * Set the length of the payload
+ * @param length length of the payload
*/
- u_int32_t getMaxLength() const;
+ void setPayloadLength(u_int32_t payload_length);
/**
- * Set the real length of the payload
- * @param length the real length of the payload, has to be smaller than the maximum payload size!
+ * Get the the payload
+ * @return the Pointer to the payload
*/
- void setLength(u_int32_t length);
+ u_int8_t* getPayload();
+
+
bool hasAuthTag() const;
void withAuthTag(bool b);
AuthTag getAuthTag() const;
void setAuthTag(AuthTag& tag);
- void setPayloadLength(u_int32_t payload_length);
-
-
-// bool hasHeader() const;
-// Packet& withHeader(bool b);
-// Packet& addHeader(seq_nr_t seq_nr, sender_id_t sender_id);
-// Packet& withAuthTag(bool b);
-// AuthTag getAuthTag() const;
-// Packet& addAuthTag(AuthTag auth_tag);
-
+
private:
EncryptedPacket();
EncryptedPacket(const EncryptedPacket &src);
+
struct HeaderStruct
{
seq_nr_t seq_nr;
@@ -132,14 +133,9 @@ private:
}__attribute__((__packed__));
struct HeaderStruct* header_;
- AuthTag* auth_tag_;
- u_int32_t max_length_;
-
- static const u_int32_t AUTHTAG_SIZE = 10; // 10byte
-protected:
- friend class Cipher;
u_int8_t * payload_;
- u_int32_t payload_length_;
+ AuthTag* auth_tag_;
+ static const u_int32_t AUTHTAG_SIZE = 10; // TODO: hardcoded size
};
#endif