libwebsockets
Lightweight C library for HTML5 websockets
Toggle main menu visibility
class="ui-resizable-handle">
Loading...
Searching...
No Matches
lws-stun.h
Go to the documentation of this file.
1
/*
2
* libwebsockets - small server side websockets and web server implementation
3
*
4
* Copyright (C) 2010 - 2022 Andy Green <andy@warmcat.com>
5
*
6
* Permission is hereby granted, free of charge, to any person obtaining a copy
7
* of this software and associated documentation files (the "Software"), to
8
* deal in the Software without restriction, including without limitation the
9
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10
* sell copies of the Software, and to permit persons to whom the Software is
11
* furnished to do so, subject to the following conditions:
12
*
13
* The above copyright notice and this permission notice shall be included in
14
* all copies or substantial portions of the Software.
15
*
16
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22
* IN THE SOFTWARE.
23
*/
24
25
#ifndef _LWS_STUN_H_
26
#define _LWS_STUN_H_
27
28
#define LWS_STUN_MAGIC_COOKIE 0x2112A442
29
#define LWS_STUN_FINGERPRINT_XOR 0x5354554e
30
31
enum
lws_stun_req_type
{
32
LWS_STUNREQ_BINDING
= 1,
33
};
34
35
enum
lws_stun_attr_type
{
36
LWS_STUN_ATTR_USERNAME
= 0x0006,
37
};
38
39
/*
40
* This is the public API for the STUN packet processing
41
*/
42
43
LWS_VISIBLE
LWS_EXTERN
int
44
lws_stun_req_pack
(
struct
lws *wsi,
enum
lws_stun_req_type
type,
45
struct
sockaddr_in
*sa4,
uint8_t
*buf,
size_t
len,
46
void
*cookie);
47
48
/*
49
* Validates incoming STUN packet against password (HMAC) and generates reply.
50
* Returns length of reply in 'out', or 0 if validation fails or nothing to send.
51
*/
52
LWS_VISIBLE
LWS_EXTERN
int
53
lws_stun_validate_and_reply
(
struct
lws *wsi,
uint8_t
*in,
size_t
in_len,
54
uint8_t
*out,
size_t
out_len,
55
const
char
*password,
const
struct
sockaddr_in
*peer_sin);
56
57
#endif
LWS_EXTERN
#define LWS_EXTERN
Definition
libwebsockets.h:296
uint8_t
unsigned char uint8_t
Definition
libwebsockets.h:697
LWS_VISIBLE
#define LWS_VISIBLE
Definition
libwebsockets.h:291
lws_stun_attr_type
lws_stun_attr_type
Definition
lws-stun.h:35
LWS_STUN_ATTR_USERNAME
@ LWS_STUN_ATTR_USERNAME
Definition
lws-stun.h:36
lws_stun_req_type
lws_stun_req_type
Definition
lws-stun.h:31
LWS_STUNREQ_BINDING
@ LWS_STUNREQ_BINDING
Definition
lws-stun.h:32
lws_stun_validate_and_reply
LWS_VISIBLE LWS_EXTERN int lws_stun_validate_and_reply(struct lws *wsi, uint8_t *in, size_t in_len, uint8_t *out, size_t out_len, const char *password, const struct sockaddr_in *peer_sin)
lws_stun_req_pack
LWS_VISIBLE LWS_EXTERN int lws_stun_req_pack(struct lws *wsi, enum lws_stun_req_type type, struct sockaddr_in *sa4, uint8_t *buf, size_t len, void *cookie)
sockaddr_in
Definition
lws-optee.h:59
include
libwebsockets
lws-stun.h
Generated on
for libwebsockets by
1.18.0