[Home]

Summary:ASTERISK-03541: Account code not populated when 'type=friend' sets caller*ID number
Reporter:delvar (delvar)Labels:
Date Opened:2005-02-18 12:27:53.000-0600Date Closed:2011-06-07 14:10:47
Priority:MinorRegression?No
Status:Closed/CompleteComponents:Core/General
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:
Description:I wasnt sure if this was minor or tweak or even if it is a bug or it is suposed to do this...


Client is trying to set caller*ID name and number for outbound calls to PSTN.
-------------------------------------------------------------------------------
[Client Asterisk] >---> [Our Asterisk] >---> [Our PSTN Gateway]
-------------------------------------------------------------------------------

(we are really only interested in the [Client Asterisk] and [Our Asterisk]).

[Client Asterisk] hostname = ast.client
[Our Asterisk] hostname = ast.our

When client sets the caller id to his PSTN number the accountcode [Our Asterisk] on is NOT populated and our billing system drops the call as soon as it hits the dialplan.

With experimentation we found that the only way to get the accountcode to be populated was to set the caller*ID number to the SIP entity name either via SetCIDNum in extensions.conf or fromuser in sip.conf (on [Client Asterisk]).


****** ADDITIONAL INFORMATION ******

Sample Extensions.conf from [Client Asterisk] (setting the caller id num per call)

-------------------------------------------------------------------------------
[set-cid]
exten => s,1,SetCIDNum(8440101);
exten => s,2,SetCIDName(DELVAR-TEST);
exten => s,3,Dial(SIP/0247622222@8440101);
exten => s,4,Hangup();
-------------------------------------------------------------------------------

Sample Sip.conf from [Client Asterisk] (setting the caller id num per entity)

-------------------------------------------------------------------------------
[8440101]
type=friend
username=8440101
secret=XXXXXX
host=ast.our
dtmfmode=rfc2833
fromuser=8440101
-------------------------------------------------------------------------------











Sample Extensions.conf from [Our Asterisk] (just echo the data to cli)
-------------------------------------------------------------------------------
[show-vars]
exten => _X.,1,NoOp(AccountCode = ${ACCOUNTCODE})
exten => _X.,2,NoOp(CallerID = ${CALLERID})
exten => _X.,3,NoOp(CALLERIDNUM = ${CALLERIDNUM})
exten => _X.,4,NoOp(CALLERIDNAME = ${CALLERIDNAME})
exten => _X.,5,NoOp(Exten = ${EXTEN})
exten => _X.,6,Background(demo-congrats);
exten => _X.,7,Hangup();
exten => h,1,hangup();
-------------------------------------------------------------------------------

Sample Sip.conf from [Our Asterisk] (usual entity)

-------------------------------------------------------------------------------
[8440101]
type=friend
username=8440101
secret=XXXXXX
host=dynamic
canreinvite=no
context= show-vars
dtmfmode=rfc2833
accountcode=sip-8440101
-------------------------------------------------------------------------------


When [Client Asterisk] sets the caller*ID number to a the correct account id &ASTERISK-7995;8440101&ASTERISK-7996;,
Call connects correctly and at the CLI on [Our Asterisk] we see,

-------------------------------------------------------------------------------
AccountCode = sip-8440101
CallerID = "DELVAR-TEST" <8440101>
CALLERIDNUM = 8440101
CALLERIDNAME = DELVAR-TEST
Exten = 0247622222
-------------------------------------------------------------------------------


When [Client Asterisk] sets the caller*ID number to a PSTN number ie &ASTERISK-7995;0247611111&ASTERISK-7996;
Call connects but doesn&ASTERISK-7996;t populate account code at the CLI on [Our Asterisk] we see,

-------------------------------------------------------------------------------
AccountCode =
CallerID = "DELVAR-TEST" <0247611111>
CALLERIDNUM = 0247611111
CALLERIDNAME = DELVAR-TEST
Exten = 0247622222
-------------------------------------------------------------------------------


!! warning, I am no asterisk coder&ASTERISK-8010; I only have basic knowledge&ASTERISK-8010;!!

looking at /usr/src/asterisk/channels/chan_sip.c I noticed that in &ASTERISK-7995;static int check_user_full&ASTERISK-7996; that when a call/sip packet comes in it checks the &ASTERISK-7995;From:&ASTERISK-7996; field numeric part before the @ against the list of users, if it cant find one then it checks against the list of peers using the connection info.

If it matches the user part it can easily populate the account code: &ASTERISK-7995;strncpy(p->accountcode, user->accountcode, sizeof(p->accountcode)  -1);&ASTERISK-7996; and continue on with the call.
But if it matches on the peer side it can NOT do this as peers do not have account codes&ASTERISK-8010;
The problem is, yes we do want this sip user of type friend to make a call out but we also want the correct account code for ALL calles regardless of the &ASTERISK-7995;From:&ASTERISK-7996; header&ASTERISK-8010;

As a quick hack I added the following code to &ASTERISK-7995;static int check_user_full&ASTERISK-7996; at line: 5745 just below &ASTERISK-7995;p->noncodeccapability &= ~AST_RTP_DTMF;&ASTERISK-7996;,
-------------------------------------------------------------------------------
struct sip_user *user2;
user2 = find_user(peer->name);
if (user2)
       {
       if (!ast_strlen_zero(user2->accountcode))
               strncpy(p->accountcode, user2->accountcode, sizeof(p->accountcode) - 1);
       ASTOBJ_UNREF(user2,sip_destroy_user);
       }
-------------------------------------------------------------------------------

if it matches on the peer side, it then does a lookup for a user with the same entity name as the peer, then gets the account code from there.
With this patch it works as I think it should, but as you can see its not very nice.
It requires the entity to be &ASTERISK-7995;type=friend&ASTERISK-7996;.

A better work around would be to assign the account code based on the authentication (AUTH) packet where the username is clearly stated.

but i have to ask why authenticate an inbound (from client to asterisk) call using a peer... surly it should ONLY use user.
Comments:By: delvar (delvar) 2005-02-18 12:33:21.000-0600

oh dear, all the ` (backtick) have been turned into http encoded widget things, can a nice op correct it?

By: Mark Spencer (markster) 2005-02-18 13:48:01.000-0600

Please update to latest CVS and confirm the problem is there.  accountcode was only recently added to the peer structure.  Normally the callerid is used to select a user for authentication.  Assuming registration is being used, you probably just need to use type=peer and latest CVS head.

By: Olle Johansson (oej) 2005-02-18 13:53:21.000-0600

1) The current cvs head accepts accountcode= as a setting for a peer
2) For users we always match the From: user name to the name in the [name] setting for type=user (or the user part of type=friend)
3) The username= setting does not set the username (yes, it's a bad name)
4) In the current version of asterisk you can't have a different username than the [name] you define in sip.conf
5) Please add a SIP debug output (see the bug guidelines) so we see the transaction
6) The matching for a peer on incoming calls is done on IP address
7) The bug tracker is not meant for support. Start with the mailing list or the IRC, please

By: Olle Johansson (oej) 2005-02-18 13:53:39.000-0600

--not a bug, configuration problem---