| 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 | |