-fix (C) notices
[oweals/gnunet.git] / src / nat / nat_stun.h
1 /*
2      This file is part of GNUnet.
3      Copyright (C) 2009, 2015 GNUnet e.V.
4
5      GNUnet is free software; you can redistribute it and/or modify
6      it under the terms of the GNU General Public License as published
7      by the Free Software Foundation; either version 3, or (at your
8      option) any later version.
9
10      GNUnet is distributed in the hope that it will be useful, but
11      WITHOUT ANY WARRANTY; without even the implied warranty of
12      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13      General Public License for more details.
14
15      You should have received a copy of the GNU General Public License
16      along with GNUnet; see the file COPYING.  If not, write to the
17      Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18      Boston, MA 02110-1301, USA.
19 */
20
21 /**
22  * Testcase for STUN server resolution
23  *
24  * @file nat/nat_stun.h
25  * @brief Testcase for STUN library
26  * @author Bruno Souza Cabral
27  * @autor Mark Spencer (Original code borrowed from Asterisk)
28  *
29  */
30
31
32 #define STUN_IGNORE             (0)
33 #define STUN_ACCEPT             (1)
34
35 #define STUN_MAGIC_COOKIE       0x2112A442
36
37 typedef struct { uint32_t id[3]; } GNUNET_PACKED stun_trans_id;
38
39 struct stun_header
40 {
41   uint16_t msgtype;
42   uint16_t msglen;
43   uint32_t magic;
44   stun_trans_id id;
45 } GNUNET_PACKED;
46
47 struct stun_attr
48 {
49   uint16_t attr;
50   uint16_t len;
51 } GNUNET_PACKED;
52
53 /*
54  * The format normally used for addresses carried by STUN messages.
55  */
56 struct stun_addr
57 {
58   uint8_t  unused;
59   uint8_t  family;
60   uint16_t port;
61   uint32_t   addr;
62 } GNUNET_PACKED;
63
64
65
66 /* STUN message classes */
67 enum StunClasses {
68     INVALID_CLASS = 0,
69     STUN_REQUEST = 0x0000,
70     STUN_INDICATION = 0x0001,
71     STUN_RESPONSE = 0x0002,
72     STUN_ERROR_RESPONSE = 0x0003
73 };
74
75 enum StunMethods {
76   INVALID_METHOD = 0,
77   STUN_BINDING = 0x0001,
78   STUN_SHARED_SECRET = 0x0002,
79   STUN_ALLOCATE = 0x0003,
80   STUN_REFRESH = 0x0004,
81   STUN_SEND = 0x0006,
82   STUN_DATA = 0x0007,
83   STUN_CREATE_PERMISSION = 0x0008,
84   STUN_CHANNEL_BIND = 0x0009
85 };
86
87 /* Basic attribute types in stun messages.
88  * Messages can also contain custom attributes (codes above 0x7fff)
89  */
90 enum StunAttributes {
91   STUN_MAPPED_ADDRESS = 0x0001,
92   STUN_RESPONSE_ADDRESS = 0x0002,
93   STUN_CHANGE_ADDRESS = 0x0003,
94   STUN_SOURCE_ADDRESS = 0x0004,
95   STUN_CHANGED_ADDRESS = 0x0005,
96   STUN_USERNAME = 0x0006,
97   STUN_PASSWORD = 0x0007,
98   STUN_MESSAGE_INTEGRITY = 0x0008,
99   STUN_ERROR_CODE = 0x0009,
100   STUN_UNKNOWN_ATTRIBUTES = 0x000a,
101   STUN_REFLECTED_FROM = 0x000b,
102   STUN_REALM = 0x0014,
103   STUN_NONCE = 0x0015,
104   STUN_XOR_MAPPED_ADDRESS = 0x0020,
105   STUN_MS_VERSION = 0x8008,
106   STUN_MS_XOR_MAPPED_ADDRESS = 0x8020,
107   STUN_SOFTWARE = 0x8022,
108   STUN_ALTERNATE_SERVER = 0x8023,
109   STUN_FINGERPRINT = 0x8028
110 };