Browse code

* Core, etc, documentation: renamed ser to sip-router

* Renamed ser to sip-router in Makefile, etc files and some core files.
* Renamed some etc files from ser based name to sip-router based name.

Juha Heinanen authored on 24/06/2009 12:44:10
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,549 +0,0 @@
1
-#
2
-# $Id$
3
-#
4
-
5
-# First start SER sample config script with:
6
-#   database, accounting, authentication, multi-domain support
7
-#   PSTN GW section, named flags, named routes, global-,
8
-#   domain- and user-preferences with AVPs
9
-# Several of these features are only here for demonstration purpose
10
-# what can be achieved with the SER config script language.
11
-#
12
-# If you look for a simpler version with a lot less dependencies
13
-# please refer to the ser-basic.cfg file in your SER distribution.
14
-
15
-# To get this config running you need to execute the following commands
16
-# with the new serctl (the capital word are just place holders)
17
-# - ser_ctl domain add DOMAINNAME
18
-# - ser_ctl user add USERNAME@DOMAINNAME -p PASSWORD
19
-# If you want to have PID header for your user
20
-# - ser_attr add uid=UID asserted_id="PID"
21
-# If you want to have gateway support
22
-# - ser_db add attr_types name=gw_ip rich_type=string raw_type=2 description="The gateway IP for the default ser.cfg" default_flags=33
23
-# - ser_attr add global gw_ip=GATEWAY-IP
24
-
25
-# ----------- global configuration parameters ------------------------
26
-
27
-debug=2         # debug level (cmd line: -dddddddddd)
28
-#memdbg=10 # memory debug log level
29
-#memlog=10 # memory statistics log level
30
-#log_facility=LOG_LOCAL0 # sets the facility used for logging (see syslog(3))
31
-
32
-/* Uncomment these lines to enter debugging mode 
33
-fork=no
34
-log_stderror=yes
35
-*/
36
-
37
-check_via=no    # (cmd. line: -v)
38
-dns=no          # (cmd. line: -r)
39
-rev_dns=no      # (cmd. line: -R)
40
-#port=5060
41
-#children=4
42
-#user=ser
43
-#group=ser
44
-#disable_core=yes #disables core dumping
45
-#open_fd_limit=1024 # sets the open file descriptors limit
46
-#mhomed=yes  # usefull for multihomed hosts, small performance penalty
47
-#disable_tcp=yes 
48
-#tcp_accept_aliases=yes # accepts the tcp alias via option (see NEWS)
49
-enable_tls=yes
50
-
51
-#
52
-
53
-# ------------------ module loading ----------------------------------
54
-
55
-#loadpath "modules:modules_s"
56
-loadpath "/usr/lib/ser/modules:/usr/lib/ser/modules_s"
57
-
58
-# load a SQL database for authentication, domains, user AVPs etc.
59
-loadmodule "db_mysql"
60
-
61
-loadmodule "sl"
62
-loadmodule "tm"
63
-loadmodule "rr"
64
-loadmodule "maxfwd"
65
-loadmodule "usrloc"
66
-loadmodule "registrar"
67
-loadmodule "xlog"
68
-loadmodule "textops"
69
-loadmodule "ctl"
70
-loadmodule "cfg_rpc"
71
-loadmodule "auth"
72
-loadmodule "auth_db"
73
-loadmodule "gflags"
74
-loadmodule "domain"
75
-loadmodule "uri_db"
76
-loadmodule "avp"
77
-loadmodule "avp_db"
78
-loadmodule "acc_db"
79
-loadmodule "xmlrpc"
80
-#loadmodule "tls"
81
-
82
-# ----------------- setting script FLAGS -----------------------------
83
-flags
84
-  FLAG_ACC          : 1,  # include message in accounting
85
-  FLAG_FAILUREROUTE : 2;  # we are operating from a failure route
86
-
87
-avpflags
88
-  dialog_cookie;        # handled by rr module
89
-
90
-# ----------------- setting module-specific parameters ---------------
91
-
92
-# specify the path to you database here
93
-modparam("acc_db|auth_db|avp_db|domain|gflags|usrloc|uri_db", "db_url", "mysql://ser:heslo@127.0.0.1/ser")
94
-
95
-# -- usrloc params --
96
-
97
-# as we use the database anyway we will use it for usrloc as well
98
-modparam("usrloc", "db_mode", 1)
99
-
100
-# -- auth params --
101
-modparam("auth_db", "calculate_ha1", yes)
102
-modparam("auth_db", "plain_password_column", "password")
103
-
104
-# -- rr params --
105
-# add value to ;lr param to make some broken UAs happy
106
-modparam("rr", "enable_full_lr", 1)
107
-#
108
-# limit the length of the AVP cookie to only necessary ones
109
-modparam("rr", "cookie_filter", "(account)")
110
-#
111
-# you probably do not want that someone can simply read and change
112
-# the AVP cookie in your Routes, thus should really change this
113
-# secret value below
114
-modparam("rr", "cookie_secret", "MyRRAVPcookiesecret")
115
-
116
-# -- gflags params --
117
-# load the global AVPs
118
-modparam("gflags", "load_global_attrs", 1)
119
-
120
-# -- domain params --
121
-# load the domain AVPs
122
-modparam("domain", "load_domain_attrs", 1)
123
-
124
-# -- ctl params --
125
-# by default ctl listens on unixs:/tmp/ser_ctl if no other address is
126
-# specified in modparams; this is also the default for sercmd
127
-modparam("ctl", "binrpc", "unixs:/tmp/ser_ctl")
128
-# listen on the "standard" fifo for backward compatibility
129
-modparam("ctl", "fifo", "fifo:/tmp/ser_fifo")
130
-# listen on tcp, localhost
131
-#modparam("ctl", "binrpc", "tcp:localhost:2046")
132
-
133
-# -- acc_db params --
134
-# failed transactions (=negative responses) should be logged to
135
-modparam("acc_db", "failed_transactions", 1)
136
-
137
-# comment the next line if you dont want to have accounting to DB
138
-modparam("acc_db", "log_flag", "FLAG_ACC")
139
-
140
-# -- tm params --
141
-# uncomment the following line if you want to avoid that each new reply
142
-# restarts the resend timer (see INBOUND route below)
143
-#modparam("tm", "restart_fr_on_each_reply", "0")
144
-
145
-# -- xmlrpc params --
146
-# using a sub-route from the module is a lot safer then relying on the
147
-# request method to distinguish HTTP from SIP
148
-modparam("xmlrpc", "route", "RPC");
149
-
150
-# -------------------------  request routing logic -------------------
151
-
152
-# main routing logic
153
-
154
-route{
155
-	# if you have a PSTN gateway just un-comment the follwoing line and 
156
-	# specify the IP address of it to route calls to it
157
-	#$gw_ip = "1.2.3.4"
158
-
159
-	# first do some initial sanity checks
160
-	route(INIT);
161
-
162
-	# bypass the rest of the script for CANCELs if possible
163
-	route(CATCH_CANCEL);
164
-
165
-	# check if the request is routed via Route header or
166
-	# needs a Record-Route header
167
-	route(RR);
168
-
169
-	# check if the request belongs to our proxy
170
-	route(DOMAIN);
171
-
172
-	# handle REGISTER requests
173
-	route(REGISTRAR);
174
-
175
-	# from here on we want to know you is calling
176
-	route(AUTHENTICATION);
177
-
178
-	# check if we should be outbound proxy for a local user
179
-	route(OUTBOUND);
180
-
181
-	# check if the request is for a local user
182
-	route(INBOUND);
183
-
184
-	# here you could for example try to do an ENUM lookup before
185
-	# the call gets routed to the PSTN
186
-	#route(ENUM);
187
-
188
-	# lets see if someone wants to call a PSTN number
189
-	route(PSTN);
190
-
191
-	# nothing matched, reject it finally
192
-	sl_reply("404", "No route matched");
193
-}
194
-
195
-route[FORWARD]
196
-{
197
-	# here you could decide wether this call needs a RTP relay or not
198
-
199
-	# if this is called from the failure route we need to open a new branch
200
-	if (isflagset(FLAG_FAILUREROUTE)) {
201
-		append_branch();
202
-	}
203
-
204
-	# if this is an initial INVITE (without a To-tag) we might try another
205
-	# (forwarding or voicemail) target after receiving an error
206
-	if (method=="INVITE" && strempty(@to.tag)) {
207
-		t_on_failure("FAILURE_ROUTE");
208
-	}
209
-
210
-	# send it out now; use stateful forwarding as it works reliably
211
-	# even for UDP2TCP
212
-	if (!t_relay()) {
213
-		sl_reply_error();
214
-	}
215
-	drop;
216
-}
217
-
218
-route[INIT]
219
-{
220
-	# initial sanity checks -- messages with
221
-	# max_forwards==0, or excessively long requests
222
-	if (!mf_process_maxfwd_header("10")) {
223
-		sl_reply("483","Too Many Hops");
224
-		drop;
225
-	}
226
-
227
-	if (msg:len >=  4096 ) {
228
-		sl_reply("513", "Message too big");
229
-		drop;
230
-	}
231
-
232
-	# you could add some NAT detection here for example
233
-
234
-	# or you cuold call here some of the check from the sanity module
235
-
236
-	# lets account all initial INVITEs
237
-	# further in-dialog requests are accounted by a RR cookie (see below)
238
-	if (method=="INVITE" && strempty(@to.tag)) {
239
-		setflag(FLAG_ACC);
240
-	}
241
-}
242
-
243
-route[RPC]
244
-{
245
-	# allow XMLRPC from localhost
246
-	if ((method=="POST" || method=="GET") &&
247
-		src_ip==127.0.0.1) {
248
-
249
-		if (msg:len >= 8192) {
250
-			sl_reply("513", "Request to big");
251
-			drop;
252
-		}
253
-
254
-		# lets see if a module wants to answer this
255
-		dispatch_rpc();
256
-		drop;
257
-	}
258
-}
259
-
260
-route[RR]
261
-{
262
-	# subsequent messages withing a dialog should take the
263
-	# path determined by record-routing
264
-	if (loose_route()) {
265
-		# mark routing logic in request
266
-		append_hf("P-hint: rr-enforced\r\n"); 
267
-
268
-		# if the Route contained the accounting AVP cookie we
269
-		# set the accounting flag for the acc_db module.
270
-		# this is more for demonstration purpose as this could
271
-		# also be solved without RR cookies.
272
-		# Note: this means all in-dialog request will show up in the
273
-		# accounting tables, so prepare your accounting software for this ;-)
274
-		if ($account == "yes") {
275
-			setflag(FLAG_ACC);
276
-		}
277
-
278
-		# for broken devices which overwrite their Route's with each
279
-		# (not present) RR from within dialog requests it is better
280
-		# to repeat the RRing
281
-		# and if we call rr after loose_route the AVP cookies are restored
282
-		# automatically :)
283
-		record_route();
284
-
285
-		route(FORWARD);
286
-	} else if (!method=="REGISTER") {
287
-		# we record-route all messages -- to make sure that
288
-		# subsequent messages will go through our proxy; that's
289
-		# particularly good if upstream and downstream entities
290
-		# use different transport protocol
291
-
292
-		# if the inital INVITE got the ACC flag store this in
293
-		# an RR AVP cookie. this is more for demonstration purpose
294
-		if (isflagset(FLAG_ACC)) {
295
-			$account = "yes";
296
-			setavpflag($account, "dialog_cookie");
297
-		}
298
-
299
-		record_route();
300
-	}
301
-}
302
-
303
-route[DOMAIN]
304
-{
305
-	# check if the caller is from a local domain
306
-	lookup_domain("$fd", "@from.uri.host");
307
-
308
-	# check if the callee is at a local domain
309
-	lookup_domain("$td", "@ruri.host");
310
-
311
-	# we dont know the domain of the caller and also not
312
-	# the domain of the callee -> somone uses our proxy as
313
-	# a relay
314
-	if (strempty($t.did) && strempty($f.did)) {
315
-		sl_reply("403", "Relaying Forbidden");
316
-		drop;
317
-	}
318
-}
319
-
320
-route[REGISTRAR]
321
-{
322
-	# if the request is a REGISTER lets take care of it
323
-	if (method=="REGISTER") {
324
-		# check if the REGISTER if for one of our local domains
325
-		if (strempty($t.did)) {
326
-			sl_reply("403", "Register forwarding forbidden");
327
-			drop;
328
-		}
329
-
330
-		# we want only authenticated users to be registered
331
-		if (!www_authenticate("$fd.digest_realm", "credentials")) {
332
-			if ($? == -2) {
333
-				sl_reply("500", "Internal Server Error");
334
-			} else if ($? == -3) {
335
-				sl_reply("400", "Bad Request");
336
-			} else {
337
-				if ($digest_challenge != "") {
338
-					append_to_reply("%$digest_challenge");
339
-				}
340
-				sl_reply("401", "Unauthorized");
341
-			}
342
-			drop;
343
-		}
344
-
345
-		# check if the authenticated user is the same as the target user
346
-		if (!lookup_user("$tu.uid", "@to.uri")) {
347
-			sl_reply("404", "Unknown user in To");
348
-			drop;
349
-		}
350
-
351
-		if ($f.uid != $t.uid) {
352
-			sl_reply("403", "Authentication and To-Header mismatch");
353
-			drop;
354
-		}
355
-
356
-		# check if the authenticated user is the same as the request originator
357
-		# you may uncomment it if you care, what uri is in From header
358
-		#if (!lookup_user("$fu.uid", "@from.uri")) {
359
-		#	sl_reply("404", "Unknown user in From");
360
-		#	drop;
361
-		#}
362
-		#if ($fu.uid != $tu.uid) {
363
-		#	sl_reply("403", "Authentication and From-Header mismatch");
364
-		#	drop;
365
-		#}
366
-
367
-		# everyhting is fine so lets store the binding
368
-		if (!save_contacts("location")) {
369
-			sl_reply("400", "Invalid REGISTER Request");
370
-			drop;
371
-		}
372
-		drop;
373
-	}
374
-}
375
-
376
-route[AUTHENTICATION]
377
-{
378
-	if (method=="CANCEL" || method=="ACK") {
379
-		# you are not allowed to challenge these methods
380
-		break;
381
-	}
382
-
383
-	# requests from non-local to local domains should be permitted
384
-	# remove this if you want a walled garden
385
-	if (strempty($f.did)) {
386
-		break;
387
-	}
388
-
389
-	# as gateways are usually not able to authenticate for their
390
-	# requests you will have trust them base on some other information
391
-	# like the source IP address. WARNING: if at all this is only safe
392
-	# in a local network!!!
393
-	#if (src_ip==a.b.c.d) {
394
-	#	break;
395
-	#}
396
-
397
-	if (!proxy_authenticate("$fd.digest_realm", "credentials")) {
398
-		if ($? == -2) {
399
-			sl_reply("500", "Internal Server Error");
400
-		} else if ($? == -3) {
401
-			sl_reply("400", "Bad Request");
402
-		} else {
403
-			if ($digest_challenge != "") {
404
-				append_to_reply("%$digest_challenge");
405
-			}
406
-			sl_reply("407", "Proxy Authentication Required");
407
-		}
408
-		drop;
409
-	}
410
-
411
-	# check if the UID from the authentication meets the From header
412
-	$authuid = $uid;
413
-	if (!lookup_user("$fu.uid", "@from.uri")) {
414
-		del_attr("$uid");
415
-	}
416
-	if ($fu.uid != $fr.authuid) {
417
-		sl_reply("403", "Fake Identity");
418
-		drop;
419
-	}
420
-	# load the user AVPs (preferences) of the caller, e.g. for RPID header
421
-	load_attrs("$fu", "$f.uid");
422
-}
423
-
424
-route[OUTBOUND]
425
-{
426
-	# if a local user calls to a foreign domain we play outbound proxy for him
427
-	# comment this out if you want a walled garden
428
-	if ($f.did != ""  && $t.did == "") {
429
-		append_hf("P-hint: outbound\r\n");
430
-		route(FORWARD);
431
-	}
432
-}
433
-
434
-route[INBOUND]
435
-{
436
-	# lets see if know the callee
437
-	if (lookup_user("$tu.uid", "@ruri")) {
438
-
439
-		# load the preferences of the callee to have his timeout values loaded
440
-		load_attrs("$tu", "$t.uid");
441
-
442
-		# if you want to know if the callee username was an alias
443
-		# check it like this
444
-		#if (strempty($tu.uri_canonical)) {
445
-			# if the alias URI has different AVPs/preferences
446
-			# you can load them into the URI track like this
447
-			#load_attrs("$tr", "@ruri");
448
-		#}
449
-
450
-		# check for call forwarding of the callee
451
-		# Note: the forwarding target has to be full routable URI
452
-		#       in this example
453
-		if ($tu.fwd_always_target != "") {
454
-			attr2uri("$tu.fwd_always_target");
455
-			route(FORWARD);
456
-		}
457
-
458
-		# native SIP destinations are handled using our USRLOC DB
459
-		if (lookup_contacts("location")) {
460
-			append_hf("P-hint: usrloc applied\r\n");
461
-
462
-			# we set the TM module timers according to the prefences
463
-			# of the callee (avoid too long ringing of his phones)
464
-			# Note1: timer values have to be in ms now!
465
-			# Note2: this makes even more sense if you switch to a voicemail
466
-			#        from the FAILURE_ROUTE below
467
-			if ($t.fr_inv_timer != 0) {
468
-				if ($t.fr_timer != 0) {
469
-					t_set_fr("$t.fr_inv_timer", "$t.fr_timer");
470
-				} else {
471
-					t_set_fr("$t.fr_inv_timer");
472
-				}
473
-			}
474
-
475
-			route(FORWARD);
476
-		} else {
477
-			sl_reply("480", "User temporarily not available");
478
-			drop;
479
-		}
480
-	}
481
-}
482
-
483
-route[PSTN]
484
-{
485
-	# Only if the AVP 'gw_ip' is set and the request URI contains
486
-	# only a number we consider sending this to the PSTN GW.
487
-	# Only users from a local domain are permitted to make calls.
488
-	# Additionally you might want to check the acl AVP to verify
489
-	# that the user is allowed to make such expensives calls.
490
-	if ($f.did != "" && $gw_ip != "" &&
491
-		uri=~"sips?:\+?[0-9]{3,18}@.*") {
492
-		# probably you need to convert the number in the request
493
-		# URI according to the requirements of your gateway here
494
-
495
-		# if an AVP 'asserted_id' is set we insert an RPID header
496
-		if ($asserted_id != "") {
497
-			xlset_attr("$rpidheader", "<sip:%$asserted_id@%@ruri.host>;screen=yes");
498
-			replace_attr_hf("Remote-Party-ID", "$rpidheader");
499
-		}
500
-
501
-		# just replace the domain part of the RURI with the
502
-		# value from the AVP and send it out
503
-		attr2uri("$gw_ip", "domain");
504
-		route(FORWARD);
505
-	}
506
-}
507
-
508
-route[CATCH_CANCEL] {
509
-	# check whether there is a corresponding INVITE to the CANCEL,
510
-	# and bypass the rest of the script if possible
511
-
512
-	if (method == CANCEL) {
513
-		if (!t_relay_cancel()) { # implicit drop if the INVITE was found
514
-
515
-			# INVITE was found but some error occurred
516
-			sl_reply("500", "Internal Server Error");
517
-			drop;
518
-		}
519
-		# bad luck, no corresponding INVITE was found,
520
-		# we have to continue with the script
521
-	}
522
-}
523
-
524
-failure_route[FAILURE_ROUTE]
525
-{
526
-	# mark for the other routes that we are operating from here on from a
527
-	# failure route
528
-	setflag(FLAG_FAILUREROUTE);
529
-
530
-	if (t_check_status("486|600")) {
531
-		# if we received a busy and a busy target is set, forward it there
532
-		# Note: again the forwarding target has to be a routeable URI
533
-		if ($tu.fwd_busy_target != "") {
534
-			attr2uri("$tu.fwd_busy_target");
535
-			route(FORWARD);
536
-		}
537
-		# alternatively you could forward the request to SEMS/voicemail here
538
-	}
539
-	else if (t_check_status("408|480")) {
540
-		# if we received no answer and the noanswer target is set,
541
-		# forward it there
542
-		# Note: again the target has to be a routeable URI
543
-		if ($tu.fwd_noanswer_target != "") {
544
-			attr2uri("$tu.fwd_noanswer_target");
545
-			route(FORWARD);
546
-		}
547
-		# alternatively you could forward the request to SEMS/voicemail here
548
-	}
549
-}
Browse code

cfg: example configs migrated to sip-router

Ported ser example configs to sip-router:
- updated module path (now using loadpath)
- changed mysql module name to db_mysql
- replaced max_len in msg:len comparisons with 4096
- updated avp and selects non-empty checks:
if($v) -> if ($v!="")
if(!$v) -> if (strempty($v)) or if ($v=="")

Andrei Pelinescu-Onciul authored on 06/05/2009 15:50:53
Showing 1 changed files
... ...
@@ -24,7 +24,7 @@
24 24
 
25 25
 # ----------- global configuration parameters ------------------------
26 26
 
27
-debug=3         # debug level (cmd line: -dddddddddd)
27
+debug=2         # debug level (cmd line: -dddddddddd)
28 28
 #memdbg=10 # memory debug log level
29 29
 #memlog=10 # memory statistics log level
30 30
 #log_facility=LOG_LOCAL0 # sets the facility used for logging (see syslog(3))
... ...
@@ -52,29 +52,32 @@ enable_tls=yes
52 52
 
53 53
 # ------------------ module loading ----------------------------------
54 54
 
55
+#loadpath "modules:modules_s"
56
+loadpath "/usr/lib/ser/modules:/usr/lib/ser/modules_s"
57
+
55 58
 # load a SQL database for authentication, domains, user AVPs etc.
56
-loadmodule "/usr/local/lib/ser/modules/mysql.so"
57
-
58
-loadmodule "/usr/local/lib/ser/modules/sl.so"
59
-loadmodule "/usr/local/lib/ser/modules/tm.so"
60
-loadmodule "/usr/local/lib/ser/modules/rr.so"
61
-loadmodule "/usr/local/lib/ser/modules/maxfwd.so"
62
-loadmodule "/usr/local/lib/ser/modules/usrloc.so"
63
-loadmodule "/usr/local/lib/ser/modules/registrar.so"
64
-loadmodule "/usr/local/lib/ser/modules/xlog.so"
65
-loadmodule "/usr/local/lib/ser/modules/textops.so"
66
-loadmodule "/usr/local/lib/ser/modules/ctl.so"
67
-loadmodule "/usr/local/lib/ser/modules/fifo.so"
68
-loadmodule "/usr/local/lib/ser/modules/auth.so"
69
-loadmodule "/usr/local/lib/ser/modules/auth_db.so"
70
-loadmodule "/usr/local/lib/ser/modules/gflags.so"
71
-loadmodule "/usr/local/lib/ser/modules/domain.so"
72
-loadmodule "/usr/local/lib/ser/modules/uri_db.so"
73
-loadmodule "/usr/local/lib/ser/modules/avp.so"
74
-loadmodule "/usr/local/lib/ser/modules/avp_db.so"
75
-loadmodule "/usr/local/lib/ser/modules/acc_db.so"
76
-loadmodule "/usr/local/lib/ser/modules/xmlrpc.so"
77
-#loadmodule "/usr/local/lib/ser/modules/tls.so"
59
+loadmodule "db_mysql"
60
+
61
+loadmodule "sl"
62
+loadmodule "tm"
63
+loadmodule "rr"
64
+loadmodule "maxfwd"
65
+loadmodule "usrloc"
66
+loadmodule "registrar"
67
+loadmodule "xlog"
68
+loadmodule "textops"
69
+loadmodule "ctl"
70
+loadmodule "cfg_rpc"
71
+loadmodule "auth"
72
+loadmodule "auth_db"
73
+loadmodule "gflags"
74
+loadmodule "domain"
75
+loadmodule "uri_db"
76
+loadmodule "avp"
77
+loadmodule "avp_db"
78
+loadmodule "acc_db"
79
+loadmodule "xmlrpc"
80
+#loadmodule "tls"
78 81
 
79 82
 # ----------------- setting script FLAGS -----------------------------
80 83
 flags
... ...
@@ -200,7 +203,7 @@ route[FORWARD]
200 203
 
201 204
 	# if this is an initial INVITE (without a To-tag) we might try another
202 205
 	# (forwarding or voicemail) target after receiving an error
203
-	if (method=="INVITE" && !@to.tag) {
206
+	if (method=="INVITE" && strempty(@to.tag)) {
204 207
 		t_on_failure("FAILURE_ROUTE");
205 208
 	}
206 209
 
... ...
@@ -221,7 +224,7 @@ route[INIT]
221 224
 		drop;
222 225
 	}
223 226
 
224
-	if (msg:len >=  max_len ) {
227
+	if (msg:len >=  4096 ) {
225 228
 		sl_reply("513", "Message too big");
226 229
 		drop;
227 230
 	}
... ...
@@ -232,7 +235,7 @@ route[INIT]
232 235
 
233 236
 	# lets account all initial INVITEs
234 237
 	# further in-dialog requests are accounted by a RR cookie (see below)
235
-	if (method=="INVITE" && !@to.tag) {
238
+	if (method=="INVITE" && strempty(@to.tag)) {
236 239
 		setflag(FLAG_ACC);
237 240
 	}
238 241
 }
... ...
@@ -308,7 +311,7 @@ route[DOMAIN]
308 311
 	# we dont know the domain of the caller and also not
309 312
 	# the domain of the callee -> somone uses our proxy as
310 313
 	# a relay
311
-	if (!$t.did && !$f.did) {
314
+	if (strempty($t.did) && strempty($f.did)) {
312 315
 		sl_reply("403", "Relaying Forbidden");
313 316
 		drop;
314 317
 	}
... ...
@@ -319,7 +322,7 @@ route[REGISTRAR]
319 322
 	# if the request is a REGISTER lets take care of it
320 323
 	if (method=="REGISTER") {
321 324
 		# check if the REGISTER if for one of our local domains
322
-		if (!$t.did) {
325
+		if (strempty($t.did)) {
323 326
 			sl_reply("403", "Register forwarding forbidden");
324 327
 			drop;
325 328
 		}
... ...
@@ -331,7 +334,7 @@ route[REGISTRAR]
331 334
 			} else if ($? == -3) {
332 335
 				sl_reply("400", "Bad Request");
333 336
 			} else {
334
-				if ($digest_challenge) {
337
+				if ($digest_challenge != "") {
335 338
 					append_to_reply("%$digest_challenge");
336 339
 				}
337 340
 				sl_reply("401", "Unauthorized");
... ...
@@ -379,7 +382,7 @@ route[AUTHENTICATION]
379 382
 
380 383
 	# requests from non-local to local domains should be permitted
381 384
 	# remove this if you want a walled garden
382
-	if (! $f.did) {
385
+	if (strempty($f.did)) {
383 386
 		break;
384 387
 	}
385 388
 
... ...
@@ -397,7 +400,7 @@ route[AUTHENTICATION]
397 400
 		} else if ($? == -3) {
398 401
 			sl_reply("400", "Bad Request");
399 402
 		} else {
400
-			if ($digest_challenge) {
403
+			if ($digest_challenge != "") {
401 404
 				append_to_reply("%$digest_challenge");
402 405
 			}
403 406
 			sl_reply("407", "Proxy Authentication Required");
... ...
@@ -422,7 +425,7 @@ route[OUTBOUND]
422 425
 {
423 426
 	# if a local user calls to a foreign domain we play outbound proxy for him
424 427
 	# comment this out if you want a walled garden
425
-	if ($f.did && ! $t.did) {
428
+	if ($f.did != ""  && $t.did == "") {
426 429
 		append_hf("P-hint: outbound\r\n");
427 430
 		route(FORWARD);
428 431
 	}
... ...
@@ -438,7 +441,7 @@ route[INBOUND]
438 441
 
439 442
 		# if you want to know if the callee username was an alias
440 443
 		# check it like this
441
-		#if (! $tu.uri_canonical) {
444
+		#if (strempty($tu.uri_canonical)) {
442 445
 			# if the alias URI has different AVPs/preferences
443 446
 			# you can load them into the URI track like this
444 447
 			#load_attrs("$tr", "@ruri");
... ...
@@ -447,7 +450,7 @@ route[INBOUND]
447 450
 		# check for call forwarding of the callee
448 451
 		# Note: the forwarding target has to be full routable URI
449 452
 		#       in this example
450
-		if ($tu.fwd_always_target) {
453
+		if ($tu.fwd_always_target != "") {
451 454
 			attr2uri("$tu.fwd_always_target");
452 455
 			route(FORWARD);
453 456
 		}
... ...
@@ -461,8 +464,8 @@ route[INBOUND]
461 464
 			# Note1: timer values have to be in ms now!
462 465
 			# Note2: this makes even more sense if you switch to a voicemail
463 466
 			#        from the FAILURE_ROUTE below
464
-			if ($t.fr_inv_timer) {
465
-				if ($t.fr_timer) {
467
+			if ($t.fr_inv_timer != 0) {
468
+				if ($t.fr_timer != 0) {
466 469
 					t_set_fr("$t.fr_inv_timer", "$t.fr_timer");
467 470
 				} else {
468 471
 					t_set_fr("$t.fr_inv_timer");
... ...
@@ -484,13 +487,13 @@ route[PSTN]
484 487
 	# Only users from a local domain are permitted to make calls.
485 488
 	# Additionally you might want to check the acl AVP to verify
486 489
 	# that the user is allowed to make such expensives calls.
487
-	if ($f.did && $gw_ip &&
490
+	if ($f.did != "" && $gw_ip != "" &&
488 491
 		uri=~"sips?:\+?[0-9]{3,18}@.*") {
489 492
 		# probably you need to convert the number in the request
490 493
 		# URI according to the requirements of your gateway here
491 494
 
492 495
 		# if an AVP 'asserted_id' is set we insert an RPID header
493
-		if ($asserted_id) {
496
+		if ($asserted_id != "") {
494 497
 			xlset_attr("$rpidheader", "<sip:%$asserted_id@%@ruri.host>;screen=yes");
495 498
 			replace_attr_hf("Remote-Party-ID", "$rpidheader");
496 499
 		}
... ...
@@ -527,7 +530,7 @@ failure_route[FAILURE_ROUTE]
527 530
 	if (t_check_status("486|600")) {
528 531
 		# if we received a busy and a busy target is set, forward it there
529 532
 		# Note: again the forwarding target has to be a routeable URI
530
-		if ($tu.fwd_busy_target) {
533
+		if ($tu.fwd_busy_target != "") {
531 534
 			attr2uri("$tu.fwd_busy_target");
532 535
 			route(FORWARD);
533 536
 		}
... ...
@@ -537,7 +540,7 @@ failure_route[FAILURE_ROUTE]
537 540
 		# if we received no answer and the noanswer target is set,
538 541
 		# forward it there
539 542
 		# Note: again the target has to be a routeable URI
540
-		if ($tu.fwd_noanswer_target) {
543
+		if ($tu.fwd_noanswer_target != "") {
541 544
 			attr2uri("$tu.fwd_noanswer_target");
542 545
 			route(FORWARD);
543 546
 		}
Browse code

- added various tls options (commented out)

Jan Janak authored on 23/06/2008 17:53:09
Showing 1 changed files
... ...
@@ -46,6 +46,7 @@ rev_dns=no      # (cmd. line: -R)
46 46
 #mhomed=yes  # usefull for multihomed hosts, small performance penalty
47 47
 #disable_tcp=yes 
48 48
 #tcp_accept_aliases=yes # accepts the tcp alias via option (see NEWS)
49
+enable_tls=yes
49 50
 
50 51
 #
51 52
 
... ...
@@ -73,6 +74,7 @@ loadmodule "/usr/local/lib/ser/modules/avp.so"
73 74
 loadmodule "/usr/local/lib/ser/modules/avp_db.so"
74 75
 loadmodule "/usr/local/lib/ser/modules/acc_db.so"
75 76
 loadmodule "/usr/local/lib/ser/modules/xmlrpc.so"
77
+#loadmodule "/usr/local/lib/ser/modules/tls.so"
76 78
 
77 79
 # ----------------- setting script FLAGS -----------------------------
78 80
 flags
Browse code

fix some typos; accouting -> accounting

Alfred E. Heggestad authored on 12/06/2008 13:28:04
Showing 1 changed files
... ...
@@ -76,7 +76,7 @@ loadmodule "/usr/local/lib/ser/modules/xmlrpc.so"
76 76
 
77 77
 # ----------------- setting script FLAGS -----------------------------
78 78
 flags
79
-  FLAG_ACC          : 1,  # include message in accouting
79
+  FLAG_ACC          : 1,  # include message in accounting
80 80
   FLAG_FAILUREROUTE : 2;  # we are operating from a failure route
81 81
 
82 82
 avpflags
... ...
@@ -129,7 +129,7 @@ modparam("ctl", "fifo", "fifo:/tmp/ser_fifo")
129 129
 # failed transactions (=negative responses) should be logged to
130 130
 modparam("acc_db", "failed_transactions", 1)
131 131
 
132
-# comment the next line if you dont want to have accouting to DB
132
+# comment the next line if you dont want to have accounting to DB
133 133
 modparam("acc_db", "log_flag", "FLAG_ACC")
134 134
 
135 135
 # -- tm params --
... ...
@@ -265,7 +265,7 @@ route[RR]
265 265
 		# this is more for demonstration purpose as this could
266 266
 		# also be solved without RR cookies.
267 267
 		# Note: this means all in-dialog request will show up in the
268
-		# accouting tables, so prepare your accounting software for this ;-)
268
+		# accounting tables, so prepare your accounting software for this ;-)
269 269
 		if ($account == "yes") {
270 270
 			setflag(FLAG_ACC);
271 271
 		}
Browse code

Replacing @select=="" with !@select, because the latter is safer. (The select must exist with empty string value in order to evaluate @select=="" as true.)

Miklos Tirpak authored on 23/04/2008 15:34:28
Showing 1 changed files
... ...
@@ -198,7 +198,7 @@ route[FORWARD]
198 198
 
199 199
 	# if this is an initial INVITE (without a To-tag) we might try another
200 200
 	# (forwarding or voicemail) target after receiving an error
201
-	if (method=="INVITE" && @to.tag=="") {
201
+	if (method=="INVITE" && !@to.tag) {
202 202
 		t_on_failure("FAILURE_ROUTE");
203 203
 	}
204 204
 
... ...
@@ -230,7 +230,7 @@ route[INIT]
230 230
 
231 231
 	# lets account all initial INVITEs
232 232
 	# further in-dialog requests are accounted by a RR cookie (see below)
233
-	if (method=="INVITE" && @to.tag=="") {
233
+	if (method=="INVITE" && !@to.tag) {
234 234
 		setflag(FLAG_ACC);
235 235
 	}
236 236
 }
Browse code

t_relay_cancel() is added to the sample configuration

Miklos Tirpak authored on 30/05/2007 12:28:17
Showing 1 changed files
... ...
@@ -154,6 +154,9 @@ route{
154 154
 	# first do some initial sanity checks
155 155
 	route(INIT);
156 156
 
157
+	# bypass the rest of the script for CANCELs if possible
158
+	route(CATCH_CANCEL);
159
+
157 160
 	# check if the request is routed via Route header or
158 161
 	# needs a Record-Route header
159 162
 	route(RR);
... ...
@@ -497,6 +500,22 @@ route[PSTN]
497 500
 	}
498 501
 }
499 502
 
503
+route[CATCH_CANCEL] {
504
+	# check whether there is a corresponding INVITE to the CANCEL,
505
+	# and bypass the rest of the script if possible
506
+
507
+	if (method == CANCEL) {
508
+		if (!t_relay_cancel()) { # implicit drop if the INVITE was found
509
+
510
+			# INVITE was found but some error occurred
511
+			sl_reply("500", "Internal Server Error");
512
+			drop;
513
+		}
514
+		# bad luck, no corresponding INVITE was found,
515
+		# we have to continue with the script
516
+	}
517
+}
518
+
500 519
 failure_route[FAILURE_ROUTE]
501 520
 {
502 521
 	# mark for the other routes that we are operating from here on from a
Browse code

examples updated according to anounced auth_db change (see http://lists.iptel.org/pipermail/serdev/2007-May/010034.html)

Vaclav Kubart authored on 11/05/2007 11:27:06
Showing 1 changed files
... ...
@@ -94,7 +94,7 @@ modparam("usrloc", "db_mode", 1)
94 94
 
95 95
 # -- auth params --
96 96
 modparam("auth_db", "calculate_ha1", yes)
97
-modparam("auth_db", "password_column", "password")
97
+modparam("auth_db", "plain_password_column", "password")
98 98
 
99 99
 # -- rr params --
100 100
 # add value to ;lr param to make some broken UAs happy
Browse code

removed sl_send_reply also from comments

Nils Ohlmeier authored on 08/03/2007 10:53:04
Showing 1 changed files
... ...
@@ -348,11 +348,11 @@ route[REGISTRAR]
348 348
 		# check if the authenticated user is the same as the request originator
349 349
 		# you may uncomment it if you care, what uri is in From header
350 350
 		#if (!lookup_user("$fu.uid", "@from.uri")) {
351
-		#	sl_send_reply("404", "Unknown user in From");
351
+		#	sl_reply("404", "Unknown user in From");
352 352
 		#	drop;
353 353
 		#}
354 354
 		#if ($fu.uid != $tu.uid) {
355
-		#	sl_send_reply("403", "Authentication and From-Header mismatch");
355
+		#	sl_reply("403", "Authentication and From-Header mismatch");
356 356
 		#	drop;
357 357
 		#}
358 358
 
Browse code

- added call forwarding (always, on busy and on no answer) - fixed several comments - moved XMLRPC to module callback because it is safer

Nils Ohlmeier authored on 07/03/2007 19:40:33
Showing 1 changed files
... ...
@@ -76,7 +76,8 @@ loadmodule "/usr/local/lib/ser/modules/xmlrpc.so"
76 76
 
77 77
 # ----------------- setting script FLAGS -----------------------------
78 78
 flags
79
-  FLAG_ACC         : 1  # include message in accouting
79
+  FLAG_ACC          : 1,  # include message in accouting
80
+  FLAG_FAILUREROUTE : 2;  # we are operating from a failure route
80 81
 
81 82
 avpflags
82 83
   dialog_cookie;        # handled by rr module
... ...
@@ -136,6 +137,11 @@ modparam("acc_db", "log_flag", "FLAG_ACC")
136 137
 # restarts the resend timer (see INBOUND route below)
137 138
 #modparam("tm", "restart_fr_on_each_reply", "0")
138 139
 
140
+# -- xmlrpc params --
141
+# using a sub-route from the module is a lot safer then relying on the
142
+# request method to distinguish HTTP from SIP
143
+modparam("xmlrpc", "route", "RPC");
144
+
139 145
 # -------------------------  request routing logic -------------------
140 146
 
141 147
 # main routing logic
... ...
@@ -167,7 +173,7 @@ route{
167 173
 	# check if the request is for a local user
168 174
 	route(INBOUND);
169 175
 
170
-	# here you coud for example try to an ENUM lookup before
176
+	# here you could for example try to do an ENUM lookup before