Asterisk - The Open Source Telephony Project
18.5.0
|
STUN support. More...
Go to the source code of this file.
Macros | |
#define | AST_DEBUG_CATEGORY_STUN ast_debug_category_stun_id() /* STUN debug logging category id */ |
#define | AST_DEBUG_CATEGORY_STUN_PACKET ast_debug_category_stun_packet_id() /* STUN packet debug logging category id */ |
#define | ast_debug_stun(sublevel, ...) ast_debug_category(sublevel, AST_DEBUG_CATEGORY_STUN, __VA_ARGS__) |
Log debug level STUN information. More... | |
#define | ast_debug_stun_packet_is_allowed ast_debug_category_is_allowed(AST_LOG_CATEGORY_ENABLED, AST_DEBUG_CATEGORY_STUN_PACKET) |
#define | AST_LOG_CATEGORY_STUN "stun" |
#define | AST_LOG_CATEGORY_STUN_PACKET "stun_packet" |
Typedefs | |
typedef int() | stun_cb_f(struct stun_attr *attr, void *arg) |
callback type to be invoked on stun responses. More... | |
Enumerations | |
enum | ast_stun_result { AST_STUN_IGNORE = 0, AST_STUN_ACCEPT } |
Functions | |
uintmax_t | ast_debug_category_stun_id (void) |
uintmax_t | ast_debug_category_stun_packet_id (void) |
int | ast_stun_handle_packet (int s, struct sockaddr_in *src, unsigned char *data, size_t len, stun_cb_f *stun_cb, void *arg) |
handle an incoming STUN message. More... | |
int | ast_stun_request (int s, struct sockaddr_in *dst, const char *username, struct sockaddr_in *answer) |
Generic STUN request. More... | |
Variables | |
static const int | STANDARD_STUN_PORT = 3478 |
#define AST_DEBUG_CATEGORY_STUN ast_debug_category_stun_id() /* STUN debug logging category id */ |
Definition at line 44 of file stun.h.
Referenced by rtp_add_candidates_to_ice().
#define AST_DEBUG_CATEGORY_STUN_PACKET ast_debug_category_stun_packet_id() /* STUN packet debug logging category id */ |
#define ast_debug_stun | ( | sublevel, | |
... | |||
) | ast_debug_category(sublevel, AST_DEBUG_CATEGORY_STUN, __VA_ARGS__) |
Log debug level STUN information.
sublevel | Debug output sublevel (>= 0) |
... | String format and any associated arguments |
Definition at line 53 of file stun.h.
Referenced by ast_rtcp_read(), ast_rtp_read(), ast_stun_handle_packet(), and ast_stun_request().
#define ast_debug_stun_packet_is_allowed ast_debug_category_is_allowed(AST_LOG_CATEGORY_ENABLED, AST_DEBUG_CATEGORY_STUN_PACKET) |
Definition at line 57 of file stun.h.
Referenced by ast_stun_handle_packet(), handle_cli_stun_set_debug(), and stun_process_attr().
#define AST_LOG_CATEGORY_STUN "stun" |
Definition at line 37 of file stun.h.
Referenced by ast_stun_init(), and stun_shutdown().
#define AST_LOG_CATEGORY_STUN_PACKET "stun_packet" |
Definition at line 39 of file stun.h.
Referenced by ast_stun_init(), handle_cli_stun_set_debug(), and stun_shutdown().
typedef int() stun_cb_f(struct stun_attr *attr, void *arg) |
enum ast_stun_result |
uintmax_t ast_debug_category_stun_id | ( | void | ) |
uintmax_t ast_debug_category_stun_packet_id | ( | void | ) |
int ast_stun_handle_packet | ( | int | s, |
struct sockaddr_in * | src, | ||
unsigned char * | data, | ||
size_t | len, | ||
stun_cb_f * | stun_cb, | ||
void * | arg | ||
) |
handle an incoming STUN message.
s | Socket to send any response to. |
src | Address where packet came from. |
data | STUN packet buffer to process. |
len | Length of packet |
stun_cb | If not NULL, callback for each STUN attribute. |
arg | Arg to pass to callback. |
Do some basic sanity checks on packet size and content, try to extract a bit of information, and possibly reply. At the moment this only processes BIND requests, and returns the externally visible address of the request. If a callback is specified, invoke it with the attribute.
AST_STUN_ACCEPT | if responed to a STUN request |
AST_STUN_IGNORE | |
-1 | on error |
Definition at line 268 of file stun.c.
References append_attr_address(), append_attr_string(), ast_debug_stun, ast_debug_stun_packet_is_allowed, AST_STUN_ACCEPT, AST_STUN_IGNORE, ast_stun_request(), ast_verbose(), stun_attr::attr, stun_header::id, stun_header::ies, stun_attr::len, stun_header::msglen, stun_header::msgtype, NULL, stun_attr2str(), STUN_BINDREQ, STUN_BINDRESP, STUN_MAPPED_ADDRESS, stun_msg2str(), stun_process_attr(), stun_send(), STUN_USERNAME, and stun_state::username.
Referenced by ast_rtcp_read(), ast_rtp_read(), and ast_stun_request().
int ast_stun_request | ( | int | s, |
struct sockaddr_in * | dst, | ||
const char * | username, | ||
struct sockaddr_in * | answer | ||
) |
Generic STUN request.
s | The socket used to send the request. |
dst | If non null, the address of the STUN server. Only needed if the socket is not bound or connected. |
username | If non null, add the username in the request. |
answer | If non null, the function waits for a response and puts here the externally visible address. |
Send a generic STUN request to the server specified, possibly waiting for a reply and filling the answer parameter with the externally visible address. Note that in this case the request will be blocking.
0 | on success. |
<0 | on error. |
>0 | on timeout. |
Definition at line 384 of file stun.c.
References append_attr_string(), ast_debug_stun, ast_poll, ast_remaining_ms(), ast_stun_handle_packet(), ast_tvnow(), stun_attr::attr, errno, stun_header::id, stun_header::ies, if(), stun_header::msglen, stun_header::msgtype, STUN_BINDERR, STUN_BINDREQ, STUN_BINDRESP, stun_get_mapped(), stun_id_cmp(), stun_req_id(), stun_send(), and STUN_USERNAME.
Referenced by ast_rtp_stun_request(), ast_stun_handle_packet(), rtp_add_candidates_to_ice(), and stun_monitor_request().
|
static |
Definition at line 60 of file stun.h.
Referenced by rtp_reload(), and setup_stunaddr().