Use CBitcoinAddress ti store change destination
[novacoin.git] / src / ministun.h
1 /*
2  * ministun.h
3  * Part of the ministun package
4  *
5  * STUN support code borrowed from Asterisk -- An open source telephony toolkit.
6  * Copyright (C) 1999 - 2006, Digium, Inc.
7  * Mark Spencer <markster@digium.com>
8  * Standalone remake (c) 2009 Vladislav Grishenko <themiron@mail.ru>
9  *
10  * This software is licensed under the terms of the GNU General
11  * Public License (GPL). Please see the file COPYING for details.
12  *
13  */
14
15 #define PACKAGE  "ministun"
16 #define VERSION  "0.1"
17
18 #define STUN_SERVER "stun.xten.com"
19 #define STUN_PORT 3478
20 #define STUN_COUNT 3
21 #define STUN_TIMEOUT 3
22
23 #ifndef _MSC_VER
24     typedef struct { unsigned int id[4]; } __attribute__((packed)) stun_trans_id;
25
26     struct stun_header {
27         unsigned short msgtype;
28         unsigned short msglen;
29         stun_trans_id id;
30     } __attribute__((packed));
31
32     struct stun_attr {
33         unsigned short attr;
34         unsigned short len;
35     } __attribute__((packed));
36
37     /*
38     * The format normally used for addresses carried by STUN messages.
39     */
40
41     struct stun_addr {
42         unsigned char unused;
43         unsigned char family;
44         unsigned short port;
45         unsigned int addr;
46     } __attribute__((packed));
47 #else
48     typedef struct { unsigned int id[4]; } stun_trans_id;
49
50 #pragma pack(push, 1)    
51     struct stun_header {
52         unsigned short msgtype;
53         unsigned short msglen;
54         stun_trans_id id;
55     };
56 #pragma pack(pop)
57
58 #pragma pack(push, 1)
59     struct stun_attr {
60         unsigned short attr;
61         unsigned short len;
62     };
63 #pragma pack(pop)
64
65     /*
66     * The format normally used for addresses carried by STUN messages.
67     */
68 #pragma pack(push, 1)
69     struct stun_addr {
70         unsigned char unused;
71         unsigned char family;
72         unsigned short port;
73         unsigned int addr;
74     };
75 #pragma pack(pop)
76 #endif
77
78 #define STUN_IGNORE  (0)
79 #define STUN_ACCEPT  (1)
80
81 /* STUN message types
82  * 'BIND' refers to transactions used to determine the externally
83  * visible addresses. 'SEC' refers to transactions used to establish
84  * a session key for subsequent requests.
85  * 'SEC' functionality is not supported here.
86  */
87
88 #define STUN_BINDREQ 0x0001
89 #define STUN_BINDRESP 0x0101
90 #define STUN_BINDERR 0x0111
91 #define STUN_SECREQ 0x0002
92 #define STUN_SECRESP 0x0102
93 #define STUN_SECERR 0x0112
94
95 /* Basic attribute types in stun messages.
96  * Messages can also contain custom attributes (codes above 0x7fff)
97  */
98 #define STUN_MAPPED_ADDRESS 0x0001
99 #define STUN_RESPONSE_ADDRESS 0x0002
100 #define STUN_CHANGE_REQUEST 0x0003
101 #define STUN_SOURCE_ADDRESS 0x0004
102 #define STUN_CHANGED_ADDRESS 0x0005
103 #define STUN_USERNAME  0x0006
104 #define STUN_PASSWORD  0x0007
105 #define STUN_MESSAGE_INTEGRITY 0x0008
106 #define STUN_ERROR_CODE  0x0009
107 #define STUN_UNKNOWN_ATTRIBUTES 0x000a
108 #define STUN_REFLECTED_FROM 0x000b