Imported Upstream version 0.1.17
[platform/upstream/libnice.git] / stun / constants.h
1 /*
2  * This file is part of the Nice GLib ICE library.
3  *
4  * (C) 2008 Collabora Ltd.
5  *  Contact: Youness Alaoui
6  * (C) 2008 Nokia Corporation. All rights reserved.
7  *
8  * The contents of this file are subject to the Mozilla Public License Version
9  * 1.1 (the "License"); you may not use this file except in compliance with
10  * the License. You may obtain a copy of the License at
11  * http://www.mozilla.org/MPL/
12  *
13  * Software distributed under the License is distributed on an "AS IS" basis,
14  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
15  * for the specific language governing rights and limitations under the
16  * License.
17  *
18  * The Original Code is the Nice GLib ICE library.
19  *
20  * The Initial Developers of the Original Code are Collabora Ltd and Nokia
21  * Corporation. All Rights Reserved.
22  *
23  * Contributors:
24  *   Youness Alaoui, Collabora Ltd.
25  *
26  * Alternatively, the contents of this file may be used under the terms of the
27  * the GNU Lesser General Public License Version 2.1 (the "LGPL"), in which
28  * case the provisions of LGPL are applicable instead of those above. If you
29  * wish to allow use of your version of this file only under the terms of the
30  * LGPL and not to allow others to use your version of this file under the
31  * MPL, indicate your decision by deleting the provisions above and replace
32  * them with the notice and other provisions required by the LGPL. If you do
33  * not delete the provisions above, a recipient may use your version of this
34  * file under either the MPL or the LGPL.
35  */
36
37 #ifndef _STUN_CONSTANTS_H
38 #define _STUN_CONSTANTS_H
39
40
41 /**
42  * SECTION:stunconstants
43  * @short_description: STUN constants
44  * @include: stun/constants.h
45  * @stability: Stable
46  *
47  * Various constants defining parts of the STUN and TURN protocols and
48  * on-the-wire packet formats.
49  */
50
51 /**
52  * STUN_ATTRIBUTE_LENGTH_LEN:
53  *
54  * Length of the length field of a STUN attribute (in bytes).
55  */
56 /**
57  * STUN_ATTRIBUTE_LENGTH_POS:
58  *
59  * Offset of the length field of a STUN attribute (in bytes).
60  */
61 /**
62  * STUN_ATTRIBUTE_TYPE_LEN:
63  *
64  * Length of the type field of a STUN attribute (in bytes).
65  */
66 /**
67  * STUN_ATTRIBUTE_TYPE_POS:
68  *
69  * Offset of the type field of a STUN attribute (in bytes).
70  */
71 /**
72  * STUN_ATTRIBUTE_VALUE_POS:
73  *
74  * Offset of the value field of a STUN attribute (in bytes).
75  */
76 /**
77  * STUN_ID_LEN:
78  *
79  * Length of the ID field of a STUN message (in bytes).
80  */
81 /**
82  * STUN_MAGIC_COOKIE:
83  *
84  * Magic cookie value used to identify STUN messages.
85  */
86 /**
87  * TURN_MAGIC_COOKIE:
88  *
89  * Magic cookie value used to identify TURN messages.
90  */
91 /**
92  * STUN_MAX_MESSAGE_SIZE_IPV4:
93  *
94  * Maximum size of a STUN message sent over IPv4 (in bytes).
95  */
96 /**
97  * STUN_MAX_MESSAGE_SIZE_IPV6:
98  *
99  * Maximum size of a STUN message sent over IPv6 (in bytes).
100  */
101 /**
102  * STUN_MESSAGE_ATTRIBUTES_POS:
103  *
104  * Offset of the attributes of a STUN message (in bytes).
105  */
106 /**
107  * STUN_MESSAGE_HEADER_LENGTH:
108  *
109  * Total length of a STUN message header (in bytes).
110  */
111 /**
112  * STUN_MESSAGE_LENGTH_LEN:
113  *
114  * Length of the length field of a STUN message (in bytes).
115  */
116 /**
117  * STUN_MESSAGE_LENGTH_POS:
118  *
119  * Offset of the length field of a STUN message (in bytes).
120  */
121 /**
122  * STUN_MESSAGE_TRANS_ID_LEN:
123  *
124  * Length of the transaction ID field of a STUN message (in bytes).
125  */
126 /**
127  * STUN_MESSAGE_TRANS_ID_POS:
128  *
129  * Offset of the transaction ID field of a STUN message (in bytes).
130  */
131 /**
132  * STUN_MESSAGE_TYPE_LEN:
133  *
134  * Length of the type field of a STUN message (in bytes).
135  */
136 /**
137  * STUN_MESSAGE_TYPE_POS:
138  *
139  * Offset of the type field of a STUN message (in bytes).
140  */
141
142 #define STUN_MESSAGE_TYPE_POS 0
143 #define STUN_MESSAGE_TYPE_LEN 2
144 #define STUN_MESSAGE_LENGTH_POS \
145   (STUN_MESSAGE_TYPE_POS + STUN_MESSAGE_TYPE_LEN)
146 #define STUN_MESSAGE_LENGTH_LEN 2
147 #define STUN_MESSAGE_TRANS_ID_POS \
148   (STUN_MESSAGE_LENGTH_POS + STUN_MESSAGE_LENGTH_LEN)
149 #define STUN_MESSAGE_TRANS_ID_LEN 16
150 #define STUN_MESSAGE_ATTRIBUTES_POS \
151   (STUN_MESSAGE_TRANS_ID_POS + STUN_MESSAGE_TRANS_ID_LEN)
152
153 #define STUN_MESSAGE_HEADER_LENGTH STUN_MESSAGE_ATTRIBUTES_POS
154
155 #define STUN_ATTRIBUTE_TYPE_POS 0
156 #define STUN_ATTRIBUTE_TYPE_LEN 2
157 #define STUN_ATTRIBUTE_LENGTH_POS \
158   (STUN_ATTRIBUTE_TYPE_POS + STUN_ATTRIBUTE_TYPE_LEN)
159 #define STUN_ATTRIBUTE_LENGTH_LEN 2
160 #define STUN_ATTRIBUTE_VALUE_POS \
161   (STUN_ATTRIBUTE_LENGTH_POS + STUN_ATTRIBUTE_LENGTH_LEN)
162
163 /**
164  * STUN_ATTRIBUTE_HEADER_LENGTH:
165  *
166  * Length of a single STUN attribute header (in bytes).
167  */
168 #define STUN_ATTRIBUTE_HEADER_LENGTH STUN_ATTRIBUTE_VALUE_POS
169
170
171 #define STUN_MAX_MESSAGE_SIZE_IPV4 576
172 #define STUN_MAX_MESSAGE_SIZE_IPV6 1280
173 /* #define STUN_MAX_MESSAGE_SIZE STUN_MAX_MESSAGE_SIZE_IPV4 */
174
175 #define STUN_ID_LEN 16
176
177 /**
178  * STUN_AGENT_MAX_SAVED_IDS:
179  *
180  * Maximum number of simultaneously ongoing STUN transactions.
181  */
182 #define STUN_AGENT_MAX_SAVED_IDS 200
183
184 /**
185  * STUN_AGENT_MAX_UNKNOWN_ATTRIBUTES:
186  *
187  * Maximum number of unknown attribute which can be handled in a single STUN
188  * message.
189  */
190 #define STUN_AGENT_MAX_UNKNOWN_ATTRIBUTES 256
191
192 #define STUN_MAGIC_COOKIE 0x2112A442
193 #define TURN_MAGIC_COOKIE 0x72c64bc6
194
195 #ifndef TRUE
196 #define TRUE (1 == 1)
197 #endif
198
199 #ifndef FALSE
200 #define FALSE (0 == 1)
201 #endif
202
203 #endif /* _STUN_CONSTANTS_H */