--- res/res_pjsip/pjsip_message_filter.c 2018-05-04 20:10:12.581391149 +0300 +++ ../vanilla/asterisk-13.21.0/res/res_pjsip/pjsip_message_filter.c 2018-05-01 23:01:46.000000000 +0300 @@ -162,13 +162,6 @@ #define is_sip_uri(uri) \ (PJSIP_URI_SCHEME_IS_SIP(uri) || PJSIP_URI_SCHEME_IS_SIPS(uri)) -#define is_tel_uri(uri) \ - (PJSIP_URI_SCHEME_IS_TEL(uri)) - -#define is_sip_or_tel_uri(uri) \ - (is_sip_uri(uri) || is_tel_uri(uri)) - - static void print_sanitize_debug(char *msg, pjsip_uri_context_e context, pjsip_sip_uri *uri) { #ifdef AST_DEVMODE @@ -192,18 +185,13 @@ { static const pj_str_t x_name = { AST_SIP_X_AST_TXP, AST_SIP_X_AST_TXP_LEN }; pjsip_param *x_transport; + pjsip_sip_uri *uri; pjsip_hdr *hdr; if (tdata->msg->type == PJSIP_REQUEST_MSG) { if (is_sip_uri(tdata->msg->line.req.uri)) { - pjsip_sip_uri *uri = pjsip_uri_get_uri(tdata->msg->line.req.uri); - print_sanitize_debug("Sanitizing SIP Request", PJSIP_URI_IN_REQ_URI, uri); - while ((x_transport = pjsip_param_find(&uri->other_param, &x_name))) { - pj_list_erase(x_transport); - } - } - else if (is_tel_uri(tdata->msg->line.req.uri)) { - pjsip_tel_uri *uri = pjsip_uri_get_uri(tdata->msg->line.req.uri); + uri = pjsip_uri_get_uri(tdata->msg->line.req.uri); + print_sanitize_debug("Sanitizing Request", PJSIP_URI_IN_REQ_URI, uri); while ((x_transport = pjsip_param_find(&uri->other_param, &x_name))) { pj_list_erase(x_transport); } @@ -213,28 +201,16 @@ for (hdr = tdata->msg->hdr.next; hdr != &tdata->msg->hdr; hdr = hdr->next) { if (hdr->type == PJSIP_H_TO || hdr->type == PJSIP_H_FROM) { if (is_sip_uri(((pjsip_fromto_hdr *) hdr)->uri)) { - pjsip_sip_uri *uri = pjsip_uri_get_uri(((pjsip_fromto_hdr *) hdr)->uri); - print_sanitize_debug("Sanitizing SIP From/To header", PJSIP_URI_IN_FROMTO_HDR, uri); - while ((x_transport = pjsip_param_find(&uri->other_param, &x_name))) { - pj_list_erase(x_transport); - } - } - else if (is_tel_uri(((pjsip_fromto_hdr *) hdr)->uri)) { - pjsip_tel_uri *uri = pjsip_uri_get_uri(((pjsip_fromto_hdr *) hdr)->uri); + uri = pjsip_uri_get_uri(((pjsip_fromto_hdr *) hdr)->uri); + print_sanitize_debug("Sanitizing From/To header", PJSIP_URI_IN_FROMTO_HDR, uri); while ((x_transport = pjsip_param_find(&uri->other_param, &x_name))) { pj_list_erase(x_transport); } } } else if (hdr->type == PJSIP_H_CONTACT) { if (!((pjsip_contact_hdr *) hdr)->star && is_sip_uri(((pjsip_contact_hdr *) hdr)->uri)) { - pjsip_sip_uri *uri = pjsip_uri_get_uri(((pjsip_contact_hdr *) hdr)->uri); - print_sanitize_debug("Sanitizing SIP Contact header", PJSIP_URI_IN_CONTACT_HDR, uri); - while ((x_transport = pjsip_param_find(&uri->other_param, &x_name))) { - pj_list_erase(x_transport); - } - } - else if (!((pjsip_contact_hdr *) hdr)->star && is_tel_uri(((pjsip_contact_hdr *) hdr)->uri)) { - pjsip_tel_uri *uri = pjsip_uri_get_uri(((pjsip_contact_hdr *) hdr)->uri); + uri = pjsip_uri_get_uri(((pjsip_contact_hdr *) hdr)->uri); + print_sanitize_debug("Sanitizing Contact header", PJSIP_URI_IN_CONTACT_HDR, uri); while ((x_transport = pjsip_param_find(&uri->other_param, &x_name))) { pj_list_erase(x_transport); } @@ -432,21 +408,21 @@ return PJ_FALSE; } - if (!is_sip_or_tel_uri(rdata->msg_info.msg->line.req.uri)) { + if (!is_sip_uri(rdata->msg_info.msg->line.req.uri)) { print_uri_debug(URI_TYPE_REQUEST, rdata, NULL); pjsip_endpt_respond_stateless(ast_sip_get_pjsip_endpoint(), rdata, PJSIP_SC_UNSUPPORTED_URI_SCHEME, NULL, NULL, NULL); return PJ_TRUE; } - if (!is_sip_or_tel_uri(rdata->msg_info.from->uri)) { + if (!is_sip_uri(rdata->msg_info.from->uri)) { print_uri_debug(URI_TYPE_FROM, rdata, (pjsip_hdr *)rdata->msg_info.from); pjsip_endpt_respond_stateless(ast_sip_get_pjsip_endpoint(), rdata, PJSIP_SC_UNSUPPORTED_URI_SCHEME, NULL, NULL, NULL); return PJ_TRUE; } - if (!is_sip_or_tel_uri(rdata->msg_info.to->uri)) { + if (!is_sip_uri(rdata->msg_info.to->uri)) { print_uri_debug(URI_TYPE_TO, rdata, (pjsip_hdr *)rdata->msg_info.to); pjsip_endpt_respond_stateless(ast_sip_get_pjsip_endpoint(), rdata, PJSIP_SC_UNSUPPORTED_URI_SCHEME, NULL, NULL, NULL); @@ -466,7 +442,7 @@ } while (contact) { - if (!contact->star && !is_sip_or_tel_uri(contact->uri)) { + if (!contact->star && !is_sip_uri(contact->uri)) { print_uri_debug(URI_TYPE_CONTACT, rdata, (pjsip_hdr *)contact); pjsip_endpt_respond_stateless(ast_sip_get_pjsip_endpoint(), rdata, PJSIP_SC_UNSUPPORTED_URI_SCHEME, NULL, NULL, NULL);