Module: sip-router
Branch: kamailio_3.0
Commit: a9e4d86edeee7b2f70b33c89c91e800aefe11da0
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=a9e4d86…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Fri Jan 8 17:16:28 2010 +0100
kamailio.cfg: updated cfg with sample PSTN gw routing
- defined within WITH_PSTN
- calls to numbers starting with + or 00 are sent to PSTN GW
- use of custome cfg parameter to define GW IP
- remove preloaded Route headers for initial requests
---
etc/kamailio.cfg | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 59 insertions(+), 0 deletions(-)
diff --git a/etc/kamailio.cfg b/etc/kamailio.cfg
index 77727d1..637602d 100644
--- a/etc/kamailio.cfg
+++ b/etc/kamailio.cfg
@@ -38,6 +38,11 @@
# - start RTPProxy:
# rtpproxy -l _your_public_ip_ -s udp:localhost:7722
#
+# *** To enable PSTN gateway routing execute:
+# - define WITH_PSTN
+# - set the value of pstn.gw_ip
+# - check route[PSTN] for regexp routing condition
+#
# *** To enhance accounting execute:
# - enable mysql
# - define WITH_ACCDB
@@ -88,6 +93,26 @@ port=5060
#listen=udp:10.0.0.10:5060
+####### Custom Parameters #########
+
+# These parameters can be modified runtime via RPC interface
+# - see the documentation of 'cfg_rpc' module.
+#
+# Format: group.id = value 'desc' description
+# Access: $sel(cfg_get.group.id) or @cfg_get.group.id
+#
+
+#!ifdef WITH_PSTN
+# PSTN GW Routing
+#
+# - pstn.gw_ip: valid IP or hostname as string value, example:
+# pstn.gw_ip = "10.0.0.101" desc "My PSTN GW Address"
+#
+# - by default is empty to avoid misrouting
+pstn.gw_ip = "" desc "PSTN GW Address"
+#!endif
+
+
####### Modules Section ########
#set module path
@@ -316,6 +341,8 @@ route{
route(AUTH);
# record routing for dialog forming requests (in case they are routed)
+ # - remove preloaded route headers
+ remove_hf("Route");
if (is_method("INVITE|SUBSCRIBE"))
record_route();
@@ -356,6 +383,8 @@ route{
exit;
}
+ route(PSTN);
+
# apply DB based aliases (uncomment to enable)
##alias_db_lookup("dbaliases");
@@ -511,6 +540,36 @@ route[RTPPROXY] {
return;
}
+# PSTN GW routing
+route[PSTN] {
+#!ifdef WITH_PSTN
+ # check if PSTN GW IP is defined
+ if (strempty($sel(cfg_get.pstn.gw_ip))) {
+ xlog("SCRIPT: PSTN rotuing enabled but pstn.gw_ip not defined\n");
+ return;
+ }
+
+ # route to PSTN dialed numbers starting with '+' or '00'
+ # (international format)
+ # - update the condition to match your dialing rules for PSTN routing
+ if(!($rU=~"^(\+|00)[1-9][0-9]{3,20}$"))
+ return;
+
+ # only local users allowed to call
+ if(from_uri!=myself) {
+ sl_send_reply("403", "Not Allowed");
+ exit;
+ }
+
+ $ru = "sip:" + $rU + "@" + $sel(cfg_get.pstn.gw_ip);
+
+ route(RELAY);
+ exit;
+#!endif
+
+ return;
+}
+
# Sample branch router
branch_route[BRANCH_ONE] {
xdbg("new branch at $ru\n");