diff options
author | Benny Prijono <bennylp@teluu.com> | 2007-03-20 22:36:54 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2007-03-20 22:36:54 +0000 |
commit | 54037d38631be9cb082b61bbfd3cc6c218283ea1 (patch) | |
tree | da3bf9c6acab9078860d14ed03d56afd07e583e4 /pjnath/include | |
parent | a77eff2047fb31f53e35b898b8cbc9bb86dba0b9 (diff) |
Today's work
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@1089 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjnath/include')
-rw-r--r-- | pjnath/include/pjnath/errno.h | 1 | ||||
-rw-r--r-- | pjnath/include/pjnath/ice.h | 45 | ||||
-rw-r--r-- | pjnath/include/pjnath/stun_auth.h | 43 |
3 files changed, 63 insertions, 26 deletions
diff --git a/pjnath/include/pjnath/errno.h b/pjnath/include/pjnath/errno.h index cbefee85..9e1881f1 100644 --- a/pjnath/include/pjnath/errno.h +++ b/pjnath/include/pjnath/errno.h @@ -45,6 +45,7 @@ #define PJNATH_ESTUNINMSGTYPE -1 #define PJNATH_ESTUNFINGERPRINT -1 #define PJNATH_ESTUNNOTRESPOND -1 +#define PJNATH_ESTUNNOXORMAP -1 /** * @hideinitializer diff --git a/pjnath/include/pjnath/ice.h b/pjnath/include/pjnath/ice.h index f42a793b..9f86894f 100644 --- a/pjnath/include/pjnath/ice.h +++ b/pjnath/include/pjnath/ice.h @@ -27,6 +27,8 @@ #include <pjnath/stun_session.h> #include <pjlib-util/resolver.h> #include <pj/sock.h> +#include <pj/timer.h> + PJ_BEGIN_DECL @@ -67,14 +69,17 @@ typedef struct pj_ice pj_ice; #define PJ_ICE_MAX_CAND 16 #define PJ_ICE_MAX_COMP 8 #define PJ_ICE_MAX_CHECKS 32 +#define PJ_ICE_TA_VAL 20 /** * ICE component */ typedef struct pj_ice_comp { - unsigned comp_id; - pj_sock_t sock; + unsigned comp_id; + pj_sock_t sock; + pj_stun_session *stun_sess; + pj_sockaddr local_addr; } pj_ice_comp; @@ -104,18 +109,13 @@ typedef enum pj_ice_check_state typedef struct pj_ice_check { - unsigned cand_id; - pj_uint32_t comp_id; - pj_str_t foundation; - - pj_uint64_t check_prio; - pj_ice_check_state check_state; - - pj_ice_cand_type rem_type; - pj_str_t rem_foundation; - pj_uint32_t rem_prio; - pj_sockaddr rem_addr; - pj_sockaddr rem_base_addr; + pj_ice_cand *lcand; + pj_ice_cand *rcand; + + pj_uint64_t prio; + pj_ice_check_state state; + pj_bool_t nominated; + pj_status_t err_code; } pj_ice_check; @@ -131,6 +131,7 @@ typedef struct pj_ice_checklist pj_ice_checklist_state state; unsigned count; pj_ice_check checks[PJ_ICE_MAX_CHECKS]; + pj_timer_entry timer; } pj_ice_checklist; @@ -175,9 +176,10 @@ struct pj_ice int sock_type; pj_ice_role role; pj_ice_state state; - pj_ice_cb cb; + pj_stun_config stun_cfg; + /* STUN credentials */ pj_str_t tx_uname; pj_str_t tx_pass; @@ -205,14 +207,10 @@ struct pj_ice 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, +PJ_DECL(pj_status_t) pj_ice_create(pj_stun_config *stun_cfg, const char *name, pj_ice_role role, const pj_ice_cb *cb, @@ -256,17 +254,16 @@ PJ_DECL(pj_status_t) pj_ice_add_cand(pj_ice *ice, PJ_DECL(unsigned) pj_ice_get_cand_cnt(pj_ice *ice); PJ_DECL(pj_status_t) pj_ice_enum_cands(pj_ice *ice, - unsigned sort_by, unsigned *p_count, unsigned cand_ids[]); -PJ_DECL(unsigned) pj_ice_get_default_cand(pj_ice *ice, - int *cand_id); +PJ_DECL(pj_status_t) pj_ice_get_default_cand(pj_ice *ice, + unsigned comp_id, + int *cand_id); PJ_DECL(pj_status_t) pj_ice_get_cand(pj_ice *ice, unsigned cand_id, pj_ice_cand **p_cand); PJ_DECL(pj_status_t) pj_ice_create_check_list(pj_ice *ice, - pj_bool_t is_remote_offer, unsigned rem_cand_cnt, const pj_ice_cand rem_cand[]); diff --git a/pjnath/include/pjnath/stun_auth.h b/pjnath/include/pjnath/stun_auth.h index e30ebc95..1a9f6a0c 100644 --- a/pjnath/include/pjnath/stun_auth.h +++ b/pjnath/include/pjnath/stun_auth.h @@ -155,9 +155,45 @@ typedef struct pj_stun_auth_cred pj_str_t *nonce); /** + * Get the credential to be put in outgoing message. + * + * @param msg The outgoing message where the credential is + * to be applied. + * @param user_data The user data as specified in the credential. + * @param pool Pool where the callback can allocate memory + * to fill in the credential. + * @param realm On return, the callback may specify the realm + * if long term credential is desired, otherwise + * this string must be set to empty. + * @param username On return, the callback must fill in with the + * username. + * @param nonce On return, the callback may optionally fill in + * this argument with NONCE value if desired, + * otherwise this argument must be set to empty. + * @param data_type On return, the callback must set this argument + * with the type of password in the data argument. + * @param data On return, the callback must set this with + * the password, encoded according to data_type + * argument. + * + * @return The callback must return PJ_SUCCESS, otherwise + * the message transmission will be cancelled. + */ + pj_status_t (*get_cred)(const pj_stun_msg *msg, + void *user_data, + pj_pool_t *pool, + pj_str_t *realm, + pj_str_t *username, + pj_str_t *nonce, + int *data_type, + pj_str_t *data); + + /** * Get the password for the specified username. This function * is also used to check whether the username is valid. * + * @param msg The STUN message where the password will be + * applied to. * @param user_data The user data as specified in the credential. * @param realm The realm as specified in the message. * @param username The username as specified in the message. @@ -175,7 +211,8 @@ typedef struct pj_stun_auth_cred * is returned, it is assumed that the * username is not valid. */ - pj_status_t (*get_password)(void *user_data, + pj_status_t (*get_password)(const pj_stun_msg *msg, + void *user_data, const pj_str_t *realm, const pj_str_t *username, pj_pool_t *pool, @@ -187,6 +224,7 @@ typedef struct pj_stun_auth_cred * in the message can be accepted. If this callback returns * PJ_FALSE, 438 (Stale Nonce) response will be created. * + * @param msg The STUN message where the nonce was received. * @param user_data The user data as specified in the credential. * @param realm The realm as specified in the message. * @param username The username as specified in the message. @@ -195,7 +233,8 @@ typedef struct pj_stun_auth_cred * @return The callback MUST return non-zero if the * NONCE can be accepted. */ - pj_bool_t (*verify_nonce)(void *user_data, + pj_bool_t (*verify_nonce)(const pj_stun_msg *msg, + void *user_data, const pj_str_t *realm, const pj_str_t *username, const pj_str_t *nonce); |