finallly working, payload type needs further checks
[anytun.git] / plainPacket.h
blob22664f4c9a9b25af7be28e08fb3e78aa23576936
1 /*
2 * anytun
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 anytun.org <satp@wirdorange.org>
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License version 2
18 * as published by the Free Software Foundation.
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this program (see the file COPYING included with this
27 * distribution); if not, write to the Free Software Foundation, Inc.,
28 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31 #ifndef _PLAIN_PACKET_H_
32 #define _PLAIN_PACKET_H_
34 #include "datatypes.h"
35 #include "buffer.h"
37 class Cypher;
38 /**
39 * plain SATP packet class<br>
40 * includes payload_type and payload
43 class PlainPacket : public Buffer
45 public:
46 ~PlainPacket();
48 /**
49 * Packet constructor
50 * @param max_payload_length maximum payload length
52 PlainPacket(u_int32_t max_payload_length);
54 /**
55 * Get the payload type
56 * @return the id of the payload type
58 payload_type_t getPayloadType() const;
60 /**
61 * Set the payload type
62 * @param payload_type payload type id
64 void setPayloadType(payload_type_t payload_type);
66 void setCompletePayloadLength(u_int32_t payload_length);
68 /**
69 * Set the real payload length
70 * @param length the real payload length
72 //void setRealPayloadLengt(u_int32_t length);
74 /**
75 * Get the real payload length
76 * @return the real length of the payload
78 //u_int32_t getRealPayloadLength();
80 /**
81 * Set the length of the payload
82 * @param length length of the payload
84 void setLength(u_int32_t length);
86 /**
87 * Get the size of the allocated memory for the payload
88 * @return maximum size of payload
90 u_int32_t getMaxLength() const;
92 private:
93 PlainPacket();
94 PlainPacket(const PlainPacket &src);
95 void splitPayload();
96 u_int32_t max_length_;
97 payload_type_t* payload_type_;
98 protected:
99 friend class Cypher;
100 u_int8_t * complete_payload_;
101 u_int32_t complete_payload_length_;
104 #endif