[Asterisk-Dev] defect in sip_chan.c?

Steve Murphy murf at e-tools.com
Wed Dec 14 08:52:28 MST 2005


Hello--

I am having a problem with matching contexts from sip.conf with the
callerid info coming in from a SIP provider.

My sip provider passes the callerID info to Asterisk via the From:
header in the INVITE packet.

Asterisk dutifully pulls the callerid num and name from the From:
header, and then, searches sip.conf for a user context that has the same
name as the callerid number....

Isn't this brain dead? Or is there some method to the madness? Why on
earth would I ever want to have an entry in sip.conf for every possible
person who would call me via the phone number provided me by the vendor?

Wouldn't it make more sense instead to find a user entry for the exten
instead? I looked at chan_sip.c, and in check_user_full(), at the time
the find_user() func is called, the variable p->exten contains the
extension number (my account number with the Provider).

Now, I could ask the Provider not to include actual callerID info in the
INVITE (we started out that way), and I might end up with the exten in
the callerID number field that way, but I'd never see who was calling
me!

The rub is, I need to NOT authenticate incoming calls, just the outgoing
calls. To do this, I'd like to have two entries in sip.conf, one for the
"user", and the other for the "peer", where the "user" doesn't
authenticate (no md5secret, no realm, etc), and the "peer" does
authenticate.

What if check_user_full() adds a call to find_user with p->exten AFTER
it does the existing call to find_user with the cid num? Or am I daft
because the rest of the world does it differently? It looks like (I
haven't searched the code yet...) the p->exten seems to be filled in
from the "To:" header.

So, would it harm anyone, if the sip driver, on receiving a call, first
checked for a user context matching the "From:" header, then checked for
a user context matching the "To:" header, THEN went for a peer with a
matching IP?

I inserted the two lines to do this, and now I get the behavior I need.
Is this a worthwhile thing to do for anyone else?

murf

-- 
Steve Murphy <murf at e-tools.com>
Electronic Tools Company




More information about the asterisk-dev mailing list