- Timestamp:
- Aug 5, 2009 6:41:23 PM (15 years ago)
- Location:
- pjproject/trunk/pjsip
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/include/pjsip-ua/sip_regc.h
r2394 r2855 167 167 * be a SIP/SIPS URL. 168 168 * @param ccnt Number of contacts in the array. 169 * @param contact Array of contacts. 169 * @param contact Array of contacts, each contact item must be formatted 170 * as described in RFC 3261 Section 20.10: 171 * When the header field value contains a display 172 * name, the URI including all URI parameters is 173 * enclosed in "<" and ">". If no "<" and ">" are 174 * present, all parameters after the URI are header 175 * parameters, not URI parameters. The display name 176 * can be tokens, or a quoted string, if a larger 177 * character set is desired. 170 178 * @param expires Default expiration interval (in seconds) to be applied for 171 179 * contact URL that doesn't have expiration settings. If the … … 304 312 /** 305 313 * Update Contact details in the client registration structure. For each 306 * contact URI, if the uriis not found in existing contact, it will be307 * added to the Contact list. If the URImatches existing contact, nothing314 * contact, if the contact is not found in existing contact, it will be 315 * added to the Contact list. If it matches existing contact, nothing 308 316 * will be added. This function will also mark existing contacts which 309 317 * are not specified in the new contact list as to be removed, by adding … … 318 326 * @param regc The client registration structure. 319 327 * @param ccnt Number of contacts. 320 * @param contact Array of contact URIs. 328 * @param contact Array of contacts, each contact item must be formatted 329 * as described in RFC 3261 Section 20.10: 330 * When the header field value contains a display 331 * name, the URI including all URI parameters is 332 * enclosed in "<" and ">". If no "<" and ">" are 333 * present, all parameters after the URI are header 334 * parameters, not URI parameters. The display name 335 * can be tokens, or a quoted string, if a larger 336 * character set is desired. 321 337 * @return PJ_SUCCESS if sucessfull. 322 338 */ -
pjproject/trunk/pjsip/include/pjsip/sip_dialog.h
r2394 r2855 184 184 * @param ua The user agent module instance. 185 185 * @param local_uri Dialog local URI (i.e. From header). 186 * @param local_contact_uri Optional dialog local Contact URI. 187 * If this argument is NULL, the Contact will be 188 * taken from the local URI. 186 * @param local_contact Optional dialog local Contact to be put as Contact 187 * header value, hence the format must follow 188 * RFC 3261 Section 20.10: 189 * When the header field value contains a display 190 * name, the URI including all URI parameters is 191 * enclosed in "<" and ">". If no "<" and ">" are 192 * present, all parameters after the URI are header 193 * parameters, not URI parameters. The display name 194 * can be tokens, or a quoted string, if a larger 195 * character set is desired. 196 * If this argument is NULL, the Contact will be taken 197 * from the local URI. 189 198 * @param remote_uri Dialog remote URI (i.e. To header). 190 199 * @param target Optional initial remote target. If this argument … … 197 206 PJ_DECL(pj_status_t) pjsip_dlg_create_uac( pjsip_user_agent *ua, 198 207 const pj_str_t *local_uri, 199 const pj_str_t *local_contact _uri,208 const pj_str_t *local_contact, 200 209 const pj_str_t *remote_uri, 201 210 const pj_str_t *target, … … 221 230 * @param rdata The incoming request that creates the dialog, 222 231 * such as INVITE, SUBSCRIBE, or REFER. 223 * @param contact Optional URI to be used as local Contact. If 224 * this argument is NULL, the local contact will be 232 * @param contact Optional dialog local Contact to be put as Contact 233 * header value, hence the format must follow 234 * RFC 3261 Section 20.10: 235 * When the header field value contains a display 236 * name, the URI including all URI parameters is 237 * enclosed in "<" and ">". If no "<" and ">" are 238 * present, all parameters after the URI are header 239 * parameters, not URI parameters. The display name 240 * can be tokens, or a quoted string, if a larger 241 * character set is desired. 242 * If this argument is NULL, the local contact will be 225 243 * initialized from the value of To header in the 226 244 * request. -
pjproject/trunk/pjsip/include/pjsip/sip_util.h
r2394 r2855 244 244 * @param from URL to put in From header. 245 245 * @param to URL to put in To header. 246 * @param contact URL to put in Contact header. 246 * @param contact Contact to be put as Contact header value, hence 247 * the format must follow RFC 3261 Section 20.10: 248 * When the header field value contains a display 249 * name, the URI including all URI parameters is 250 * enclosed in "<" and ">". If no "<" and ">" are 251 * present, all parameters after the URI are header 252 * parameters, not URI parameters. The display name 253 * can be tokens, or a quoted string, if a larger 254 * character set is desired. 247 255 * @param call_id Optional Call-ID (put NULL to generate unique Call-ID). 248 256 * @param cseq Optional CSeq (put -1 to generate random CSeq). … … 281 289 * @param method SIP Method. 282 290 * @param target Target URI. 283 * @param from URL to put inFrom header.284 * @param to URL to put inTo header.285 * @param contact URL to put inContact header.291 * @param from From header. 292 * @param to To header. 293 * @param contact Contact header. 286 294 * @param call_id Optional Call-ID (put NULL to generate unique Call-ID). 287 295 * @param cseq Optional CSeq (put -1 to generate random CSeq). -
pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h
r2852 r2855 2164 2164 2165 2165 /** 2166 * Create a suitable URI to be put as Contact based on the specified2167 * target URIfor the specified account.2166 * Create a suitable Contact header value, based on the specified target URI 2167 * for the specified account. 2168 2168 * 2169 2169 * @param pool Pool to allocate memory for the string. 2170 * @param contact The string where the Contact URIwill be stored.2170 * @param contact The string where the Contact will be stored. 2171 2171 * @param acc_id Account ID. 2172 2172 * @param uri Destination URI of the request. … … 2182 2182 2183 2183 /** 2184 * Create a suitable URI to be put as Contact based on the information2185 * in the incoming request.2184 * Create a suitable Contact header value, based on the information in the 2185 * incoming request. 2186 2186 * 2187 2187 * @param pool Pool to allocate memory for the string. 2188 * @param contact The string where the Contact URIwill be stored.2188 * @param contact The string where the Contact will be stored. 2189 2189 * @param acc_id Account ID. 2190 2190 * @param rdata Incoming request. -
pjproject/trunk/pjsip/include/pjsua-lib/pjsua_internal.h
r2506 r2855 119 119 pj_str_t display; /**< Display name, if any. */ 120 120 pj_str_t user_part; /**< User part of local URI. */ 121 pj_str_t contact; /**< Our Contact URI for REGISTER*/121 pj_str_t contact; /**< Our Contact header. */ 122 122 123 123 pj_str_t srv_domain; /**< Host part of reg server. */ -
pjproject/trunk/pjsip/src/pjsip-ua/sip_reg.c
r2732 r2855 273 273 pjsip_parse_hdr(regc->pool, &CONTACT, tmp.ptr, tmp.slen, NULL); 274 274 if (hdr == NULL) { 275 PJ_LOG(4,(THIS_FILE, "Invalid Contact URI: \"%.*s\"",275 PJ_LOG(4,(THIS_FILE, "Invalid Contact: \"%.*s\"", 276 276 (int)tmp.slen, tmp.ptr)); 277 277 return PJSIP_EINVALIDURI; -
pjproject/trunk/pjsip/src/pjsip/sip_dialog.c
r2394 r2855 44 44 pj_bool_t pjsip_include_allow_hdr_in_dlg = PJSIP_INCLUDE_ALLOW_HDR_IN_DLG; 45 45 46 /* Contact header string */ 47 static const pj_str_t HCONTACT = { "Contact", 7 }; 46 48 47 49 PJ_DEF(pj_bool_t) pjsip_method_creates_dialog(const pjsip_method *m) … … 211 213 212 214 /* Init local contact. */ 213 dlg->local.contact = pjsip_contact_hdr_create(dlg->pool);214 215 pj_strdup_with_null(dlg->pool, &tmp, 215 216 local_contact ? local_contact : local_uri); 216 dlg->local.contact ->uri = pjsip_parse_uri(dlg->pool, tmp.ptr, tmp.slen,217 PJSIP_PARSE_URI_AS_NAMEADDR);218 if (!dlg->local.contact ->uri) {217 dlg->local.contact = pjsip_parse_hdr(dlg->pool, &HCONTACT, tmp.ptr, 218 tmp.slen, NULL); 219 if (!dlg->local.contact) { 219 220 status = PJSIP_EINVALIDURI; 220 221 goto on_error; … … 391 392 pj_str_t tmp; 392 393 393 dlg->local.contact = pjsip_contact_hdr_create(dlg->pool);394 394 pj_strdup_with_null(dlg->pool, &tmp, contact); 395 dlg->local.contact ->uri = pjsip_parse_uri(dlg->pool, tmp.ptr, tmp.slen,396 PJSIP_PARSE_URI_AS_NAMEADDR);397 if (!dlg->local.contact ->uri) {395 dlg->local.contact = pjsip_parse_hdr(dlg->pool, &HCONTACT, tmp.ptr, 396 tmp.slen, NULL); 397 if (!dlg->local.contact) { 398 398 status = PJSIP_EINVALIDURI; 399 399 goto on_error; … … 1226 1226 st_code==485) 1227 1227 { 1228 pj_str_t hcontact = { "Contact", 7 };1229 1230 1228 /* Add contact header only if one is not present. */ 1231 1229 if (pjsip_msg_find_hdr(tdata->msg, PJSIP_H_CONTACT, NULL) == 0 && 1232 pjsip_msg_find_hdr_by_name(tdata->msg, & hcontact, NULL) == 0)1230 pjsip_msg_find_hdr_by_name(tdata->msg, &HCONTACT, NULL) == 0) 1233 1231 { 1234 1232 hdr = (pjsip_hdr*) pjsip_hdr_clone(tdata->pool, -
pjproject/trunk/pjsip/src/pjsip/sip_util.c
r2766 r2855 308 308 pj_str_t tmp; 309 309 pj_status_t status; 310 const pj_str_t STR_CONTACT = { "Contact", 7 }; 310 311 PJ_USE_EXCEPTION; 311 312 … … 349 350 /* Contact. */ 350 351 if (param_contact) { 351 contact = pjsip_contact_hdr_create(tdata->pool);352 352 pj_strdup_with_null(tdata->pool, &tmp, param_contact); 353 contact->uri = pjsip_parse_uri( tdata->pool, tmp.ptr, tmp.slen, 354 PJSIP_PARSE_URI_AS_NAMEADDR); 355 if (contact->uri == NULL) { 353 contact = (pjsip_contact_hdr*) 354 pjsip_parse_hdr(tdata->pool, &STR_CONTACT, tmp.ptr, 355 tmp.slen, NULL); 356 if (contact == NULL) { 356 357 status = PJSIP_EINVALIDHDR; 357 358 goto on_error; -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_acc.c
r2852 r2855 574 574 pj_bool_t matched; 575 575 pj_str_t srv_ip; 576 pjsip_contact_hdr *contact_hdr; 577 const pj_str_t STR_CONTACT = { "Contact", 7 }; 576 578 577 579 tp = param->rdata->tp_info.transport; … … 620 622 /* Compare received and rport with the URI in our registration */ 621 623 pool = pjsua_pool_create("tmp", 512, 512); 622 uri = (pjsip_sip_uri*) 623 pjsip_parse_uri(pool, acc->contact.ptr, acc->contact.slen, 0); 624 contact_hdr = (pjsip_contact_hdr*) 625 pjsip_parse_hdr(pool, &STR_CONTACT, acc->contact.ptr, 626 acc->contact.slen, NULL); 627 pj_assert(contact_hdr != NULL); 628 uri = (pjsip_sip_uri*) contact_hdr->uri; 624 629 pj_assert(uri != NULL); 625 630 uri = (pjsip_sip_uri*) pjsip_uri_get_uri(uri); -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_im.c
r2651 r2855 510 510 pjsip_media_type media_type; 511 511 pjsua_im_data *im_data; 512 pjsua_acc *acc; 512 513 pj_str_t contact; 513 514 pj_status_t status; … … 515 516 /* To and message body must be specified. */ 516 517 PJ_ASSERT_RETURN(to && content, PJ_EINVAL); 518 519 acc = &pjsua_var.acc[acc_id]; 517 520 518 521 /* Create request. */ 519 522 status = pjsip_endpt_create_request(pjsua_var.endpt, 520 523 &pjsip_message_method, to, 521 & pjsua_var.acc[acc_id].cfg.id,524 &acc->cfg.id, 522 525 to, NULL, NULL, -1, NULL, &tdata); 523 526 if (status != PJ_SUCCESS) { … … 529 532 * the request. 530 533 */ 531 if ( pjsua_var.acc[acc_id].cfg.transport_id != PJSUA_INVALID_ID) {534 if (acc->cfg.transport_id != PJSUA_INVALID_ID) { 532 535 pjsip_tpselector tp_sel; 533 536 534 pjsua_init_tpselector( pjsua_var.acc[acc_id].cfg.transport_id, &tp_sel);537 pjsua_init_tpselector(acc->cfg.transport_id, &tp_sel); 535 538 pjsip_tx_data_set_transport(tdata, &tp_sel); 536 539 } … … 540 543 (pjsip_hdr*)pjsua_im_create_accept(tdata->pool)); 541 544 542 /* Add contact. */ 543 status = pjsua_acc_create_uac_contact(tdata->pool, &contact, acc_id, to); 544 if (status != PJ_SUCCESS) { 545 pjsua_perror(THIS_FILE, "Unable to generate Contact header", status); 546 pjsip_tx_data_dec_ref(tdata); 547 return status; 545 /* Create suitable Contact header unless a Contact header has been 546 * set in the account. 547 */ 548 if (acc->contact.slen) { 549 contact = acc->contact; 550 } else { 551 status = pjsua_acc_create_uac_contact(tdata->pool, &contact, acc_id, to); 552 if (status != PJ_SUCCESS) { 553 pjsua_perror(THIS_FILE, "Unable to generate Contact header", status); 554 pjsip_tx_data_dec_ref(tdata); 555 return status; 556 } 548 557 } 549 558 … … 585 594 586 595 /* Add route set */ 587 pjsua_set_msg_route_set(tdata, & pjsua_var.acc[acc_id].route_set);596 pjsua_set_msg_route_set(tdata, &acc->route_set); 588 597 589 598 /* Send request (statefully) */ … … 610 619 pjsua_im_data *im_data; 611 620 pjsip_tx_data *tdata; 621 pjsua_acc *acc; 612 622 pj_str_t contact; 613 623 pj_status_t status; 614 624 625 acc = &pjsua_var.acc[acc_id]; 626 615 627 /* Create request. */ 616 628 status = pjsip_endpt_create_request( pjsua_var.endpt, &pjsip_message_method, 617 to, & pjsua_var.acc[acc_id].cfg.id,629 to, &acc->cfg.id, 618 630 to, NULL, NULL, -1, NULL, &tdata); 619 631 if (status != PJ_SUCCESS) { … … 626 638 * the request. 627 639 */ 628 if ( pjsua_var.acc[acc_id].cfg.transport_id != PJSUA_INVALID_ID) {640 if (acc->cfg.transport_id != PJSUA_INVALID_ID) { 629 641 pjsip_tpselector tp_sel; 630 642 631 pjsua_init_tpselector( pjsua_var.acc[acc_id].cfg.transport_id, &tp_sel);643 pjsua_init_tpselector(acc->cfg.transport_id, &tp_sel); 632 644 pjsip_tx_data_set_transport(tdata, &tp_sel); 633 645 } … … 638 650 639 651 640 /* Add contact. */ 641 status = pjsua_acc_create_uac_contact(tdata->pool, &contact, acc_id, to); 642 if (status != PJ_SUCCESS) { 643 pjsua_perror(THIS_FILE, "Unable to generate Contact header", status); 644 pjsip_tx_data_dec_ref(tdata); 645 return status; 652 /* Create suitable Contact header unless a Contact header has been 653 * set in the account. 654 */ 655 if (acc->contact.slen) { 656 contact = acc->contact; 657 } else { 658 status = pjsua_acc_create_uac_contact(tdata->pool, &contact, acc_id, to); 659 if (status != PJ_SUCCESS) { 660 pjsua_perror(THIS_FILE, "Unable to generate Contact header", status); 661 pjsip_tx_data_dec_ref(tdata); 662 return status; 663 } 646 664 } 647 665 … … 659 677 660 678 /* Add route set */ 661 pjsua_set_msg_route_set(tdata, & pjsua_var.acc[acc_id].route_set);679 pjsua_set_msg_route_set(tdata, &acc->route_set); 662 680 663 681 /* Create data to reauthenticate */
Note: See TracChangeset
for help on using the changeset viewer.