Merge tag 'upstream/0.3.7'
[debian/uanytun.git] / src / datatypes.h
1 /*
2  *  uAnytun
3  *
4  *  uAnytun is a tiny implementation of SATP. Unlike Anytun which is a full
5  *  featured implementation uAnytun has no support for multiple connections
6  *  or synchronisation. It is a small single threaded implementation intended
7  *  to act as a client on small platforms.
8  *  The secure anycast tunneling protocol (satp) defines a protocol used
9  *  for communication between any combination of unicast and anycast
10  *  tunnel endpoints.  It has less protocol overhead than IPSec in Tunnel
11  *  mode and allows tunneling of every ETHER TYPE protocol (e.g.
12  *  ethernet, ip, arp ...). satp directly includes cryptography and
13  *  message authentication based on the methods used by SRTP.  It is
14  *  intended to deliver a generic, scaleable and secure solution for
15  *  tunneling and relaying of packets of any protocol.
16  *
17  *
18  *  Copyright (C) 2007-2014 Christian Pointner <equinox@anytun.org>
19  *
20  *  This file is part of uAnytun.
21  *
22  *  uAnytun is free software: you can redistribute it and/or modify
23  *  it under the terms of the GNU General Public License as published by
24  *  the Free Software Foundation, either version 3 of the License, or
25  *  any later version.
26  *
27  *  uAnytun is distributed in the hope that it will be useful,
28  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
29  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
30  *  GNU General Public License for more details.
31  *
32  *  You should have received a copy of the GNU General Public License
33  *  along with uAnytun. If not, see <http://www.gnu.org/licenses/>.
34  *
35  *  In addition, as a special exception, the copyright holders give
36  *  permission to link the code of portions of this program with the
37  *  OpenSSL library under certain conditions as described in each
38  *  individual source file, and distribute linked combinations
39  *  including the two.
40  *  You must obey the GNU General Public License in all respects
41  *  for all of the code used other than OpenSSL.  If you modify
42  *  file(s) with this exception, you may extend this exception to your
43  *  version of the file(s), but you are not obligated to do so.  If you
44  *  do not wish to do so, delete this exception statement from your
45  *  version.  If you delete this exception statement from all source
46  *  files in the program, then also delete it here.
47  */
48
49 #ifndef UANYTUN_datatypes_h_INCLUDED
50 #define UANYTUN_datatypes_h_INCLUDED
51
52 #include <stdint.h>
53 #include <arpa/inet.h>
54
55 typedef uint8_t u_int8_t;
56 typedef uint16_t u_int16_t;
57 typedef uint32_t u_int32_t;
58 typedef uint64_t u_int64_t;
59 /* typedef int8_t int8_t; */
60 /* typedef int16_t int16_t; */
61 /* typedef int32_t int32_t; */
62 /* typedef int64_t int64_t; */
63
64 typedef u_int32_t window_size_t;
65
66 typedef u_int32_t seq_nr_t;
67 #define SEQ_NR_T_NTOH(a) ntohl(a)
68 #define SEQ_NR_T_HTON(a) htonl(a)
69 #define SEQ_NR_MAX UINT32_MAX
70
71 typedef u_int16_t sender_id_t;
72 #define SENDER_ID_T_NTOH(a) ntohs(a)
73 #define SENDER_ID_T_HTON(a) htons(a)
74
75 typedef u_int16_t payload_type_t;
76 #define PAYLOAD_TYPE_T_NTOH(a) ntohs(a)
77 #define PAYLOAD_TYPE_T_HTON(a) htons(a)
78
79 typedef u_int16_t mux_t;
80 #define MUX_T_NTOH(a) ntohs(a)
81 #define MUX_T_HTON(a) htons(a)
82
83 typedef u_int32_t satp_prf_label_t;
84 #define SATP_PRF_LABEL_T_NTOH(a) ntohl(a)
85 #define SATP_PRF_LABEL_T_HTON(a) htonl(a)
86
87 struct buffer_struct {
88   u_int32_t length_;
89   u_int8_t* buf_;
90 };
91 typedef struct buffer_struct buffer_t;
92
93 #endif