4 * The secure anycast tunneling protocol (satp) defines a protocol used
5 * for communication between any combination of unicast and anycast
6 * tunnel endpoints. It has less protocol overhead than IPSec in Tunnel
7 * mode and allows tunneling of every ETHER TYPE protocol (e.g.
8 * ethernet, ip, arp ...). satp directly includes cryptography and
9 * message authentication based on the methodes used by SRTP. It is
10 * intended to deliver a generic, scaleable and secure solution for
11 * tunneling and relaying of packets of any protocol.
14 * Copyright (C) 2007-2009 Othmar Gsenger, Erwin Nindl,
15 * Christian Pointner <satp@wirdorange.org>
17 * This file is part of Anytun.
19 * Anytun is free software: you can redistribute it and/or modify
20 * it under the terms of the GNU General Public License as published by
21 * the Free Software Foundation, either version 3 of the License, or
24 * Anytun is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU General Public License for more details.
29 * You should have received a copy of the GNU General Public License
30 * along with anytun. If not, see <http://www.gnu.org/licenses/>.
33 #ifndef ANYTUN_encryptedPacket_h_INCLUDED
34 #define ANYTUN_encryptedPacket_h_INCLUDED
36 #include "datatypes.h"
40 class EncryptedPacket : public Buffer
46 * @param the length of the payload
47 * @param allow reallocation of buffer
49 EncryptedPacket(u_int32_t payload_length, u_int32_t auth_tag_length, bool allow_realloc = false);
54 ~EncryptedPacket() {};
57 * Get the length of the header
58 * @return the length of the header
60 static u_int32_t getHeaderLength();
63 * Get the sequence number
64 * @return seqence number
66 seq_nr_t getSeqNr() const;
69 * Set the seqence number
70 * @param seq_nr sequence number
72 void setSeqNr(seq_nr_t seq_nr);
78 sender_id_t getSenderId() const;
82 * @param sender_id sender id
84 void setSenderId(sender_id_t sender_id);
87 * Get the mulitplex id
88 * @return multiplex id
93 * Set the multiplex id
94 * @param mux multiplex id
96 void setMux(mux_t mux);
99 * Set the header of a packet
100 * @param seq_nr sequence number
101 * @param sender_id sender id
102 * @param mux multiplex id
104 void setHeader(seq_nr_t seq_nr, sender_id_t sender_id, mux_t mux);
107 * Get the length of the payload
108 * @return the length of the payload
110 u_int32_t getPayloadLength() const;
113 * Set the length of the payload
114 * @param length length of the payload
116 void setPayloadLength(u_int32_t payload_length);
119 * Get the the payload
120 * @return the Pointer to the payload
122 u_int8_t* getPayload();
125 u_int8_t* getAuthenticatedPortion();
126 u_int32_t getAuthenticatedPortionLength();
128 void withAuthTag(bool b);
130 void removeAuthTag();
131 u_int8_t* getAuthTag();
132 u_int32_t getAuthTagLength();
136 EncryptedPacket(const EncryptedPacket &src);
141 #pragma pack(push, 1)
143 struct ATTR_PACKED HeaderStruct
146 sender_id_t sender_id;
153 struct HeaderStruct* header_;
155 u_int8_t * auth_tag_;
156 u_int32_t auth_tag_length_;