From a0a8b8b6977c38d15cd67d49345e7a31df23cf3f Mon Sep 17 00:00:00 2001 From: Kaian Date: Fri, 14 Mar 2014 14:14:45 +0100 Subject: [PATCH] Add an option to ignore incomplete dialogs Some power users don't want to open sngrep and see calls starting with a response message. Meh. --- config/sngreprc | 9 +++++++++ src/option.c | 5 +++++ src/sip.c | 14 ++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/config/sngreprc b/config/sngreprc index 0483050..4f0643d 100644 --- a/config/sngreprc +++ b/config/sngreprc @@ -50,6 +50,15 @@ # set cl.column5 starting # set cl.column5.width 15 + +##----------------------------------------------------------------------------- +## Default minimun size from Message info in Call Flow panel +# set cf.rawminwidth 100 + +##----------------------------------------------------------------------------- +## Ignore dialogs that does not start with a request method +# set sip.ignoreincomplete 1 + ##----------------------------------------------------------------------------- ## You can ignore some calls with any of the previous attributes with a given ## value with ignore directive. diff --git a/src/option.c b/src/option.c index 1eaab68..5a1cea2 100644 --- a/src/option.c +++ b/src/option.c @@ -65,14 +65,19 @@ init_options() // Set Autoscroll in call list set_option_value("cl.autoscroll", "on"); set_option_value("cl.scrollstep", "10"); + set_option_value("cl.defexitbutton", "1"); // Raw options for Call flow screen set_option_value("cf.forceraw", "on"); set_option_value("cf.rawminwidth", "100"); set_option_value("cf.splitcallid", "off"); + // Allow dialogs to be incomplete + set_option_value("sip.ignoreincomlete", "0"); + // Read options from configuration files read_options("/etc/sngreprc"); + read_options("/usr/local/etc/sngreprc"); read_options("/root/.sngreprc"); return 0; diff --git a/src/sip.c b/src/sip.c index 1c875c3..8fe75de 100644 --- a/src/sip.c +++ b/src/sip.c @@ -188,6 +188,20 @@ sip_load_message(const char *header, const char *payload) // Find the call for this msg if (!(call = call_find_by_callid(callid))) { + + // Only create a new call if the first msg + // is a request message in the following gorup + if (get_option_int_value("sip.ignoreincomplete")) { + const char *method = msg_get_attribute(msg, SIP_ATTR_METHOD); + if (method && strcasecmp(method, "INVITE") + && strcasecmp(method, "REGISTER") && strcasecmp(method, "SUBSCRIBE") + && strcasecmp(method, "OPTIONS") && strcasecmp(method, "PUBLISH") + && strcasecmp(method, "MESSAGE") && strcasecmp(method, "NOTIFY")){ + //@todo sip_msg_destroy(); + return NULL; + } + } + // Create the call if not found if (!(call = sip_call_create(callid))) { //@todo sip_msg_destroy();