added more options
[anytun.git] / plainPacket.h
blob03ae50795f43bdf0af56d382cec636de9771e272
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 0x0800
47 #define PAYLOAD_TYPE_TUN6 0x86DD
49 class PlainPacket : public Buffer
51 public:
52 /**
53 * Packet constructor
54 * @param the length of the payload
55 * @param allow reallocation of buffer
57 PlainPacket(u_int32_t payload_length, bool allow_realloc = false);
59 /**
60 * Packet destructor
62 ~PlainPacket() {};
64 /**
65 * Get the payload type
66 * @return the id of the payload type
68 payload_type_t getPayloadType() const;
70 /**
71 * Set the payload type
72 * @param payload_type payload type id
74 void setPayloadType(payload_type_t payload_type);
76 /**
77 * Get the length of the payload
78 * @return the length of the payload
80 u_int32_t getPayloadLength() const;
82 /**
83 * Set the length of the payload
84 * @param length length of the payload
86 void setPayloadLength(u_int32_t payload_length);
88 /**
89 * Get the the payload
90 * @return the Pointer to the payload
92 u_int8_t* getPayload();
94 NetworkAddress getSrcAddr() const;
95 NetworkAddress getDstAddr() const;
97 private:
98 PlainPacket();
99 PlainPacket(const PlainPacket &src);
101 void reinit();
103 payload_type_t* payload_type_;
104 u_int8_t* payload_;
107 #endif