Hello all,

So I discarded all previous changes and re-worked it all on sofia instead of console.
You may want to check it out on

https://freeswitch.org/stash/users/davidcsi/repos/freeswitch/browse

freeswitch@core> sofia

USAGE:
--------------------------------------------------------------------------------
sofia filter <filter-expression|off>
sofia global siptrace <on|off>
sofia        capture  <on|off>
             watchdog <on|off>

sofia profile <name> [start | stop | restart | rescan] [wait]
                     flush_inbound_reg [<call_id> | <[user]@domain>] [reboot]
                     check_sync [<call_id> | <[user]@domain>]
                     [register | unregister] [<gateway name> | all]
                     killgw <gateway name>
                     [stun-auto-disable | stun-enabled] [true | false]]
                     siptrace <on|off>
                     capture  <on|off>
                     watchdog <on|off>

sofia <status|xmlstatus> profile <name> [reg [<contact str>]] | [pres <pres str>] | [user <user@domain>]
sofia <status|xmlstatus> gateway <name>

sofia loglevel <all|default|tport|iptsec|nea|nta|nth_client|nth_server|nua|soa|sresolv|stun> [0-9]
sofia tracelevel <console|alert|crit|err|warning|notice|info|debug>

sofia help
--------------------------------------------------------------------------------

sofia:

freeswitch@core> sofia filter

sofia filter is disabled.  (sofia filter <filter-expression|off>) - Enable, disable filtering, set 'filer-expression' to use as filter. Set 'filter-expression' to 'off' to stop filtering

Comments are very welcome!


Please whoever is able, test and comment!

Thanks!!

David

​
ᐧ

On Sun, Aug 28, 2016 at 11:27 PM, David Villasmil <david.villasmil.work@gmail.com> wrote:
Great, thanks mike.

David
ᐧ

On Fri, Aug 26, 2016 at 10:06 PM, Michael Jerris <mike@jerris.com> wrote:
sorry for the delay.. take a look in sofia.c

static void logger(void *logarg, char const *fmt, va_list ap)
{   
    if (!fmt) return;

    switch_log_vprintf(SWITCH_CHANNEL_LOG_CLEAN, mod_sofia_globals.tracelevel, fmt, ap);
}

and also in 

switch_status_t sofia_init(void)

where it binds the logger function

su_log_redirect(tport_log, logger, NULL);

Mike


On Aug 26, 2016, at 11:33 AM, David Villasmil <david.villasmil.work@gmail.com> wrote:

Nice, thanks
ᐧ

On Fri, Aug 26, 2016 at 5:26 PM, Michael Jerris <mike@jerris.com> wrote:
give me a few minutes to finish my meeting and I'll get you that 


On Friday, August 26, 2016, David Villasmil <david.villasmil.work@gmail.com> wrote:
Hello Michael, 

Agreed, i just couldn't find the related code. It's important to note i'm no expert :)

Regards,

David
ᐧ

On Fri, Aug 26, 2016 at 5:14 PM, Michael Jerris <mike@jerris.com> wrote:
this is interesting but I'm much more interested in this in mod_sofia at the callback we get for sip tracing.  I think this is interesting too but maybe better to do down one level in logger so you can do this to log files and other things too.


On Friday, August 26, 2016, David Villasmil <david.villasmil.work@gmail.com> wrote:

Hello guys,

You can get all SIP messages coming and going to a specific profile by typing on the console:
“sofia profile [PROFILE] siptrace on”

But if you have traffic on the box, this is a NIGHTMARE, as you get ALL messages…

So I made a modification to mod_console.c to add a filtering for siptraces.

By enabling the filter like so:

“console filter [expression]”

Where “expression” can be anything present in the packets you want to get, be it username, dialed number, whatever. Only those messages on which the expression was found will be shown:

freeswitch@MacBookPro-David> console

USAGE:
--------------------------------------------------------------------------------
console help
console loglevel [[0-7] | <loglevel_string>]
console filter <filter-expression>  <<<——— NEW functionality
console colorize [on|off|toggle]
————————————————————————————————————————
freeswitch@MacBookPro-David> console filter

USAGE:
--------------------------------------------------------------------------------
console filter <filter-expression|off>

Enable, disable filtering, Only messages containing the 'filer-expression' will be printed out.
set 'filter-expression' to 'off' to stop filtering
————————————————————————————————————————

Typing:
console filter 1001

Would result in only seeing messages which include 1001

EXPRESSION (1001) FOUND IN:
 <<<recv 1255 bytes from tcp/[127.0.0.1]:52917 at 21:43:11.739980:
   ------------------------------------------------------------------------
   INVITE sip:1001@127.0.0.1 SIP/2.0
   Call-ID: 6f9cdc511446251e254e9e617d26647c@0:0:0:0:0:0:0:0
   CSeq: 2 INVITE
   From: "1000" <sip:1000@127.0.0.1>;tag=45dd865b
   To: <sip:1001@127.0.0.1>
   Max-Forwards: 70
   Contact: "1000" <sip:1000@127.0.0.1:52917;transport=tcp;registering_acc=127_0_0_1>
   User-Agent: Jitsi2.8.5426Mac OS X
   Content-Type: application/sdp
   Via: SIP/2.0/TCP 127.0.0.1:52917;branch=z9hG4bK-343435-1dc76531757a26482fa8ff1bac9acf3b
   Proxy-Authorization: Digest username="1000",realm="127.0.0.1",nonce="1a2be9b9-fa12-4763-b00c-dfeacc79f9fd",uri="sip:1001@127.0.0.1",response="fce7bf74772a149fe39ec7e50ec61c69",algorithm=MD5,qop=auth,cnonce="xyz",nc=00000001
   Content-Length: 566

   v=0
   o=1000-jitsi.org 0 0 IN IP4 127.0.0.1
   s=-
   c=IN IP4 127.0.0.1
   t=0 0
   m=audio 5119 RTP/AVP 96
   a=rtpmap:96 opus/48000/2
   a=fmtp:96 usedtx=1
   a=extmap:1 urn:ietf:params:rtp-hdrext:csrc-audio-level
   a=extmap:2 urn:ietf:params:rtp-hdrext:ssrc-audio-level
   a=rtcp-xr:voip-metrics
   m=video 5121 RTP/AVP 97 99
   a=recvonly
   a=rtpmap:97 H264/90000
   a=fmtp:97 profile-level-id=4DE01f;packetization-mode=1
   a=imageattr:97 send * recv [x=[0-1920],y=[0-1200]]
   a=rtpmap:99 H264/90000
   a=fmtp:99 profile-level-id=4DE01f
   a=imageattr:99 send * recv [x=[0-1920],y=[0-1200]]
   ------------------------------------------------------------------------

>>>

My goal is to extend this to also filter other messages, like call processing, etc. (ERR messages would not be filtered out)

I’m wondering whether it is possible to do a pull request on this?

Regards,

David

​
ᐧ


_________________________________________________________________________
Professional FreeSWITCH Consulting Services:
consulting@freeswitch.org
http://www.freeswitchsolutions.com

Official FreeSWITCH Sites
http://www.freeswitch.org
http://confluence.freeswitch.org
http://www.cluecon.com

FreeSWITCH-users mailing list
FreeSWITCH-users@lists.freeswitch.org
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org