Changeset 993


Ignore:
Timestamp:
Feb 22, 2007 2:09:23 AM (17 years ago)
Author:
bennylp
Message:

Continuing work on the new STUN framework, partly implemented the client session

Location:
pjproject/trunk/pjlib-util
Files:
6 added
5 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjlib-util/build/pjlib_util.dsp

    r992 r993  
    138138# Begin Source File 
    139139 
     140SOURCE="..\src\pjlib-util\stun_msg_dump.c" 
     141# End Source File 
     142# Begin Source File 
     143 
    140144SOURCE="..\src\pjlib-util\stun_server.c" 
    141145# End Source File 
  • pjproject/trunk/pjlib-util/build/pjlib_util.dsw

    r992 r993  
    5858############################################################################### 
    5959 
     60Project: "pjstun_client"=".\pjstun_client.dsp" - Package Owner=<4> 
     61 
     62Package=<5> 
     63{{{ 
     64}}} 
     65 
     66Package=<4> 
     67{{{ 
     68    Begin Project Dependency 
     69    Project_Dep_Name pjlib 
     70    End Project Dependency 
     71    Begin Project Dependency 
     72    Project_Dep_Name pjlib_util 
     73    End Project Dependency 
     74}}} 
     75 
     76############################################################################### 
     77 
    6078Project: "pjstun_srv"=".\pjstun_srv.dsp" - Package Owner=<4> 
    6179 
  • pjproject/trunk/pjlib-util/include/pjlib-util/stun_msg.h

    r992 r993  
    11911191 
    11921192/** 
     1193 * Dump STUN message to a printable string output. 
     1194 * 
     1195 * @param msg           The STUN message 
     1196 * @param buffer        Buffer where the printable string output will 
     1197 *                      be printed on. 
     1198 * @param length        On input, specify the maximum length of the buffer. 
     1199 *                      On output, it will be filled up with the actual 
     1200 *                      length of the output string. 
     1201 * 
     1202 * @return              The message string output. 
     1203 */ 
     1204PJ_DECL(char*) pj_stun_msg_dump(const pj_stun_msg *msg, 
     1205                                char *buffer, 
     1206                                unsigned *length); 
     1207 
     1208 
     1209/** 
    11931210 * Find STUN attribute in the STUN message, starting from the specified 
    11941211 * index. 
    11951212 * 
    11961213 * @param msg           The STUN message. 
    1197  * @param attr_type     The attribute type to be found. 
     1214 * @param attr_type     The attribute type to be found, from pj_stun_attr_type. 
    11981215 * @param start_index   The start index of the attribute in the message. 
    11991216 *                      Specify zero to start searching from the first 
     
    12131230 * 
    12141231 * @param pool          The pool to allocate memory from. 
    1215  * @param attr_type     Attribute type. 
     1232 * @param attr_type     Attribute type, from #pj_stun_attr_type. 
    12161233 * @param xor_ed        If non-zero, the port and address will be XOR-ed 
    12171234 *                      with magic, to make the XOR-MAPPED-ADDRESS attribute. 
     
    12351252 * 
    12361253 * @param pool          The pool to allocate memory from. 
     1254 * @param attr_type     Attribute type, from #pj_stun_attr_type. 
    12371255 * @param value         The string value to be assigned to the attribute. 
    12381256 * @param p_attr        Pointer to receive the attribute. 
     
    13161334 * 
    13171335 * @param pool          The pool to allocate memory from. 
    1318  * @param attr_type     The attribute type. 
     1336 * @param attr_type     The attribute type, from #pj_stun_attr_type. 
    13191337 * @param p_attr        Pointer to receive the attribute. 
    13201338 * 
  • pjproject/trunk/pjlib-util/include/pjlib-util/stun_transaction.h

    r992 r993  
    7474    void        (*on_complete)(pj_stun_client_tsx *tsx, 
    7575                               pj_status_t status,  
    76                                pj_stun_msg *response); 
     76                               const pj_stun_msg *response); 
    7777 
    7878    /** 
     
    125125 
    126126/** 
     127 * Check if transaction has completed. 
     128 * 
     129 * @param tsx           The STUN transaction. 
     130 * 
     131 * @return              Non-zero if transaction has completed. 
     132 */ 
     133PJ_DECL(pj_bool_t) pj_stun_client_tsx_is_complete(pj_stun_client_tsx *tsx); 
     134 
     135 
     136/** 
    127137 * Associate an arbitrary data with the STUN transaction. This data 
    128138 * can be then retrieved later from the transaction, by using 
     
    187197 * @return              PJ_SUCCESS on success or the appropriate error code. 
    188198 */ 
    189 PJ_DECL(pj_status_t) pj_stun_client_tsx_on_rx_msg(pj_stun_client_tsx *tsx, 
     199PJ_DECL(pj_status_t) pj_stun_client_tsx_on_rx_pkt(pj_stun_client_tsx *tsx, 
    190200                                                  const void *packet, 
    191201                                                  pj_size_t pkt_size, 
     
    193203 
    194204 
     205/** 
     206 * Notify the STUN transaction about the arrival of STUN response. 
     207 * If the STUN response contains a final error (300 and greater), the 
     208 * transaction will be terminated and callback will be called. If the 
     209 * STUN response contains response code 100-299, retransmission 
     210 * will  cease, but application must still call this function again 
     211 * with a final response later to allow the transaction to complete. 
     212 * 
     213 * @param tsx           The STUN client transaction instance. 
     214 * @param packet        The incoming packet. 
     215 * @param pkt_size      Size of the incoming packet. 
     216 * @param parsed_len    Optional pointer to receive the number of bytes 
     217 *                      that have been parsed from the incoming packet 
     218 *                      for the STUN message. This is useful if the 
     219 *                      STUN transaction is running over stream oriented 
     220 *                      socket such as TCP or TLS. 
     221 * 
     222 * @return              PJ_SUCCESS on success or the appropriate error code. 
     223 */ 
     224PJ_DECL(pj_status_t) pj_stun_client_tsx_on_rx_msg(pj_stun_client_tsx *tsx, 
     225                                                  const pj_stun_msg *msg); 
     226 
    195227 
    196228/** 
  • pjproject/trunk/pjlib-util/src/pjlib-util/stun_transaction.c

    r992 r993  
    253253 
    254254 
     255 
    255256/* 
    256257 * Notify the STUN transaction about the arrival of STUN response. 
    257258 */ 
    258259PJ_DEF(pj_status_t) pj_stun_client_tsx_on_rx_msg(pj_stun_client_tsx *tsx, 
    259                                                  const void *packet, 
    260                                                  pj_size_t pkt_size, 
    261                                                  unsigned *parsed_len) 
    262 { 
    263     pj_stun_msg *msg; 
     260                                                 const pj_stun_msg *msg) 
     261{ 
    264262    pj_stun_error_code_attr *err_attr; 
    265263    pj_status_t status; 
    266  
    267     PJ_ASSERT_RETURN(tsx && packet && pkt_size, PJ_EINVAL); 
    268  
    269     /* Try to parse the message */ 
    270     status = pj_stun_msg_decode(tsx->pool, (const pj_uint8_t*)packet, 
    271                                 pkt_size, 0, &msg, parsed_len, 
    272                                 NULL, NULL, NULL); 
    273     if (status != PJ_SUCCESS) { 
    274         stun_perror(tsx, "STUN msg_decode() error", status); 
    275         return status; 
    276     } 
    277264 
    278265    /* Must be STUN response message */ 
     
    330317 
    331318    return PJ_SUCCESS; 
    332 } 
    333  
     319 
     320} 
     321 
     322 
     323/* 
     324 * Notify the STUN transaction about the arrival of STUN response. 
     325 */ 
     326PJ_DEF(pj_status_t) pj_stun_client_tsx_on_rx_pkt(pj_stun_client_tsx *tsx, 
     327                                                 const void *packet, 
     328                                                 pj_size_t pkt_size, 
     329                                                 unsigned *parsed_len) 
     330{ 
     331    pj_stun_msg *msg; 
     332    pj_status_t status; 
     333 
     334    PJ_ASSERT_RETURN(tsx && packet && pkt_size, PJ_EINVAL); 
     335 
     336    /* Try to parse the message */ 
     337    status = pj_stun_msg_decode(tsx->pool, (const pj_uint8_t*)packet, 
     338                                pkt_size, 0, &msg, parsed_len, 
     339                                NULL, NULL, NULL); 
     340    if (status != PJ_SUCCESS) { 
     341        stun_perror(tsx, "STUN msg_decode() error", status); 
     342        return status; 
     343    } 
     344 
     345    return pj_stun_client_tsx_on_rx_msg(tsx, msg); 
     346} 
     347 
Note: See TracChangeset for help on using the changeset viewer.