diff options
author | Bruno Cabral <bcabral@uw.edu> | 2015-06-25 02:21:23 +0000 |
---|---|---|
committer | Bruno Cabral <bcabral@uw.edu> | 2015-06-25 02:21:23 +0000 |
commit | 26ad92551ed4afd96f3d7742179509b850a5cc7a (patch) | |
tree | ddcf6699873afc2431df036193b1e598c15e142c /src/nat/nat_stun.h | |
parent | 20d8a41eaa19064d16e9a004dea2d9abcdbd9731 (diff) | |
download | gnunet-26ad92551ed4afd96f3d7742179509b850a5cc7a.tar.gz gnunet-26ad92551ed4afd96f3d7742179509b850a5cc7a.zip |
Polish and simplyfy STUN code, move STUN code to GNUNET_NAT_
Diffstat (limited to 'src/nat/nat_stun.h')
-rw-r--r-- | src/nat/nat_stun.h | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/src/nat/nat_stun.h b/src/nat/nat_stun.h new file mode 100644 index 000000000..a3982bfc9 --- /dev/null +++ b/src/nat/nat_stun.h | |||
@@ -0,0 +1,111 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2009, 2015 Christian Grothoff (and other contributing authors) | ||
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., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * Testcase for STUN server resolution | ||
23 | * | ||
24 | * @file nat/test_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 | uint16_t msgtype; | ||
41 | uint16_t msglen; | ||
42 | uint32_t magic; | ||
43 | stun_trans_id id; | ||
44 | |||
45 | } GNUNET_PACKED; | ||
46 | |||
47 | struct stun_attr { | ||
48 | uint16_t attr; | ||
49 | uint16_t len; | ||
50 | |||
51 | } GNUNET_PACKED; | ||
52 | |||
53 | /* | ||
54 | * The format normally used for addresses carried by STUN messages. | ||
55 | */ | ||
56 | struct stun_addr { | ||
57 | uint8_t unused; | ||
58 | uint8_t family; | ||
59 | uint16_t port; | ||
60 | uint32_t addr; | ||
61 | } GNUNET_PACKED; | ||
62 | |||
63 | |||
64 | |||
65 | /* STUN message classes */ | ||
66 | typedef enum StunClasses { | ||
67 | INVALID_CLASS = 0, | ||
68 | STUN_REQUEST = 0x0000, | ||
69 | STUN_INDICATION = 0x0001, | ||
70 | STUN_RESPONSE = 0x0002, | ||
71 | STUN_ERROR_RESPONSE = 0x0003 | ||
72 | } StunClasses; | ||
73 | |||
74 | typedef enum StunMethods { | ||
75 | INVALID_METHOD = 0, | ||
76 | STUN_BINDING = 0x0001, | ||
77 | STUN_SHARED_SECRET = 0x0002, | ||
78 | STUN_ALLOCATE = 0x0003, | ||
79 | STUN_REFRESH = 0x0004, | ||
80 | STUN_SEND = 0x0006, | ||
81 | STUN_DATA = 0x0007, | ||
82 | STUN_CREATE_PERMISSION = 0x0008, | ||
83 | STUN_CHANNEL_BIND = 0x0009 | ||
84 | } StunMethods; | ||
85 | |||
86 | /* Basic attribute types in stun messages. | ||
87 | * Messages can also contain custom attributes (codes above 0x7fff) | ||
88 | */ | ||
89 | |||
90 | typedef 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 | } StunAttributes; | ||
111 | |||