From 0c6465f6d887d3b248d71c76e00fdce330a8629b Mon Sep 17 00:00:00 2001 From: Benny Prijono Date: Fri, 2 Mar 2007 19:06:05 +0000 Subject: 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 --- pjlib-util/include/pjlib-util/stun_endpoint.h | 34 ++++++++++++++++++++++++++- pjlib-util/include/pjlib-util/stun_session.h | 22 +++++++++++++---- 2 files changed, 51 insertions(+), 5 deletions(-) (limited to 'pjlib-util/include') 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 #include #include +#include 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 -- cgit v1.2.3