Ticket #831: ticket831.patch

File ticket831.patch, 1.6 KB (added by nanang, 15 years ago)
  • pjsip/src/pjsip/sip_util.c

     
    11811181    /* Copy server addresses */ 
    11821182    pj_memcpy( &stateless_data->addr, addr, sizeof(pjsip_server_addresses)); 
    11831183 
     1184    /* RFC 3261 section 18.1.1: 
     1185     * If a request is within 200 bytes of the path MTU, or if it is larger 
     1186     * than 1300 bytes and the path MTU is unknown, the request MUST be sent 
     1187     * using an RFC 2914 [43] congestion controlled transport protocol, such 
     1188     * as TCP. 
     1189     */ 
     1190    if (stateless_data->tdata->msg->type == PJSIP_REQUEST_MSG && 
     1191        addr->count > 0 &&  
     1192        addr->entry[0].type == PJSIP_TRANSPORT_UDP) 
     1193    { 
     1194        char buf[1500]; 
     1195        int len; 
     1196 
     1197        /* Check if request message is larger than 1300 bytes. */ 
     1198        len = pjsip_msg_print(stateless_data->tdata->msg, buf, 1300); 
     1199        if (len < 0) { 
     1200            int i; 
     1201            int count = stateless_data->addr.count; 
     1202 
     1203            /* Insert "TCP version" of resolved UDP addresses at the 
     1204             * beginning. 
     1205             */ 
     1206            if (count * 2 > PJSIP_MAX_RESOLVED_ADDRESSES) 
     1207                count = PJSIP_MAX_RESOLVED_ADDRESSES / 2; 
     1208            for (i = 0; i < count; ++i) { 
     1209                pj_memcpy(&stateless_data->addr.entry[i+count], 
     1210                          &stateless_data->addr.entry[i], 
     1211                          sizeof(stateless_data->addr.entry[0])); 
     1212                stateless_data->addr.entry[i].type = PJSIP_TRANSPORT_TCP; 
     1213            } 
     1214            stateless_data->addr.count = count * 2; 
     1215        } 
     1216    } 
     1217 
    11841218    /* Process the addresses. */ 
    11851219    stateless_send_transport_cb( stateless_data, stateless_data->tdata, 
    11861220                                 -PJ_EPENDING);