WARNING: The online documentation has moved to https://docs.pjsip.org.

Visit the new documentation at https://docs.pjsip.org:

BLOG | DOCUMENTATION | GITHUB

Home --> Documentations --> PJNATH Reference

ice_session.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
3 * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19#ifndef __PJNATH_ICE_SESSION_H__
20#define __PJNATH_ICE_SESSION_H__
21
26#include <pjnath/types.h>
27#include <pjnath/stun_session.h>
28#include <pjnath/errno.h>
29#include <pj/sock.h>
30#include <pj/timer.h>
31
33
34
127
132{
138
145
151
157
162
164
165
167typedef struct pj_ice_sess pj_ice_sess;
168
171
174
182typedef struct pj_ice_sess_comp
183{
190
197
203
205
206
210typedef struct pj_ice_msg_data
211{
213 unsigned transport_id;
214
217
219 union data {
224 unsigned ckid;
227 } req;
231
232
242{
246 unsigned id;
247
252
260
267
272
277
285
292
303
313
319
320};
321
322
327{
334
341
348
355
362
364
365
374{
379
384
389
394
399
407
413
419};
420
421
426{
431
437
443
445
446
452{
457
461 unsigned count;
462
467
472
477
482
483};
484
485
490typedef struct pj_ice_sess_cb
491{
499
509
522 pj_status_t (*on_tx_pkt)(pj_ice_sess *ice, unsigned comp_id,
523 unsigned transport_id,
524 const void *pkt, pj_size_t size,
525 const pj_sockaddr_t *dst_addr,
526 unsigned dst_addr_len);
527
541 void (*on_rx_data)(pj_ice_sess *ice, unsigned comp_id,
542 unsigned transport_id,
543 void *pkt, pj_size_t size,
544 const pj_sockaddr_t *src_addr,
545 unsigned src_addr_len);
547
548
553{
558
563
568
570
571
581typedef struct pj_ice_rx_check
582{
585 unsigned comp_id;
586 unsigned transport_id;
589 unsigned src_addr_len;
596
597
602{
607
619
627
629
630
637{
643
652
666
674
676
677
688{
692 void *user_data;
711 /* STUN credentials */
719 /* Components */
720 unsigned comp_cnt;
722 unsigned comp_ka;
724 /* Local candidates */
725 unsigned lcand_cnt;
727 unsigned lcand_paired;
730 /* Remote candidates */
731 unsigned rcand_cnt;
733 unsigned rcand_paired;
738
739 /* List of eearly checks */
742 /* Checklist */
745 /* Valid list */
749 union {
750 char txt[128];
751 char errmsg[PJ_ERR_MSG_SIZE];
753};
754
755
765
766
775PJ_DECL(const char*) pj_ice_sess_role_name(pj_ice_sess_role role);
776
777
788 pj_str_t *foundation,
789 pj_ice_cand_type type,
790 const pj_sockaddr *base_addr);
791
798
826 const char *name,
827 pj_ice_sess_role role,
828 unsigned comp_cnt,
829 const pj_ice_sess_cb *cb,
830 const pj_str_t *local_ufrag,
831 const pj_str_t *local_passwd,
832 pj_grp_lock_t *grp_lock,
833 pj_ice_sess **p_ice);
834
846
861 const pj_ice_sess_options *opt);
862
863
881 pj_grp_lock_handler *handler);
882
883
894
895
908 pj_ice_sess_role new_role);
909
910
929 const pj_uint8_t prefs[4]);
930
931
932
955 unsigned comp_id,
956 unsigned transport_id,
957 pj_ice_cand_type type,
958 pj_uint16_t local_pref,
959 const pj_str_t *foundation,
960 const pj_sockaddr_t *addr,
961 const pj_sockaddr_t *base_addr,
962 const pj_sockaddr_t *rel_addr,
963 int addr_len,
964 unsigned *p_cand_id);
965
981 unsigned comp_id,
982 int *p_cand_id);
983
1005PJ_DECL(pj_status_t)
1007 const pj_str_t *rem_ufrag,
1008 const pj_str_t *rem_passwd,
1009 unsigned rem_cand_cnt,
1010 const pj_ice_sess_cand rem_cand[]);
1011
1012
1038PJ_DECL(pj_status_t)
1040 const pj_str_t *rem_ufrag,
1041 const pj_str_t *rem_passwd,
1042 unsigned rem_cand_cnt,
1043 const pj_ice_sess_cand rem_cand[],
1044 pj_bool_t trickle_done);
1045
1046
1057
1058
1080 unsigned comp_id,
1081 const void *data,
1082 pj_size_t data_len);
1083
1104 unsigned comp_id,
1105 unsigned transport_id,
1106 void *pkt,
1107 pj_size_t pkt_size,
1108 const pj_sockaddr_t *src_addr,
1109 int src_addr_len);
1110
1111
1112
1118PJ_END_DECL
1119
1120
1121#endif /* __PJNATH_ICE_SESSION_H__ */
1122
PJNATH specific error codes.
#define PJ_ICE_MAX_TURN
Definition: config.h:272
#define PJ_ICE_MAX_CHECKS
Definition: config.h:332
#define PJ_ICE_MAX_CAND
Definition: config.h:240
#define PJ_ICE_MAX_STUN
Definition: config.h:261
#define PJ_ICE_MAX_COMP
Definition: config.h:288
pj_status_t pj_ice_sess_detach_grp_lock(pj_ice_sess *ice, pj_grp_lock_handler *handler)
pj_ice_sess_trickle
Definition: ice_session.h:602
pj_status_t pj_ice_sess_set_options(pj_ice_sess *ice, const pj_ice_sess_options *opt)
pj_ice_sess_checklist_state
Definition: ice_session.h:426
pj_ice_sess_role
Definition: ice_session.h:553
const char * pj_ice_get_cand_type_name(pj_ice_cand_type type)
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)
void pj_ice_sess_options_default(pj_ice_sess_options *opt)
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_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_status_t pj_ice_sess_set_prefs(pj_ice_sess *ice, const pj_uint8_t prefs[4])
pj_status_t pj_ice_sess_change_role(pj_ice_sess *ice, pj_ice_sess_role new_role)
pj_ice_sess_check_state
Definition: ice_session.h:327
pj_status_t pj_ice_sess_start_check(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)
pj_status_t pj_ice_sess_destroy(pj_ice_sess *ice)
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)
pj_status_t pj_ice_sess_find_default_cand(pj_ice_sess *ice, unsigned comp_id, int *p_cand_id)
pj_ice_cand_type
Definition: ice_session.h:132
pj_status_t pj_ice_sess_get_options(pj_ice_sess *ice, pj_ice_sess_options *opt)
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[])
const char * pj_ice_sess_role_name(pj_ice_sess_role role)
pj_status_t pj_ice_sess_send_data(pj_ice_sess *ice, unsigned comp_id, const void *data, pj_size_t data_len)
@ PJ_ICE_SESS_TRICKLE_FULL
Definition: ice_session.h:626
@ PJ_ICE_SESS_TRICKLE_DISABLED
Definition: ice_session.h:606
@ PJ_ICE_SESS_TRICKLE_HALF
Definition: ice_session.h:618
@ PJ_ICE_SESS_CHECKLIST_ST_COMPLETED
Definition: ice_session.h:442
@ PJ_ICE_SESS_CHECKLIST_ST_IDLE
Definition: ice_session.h:430
@ PJ_ICE_SESS_CHECKLIST_ST_RUNNING
Definition: ice_session.h:436
@ PJ_ICE_SESS_ROLE_UNKNOWN
Definition: ice_session.h:557
@ PJ_ICE_SESS_ROLE_CONTROLLING
Definition: ice_session.h:567
@ PJ_ICE_SESS_ROLE_CONTROLLED
Definition: ice_session.h:562
@ PJ_ICE_SESS_CHECK_STATE_IN_PROGRESS
Definition: ice_session.h:347
@ PJ_ICE_SESS_CHECK_STATE_WAITING
Definition: ice_session.h:340
@ PJ_ICE_SESS_CHECK_STATE_FAILED
Definition: ice_session.h:361
@ PJ_ICE_SESS_CHECK_STATE_FROZEN
Definition: ice_session.h:333
@ PJ_ICE_SESS_CHECK_STATE_SUCCEEDED
Definition: ice_session.h:354
@ PJ_ICE_CAND_TYPE_MAX
Definition: ice_session.h:161
@ PJ_ICE_CAND_TYPE_RELAYED
Definition: ice_session.h:156
@ PJ_ICE_CAND_TYPE_PRFLX
Definition: ice_session.h:150
@ PJ_ICE_CAND_TYPE_HOST
Definition: ice_session.h:137
@ PJ_ICE_CAND_TYPE_SRFLX
Definition: ice_session.h:144
struct pj_stun_session pj_stun_session
Definition: stun_session.h:174
unsigned char pj_uint8_t
int pj_bool_t
unsigned short pj_uint16_t
#define PJ_MAX_OBJ_NAME
size_t pj_size_t
void pj_sockaddr_t
int pj_status_t
struct pj_grp_lock_t pj_grp_lock_t
unsigned int pj_uint32_t
void(* pj_grp_lock_handler)(void *member)
#define PJ_BEGIN_DECL
#define PJ_ERR_MSG_SIZE
Definition: ice_session.h:221
pj_ice_sess_checklist * clist
Definition: ice_session.h:223
pj_ice_sess_cand * rcand
Definition: ice_session.h:226
pj_ice_sess * ice
Definition: ice_session.h:222
unsigned ckid
Definition: ice_session.h:224
pj_ice_sess_cand * lcand
Definition: ice_session.h:225
Definition: ice_session.h:211
unsigned transport_id
Definition: ice_session.h:213
union pj_ice_msg_data::data data
pj_bool_t has_req_data
Definition: ice_session.h:216
Definition: ice_session.h:582
unsigned transport_id
Definition: ice_session.h:586
unsigned src_addr_len
Definition: ice_session.h:589
pj_bool_t use_candidate
Definition: ice_session.h:591
pj_stun_uint64_attr * role_attr
Definition: ice_session.h:593
unsigned comp_id
Definition: ice_session.h:585
PJ_DECL_LIST_MEMBER(struct pj_ice_rx_check)
pj_sockaddr src_addr
Definition: ice_session.h:588
pj_uint32_t priority
Definition: ice_session.h:592
Definition: ice_session.h:242
pj_sockaddr addr
Definition: ice_session.h:302
pj_sockaddr base_addr
Definition: ice_session.h:312
pj_status_t status
Definition: ice_session.h:259
pj_str_t foundation
Definition: ice_session.h:284
unsigned id
Definition: ice_session.h:246
pj_uint16_t local_pref
Definition: ice_session.h:276
pj_sockaddr rel_addr
Definition: ice_session.h:318
pj_ice_cand_type type
Definition: ice_session.h:251
pj_uint32_t prio
Definition: ice_session.h:291
pj_uint8_t transport_id
Definition: ice_session.h:271
pj_uint8_t comp_id
Definition: ice_session.h:266
Definition: ice_session.h:491
pj_status_t(* on_tx_pkt)(pj_ice_sess *ice, unsigned comp_id, unsigned transport_id, const void *pkt, pj_size_t size, const pj_sockaddr_t *dst_addr, unsigned dst_addr_len)
Definition: ice_session.h:522
void(* on_rx_data)(pj_ice_sess *ice, unsigned comp_id, unsigned transport_id, void *pkt, pj_size_t size, const pj_sockaddr_t *src_addr, unsigned src_addr_len)
Definition: ice_session.h:541
void(* on_ice_complete)(pj_ice_sess *ice, pj_status_t status)
Definition: ice_session.h:508
void(* on_valid_pair)(pj_ice_sess *ice)
Definition: ice_session.h:498
Definition: ice_session.h:374
pj_status_t err_code
Definition: ice_session.h:418
pj_timestamp prio
Definition: ice_session.h:393
pj_ice_sess_check_state state
Definition: ice_session.h:398
int foundation_idx
Definition: ice_session.h:388
pj_bool_t nominated
Definition: ice_session.h:412
pj_ice_sess_cand * lcand
Definition: ice_session.h:378
pj_stun_tx_data * tdata
Definition: ice_session.h:406
pj_ice_sess_cand * rcand
Definition: ice_session.h:383
Definition: ice_session.h:452
pj_ice_sess_check checks[PJ_ICE_MAX_CHECKS]
Definition: ice_session.h:466
pj_timer_entry timer
Definition: ice_session.h:481
unsigned count
Definition: ice_session.h:461
unsigned foundation_cnt
Definition: ice_session.h:471
pj_str_t foundation[PJ_ICE_MAX_CHECKS *2]
Definition: ice_session.h:476
pj_ice_sess_checklist_state state
Definition: ice_session.h:456
Definition: ice_session.h:183
pj_ice_sess_check * valid_check
Definition: ice_session.h:189
pj_stun_session * stun_sess
Definition: ice_session.h:202
pj_ice_sess_check * nominated_check
Definition: ice_session.h:196
Definition: ice_session.h:637
int controlled_agent_want_nom_timeout
Definition: ice_session.h:665
unsigned nominated_check_delay
Definition: ice_session.h:651
pj_ice_sess_trickle trickle
Definition: ice_session.h:673
pj_bool_t aggressive
Definition: ice_session.h:642
Definition: ice_session.h:688
pj_str_t rx_ufrag
Definition: ice_session.h:715
pj_timestamp tie_breaker
Definition: ice_session.h:696
pj_grp_lock_t * grp_lock
Definition: ice_session.h:693
pj_str_t rx_pass
Definition: ice_session.h:717
unsigned comp_cnt
Definition: ice_session.h:720
unsigned lcand_paired
Definition: ice_session.h:727
pj_bool_t is_complete
Definition: ice_session.h:699
pj_uint8_t * prefs
Definition: ice_session.h:697
pj_bool_t valid_pair_found
Definition: ice_session.h:701
void * user_data
Definition: ice_session.h:692
pj_ice_sess_checklist valid_list
Definition: ice_session.h:746
pj_bool_t is_destroying
Definition: ice_session.h:700
pj_ice_rx_check early_check
Definition: ice_session.h:740
pj_ice_sess_checklist clist
Definition: ice_session.h:743
unsigned comp_ka
Definition: ice_session.h:722
pj_ice_sess_cb cb
Definition: ice_session.h:707
pj_str_t tx_pass
Definition: ice_session.h:714
pj_timer_entry timer_end_of_cand
Definition: ice_session.h:706
pj_ice_msg_data tp_data[PJ_ICE_MAX_STUN+PJ_ICE_MAX_TURN]
Definition: ice_session.h:737
pj_ice_sess_role role
Definition: ice_session.h:694
pj_bool_t is_nominating
Definition: ice_session.h:698
union pj_ice_sess::@0 tmp
pj_bool_t is_trickling
Definition: ice_session.h:702
pj_pool_t * pool
Definition: ice_session.h:691
pj_ice_sess_cand rcand[PJ_ICE_MAX_CAND]
Definition: ice_session.h:732
pj_ice_sess_cand lcand[PJ_ICE_MAX_CAND]
Definition: ice_session.h:726
pj_status_t ice_status
Definition: ice_session.h:704
pj_str_t tx_ufrag
Definition: ice_session.h:712
pj_timer_entry timer
Definition: ice_session.h:705
unsigned lcand_cnt
Definition: ice_session.h:725
pj_ice_sess_options opt
Definition: ice_session.h:695
unsigned rcand_cnt
Definition: ice_session.h:731
pj_str_t rx_uname
Definition: ice_session.h:716
pj_ice_sess_comp comp[PJ_ICE_MAX_COMP]
Definition: ice_session.h:721
pj_str_t tx_uname
Definition: ice_session.h:713
pj_stun_config stun_cfg
Definition: ice_session.h:709
char obj_name[PJ_MAX_OBJ_NAME]
Definition: ice_session.h:689
unsigned rcand_paired
Definition: ice_session.h:733
Definition: stun_config.h:48
Definition: stun_session.h:336
Definition: stun_msg.h:614
STUN session management for client/server.
PJNATH types.
Definition: ice_session.h:219
struct pj_ice_msg_data::data::request_data req

 


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