summaryrefslogtreecommitdiff
path: root/pjlib-util/include
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2007-03-02 19:06:05 +0000
committerBenny Prijono <bennylp@teluu.com>2007-03-02 19:06:05 +0000
commit0c6465f6d887d3b248d71c76e00fdce330a8629b (patch)
tree65682049647b3d69415859278ab6909612545290 /pjlib-util/include
parent3c27e733111fed60a836f6757bbf56ff0ede6701 (diff)
Finishing up client-side STUN authentication, a simple STUN client, and simple STUN server
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@1034 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjlib-util/include')
-rw-r--r--pjlib-util/include/pjlib-util/stun_endpoint.h34
-rw-r--r--pjlib-util/include/pjlib-util/stun_session.h22
2 files changed, 51 insertions, 5 deletions
diff --git a/pjlib-util/include/pjlib-util/stun_endpoint.h b/pjlib-util/include/pjlib-util/stun_endpoint.h
index fadde315..f6e12115 100644
--- a/pjlib-util/include/pjlib-util/stun_endpoint.h
+++ b/pjlib-util/include/pjlib-util/stun_endpoint.h
@@ -45,14 +45,46 @@ PJ_BEGIN_DECL
*/
typedef struct pj_stun_endpoint
{
+ /**
+ * Pool factory to be used by the STUN endpoint and all objects created
+ * that use this STUN endpoint.
+ */
pj_pool_factory *pf;
+
+ /**
+ * Ioqueue used by this endpoint.
+ */
pj_ioqueue_t *ioqueue;
+
+ /**
+ * Timer heap instance used by this endpoint.
+ */
pj_timer_heap_t *timer_heap;
+
+ /**
+ * Internal pool used by this endpoint. This shouldn't be used by
+ * application.
+ */
+ pj_pool_t *pool;
+
+ /**
+ * Options.
+ */
unsigned options;
+ /**
+ * The default initial STUN round-trip time estimation in msecs.
+ * The value normally is PJ_STUN_RTO_VALUE.
+ */
unsigned rto_msec;
- pj_pool_t *pool;
+ /**
+ * The interval to cache outgoing STUN response in the STUN session,
+ * in miliseconds.
+ *
+ * Default 10000 (10 seconds).
+ */
+ unsigned res_cache_msec;
} pj_stun_endpoint;
diff --git a/pjlib-util/include/pjlib-util/stun_session.h b/pjlib-util/include/pjlib-util/stun_session.h
index 94ea9ff6..610302fa 100644
--- a/pjlib-util/include/pjlib-util/stun_session.h
+++ b/pjlib-util/include/pjlib-util/stun_session.h
@@ -23,6 +23,7 @@
#include <pjlib-util/stun_endpoint.h>
#include <pjlib-util/stun_transaction.h>
#include <pj/list.h>
+#include <pj/timer.h>
PJ_BEGIN_DECL
@@ -139,14 +140,18 @@ struct pj_stun_tx_data
void *user_data; /**< Arbitrary user data. */
pj_stun_client_tsx *client_tsx; /**< Client STUN transaction. */
- pj_uint8_t client_key[12];/**< Client transaction key. */
+ pj_uint32_t msg_magic; /**< Message magic. */
+ pj_uint8_t msg_key[12]; /**< Message/transaction key. */
void *pkt; /**< The STUN packet. */
unsigned max_len; /**< Length of packet buffer. */
unsigned pkt_size; /**< The actual length of STUN pkt. */
+ unsigned options; /**< Options specified when sending */
unsigned addr_len; /**< Length of destination address. */
const pj_sockaddr_t *dst_addr; /**< Destination address. */
+
+ pj_timer_entry res_timer; /**< Response cache timer. */
};
@@ -154,7 +159,7 @@ struct pj_stun_tx_data
* Options that can be specified when creating or sending outgoing STUN
* messages. These options may be specified as bitmask.
*/
-enum pj_stun_session_option
+enum pj_stun_session_send_option
{
/**
* Add short term credential to the message. This option may not be used
@@ -171,7 +176,15 @@ enum pj_stun_session_option
/**
* Add STUN fingerprint to the message.
*/
- PJ_STUN_USE_FINGERPRINT = 4
+ PJ_STUN_USE_FINGERPRINT = 4,
+
+ /**
+ * Instruct the session to cache outgoing response. This can only be
+ * used when sending outgoing response message, and when it's specified,
+ * the session will use \a res_cache_msec settings in pj_stun_endpoint
+ * as the duration of the cache.
+ */
+ PJ_STUN_CACHE_RESPONSE = 8
};
@@ -258,6 +271,7 @@ pj_stun_session_set_short_term_credential(pj_stun_session *sess,
const pj_str_t *user,
const pj_str_t *passwd);
+
/**
* Create a STUN Bind request message. After the message has been
* successfully created, application can send the message by calling
@@ -395,7 +409,7 @@ PJ_DECL(pj_status_t) pj_stun_session_create_response(pj_stun_session *sess,
* to actually send the message to the wire.
*
* @param sess The STUN session instance.
- * @param options Optional flags, from pj_stun_session_option.
+ * @param options Optional flags, from pj_stun_session_send_option.
* @param dst_addr The destination socket address.
* @param addr_len Length of destination address.
* @param tdata The STUN transmit data containing the STUN message to