Changeset 611
- Timestamp:
- Jul 18, 2006 12:33:02 AM (18 years ago)
- Location:
- pjproject/trunk/pjsip
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/include/pjsip/sip_transport.h
r563 r611 63 63 PJSIP_TRANSPORT_RELIABLE = 1, /**< Transport is reliable. */ 64 64 PJSIP_TRANSPORT_SECURE = 2, /**< Transport is secure. */ 65 PJSIP_TRANSPORT_DATAGRAM = 4, /**< Datagram based transport. */ 65 PJSIP_TRANSPORT_DATAGRAM = 4, /**< Datagram based transport. 66 (it's also assumed to be 67 connectionless) */ 66 68 }; 67 69 … … 787 789 788 790 /** 791 * Find out the appropriate local address info (IP address and port) to 792 * advertise in Contact header based on the remote address to be 793 * contacted. The local address info would be the address name of the 794 * transport or listener which will be used to send the request. 795 * 796 * In this implementation, it will only select the transport based on 797 * the transport type in the request. 798 * 799 * @param tpmgr The transport manager. 800 * @param pool Pool to allocate memory for the IP address. 801 * @param h Destination address to contact. 802 * @param ip_addr Pointer to receive the IP address. 803 * @param port Pointer to receive the port number. 804 * 805 * @return PJ_SUCCESS, or the appropriate error code. 806 */ 807 PJ_DECL(pj_status_t) pjsip_tpmgr_find_local_addr( pjsip_tpmgr *tpmgr, 808 pj_pool_t *pool, 809 pjsip_transport_type_e type, 810 pj_str_t *ip_addr, 811 int *port); 812 813 814 /** 789 815 * Destroy transport manager. 790 816 */ -
pjproject/trunk/pjsip/include/pjsip/sip_uri.h
r515 r611 360 360 * Create new SIP URL and initialize all fields with zero or NULL. 361 361 * @param pool The pool. 362 * @param secure Tlag to indicate whether secure transport should be used.362 * @param secure Flag to indicate whether secure transport should be used. 363 363 * @return SIP URL. 364 364 */ 365 PJ_DECL(pjsip_sip_uri*) pjsip_sip_uri_create( pj_pool_t *pool, int secure ); 366 367 /** 368 * Create new SIPS URL and initialize all fields with zero or NULL. 369 * @param pool The pool. 370 * @return SIPS URL. 371 */ 372 PJ_DECL(pjsip_sip_uri*) pjsip_sips_uri_create( pj_pool_t *pool ); 365 PJ_DECL(pjsip_sip_uri*) pjsip_sip_uri_create( pj_pool_t *pool, 366 pj_bool_t secure ); 367 368 /** 369 * Change the SIP URI scheme to sip or sips based on the secure flag. 370 * This would not change anything except the scheme. 371 * @param uri The URI 372 * @param secure Non-zero if sips is wanted. 373 */ 374 PJ_DECL(void) pjsip_sip_uri_set_secure( pjsip_sip_uri *uri, 375 pj_bool_t secure ); 373 376 374 377 /** … … 377 380 * @param secure Create sips URI? 378 381 */ 379 PJ_DECL(void) pjsip_sip_uri_init(pjsip_sip_uri *url, int secure);382 PJ_DECL(void) pjsip_sip_uri_init(pjsip_sip_uri *url, pj_bool_t secure); 380 383 381 384 /** -
pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h
r597 r611 1303 1303 PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_incoming(pjsip_rx_data *rdata); 1304 1304 1305 1306 /** 1307 * Create a suitable URI to be put as Contact based on the specified 1308 * target URI for the specified account. 1309 * 1310 * @param pool Pool to allocate memory for the string. 1311 * @param contact The string where the Contact URI will be stored. 1312 * @param acc_id Account ID. 1313 * @param uri Destination URI of the request. 1314 * 1315 * @return PJ_SUCCESS on success, other on error. 1316 */ 1317 PJ_DECL(pj_status_t) pjsua_acc_create_uac_contact( pj_pool_t *pool, 1318 pj_str_t *contact, 1319 pjsua_acc_id acc_id, 1320 const pj_str_t *uri); 1321 1322 1323 1324 /** 1325 * Create a suitable URI to be put as Contact based on the information 1326 * in the incoming request. 1327 * 1328 * @param pool Pool to allocate memory for the string. 1329 * @param contact The string where the Contact URI will be stored. 1330 * @param acc_id Account ID. 1331 * @param rdata Incoming request. 1332 * 1333 * @return PJ_SUCCESS on success, other on error. 1334 */ 1335 PJ_DECL(pj_status_t) pjsua_acc_create_uas_contact( pj_pool_t *pool, 1336 pj_str_t *contact, 1337 pjsua_acc_id acc_id, 1338 pjsip_rx_data *rdata ); 1339 1305 1340 1306 1341 -
pjproject/trunk/pjsip/include/pjsua-lib/pjsua_internal.h
r597 r611 80 80 81 81 int index; /**< Index in accounts array. */ 82 pj_str_t display; /**< Display name, if any. */ 82 83 pj_str_t user_part; /**< User part of local URI. */ 83 pj_str_t real_contact; /**< Real contact address. */84 84 85 85 pj_str_t srv_domain; /**< Host part of reg server. */ -
pjproject/trunk/pjsip/src/pjsip/sip_transport.c
r600 r611 82 82 }; 83 83 84 /* Key for looking up hash table */ 85 struct transport_key 86 { 87 pjsip_transport_type_e type; 88 pj_sockaddr addr; 89 }; 90 84 91 /***************************************************************************** 85 92 * … … 818 825 } 819 826 827 828 829 /* 830 * Find out the appropriate local address info (IP address and port) to 831 * advertise in Contact header based on the remote address to be 832 * contacted. The local address info would be the address name of the 833 * transport or listener which will be used to send the request. 834 * 835 * In this implementation, it will only select the transport based on 836 * the transport type in the request. 837 */ 838 PJ_DEF(pj_status_t) pjsip_tpmgr_find_local_addr( pjsip_tpmgr *tpmgr, 839 pj_pool_t *pool, 840 pjsip_transport_type_e type, 841 pj_str_t *ip_addr, 842 int *port) 843 { 844 pj_status_t status = PJSIP_EUNSUPTRANSPORT; 845 unsigned flag; 846 847 /* Sanity checks */ 848 PJ_ASSERT_RETURN(tpmgr && pool && ip_addr && port, PJ_EINVAL); 849 850 ip_addr->slen = 0; 851 *port = 0; 852 853 flag = pjsip_transport_get_flag_from_type(type); 854 855 if ((flag & PJSIP_TRANSPORT_DATAGRAM) != 0) { 856 857 pj_sockaddr_in remote; 858 pjsip_transport *tp; 859 860 pj_sockaddr_in_init(&remote, NULL, 0); 861 status = pjsip_tpmgr_acquire_transport(tpmgr, type, &remote, 862 sizeof(remote), &tp); 863 864 if (status == PJ_SUCCESS) { 865 pj_strdup(pool, ip_addr, &tp->local_name.host); 866 *port = tp->local_name.port; 867 status = PJ_SUCCESS; 868 869 pjsip_transport_dec_ref(tp); 870 } 871 872 } else { 873 /* For connection oriented transport, enum the factories */ 874 pjsip_tpfactory *f; 875 876 pj_lock_acquire(tpmgr->lock); 877 878 f = tpmgr->factory_list.next; 879 while (f != &tpmgr->factory_list) { 880 if (f->type == type) 881 break; 882 f = f->next; 883 } 884 885 if (f != &tpmgr->factory_list) { 886 pj_strdup(pool, ip_addr, &f->addr_name.host); 887 *port = f->addr_name.port; 888 status = PJ_SUCCESS; 889 } 890 pj_lock_release(tpmgr->lock); 891 } 892 893 return PJ_SUCCESS; 894 } 895 896 820 897 /* 821 898 * pjsip_tpmgr_destroy() … … 1062 1139 pjsip_transport **tp) 1063 1140 { 1064 struct transport_key 1065 { 1066 pjsip_transport_type_e type; 1067 pj_sockaddr addr; 1068 } key; 1141 struct transport_key key; 1069 1142 int key_len; 1070 1143 pjsip_transport *transport; -
pjproject/trunk/pjsip/src/pjsip/sip_uri.c
r583 r611 207 207 } 208 208 209 PJ_DEF(void) pjsip_sip_uri_init(pjsip_sip_uri *url, int secure) 209 PJ_DEF(void) pjsip_sip_uri_set_secure( pjsip_sip_uri *url, 210 pj_bool_t secure ) 211 { 212 url->vptr = secure ? &sips_url_vptr : &sip_url_vptr; 213 } 214 215 PJ_DEF(void) pjsip_sip_uri_init(pjsip_sip_uri *url, pj_bool_t secure) 210 216 { 211 217 pj_bzero(url, sizeof(*url)); 212 218 url->ttl_param = -1; 213 url->vptr = secure ? &sips_url_vptr : &sip_url_vptr;219 pjsip_sip_uri_set_secure(url, secure); 214 220 pj_list_init(&url->other_param); 215 221 pj_list_init(&url->header_param); 216 222 } 217 223 218 PJ_DEF(pjsip_sip_uri*) pjsip_sip_uri_create( pj_pool_t *pool, int secure ) 224 PJ_DEF(pjsip_sip_uri*) pjsip_sip_uri_create( pj_pool_t *pool, 225 pj_bool_t secure ) 219 226 { 220 227 pjsip_sip_uri *url = pj_pool_alloc(pool, sizeof(pjsip_sip_uri)); -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_acc.c
r597 r611 72 72 73 73 /* 74 * Update account's real contact address.75 */76 static void update_acc_contact(unsigned acc_id,77 unsigned tp_id)78 {79 pjsua_acc *acc = &pjsua_var.acc[acc_id];80 struct transport_data *t = &pjsua_var.tpdata[tp_id];81 char uri[80];82 83 /* Transport must be valid */84 pj_assert(t->data.ptr != NULL);85 86 /* Build URI for the account */87 pj_ansi_sprintf(uri, "<sip:%.*s:%d;transport=%s>",88 (int)t->local_name.host.slen,89 t->local_name.host.ptr,90 t->local_name.port,91 pjsip_transport_get_type_name(t->type));92 93 94 pj_strdup2(pjsua_var.pool, &acc->real_contact, uri);95 }96 97 98 /*99 74 * Initialize a new account (after configuration is set). 100 75 */ … … 103 78 pjsua_acc_config *acc_cfg = &pjsua_var.acc[acc_id].cfg; 104 79 pjsua_acc *acc = &pjsua_var.acc[acc_id]; 105 pjsip_ uri *uri;80 pjsip_name_addr *name_addr; 106 81 pjsip_sip_uri *sip_uri, *sip_reg_uri; 107 82 unsigned i; … … 109 84 /* Need to parse local_uri to get the elements: */ 110 85 111 uri = pjsip_parse_uri(pjsua_var.pool, acc_cfg->id.ptr, 112 acc_cfg->id.slen, 0); 113 if (uri == NULL) { 86 name_addr = (pjsip_name_addr*) 87 pjsip_parse_uri(pjsua_var.pool, acc_cfg->id.ptr, 88 acc_cfg->id.slen, 89 PJSIP_PARSE_URI_AS_NAMEADDR); 90 if (name_addr == NULL) { 114 91 pjsua_perror(THIS_FILE, "Invalid local URI", 115 92 PJSIP_EINVALIDURI); … … 119 96 /* Local URI MUST be a SIP or SIPS: */ 120 97 121 if (!PJSIP_URI_SCHEME_IS_SIP( uri) &&122 !PJSIP_URI_SCHEME_IS_SIPS( uri))98 if (!PJSIP_URI_SCHEME_IS_SIP(name_addr) && 99 !PJSIP_URI_SCHEME_IS_SIPS(name_addr)) 123 100 { 124 101 pjsua_perror(THIS_FILE, "Invalid local URI", … … 129 106 130 107 /* Get the SIP URI object: */ 131 sip_uri = (pjsip_sip_uri*) pjsip_uri_get_uri( uri);108 sip_uri = (pjsip_sip_uri*) pjsip_uri_get_uri(name_addr); 132 109 133 110 … … 163 140 * account for incoming requests. 164 141 */ 142 acc->display = name_addr->display; 165 143 acc->user_part = sip_uri->user; 166 144 acc->srv_domain = sip_uri->host; … … 175 153 // acc_cfg->contact = acc_cfg->id; 176 154 //} 177 178 PJ_TODO(attach_account_to_transport);179 if (pjsua_var.tpdata[0].data.ptr)180 update_acc_contact(acc_id, 0);181 155 182 156 /* Build account route-set from outbound proxies and route set from … … 377 351 { 378 352 PJ_TODO(pjsua_acc_modify); 353 PJ_UNUSED_ARG(acc_id); 354 PJ_UNUSED_ARG(cfg); 379 355 return PJ_EINVALIDOP; 380 356 } … … 462 438 { 463 439 pjsua_acc *acc; 440 pj_str_t contact; 464 441 pj_status_t status; 465 442 … … 482 459 } 483 460 461 status = pjsua_acc_create_uac_contact( pjsua_var.pool, &contact, 462 acc_id, &acc->cfg.reg_uri); 463 if (status != PJ_SUCCESS) { 464 pjsua_perror(THIS_FILE, "Unable to generate suitable Contact header" 465 " for registration", 466 status); 467 return status; 468 } 469 484 470 status = pjsip_regc_init( acc->regc, 485 471 &acc->cfg.reg_uri, 486 472 &acc->cfg.id, 487 473 &acc->cfg.id, 488 1, & acc->real_contact,474 1, &contact, 489 475 acc->cfg.reg_timeout); 490 476 if (status != PJ_SUCCESS) { … … 823 809 } 824 810 811 812 PJ_DEF(pj_status_t) pjsua_acc_create_uac_contact( pj_pool_t *pool, 813 pj_str_t *contact, 814 pjsua_acc_id acc_id, 815 const pj_str_t *suri) 816 { 817 pjsua_acc *acc; 818 pjsip_sip_uri *sip_uri; 819 pj_status_t status; 820 pjsip_transport_type_e tp_type = PJSIP_TRANSPORT_UNSPECIFIED; 821 pj_str_t local_addr; 822 unsigned flag; 823 int secure; 824 int local_port; 825 826 acc = &pjsua_var.acc[acc_id]; 827 828 /* If route-set is configured for the account, then URI is the 829 * first entry of the route-set. 830 */ 831 if (!pj_list_empty(&acc->route_set)) { 832 sip_uri = (pjsip_sip_uri*) acc->route_set.next->name_addr.uri; 833 } else { 834 pj_str_t tmp; 835 pjsip_uri *uri; 836 837 pj_strdup_with_null(pool, &tmp, suri); 838 839 uri = pjsip_parse_uri(pool, tmp.ptr, tmp.slen, 0); 840 if (uri == NULL) 841 return PJSIP_EINVALIDURI; 842 843 /* For non-SIP scheme, route set should be configured */ 844 if (!PJSIP_URI_SCHEME_IS_SIP(uri) && !PJSIP_URI_SCHEME_IS_SIPS(uri)) 845 return PJSIP_EINVALIDREQURI; 846 847 sip_uri = (pjsip_sip_uri*)uri; 848 } 849 850 /* Get transport type of the URI */ 851 if (PJSIP_URI_SCHEME_IS_SIPS(sip_uri)) 852 tp_type = PJSIP_TRANSPORT_TLS; 853 else if (sip_uri->transport_param.slen == 0) { 854 tp_type = PJSIP_TRANSPORT_UDP; 855 } else 856 tp_type = pjsip_transport_get_type_from_name(&sip_uri->transport_param); 857 858 if (tp_type == PJSIP_TRANSPORT_UNSPECIFIED) 859 return PJSIP_EUNSUPTRANSPORT; 860 861 flag = pjsip_transport_get_flag_from_type(tp_type); 862 secure = (flag & PJSIP_TRANSPORT_SECURE) != 0; 863 864 /* Get local address suitable to send request from */ 865 status = pjsip_tpmgr_find_local_addr(pjsip_endpt_get_tpmgr(pjsua_var.endpt), 866 pool, tp_type, &local_addr, &local_port); 867 if (status != PJ_SUCCESS) 868 return status; 869 870 /* Create the contact header */ 871 contact->ptr = pj_pool_alloc(pool, PJSIP_MAX_URL_SIZE); 872 contact->slen = pj_ansi_snprintf(contact->ptr, PJSIP_MAX_URL_SIZE, 873 "%.*s%s<%s:%.*s%s%.*s:%d;transport=%s>", 874 (int)acc->display.slen, 875 acc->display.ptr, 876 (acc->display.slen?" " : ""), 877 (secure ? "sips" : "sip"), 878 (int)acc->user_part.slen, 879 acc->user_part.ptr, 880 (acc->user_part.slen?"@":""), 881 (int)local_addr.slen, 882 local_addr.ptr, 883 local_port, 884 pjsip_transport_get_type_name(tp_type)); 885 886 return PJ_SUCCESS; 887 } 888 889 890 891 PJ_DEF(pj_status_t) pjsua_acc_create_uas_contact( pj_pool_t *pool, 892 pj_str_t *contact, 893 pjsua_acc_id acc_id, 894 pjsip_rx_data *rdata ) 895 { 896 /* 897 * Section 12.1.1, paragraph about using SIPS URI in Contact. 898 * If the request that initiated the dialog contained a SIPS URI 899 * in the Request-URI or in the top Record-Route header field value, 900 * if there was any, or the Contact header field if there was no 901 * Record-Route header field, the Contact header field in the response 902 * MUST be a SIPS URI. 903 */ 904 pjsua_acc *acc; 905 pjsip_sip_uri *sip_uri; 906 pj_status_t status; 907 pjsip_transport_type_e tp_type = PJSIP_TRANSPORT_UNSPECIFIED; 908 pj_str_t local_addr; 909 unsigned flag; 910 int secure; 911 int local_port; 912 913 acc = &pjsua_var.acc[acc_id]; 914 915 /* If Record-Route is present, then URI is the top Record-Route. */ 916 if (rdata->msg_info.record_route) { 917 sip_uri = (pjsip_sip_uri*) rdata->msg_info.record_route->name_addr.uri; 918 } else { 919 pjsip_contact_hdr *h_contact; 920 pjsip_uri *uri = NULL; 921 922 /* Otherwise URI is Contact URI */ 923 h_contact = pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_CONTACT, 924 NULL); 925 if (h_contact) 926 uri = pjsip_uri_get_uri(h_contact->uri); 927 928 929 /* Or if Contact URI is not present, take the remote URI from 930 * the From URI. 931 */ 932 if (uri == NULL) 933 uri = pjsip_uri_get_uri(rdata->msg_info.from->uri); 934 935 936 /* Can only do sip/sips scheme at present. */ 937 if (!PJSIP_URI_SCHEME_IS_SIP(uri) && !PJSIP_URI_SCHEME_IS_SIPS(uri)) 938 return PJSIP_EINVALIDREQURI; 939 940 sip_uri = (pjsip_sip_uri*)uri; 941 } 942 943 /* Get transport type of the URI */ 944 if (PJSIP_URI_SCHEME_IS_SIPS(sip_uri)) 945 tp_type = PJSIP_TRANSPORT_TLS; 946 else if (sip_uri->transport_param.slen == 0) { 947 tp_type = PJSIP_TRANSPORT_UDP; 948 } else 949 tp_type = pjsip_transport_get_type_from_name(&sip_uri->transport_param); 950 951 if (tp_type == PJSIP_TRANSPORT_UNSPECIFIED) 952 return PJSIP_EUNSUPTRANSPORT; 953 954 flag = pjsip_transport_get_flag_from_type(tp_type); 955 secure = (flag & PJSIP_TRANSPORT_SECURE) != 0; 956 957 /* Get local address suitable to send request from */ 958 status = pjsip_tpmgr_find_local_addr(pjsip_endpt_get_tpmgr(pjsua_var.endpt), 959 pool, tp_type, &local_addr, &local_port); 960 if (status != PJ_SUCCESS) 961 return status; 962 963 /* Create the contact header */ 964 contact->ptr = pj_pool_alloc(pool, PJSIP_MAX_URL_SIZE); 965 contact->slen = pj_ansi_snprintf(contact->ptr, PJSIP_MAX_URL_SIZE, 966 "%.*s%s<%s:%.*s%s%.*s:%d;transport=%s>", 967 (int)acc->display.slen, 968 acc->display.ptr, 969 (acc->display.slen?" " : ""), 970 (secure ? "sips" : "sip"), 971 (int)acc->user_part.slen, 972 acc->user_part.ptr, 973 (acc->user_part.slen?"@":""), 974 (int)local_addr.slen, 975 local_addr.ptr, 976 local_port, 977 pjsip_transport_get_type_name(tp_type)); 978 979 return PJ_SUCCESS; 980 } 981 982 983 -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_call.c
r597 r611 192 192 pjsua_call *call; 193 193 unsigned call_id; 194 pj_str_t contact; 194 195 pjsip_tx_data *tdata; 195 196 pj_status_t status; … … 233 234 call->res_time.sec = 0; 234 235 236 /* Create suitable Contact header */ 237 status = pjsua_acc_create_uac_contact(pjsua_var.pool, &contact, 238 acc_id, dest_uri); 239 if (status != PJ_SUCCESS) { 240 pjsua_perror(THIS_FILE, "Unable to generate Contact header", status); 241 PJSUA_UNLOCK(); 242 return status; 243 } 244 235 245 /* Create outgoing dialog: */ 236 246 status = pjsip_dlg_create_uac( pjsip_ua_instance(), 237 &acc->cfg.id, & acc->real_contact,247 &acc->cfg.id, &contact, 238 248 dest_uri, dest_uri, &dlg); 239 249 if (status != PJ_SUCCESS) { … … 346 356 pj_bool_t pjsua_call_on_incoming(pjsip_rx_data *rdata) 347 357 { 358 pj_str_t contact; 348 359 pjsip_dialog *dlg = pjsip_rdata_get_dlg(rdata); 349 360 pjsip_transaction *tsx = pjsip_rdata_get_tsx(rdata); … … 440 451 acc_id = pjsua_acc_find_for_incoming(rdata); 441 452 453 /* Get suitable Contact header */ 454 status = pjsua_acc_create_uas_contact(rdata->tp_info.pool, &contact, 455 acc_id, rdata); 456 if (status != PJ_SUCCESS) { 457 pjsua_perror(THIS_FILE, "Unable to generate Contact header", status); 458 pjsip_endpt_respond_stateless(pjsua_var.endpt, rdata, 500, NULL, 459 NULL, NULL); 460 return PJ_TRUE; 461 } 462 442 463 /* Create dialog: */ 443 464 status = pjsip_dlg_create_uas( pjsip_ua_instance(), rdata, 444 &pjsua_var.acc[acc_id].real_contact, 445 &dlg); 465 &contact, &dlg); 446 466 if (status != PJ_SUCCESS) { 447 467 pjsip_endpt_respond_stateless(pjsua_var.endpt, rdata, 500, NULL, … … 922 942 923 943 /* Create SDP */ 944 PJ_TODO(create_active_inactive_sdp_based_on_unhold_arg); 924 945 status = pjmedia_endpt_create_sdp( pjsua_var.med_endpt, call->inv->pool, 925 946 1, &call->skinfo, &sdp); -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c
r597 r611 987 987 /* To be done!! */ 988 988 PJ_TODO(pjsua_transport_set_enable); 989 PJ_UNUSED_ARG(enabled); 989 990 990 991 return PJ_EINVALIDOP; -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_im.c
r597 r611 418 418 pjsip_media_type media_type; 419 419 pjsua_im_data *im_data; 420 pj_str_t contact; 420 421 pj_status_t status; 421 422 … … 438 439 439 440 /* Add contact. */ 441 status = pjsua_acc_create_uac_contact(tdata->pool, &contact, acc_id, to); 442 if (status != PJ_SUCCESS) { 443 pjsua_perror(THIS_FILE, "Unable to generate Contact header", status); 444 pjsip_tx_data_dec_ref(tdata); 445 return status; 446 } 447 440 448 pjsip_msg_add_hdr( tdata->msg, (pjsip_hdr*) 441 449 pjsip_generic_string_hdr_create(tdata->pool, 442 &STR_CONTACT, 443 &pjsua_var.acc[acc_id].real_contact)); 450 &STR_CONTACT, &contact)); 444 451 445 452 /* Create IM data to keep message details and give it back to … … 501 508 pjsua_im_data *im_data; 502 509 pjsip_tx_data *tdata; 510 pj_str_t contact; 503 511 pj_status_t status; 504 512 … … 519 527 520 528 /* Add contact. */ 529 status = pjsua_acc_create_uac_contact(tdata->pool, &contact, acc_id, to); 530 if (status != PJ_SUCCESS) { 531 pjsua_perror(THIS_FILE, "Unable to generate Contact header", status); 532 pjsip_tx_data_dec_ref(tdata); 533 return status; 534 } 535 521 536 pjsip_msg_add_hdr( tdata->msg, (pjsip_hdr*) 522 537 pjsip_generic_string_hdr_create(tdata->pool, 523 &STR_CONTACT, 524 &pjsua_var.acc[acc_id].real_contact)); 538 &STR_CONTACT, &contact)); 525 539 526 540 -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_pres.c
r597 r611 441 441 int acc_id; 442 442 pjsua_acc *acc; 443 pj_str_t contact; 443 444 pjsip_method *req_method = &rdata->msg_info.msg->line.req.method; 444 445 pjsua_srv_pres *uapres; … … 464 465 acc_id)); 465 466 467 /* Create suitable Contact header */ 468 status = pjsua_acc_create_uas_contact(rdata->tp_info.pool, &contact, 469 acc_id, rdata); 470 if (status != PJ_SUCCESS) { 471 pjsua_perror(THIS_FILE, "Unable to generate Contact header", status); 472 PJSUA_UNLOCK(); 473 return PJ_TRUE; 474 } 475 466 476 /* Create UAS dialog: */ 467 477 status = pjsip_dlg_create_uas(pjsip_ua_instance(), rdata, 468 &acc->real_contact, 469 &dlg); 478 &contact, &dlg); 470 479 if (status != PJ_SUCCESS) { 471 480 pjsua_perror(THIS_FILE, … … 762 771 int acc_id; 763 772 pjsua_acc *acc; 773 pj_str_t contact; 764 774 pjsip_dialog *dlg; 765 775 pjsip_tx_data *tdata; … … 774 784 acc_id, index)); 775 785 786 /* Generate suitable Contact header */ 787 status = pjsua_acc_create_uac_contact(pjsua_var.pool, &contact, 788 acc_id, &buddy->uri); 789 if (status != PJ_SUCCESS) { 790 pjsua_perror(THIS_FILE, "Unable to generate Contact header", status); 791 return; 792 } 793 776 794 /* Create UAC dialog */ 777 795 status = pjsip_dlg_create_uac( pjsip_ua_instance(), 778 796 &acc->cfg.id, 779 & acc->real_contact,797 &contact, 780 798 &buddy->uri, 781 799 NULL, &dlg);
Note: See TracChangeset
for help on using the changeset viewer.