Ignore:
Timestamp:
Apr 9, 2008 9:38:12 AM (16 years ago)
Author:
bennylp
Message:

More ticket #485: huge changeset to support TURN TCP. Please see ticket #485 for the details

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjnath/include/pjnath/stun_session.h

    r1877 r1913  
    6565     * 
    6666     * @param sess          The STUN session. 
     67     * @param token         The token associated with this outgoing message 
     68     *                      and was set by the application. This token was  
     69     *                      set by application in pj_stun_session_send_msg() 
     70     *                      for outgoing messages that are initiated by the 
     71     *                      application, or in pj_stun_session_on_rx_pkt() 
     72     *                      if this message is a response that was internally 
     73     *                      generated by the STUN session (for example, an 
     74     *                      401/Unauthorized response). Application may use 
     75     *                      this facility for any purposes. 
    6776     * @param pkt           Packet to be sent. 
    6877     * @param pkt_size      Size of the packet to be sent. 
     
    7483     */ 
    7584    pj_status_t (*on_send_msg)(pj_stun_session *sess, 
     85                               void *token, 
    7686                               const void *pkt, 
    7787                               pj_size_t pkt_size, 
     
    8090 
    8191    /**  
    82      * Callback to be called on incoming STUN request message. In the  
     92     * Callback to be called on incoming STUN request message. This function 
     93     * is called when application calls pj_stun_session_on_rx_pkt() and when 
     94     * the STUN session has detected that the incoming STUN message is a 
     95     * STUN request message. In the  
    8396     * callback processing, application MUST create a response by calling 
    8497     * pj_stun_session_create_response() function and send the response 
     
    90103     * @param pkt_len       Length of the STUN packet. 
    91104     * @param rdata         Data containing incoming request message. 
     105     * @param token         The token that was set by the application when 
     106     *                      calling pj_stun_session_on_rx_pkt() function. 
    92107     * @param src_addr      Source address of the packet. 
    93108     * @param src_addr_len  Length of the source address. 
     
    101116                                 unsigned pkt_len, 
    102117                                 const pj_stun_rx_data *rdata, 
     118                                 void *token, 
    103119                                 const pj_sockaddr_t *src_addr, 
    104120                                 unsigned src_addr_len); 
     
    106122    /** 
    107123     * Callback to be called when response is received or the transaction  
    108      * has timed out. 
     124     * has timed out. This callback is called either when application calls 
     125     * pj_stun_session_on_rx_pkt() with the packet containing a STUN 
     126     * response for the client transaction, or when the internal timer of 
     127     * the STUN client transaction has timed-out before a STUN response is 
     128     * received. 
    109129     * 
    110130     * @param sess          The STUN session. 
     
    116136     *                      response may contain non-NULL value if the  
    117137     *                      response contains STUN ERROR-CODE attribute. 
     138     * @param token         The token that was set by the application  when 
     139     *                      calling pj_stun_session_send_msg() function. 
     140     *                      Please not that this token IS NOT the token 
     141     *                      that was given in pj_stun_session_on_rx_pkt(). 
    118142     * @param tdata         The original STUN request. 
    119143     * @param response      The response message, on successful transaction, 
     
    128152    void (*on_request_complete)(pj_stun_session *sess, 
    129153                                pj_status_t status, 
     154                                void *token, 
    130155                                pj_stun_tx_data *tdata, 
    131156                                const pj_stun_msg *response, 
     
    135160 
    136161    /** 
    137      * Type of callback to be called on incoming STUN indication. 
     162     * Callback to be called on incoming STUN request message. This function 
     163     * is called when application calls pj_stun_session_on_rx_pkt() and when 
     164     * the STUN session has detected that the incoming STUN message is a 
     165     * STUN indication message. 
     166     * 
     167     * @param sess          The STUN session. 
     168     * @param pkt           Pointer to the original STUN packet. 
     169     * @param pkt_len       Length of the STUN packet. 
     170     * @param msg           The parsed STUN indication. 
     171     * @param token         The token that was set by the application when 
     172     *                      calling pj_stun_session_on_rx_pkt() function. 
     173     * @param src_addr      Source address of the packet. 
     174     * @param src_addr_len  Length of the source address. 
     175     * 
     176     * @return              The return value of this callback will be 
     177     *                      returned back to pj_stun_session_on_rx_pkt() 
     178     *                      function. 
    138179     */ 
    139180    pj_status_t (*on_rx_indication)(pj_stun_session *sess, 
     
    141182                                    unsigned pkt_len, 
    142183                                    const pj_stun_msg *msg, 
     184                                    void *token, 
    143185                                    const pj_sockaddr_t *src_addr, 
    144186                                    unsigned src_addr_len); 
     
    178220    pj_stun_msg         *msg;           /**< The STUN message.              */ 
    179221 
    180     void                *user_data;     /**< Arbitrary application data.    */ 
     222    void                *token;         /**< The token.                     */ 
    181223 
    182224    pj_stun_client_tsx  *client_tsx;    /**< Client STUN transaction.       */ 
     225    pj_bool_t            retransmit;    /**< Retransmit request?            */ 
    183226    pj_uint32_t          msg_magic;     /**< Message magic.                 */ 
    184227    pj_uint8_t           msg_key[12];   /**< Message/transaction key.       */ 
     
    369412 * 
    370413 * @param sess      The STUN session instance. 
    371  * @param cache_res If PJ_TRUE then response will be cached. 
     414 * @param token     Optional token which will be given back to application in 
     415 *                  \a on_send_msg() callback and \a on_request_complete() 
     416 *                  callback, if the message is a STUN request message.  
     417 *                  Internally this function will put the token in the  
     418 *                  \a token field of pj_stun_tx_data, hence it will 
     419 *                  overwrite any value that the application puts there. 
     420 * @param cache_res If the message is a response message for an incoming 
     421 *                  request, specify PJ_TRUE to instruct the STUN session 
     422 *                  to cache this response for subsequent incoming request 
     423 *                  retransmission. Otherwise this parameter will be ignored 
     424 *                  for non-response message. 
     425 * @param retransmit If the message is a request message, specify whether the 
     426 *                  request should be retransmitted. Normally application will 
     427 *                  specify TRUE if the underlying transport is UDP and FALSE 
     428 *                  if the underlying transport is TCP or TLS. 
    372429 * @param dst_addr  The destination socket address. 
    373430 * @param addr_len  Length of destination address. 
     
    378435 */ 
    379436PJ_DECL(pj_status_t) pj_stun_session_send_msg(pj_stun_session *sess, 
     437                                              void *token, 
    380438                                              pj_bool_t cache_res, 
     439                                              pj_bool_t retransmit, 
    381440                                              const pj_sockaddr_t *dst_addr, 
    382441                                              unsigned addr_len, 
     
    384443 
    385444/** 
    386  * Create and send STUN response message. 
     445 * This is a utility function to create and send response for an incoming 
     446 * STUN request. Internally this function calls pj_stun_session_create_res() 
     447 * and pj_stun_session_send_msg(). It is provided here as a matter of 
     448 * convenience. 
    387449 * 
    388450 * @param sess      The STUN session instance. 
     
    396458 *                  \a err_code is non-zero, then default error message will 
    397459 *                  be used. 
     460 * @param token     Optional token which will be given back to application in 
     461 *                  \a on_send_msg() callback and \a on_request_complete() 
     462 *                  callback, if the message is a STUN request message.  
     463 *                  Internally this function will put the token in the  
     464 *                  \a token field of pj_stun_tx_data, hence it will 
     465 *                  overwrite any value that the application puts there. 
    398466 * @param cache     Specify whether session should cache this response for 
    399467 *                  future request retransmission. If TRUE, subsequent request 
     
    410478                                             unsigned code,  
    411479                                             const char *err_msg, 
     480                                             void *token, 
    412481                                             pj_bool_t cache,  
    413482                                             const pj_sockaddr_t *dst_addr,  
     
    469538 *                      STUN message (useful if packet is received via a 
    470539 *                      stream oriented protocol). 
    471  * @param src_addr      The source address of the packet. 
     540 * @param token         Optional token which will be given back to application 
     541 *                      in the \a on_rx_request(), \a on_rx_indication() and  
     542 *                      \a on_send_msg() callbacks. The token can be used to  
     543 *                      associate processing or incoming request or indication 
     544 *                      with some context. 
     545 * @param src_addr      The source address of the packet, which will also 
     546 *                      be given back to application callbacks, along with 
     547 *                      source address length. 
    472548 * @param src_addr_len  Length of the source address. 
    473549 * 
     
    478554                                               pj_size_t pkt_size, 
    479555                                               unsigned options, 
     556                                               void *token, 
    480557                                               unsigned *parsed_len, 
    481558                                               const pj_sockaddr_t *src_addr, 
Note: See TracChangeset for help on using the changeset viewer.