Changeset 2710


Ignore:
Timestamp:
May 18, 2009 11:18:38 AM (15 years ago)
Author:
bennylp
Message:

More ticket #831:

  • fixed Via address unchanged when switching transport
  • reset transaction retransmit count and timeout timer when retrying
  • handle case when TCP transport is not available
  • added macro PJSIP_UDP_SIZE_THRESHOLD
  • added API to encode transmit data (to avoid using stack when checking message size)
Location:
pjproject/branches/projects/sipit24
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • pjproject/branches/projects/sipit24/pjnath/src/pjnath-test/ice_test.c

    r2705 r2710  
    6565 
    6666    struct test_result expected;/* Expected result              */ 
     67 
     68    pj_bool_t   nom_regular;    /* Use regular nomination?      */ 
    6769}; 
    6870 
  • pjproject/branches/projects/sipit24/pjsip/include/pjsip/sip_config.h

    r2394 r2710  
    228228 
    229229/** 
     230 * RFC 3261 section 18.1.1: 
     231 * If a request is within 200 bytes of the path MTU, or if it is larger 
     232 * than 1300 bytes and the path MTU is unknown, the request MUST be sent 
     233 * using an RFC 2914 [43] congestion controlled transport protocol, such 
     234 * as TCP. 
     235 * 
     236 * This setting controls the threshold of the UDP packet, which if it's 
     237 * larger than this value the request will be sent with TCP. Default is 
     238 * 1300 bytes. 
     239 */ 
     240#ifndef PJSIP_UDP_SIZE_THRESHOLD 
     241#   define PJSIP_UDP_SIZE_THRESHOLD     1300 
     242#endif 
     243 
     244/** 
    230245 * Encode SIP headers in their short forms to reduce size. By default, 
    231246 * SIP headers in outgoing messages will be encoded in their full names.  
  • pjproject/branches/projects/sipit24/pjsip/include/pjsip/sip_transport.h

    r2394 r2710  
    579579 */ 
    580580PJ_DECL(pj_status_t) pjsip_tx_data_dec_ref( pjsip_tx_data *tdata ); 
     581 
     582/** 
     583 * Print the SIP message to transmit data buffer's internal buffer. This 
     584 * may allocate memory for the buffer, if the buffer has not been allocated 
     585 * yet, and encode the SIP message to that buffer. 
     586 * 
     587 * @param tdata     The transmit buffer. 
     588 * 
     589 * @return          PJ_SUCCESS on success of the appropriate error code. 
     590 */ 
     591PJ_DECL(pj_status_t) pjsip_tx_data_encode(pjsip_tx_data *tdata); 
    581592 
    582593/** 
  • pjproject/branches/projects/sipit24/pjsip/src/pjsip/sip_transaction.c

    r2646 r2710  
    17261726                      pjsip_tx_data_get_info(send_state->tdata), -sent, 
    17271727                      pj_strerror(-sent, errmsg, sizeof(errmsg)).ptr)); 
     1728 
     1729            /* Reset retransmission count */ 
     1730            tsx->retransmit_count = 0; 
     1731 
     1732            /* And reset timeout timer */ 
     1733            if (tsx->timeout_timer.id) { 
     1734                pjsip_endpt_cancel_timer(tsx->endpt, &tsx->timeout_timer); 
     1735                tsx->timeout_timer.id = TIMER_INACTIVE; 
     1736 
     1737                tsx->timeout_timer.id = TIMER_ACTIVE; 
     1738                pjsip_endpt_schedule_timer( tsx->endpt, &tsx->timeout_timer,  
     1739                                            &timeout_timer_val); 
     1740            } 
    17281741        } 
    17291742    } 
  • pjproject/branches/projects/sipit24/pjsip/src/pjsip/sip_transport.c

    r2394 r2710  
    435435} 
    436436 
     437/* 
     438 * Print the SIP message to transmit data buffer's internal buffer. 
     439 */ 
     440PJ_DEF(pj_status_t) pjsip_tx_data_encode(pjsip_tx_data *tdata) 
     441{ 
     442    /* Allocate buffer if necessary. */ 
     443    if (tdata->buf.start == NULL) { 
     444        PJ_USE_EXCEPTION; 
     445 
     446        PJ_TRY { 
     447            tdata->buf.start = (char*)  
     448                               pj_pool_alloc(tdata->pool, PJSIP_MAX_PKT_LEN); 
     449        } 
     450        PJ_CATCH_ANY { 
     451            return PJ_ENOMEM; 
     452        } 
     453        PJ_END 
     454 
     455        tdata->buf.cur = tdata->buf.start; 
     456        tdata->buf.end = tdata->buf.start + PJSIP_MAX_PKT_LEN; 
     457    } 
     458 
     459    /* Do we need to reprint? */ 
     460    if (!pjsip_tx_data_is_valid(tdata)) { 
     461        pj_ssize_t size; 
     462 
     463        size = pjsip_msg_print( tdata->msg, tdata->buf.start,  
     464                                tdata->buf.end - tdata->buf.start); 
     465        if (size < 0) { 
     466            return PJSIP_EMSGTOOLONG; 
     467        } 
     468        pj_assert(size != 0); 
     469        tdata->buf.cur[size] = '\0'; 
     470        tdata->buf.cur += size; 
     471    } 
     472 
     473    return PJ_SUCCESS; 
     474} 
     475 
    437476PJ_DEF(pj_bool_t) pjsip_tx_data_is_valid( pjsip_tx_data *tdata ) 
    438477{ 
     
    568607static pj_status_t mod_on_tx_msg(pjsip_tx_data *tdata) 
    569608{ 
    570     /* Allocate buffer if necessary. */ 
    571     if (tdata->buf.start == NULL) { 
    572         PJ_USE_EXCEPTION; 
    573  
    574         PJ_TRY { 
    575             tdata->buf.start = (char*)  
    576                                pj_pool_alloc(tdata->pool, PJSIP_MAX_PKT_LEN); 
    577         } 
    578         PJ_CATCH_ANY { 
    579             return PJ_ENOMEM; 
    580         } 
    581         PJ_END 
    582  
    583         tdata->buf.cur = tdata->buf.start; 
    584         tdata->buf.end = tdata->buf.start + PJSIP_MAX_PKT_LEN; 
    585     } 
    586  
    587     /* Do we need to reprint? */ 
    588     if (!pjsip_tx_data_is_valid(tdata)) { 
    589         pj_ssize_t size; 
    590  
    591         size = pjsip_msg_print( tdata->msg, tdata->buf.start,  
    592                                 tdata->buf.end - tdata->buf.start); 
    593         if (size < 0) { 
    594             return PJSIP_EMSGTOOLONG; 
    595         } 
    596         pj_assert(size != 0); 
    597         tdata->buf.cur[size] = '\0'; 
    598         tdata->buf.cur += size; 
    599     } 
    600  
    601     return PJ_SUCCESS; 
     609    return pjsip_tx_data_encode(tdata); 
    602610} 
    603611 
  • pjproject/branches/projects/sipit24/pjsip/src/pjsip/sip_util.c

    r2703 r2710  
    11361136        via->rport_param = 0; 
    11371137 
     1138        pjsip_tx_data_invalidate_msg(tdata); 
     1139 
    11381140        /* Send message using this transport. */ 
    11391141        status = pjsip_transport_send( stateless_data->cur_transport, 
     
    11921194        addr->entry[0].type == PJSIP_TRANSPORT_UDP) 
    11931195    { 
    1194         char buf[1500]; 
    11951196        int len; 
    11961197 
     1198        /* Encode the request */ 
     1199        status = pjsip_tx_data_encode(stateless_data->tdata); 
     1200        if (status != PJ_SUCCESS) { 
     1201            if (stateless_data->app_cb) { 
     1202                pj_bool_t cont = PJ_FALSE; 
     1203                (*stateless_data->app_cb)(stateless_data, -status, &cont); 
     1204            } 
     1205            pjsip_tx_data_dec_ref(stateless_data->tdata); 
     1206            return; 
     1207        } 
     1208 
    11971209        /* Check if request message is larger than 1300 bytes. */ 
    1198         len = pjsip_msg_print(stateless_data->tdata->msg, buf, 1300); 
    1199         if (len < 0) { 
     1210        len = stateless_data->tdata->buf.end -  
     1211                stateless_data->tdata->buf.start; 
     1212        if (len >= PJSIP_UDP_SIZE_THRESHOLD) { 
    12001213            int i; 
    12011214            int count = stateless_data->addr.count; 
Note: See TracChangeset for help on using the changeset viewer.