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