diff options
author | Benny Prijono <bennylp@teluu.com> | 2007-03-29 21:54:21 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2007-03-29 21:54:21 +0000 |
commit | 3bde23647e94fe0764c8e32d53537e6b116e71de (patch) | |
tree | 7c8aa98ecff5193e7b89e6f44697b9f7538d59b3 /pjnath/include | |
parent | 7d29fabefb6405ea7bc47b8d9a465df5af96612c (diff) |
Added ICE-CONTROLLING and ICE-CONTROLLED STUN attribute types
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@1114 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjnath/include')
-rw-r--r-- | pjnath/include/pjnath/ice_session.h | 16 | ||||
-rw-r--r-- | pjnath/include/pjnath/ice_strans.h | 3 | ||||
-rw-r--r-- | pjnath/include/pjnath/stun_msg.h | 71 | ||||
-rw-r--r-- | pjnath/include/pjnath/types.h | 45 |
4 files changed, 102 insertions, 33 deletions
diff --git a/pjnath/include/pjnath/ice_session.h b/pjnath/include/pjnath/ice_session.h index fd7da751..929a4e82 100644 --- a/pjnath/include/pjnath/ice_session.h +++ b/pjnath/include/pjnath/ice_session.h @@ -444,6 +444,7 @@ struct pj_ice_sess void *user_data; /**< App. data. */ pj_mutex_t *mutex; /**< Mutex. */ pj_ice_sess_role role; /**< ICE role. */ + pj_timestamp tie_breaker; /**< Tie breaker value */ pj_bool_t is_complete; /**< Complete? */ pj_status_t ice_status; /**< Error status. */ pj_ice_sess_cb cb; /**< Callback. */ @@ -550,6 +551,21 @@ PJ_DECL(pj_status_t) pj_ice_sess_destroy(pj_ice_sess *ice); /** + * Change session role. This happens for example when ICE session was + * created with controlled role when receiving an offer, but it turns out + * that the offer contains "a=ice-lite" attribute when the SDP gets + * inspected. + * + * @param ice The ICE session. + * @param new_role The new role to be set. + * + * @return PJ_SUCCESS on success, or the appropriate error. + */ +PJ_DECL(pj_status_t) pj_ice_sess_change_role(pj_ice_sess *ice, + pj_ice_sess_role new_role); + + +/** * Add a candidate to this ICE session. Application must add candidates for * each components ID before it can start pairing the candidates and * performing connectivity checks. diff --git a/pjnath/include/pjnath/ice_strans.h b/pjnath/include/pjnath/ice_strans.h index b26b6a49..59243a00 100644 --- a/pjnath/include/pjnath/ice_strans.h +++ b/pjnath/include/pjnath/ice_strans.h @@ -27,6 +27,7 @@ #include <pjnath/ice_session.h> #include <pjlib-util/resolver.h> #include <pj/ioqueue.h> +#include <pj/timer.h> PJ_BEGIN_DECL @@ -314,6 +315,8 @@ struct pj_ice_strans pj_bool_t has_rjob; /**< Has pending resolve? */ pj_sockaddr_in stun_srv; /**< STUN server address. */ pj_sockaddr_in turn_srv; /**< TURN server address. */ + + pj_timer_entry ka_timer; /**< STUN keep-alive timer. */ }; diff --git a/pjnath/include/pjnath/stun_msg.h b/pjnath/include/pjnath/stun_msg.h index 6c43ee9b..6c716a0c 100644 --- a/pjnath/include/pjnath/stun_msg.h +++ b/pjnath/include/pjnath/stun_msg.h @@ -310,6 +310,8 @@ typedef enum pj_stun_attr_type PJ_STUN_ATTR_ALTERNATE_SERVER = 0x8023,/**< ALTERNATE-SERVER. */ PJ_STUN_ATTR_REFRESH_INTERVAL = 0x8024,/**< REFRESH-INTERVAL. */ PJ_STUN_ATTR_FINGERPRINT = 0x8028,/**< FINGERPRINT attribute. */ + PJ_STUN_ATTR_ICE_CONTROLLED = 0x8029,/**< ICE-CCONTROLLED attribute.*/ + PJ_STUN_ATTR_ICE_CONTROLLING = 0x802a,/**< ICE-CCONTROLLING attribute*/ PJ_STUN_ATTR_END_EXTENDED_ATTR @@ -344,6 +346,7 @@ typedef enum pj_stun_status PJ_STUN_SC_CONNECTION_TIMEOUT = 447, /**< Connection Timeout */ PJ_STUN_SC_ALLOCATION_QUOTA_REACHED = 486, /**< Allocation Quota Reached (TURN) */ + PJ_STUN_SC_ROLE_CONFLICT = 487, /**< Role Conflict */ PJ_STUN_SC_SERVER_ERROR = 500, /**< Server Error */ PJ_STUN_SC_INSUFFICIENT_CAPACITY = 507, /**< Insufficient Capacity (TURN) */ @@ -418,8 +421,6 @@ typedef struct pj_stun_msg_hdr +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type | Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Value .... | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ \endverbatim */ @@ -533,7 +534,7 @@ typedef struct pj_stun_uint_attr pj_stun_attr_hdr hdr; /** - * The 32bit value. + * The 32bit value, in host byte order. */ pj_uint32_t value; @@ -541,6 +542,25 @@ typedef struct pj_stun_uint_attr /** + * This structure represents a generic STUN attributes with 64bit (unsigned) + * integer value, such as ICE-CONTROLLED and ICE-CONTROLLING attributes. + */ +typedef struct pj_stun_uint64_attr +{ + /** + * Standard STUN attribute header. + */ + pj_stun_attr_hdr hdr; + + /** + * The 64bit value, in host byte order, represented with pj_timestamp. + */ + pj_timestamp value; + +} pj_stun_uint64_attr; + + +/** * This structure represents generic STUN attributes to hold a raw binary * data. */ @@ -621,19 +641,9 @@ typedef struct pj_stun_errcode_attr pj_stun_attr_hdr hdr; /** - * The value must be zero. - */ - pj_uint16_t zero; - - /** - * Error class (1-6). - */ - pj_uint8_t err_class; - - /** - * Error number is the error number modulo 100. + * STUN error code. */ - pj_uint8_t number; + int err_code; /** * The reason phrase. @@ -1349,6 +1359,37 @@ PJ_DECL(pj_status_t) pj_stun_msg_add_uint_attr(pj_pool_t *pool, /** + * Create a STUN generic 64bit value attribute. + * + * @param pool Pool to allocate memory from. + * @param attr_type Attribute type, from #pj_stun_attr_type. + * @param value Optional value to be assigned. + * @param p_attr Pointer to receive the attribute. + * + * @return PJ_SUCCESS on success or the appropriate error code. + */ +PJ_DEF(pj_status_t) pj_stun_uint64_attr_create(pj_pool_t *pool, + int attr_type, + const pj_timestamp *value, + pj_stun_uint64_attr **p_attr); + + +/** + * Create and add STUN generic 64bit value attribute to the message. + * + * @param pool The pool to allocate memory from. + * @param msg The STUN message + * @param attr_type Attribute type, from #pj_stun_attr_type. + * @param value The 64bit value to be assigned to the attribute. + * + * @return PJ_SUCCESS on success or the appropriate error code. + */ +PJ_DECL(pj_status_t) pj_stun_msg_add_uint64_attr(pj_pool_t *pool, + pj_stun_msg *msg, + int attr_type, + const pj_timestamp *value); + +/** * Create a STUN MESSAGE-INTEGRITY attribute. * * @param pool The pool to allocate memory from. diff --git a/pjnath/include/pjnath/types.h b/pjnath/include/pjnath/types.h index 2eaf6313..72c326af 100644 --- a/pjnath/include/pjnath/types.h +++ b/pjnath/include/pjnath/types.h @@ -51,18 +51,11 @@ PJ_END_DECL /* Doxygen documentation below: */ /** - * @mainpage PJNATH - Open Source STUN, TURN, and ICE Library + * @mainpage PJNATH - Open Source ICE, STUN, and TURN Library * * \n * This is the documentation of PJNATH, an Open Source library providing - * NAT traversal helper functionalities by using standard based protocols - * such as: - * - <b>STUN</b> (Session Traversal Utilities), - * - <b>TURN</b> (Obtaining Relay Addresses from STUN) - * - <b>ICE</b> (Interactive Connectivity Establishment). - * - * The following sections will give a short overview about the protocols - * supported by this library, and how they are implemented in PJNATH. + * NAT traversal helper functionalities by using standard based protocols. * * \n @@ -70,15 +63,10 @@ PJ_END_DECL * * Session Traversal Utilities (STUN, or previously known as Simple * Traversal of User Datagram Protocol (UDP) Through Network Address - * Translators (NAT)s), was previously released as IETF standard - * <A HREF="http://www.ietf.org/rfc/rfc3489.txt">RFC 3489</A>, but since - * then it has been revised into the following: - * - <A HREF="http://www.ietf.org/internet-drafts/draft-ietf-behave-rfc3489bis-06.txt"> - * <B>draft-ietf-behave-rfc3489bis-06</b></A> for the main STUN - * specification, - * - <A HREF="http://www.ietf.org/internet-drafts/draft-ietf-behave-turn-03.txt"> - * <B>draft-ietf-behave-turn-03</B></A> for TURN usage of STUN, - * - and several other drafts explaining other STUN usages. + * Translators (NAT)s), is a lightweight protocol that serves as a tool for + * application protocols in dealing with NAT traversal. It allows a client + * to determine the IP address and port allocated to them by a NAT and to + * keep NAT bindings open. * * The PJNATH library provides facilities to support both the core * <B>STUN-bis</B> specification and the <B>TURN</B> usage of STUN, @@ -133,6 +121,19 @@ PJ_END_DECL * to the STUN components for processing. and it must supply the STUN * components with callback to send outgoing messages. * + * + * \subsection PJNATH_STUN_REF STUN Reference + * + * References for STUN: + * + * - <A HREF="http://www.ietf.org/internet-drafts/draft-ietf-behave-rfc3489bis-06.txt"> + * <B>draft-ietf-behave-rfc3489bis-06</b></A>: Session Traversal + * Utilities for (NAT) (STUN), + * - <A HREF="http://www.ietf.org/internet-drafts/draft-ietf-behave-turn-03.txt"> + * <B>draft-ietf-behave-turn-03</B></A>: Obtaining Relay Addresses + * from Simple Traversal Underneath NAT (STUN) + * - Obsoleted: <A HREF="http://www.ietf.org/rfc/rfc3489.txt">RFC 3489</A>. + * * \n * * \section PJNATH_ICE ICE Implementation @@ -170,6 +171,14 @@ PJ_END_DECL * - the highest abstraction is ICE media transport, which maintains * ICE stream transport and provides SDP translations to be used * for SIP offer/answer exchanges. + * + * \subsection PJNATH_ICE_REF Reference + * + * References for ICE: + * - <A HREF="http://www.ietf.org/internet-drafts/draft-ietf-mmusic-ice-15.txt"> + * <B>draft-ietf-mmusic-ice-15.txt</B></A>: Interactive Connectivity + * Establishment (ICE): A Methodology for Network Address Translator + * (NAT) Traversal for Offer/Answer Protocols */ /** |