BLOG | DOCUMENTATION | TRAC

Home --> Documentations --> PJNATH Reference

turn_sock.h
Go to the documentation of this file.
1 /* $Id$ */
2 /*
3  * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
4  * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  */
20 #ifndef __PJNATH_TURN_SOCK_H__
21 #define __PJNATH_TURN_SOCK_H__
22 
27 #include <pjnath/turn_session.h>
28 #include <pj/sock_qos.h>
29 #include <pj/ssl_sock.h>
30 
31 
33 
34 
35 /* **************************************************************************/
63 typedef struct pj_turn_sock pj_turn_sock;
64 
69 typedef struct pj_turn_sock_cb
70 {
84  void (*on_rx_data)(pj_turn_sock *turn_sock,
85  void *pkt,
86  unsigned pkt_len,
87  const pj_sockaddr_t *peer_addr,
88  unsigned addr_len);
89 
105  pj_ssize_t sent);
106 
115  void (*on_state)(pj_turn_sock *turn_sock,
116  pj_turn_state_t old_state,
117  pj_turn_state_t new_state);
118 
142  pj_uint32_t conn_id,
143  const pj_sockaddr_t *peer_addr,
144  unsigned addr_len);
145 
156  void (*on_connection_status)(pj_turn_sock *turn_sock,
157  pj_status_t status,
158  pj_uint32_t conn_id,
159  const pj_sockaddr_t *peer_addr,
160  unsigned addr_len);
161 
163 
164 
169 #ifndef PJ_TURN_TLS_DEFAULT_PROTO
170 # define PJ_TURN_TLS_DEFAULT_PROTO (PJ_SSL_SOCK_PROTO_TLS1 | \
171  PJ_SSL_SOCK_PROTO_TLS1_1 | \
172  PJ_SSL_SOCK_PROTO_TLS1_2)
173 #endif
174 
178 typedef struct pj_turn_sock_tls_cfg
179 {
184 
189 
195 
200 
206 
214 
221 
226 
243 
245 
251  PJ_DECL(void) pj_turn_sock_tls_cfg_default(pj_turn_sock_tls_cfg *tls_cfg);
252 
260  PJ_DECL(void) pj_turn_sock_tls_cfg_dup(pj_pool_t *pool,
262  const pj_turn_sock_tls_cfg *src);
263 
270 
271 
277 typedef struct pj_turn_sock_cfg
278 {
286 
292  unsigned max_pkt_size;
293 
302 
311 
319 
327 
336 
345  unsigned so_rcvbuf_size;
346 
355  unsigned so_sndbuf_size;
356 
362 
364 
365 
369 PJ_DECL(void) pj_turn_sock_cfg_default(pj_turn_sock_cfg *cfg);
370 
371 
398  int af,
399  pj_turn_tp_type conn_type,
400  const pj_turn_sock_cb *cb,
401  const pj_turn_sock_cfg *setting,
402  void *user_data,
403  pj_turn_sock **p_turn_sock);
404 
414 PJ_DECL(void) pj_turn_sock_destroy(pj_turn_sock *turn_sock);
415 
416 
428  void *user_data);
429 
438 PJ_DECL(void*) pj_turn_sock_get_user_data(pj_turn_sock *turn_sock);
439 
440 
449 
450 
463 
474 PJ_DECL(pj_status_t) pj_turn_sock_lock(pj_turn_sock *turn_sock);
475 
476 
485 PJ_DECL(pj_status_t) pj_turn_sock_unlock(pj_turn_sock *turn_sock);
486 
487 
495 PJ_DECL(void) pj_turn_sock_set_log(pj_turn_sock *turn_sock,
496  unsigned flags);
497 
510  const pj_str_t *sw);
511 
512 
548 PJ_DECL(pj_status_t) pj_turn_sock_alloc(pj_turn_sock *turn_sock,
549  const pj_str_t *domain,
550  int default_port,
551  pj_dns_resolver *resolver,
552  const pj_stun_auth_cred *cred,
553  const pj_turn_alloc_param *param);
554 
574  unsigned addr_cnt,
575  const pj_sockaddr addr[],
576  unsigned options);
577 
600 PJ_DECL(pj_status_t) pj_turn_sock_sendto(pj_turn_sock *turn_sock,
601  const pj_uint8_t *pkt,
602  unsigned pkt_len,
603  const pj_sockaddr_t *peer_addr,
604  unsigned addr_len);
605 
623  const pj_sockaddr_t *peer,
624  unsigned addr_len);
625 
626 
633 
634 
635 #endif /* __PJNATH_TURN_SOCK_H__ */
636 
pj_bool_t(* on_data_sent)(pj_turn_sock *sock, pj_ssize_t sent)
Definition: turn_sock.h:104
void pj_turn_sock_tls_cfg_dup(pj_pool_t *pool, pj_turn_sock_tls_cfg *dst, const pj_turn_sock_tls_cfg *src)
Definition: stun_auth.h:114
pj_status_t pj_turn_sock_get_info(pj_turn_sock *turn_sock, pj_turn_session_info *info)
int pj_bool_t
pj_status_t pj_turn_sock_set_user_data(pj_turn_sock *turn_sock, void *user_data)
pj_turn_sock_tls_cfg tls_cfg
Definition: turn_sock.h:361
pj_status_t pj_turn_sock_set_perm(pj_turn_sock *turn_sock, unsigned addr_cnt, const pj_sockaddr addr[], unsigned options)
pj_qos_type
Definition: turn_session.h:419
unsigned so_rcvbuf_size
Definition: turn_sock.h:345
pj_uint16_t port_range
Definition: turn_sock.h:335
Transport independent TURN client session.
pj_status_t pj_turn_sock_alloc(pj_turn_sock *turn_sock, const pj_str_t *domain, int default_port, pj_dns_resolver *resolver, const pj_stun_auth_cred *cred, const pj_turn_alloc_param *param)
pj_grp_lock_t * grp_lock
Definition: turn_sock.h:285
#define PJ_BEGIN_DECL
void * user_data
void(* on_rx_data)(pj_turn_sock *turn_sock, void *pkt, unsigned pkt_len, const pj_sockaddr_t *peer_addr, unsigned addr_len)
Definition: turn_sock.h:84
pj_status_t pj_turn_sock_set_software_name(pj_turn_sock *turn_sock, const pj_str_t *sw)
pj_status_t pj_turn_sock_sendto(pj_turn_sock *turn_sock, const pj_uint8_t *pkt, unsigned pkt_len, const pj_sockaddr_t *peer_addr, unsigned addr_len)
pj_turn_tp_type
Definition: turn_session.h:139
void pj_sockaddr_t
pj_str_t ca_list_file
Definition: turn_sock.h:183
pj_ssl_cert_buffer privkey_buf
Definition: turn_sock.h:220
pj_str_t ca_list_path
Definition: turn_sock.h:188
int pj_status_t
Definition: turn_sock.h:277
pj_str_t password
Definition: turn_sock.h:225
Definition: turn_session.h:373
void pj_turn_sock_cfg_default(pj_turn_sock_cfg *cfg)
void(* on_connection_status)(pj_turn_sock *turn_sock, pj_status_t status, pj_uint32_t conn_id, const pj_sockaddr_t *peer_addr, unsigned addr_len)
Definition: turn_sock.h:156
struct pj_turn_sock pj_turn_sock
Definition: turn_sock.h:63
struct pj_grp_lock_t pj_grp_lock_t
pj_ssl_sock_param ssock_param
Definition: turn_sock.h:242
pj_status_t pj_turn_sock_lock(pj_turn_sock *turn_sock)
unsigned int pj_uint32_t
void pj_turn_sock_destroy(pj_turn_sock *turn_sock)
void pj_turn_sock_set_log(pj_turn_sock *turn_sock, unsigned flags)
Definition: turn_sock.h:69
unsigned max_pkt_size
Definition: turn_sock.h:292
pj_grp_lock_t * pj_turn_sock_get_grp_lock(pj_turn_sock *turn_sock)
Definition: stun_config.h:48
struct pj_dns_resolver pj_dns_resolver
Definition: turn_sock.h:178
pj_status_t pj_turn_sock_bind_channel(pj_turn_sock *turn_sock, const pj_sockaddr_t *peer, unsigned addr_len)
void pj_turn_sock_tls_cfg_wipe_keys(pj_turn_sock_tls_cfg *tls_cfg)
unsigned char pj_uint8_t
pj_status_t(* on_connection_attempt)(pj_turn_sock *turn_sock, pj_uint32_t conn_id, const pj_sockaddr_t *peer_addr, unsigned addr_len)
Definition: turn_sock.h:141
long pj_ssize_t
void * pj_turn_sock_get_user_data(pj_turn_sock *turn_sock)
void pj_turn_sock_tls_cfg_default(pj_turn_sock_tls_cfg *tls_cfg)
pj_str_t info
pj_status_t pj_turn_sock_create(pj_stun_config *cfg, int af, pj_turn_tp_type conn_type, const pj_turn_sock_cb *cb, const pj_turn_sock_cfg *setting, void *user_data, pj_turn_sock **p_turn_sock)
pj_qos_type qos_type
Definition: turn_sock.h:301
pj_turn_state_t
Definition: turn_session.h:162
pj_ssl_cert_buffer cert_buf
Definition: turn_sock.h:213
pj_bool_t qos_ignore_error
Definition: turn_sock.h:318
pj_ssl_cert_buffer ca_buf
Definition: turn_sock.h:205
pj_status_t pj_turn_sock_unlock(pj_turn_sock *turn_sock)
pj_qos_params qos_params
Definition: turn_sock.h:310
pj_uint32_t flags
unsigned short pj_uint16_t
unsigned so_sndbuf_size
Definition: turn_sock.h:355
#define PJ_END_DECL
pj_str_t privkey_file
Definition: turn_sock.h:199
pj_sockaddr bound_addr
Definition: turn_sock.h:326
pj_str_t cert_file
Definition: turn_sock.h:194
void(* on_state)(pj_turn_sock *turn_sock, pj_turn_state_t old_state, pj_turn_state_t new_state)
Definition: turn_sock.h:115

 


PJNATH - Open Source NAT traversal helper library supporting STUN, TURN, and ICE
Copyright (C) 2006-2009 Teluu Inc.