Changeset 1547 for pjproject/trunk
- Timestamp:
- Nov 4, 2007 2:05:13 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsip-ua/sip_reg.c
r1518 r1547 683 683 pjsip_contact_hdr *contact[PJSIP_REGC_MAX_CONTACT]; 684 684 pjsip_rx_data *rdata; 685 pj_int32_t expiration = 0xFFFF; 685 enum { NOEXP = 0x1FFFFFFF }; 686 pj_int32_t expiration = NOEXP; 686 687 687 688 if (tsx->status_code/100 == 2) { … … 689 690 pjsip_contact_hdr *hdr; 690 691 pjsip_msg *msg; 692 pj_bool_t has_our_contact = PJ_FALSE; 691 693 pjsip_expires_hdr *expires; 692 694 693 695 rdata = event->body.tsx_state.src.rdata; 694 696 msg = rdata->msg_info.msg; 697 698 /* Record all Contact headers in the response */ 695 699 hdr = (pjsip_contact_hdr*) 696 700 pjsip_msg_find_hdr( msg, PJSIP_H_CONTACT, NULL); … … 704 708 } 705 709 710 /* Set default expiration value to the value of Expires hdr */ 706 711 expires = (pjsip_expires_hdr*) 707 712 pjsip_msg_find_hdr(msg, PJSIP_H_EXPIRES, NULL); … … 710 715 expiration = expires->ivalue; 711 716 717 /* Enumerate all Contact headers found in the response and 718 * find the Contact(s) that we register. 719 */ 712 720 for (i=0; i<contact_cnt; ++i) { 713 hdr = contact[i]; 714 if (hdr->expires >= 0 && hdr->expires < expiration) { 715 pjsip_contact_hdr *our_contact; 721 pjsip_contact_hdr *our_contact; 722 723 our_contact = (pjsip_contact_hdr*) 724 regc->contact_hdr_list.next; 725 726 while ((void*)our_contact != (void*)®c->contact_hdr_list) { 727 716 728 const pjsip_uri *uri1, *uri2; 717 729 718 our_contact = (pjsip_contact_hdr*) 719 regc->contact_hdr_list.next; 720 if ((void*)our_contact==(void*)®c->contact_hdr_list.next) 721 continue; 722 723 /* Only set expiration time if this is the same Contact 724 * that we register. 730 /* Compare URIs. 731 * Exclude the display name when comparing the URI since 732 * server may not return it. 725 733 */ 726 734 727 /* Exclude the display name when comparing the URI. 728 * This is because a well known open source proxy server 729 * doesn't return the display name in the Contact header 730 * of the REGISTER response. 731 */ 732 uri1 = pjsip_uri_get_uri(hdr->uri); 735 uri1 = pjsip_uri_get_uri(contact[i]->uri); 733 736 uri2 = pjsip_uri_get_uri(our_contact->uri); 734 737 if (pjsip_uri_cmp(PJSIP_URI_IN_CONTACT_HDR, uri1, uri2)==0) 735 738 { 736 expiration = contact[i]->expires; 739 has_our_contact = PJ_TRUE; 740 741 if (contact[i]->expires >= 0 && 742 contact[i]->expires < expiration) 743 { 744 /* Get the lowest expiration time. */ 745 expiration = contact[i]->expires; 746 } 737 747 } 748 749 our_contact = our_contact->next; 738 750 } 739 751 } 740 752 741 if (regc->auto_reg && expiration != 0 && expiration != 0xFFFF) { 753 /* When the response doesn't contain our Contact header, that 754 * means we have been unregistered. 755 */ 756 if (!has_our_contact) 757 expiration = 0; 758 759 /* Schedule next registration */ 760 if (regc->auto_reg && expiration != 0 && expiration != NOEXP) { 742 761 pj_time_val delay = { 0, 0}; 743 762 … … 770 789 771 790 /* Call callback. */ 772 if (expiration == 0xFFFF) expiration = -1;791 if (expiration == NOEXP) expiration = -1; 773 792 call_callback(regc, PJ_SUCCESS, tsx->status_code, 774 793 (rdata ? &rdata->msg_info.msg->line.status.reason
Note: See TracChangeset
for help on using the changeset viewer.