fixed init
[anytun.git] / plainPacket.h
blob5348fe0ee12689bed3a69f17b4d892c149ec4164
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 #include "networkAddress.h"
39 class Cipher;
40 /**
41 * plain SATP packet class<br>
42 * includes payload_type and payload
45 #define PAYLOAD_TYPE_TAP 0x6558
46 #define PAYLOAD_TYPE_TUN 0x0000
47 #define PAYLOAD_TYPE_TUN4 0x0800
48 #define PAYLOAD_TYPE_TUN6 0x86DD
50 class PlainPacket : public Buffer
52 public:
53 /**
54 * Packet constructor
55 * @param the length of the payload
56 * @param allow reallocation of buffer
58 PlainPacket(u_int32_t payload_length, bool allow_realloc = false);
60 /**
61 * Packet destructor
63 ~PlainPacket() {};
65 /**
66 * Get the payload type
67 * @return the id of the payload type
69 payload_type_t getPayloadType() const;
71 /**
72 * Set the payload type
73 * @param payload_type payload type id
75 void setPayloadType(payload_type_t payload_type);
77 /**
78 * Get the length of the payload
79 * @return the length of the payload
81 u_int32_t getPayloadLength() const;
83 /**
84 * Set the length of the payload
85 * @param length length of the payload
87 void setPayloadLength(u_int32_t payload_length);
89 /**
90 * Get the the payload
91 * @return the Pointer to the payload
93 u_int8_t* getPayload();
95 NetworkAddress getSrcAddr() const;
96 NetworkAddress getDstAddr() const;
98 private:
99 PlainPacket();
100 PlainPacket(const PlainPacket &src);
102 void reinit();
104 payload_type_t* payload_type_;
105 u_int8_t* payload_;
108 #endif