Hello everybody,
since this is my first post and I am kinda new to OpenSER, bare with me ;)
I have been trying to manipulate invites for the last 2 days and cant find the proper way to reach what is expected.
my goal: send invites to specific PBX (Asterisk for example) with only the desired extension and not the full username, this is based on a avp_check if that UAC needs only extensions, some do, some don't ;)
Here is what I do: First off all I extract the real username (in subscribers) and extension from the R-URI and place it in "$avp(callee_user)" and "$avp(callee_exten)"
############# my solution No1 is "working"
avp_pushto("$ru/username", "$avp(callee_user)"); avp_copy("$avp(callee_exten)","$avp(callee_tmp)/gd"); if( subst('/^To:(.*)sip:[^@]*(@[a-zA-Z0-9.]+.*)$/To:\1sip:$avp(callee_tmp)\2/ig') ){};
-> callee_user is 012345678 -> callee_exten is 200 -> $ru is sip:012345678@xxx.xxx.xxx.xxx;user=phone -> subst [ To: sip:012345678200@xxx.xxx.xxx.xxx;user=phone ] with [To: sip:200@xxx.xxx.xxx.xxx;user=phone ]
Those 3 lines work "fine", the testing Asterisk PBX gets the call correctly. The problem is that I should not change the "To:" part, it will make problems with call forwards etc...
############# my solution No.2 NOT working.
if (subst_uri('/^sip:([0-9]+)@(.*)$/sip:$avp(callee_tmp)@\2;/i')){$};
doesn't work because OpenSER of course cant find 200 in the userloc....
#############
Generally I would think that changing the INVITE uri itself like in solution No.2 is the best way, couldn't find any proper way to make that work though.
Does anyone have an idea how to realize this properly, or even if this makes sense ;) ?
thx in advance,
Patrick.
Patrick,
You don't want to alter the To header. Extract the extension from the R-URI and save it into an AVP (or var if >= 1.2) , then do a lookup with the resulting R-RUI (user-part without extension), and if it's successful, replace the user-part with the extension saved in the AVP/var.
Cheers, Andreas
Patrick Miccio wrote:
Hello everybody,
since this is my first post and I am kinda new to OpenSER, bare with me ;)
I have been trying to manipulate invites for the last 2 days and cant find the proper way to reach what is expected.
my goal: send invites to specific PBX (Asterisk for example) with only the desired extension and not the full username, this is based on a avp_check if that UAC needs only extensions, some do, some don't ;)
Here is what I do: First off all I extract the real username (in subscribers) and extension from the R-URI and place it in "$avp(callee_user)" and "$avp(callee_exten)"
############# my solution No1 is "working"
avp_pushto("$ru/username", "$avp(callee_user)"); avp_copy("$avp(callee_exten)","$avp(callee_tmp)/gd"); if( subst('/^To:(.*)sip:[^@]*(@[a-zA-Z0-9.]+.*)$/To:\1sip:$avp(callee_tmp)\2/ig') ){};
-> callee_user is 012345678 -> callee_exten is 200 -> $ru is sip:012345678@xxx.xxx.xxx.xxx;user=phone -> subst [ To: sip:012345678200@xxx.xxx.xxx.xxx;user=phone ] with [To: sip:200@xxx.xxx.xxx.xxx;user=phone ]
Those 3 lines work "fine", the testing Asterisk PBX gets the call correctly. The problem is that I should not change the "To:" part, it will make problems with call forwards etc...
############# my solution No.2 NOT working.
if (subst_uri('/^sip:([0-9]+)@(.*)$/sip:$avp(callee_tmp)@\2;/i')){$};
doesn't work because OpenSER of course cant find 200 in the userloc....
#############
Generally I would think that changing the INVITE uri itself like in solution No.2 is the best way, couldn't find any proper way to make that work though.
Does anyone have an idea how to realize this properly, or even if this makes sense ;) ?
thx in advance,
Patrick.
Users mailing list Users@openser.org http://openser.org/cgi-bin/mailman/listinfo/users
Hi Andreas,
what you explained sounds like my solution No.2 (correct me if I am wrong), which is not working, OpenSer makes the userloc check right before relaying the call, if you replace the user part of the R-URI it will try to find the extension ;0)
It feels like for that solution one has to work with the location table, fill it dynamically for each call, or fill in advance with known extensions by copying the basenumber location...
Also using domains in register and location is a must in this case to differentiate between extensions (ext. 200 could be at multiple locations) , but I don't want to transform OpenSER in a PBX.
cheers,
Patrick.
Patrick,
You don't want to alter the To header. Extract the extension from the R-URI and save it into an AVP (or var if >= 1.2) , then do a lookup with the resulting R-RUI (user-part without extension), and if it's successful, replace the user-part with the extension saved in the AVP/var.
Cheers, Andreas
Patrick Miccio wrote:
Hello everybody,
since this is my first post and I am kinda new to OpenSER, bare with me ;)
I have been trying to manipulate invites for the last 2 days and cant find the proper way to reach what is expected.
my goal: send invites to specific PBX (Asterisk for example) with only the desired extension and not the full username, this is based on a avp_check if that UAC needs only extensions, some do, some don't ;)
Here is what I do: First off all I extract the real username (in subscribers) and extension from the R-URI and place it in "$avp(callee_user)" and "$avp(callee_exten)"
############# my solution No1 is "working"
avp_pushto("$ru/username", "$avp(callee_user)"); avp_copy("$avp(callee_exten)","$avp(callee_tmp)/gd"); if( subst('/^To:(.*)sip:[^@]*(@[a-zA-Z0-9.]+.*)$/To:\1sip:$avp(callee_tmp)\2/ig') ){};
-> callee_user is 012345678 -> callee_exten is 200 -> $ru is sip:012345678@xxx.xxx.xxx.xxx;user=phone -> subst [ To: sip:012345678200@xxx.xxx.xxx.xxx;user=phone ] with [To: sip:200@xxx.xxx.xxx.xxx;user=phone ]
Those 3 lines work "fine", the testing Asterisk PBX gets the call correctly. The problem is that I should not change the "To:" part, it will make problems with call forwards etc...
############# my solution No.2 NOT working.
if (subst_uri('/^sip:([0-9]+)@(.*)$/sip:$avp(callee_tmp)@\2;/i')){$};
doesn't work because OpenSER of course cant find 200 in the userloc....
#############
Generally I would think that changing the INVITE uri itself like in solution No.2 is the best way, couldn't find any proper way to make that work though.
Does anyone have an idea how to realize this properly, or even if this makes sense ;) ?
thx in advance,
Patrick.
Users mailing list Users@openser.org http://openser.org/cgi-bin/mailman/listinfo/users
Patrick Miccio wrote:
what you explained sounds like my solution No.2 (correct me if I am wrong), which is not working, OpenSer makes the userloc check right before relaying the call, if you replace the user part of the R-URI it will try to find the extension ;0)
No.
Let's assume your R-URI is sip:01234100@some.domain. Your AOR registered to OpenSER is sip:01234@some.domain with a contact sip:01234@ip, and in some circumstances you only want to send sip:100@ip to the UAC, right?
So you have to extract the extension "100" from the R-URI. Save it into a var or an AVP. Your resulting R-URI then is sip:01234@some.domain. Then do a lookup in the location table, which results in an R-URI sip:01234@ip. Then, replace the user-part of the new R-URI with the value saved in the AVP or var, so your final R-URI is sip:100@ip, which you can relay to the UAC.
Cheers, Andreas
No.
Let's assume your R-URI is sip:01234100@some.domain. Your AOR registered to OpenSER is sip:01234@some.domain with a contact sip:01234@ip, and in some circumstances you only want to send sip:100@ip to the UAC, right?
So you have to extract the extension "100" from the R-URI. Save it into a var or an AVP. Your resulting R-URI then is sip:01234@some.domain. Then do a lookup in the location table, which results in an R-URI sip:01234@ip. Then, replace the user-part of the new R-URI with the value saved in the AVP or var, so your final R-URI is sip:100@ip, which you can relay to the UAC.
Cheers, Andreas
Hey,
I thought about it on the week end, and I was sure you were gonna tell me this, rewriting the R-URI after the userloc check did the trick, didn't know/understand it was possible like this.
Thanks for the help :-)
cheers,
Patrick.