Browse code

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

Daniel-Constantin Mierla authored on 08/01/2010 16:16:28
Showing 1 changed files
... ...
@@ -38,6 +38,11 @@
38 38
 #     - start RTPProxy:
39 39
 #        rtpproxy -l _your_public_ip_ -s udp:localhost:7722
40 40
 #
41
+# *** To enable PSTN gateway routing execute:
42
+#     - define WITH_PSTN
43
+#     - set the value of pstn.gw_ip
44
+#     - check route[PSTN] for regexp routing condition
45
+#
41 46
 # *** To enhance accounting execute:
42 47
 #     - enable mysql
43 48
 #     - define WITH_ACCDB
... ...
@@ -88,6 +93,26 @@ port=5060
88 93
 #listen=udp:10.0.0.10:5060
89 94
 
90 95
 
96
+####### Custom Parameters #########
97
+
98
+# These parameters can be modified runtime via RPC interface
99
+# - see the documentation of 'cfg_rpc' module.
100
+#
101
+# Format: group.id = value 'desc' description
102
+# Access: $sel(cfg_get.group.id) or @cfg_get.group.id
103
+#
104
+
105
+#!ifdef WITH_PSTN
106
+# PSTN GW Routing
107
+#
108
+# - pstn.gw_ip: valid IP or hostname as string value, example:
109
+# pstn.gw_ip = "10.0.0.101" desc "My PSTN GW Address"
110
+#
111
+# - by default is empty to avoid misrouting
112
+pstn.gw_ip = "" desc "PSTN GW Address"
113
+#!endif
114
+
115
+
91 116
 ####### Modules Section ########
92 117
 
93 118
 #set module path
... ...
@@ -316,6 +341,8 @@ route{
316 341
 	route(AUTH);
317 342
 
318 343
 	# record routing for dialog forming requests (in case they are routed)
344
+	# - remove preloaded route headers
345
+	remove_hf("Route");
319 346
 	if (is_method("INVITE|SUBSCRIBE"))
320 347
 		record_route();
321 348
 
... ...
@@ -356,6 +383,8 @@ route{
356 383
 		exit;
357 384
 	}
358 385
 
386
+	route(PSTN);
387
+
359 388
 	# apply DB based aliases (uncomment to enable)
360 389
 	##alias_db_lookup("dbaliases");
361 390
 
... ...
@@ -511,6 +540,36 @@ route[RTPPROXY] {
511 540
 	return;
512 541
 }
513 542
 
543
+# PSTN GW routing
544
+route[PSTN] {
545
+#!ifdef WITH_PSTN
546
+	# check if PSTN GW IP is defined
547
+	if (strempty($sel(cfg_get.pstn.gw_ip))) {
548
+		xlog("SCRIPT: PSTN rotuing enabled but pstn.gw_ip not defined\n");
549
+		return;
550
+	}
551
+
552
+	# route to PSTN dialed numbers starting with '+' or '00'
553
+	#     (international format)
554
+	# - update the condition to match your dialing rules for PSTN routing
555
+	if(!($rU=~"^(\+|00)[1-9][0-9]{3,20}$"))
556
+		return;
557
+
558
+	# only local users allowed to call
559
+	if(from_uri!=myself) {
560
+		sl_send_reply("403", "Not Allowed");
561
+		exit;
562
+	}
563
+
564
+	$ru = "sip:" + $rU + "@" + $sel(cfg_get.pstn.gw_ip);
565
+
566
+	route(RELAY);
567
+	exit;
568
+#!endif
569
+
570
+	return;
571
+}
572
+
514 573
 # Sample branch router
515 574
 branch_route[BRANCH_ONE] {
516 575
 	xdbg("new branch at $ru\n");