- Timestamp:
- Oct 9, 2009 12:11:07 PM (15 years ago)
- Location:
- pjproject/trunk/pjsip
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/include/pjsip/sip_transport.h
r2724 r2932 28 28 #include <pjsip/sip_msg.h> 29 29 #include <pjsip/sip_parser.h> 30 #include <pjsip/sip_resolve.h> 30 31 #include <pj/sock.h> 31 32 #include <pj/list.h> … … 522 523 /** Callback to be called when this tx_data has been transmitted. */ 523 524 void (*cb)(void*, pjsip_tx_data*, pj_ssize_t); 525 526 /** Destination information, to be used to determine the network address 527 * of the message. For a request, this information is initialized when 528 * the request is sent with #pjsip_endpt_send_request_stateless() and 529 * network address is resolved. For CANCEL request, this information 530 * will be copied from the original INVITE to make sure that the CANCEL 531 * request goes to the same physical network address as the INVITE 532 * request. 533 */ 534 struct 535 { 536 /** Server addresses resolved. 537 */ 538 pjsip_server_addresses addr; 539 540 /** Current server address being tried. 541 */ 542 unsigned cur_addr; 543 544 } dest_info; 524 545 525 546 /** Transport information, only valid during on_tx_request() and -
pjproject/trunk/pjsip/include/pjsip/sip_util.h
r2855 r2932 452 452 pjsip_tx_data *tdata; 453 453 454 /** Server addresses resolved.455 */456 pjsip_server_addresses addr;457 458 /** Current server address being tried.459 */460 unsigned cur_addr;461 462 454 /** Current transport being used. 463 455 */ -
pjproject/trunk/pjsip/src/pjsip/sip_transaction.c
r2915 r2932 1627 1627 { 1628 1628 pjsip_transaction *tsx = (pjsip_transaction*) send_state->token; 1629 pjsip_tx_data *tdata = send_state->tdata; 1629 1630 struct tsx_lock_data lck; 1630 1631 … … 1645 1646 1646 1647 /* Update remote address. */ 1647 tsx->addr_len = send_state->addr.entry[send_state->cur_addr].addr_len;1648 tsx->addr_len = tdata->dest_info.addr.entry[tdata->dest_info.cur_addr].addr_len; 1648 1649 pj_memcpy(&tsx->addr, 1649 & send_state->addr.entry[send_state->cur_addr].addr,1650 &tdata->dest_info.addr.entry[tdata->dest_info.cur_addr].addr, 1650 1651 tsx->addr_len); 1651 1652 -
pjproject/trunk/pjsip/src/pjsip/sip_util.c
r2855 r2932 755 755 } 756 756 757 /* Must also copy the saved strict route header, otherwise CANCEL will be 758 * sent with swapped Route and request URI! 759 */ 760 if (req_tdata->saved_strict_route) { 761 cancel_tdata->saved_strict_route = (pjsip_route_hdr*) 762 pjsip_hdr_clone(cancel_tdata->pool, req_tdata->saved_strict_route); 763 } 764 765 /* Finally copy the destination info from the original request */ 766 pj_memcpy(&cancel_tdata->dest_info, &req_tdata->dest_info, 767 sizeof(req_tdata->dest_info)); 768 757 769 /* Done. 758 770 * Return the transmit buffer containing the CANCEL request. … … 1058 1070 */ 1059 1071 cont = (sent > 0) ? PJ_FALSE : 1060 ( stateless_data->cur_addr<stateless_data->addr.count-1);1072 (tdata->dest_info.cur_addr<tdata->dest_info.addr.count-1); 1061 1073 if (stateless_data->app_cb) { 1062 1074 (*stateless_data->app_cb)(stateless_data, sent, &cont); … … 1085 1097 */ 1086 1098 if (sent != -PJ_EPENDING) { 1087 stateless_data->cur_addr++;1099 tdata->dest_info.cur_addr++; 1088 1100 } 1089 1101 1090 1102 /* Have next address? */ 1091 if ( stateless_data->cur_addr >= stateless_data->addr.count) {1103 if (tdata->dest_info.cur_addr >= tdata->dest_info.addr.count) { 1092 1104 /* This only happens when a rather buggy application has 1093 1105 * sent 'cont' to PJ_TRUE when the initial value was PJ_FALSE. … … 1101 1113 1102 1114 /* Keep current server address information handy. */ 1103 cur_addr = & stateless_data->addr.entry[stateless_data->cur_addr].addr;1104 cur_addr_type = stateless_data->addr.entry[stateless_data->cur_addr].type;1105 cur_addr_len = stateless_data->addr.entry[stateless_data->cur_addr].addr_len;1115 cur_addr = &tdata->dest_info.addr.entry[tdata->dest_info.cur_addr].addr; 1116 cur_addr_type = tdata->dest_info.addr.entry[tdata->dest_info.cur_addr].type; 1117 cur_addr_len = tdata->dest_info.addr.entry[tdata->dest_info.cur_addr].addr_len; 1106 1118 1107 1119 /* Acquire transport. */ … … 1179 1191 { 1180 1192 pjsip_send_state *stateless_data = (pjsip_send_state*) token; 1193 pjsip_tx_data *tdata = stateless_data->tdata; 1181 1194 1182 1195 /* Fail on server resolution. */ … … 1186 1199 (*stateless_data->app_cb)(stateless_data, -status, &cont); 1187 1200 } 1188 pjsip_tx_data_dec_ref( stateless_data->tdata);1201 pjsip_tx_data_dec_ref(tdata); 1189 1202 return; 1190 1203 } 1191 1204 1192 1205 /* Copy server addresses */ 1193 pj_memcpy( &stateless_data->addr, addr, sizeof(pjsip_server_addresses)); 1206 if (addr && addr != &tdata->dest_info.addr) { 1207 pj_memcpy( &tdata->dest_info.addr, addr, 1208 sizeof(pjsip_server_addresses)); 1209 } 1210 pj_assert(tdata->dest_info.addr.count != 0); 1194 1211 1195 1212 #if !defined(PJSIP_DONT_SWITCH_TO_TCP) || PJSIP_DONT_SWITCH_TO_TCP==0 … … 1200 1217 * as TCP. 1201 1218 */ 1202 if ( stateless_data->tdata->msg->type == PJSIP_REQUEST_MSG &&1203 addr->count > 0 &&1204 addr->entry[0].type == PJSIP_TRANSPORT_UDP)1219 if (tdata->msg->type == PJSIP_REQUEST_MSG && 1220 tdata->dest_info.addr.count > 0 && 1221 tdata->dest_info.addr.entry[0].type == PJSIP_TRANSPORT_UDP) 1205 1222 { 1206 1223 int len; 1207 1224 1208 1225 /* Encode the request */ 1209 status = pjsip_tx_data_encode( stateless_data->tdata);1226 status = pjsip_tx_data_encode(tdata); 1210 1227 if (status != PJ_SUCCESS) { 1211 1228 if (stateless_data->app_cb) { … … 1213 1230 (*stateless_data->app_cb)(stateless_data, -status, &cont); 1214 1231 } 1215 pjsip_tx_data_dec_ref( stateless_data->tdata);1232 pjsip_tx_data_dec_ref(tdata); 1216 1233 return; 1217 1234 } 1218 1235 1219 1236 /* Check if request message is larger than 1300 bytes. */ 1220 len = stateless_data->tdata->buf.cur - 1221 stateless_data->tdata->buf.start; 1237 len = tdata->buf.cur - tdata->buf.start; 1222 1238 if (len >= PJSIP_UDP_SIZE_THRESHOLD) { 1223 1239 int i; 1224 int count = stateless_data->addr.count; 1240 int count = tdata->dest_info.addr.count; 1241 1242 PJ_LOG(5,(THIS_FILE, "%s exceeds UDP size threshold (%u), " 1243 "sending with TCP", 1244 pjsip_tx_data_get_info(tdata), 1245 PJSIP_UDP_SIZE_THRESHOLD)); 1225 1246 1226 1247 /* Insert "TCP version" of resolved UDP addresses at the … … 1230 1251 count = PJSIP_MAX_RESOLVED_ADDRESSES / 2; 1231 1252 for (i = 0; i < count; ++i) { 1232 pj_memcpy(& stateless_data->addr.entry[i+count],1233 & stateless_data->addr.entry[i],1234 sizeof( stateless_data->addr.entry[0]));1235 stateless_data->addr.entry[i].type = PJSIP_TRANSPORT_TCP;1253 pj_memcpy(&tdata->dest_info.addr.entry[i+count], 1254 &tdata->dest_info.addr.entry[i], 1255 sizeof(tdata->dest_info.addr.entry[0])); 1256 tdata->dest_info.addr.entry[i].type = PJSIP_TRANSPORT_TCP; 1236 1257 } 1237 stateless_data->addr.count = count * 2;1258 tdata->dest_info.addr.count = count * 2; 1238 1259 } 1239 1260 } … … 1241 1262 1242 1263 /* Process the addresses. */ 1243 stateless_send_transport_cb( stateless_data, stateless_data->tdata, 1244 -PJ_EPENDING); 1264 stateless_send_transport_cb( stateless_data, tdata, -PJ_EPENDING); 1245 1265 } 1246 1266 … … 1276 1296 stateless_data->app_cb = cb; 1277 1297 1278 /* Resolve destination host. 1279 * The processing then resumed when the resolving callback is called. 1280 */ 1281 pjsip_endpt_resolve( endpt, tdata->pool, &dest_info, stateless_data, 1282 &stateless_send_resolver_callback); 1298 /* If destination info has not been initialized (this applies for most 1299 * all requests except CANCEL), resolve destination host. The processing 1300 * then resumed when the resolving callback is called. For CANCEL, the 1301 * destination info must have been copied from the original INVITE so 1302 * proceed to sending the request directly. 1303 */ 1304 if (tdata->dest_info.addr.count == 0) { 1305 pjsip_endpt_resolve( endpt, tdata->pool, &dest_info, stateless_data, 1306 &stateless_send_resolver_callback); 1307 } else { 1308 PJ_LOG(5,(THIS_FILE, "%s: skipping target resolution because " 1309 "address is already set", 1310 pjsip_tx_data_get_info(tdata))); 1311 stateless_send_resolver_callback(PJ_SUCCESS, stateless_data, 1312 &tdata->dest_info.addr); 1313 } 1283 1314 return PJ_SUCCESS; 1284 1315 } … … 1591 1622 1592 1623 /* Update address in send_state. */ 1593 send_state->addr = *addr;1624 pj_memcpy(&send_state->tdata->dest_info.addr, addr, sizeof(*addr)); 1594 1625 1595 1626 /* Send response using the transoprt. */
Note: See TracChangeset
for help on using the changeset viewer.