BLOG | DOCUMENTATION | TRAC

Home --> Documentations --> PJNATH Reference

ice_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_ICE_SESSION_H__
21 #define __PJNATH_ICE_SESSION_H__
22 
27 #include <pjnath/types.h>
28 #include <pjnath/stun_session.h>
29 #include <pjnath/errno.h>
30 #include <pj/sock.h>
31 #include <pj/timer.h>
32 
34 
35 
128 
132 typedef enum pj_ice_cand_type
133 {
139 
146 
152 
158 
163 
165 
166 
168 typedef struct pj_ice_sess pj_ice_sess;
169 
171 typedef struct pj_ice_sess_check pj_ice_sess_check;
172 
174 typedef struct pj_ice_sess_cand pj_ice_sess_cand;
175 
183 typedef struct pj_ice_sess_comp
184 {
191 
198 
204 
206 
207 
211 typedef struct pj_ice_msg_data
212 {
214  unsigned transport_id;
215 
218 
220  union data {
222  struct request_data {
225  unsigned ckid;
228  } req;
229  } data;
230 
232 
233 
243 {
247  unsigned id;
248 
253 
261 
268 
273 
278 
286 
293 
304 
314 
320 
321 };
322 
323 
328 {
335 
342 
349 
356 
363 
365 
366 
375 {
380 
385 
390 
395 
400 
408 
414 
420 };
421 
422 
427 {
432 
438 
444 
446 
447 
453 {
458 
462  unsigned count;
463 
468 
472  unsigned foundation_cnt;
473 
477  pj_str_t foundation[PJ_ICE_MAX_CHECKS * 2];
478 
483 
484 };
485 
486 
491 typedef struct pj_ice_sess_cb
492 {
499  void (*on_valid_pair)(pj_ice_sess *ice);
500 
509  void (*on_ice_complete)(pj_ice_sess *ice, pj_status_t status);
510 
523  pj_status_t (*on_tx_pkt)(pj_ice_sess *ice, unsigned comp_id,
524  unsigned transport_id,
525  const void *pkt, pj_size_t size,
526  const pj_sockaddr_t *dst_addr,
527  unsigned dst_addr_len);
528 
542  void (*on_rx_data)(pj_ice_sess *ice, unsigned comp_id,
543  unsigned transport_id,
544  void *pkt, pj_size_t size,
545  const pj_sockaddr_t *src_addr,
546  unsigned src_addr_len);
548 
549 
553 typedef enum pj_ice_sess_role
554 {
559 
564 
569 
571 
572 
582 typedef struct pj_ice_rx_check
583 {
586  unsigned comp_id;
587  unsigned transport_id;
590  unsigned src_addr_len;
597 
598 
603 {
608 
620 
628 
630 
631 
637 typedef struct pj_ice_sess_options
638 {
644 
653 
667 
675 
677 
678 
689 {
690  char obj_name[PJ_MAX_OBJ_NAME];
693  void *user_data;
712  /* STUN credentials */
720  /* Components */
721  unsigned comp_cnt;
723  unsigned comp_ka;
725  /* Local candidates */
726  unsigned lcand_cnt;
728  unsigned lcand_paired;
731  /* Remote candidates */
732  unsigned rcand_cnt;
734  unsigned rcand_paired;
739 
740  /* List of eearly checks */
743  /* Checklist */
746  /* Valid list */
750  union {
751  char txt[128];
752  char errmsg[PJ_ERR_MSG_SIZE];
753  } tmp;
754 };
755 
756 
765 PJ_DECL(const char*) pj_ice_get_cand_type_name(pj_ice_cand_type type);
766 
767 
776 PJ_DECL(const char*) pj_ice_sess_role_name(pj_ice_sess_role role);
777 
778 
788 PJ_DECL(void) pj_ice_calc_foundation(pj_pool_t *pool,
789  pj_str_t *foundation,
790  pj_ice_cand_type type,
791  const pj_sockaddr *base_addr);
792 
799 
827  const char *name,
828  pj_ice_sess_role role,
829  unsigned comp_cnt,
830  const pj_ice_sess_cb *cb,
831  const pj_str_t *local_ufrag,
832  const pj_str_t *local_passwd,
833  pj_grp_lock_t *grp_lock,
834  pj_ice_sess **p_ice);
835 
846  pj_ice_sess_options *opt);
847 
862  const pj_ice_sess_options *opt);
863 
864 
882  pj_grp_lock_handler *handler);
883 
884 
895 
896 
909  pj_ice_sess_role new_role);
910 
911 
930  const pj_uint8_t prefs[4]);
931 
932 
933 
956  unsigned comp_id,
957  unsigned transport_id,
958  pj_ice_cand_type type,
959  pj_uint16_t local_pref,
960  const pj_str_t *foundation,
961  const pj_sockaddr_t *addr,
962  const pj_sockaddr_t *base_addr,
963  const pj_sockaddr_t *rel_addr,
964  int addr_len,
965  unsigned *p_cand_id);
966 
982  unsigned comp_id,
983  int *p_cand_id);
984 
1006 PJ_DECL(pj_status_t)
1008  const pj_str_t *rem_ufrag,
1009  const pj_str_t *rem_passwd,
1010  unsigned rem_cand_cnt,
1011  const pj_ice_sess_cand rem_cand[]);
1012 
1013 
1039 PJ_DECL(pj_status_t)
1041  const pj_str_t *rem_ufrag,
1042  const pj_str_t *rem_passwd,
1043  unsigned rem_cand_cnt,
1044  const pj_ice_sess_cand rem_cand[],
1045  pj_bool_t trickle_done);
1046 
1047 
1058 
1059 
1081  unsigned comp_id,
1082  const void *data,
1083  pj_size_t data_len);
1084 
1105  unsigned comp_id,
1106  unsigned transport_id,
1107  void *pkt,
1108  pj_size_t pkt_size,
1109  const pj_sockaddr_t *src_addr,
1110  int src_addr_len);
1111 
1112 
1113 
1120 
1121 
1122 #endif /* __PJNATH_ICE_SESSION_H__ */
1123 
pj_timestamp prio
Definition: ice_session.h:394
pj_bool_t aggressive
Definition: ice_session.h:643
Definition: ice_session.h:162
unsigned rcand_paired
Definition: ice_session.h:734
pj_status_t pj_ice_sess_set_prefs(pj_ice_sess *ice, const pj_uint8_t prefs[4])
pj_status_t err_code
Definition: ice_session.h:419
pj_uint16_t local_pref
Definition: ice_session.h:277
unsigned transport_id
Definition: ice_session.h:587
Definition: ice_session.h:563
unsigned transport_id
Definition: ice_session.h:214
pj_ice_sess_role
Definition: ice_session.h:553
pj_sockaddr base_addr
Definition: ice_session.h:313
pj_status_t pj_ice_sess_update_check_list(pj_ice_sess *ice, const pj_str_t *rem_ufrag, const pj_str_t *rem_passwd, unsigned rem_cand_cnt, const pj_ice_sess_cand rem_cand[], pj_bool_t trickle_done)
pj_ice_cand_type
Definition: ice_session.h:132
Definition: ice_session.h:151
int pj_bool_t
pj_ice_cand_type type
Definition: ice_session.h:252
pj_str_t rx_uname
Definition: ice_session.h:717
pj_status_t pj_ice_sess_destroy(pj_ice_sess *ice)
void pj_ice_calc_foundation(pj_pool_t *pool, pj_str_t *foundation, pj_ice_cand_type type, const pj_sockaddr *base_addr)
Definition: ice_session.h:637
Definition: ice_session.h:627
unsigned comp_cnt
Definition: ice_session.h:721
pj_str_t rx_ufrag
Definition: ice_session.h:716
Definition: ice_session.h:220
int controlled_agent_want_nom_timeout
Definition: ice_session.h:666
pj_bool_t use_candidate
Definition: ice_session.h:592
pj_bool_t valid_pair_found
Definition: ice_session.h:702
Definition: ice_session.h:242
pj_str_t tx_ufrag
Definition: ice_session.h:713
Definition: ice_session.h:157
pj_status_t pj_ice_sess_send_data(pj_ice_sess *ice, unsigned comp_id, const void *data, pj_size_t data_len)
pj_status_t pj_ice_sess_create_check_list(pj_ice_sess *ice, const pj_str_t *rem_ufrag, const pj_str_t *rem_passwd, unsigned rem_cand_cnt, const pj_ice_sess_cand rem_cand[])
pj_str_t tx_pass
Definition: ice_session.h:715
pj_status_t status
Definition: ice_session.h:260
pj_status_t pj_ice_sess_detach_grp_lock(pj_ice_sess *ice, pj_grp_lock_handler *handler)
Definition: ice_session.h:491
Definition: ice_session.h:431
Definition: ice_session.h:222
pj_ice_sess_role role
Definition: ice_session.h:695
Definition: ice_session.h:568
pj_stun_uint64_attr * role_attr
Definition: ice_session.h:594
pj_ice_sess_trickle
Definition: ice_session.h:602
Definition: ice_session.h:443
#define PJ_MAX_OBJ_NAME
pj_uint32_t priority
Definition: ice_session.h:593
Definition: ice_session.h:183
#define PJ_ICE_MAX_TURN
Definition: config.h:273
Definition: ice_session.h:362
#define PJ_ICE_MAX_CHECKS
Definition: config.h:333
void(* pj_grp_lock_handler)(void *member)
pj_ice_sess_check * valid_check
Definition: ice_session.h:190
pj_uint8_t comp_id
Definition: ice_session.h:267
pj_stun_tx_data * tdata
Definition: ice_session.h:407
pj_ice_sess_cb cb
Definition: ice_session.h:708
Definition: ice_session.h:619
pj_uint32_t prio
Definition: ice_session.h:292
int pj_status_t
pj_bool_t nominated
Definition: ice_session.h:413
Definition: ice_session.h:355
Definition: ice_session.h:138
pj_status_t pj_ice_sess_start_check(pj_ice_sess *ice)
pj_sockaddr rel_addr
Definition: ice_session.h:319
Definition: stun_config.h:48
void pj_sockaddr_t
Definition: ice_session.h:348
pj_status_t pj_ice_sess_set_options(pj_ice_sess *ice, const pj_ice_sess_options *opt)
struct pj_grp_lock_t pj_grp_lock_t
Definition: ice_session.h:145
pj_ice_sess_options opt
Definition: ice_session.h:696
Definition: stun_msg.h:614
unsigned int pj_uint32_t
pj_status_t pj_ice_sess_add_cand(pj_ice_sess *ice, unsigned comp_id, unsigned transport_id, pj_ice_cand_type type, pj_uint16_t local_pref, const pj_str_t *foundation, const pj_sockaddr_t *addr, const pj_sockaddr_t *base_addr, const pj_sockaddr_t *rel_addr, int addr_len, unsigned *p_cand_id)
unsigned ckid
Definition: ice_session.h:225
pj_ice_sess_cand * lcand
Definition: ice_session.h:379
pj_ice_sess * ice
Definition: ice_session.h:223
pj_ice_sess_cand * rcand
Definition: ice_session.h:227
unsigned count
Definition: ice_session.h:462
pj_ice_sess_checklist valid_list
Definition: ice_session.h:747
#define PJ_END_DECL
pj_str_t rx_pass
Definition: ice_session.h:718
pj_status_t pj_ice_sess_on_rx_pkt(pj_ice_sess *ice, unsigned comp_id, unsigned transport_id, void *pkt, pj_size_t pkt_size, const pj_sockaddr_t *src_addr, int src_addr_len)
pj_pool_t * pool
Definition: ice_session.h:692
pj_timer_entry timer_end_of_cand
Definition: ice_session.h:707
#define PJ_ICE_MAX_STUN
Definition: config.h:262
Definition: ice_session.h:558
#define PJ_DECL_LIST_MEMBER(type)
struct pj_stun_session pj_stun_session
Definition: stun_session.h:175
pj_timer_entry timer
Definition: ice_session.h:482
pj_bool_t has_req_data
Definition: ice_session.h:217
Definition: ice_session.h:334
Definition: ice_session.h:688
pj_timestamp tie_breaker
Definition: ice_session.h:697
pj_ice_sess_checklist_state
Definition: ice_session.h:426
int foundation_idx
Definition: ice_session.h:389
pj_ice_rx_check early_check
Definition: ice_session.h:741
STUN session management for client/server.
pj_status_t ice_status
Definition: ice_session.h:705
Definition: ice_session.h:211
Definition: ice_session.h:374
#define PJ_BEGIN_DECL
pj_stun_config stun_cfg
Definition: ice_session.h:710
pj_bool_t is_destroying
Definition: ice_session.h:701
pj_status_t pj_ice_sess_find_default_cand(pj_ice_sess *ice, unsigned comp_id, int *p_cand_id)
Definition: ice_session.h:452
Definition: ice_session.h:607
pj_ice_sess_checklist * clist
Definition: ice_session.h:224
pj_bool_t is_trickling
Definition: ice_session.h:703
pj_ice_sess_checklist clist
Definition: ice_session.h:744
unsigned foundation_cnt
Definition: ice_session.h:472
pj_ice_sess_trickle trickle
Definition: ice_session.h:674
pj_ice_sess_cand * lcand
Definition: ice_session.h:226
unsigned char pj_uint8_t
unsigned src_addr_len
Definition: ice_session.h:590
unsigned id
Definition: ice_session.h:247
const char * pj_ice_get_cand_type_name(pj_ice_cand_type type)
pj_sockaddr src_addr
Definition: ice_session.h:589
#define PJ_ICE_MAX_CAND
Definition: config.h:241
unsigned lcand_paired
Definition: ice_session.h:728
Definition: stun_session.h:336
pj_str_t tx_uname
Definition: ice_session.h:714
pj_ice_sess_check * nominated_check
Definition: ice_session.h:197
unsigned comp_id
Definition: ice_session.h:586
pj_status_t pj_ice_sess_get_options(pj_ice_sess *ice, pj_ice_sess_options *opt)
#define PJ_ERR_MSG_SIZE
void pj_ice_sess_options_default(pj_ice_sess_options *opt)
unsigned comp_ka
Definition: ice_session.h:723
unsigned nominated_check_delay
Definition: ice_session.h:652
pj_bool_t is_complete
Definition: ice_session.h:700
pj_stun_session * stun_sess
Definition: ice_session.h:203
pj_bool_t is_nominating
Definition: ice_session.h:699
pj_status_t pj_ice_sess_change_role(pj_ice_sess *ice, pj_ice_sess_role new_role)
const char * pj_ice_sess_role_name(pj_ice_sess_role role)
void * user_data
Definition: ice_session.h:693
pj_status_t pj_ice_sess_create(pj_stun_config *stun_cfg, const char *name, pj_ice_sess_role role, unsigned comp_cnt, const pj_ice_sess_cb *cb, const pj_str_t *local_ufrag, const pj_str_t *local_passwd, pj_grp_lock_t *grp_lock, pj_ice_sess **p_ice)
pj_ice_sess_checklist_state state
Definition: ice_session.h:457
Definition: ice_session.h:437
pj_grp_lock_t * grp_lock
Definition: ice_session.h:694
unsigned rcand_cnt
Definition: ice_session.h:732
#define PJ_ICE_MAX_COMP
Definition: config.h:289
pj_str_t foundation
Definition: ice_session.h:285
unsigned lcand_cnt
Definition: ice_session.h:726
pj_ice_sess_check_state state
Definition: ice_session.h:399
unsigned short pj_uint16_t
pj_uint8_t * prefs
Definition: ice_session.h:698
pj_ice_sess_cand * rcand
Definition: ice_session.h:384
pj_timer_entry timer
Definition: ice_session.h:706
pj_ice_sess_check_state
Definition: ice_session.h:327
Definition: ice_session.h:341
size_t pj_size_t
pj_sockaddr addr
Definition: ice_session.h:303
pj_uint8_t transport_id
Definition: ice_session.h:272
Definition: ice_session.h:582

 


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