Changeset 1816 for pjproject/trunk/pjsip/src/pjsip/sip_util.c
- Timestamp:
- Feb 22, 2008 8:36:06 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsip/sip_util.c
r1417 r1816 721 721 PJ_ASSERT_RETURN(dest_info != NULL, PJ_EINVAL); 722 722 723 /* Assert if the request contains strict route and strict 724 * route processing has been applied before. We need to 725 * restore the strict route with pjsip_restore_strict_route_set() 726 * before we can call this function again, otherwise strict 727 * route will be swapped twice! 728 */ 729 PJ_ASSERT_RETURN(tdata->saved_strict_route==NULL, PJ_EBUG); 730 723 731 /* Find the first and last "Route" headers from the message. */ 724 732 last_route_hdr = first_route_hdr = (pjsip_route_hdr*) … … 776 784 pjsip_uri_get_uri((pjsip_uri*)topmost_route_uri); 777 785 pj_list_erase(first_route_hdr); 786 tdata->saved_strict_route = first_route_hdr; 778 787 if (first_route_hdr == last_route_hdr) 779 last_route_hdr = NULL;788 first_route_hdr = last_route_hdr = NULL; 780 789 } 781 790 … … 807 816 /* Success. */ 808 817 return PJ_SUCCESS; 818 } 819 820 821 /* 822 * Swap the request URI and strict route back to the original position 823 * before #pjsip_process_route_set() function is called. This function 824 * should only used internally by PJSIP client authentication module. 825 */ 826 PJ_DEF(void) pjsip_restore_strict_route_set(pjsip_tx_data *tdata) 827 { 828 pjsip_route_hdr *first_route_hdr, *last_route_hdr; 829 830 /* Check if we have found strict route before */ 831 if (tdata->saved_strict_route == NULL) { 832 /* This request doesn't contain strict route */ 833 return; 834 } 835 836 /* Find the first "Route" headers from the message. */ 837 first_route_hdr = (pjsip_route_hdr*) 838 pjsip_msg_find_hdr(tdata->msg, PJSIP_H_ROUTE, NULL); 839 840 if (first_route_hdr == NULL) { 841 /* User has modified message route? We don't expect this! */ 842 pj_assert(!"Message route was modified?"); 843 tdata->saved_strict_route = NULL; 844 return; 845 } 846 847 /* Find last Route header */ 848 last_route_hdr = first_route_hdr; 849 while (last_route_hdr->next != (void*)&tdata->msg->hdr) { 850 pjsip_route_hdr *hdr; 851 hdr = (pjsip_route_hdr*) 852 pjsip_msg_find_hdr(tdata->msg, PJSIP_H_ROUTE, 853 last_route_hdr->next); 854 if (!hdr) 855 break; 856 last_route_hdr = hdr; 857 } 858 859 /* Put the last Route header as request URI, delete last Route 860 * header, and insert the saved strict route as the first Route. 861 */ 862 tdata->msg->line.req.uri = last_route_hdr->name_addr.uri; 863 pj_list_insert_before(first_route_hdr, tdata->saved_strict_route); 864 pj_list_erase(last_route_hdr); 865 866 /* Reset */ 867 tdata->saved_strict_route = NULL; 809 868 } 810 869
Note: See TracChangeset
for help on using the changeset viewer.