BLOG | DOCUMENTATION | TRAC

Home --> Documentations --> PJNATH Reference

turn_session.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_SESSION_H__
21 #define __PJNATH_TURN_SESSION_H__
22 
27 #include <pjnath/stun_session.h>
28 #include <pjlib-util/resolver.h>
29 
30 
32 
33 
34 /* **************************************************************************/
132 
133 
139 typedef enum pj_turn_tp_type
140 {
145 
150 
157 
159 
160 
162 typedef enum pj_turn_state_t
163 {
168 
174 
180 
186 
192 
198 
204 
209 
211 
212 
213 #pragma pack(1)
214 
219 typedef struct pj_turn_channel_data
220 {
224 
225 
226 #pragma pack()
227 
228 
232 typedef struct pj_turn_session_cb
233 {
252  const pj_uint8_t *pkt,
253  unsigned pkt_len,
254  const pj_sockaddr_t *dst_addr,
255  unsigned addr_len);
256 
274  const pj_uint8_t *pkt,
275  unsigned pkt_len,
276  const pj_sockaddr_t *dst_addr,
277  unsigned addr_len);
278 
292  const pj_sockaddr_t *peer_addr,
293  unsigned addr_len,
294  unsigned ch_num);
295 
309  void *pkt,
310  unsigned pkt_len,
311  const pj_sockaddr_t *peer_addr,
312  unsigned addr_len);
313 
323  void (*on_state)(pj_turn_session *sess,
324  pj_turn_state_t old_state,
325  pj_turn_state_t new_state);
326 
344  pj_uint32_t conn_id,
345  const pj_sockaddr_t *peer_addr,
346  unsigned addr_len);
347 
359  pj_status_t status,
360  pj_uint32_t conn_id,
361  const pj_sockaddr_t *peer_addr,
362  unsigned addr_len);
363 
365 
366 
373 typedef struct pj_turn_alloc_param
374 {
382 
387  int lifetime;
388 
395 
403  int af;
404 
412 
414 
415 
419 typedef struct pj_turn_session_info
420 {
425 
430 
435 
440 
445 
450 
454  int lifetime;
455 
457 
458 
463 {
468  void *pkt;
469 
474 
479 
484 
488  unsigned src_addr_len;
489 
491 
492 
499 
500 
508 PJ_DECL(void) pj_turn_alloc_param_copy(pj_pool_t *pool,
509  pj_turn_alloc_param *dst,
510  const pj_turn_alloc_param *src);
511 
519 PJ_DECL(const char*) pj_turn_state_name(pj_turn_state_t state);
520 
521 
549  const char *name,
550  int af,
551  pj_turn_tp_type conn_type,
552  pj_grp_lock_t *grp_lock,
553  const pj_turn_session_cb *cb,
554  unsigned options,
555  void *user_data,
556  pj_turn_session **p_sess);
557 
568 
569 
588  pj_status_t last_err);
589 
590 
604 
616  void *user_data);
617 
626 PJ_DECL(void*) pj_turn_session_get_user_data(pj_turn_session *sess);
627 
628 
637 
638 
645 PJ_DECL(void) pj_turn_session_set_log(pj_turn_session *sess,
646  unsigned flags);
647 
648 
661  const pj_str_t *sw);
662 
663 
700  const pj_str_t *domain,
701  int default_port,
702  pj_dns_resolver *resolver);
703 
704 
717  const pj_stun_auth_cred *cred);
718 
719 
743  const pj_turn_alloc_param *param);
744 
745 
765  unsigned addr_cnt,
766  const pj_sockaddr addr[],
767  unsigned options);
768 
769 
796  const pj_uint8_t *pkt,
797  unsigned pkt_len,
798  const pj_sockaddr_t *peer_addr,
799  unsigned addr_len);
800 
821  const pj_sockaddr_t *peer,
822  unsigned addr_len);
823 
846  void *pkt,
847  pj_size_t pkt_len,
848  pj_size_t *parsed_len);
849 
874  pj_turn_session *sess,
876 
895  pj_turn_session *sess,
896  pj_pool_t *pool,
897  pj_uint32_t conn_id,
898  const pj_sockaddr_t *peer_addr,
899  unsigned addr_len);
900 
907 
908 
909 #endif /* __PJNATH_TURN_SESSION_H__ */
910 
Definition: turn_session.h:462
size_t pj_size_t
@ PJ_TURN_STATE_DEALLOCATED
Definition: turn_session.h:203
pj_size_t parsed_len
Definition: turn_session.h:478
pj_status_t pj_turn_session_bind_channel(pj_turn_session *sess, const pj_sockaddr_t *peer, unsigned addr_len)
Definition: stun_auth.h:114
pj_status_t pj_turn_session_set_credential(pj_turn_session *sess, const pj_stun_auth_cred *cred)
int af
Definition: turn_session.h:403
pj_size_t pkt_len
Definition: turn_session.h:473
@ PJ_TURN_STATE_NULL
Definition: turn_session.h:167
int ka_interval
Definition: turn_session.h:394
void(* on_connection_attempt)(pj_turn_session *sess, pj_uint32_t conn_id, const pj_sockaddr_t *peer_addr, unsigned addr_len)
Definition: turn_session.h:343
pj_status_t pj_turn_session_connection_bind(pj_turn_session *sess, pj_pool_t *pool, pj_uint32_t conn_id, const pj_sockaddr_t *peer_addr, unsigned addr_len)
Definition: turn_session.h:419
pj_status_t pj_turn_session_sendto(pj_turn_session *sess, const pj_uint8_t *pkt, unsigned pkt_len, const pj_sockaddr_t *peer_addr, unsigned addr_len)
pj_grp_lock_t * pj_turn_session_get_grp_lock(pj_turn_session *sess)
pj_status_t pj_turn_session_shutdown(pj_turn_session *sess)
pj_turn_tp_type peer_conn_type
Definition: turn_session.h:411
@ PJ_TURN_TP_TCP
Definition: turn_session.h:149
void * pj_turn_session_get_user_data(pj_turn_session *sess)
#define PJ_BEGIN_DECL
void * user_data
pj_turn_tp_type
Definition: turn_session.h:139
@ PJ_TURN_STATE_READY
Definition: turn_session.h:191
const pj_sockaddr_t * src_addr
Definition: turn_session.h:483
void pj_turn_session_set_log(pj_turn_session *sess, unsigned flags)
pj_status_t last_status
Definition: turn_session.h:429
void pj_sockaddr_t
int pj_status_t
pj_status_t pj_turn_session_set_user_data(pj_turn_session *sess, void *user_data)
@ PJ_TURN_STATE_DEALLOCATING
Definition: turn_session.h:197
void pj_turn_alloc_param_default(pj_turn_alloc_param *prm)
Definition: turn_session.h:373
@ PJ_TURN_STATE_RESOLVING
Definition: turn_session.h:173
void(* on_state)(pj_turn_session *sess, pj_turn_state_t old_state, pj_turn_state_t new_state)
Definition: turn_session.h:323
@ PJ_TURN_STATE_ALLOCATING
Definition: turn_session.h:185
pj_turn_tp_type conn_type
Definition: turn_session.h:434
pj_uint16_t length
Definition: turn_session.h:222
struct pj_grp_lock_t pj_grp_lock_t
@ PJ_TURN_TP_TLS
Definition: turn_session.h:156
unsigned int pj_uint32_t
int lifetime
Definition: turn_session.h:454
void(* on_rx_data)(pj_turn_session *sess, void *pkt, unsigned pkt_len, const pj_sockaddr_t *peer_addr, unsigned addr_len)
Definition: turn_session.h:308
int lifetime
Definition: turn_session.h:387
pj_status_t(* on_stun_send_pkt)(pj_turn_session *sess, const pj_uint8_t *pkt, unsigned pkt_len, const pj_sockaddr_t *dst_addr, unsigned addr_len)
Definition: turn_session.h:273
pj_status_t pj_turn_session_on_rx_pkt2(pj_turn_session *sess, pj_turn_session_on_rx_pkt_param *prm)
int bandwidth
Definition: turn_session.h:381
void(* on_channel_bound)(pj_turn_session *sess, const pj_sockaddr_t *peer_addr, unsigned addr_len, unsigned ch_num)
Definition: turn_session.h:291
pj_sockaddr server
Definition: turn_session.h:439
pj_sockaddr relay_addr
Definition: turn_session.h:449
Definition: stun_config.h:48
struct pj_dns_resolver pj_dns_resolver
pj_status_t pj_turn_session_set_software_name(pj_turn_session *sess, const pj_str_t *sw)
const char * pj_turn_state_name(pj_turn_state_t state)
@ PJ_TURN_TP_UDP
Definition: turn_session.h:144
unsigned char pj_uint8_t
pj_status_t(* on_send_pkt)(pj_turn_session *sess, const pj_uint8_t *pkt, unsigned pkt_len, const pj_sockaddr_t *dst_addr, unsigned addr_len)
Definition: turn_session.h:251
pj_status_t pj_turn_session_destroy(pj_turn_session *sess, pj_status_t last_err)
Definition: turn_session.h:232
pj_str_t info
pj_uint16_t ch_number
Definition: turn_session.h:221
pj_sockaddr mapped_addr
Definition: turn_session.h:444
pj_turn_state_t
Definition: turn_session.h:162
pj_status_t pj_turn_session_on_rx_pkt(pj_turn_session *sess, void *pkt, pj_size_t pkt_len, pj_size_t *parsed_len)
pj_turn_state_t state
Definition: turn_session.h:424
@ PJ_TURN_STATE_RESOLVED
Definition: turn_session.h:179
pj_status_t pj_turn_session_set_perm(pj_turn_session *sess, unsigned addr_cnt, const pj_sockaddr addr[], unsigned options)
pj_uint32_t flags
pj_status_t pj_turn_session_set_server(pj_turn_session *sess, const pj_str_t *domain, int default_port, pj_dns_resolver *resolver)
unsigned short pj_uint16_t
pj_status_t pj_turn_session_create(const pj_stun_config *cfg, const char *name, int af, pj_turn_tp_type conn_type, pj_grp_lock_t *grp_lock, const pj_turn_session_cb *cb, unsigned options, void *user_data, pj_turn_session **p_sess)
Definition: turn_session.h:219
#define PJ_END_DECL
pj_status_t pj_turn_session_alloc(pj_turn_session *sess, const pj_turn_alloc_param *param)
STUN session management for client/server.
struct pj_turn_session pj_turn_session
Definition: turn_session.h:131
pj_status_t pj_turn_session_get_info(pj_turn_session *sess, pj_turn_session_info *info)
unsigned src_addr_len
Definition: turn_session.h:488
void pj_turn_alloc_param_copy(pj_pool_t *pool, pj_turn_alloc_param *dst, const pj_turn_alloc_param *src)
void * pkt
Definition: turn_session.h:468
void(* on_connection_bind_status)(pj_turn_session *sess, pj_status_t status, pj_uint32_t conn_id, const pj_sockaddr_t *peer_addr, unsigned addr_len)
Definition: turn_session.h:358
@ PJ_TURN_STATE_DESTROYING
Definition: turn_session.h:208

 


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