[Asterisk-code-review] res pjsip: Filter out non SIP(S) requests (asterisk[13])
Kevin Harwell
asteriskteam at digium.com
Fri Sep 15 13:07:49 CDT 2017
Kevin Harwell has posted comments on this change. ( https://gerrit.asterisk.org/6501 )
Change subject: res_pjsip: Filter out non SIP(S) requests
......................................................................
Patch Set 1: Code-Review-1
(2 comments)
https://gerrit.asterisk.org/#/c/6501/1/res/res_pjsip/pjsip_message_filter.c
File res/res_pjsip/pjsip_message_filter.c:
https://gerrit.asterisk.org/#/c/6501/1/res/res_pjsip/pjsip_message_filter.c@160
PS1, Line 160: {
: #ifdef AST_DEVMODE
: char hdrbuf[512];
: int hdrbuf_len;
:
: hdrbuf_len = pjsip_uri_print(context, uri, hdrbuf, 512);
: hdrbuf[hdrbuf_len] = '\0';
: ast_debug(2, "%s: %s\n", msg, hdrbuf);
: #endif
: }
since you already have a separate function for this why not go ahead and check the debug level first before calling uri_print. This would save a copy on every call.
https://gerrit.asterisk.org/#/c/6501/1/res/res_pjsip/pjsip_message_filter.c@349
PS1, Line 349: static void print_uri_debug(enum uri_type ut, pjsip_rx_data *rdata, pjsip_hdr *hdr)
: {
: #ifdef AST_DEVMODE
: pjsip_uri *local_uri = NULL;
: char hdrbuf[512];
: int hdrbuf_len;
: char *request_uri;
: pjsip_uri_context_e context = PJSIP_URI_IN_OTHER;
: char header_name[32];
:
: switch (ut) {
: case(URI_TYPE_REQUEST):
: context = PJSIP_URI_IN_REQ_URI;
: strcpy(header_name, "Request"); /* Safe */
: local_uri = rdata->msg_info.msg->line.req.uri;
: break;
: case(PJSIP_H_FROM):
: strcpy(header_name, "From"); /* Safe */
: context = PJSIP_URI_IN_FROMTO_HDR;
: local_uri = pjsip_uri_get_uri(((pjsip_from_hdr *)hdr)->uri);
: break;
: case(PJSIP_H_TO):
: strcpy(header_name, "To"); /* Safe */
: context = PJSIP_URI_IN_FROMTO_HDR;
: local_uri = pjsip_uri_get_uri(((pjsip_to_hdr *)hdr)->uri);
: break;
: case(PJSIP_H_CONTACT):
: strcpy(header_name, "Contact"); /* Safe */
: context = PJSIP_URI_IN_CONTACT_HDR;
: local_uri = pjsip_uri_get_uri(((pjsip_contact_hdr *)hdr)->uri);
: break;
: }
:
: hdrbuf_len = pjsip_uri_print(PJSIP_URI_IN_REQ_URI, rdata->msg_info.msg->line.req.uri, hdrbuf, 512);
: hdrbuf[hdrbuf_len] = '\0';
: request_uri = ast_strdupa(hdrbuf);
: hdrbuf_len = pjsip_uri_print(context, local_uri, hdrbuf, 512);
: hdrbuf[hdrbuf_len] = '\0';
:
: ast_debug(2, "There was a non sip(s) URI scheme in %s URI '%s' for request '%*.*s %s'\n",
: header_name, hdrbuf,
: (int)rdata->msg_info.msg->line.req.method.name.slen,
: (int)rdata->msg_info.msg->line.req.method.name.slen,
: rdata->msg_info.msg->line.req.method.name.ptr, request_uri);
: #endif
: }
Same for this one. Check the debug level prior to processing everything.
--
To view, visit https://gerrit.asterisk.org/6501
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-MessageType: comment
Gerrit-Change-Id: Ibb2f9f1d2dc7549da562af4cbd9156c44ffdd460
Gerrit-Change-Number: 6501
Gerrit-PatchSet: 1
Gerrit-Owner: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-Comment-Date: Fri, 15 Sep 2017 18:07:49 +0000
Gerrit-HasComments: Yes
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20170915/c31ffe77/attachment.html>
More information about the asterisk-code-review
mailing list