Home --> Documentations --> PJNATH Reference

ice_session.h
Go to the documentation of this file.
1 /* $Id: ice_session.h 5339 2016-06-08 03:17:45Z nanang $ */
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 
173 
181 typedef struct pj_ice_sess_comp
182 {
189 
196 
202 
204 
205 
209 typedef struct pj_ice_msg_data
210 {
212  unsigned transport_id;
213 
216 
218  union data {
220  struct request_data {
223  unsigned ckid;
224  } req;
225  } data;
226 
228 
229 
238 typedef struct pj_ice_sess_cand
239 {
244 
252 
259 
264 
269 
277 
284 
295 
305 
311 
313 
314 
319 {
326 
333 
340 
347 
354 
356 
357 
366 {
371 
376 
381 
386 
394 
400 
406 };
407 
408 
413 {
418 
424 
430 
432 
433 
439 {
444 
448  unsigned count;
449 
454 
459 
460 };
461 
462 
467 typedef struct pj_ice_sess_cb
468 {
477  void (*on_ice_complete)(pj_ice_sess *ice, pj_status_t status);
478 
491  pj_status_t (*on_tx_pkt)(pj_ice_sess *ice, unsigned comp_id,
492  unsigned transport_id,
493  const void *pkt, pj_size_t size,
494  const pj_sockaddr_t *dst_addr,
495  unsigned dst_addr_len);
496 
510  void (*on_rx_data)(pj_ice_sess *ice, unsigned comp_id,
511  unsigned transport_id,
512  void *pkt, pj_size_t size,
513  const pj_sockaddr_t *src_addr,
514  unsigned src_addr_len);
516 
517 
521 typedef enum pj_ice_sess_role
522 {
527 
532 
537 
539 
540 
550 typedef struct pj_ice_rx_check
551 {
554  unsigned comp_id;
555  unsigned transport_id;
558  unsigned src_addr_len;
565 
566 
572 typedef struct pj_ice_sess_options
573 {
578 
587 
601 
603 
604 
615 {
619  void *user_data;
634  /* STUN credentials */
642  /* Components */
643  unsigned comp_cnt;
645  unsigned comp_ka;
647  /* Local candidates */
648  unsigned lcand_cnt;
651  /* Remote candidates */
652  unsigned rcand_cnt;
657 
658  /* List of eearly checks */
661  /* Checklist */
664  /* Valid list */
668  union {
669  char txt[128];
670  char errmsg[PJ_ERR_MSG_SIZE];
671  } tmp;
672 };
673 
674 
683 PJ_DECL(const char*) pj_ice_get_cand_type_name(pj_ice_cand_type type);
684 
685 
694 PJ_DECL(const char*) pj_ice_sess_role_name(pj_ice_sess_role role);
695 
696 
706 PJ_DECL(void) pj_ice_calc_foundation(pj_pool_t *pool,
707  pj_str_t *foundation,
708  pj_ice_cand_type type,
709  const pj_sockaddr *base_addr);
710 
717 
745  const char *name,
746  pj_ice_sess_role role,
747  unsigned comp_cnt,
748  const pj_ice_sess_cb *cb,
749  const pj_str_t *local_ufrag,
750  const pj_str_t *local_passwd,
751  pj_grp_lock_t *grp_lock,
752  pj_ice_sess **p_ice);
753 
764  pj_ice_sess_options *opt);
765 
780  const pj_ice_sess_options *opt);
781 
792 
793 
806  pj_ice_sess_role new_role);
807 
808 
827  const pj_uint8_t prefs[4]);
828 
829 
830 
853  unsigned comp_id,
854  unsigned transport_id,
855  pj_ice_cand_type type,
856  pj_uint16_t local_pref,
857  const pj_str_t *foundation,
858  const pj_sockaddr_t *addr,
859  const pj_sockaddr_t *base_addr,
860  const pj_sockaddr_t *rel_addr,
861  int addr_len,
862  unsigned *p_cand_id);
863 
879  unsigned comp_id,
880  int *p_cand_id);
881 
903 PJ_DECL(pj_status_t)
905  const pj_str_t *rem_ufrag,
906  const pj_str_t *rem_passwd,
907  unsigned rem_cand_cnt,
908  const pj_ice_sess_cand rem_cand[]);
909 
920 
921 
940  unsigned comp_id,
941  const void *data,
942  pj_size_t data_len);
943 
964  unsigned comp_id,
965  unsigned transport_id,
966  void *pkt,
967  pj_size_t pkt_size,
968  const pj_sockaddr_t *src_addr,
969  int src_addr_len);
970 
971 
972 
978 PJ_END_DECL
979 
980 
981 #endif /* __PJNATH_ICE_SESSION_H__ */
982 
pj_timestamp prio
Definition: ice_session.h:380
pj_bool_t aggressive
Definition: ice_session.h:577
Definition: ice_session.h:162
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:405
pj_uint16_t local_pref
Definition: ice_session.h:268
unsigned transport_id
Definition: ice_session.h:555
Definition: ice_session.h:531
unsigned transport_id
Definition: ice_session.h:212
pj_ice_sess_role
Definition: ice_session.h:521
pj_ice_msg_data tp_data[PJ_ICE_MAX_STUN+PJ_ICE_MAX_TURN]
Definition: ice_session.h:656
pj_sockaddr base_addr
Definition: ice_session.h:304
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:243
pj_ice_sess_cand lcand[PJ_ICE_MAX_CAND]
Definition: ice_session.h:649
pj_str_t rx_uname
Definition: ice_session.h:639
pj_status_t pj_ice_sess_destroy(pj_ice_sess *ice)
pj_ice_sess_check checks[PJ_ICE_MAX_CHECKS]
Definition: ice_session.h:453
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:572
unsigned comp_cnt
Definition: ice_session.h:643
pj_str_t rx_ufrag
Definition: ice_session.h:638
Definition: ice_session.h:218
int controlled_agent_want_nom_timeout
Definition: ice_session.h:600
pj_bool_t use_candidate
Definition: ice_session.h:560
Definition: ice_session.h:238
pj_str_t tx_ufrag
Definition: ice_session.h:635
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:637
pj_status_t status
Definition: ice_session.h:251
Definition: ice_session.h:467
Definition: ice_session.h:417
Definition: ice_session.h:220
pj_ice_sess_role role
Definition: ice_session.h:621
Definition: ice_session.h:536
pj_stun_uint64_attr * role_attr
Definition: ice_session.h:562
Definition: ice_session.h:429
#define PJ_MAX_OBJ_NAME
pj_uint32_t priority
Definition: ice_session.h:561
Definition: ice_session.h:181
#define PJ_ICE_MAX_TURN
Definition: config.h:266
Definition: ice_session.h:353
#define PJ_ICE_MAX_CHECKS
Definition: config.h:326
pj_ice_sess_cand rcand[PJ_ICE_MAX_CAND]
Definition: ice_session.h:653
pj_ice_sess_check * valid_check
Definition: ice_session.h:188
pj_uint8_t comp_id
Definition: ice_session.h:258
pj_stun_tx_data * tdata
Definition: ice_session.h:393
pj_ice_sess_cb cb
Definition: ice_session.h:630
pj_uint32_t prio
Definition: ice_session.h:283
int pj_status_t
pj_bool_t nominated
Definition: ice_session.h:399
Definition: ice_session.h:346
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:310
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:510
Definition: stun_config.h:48
void pj_sockaddr_t
Definition: ice_session.h:339
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:622
Definition: stun_msg.h:583
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:223
pj_ice_sess_cand * lcand
Definition: ice_session.h:370
pj_ice_sess * ice
Definition: ice_session.h:221
unsigned count
Definition: ice_session.h:448
pj_ice_sess_checklist valid_list
Definition: ice_session.h:665
pj_str_t rx_pass
Definition: ice_session.h:640
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:618
#define PJ_ICE_MAX_STUN
Definition: config.h:255
Definition: ice_session.h:526
PJ_DECL_LIST_MEMBER(struct pj_ice_rx_check)
struct pj_stun_session pj_stun_session
Definition: stun_session.h:175
pj_timer_entry timer
Definition: ice_session.h:458
pj_bool_t has_req_data
Definition: ice_session.h:215
Definition: ice_session.h:325
Definition: ice_session.h:614
pj_timestamp tie_breaker
Definition: ice_session.h:623
pj_ice_sess_checklist_state
Definition: ice_session.h:412
pj_ice_rx_check early_check
Definition: ice_session.h:659
STUN session management for client/server.
pj_status_t ice_status
Definition: ice_session.h:628
Definition: ice_session.h:209
pj_ice_sess_comp comp[PJ_ICE_MAX_COMP]
Definition: ice_session.h:644
Definition: ice_session.h:365
#define PJ_BEGIN_DECL
pj_stun_config stun_cfg
Definition: ice_session.h:632
pj_bool_t is_destroying
Definition: ice_session.h:627
pj_status_t pj_ice_sess_find_default_cand(pj_ice_sess *ice, unsigned comp_id, int *p_cand_id)
Definition: ice_session.h:438
pj_ice_sess_checklist * clist
Definition: ice_session.h:222
pj_ice_sess_checklist clist
Definition: ice_session.h:662
unsigned char pj_uint8_t
unsigned src_addr_len
Definition: ice_session.h:558
const char * pj_ice_get_cand_type_name(pj_ice_cand_type type)
pj_sockaddr src_addr
Definition: ice_session.h:557
#define PJ_ICE_MAX_CAND
Definition: config.h:234
Definition: stun_session.h:336
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:491
pj_str_t tx_uname
Definition: ice_session.h:636
pj_ice_sess_check * nominated_check
Definition: ice_session.h:195
unsigned comp_id
Definition: ice_session.h:554
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:645
unsigned nominated_check_delay
Definition: ice_session.h:586
pj_bool_t is_complete
Definition: ice_session.h:626
pj_stun_session * stun_sess
Definition: ice_session.h:201
pj_bool_t is_nominating
Definition: ice_session.h:625
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:619
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)
union pj_ice_sess::@0 tmp
pj_ice_sess_checklist_state state
Definition: ice_session.h:443
Definition: ice_session.h:423
pj_grp_lock_t * grp_lock
Definition: ice_session.h:620
unsigned rcand_cnt
Definition: ice_session.h:652
#define PJ_ICE_MAX_COMP
Definition: config.h:282
pj_str_t foundation
Definition: ice_session.h:276
unsigned lcand_cnt
Definition: ice_session.h:648
pj_ice_sess_check_state state
Definition: ice_session.h:385
unsigned short pj_uint16_t
pj_uint8_t * prefs
Definition: ice_session.h:624
pj_ice_sess_cand * rcand
Definition: ice_session.h:375
pj_timer_entry timer
Definition: ice_session.h:629
pj_ice_sess_check_state
Definition: ice_session.h:318
void(* on_ice_complete)(pj_ice_sess *ice, pj_status_t status)
Definition: ice_session.h:477
Definition: ice_session.h:332
size_t pj_size_t
pj_sockaddr addr
Definition: ice_session.h:294
pj_uint8_t transport_id
Definition: ice_session.h:263
char obj_name[PJ_MAX_OBJ_NAME]
Definition: ice_session.h:616
Definition: ice_session.h:550

 


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