Ignore:
Timestamp:
Mar 3, 2007 2:16:36 AM (17 years ago)
Author:
bennylp
Message:

Committed today's work on STUN

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjlib-util/include/pjlib-util/stun_session.h

    r1034 r1037  
    2121 
    2222#include <pjlib-util/stun_msg.h> 
     23#include <pjlib-util/stun_auth.h> 
    2324#include <pjlib-util/stun_endpoint.h> 
    2425#include <pjlib-util/stun_transaction.h> 
     
    148149    unsigned             pkt_size;      /**< The actual length of STUN pkt. */ 
    149150 
    150     unsigned             options;       /**< Options specified when sending */ 
    151151    unsigned             addr_len;      /**< Length of destination address. */ 
    152152    const pj_sockaddr_t *dst_addr;      /**< Destination address.           */ 
     
    157157 
    158158/** 
    159  * Options that can be specified when creating or sending outgoing STUN 
    160  * messages. These options may be specified as bitmask. 
    161  */ 
    162 enum pj_stun_session_send_option 
    163 { 
    164     /** 
    165      * Add short term credential to the message. This option may not be used 
    166      * together with PJ_STUN_USE_LONG_TERM_CRED option. 
    167      */ 
    168     PJ_STUN_USE_SHORT_TERM_CRED = 1, 
    169  
    170     /** 
    171      * Add long term credential to the message. This option may not be used 
    172      * together with PJ_STUN_USE_SHORT_TERM_CRED option. 
    173      */ 
    174     PJ_STUN_USE_LONG_TERM_CRED  = 2, 
    175  
    176     /** 
    177      * Add STUN fingerprint to the message. 
    178      */ 
    179     PJ_STUN_USE_FINGERPRINT     = 4, 
    180  
    181     /** 
    182      * Instruct the session to cache outgoing response. This can only be  
    183      * used when sending outgoing response message, and when it's specified, 
    184      * the session will use \a res_cache_msec settings in pj_stun_endpoint 
    185      * as the duration of the cache. 
    186      */ 
    187     PJ_STUN_CACHE_RESPONSE      = 8 
    188 }; 
    189  
    190  
    191 /** 
    192159 * Create a STUN session. 
    193160 * 
    194  * @param endpt     The STUN endpoint, to be used to register timers etc. 
    195  * @param name      Optional name to be associated with this instance. The 
    196  *                  name will be used for example for logging purpose. 
    197  * @param cb        Session callback. 
    198  * @param p_sess    Pointer to receive STUN session instance. 
     161 * @param endpt         The STUN endpoint, to be used to register timers etc. 
     162 * @param name          Optional name to be associated with this instance. The 
     163 *                      name will be used for example for logging purpose. 
     164 * @param cb            Session callback. 
     165 * @param fingerprint   Enable message fingerprint for outgoing messages. 
     166 * @param p_sess        Pointer to receive STUN session instance. 
    199167 * 
    200168 * @return          PJ_SUCCESS on success, or the appropriate error code. 
     
    203171                                            const char *name, 
    204172                                            const pj_stun_session_cb *cb, 
     173                                            pj_bool_t fingerprint, 
    205174                                            pj_stun_session **p_sess); 
    206175 
     
    236205 
    237206/** 
    238  * Save a long term credential to be used by this STUN session when sending 
    239  * outgoing messages. After long term credential is configured, application 
    240  * may specify PJ_STUN_USE_LONG_TERM_CRED option when sending outgoing STUN 
    241  * message to send the long term credential in the message. 
    242  * 
    243  * @param sess      The STUN session instance. 
    244  * @param realm     Realm of the long term credential. 
    245  * @param user      The user name. 
    246  * @param passwd    The pain-text password. 
    247  * 
    248  * @return          PJ_SUCCESS on success, or the appropriate error code. 
    249  */ 
    250 PJ_DECL(pj_status_t)  
    251 pj_stun_session_set_long_term_credential(pj_stun_session *sess, 
    252                                          const pj_str_t *realm, 
    253                                          const pj_str_t *user, 
    254                                          const pj_str_t *passwd); 
    255  
    256  
    257 /** 
    258  * Save a short term credential to be used by this STUN session when sending 
    259  * outgoing messages. After short term credential is configured, application 
    260  * may specify PJ_STUN_USE_SHORT_TERM_CRED option when sending outgoing STUN 
    261  * message to send the short term credential in the message. 
    262  * 
    263  * @param sess      The STUN session instance. 
    264  * @param user      The user name. 
    265  * @param passwd    The pain-text password. 
    266  * 
    267  * @return          PJ_SUCCESS on success, or the appropriate error code. 
    268  */ 
    269 PJ_DECL(pj_status_t)  
    270 pj_stun_session_set_short_term_credential(pj_stun_session *sess, 
    271                                           const pj_str_t *user, 
    272                                           const pj_str_t *passwd); 
    273  
     207 * Set server name to be included in all response. 
     208 * 
     209 * @param sess      The STUN session instance. 
     210 * @param srv_name  Server name string. 
     211 * 
     212 * @return          The user data associated with this STUN session. 
     213 */ 
     214PJ_DECL(pj_status_t) pj_stun_session_set_server_name(pj_stun_session *sess, 
     215                                                     const pj_str_t *srv_name); 
     216 
     217/** 
     218 * Set credential to be used by this session. Once credential is set, all 
     219 * outgoing messages will include MESSAGE-INTEGRITY, and all incoming 
     220 * message will be authenticated against this credential. 
     221 * 
     222 * To disable authentication after it has been set, call this function 
     223 * again with NULL as the argument. 
     224 * 
     225 * @param sess      The STUN session instance. 
     226 * @param cred      The credential to be used by this session. If NULL 
     227 *                  is specified, authentication will be disabled. 
     228 * 
     229 * @return          PJ_SUCCESS on success, or the appropriate error code. 
     230 */ 
     231PJ_DECL(void) pj_stun_session_set_credential(pj_stun_session *sess, 
     232                                             const pj_stun_auth_cred *cred); 
    274233 
    275234/** 
     
    410369 * 
    411370 * @param sess      The STUN session instance. 
    412  * @param options   Optional flags, from pj_stun_session_send_option. 
     371 * @param cache_res If PJ_TRUE then response will be cached. 
    413372 * @param dst_addr  The destination socket address. 
    414373 * @param addr_len  Length of destination address. 
     
    419378 */ 
    420379PJ_DECL(pj_status_t) pj_stun_session_send_msg(pj_stun_session *sess, 
    421                                               unsigned options, 
     380                                              pj_bool_t cache_res, 
    422381                                              const pj_sockaddr_t *dst_addr, 
    423382                                              unsigned addr_len, 
Note: See TracChangeset for help on using the changeset viewer.