summaryrefslogtreecommitdiff
path: root/pjnath/include
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2007-04-03 18:01:27 +0000
committerBenny Prijono <bennylp@teluu.com>2007-04-03 18:01:27 +0000
commit89c220218ff5245488bf78514c79dfaf86b13743 (patch)
tree6e2fac9d12995fe188f19226cafe233d83e4c691 /pjnath/include
parentba0f43431650452e9a2977c965edd1ea460633c0 (diff)
Fixed misc bugs with ICE: (1) moved STUN session from candidate to component since it causes STUN response to wrong session, and (2) keep-alive transaction timed-out when ICE is active
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@1140 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjnath/include')
-rw-r--r--pjnath/include/pjnath/config.h31
-rw-r--r--pjnath/include/pjnath/ice_session.h16
-rw-r--r--pjnath/include/pjnath/ice_strans.h1
-rw-r--r--pjnath/include/pjnath/stun_session.h2
-rw-r--r--pjnath/include/pjnath/stun_transaction.h38
5 files changed, 77 insertions, 11 deletions
diff --git a/pjnath/include/pjnath/config.h b/pjnath/include/pjnath/config.h
index dec268f8..50db9420 100644
--- a/pjnath/include/pjnath/config.h
+++ b/pjnath/include/pjnath/config.h
@@ -164,6 +164,37 @@
#endif
+/**
+ * Minimum interval value to be used for sending STUN keep-alive on the ICE
+ * stream transport, in seconds. This minimum interval, plus a random value
+ * which maximum is PJ_ICE_ST_KEEP_ALIVE_MAX_RAND, specify the actual interval
+ * of the STUN keep-alive.
+ *
+ * Default: 20 seconds
+ *
+ * @see PJ_ICE_ST_KEEP_ALIVE_MAX_RAND
+ */
+#ifndef PJ_ICE_ST_KEEP_ALIVE_MIN
+# define PJ_ICE_ST_KEEP_ALIVE_MIN 20
+#endif
+
+
+/**
+ * To prevent STUN keep-alives to be sent simultaneously, application should
+ * add random interval to minimum interval (PJ_ICE_ST_KEEP_ALIVE_MIN). This
+ * setting specifies the maximum random value to be added to the minimum
+ * interval, in seconds.
+ *
+ * Default: 5 seconds
+ *
+ * @see PJ_ICE_ST_KEEP_ALIVE_MIN
+ */
+#ifndef PJ_ICE_ST_KEEP_ALIVE_MAX_RAND
+# define PJ_ICE_ST_KEEP_ALIVE_MAX_RAND 5
+#endif
+
+
+
/**
* @}
diff --git a/pjnath/include/pjnath/ice_session.h b/pjnath/include/pjnath/ice_session.h
index 14b9e3d3..761153d8 100644
--- a/pjnath/include/pjnath/ice_session.h
+++ b/pjnath/include/pjnath/ice_session.h
@@ -120,6 +120,12 @@ typedef struct pj_ice_sess_comp
*/
pj_ice_sess_check *valid_check;
+ /**
+ * The STUN session to be used to send and receive STUN messages for this
+ * component.
+ */
+ pj_stun_session *stun_sess;
+
} pj_ice_sess_comp;
@@ -187,12 +193,6 @@ typedef struct pj_ice_sess_cand
*/
pj_sockaddr rel_addr;
- /**
- * The STUN session to be used to send and receive STUN messages for this
- * candidate.
- */
- pj_stun_session *stun_sess;
-
} pj_ice_sess_cand;
@@ -366,14 +366,12 @@ typedef struct pj_ice_sess_cb
*
* @param ice The ICE session.
* @param comp_id ICE component ID.
- * @param cand_id ICE candidate ID.
* @param pkt The STUN packet.
* @param size The size of the packet.
* @param dst_addr Packet destination address.
* @param dst_addr_len Length of destination address.
*/
pj_status_t (*on_tx_pkt)(pj_ice_sess *ice, unsigned comp_id,
- unsigned cand_id,
const void *pkt, pj_size_t size,
const pj_sockaddr_t *dst_addr,
unsigned dst_addr_len);
@@ -695,7 +693,6 @@ PJ_DECL(pj_status_t) pj_ice_sess_send_data(pj_ice_sess *ice,
*
* @param ice The ICE session.
* @param comp_id Component ID.
- * @param cand_id Candidate ID.
* @param pkt Incoming packet.
* @param pkt_size Size of incoming packet.
* @param src_addr Source address of the packet.
@@ -705,7 +702,6 @@ PJ_DECL(pj_status_t) pj_ice_sess_send_data(pj_ice_sess *ice,
*/
PJ_DECL(pj_status_t) pj_ice_sess_on_rx_pkt(pj_ice_sess *ice,
unsigned comp_id,
- unsigned cand_id,
void *pkt,
pj_size_t pkt_size,
const pj_sockaddr_t *src_addr,
diff --git a/pjnath/include/pjnath/ice_strans.h b/pjnath/include/pjnath/ice_strans.h
index 59243a00..c145b277 100644
--- a/pjnath/include/pjnath/ice_strans.h
+++ b/pjnath/include/pjnath/ice_strans.h
@@ -274,6 +274,7 @@ typedef struct pj_ice_strans_comp
pj_sock_t sock; /**< Socket descriptor. */
pj_stun_session *stun_sess; /**< STUN session. */
+ pj_uint8_t ka_tsx_id[12]; /**< ID for keep STUN alives */
pj_sockaddr local_addr; /**< Local/base address. */
diff --git a/pjnath/include/pjnath/stun_session.h b/pjnath/include/pjnath/stun_session.h
index 9f5a0d60..6b45adf2 100644
--- a/pjnath/include/pjnath/stun_session.h
+++ b/pjnath/include/pjnath/stun_session.h
@@ -245,6 +245,7 @@ PJ_DECL(void) pj_stun_session_set_credential(pj_stun_session *sess,
* @param sess The STUN session instance.
* @param msg_type The STUN request message type, from pj_stun_method_e or
* from pj_stun_msg_type.
+ * @param tsx_id Optional transaction ID.
* @param p_tdata Pointer to receive STUN transmit data instance containing
* the request.
*
@@ -252,6 +253,7 @@ PJ_DECL(void) pj_stun_session_set_credential(pj_stun_session *sess,
*/
PJ_DECL(pj_status_t) pj_stun_session_create_req(pj_stun_session *sess,
int msg_type,
+ const pj_uint8_t tsx_id[12],
pj_stun_tx_data **p_tdata);
/**
diff --git a/pjnath/include/pjnath/stun_transaction.h b/pjnath/include/pjnath/stun_transaction.h
index f296c9f5..23f63771 100644
--- a/pjnath/include/pjnath/stun_transaction.h
+++ b/pjnath/include/pjnath/stun_transaction.h
@@ -90,6 +90,19 @@ typedef struct pj_stun_tsx_cb
const void *stun_pkt,
pj_size_t pkt_size);
+ /**
+ * This callback is called after the timer that was scheduled by
+ * #pj_stun_client_tsx_schedule_destroy() has elapsed. Application
+ * should call #pj_stun_client_tsx_destroy() upon receiving this
+ * callback.
+ *
+ * This callback is optional if application will not call
+ * #pj_stun_client_tsx_schedule_destroy().
+ *
+ * @param tsx The STUN transaction instance.
+ */
+ void (*on_destroy)(pj_stun_client_tsx *tsx);
+
} pj_stun_tsx_cb;
@@ -116,7 +129,30 @@ PJ_DECL(pj_status_t) pj_stun_client_tsx_create( pj_stun_config *cfg,
pj_stun_client_tsx **p_tsx);
/**
- * Destroy a STUN client transaction.
+ * Schedule timer to destroy the transaction after the transaction is
+ * complete. Application normally calls this function in the on_complete()
+ * callback. When this timer elapsed, the on_destroy() callback will be
+ * called.
+ *
+ * This is convenient to let the STUN transaction absorbs any response
+ * for the previous request retransmissions. If application doesn't want
+ * this, it can destroy the transaction immediately by calling
+ * #pj_stun_client_tsx_destroy().
+ *
+ * @param tsx The STUN transaction.
+ * @param delay The delay interval before on_destroy() callback
+ * is called.
+ *
+ * @return PJ_SUCCESS on success, or the appropriate error code.
+ */
+PJ_DECL(pj_status_t)
+pj_stun_client_tsx_schedule_destroy(pj_stun_client_tsx *tsx,
+ const pj_time_val *delay);
+
+
+/**
+ * Destroy a STUN client transaction immediately. This function can be
+ * called at any time to stop the transaction and destroy it.
*
* @param tsx The STUN transaction.
*