00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __PJNATH_ICE_STRANS_H__
00021 #define __PJNATH_ICE_STRANS_H__
00022
00023
00028 #include <pjnath/ice_session.h>
00029 #include <pjnath/stun_sock.h>
00030 #include <pjnath/turn_sock.h>
00031 #include <pjlib-util/resolver.h>
00032 #include <pj/ioqueue.h>
00033 #include <pj/timer.h>
00034
00035
00036 PJ_BEGIN_DECL
00037
00038
00117 typedef struct pj_ice_strans pj_ice_strans;
00118
00120 typedef enum pj_ice_strans_op
00121 {
00123 PJ_ICE_STRANS_OP_INIT,
00124
00126 PJ_ICE_STRANS_OP_NEGOTIATION,
00127
00131 PJ_ICE_STRANS_OP_KEEP_ALIVE
00132
00133 } pj_ice_strans_op;
00134
00139 typedef struct pj_ice_strans_cb
00140 {
00153 void (*on_rx_data)(pj_ice_strans *ice_st,
00154 unsigned comp_id,
00155 void *pkt, pj_size_t size,
00156 const pj_sockaddr_t *src_addr,
00157 unsigned src_addr_len);
00158
00166 void (*on_ice_complete)(pj_ice_strans *ice_st,
00167 pj_ice_strans_op op,
00168 pj_status_t status);
00169
00170 } pj_ice_strans_cb;
00171
00172
00178 typedef struct pj_ice_strans_cfg
00179 {
00184 int af;
00185
00194 pj_stun_config stun_cfg;
00195
00202 pj_dns_resolver *resolver;
00203
00209 pj_ice_sess_options opt;
00210
00216 struct {
00221 pj_stun_sock_cfg cfg;
00222
00229 unsigned max_host_cands;
00230
00236 pj_bool_t loop_addr;
00237
00258 pj_str_t server;
00259
00270 pj_uint16_t port;
00271
00278 pj_bool_t ignore_stun_error;
00279
00280 } stun;
00281
00285 struct {
00291 pj_turn_sock_cfg cfg;
00292
00310 pj_str_t server;
00311
00322 pj_uint16_t port;
00323
00329 pj_turn_tp_type conn_type;
00330
00337 pj_stun_auth_cred auth_cred;
00338
00343 pj_turn_alloc_param alloc_param;
00344
00345 } turn;
00346
00353 struct {
00362 pj_qos_type qos_type;
00363
00371 pj_qos_params qos_params;
00372
00373 } comp[PJ_ICE_MAX_COMP];
00374
00375 } pj_ice_strans_cfg;
00376
00377
00381 typedef enum pj_ice_strans_state
00382 {
00386 PJ_ICE_STRANS_STATE_NULL,
00387
00391 PJ_ICE_STRANS_STATE_INIT,
00392
00397 PJ_ICE_STRANS_STATE_READY,
00398
00402 PJ_ICE_STRANS_STATE_SESS_READY,
00403
00407 PJ_ICE_STRANS_STATE_NEGO,
00408
00413 PJ_ICE_STRANS_STATE_RUNNING,
00414
00418 PJ_ICE_STRANS_STATE_FAILED
00419
00420 } pj_ice_strans_state;
00421
00422
00428 PJ_DECL(void) pj_ice_strans_cfg_default(pj_ice_strans_cfg *cfg);
00429
00430
00438 PJ_DECL(void) pj_ice_strans_cfg_copy(pj_pool_t *pool,
00439 pj_ice_strans_cfg *dst,
00440 const pj_ice_strans_cfg *src);
00441
00442
00459 PJ_DECL(pj_status_t) pj_ice_strans_create(const char *name,
00460 const pj_ice_strans_cfg *cfg,
00461 unsigned comp_cnt,
00462 void *user_data,
00463 const pj_ice_strans_cb *cb,
00464 pj_ice_strans **p_ice_st);
00465
00473 PJ_DECL(pj_ice_strans_state) pj_ice_strans_get_state(pj_ice_strans *ice_st);
00474
00475
00483 PJ_DECL(const char*) pj_ice_strans_state_name(pj_ice_strans_state state);
00484
00485
00495 PJ_DECL(pj_status_t) pj_ice_strans_destroy(pj_ice_strans *ice_st);
00496
00497
00505 PJ_DECL(void*) pj_ice_strans_get_user_data(pj_ice_strans *ice_st);
00506
00507
00517 PJ_DECL(pj_status_t) pj_ice_strans_get_options(pj_ice_strans *ice_st,
00518 pj_ice_sess_options *opt);
00519
00530 PJ_DECL(pj_status_t) pj_ice_strans_set_options(pj_ice_strans *ice_st,
00531 const pj_ice_sess_options *opt);
00532
00533
00551 PJ_DECL(pj_status_t) pj_ice_strans_init_ice(pj_ice_strans *ice_st,
00552 pj_ice_sess_role role,
00553 const pj_str_t *local_ufrag,
00554 const pj_str_t *local_passwd);
00555
00565 PJ_DECL(pj_bool_t) pj_ice_strans_has_sess(pj_ice_strans *ice_st);
00566
00567
00576 PJ_DECL(pj_bool_t) pj_ice_strans_sess_is_running(pj_ice_strans *ice_st);
00577
00578
00587 PJ_DECL(pj_bool_t) pj_ice_strans_sess_is_complete(pj_ice_strans *ice_st);
00588
00589
00601 PJ_DECL(unsigned) pj_ice_strans_get_running_comp_cnt(pj_ice_strans *ice_st);
00602
00603
00630 PJ_DECL(pj_status_t) pj_ice_strans_get_ufrag_pwd(pj_ice_strans *ice_st,
00631 pj_str_t *loc_ufrag,
00632 pj_str_t *loc_pwd,
00633 pj_str_t *rem_ufrag,
00634 pj_str_t *rem_pwd);
00635
00636
00645 PJ_DECL(unsigned) pj_ice_strans_get_cands_count(pj_ice_strans *ice_st,
00646 unsigned comp_id);
00647
00661 PJ_DECL(pj_status_t) pj_ice_strans_enum_cands(pj_ice_strans *ice_st,
00662 unsigned comp_id,
00663 unsigned *count,
00664 pj_ice_sess_cand cand[]);
00665
00678 PJ_DECL(pj_status_t) pj_ice_strans_get_def_cand(pj_ice_strans *ice_st,
00679 unsigned comp_id,
00680 pj_ice_sess_cand *cand);
00681
00690 PJ_DECL(pj_ice_sess_role) pj_ice_strans_get_role(pj_ice_strans *ice_st);
00691
00692
00705 PJ_DECL(pj_status_t) pj_ice_strans_change_role(pj_ice_strans *ice_st,
00706 pj_ice_sess_role new_role);
00707
00708
00731 PJ_DECL(pj_status_t) pj_ice_strans_start_ice(pj_ice_strans *ice_st,
00732 const pj_str_t *rem_ufrag,
00733 const pj_str_t *rem_passwd,
00734 unsigned rcand_cnt,
00735 const pj_ice_sess_cand rcand[]);
00736
00748 PJ_DECL(const pj_ice_sess_check*)
00749 pj_ice_strans_get_valid_pair(const pj_ice_strans *ice_st,
00750 unsigned comp_id);
00751
00774 PJ_DECL(pj_status_t) pj_ice_strans_stop_ice(pj_ice_strans *ice_st);
00775
00776
00798 PJ_DECL(pj_status_t) pj_ice_strans_sendto(pj_ice_strans *ice_st,
00799 unsigned comp_id,
00800 const void *data,
00801 pj_size_t data_len,
00802 const pj_sockaddr_t *dst_addr,
00803 int dst_addr_len);
00804
00805
00811 PJ_END_DECL
00812
00813
00814
00815 #endif
00816