|
1 /* |
|
2 Copyright (c) 2007, Adobe Systems, Incorporated |
|
3 All rights reserved. |
|
4 |
|
5 Redistribution and use in source and binary forms, with or without |
|
6 modification, are permitted provided that the following conditions are |
|
7 met: |
|
8 |
|
9 * Redistributions of source code must retain the above copyright |
|
10 notice, this list of conditions and the following disclaimer. |
|
11 |
|
12 * Redistributions in binary form must reproduce the above copyright |
|
13 notice, this list of conditions and the following disclaimer in the |
|
14 documentation and/or other materials provided with the distribution. |
|
15 |
|
16 * Neither the name of Adobe Systems, Network Resonance nor the names of its |
|
17 contributors may be used to endorse or promote products derived from |
|
18 this software without specific prior written permission. |
|
19 |
|
20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
21 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
22 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
|
23 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
|
24 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
25 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
26 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
27 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|
28 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
29 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
30 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
31 */ |
|
32 |
|
33 |
|
34 |
|
35 #ifndef _stun_codec_h |
|
36 #define _stun_codec_h |
|
37 |
|
38 #include "stun_msg.h" |
|
39 |
|
40 typedef struct nr_stun_attr_info_ nr_stun_attr_info; |
|
41 |
|
42 typedef struct nr_stun_attr_codec_ { |
|
43 char *name; |
|
44 int (*print)(nr_stun_attr_info *attr_info, char *msg, void *data); |
|
45 int (*encode)(nr_stun_attr_info *attr_info, void *data, int offset, int buflen, UCHAR *buf, int *attrlen); |
|
46 int (*decode)(nr_stun_attr_info *attr_info, int attrlen, UCHAR *buf, int offset, int buflen, void *data); |
|
47 } nr_stun_attr_codec; |
|
48 |
|
49 struct nr_stun_attr_info_ { |
|
50 UINT2 type; |
|
51 char *name; |
|
52 nr_stun_attr_codec *codec; |
|
53 int (*illegal)(nr_stun_attr_info *attr_info, int attrlen, void *data); |
|
54 }; |
|
55 |
|
56 extern nr_stun_attr_codec nr_stun_attr_codec_UINT4; |
|
57 extern nr_stun_attr_codec nr_stun_attr_codec_UINT8; |
|
58 extern nr_stun_attr_codec nr_stun_attr_codec_addr; |
|
59 extern nr_stun_attr_codec nr_stun_attr_codec_bytes; |
|
60 extern nr_stun_attr_codec nr_stun_attr_codec_data; |
|
61 extern nr_stun_attr_codec nr_stun_attr_codec_error_code; |
|
62 extern nr_stun_attr_codec nr_stun_attr_codec_fingerprint; |
|
63 extern nr_stun_attr_codec nr_stun_attr_codec_flag; |
|
64 extern nr_stun_attr_codec nr_stun_attr_codec_message_integrity; |
|
65 extern nr_stun_attr_codec nr_stun_attr_codec_noop; |
|
66 extern nr_stun_attr_codec nr_stun_attr_codec_quoted_string; |
|
67 extern nr_stun_attr_codec nr_stun_attr_codec_string; |
|
68 extern nr_stun_attr_codec nr_stun_attr_codec_unknown_attributes; |
|
69 extern nr_stun_attr_codec nr_stun_attr_codec_xor_mapped_address; |
|
70 extern nr_stun_attr_codec nr_stun_attr_codec_xor_peer_address; |
|
71 extern nr_stun_attr_codec nr_stun_attr_codec_old_xor_mapped_address; |
|
72 |
|
73 |
|
74 int nr_stun_encode_message(nr_stun_message *msg); |
|
75 int nr_stun_decode_message(nr_stun_message *msg, int (*get_password)(void *arg, nr_stun_message *msg, Data **password), void *arg); |
|
76 |
|
77 #endif |
|
78 |