Changeset 4275 for pjproject/trunk/pjsip/src/pjsip/sip_endpoint.c
- Timestamp:
- Oct 4, 2012 6:11:58 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsip/sip_endpoint.c
r4154 r4275 813 813 } 814 814 815 /* Init with default */ 816 PJ_DEF(void) pjsip_process_rdata_param_default(pjsip_process_rdata_param *p) 817 { 818 pj_bzero(p, sizeof(*p)); 819 } 820 821 /* Distribute rdata */ 822 PJ_DEF(pj_status_t) pjsip_endpt_process_rx_data( pjsip_endpoint *endpt, 823 pjsip_rx_data *rdata, 824 pjsip_process_rdata_param *p, 825 pj_bool_t *p_handled) 826 { 827 pjsip_msg *msg; 828 pjsip_process_rdata_param def_prm; 829 pjsip_module *mod; 830 pj_bool_t handled = PJ_FALSE; 831 unsigned i; 832 pj_status_t status; 833 834 PJ_ASSERT_RETURN(endpt && rdata, PJ_EINVAL); 835 836 if (p==NULL) { 837 p = &def_prm; 838 pjsip_process_rdata_param_default(p); 839 } 840 841 msg = rdata->msg_info.msg; 842 843 if (p_handled) 844 *p_handled = PJ_FALSE; 845 846 if (!p->silent) { 847 PJ_LOG(5, (THIS_FILE, "Distributing rdata to modules: %s", 848 pjsip_rx_data_get_info(rdata))); 849 pj_log_push_indent(); 850 } 851 852 LOCK_MODULE_ACCESS(endpt); 853 854 /* Find start module */ 855 if (p->start_mod) { 856 mod = pj_list_find_node(&endpt->module_list, p->start_mod); 857 if (!mod) { 858 status = PJ_ENOTFOUND; 859 goto on_return; 860 } 861 } else { 862 mod = endpt->module_list.next; 863 } 864 865 /* Start after the specified index */ 866 for (i=0; i < p->idx_after_start && mod != &endpt->module_list; ++i) { 867 mod = mod->next; 868 } 869 870 /* Start with the specified priority */ 871 while (mod != &endpt->module_list && mod->priority < p->start_prio) { 872 mod = mod->next; 873 } 874 875 if (mod == &endpt->module_list) { 876 status = PJ_ENOTFOUND; 877 goto on_return; 878 } 879 880 /* Distribute */ 881 if (msg->type == PJSIP_REQUEST_MSG) { 882 do { 883 if (mod->on_rx_request) 884 handled = (*mod->on_rx_request)(rdata); 885 if (handled) 886 break; 887 mod = mod->next; 888 } while (mod != &endpt->module_list); 889 } else { 890 do { 891 if (mod->on_rx_response) 892 handled = (*mod->on_rx_response)(rdata); 893 if (handled) 894 break; 895 mod = mod->next; 896 } while (mod != &endpt->module_list); 897 } 898 899 status = PJ_SUCCESS; 900 901 on_return: 902 if (p_handled) 903 *p_handled = handled; 904 905 UNLOCK_MODULE_ACCESS(endpt); 906 if (!p->silent) { 907 pj_log_pop_indent(); 908 } 909 return status; 910 } 911 815 912 /* 816 913 * This is the callback that is called by the transport manager when it … … 821 918 pjsip_rx_data *rdata ) 822 919 { 823 pjsip_msg *msg = rdata->msg_info.msg; 920 pjsip_process_rdata_param proc_prm; 921 pj_bool_t handled = PJ_FALSE; 824 922 825 923 if (status != PJ_SUCCESS) { … … 928 1026 #endif 929 1027 930 931 /* Distribute to modules, starting from modules with highest priority */ 932 LOCK_MODULE_ACCESS(endpt); 933 934 if (msg->type == PJSIP_REQUEST_MSG) { 935 pjsip_module *mod; 936 pj_bool_t handled = PJ_FALSE; 937 938 mod = endpt->module_list.next; 939 while (mod != &endpt->module_list) { 940 if (mod->on_rx_request) 941 handled = (*mod->on_rx_request)(rdata); 942 if (handled) 943 break; 944 mod = mod->next; 945 } 946 947 /* No module is able to handle the request. */ 948 if (!handled) { 949 PJ_TODO(ENDPT_RESPOND_UNHANDLED_REQUEST); 950 PJ_LOG(4,(THIS_FILE, "Message %s from %s:%d was dropped/unhandled by" 951 " any modules", 952 pjsip_rx_data_get_info(rdata), 953 rdata->pkt_info.src_name, 954 rdata->pkt_info.src_port)); 955 } 956 957 } else { 958 pjsip_module *mod; 959 pj_bool_t handled = PJ_FALSE; 960 961 mod = endpt->module_list.next; 962 while (mod != &endpt->module_list) { 963 if (mod->on_rx_response) 964 handled = (*mod->on_rx_response)(rdata); 965 if (handled) 966 break; 967 mod = mod->next; 968 } 969 970 if (!handled) { 971 PJ_LOG(4,(THIS_FILE, "Message %s from %s:%d was dropped/unhandled" 972 " by any modules", 973 pjsip_rx_data_get_info(rdata), 974 rdata->pkt_info.src_name, 975 rdata->pkt_info.src_port)); 976 } 977 } 978 979 UNLOCK_MODULE_ACCESS(endpt); 1028 pjsip_process_rdata_param_default(&proc_prm); 1029 proc_prm.silent = PJ_TRUE; 1030 1031 pjsip_endpt_process_rx_data(endpt, rdata, &proc_prm, &handled); 1032 1033 /* No module is able to handle the message */ 1034 if (!handled) { 1035 PJ_LOG(4,(THIS_FILE, "%s from %s:%d was dropped/unhandled by" 1036 " any modules", 1037 pjsip_rx_data_get_info(rdata), 1038 rdata->pkt_info.src_name, 1039 rdata->pkt_info.src_port)); 1040 } 980 1041 981 1042 /* Must clear mod_data before returning rdata to transport, since
Note: See TracChangeset
for help on using the changeset viewer.