[Home]

Summary:ASTERISK-00668: [patch] sip debug confusion
Reporter:matt (matt)Labels:
Date Opened:2003-12-15 11:42:56.000-0600Date Closed:2008-01-15 14:40:59.000-0600
Priority:TrivialRegression?No
Status:Closed/CompleteComponents:Core/General
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) chan_sip.c.patch
( 1) diff.chan_sip
( 2) diff.chan_sip
Description:In chan_sip.c, approximately line 5432, where you have

ast_verbose("Sip read: \n%s\n", req.data);

Add two newlines to the beginning to make it:

ast_verbose("\n\nSip read: \n%s\n", req.data);

The reason is, if you currently log into asterisk using asterisk -r and do a sip debug, the first line of each SIP message will look like this:

Sip read: I>

Now what that is is the end of the CLI> prompt.  It was confusing enough to me that I started thinking that it was some garbage being passed at the beginning of the SIP message.  I don't want anyone else to waste any time going down that path like I did.

Comments:By: Brian West (bkw918) 2003-12-15 15:37:37.000-0600

Attach a diff -u please.

By: matt (matt) 2003-12-15 15:57:54.000-0600

There you go.  That's relative to CVS just now.

By: atacomm (atacomm) 2003-12-15 22:49:30.000-0600

Any possibility that you could also create a patch that would be something like this while you are working on the SIP debug?

sip debug <username>

I get so frustrated looking thru hundreds of SIP messages pooring in all at once, just to look at what a single phone is doing....

By: Olle Johansson (oej) 2003-12-18 14:28:15.000-0600

Good idea, atacomm. That wouldn't be easy to do,since sipdebug messages are all over chan_sip.c, but maybe we could limit the printouts of sip headers.

By: Olle Johansson (oej) 2003-12-18 14:33:18.000-0600

At the point where we're printing the headers, no parsing have been done. To limit it, would require printout somewhere else.

By: Olle Johansson (oej) 2003-12-18 14:38:15.000-0600

could sip debug <ipaddress> work?

By: atacomm (atacomm) 2003-12-18 14:38:37.000-0600

hmm... Well, say we did sip debug <username>, we could add the username to a linked list (or maybe bsp tree for faster searching in real time) of debuged channels.  Then, after parse, check to see if it matches one of the linked list entries, and print it again.  If the printing of the packet is self contained in a single function, it would be simple.  If its not, it shouldnt be hard to move it out into a function so it can be called from two seperate places in the code.  The only last item would be to not print the channel match if the generic sip debug is on, otherwise you'd get duplicates.

By: Olle Johansson (oej) 2003-12-18 14:42:16.000-0600

Well, maybe something like:
1. sip debug <username>
2. check db for registry IP address
3. Add IP address to linked list of debug nodes
4. Check nodes list before printing

This would give us a trace of a user, but if several users share IP adress (behind one NAT) they would all be traced...

By: atacomm (atacomm) 2003-12-18 14:44:32.000-0600

hmmm....that sucks, because for example CP7960Gs have 6 lines, each register with *.  I've got several phones on a single network of CP7960G, all on my LAN, whereas the server is off on the WAN side.....so it actually wouldnt eliminate anything.  3 phones x 6 register requests every 60 seconds, + any other ata adapters, adds up pretty quickly.  This is why i'm looking for a way to narrow down the results...

By: Olle Johansson (oej) 2003-12-18 14:47:34.000-0600

Add port number then, it's in the SIP registry (SIP SHOW PEERS)...

Then we can trace one user, either on FROM or TO IP:port

By: atacomm (atacomm) 2003-12-18 14:52:33.000-0600

ok, can we automate that from using a username instead of IP? (like you had suggested earlier)

By: Olle Johansson (oej) 2003-12-18 15:15:02.000-0600

Please ignore 4.diff (I can't remove it, wrong upload).

My diff integrates the first patch above and adds some marks on SIP DEBUG output, also adds IP address and port no on SIP READ output, so you know where it's from.
Also some beautifying of comments (tabs).

By: Olle Johansson (oej) 2003-12-18 16:02:09.000-0600

The latest diff adds
* sipdebugip=<ip address>
* sipdebugport=<port>

in [general] section of sip.conf. If you add these -and add both - only this adress will be in detail output (SIP Headers) mode, others will simply be noted.

Includes changes as above.

Possible changes/additions:
* Add CLI command (See above)
* Add netmask parsing to ip address or hostname
* If port equals zero, match all ports...

By: jrollyson (jrollyson) 2004-01-10 20:58:41.000-0600

one rejected hunk vs current CVS

mhc-pbx:/usr/src/asterisk/channels# less chan_sip.c.rej
***************
*** 4952,4957 ****
       return 0;
 }

 static int handle_request(struct sip_pvt *p, struct sip_request *req, struct s
ockaddr_in *sin)
 {
       /* Called with p->lock held, as well as p->owner->lock if appropriate, k
eeping things
--- 4977,4985 ----
       return 0;
 }

+ /*
+  * Handle SIP requests (methods)
+  */
 static int handle_request(struct sip_pvt *p, struct sip_request *req, struct s
ockaddr_in *sin)
 {
       /* Called with p->lock held, as well as p->owner->lock if appropriate, k
eeping things

By: zoa (zoa) 2004-01-10 22:11:15.000-0600

rollyson says that the patch works and that only some comment didnt work with the diff.

ready for cvs ?

By: Olle Johansson (oej) 2004-01-11 02:57:13.000-0600

THis patch is now part of chan_sip2, patch 759

By: jerjer (jerjer) 2004-01-12 12:43:57.000-0600

two new line's added to cvs. Clean up and resubmit the rest for future inclusion.

By: Digium Subversion (svnbot) 2008-01-15 14:40:59.000-0600

Repository: asterisk
Revision: 1986

U   trunk/channels/chan_sip.c

------------------------------------------------------------------------
r1986 | jeremy | 2008-01-15 14:40:58 -0600 (Tue, 15 Jan 2008) | 2 lines

clean up sip debug output. Bug ASTERISK-668

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=1986