[Serusers] Need to modify username (reformatted)

Mike Dehn mdehn at yknet.yk.ca
Sun Oct 19 23:55:08 CEST 2003


Unfortunately when I posted this message yesterday, the carriage returns were lost
and each paragraph came out as a single line.  Sorry about that; I'm trying again now.
I have also modified the message to reflect the fact that I've learned something in the
intervening hours ;-).  Tx to anyone who can help.    Mike
---------------------------------------------------
I am in the process of establishing a SIP-based system using SER which will allow 
my end users to connect to each other and to dial out to the pstn using a SIP/pstn 
gateway run by a provider downstream.

Some of the users on my system are consultants who work on several projects at 
once.  They would like to prefix the numbers they dial with their own arbitrary 
4-digit project codes for different calls and have the accounting I send them show 
the project code they used for each call.  Since my accounting is done downstream 
at the pstn gateway, and it shows the username for each call, I would like to change 
the username on each of the calls going out of my SER to include the project code.  
Then no changes would need to be made in the billing software and each call will be 
easy to identify as to user and project.

I believe that the username which shows up in the billing comes from the FROM field
that is transmitted for the call from my SIP, so that is the value I need to change (ie. the value of the
environment variable SIP_HF_FROM).

Of course the project code would get stripped off the uri itself so that just the correct uri is sent, 
and I have figured out how to do that using the strip function.  But I am new to SER 
and just figuring my way through this, so I need a bit of help with the rest of it.  

Here is an example of what I want to set up.

If user Mike wishes to call 1-111-1111 and wants to code it to project 1234, he would dial:
*123411111111 at wherever.com
and the outgoing uri would be just:
11111111 at wherever.com (this is done using strip)

The FROM value generated would be something like:
Mike SER <SIP:Mike at here.com:5060 >;tag=xxxxxxxxxx
and I need to change it to include the original name+project code:
Mike1234 SER <SIP:Mike at here.com:5060 >;tag=xxxxxxxxxx

Note:  the asterisk in the dial string just indicates that a project code follows.  Not all users will want this 
feature and calls without an asterisk will be handled differently.

If I can do the last part (change the outgoing FROM to mike1234) I'll have it cracked.
It would be best to do this within SER, but I don't see a way to do it.  If there is a way, please 
let me know.

So then it seems to me that the best thing might be to use the exec_dst command to 
pass a set of commands to the shell would cause characters 2 through 5 of SIP_ORURI 
(in this example 1234) to be inserted into SIP_HF_FROM.  So something like:

EXPORT SIP__HF_FROM=first_part_of_SIP_HF_FROM+(characters 2-5 of SIP_ORURI)+last_part_of_SIP_HF_FROM
     ...... Obviously my bash-knowledge needs a bit of work here ;-)  

If this would work, can someone tell me the shell commands to use?  I am not concerned with the exact 
logic of how to separate the first and last parts of the FROM field as I am in understanding how
to tell the shell to modify the environmental variables so that when control returns to SER it will
have the correct values.

Alternatively, what about calling a small executable that reads the appropriate 
environment variables and changes the value of $SIP_USER before returning to SER?  
I had at first thought this might be the simplest way to do it, but now I understand that 
when a program modifies an environment variable the variable returns to its original 
value when the child process ends.  If that is correct, then SER would never see the change.

Note that I'm aware that it would be easier to do this accounting on my own SER system, 
where I could pick off the appropriate information.  However, since the pstn gateway at the 
next hop does the official accounting and billing, I want the billing it produces to include 
the project codes, and I think the easiest way to do this is for me to modify the outgoing FROM.

I have been working away at this, starting from zero knowledge of Linux, but I've come 
about as far as I can get.  I would appreciate any advice.

Thanks,
Mike 




More information about the sr-users mailing list