x-ser(a)sidell.org wrote:
Greetings.
I'm in the processing of converting my ser.cfg file from 0.9 to 2.0,
and am trying to use ser-oob.cfg as a starting point.
I want to forward selected inbound invites to a sems server. In 0.9,
I tested the invite message's uri and forwarded the invites using code
like this:
# Test for a particular DID from the PSTN gateway
#
if (uri =~ "sip:7605796638@") {
log("Forwarding to eliza");
# Do NAT traversal
route(4);
# Tell sems what application to run
append_hf("P-App-Name: fivr\r\n");
append_hf("P-App-Param: cfg_production\r\n");
# Relay the invite to sems
rewritehostport("12.34.56.78:5070");
t_relay_to_udp("12.34.56.78","5070");
break;
}
Will the same code work in ser-oob.cfg?
It should. Although you can replace the regexp in the condition with
@ruri.user == 7605796638
But the old way should still work.
At what point in the script
should I insert these tests?
Probably in route[SITE_SPECIFIC].
Also, does the script and associated
mysql database provide any way to do this sort of forwarding in a more
generic, table-driven, way?
Yes. All these things are done through attributes these days. The
easiest way is probably to create a user but don't give it credentials
so that nobody can register. Then assign the URIs to the user. And
finally, set the attribute "fwd_always_target" for that user in the
user_attrs table. Then ser-oob.cfg will always forward incoming calls
for that user and its assigned URIs to the URI in the attribute.
What you cannot do this way, however, is adding header files as in you
above code snippet. But you shouldn't, anyways. The proper way of
choosing what you media server should do this is through either the
username or URI parameters in the Request-URI. I would presume that SEMS
supports this.
Regards,
Martin