Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __PJNATH_STUN_SOCK_H__
00021 #define __PJNATH_STUN_SOCK_H__
00022
00027 #include <pjnath/stun_config.h>
00028 #include <pjlib-util/resolver.h>
00029 #include <pj/ioqueue.h>
00030 #include <pj/sock.h>
00031 #include <pj/sock_qos.h>
00032
00033
00034 PJ_BEGIN_DECL
00035
00036
00061 typedef struct pj_stun_sock pj_stun_sock;
00062
00068 typedef enum pj_stun_sock_op
00069 {
00073 PJ_STUN_SOCK_DNS_OP = 1,
00074
00078 PJ_STUN_SOCK_BINDING_OP,
00079
00084 PJ_STUN_SOCK_KEEP_ALIVE_OP,
00085
00089 PJ_STUN_SOCK_MAPPED_ADDR_CHANGE
00090
00091
00092 } pj_stun_sock_op;
00093
00094
00099 typedef struct pj_stun_sock_cb
00100 {
00115 pj_bool_t (*on_rx_data)(pj_stun_sock *stun_sock,
00116 void *pkt,
00117 unsigned pkt_len,
00118 const pj_sockaddr_t *src_addr,
00119 unsigned addr_len);
00120
00137 pj_bool_t (*on_data_sent)(pj_stun_sock *stun_sock,
00138 pj_ioqueue_op_key_t *send_key,
00139 pj_ssize_t sent);
00140
00169 pj_bool_t (*on_status)(pj_stun_sock *stun_sock,
00170 pj_stun_sock_op op,
00171 pj_status_t status);
00172
00173 } pj_stun_sock_cb;
00174
00175
00180 typedef struct pj_stun_sock_info
00181 {
00185 pj_sockaddr bound_addr;
00186
00190 pj_sockaddr srv_addr;
00191
00197 pj_sockaddr mapped_addr;
00198
00203 unsigned alias_cnt;
00204
00208 pj_sockaddr aliases[PJ_ICE_ST_MAX_CAND];
00209
00210 } pj_stun_sock_info;
00211
00212
00218 typedef struct pj_stun_sock_cfg
00219 {
00223 unsigned max_pkt_size;
00224
00232 unsigned async_cnt;
00233
00241 pj_sockaddr bound_addr;
00242
00249 int ka_interval;
00250
00258 pj_qos_type qos_type;
00259
00267 pj_qos_params qos_params;
00268
00275 pj_bool_t qos_ignore_error;
00276
00277 } pj_stun_sock_cfg;
00278
00279
00280
00284 PJ_DECL(const char*) pj_stun_sock_op_name(pj_stun_sock_op op);
00285
00286
00292 PJ_DECL(void) pj_stun_sock_cfg_default(pj_stun_sock_cfg *cfg);
00293
00294
00316 PJ_DECL(pj_status_t) pj_stun_sock_create(pj_stun_config *stun_cfg,
00317 const char *name,
00318 int af,
00319 const pj_stun_sock_cb *cb,
00320 const pj_stun_sock_cfg *cfg,
00321 void *user_data,
00322 pj_stun_sock **p_sock);
00323
00324
00355 PJ_DECL(pj_status_t) pj_stun_sock_start(pj_stun_sock *stun_sock,
00356 const pj_str_t *domain,
00357 pj_uint16_t default_port,
00358 pj_dns_resolver *resolver);
00359
00368 PJ_DECL(pj_status_t) pj_stun_sock_destroy(pj_stun_sock *sock);
00369
00370
00381 PJ_DECL(pj_status_t) pj_stun_sock_set_user_data(pj_stun_sock *stun_sock,
00382 void *user_data);
00383
00392 PJ_DECL(void*) pj_stun_sock_get_user_data(pj_stun_sock *stun_sock);
00393
00394
00405 PJ_DECL(pj_status_t) pj_stun_sock_get_info(pj_stun_sock *stun_sock,
00406 pj_stun_sock_info *info);
00407
00408
00429 PJ_DECL(pj_status_t) pj_stun_sock_sendto(pj_stun_sock *stun_sock,
00430 pj_ioqueue_op_key_t *send_key,
00431 const void *pkt,
00432 unsigned pkt_len,
00433 unsigned flag,
00434 const pj_sockaddr_t *dst_addr,
00435 unsigned addr_len);
00436
00442 PJ_END_DECL
00443
00444
00445 #endif
00446