diff options
author | Benny Prijono <bennylp@teluu.com> | 2007-03-20 08:44:26 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2007-03-20 08:44:26 +0000 |
commit | 64942da06cce3089be7faa5ae609d5431d06efb8 (patch) | |
tree | 59437308405603551654518b4aa42e94611b5317 /pjnath/include | |
parent | ddd77d225ea62a6200a6a215655a31f680b15fe8 (diff) |
--
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@1085 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjnath/include')
-rw-r--r-- | pjnath/include/pjnath/ice.h | 60 | ||||
-rw-r--r-- | pjnath/include/pjnath/stun_msg.h | 26 | ||||
-rw-r--r-- | pjnath/include/pjnath/stun_session.h | 2 |
3 files changed, 73 insertions, 15 deletions
diff --git a/pjnath/include/pjnath/ice.h b/pjnath/include/pjnath/ice.h index 3277dc77..f42a793b 100644 --- a/pjnath/include/pjnath/ice.h +++ b/pjnath/include/pjnath/ice.h @@ -24,7 +24,7 @@ * @brief ICE socket. */ #include <pjnath/types.h> -#include <pjnath/stun_endpoint.h> +#include <pjnath/stun_session.h> #include <pjlib-util/resolver.h> #include <pj/sock.h> @@ -64,9 +64,9 @@ enum pj_ice_type_pref typedef struct pj_ice pj_ice; -#define PJ_ICE_MAX_CAND 32 +#define PJ_ICE_MAX_CAND 16 #define PJ_ICE_MAX_COMP 8 - +#define PJ_ICE_MAX_CHECKS 32 /** * ICE component @@ -104,7 +104,10 @@ typedef enum pj_ice_check_state typedef struct pj_ice_check { - unsigned local_cand_id; + unsigned cand_id; + pj_uint32_t comp_id; + pj_str_t foundation; + pj_uint64_t check_prio; pj_ice_check_state check_state; @@ -127,7 +130,7 @@ typedef struct pj_ice_checklist { pj_ice_checklist_state state; unsigned count; - pj_ice_check *checks; + pj_ice_check checks[PJ_ICE_MAX_CHECKS]; } pj_ice_checklist; @@ -136,10 +139,10 @@ typedef struct pj_ice_checklist */ typedef struct pj_ice_cb { - pj_bool_t (*on_found_cand)(pj_ice *sock, - pj_ice_cand_type type, - const pj_sockaddr_t *addr, - int addr_len); + pj_status_t (*on_send_pkt)(pj_ice *ice, + const void *pkt, pj_size_t size, + const pj_sockaddr_t *dst_addr, + unsigned addr_len); } pj_ice_cb; @@ -153,6 +156,12 @@ typedef enum pj_ice_state PJ_ICE_STATE_RESV_ERROR } pj_ice_state; +typedef enum pj_ice_role +{ + PJ_ICE_ROLE_CONTROLLED, + PJ_ICE_ROLE_CONTROLLING +} pj_ice_role; + /** * ICE structure. */ @@ -164,30 +173,49 @@ struct pj_ice pj_mutex_t *mutex; int af; int sock_type; - + pj_ice_role role; pj_ice_state state; + pj_ice_cb cb; + + /* STUN credentials */ + pj_str_t tx_uname; + pj_str_t tx_pass; + pj_str_t rx_uname; + pj_str_t rx_pass; + /* Components */ unsigned comp_cnt; pj_ice_comp comp[PJ_ICE_MAX_COMP]; /* Local candidates */ - unsigned cand_cnt; - pj_ice_cand cand[PJ_ICE_MAX_CAND]; + unsigned lcand_cnt; + pj_ice_cand lcand[PJ_ICE_MAX_CAND]; + + /* Remote candidates */ + unsigned rcand_cnt; + pj_ice_cand rcand[PJ_ICE_MAX_CAND]; - /* Checklist */ + /* Checklists */ pj_ice_checklist cklist; + pj_ice_checklist valid_list; /* STUN servers */ pj_dns_resolver *resv; pj_dns_async_query *resv_q; pj_bool_t relay_enabled; pj_sockaddr stun_srv; + + /* STUN sessions */ + pj_stun_session *tx_sess; + pj_stun_session *rx_sess; }; PJ_DECL(pj_status_t) pj_ice_create(pj_stun_config *cfg, const char *name, + pj_ice_role role, + const pj_ice_cb *cb, int af, int sock_type, pj_ice **p_ice); @@ -207,7 +235,11 @@ PJ_DECL(pj_status_t) pj_ice_add_comp(pj_ice *ice, PJ_DECL(pj_status_t) pj_ice_add_sock_comp(pj_ice *ice, unsigned comp_id, pj_sock_t sock); - +PJ_DECL(pj_status_t) pj_ice_set_credentials(pj_ice *ice, + const pj_str_t *local_ufrag, + const pj_str_t *local_pass, + const pj_str_t *remote_ufrag, + const pj_str_t *remote_pass); PJ_DECL(pj_status_t) pj_ice_start_gather(pj_ice *ice, unsigned flags); diff --git a/pjnath/include/pjnath/stun_msg.h b/pjnath/include/pjnath/stun_msg.h index ae076295..08e5672d 100644 --- a/pjnath/include/pjnath/stun_msg.h +++ b/pjnath/include/pjnath/stun_msg.h @@ -1512,7 +1512,6 @@ PJ_DECL(pj_status_t) pj_stun_binary_attr_create(pj_pool_t *pool, * if no data to be copied now. * @param length Length of data, or zero if no data is to be * copied now. - * @param p_attr Pointer to receive the attribute. * * @return PJ_SUCCESS on success or the appropriate error code. */ @@ -1522,6 +1521,31 @@ PJ_DECL(pj_status_t) pj_stun_msg_add_binary_attr(pj_pool_t *pool, const pj_uint8_t *data, unsigned length); +/** + * Create STUN empty attribute. + * + * @param pool The pool to allocate memory from. + * @param attr_type The attribute type, from #pj_stun_attr_type. + * @param p_attr Pointer to receive the attribute. + * + * @return PJ_SUCCESS on success or the appropriate error code. + */ +PJ_DECL(pj_status_t) pj_stun_empty_attr_create(pj_pool_t *pool, + int attr_type, + pj_stun_empty_attr **p_attr); + +/** + * Create STUN empty attribute and add the attribute to the message. + * + * @param pool The pool to allocate memory from. + * @param msg The STUN message. + * @param attr_type The attribute type, from #pj_stun_attr_type. + * + * @return PJ_SUCCESS on success or the appropriate error code. + */ +PJ_DECL(pj_status_t) pj_stun_msg_add_empty_attr(pj_pool_t *pool, + pj_stun_msg *msg, + int attr_type); /** * @} diff --git a/pjnath/include/pjnath/stun_session.h b/pjnath/include/pjnath/stun_session.h index 5f5bda30..bd28ecb6 100644 --- a/pjnath/include/pjnath/stun_session.h +++ b/pjnath/include/pjnath/stun_session.h @@ -138,6 +138,8 @@ struct pj_stun_tx_data pj_stun_session *sess; /**< The STUN session. */ pj_stun_msg *msg; /**< The STUN message. */ + void *user_data; /**< Arbitrary application data. */ + pj_stun_client_tsx *client_tsx; /**< Client STUN transaction. */ pj_uint32_t msg_magic; /**< Message magic. */ pj_uint8_t msg_key[12]; /**< Message/transaction key. */ |