Changeset 1816 for pjproject/trunk
- Timestamp:
- Feb 22, 2008 8:36:06 AM (17 years ago)
- Location:
- pjproject/trunk/pjsip
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/include/pjsip/sip_transport.h
r1748 r1816 496 496 /** The message in this buffer. */ 497 497 pjsip_msg *msg; 498 499 /** Strict route header saved by #pjsip_process_route_set(), to be 500 * restored by #pjsip_restore_strict_route_set(). 501 */ 502 pjsip_route_hdr *saved_strict_route; 498 503 499 504 /** Buffer to the printed text representation of the message. When the -
pjproject/trunk/pjsip/include/pjsip/sip_util.h
r1748 r1816 220 220 PJ_DECL(pj_status_t) pjsip_process_route_set(pjsip_tx_data *tdata, 221 221 pjsip_host_info *dest_info ); 222 223 224 /** 225 * Swap the request URI and strict route back to the original position 226 * before #pjsip_process_route_set() function is called. If no strict 227 * route URI was found by #pjsip_process_route_set(), this function will 228 * do nothing. 229 * 230 * This function should only used internally by PJSIP client authentication 231 * module. 232 * 233 * @param tdata Transmit data containing request message. 234 */ 235 PJ_DECL(void) pjsip_restore_strict_route_set(pjsip_tx_data *tdata); 236 222 237 223 238 /** -
pjproject/trunk/pjsip/src/pjsip/sip_auth_client.c
r1569 r1816 1099 1099 via->branch_param.slen = 0; 1100 1100 1101 /* Restore strict route set. 1102 * See http://trac.pjsip.org/repos/ticket/492 1103 */ 1104 pjsip_restore_strict_route_set(tdata); 1105 1101 1106 /* Must invalidate the message! */ 1102 1107 pjsip_tx_data_invalidate_msg(tdata); -
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.