Rewriting From header using Contact information

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Rewriting From header using Contact information

Julian Yap
I have a scenario where the PSTN to SIP gateway (AudioCodes) I am
using sets the From header to 'anonymous' when it does not receive a
Calling Name from the PSTN side.

The modified INVITE from the gateway then looks like this (changed
some numbers and IP's):
From: "anonymous" <sip:[hidden email]>;tag=1c49690767.
To: <sip:+18085557005@192.168.178.50;user=phone>.
CSeq: 1 INVITE.
Contact: <sip:8084446503@192.168.178.60>.

When the gateway does receive the Calling Name from the PSTN, it looks
like this:
From: "HONOLULU     HI" <sip:8083330048@192.168.178.60>;tag=1c1248847826.
To: <sip:+18085557005@192.168.178.50;user=phone>.
CSeq: 1 INVITE.
Contact: <sip:8083330048@192.168.178.60>.

In the first instance, I want to re-write the From header because I do
in fact have the calling number from the Contact header.  In theory,
the PSTN gateway should sort this out for me and not send me the
'anonymous' From header but I've searched the manuals and it doesn't.
Anyone else encountered this?

This is the IF statement that satisfies the criteria:
if($fu=='sip:[hidden email]' &&
$ct=~"^<sip:[2-9][0-9]{2}[2-9][0-9]{6}@")
{
    xlog("L_INFO", "fix anonymous\n");
}

The final From would be:
From: $ct;$ft
 --> That is Contact header variable;From tag

I had a look at the UAC module but using the function
uac_replace_from(), I don't know how to strip the '<' and '>' of the
Contact header to satisfy the arguments of the function.  Is it
possible?  I'm thinking that using the UAC is preferable to what I'm
proposing below.

Does this method sound sane?  Or is it dangerous?:
remove_hf("From");
append_hf("From: $ct;$ft\r\n");

Thanks,
Julian

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: Rewriting From header using Contact information

Julian Yap
I just tested and this does not work:
remove_hf("From");
append_hf("From: $ct;$ft\r\n");

So basically I want to rewrite the From header by using the details
from the Contact header.

Any suggestions?

- Julian

On Wed, Mar 18, 2009 at 1:15 AM, Julian Yap <[hidden email]> wrote:

> I have a scenario where the PSTN to SIP gateway (AudioCodes) I am
> using sets the From header to 'anonymous' when it does not receive a
> Calling Name from the PSTN side.
>
> The modified INVITE from the gateway then looks like this (changed
> some numbers and IP's):
> From: "anonymous" <sip:[hidden email]>;tag=1c49690767.
> To: <sip:+18085557005@192.168.178.50;user=phone>.
> CSeq: 1 INVITE.
> Contact: <sip:8084446503@192.168.178.60>.
>
> When the gateway does receive the Calling Name from the PSTN, it looks
> like this:
> From: "HONOLULU     HI" <sip:8083330048@192.168.178.60>;tag=1c1248847826.
> To: <sip:+18085557005@192.168.178.50;user=phone>.
> CSeq: 1 INVITE.
> Contact: <sip:8083330048@192.168.178.60>.
>
> In the first instance, I want to re-write the From header because I do
> in fact have the calling number from the Contact header.  In theory,
> the PSTN gateway should sort this out for me and not send me the
> 'anonymous' From header but I've searched the manuals and it doesn't.
> Anyone else encountered this?
>
> This is the IF statement that satisfies the criteria:
> if($fu=='sip:[hidden email]' &&
> $ct=~"^<sip:[2-9][0-9]{2}[2-9][0-9]{6}@")
> {
>    xlog("L_INFO", "fix anonymous\n");
> }
>
> The final From would be:
> From: $ct;$ft
>  --> That is Contact header variable;From tag
>
> I had a look at the UAC module but using the function
> uac_replace_from(), I don't know how to strip the '<' and '>' of the
> Contact header to satisfy the arguments of the function.  Is it
> possible?  I'm thinking that using the UAC is preferable to what I'm
> proposing below.
>
> Does this method sound sane?  Or is it dangerous?:
> remove_hf("From");
> append_hf("From: $ct;$ft\r\n");
>
> Thanks,
> Julian
>

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: Rewriting From header using Contact information

Brett Nemeroff
It's not really standards compliant, but you can do it. I'm not sure why you want to take stuff out of the contact header and stick it in from. From shouldn't ever be changed, if you can help it. If your really trying to change the resultant display name (ie: caller id) then go for manipulating / adding RPID headers instead.


I've had to rewrite "From" headers because non-compliant carriers have insisted on using data in the from header for E911 call routing.. idiots.. :P

If you insist on changing the From header; this may help.. you won't be able to do it the way you are presently trying..

take a look here:

and here:


On Wed, Mar 18, 2009 at 2:37 PM, Julian Yap <[hidden email]> wrote:
I just tested and this does not work:
remove_hf("From");
append_hf("From: $ct;$ft\r\n");

So basically I want to rewrite the From header by using the details
from the Contact header.

Any suggestions?

- Julian

On Wed, Mar 18, 2009 at 1:15 AM, Julian Yap <[hidden email]> wrote:
> I have a scenario where the PSTN to SIP gateway (AudioCodes) I am
> using sets the From header to 'anonymous' when it does not receive a
> Calling Name from the PSTN side.
>
> The modified INVITE from the gateway then looks like this (changed
> some numbers and IP's):
> From: "anonymous" <sip:[hidden email]>;tag=1c49690767.
> To: <[hidden email];user=phone>.
> CSeq: 1 INVITE.
> Contact: <[hidden email]>.
>
> When the gateway does receive the Calling Name from the PSTN, it looks
> like this:
> From: "HONOLULU     HI" <[hidden email]>;tag=1c1248847826.
> To: <[hidden email];user=phone>.
> CSeq: 1 INVITE.
> Contact: <[hidden email]>.
>
> In the first instance, I want to re-write the From header because I do
> in fact have the calling number from the Contact header.  In theory,
> the PSTN gateway should sort this out for me and not send me the
> 'anonymous' From header but I've searched the manuals and it doesn't.
> Anyone else encountered this?
>
> This is the IF statement that satisfies the criteria:
> if($fu=='sip:[hidden email]' &&
> $ct=~"^<sip:[2-9][0-9]{2}[2-9][0-9]{6}@")
> {
>    xlog("L_INFO", "fix anonymous\n");
> }
>
> The final From would be:
> From: $ct;$ft
>  --> That is Contact header variable;From tag
>
> I had a look at the UAC module but using the function
> uac_replace_from(), I don't know how to strip the '<' and '>' of the
> Contact header to satisfy the arguments of the function.  Is it
> possible?  I'm thinking that using the UAC is preferable to what I'm
> proposing below.
>
> Does this method sound sane?  Or is it dangerous?:
> remove_hf("From");
> append_hf("From: $ct;$ft\r\n");
>
> Thanks,
> Julian
>

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users


_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: Rewriting From header using Contact information

Julian Yap
Yeah, I've tried modifying the RPID header...

It looks like that's working for me.  I had to make up a hard coded
display name...

This is slightly off topic but in my current T1's I need to add in an
Asterisk 'wait' command for the facility IE with the Calling name to
be sent through.

ie. --> http://www.voipinfo.org/wiki/view/CallerID

Is there something similar for OpenSIPS?

- Julian

On Wed, Mar 18, 2009 at 9:49 AM, Brett Nemeroff <[hidden email]> wrote:

> It's not really standards compliant, but you can do it. I'm not sure why you
> want to take stuff out of the contact header and stick it in from. From
> shouldn't ever be changed, if you can help it. If your really trying to
> change the resultant display name (ie: caller id) then go for manipulating /
> adding RPID headers instead.
> http://www.opensips.org/html/docs/modules/1.4.x/auth.html#append-rpid-hf-no-params
>
> I've had to rewrite "From" headers because non-compliant carriers have
> insisted on using data in the from header for E911 call routing.. idiots..
> :P
> If you insist on changing the From header; this may help.. you won't be able
> to do it the way you are presently trying..
> take a look here:
> http://www.opensips.org/index.php?n=Resources.DocsTipsFaqs
> and here:
> http://www.opensips.org/html/docs/modules/1.4.x/uac.html#id227417
>
> On Wed, Mar 18, 2009 at 2:37 PM, Julian Yap <[hidden email]> wrote:
>>
>> I just tested and this does not work:
>> remove_hf("From");
>> append_hf("From: $ct;$ft\r\n");
>>
>> So basically I want to rewrite the From header by using the details
>> from the Contact header.
>>
>> Any suggestions?
>>
>> - Julian
>>
>> On Wed, Mar 18, 2009 at 1:15 AM, Julian Yap <[hidden email]> wrote:
>> > I have a scenario where the PSTN to SIP gateway (AudioCodes) I am
>> > using sets the From header to 'anonymous' when it does not receive a
>> > Calling Name from the PSTN side.
>> >
>> > The modified INVITE from the gateway then looks like this (changed
>> > some numbers and IP's):
>> > From: "anonymous" <sip:[hidden email]>;tag=1c49690767.
>> > To: <sip:+18085557005@192.168.178.50;user=phone>.
>> > CSeq: 1 INVITE.
>> > Contact: <sip:8084446503@192.168.178.60>.
>> >
>> > When the gateway does receive the Calling Name from the PSTN, it looks
>> > like this:
>> > From: "HONOLULU     HI"
>> > <sip:8083330048@192.168.178.60>;tag=1c1248847826.
>> > To: <sip:+18085557005@192.168.178.50;user=phone>.
>> > CSeq: 1 INVITE.
>> > Contact: <sip:8083330048@192.168.178.60>.
>> >
>> > In the first instance, I want to re-write the From header because I do
>> > in fact have the calling number from the Contact header.  In theory,
>> > the PSTN gateway should sort this out for me and not send me the
>> > 'anonymous' From header but I've searched the manuals and it doesn't.
>> > Anyone else encountered this?
>> >
>> > This is the IF statement that satisfies the criteria:
>> > if($fu=='sip:[hidden email]' &&
>> > $ct=~"^<sip:[2-9][0-9]{2}[2-9][0-9]{6}@")
>> > {
>> >    xlog("L_INFO", "fix anonymous\n");
>> > }
>> >
>> > The final From would be:
>> > From: $ct;$ft
>> >  --> That is Contact header variable;From tag
>> >
>> > I had a look at the UAC module but using the function
>> > uac_replace_from(), I don't know how to strip the '<' and '>' of the
>> > Contact header to satisfy the arguments of the function.  Is it
>> > possible?  I'm thinking that using the UAC is preferable to what I'm
>> > proposing below.
>> >
>> > Does this method sound sane?  Or is it dangerous?:
>> > remove_hf("From");
>> > append_hf("From: $ct;$ft\r\n");
>> >
>> > Thanks,
>> > Julian
>> >
>>
>> _______________________________________________
>> Users mailing list
>> [hidden email]
>> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>
>

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: Rewriting From header using Contact information

Brett Nemeroff
No,
The "Wait" command is necessary in asterisk because of the timing of when the Caller*ID information is actually transmitted. This doesn't happen in SIP. 

Now on the other hand it sounds to me like you've got an issue with your audiocodes gateway and I'd strongly recommend you going to your vendor for support. You should be able to work that out. Audiocodes products are really fantastic. You really should be getting a RPID header from your audiocodes box.. I'm sure it supports it.
-Brett




On Wed, Mar 18, 2009 at 3:40 PM, Julian Yap <[hidden email]> wrote:
Yeah, I've tried modifying the RPID header...

It looks like that's working for me.  I had to make up a hard coded
display name...

This is slightly off topic but in my current T1's I need to add in an
Asterisk 'wait' command for the facility IE with the Calling name to
be sent through.

ie. --> http://www.voipinfo.org/wiki/view/CallerID

Is there something similar for OpenSIPS?

- Julian

On Wed, Mar 18, 2009 at 9:49 AM, Brett Nemeroff <[hidden email]> wrote:
> It's not really standards compliant, but you can do it. I'm not sure why you
> want to take stuff out of the contact header and stick it in from. From
> shouldn't ever be changed, if you can help it. If your really trying to
> change the resultant display name (ie: caller id) then go for manipulating /
> adding RPID headers instead.
> http://www.opensips.org/html/docs/modules/1.4.x/auth.html#append-rpid-hf-no-params
>
> I've had to rewrite "From" headers because non-compliant carriers have
> insisted on using data in the from header for E911 call routing.. idiots..
> :P
> If you insist on changing the From header; this may help.. you won't be able
> to do it the way you are presently trying..
> take a look here:
> http://www.opensips.org/index.php?n=Resources.DocsTipsFaqs
> and here:
> http://www.opensips.org/html/docs/modules/1.4.x/uac.html#id227417
>
> On Wed, Mar 18, 2009 at 2:37 PM, Julian Yap <[hidden email]> wrote:
>>
>> I just tested and this does not work:
>> remove_hf("From");
>> append_hf("From: $ct;$ft\r\n");
>>
>> So basically I want to rewrite the From header by using the details
>> from the Contact header.
>>
>> Any suggestions?
>>
>> - Julian
>>
>> On Wed, Mar 18, 2009 at 1:15 AM, Julian Yap <[hidden email]> wrote:
>> > I have a scenario where the PSTN to SIP gateway (AudioCodes) I am
>> > using sets the From header to 'anonymous' when it does not receive a
>> > Calling Name from the PSTN side.
>> >
>> > The modified INVITE from the gateway then looks like this (changed
>> > some numbers and IP's):
>> > From: "anonymous" <sip:[hidden email]>;tag=1c49690767.
>> > To: <[hidden email];user=phone>.
>> > CSeq: 1 INVITE.
>> > Contact: <[hidden email]>.
>> >
>> > When the gateway does receive the Calling Name from the PSTN, it looks
>> > like this:
>> > From: "HONOLULU     HI"
>> > <[hidden email]>;tag=1c1248847826.
>> > To: <[hidden email];user=phone>.
>> > CSeq: 1 INVITE.
>> > Contact: <[hidden email]>.
>> >
>> > In the first instance, I want to re-write the From header because I do
>> > in fact have the calling number from the Contact header.  In theory,
>> > the PSTN gateway should sort this out for me and not send me the
>> > 'anonymous' From header but I've searched the manuals and it doesn't.
>> > Anyone else encountered this?
>> >
>> > This is the IF statement that satisfies the criteria:
>> > if($fu=='sip:[hidden email]' &&
>> > $ct=~"^<sip:[2-9][0-9]{2}[2-9][0-9]{6}@")
>> > {
>> >    xlog("L_INFO", "fix anonymous\n");
>> > }
>> >
>> > The final From would be:
>> > From: $ct;$ft
>> >  --> That is Contact header variable;From tag
>> >
>> > I had a look at the UAC module but using the function
>> > uac_replace_from(), I don't know how to strip the '<' and '>' of the
>> > Contact header to satisfy the arguments of the function.  Is it
>> > possible?  I'm thinking that using the UAC is preferable to what I'm
>> > proposing below.
>> >
>> > Does this method sound sane?  Or is it dangerous?:
>> > remove_hf("From");
>> > append_hf("From: $ct;$ft\r\n");
>> >
>> > Thanks,
>> > Julian
>> >
>>
>> _______________________________________________
>> Users mailing list
>> [hidden email]
>> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>
>


_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: Rewriting From header using Contact information

Bogdan-Andrei Iancu
In reply to this post by Julian Yap
Hi Julian,

Do not do that as you will break the dialog consistency - you change one
message from the dialog, but all the other will carry the original FROM.

So, do you the uac_replace_from() function.

use $ct and avp_subst() (over the $ct) to extract only the  part of the  
contact you need.

Regards,
Bogdan

Julian Yap wrote:

> I just tested and this does not work:
> remove_hf("From");
> append_hf("From: $ct;$ft\r\n");
>
> So basically I want to rewrite the From header by using the details
> from the Contact header.
>
> Any suggestions?
>
> - Julian
>
> On Wed, Mar 18, 2009 at 1:15 AM, Julian Yap <[hidden email]> wrote:
>  
>> I have a scenario where the PSTN to SIP gateway (AudioCodes) I am
>> using sets the From header to 'anonymous' when it does not receive a
>> Calling Name from the PSTN side.
>>
>> The modified INVITE from the gateway then looks like this (changed
>> some numbers and IP's):
>> From: "anonymous" <sip:[hidden email]>;tag=1c49690767.
>> To: <sip:+18085557005@192.168.178.50;user=phone>.
>> CSeq: 1 INVITE.
>> Contact: <sip:8084446503@192.168.178.60>.
>>
>> When the gateway does receive the Calling Name from the PSTN, it looks
>> like this:
>> From: "HONOLULU     HI" <sip:8083330048@192.168.178.60>;tag=1c1248847826.
>> To: <sip:+18085557005@192.168.178.50;user=phone>.
>> CSeq: 1 INVITE.
>> Contact: <sip:8083330048@192.168.178.60>.
>>
>> In the first instance, I want to re-write the From header because I do
>> in fact have the calling number from the Contact header.  In theory,
>> the PSTN gateway should sort this out for me and not send me the
>> 'anonymous' From header but I've searched the manuals and it doesn't.
>> Anyone else encountered this?
>>
>> This is the IF statement that satisfies the criteria:
>> if($fu=='sip:[hidden email]' &&
>> $ct=~"^<sip:[2-9][0-9]{2}[2-9][0-9]{6}@")
>> {
>>    xlog("L_INFO", "fix anonymous\n");
>> }
>>
>> The final From would be:
>> From: $ct;$ft
>>  --> That is Contact header variable;From tag
>>
>> I had a look at the UAC module but using the function
>> uac_replace_from(), I don't know how to strip the '<' and '>' of the
>> Contact header to satisfy the arguments of the function.  Is it
>> possible?  I'm thinking that using the UAC is preferable to what I'm
>> proposing below.
>>
>> Does this method sound sane?  Or is it dangerous?:
>> remove_hf("From");
>> append_hf("From: $ct;$ft\r\n");
>>
>> Thanks,
>> Julian
>>
>>    
>
> _______________________________________________
> Users mailing list
> [hidden email]
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>
>  


_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users