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