673fcccdd44a8cfaab9e00a6ec5b2bbf3fb2117c
[platform/upstream/libnice.git] / stun / utils.h
1 /*
2  * This file is part of the Nice GLib ICE library.
3  *
4  * (C) 2008-2009 Collabora Ltd.
5  *  Contact: Youness Alaoui
6  * (C) 2008-2009 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_UTILS_H
38 # define STUN_UTILS_H 1
39
40 /*
41  * @file utils.h
42  * @brief STUN client generic utility functions
43  */
44
45 #include "stunmessage.h"
46
47 #ifdef _WIN32
48 #include <winsock2.h>
49 #include <ws2tcpip.h>
50 #else
51 #include <sys/types.h>
52 #include <sys/socket.h>
53 #include <netinet/in.h>
54 #endif
55
56 # ifdef __cplusplus
57 extern "C" {
58 # endif
59
60 size_t stun_padding (size_t l);
61
62 size_t stun_align (size_t l);
63
64 uint16_t stun_getw (const uint8_t *ptr);
65
66 void *stun_setw (uint8_t *ptr, uint16_t value);
67
68 void stun_set_type (uint8_t *h, StunClass c, StunMethod m);
69
70 StunMessageReturn stun_xor_address (const StunMessage *msg,
71     struct sockaddr_storage *addr, socklen_t addrlen,
72     uint32_t magic_cookie);
73
74
75 # ifdef __cplusplus
76 }
77 # endif
78
79 #endif /* STUN_UTILS_H */