Changeset 4173
- Timestamp:
- Jun 20, 2012 10:39:05 AM (12 years ago)
- Location:
- pjproject/trunk/pjsip
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/include/pjsip-simple/publish.h
r3553 r4173 238 238 239 239 /** 240 * Set the "sent-by" field of the Via header for outgoing requests. 241 * 242 * @param pubc The client publication structure. 243 * @param via_addr Set via_addr to use for the Via header or NULL to use 244 * the transport's published name. 245 * @param via_tp via_addr will only be used if we are using via_tp 246 * transport. 247 * 248 * @return PJ_SUCCESS on success. 249 */ 250 PJ_DECL(pj_status_t) pjsip_publishc_set_via_sent_by(pjsip_publishc *pubc, 251 pjsip_host_port *via_addr, 252 pjsip_transport *via_tp); 253 254 255 /** 240 256 * Create PUBLISH request for the specified client publication structure. 241 257 * Application can use this function to both create initial publication -
pjproject/trunk/pjsip/include/pjsip-ua/sip_regc.h
r4038 r4173 192 192 193 193 /** 194 * Set the "sent-by" field of the Via header for outgoing requests. 195 * 196 * @param regc The client registration structure. 197 * @param via_addr Set via_addr to use for the Via header or NULL to use 198 * the transport's published name. 199 * @param via_tp via_addr will only be used if we are using via_tp 200 * transport. 201 * 202 * @return PJ_SUCCESS on success. 203 */ 204 PJ_DECL(pj_status_t) pjsip_regc_set_via_sent_by(pjsip_regc *regc, 205 pjsip_host_port *via_addr, 206 pjsip_transport *via_tp); 207 208 /** 194 209 * Set the number of seconds to refresh the client registration before 195 210 * the registration expires. -
pjproject/trunk/pjsip/include/pjsip/sip_dialog.h
r3553 r4173 174 174 /** Module specific data. */ 175 175 void *mod_data[PJSIP_MAX_MODULE]; /**< Module data. */ 176 177 /** 178 * If via_addr is set, it will be used as the "sent-by" field of the 179 * Via header for outgoing requests as long as the request uses via_tp 180 * transport. Normally application should not use or access these fields. 181 */ 182 pjsip_host_port via_addr; /**< Via address. */ 183 const void *via_tp; /**< Via transport. */ 176 184 }; 177 185 … … 299 307 300 308 /** 309 * Set the "sent-by" field of the Via header for outgoing requests. 310 * 311 * @param dlg The dialog instance. 312 * @param via_addr Set via_addr to use for the Via header or NULL to use 313 * the transport's published name. 314 * @param via_tp via_addr will only be used if we are using via_tp 315 * transport. 316 * 317 * @return PJ_SUCCESS on success. 318 */ 319 PJ_DECL(pj_status_t) pjsip_dlg_set_via_sent_by(pjsip_dialog *dlg, 320 pjsip_host_port *via_addr, 321 pjsip_transport *via_tp); 322 323 324 /** 301 325 * Create a new (forked) dialog on receipt on forked response in rdata. 302 326 * The new dialog will be created from original_dlg, except that it will have … … 403 427 */ 404 428 PJ_DECL(pj_bool_t) pjsip_dlg_has_usage(pjsip_dialog *dlg, 405 429 pjsip_module *module); 406 430 407 431 /** -
pjproject/trunk/pjsip/include/pjsip/sip_transport.h
r3999 r4173 585 585 */ 586 586 void *mod_data[PJSIP_MAX_MODULE]; 587 588 /** 589 * If via_addr is set, it will be used as the "sent-by" field of the 590 * Via header for outgoing requests as long as the request uses via_tp 591 * transport. Normally application should not use or access these fields. 592 */ 593 pjsip_host_port via_addr; /**< Via address. */ 594 const void *via_tp; /**< Via transport. */ 587 595 }; 588 596 -
pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h
r4172 r4173 2819 2819 2820 2820 /** 2821 * This option is used to overwrite the "sent-by" field of the Via header 2822 * for outgoing messages with the same interface address as the one in 2823 * the REGISTER request, as long as the request uses the same transport 2824 * instance as the previous REGISTER request. 2825 * 2826 * Default: 1 (yes) 2827 */ 2828 pj_bool_t allow_via_rewrite; 2829 2830 /** 2821 2831 * Control the use of SIP outbound feature. SIP outbound is described in 2822 2832 * RFC 5626 to enable proxies or registrar to send inbound requests back -
pjproject/trunk/pjsip/include/pjsua-lib/pjsua_internal.h
r4172 r4173 213 213 It may be different than acc 214 214 contact if outbound is used */ 215 pjsip_host_port via_addr; /**< Address for Via header */ 216 pjsip_transport *via_tp; /**< Transport associated with 217 the Via address */ 215 218 216 219 pj_str_t srv_domain; /**< Host part of reg server. */ -
pjproject/trunk/pjsip/src/pjsip-simple/publishc.c
r3553 r4173 95 95 pjsip_route_hdr route_set; 96 96 pjsip_hdr usr_hdr; 97 pjsip_host_port via_addr; 98 const void *via_tp; 97 99 98 100 /* Authorization sessions. */ … … 342 344 h = h->next; 343 345 } 346 347 return PJ_SUCCESS; 348 } 349 350 PJ_DEF(pj_status_t) pjsip_publishc_set_via_sent_by(pjsip_publishc *pubc, 351 pjsip_host_port *via_addr, 352 pjsip_transport *via_tp) 353 { 354 PJ_ASSERT_RETURN(pubc, PJ_EINVAL); 355 356 if (!via_addr) 357 pj_bzero(&pubc->via_addr, sizeof(pubc->via_addr)); 358 else 359 pubc->via_addr = *via_addr; 360 pubc->via_tp = via_tp; 344 361 345 362 return PJ_SUCCESS; … … 740 757 pj_mutex_unlock(pubc->mutex); 741 758 759 /* If via_addr is set, use this address for the Via header. */ 760 if (pubc->via_addr.host.slen > 0) { 761 tdata->via_addr = pubc->via_addr; 762 tdata->via_tp = pubc->via_tp; 763 } 764 742 765 /* Invalidate message buffer. */ 743 766 pjsip_tx_data_invalidate_msg(tdata); -
pjproject/trunk/pjsip/src/pjsip-ua/sip_reg.c
r4038 r4173 91 91 pjsip_route_hdr route_set; 92 92 pjsip_hdr hdr_list; 93 pjsip_host_port via_addr; 94 const void *via_tp; 93 95 94 96 /* Authorization sessions. */ … … 807 809 regc->next_reg.sec += delay.sec; 808 810 } 811 } 812 813 PJ_DEF(pj_status_t) pjsip_regc_set_via_sent_by( pjsip_regc *regc, 814 pjsip_host_port *via_addr, 815 pjsip_transport *via_tp) 816 { 817 PJ_ASSERT_RETURN(regc, PJ_EINVAL); 818 819 if (!via_addr) 820 pj_bzero(®c->via_addr, sizeof(regc->via_addr)); 821 else 822 regc->via_addr = *via_addr; 823 regc->via_tp = via_tp; 824 825 return PJ_SUCCESS; 809 826 } 810 827 … … 1263 1280 pjsip_tx_data_add_ref(tdata); 1264 1281 1282 /* If via_addr is set, use this address for the Via header. */ 1283 if (regc->via_addr.host.slen > 0) { 1284 tdata->via_addr = regc->via_addr; 1285 tdata->via_tp = regc->via_tp; 1286 } 1287 1265 1288 /* Need to unlock the regc temporarily while sending the message to 1266 1289 * prevent deadlock (https://trac.pjsip.org/repos/ticket/1247). -
pjproject/trunk/pjsip/src/pjsip/sip_dialog.c
r4171 r4173 586 586 } 587 587 588 /* 589 * Set "sent-by" field of Via header. 590 */ 591 PJ_DEF(pj_status_t) pjsip_dlg_set_via_sent_by( pjsip_dialog *dlg, 592 pjsip_host_port *via_addr, 593 pjsip_transport *via_tp) 594 { 595 PJ_ASSERT_RETURN(dlg, PJ_EINVAL); 596 597 if (!via_addr) 598 pj_bzero(&dlg->via_addr, sizeof(dlg->via_addr)); 599 else 600 dlg->via_addr = *via_addr; 601 dlg->via_tp = via_tp; 602 603 return PJ_SUCCESS; 604 } 605 588 606 589 607 /* … … 1163 1181 /* Lock and increment session */ 1164 1182 pjsip_dlg_inc_lock(dlg); 1183 1184 /* If via_addr is set, use this address for the Via header. */ 1185 if (dlg->via_addr.host.slen > 0) { 1186 tdata->via_addr = dlg->via_addr; 1187 tdata->via_tp = dlg->via_tp; 1188 } 1165 1189 1166 1190 /* Update dialog's CSeq and message's CSeq if request is not -
pjproject/trunk/pjsip/src/pjsip/sip_util.c
r3999 r4173 1193 1193 1194 1194 via->transport = pj_str(stateless_data->cur_transport->type_name); 1195 via->sent_by = stateless_data->cur_transport->local_name; 1195 if (tdata->via_addr.host.slen > 0 && 1196 tdata->via_tp == (void *)stateless_data->cur_transport) 1197 { 1198 via->sent_by = tdata->via_addr; 1199 } else { 1200 via->sent_by = stateless_data->cur_transport->local_name; 1201 } 1196 1202 via->rport_param = pjsip_cfg()->endpt.disable_rport ? -1 : 0; 1197 1203 -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_acc.c
r4172 r4173 625 625 acc->valid = PJ_FALSE; 626 626 acc->contact.slen = 0; 627 pj_bzero(&acc->via_addr, sizeof(acc->via_addr)); 628 acc->via_tp = NULL; 627 629 628 630 /* Remove from array */ … … 1091 1093 } 1092 1094 1095 /* Allow via rewrite */ 1096 if (acc->cfg.allow_via_rewrite != cfg->allow_via_rewrite) { 1097 if (acc->regc != NULL) { 1098 if (cfg->allow_via_rewrite) { 1099 pjsip_regc_set_via_sent_by(acc->regc, &acc->via_addr, 1100 acc->via_tp); 1101 } else 1102 pjsip_regc_set_via_sent_by(acc->regc, NULL, NULL); 1103 } 1104 if (acc->publish_sess != NULL) { 1105 if (cfg->allow_via_rewrite) { 1106 pjsip_publishc_set_via_sent_by(acc->publish_sess, 1107 &acc->via_addr, acc->via_tp); 1108 } else 1109 pjsip_publishc_set_via_sent_by(acc->publish_sess, NULL, NULL); 1110 } 1111 acc->cfg.allow_via_rewrite = cfg->allow_via_rewrite; 1112 } 1113 1093 1114 /* Normalize registration timeout and refresh delay */ 1094 1115 if (acc->cfg.reg_uri.slen ) { … … 1314 1335 1315 1336 tp = param->rdata->tp_info.transport; 1337 1338 /* If allow_via_rewrite is enabled, we save the Via "sent-by" address 1339 * from the response. 1340 */ 1341 if (acc->cfg.allow_via_rewrite && 1342 (acc->via_addr.host.slen == 0 || acc->via_tp != tp)) 1343 { 1344 via = param->rdata->msg_info.via; 1345 if (pj_strcmp(&acc->via_addr.host, &via->sent_by.host)) 1346 pj_strdup(acc->pool, &acc->via_addr.host, &via->sent_by.host); 1347 acc->via_addr.port = via->sent_by.port; 1348 acc->via_tp = tp; 1349 } 1316 1350 1317 1351 /* Only update if account is configured to auto-update */ … … 2177 2211 2178 2212 if (status == PJ_SUCCESS) { 2213 if (pjsua_var.acc[acc_id].cfg.allow_via_rewrite && 2214 pjsua_var.acc[acc_id].via_addr.host.slen > 0) 2215 { 2216 pjsip_regc_set_via_sent_by(pjsua_var.acc[acc_id].regc, 2217 &pjsua_var.acc[acc_id].via_addr, 2218 pjsua_var.acc[acc_id].via_tp); 2219 } 2220 2179 2221 //pjsua_process_msg_data(tdata, NULL); 2180 2222 status = pjsip_regc_send( pjsua_var.acc[acc_id].regc, tdata ); … … 2540 2582 pjsua_init_tpselector(acc->cfg.transport_id, &tp_sel); 2541 2583 pjsip_tx_data_set_transport(tdata, &tp_sel); 2584 } 2585 2586 /* If via_addr is set, use this address for the Via header. */ 2587 if (pjsua_var.acc[acc_id].cfg.allow_via_rewrite && 2588 pjsua_var.acc[acc_id].via_addr.host.slen > 0) 2589 { 2590 tdata->via_addr = pjsua_var.acc[acc_id].via_addr; 2591 tdata->via_tp = pjsua_var.acc[acc_id].via_tp; 2542 2592 } 2543 2593 -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_call.c
r4164 r4173 716 716 pjsip_dlg_inc_lock(dlg); 717 717 718 if (acc->cfg.allow_via_rewrite && acc->via_addr.host.slen > 0) 719 pjsip_dlg_set_via_sent_by(dlg, &acc->via_addr, acc->via_tp); 720 718 721 /* Calculate call's secure level */ 719 722 call->secure_level = get_secure_level(acc_id, dest_uri); … … 1169 1172 NULL, NULL); 1170 1173 goto on_return; 1174 } 1175 1176 if (pjsua_var.acc[acc_id].cfg.allow_via_rewrite && 1177 pjsua_var.acc[acc_id].via_addr.host.slen > 0) 1178 { 1179 pjsip_dlg_set_via_sent_by(dlg, &pjsua_var.acc[acc_id].via_addr, 1180 pjsua_var.acc[acc_id].via_tp); 1171 1181 } 1172 1182 -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c
r4172 r4173 212 212 cfg->transport_id = PJSUA_INVALID_ID; 213 213 cfg->allow_contact_rewrite = PJ_TRUE; 214 cfg->allow_via_rewrite = PJ_TRUE; 214 215 cfg->require_100rel = pjsua_var.ua_cfg.require_100rel; 215 216 cfg->use_timer = pjsua_var.ua_cfg.use_timer; -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_im.c
r3553 r4173 602 602 pjsua_set_msg_route_set(tdata, &acc->route_set); 603 603 604 /* If via_addr is set, use this address for the Via header. */ 605 if (acc->cfg.allow_via_rewrite && acc->via_addr.host.slen > 0) { 606 tdata->via_addr = acc->via_addr; 607 tdata->via_tp = acc->via_tp; 608 } 609 604 610 /* Send request (statefully) */ 605 611 status = pjsip_endpt_send_request( pjsua_var.endpt, tdata, -1, … … 685 691 pjsua_set_msg_route_set(tdata, &acc->route_set); 686 692 693 /* If via_addr is set, use this address for the Via header. */ 694 if (acc->cfg.allow_via_rewrite && acc->via_addr.host.slen > 0) { 695 tdata->via_addr = acc->via_addr; 696 tdata->via_tp = acc->via_tp; 697 } 698 687 699 /* Create data to reauthenticate */ 688 700 im_data = PJ_POOL_ZALLOC_T(tdata->pool, pjsua_im_data); -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_pres.c
r4172 r4173 865 865 } 866 866 867 if (acc->cfg.allow_via_rewrite && acc->via_addr.host.slen > 0) 868 pjsip_dlg_set_via_sent_by(dlg, &acc->via_addr, acc->via_tp); 869 867 870 /* Set credentials and preference. */ 868 871 pjsip_auth_clt_set_credentials(&dlg->auth_sess, acc->cred_cnt, acc->cred); … … 1229 1232 /* Add headers etc */ 1230 1233 pjsua_process_msg_data(tdata, NULL); 1234 1235 /* Set Via sent-by */ 1236 if (acc->cfg.allow_via_rewrite && acc->via_addr.host.slen > 0) { 1237 pjsip_publishc_set_via_sent_by(acc->publish_sess, &acc->via_addr, 1238 acc->via_tp); 1239 } 1231 1240 1232 1241 /* Send the PUBLISH request */ … … 1781 1790 pjsip_dlg_inc_lock(buddy->dlg); 1782 1791 1792 if (acc->cfg.allow_via_rewrite && acc->via_addr.host.slen > 0) 1793 pjsip_dlg_set_via_sent_by(buddy->dlg, &acc->via_addr, acc->via_tp); 1794 1783 1795 status = pjsip_pres_create_uac( buddy->dlg, &pres_callback, 1784 1796 PJSIP_EVSUB_NO_EVENT_ID, &buddy->sub); … … 2097 2109 */ 2098 2110 pjsip_dlg_inc_lock(acc->mwi_dlg); 2111 2112 if (acc->cfg.allow_via_rewrite && acc->via_addr.host.slen > 0) 2113 pjsip_dlg_set_via_sent_by(acc->mwi_dlg, &acc->via_addr, acc->via_tp); 2099 2114 2100 2115 /* Create UAC subscription */
Note: See TracChangeset
for help on using the changeset viewer.