00001 /* 00002 * anytun 00003 * 00004 * The secure anycast tunneling protocol (satp) defines a protocol used 00005 * for communication between any combination of unicast and anycast 00006 * tunnel endpoints. It has less protocol overhead than IPSec in Tunnel 00007 * mode and allows tunneling of every ETHER TYPE protocol (e.g. 00008 * ethernet, ip, arp ...). satp directly includes cryptography and 00009 * message authentication based on the methodes used by SRTP. It is 00010 * intended to deliver a generic, scaleable and secure solution for 00011 * tunneling and relaying of packets of any protocol. 00012 * 00013 * 00014 * Copyright (C) 2007 anytun.org <satp@wirdorange.org> 00015 * 00016 * This program is free software; you can redistribute it and/or modify 00017 * it under the terms of the GNU General Public License version 2 00018 * as published by the Free Software Foundation. 00019 * 00020 * This program is distributed in the hope that it will be useful, 00021 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00023 * GNU General Public License for more details. 00024 * 00025 * You should have received a copy of the GNU General Public License 00026 * along with this program (see the file COPYING included with this 00027 * distribution); if not, write to the Free Software Foundation, Inc., 00028 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00029 */ 00030 00031 #ifndef _PACKET_H_ 00032 #define _PACKET_H_ 00033 00034 #include "datatypes.h" 00035 #include "buffer.h" 00036 00037 class Packet : public Buffer 00038 { 00039 public: 00040 Packet(); 00041 Packet(u_int32_t length); 00042 Packet(const Buffer &src); 00043 00044 bool hasHeader() const; 00045 Packet& withHeader(bool b); 00046 seq_nr_t getSeqNr() const; 00047 sender_id_t getSenderId() const; 00048 Packet& addHeader(seq_nr_t seq_nr, sender_id_t sender_id); 00049 Packet& removeHeader(); 00050 Packet& setSeqNr(seq_nr_t seq_nr); 00051 Packet& setSenderId(sender_id_t sender_id); 00052 00053 bool hasPayloadType() const; 00054 Packet& withPayloadType(bool b); 00055 payload_type_t getPayloadType() const; 00056 Packet& addPayloadType(payload_type_t payload_type); 00057 Packet& removePayloadType(); 00058 00059 bool hasAuthTag() const; 00060 Packet& withAuthTag(bool b); 00061 auth_tag_t getAuthTag() const; 00062 Packet& addAuthTag(auth_tag_t auth_tag); 00063 Packet& removeAuthTag(); 00064 00065 private: 00066 struct HeaderStruct 00067 { 00068 seq_nr_t seq_nr; 00069 sender_id_t sender_id; 00070 }__attribute__((__packed__)); 00071 bool has_header_; 00072 bool has_payload_type_; 00073 bool has_auth_tag_; 00074 }; 00075 00076 #endif