Browse code

IMS example config files: update icscf and scscf config files to correctly use async route blocks - This fix updates the example ICSCF and SCSCF config files to correctly use route blocks for the replies of any asynchronous Diameter messages

Richard Good authored on 25/06/2013 12:11:13
Showing 2 changed files
... ...
@@ -312,29 +312,44 @@ route[register]
312 312
 		#free this from the failed I_scscf_select call
313 313
 		I_scscf_drop();
314 314
 		# Do an asynchronous UAR:
315
-		I_perform_user_authorization_request("0");
316
-		if ($avp(uaa_return_code) == 1) {
317
-			if (I_scscf_select("0")) {
318
-				t_on_reply("register_reply");
319
-				t_on_failure("register_failure");
320
-				if (!t_relay()) {
321
-					t_reply("500","Error forwarding towards S-CSCF");
322
-					break;
323
-				}
324
-				break;
325
-			} else {
326
-				I_scscf_drop();
327
-				t_reply("500", "Server error on UAR select S-CSCF");
328
-				break;
329
-			}
330
-		} else {
331
-			t_reply("500", "Server error on UAR select S-CSCF");
332
-			break;
333
-		}    
315
+                I_perform_user_authorization_request("REG_UAR_REPLY","0"); #0=REG/DEREG; 1=REG+Capabilities
316
+                exit;    
334 317
 	}
335 318
 	break;
336 319
 }
337 320
 
321
+route[REG_UAR_REPLY]
322
+{
323
+    #this is async so to know status we have to check the reply avp
324
+    switch ($avp(s:uaa_return_code)){
325
+            case 1: #success
326
+                    if (I_scscf_select("0")){
327
+                            t_on_failure("register_failure");
328
+                            t_on_reply("register_reply");
329
+                            #now relay to appropriate SCSCF
330
+                            if (!t_relay()) {
331
+                                    t_reply("500", "Error forwarding to SCSCF");
332
+                            }
333
+                    } else {#select failed
334
+                            I_scscf_drop();
335
+                            t_reply("500", "Server error on SCSCF Select (UAR)");
336
+                    }
337
+                    break;
338
+            case -1: #failure
339
+                    xlog("L_ERR", "UAR failure - error response sent from module\n");
340
+                    break;
341
+            case -2: #error
342
+                    xlog("L_ERR", "UAR error - sending error response now\n");
343
+                    t_reply("500", "UAR failed");
344
+                    break;
345
+            default:
346
+                    xlog("L_ERR", "Unknown return code from UAR, value is [$avp(s:uaa_return_code)]\n");
347
+                    t_reply("500", "Unknown response code from UAR");
348
+                    break;
349
+    }
350
+}
351
+
352
+
338 353
 ######################################################################
339 354
 # Replies to REGISTER requests, 
340 355
 ######################################################################
... ...
@@ -353,7 +353,8 @@ route {
353 353
 		if (uri=~"sip:(.*)@"+NETWORKNAME_ESC +"(.*)" || uri=~"tel:.*") {
354 354
 			if (!term_impu_registered("location")) {
355 355
 				xlog("L_ERR", "We need to do an UNREG server SAR assignemnt");
356
-		                assign_server_unreg("location", "term");
356
+                                assign_server_unreg("UNREG_SAR_REPLY", "location", "term");
357
+                                exit;
357 358
 		        }
358 359
 		} else {
359 360
 			sl_send_reply("403","Forbidden - Dialog not found on S-CSCF or Terminating user not suitable for unregistered services");
... ...
@@ -364,6 +365,28 @@ route {
364 365
 	}
365 366
 }
366 367
 
368
+route[UNREG_SAR_REPLY]
369
+{
370
+        xlog("L_DBG","saa_return code is $avp(s:saa_return_code)\n");
371
+        switch ($avp(s:saa_return_code)){
372
+            case 1: #success
373
+                    xlog("L_DBG", "SAR success - will route message\n");
374
+                route(term);
375
+                break;
376
+            case -1: #failure
377
+                    xlog("L_ERR", "SAR failure - error response sent from module\n");
378
+                break;
379
+            case -2: #error
380
+                    xlog("L_ERR", "SAR error - error response sent from module\n");
381
+                break;
382
+            default:
383
+                    xlog("L_ERR", "Unknown return code from SAR, value is [$avp(s:saa_return_code)]\n");
384
+                break;
385
+        }
386
+        exit;
387
+}
388
+
389
+
367 390
 ######################################################################
368 391
 # Helper routes (Basic-Checks, NAT-Handling/RTP-Control, XML-RPC)
369 392
 ######################################################################
... ...
@@ -458,26 +481,7 @@ route[REGISTER] {
458 481
                 } else {
459 482
                         #user has not been authenticated. Lets send a challenge via 401 Unauthorized
460 483
                         xlog("L_DBG","About to challenge! auth_ims\n");
461
-                        ims_www_challenge("$td");
462
-                        #this is async so to know status we have to check the reply avp
463
-                        xlog("L_DBG","maa_return code is $avp(s:maa_return_code)\n");
464
-
465
-                        switch ($avp(s:maa_return_code)){
466
-                                case 1: #success
467
-                                        xlog("L_DBG", "MAR success - 401/407 response sent from module");
468
-                                        break;
469
-                                case -1: #failure
470
-                                        xlog("L_ERR", "MAR failure - error response sent from module");
471
-                                        break;
472
-                                case -2: #error
473
-                                        xlog("L_ERR", "MAR error - sending error response now");
474
-                                        t_reply("500", "MAR failed");
475
-                                        break;
476
-                                default:
477
-                                        xlog("L_ERR", "Unknown return code from MAR, value is [$avp(s:uaa_return_code)]");
478
-                                        t_reply("500", "Unknown response code from MAR");
479
-                                        break;
480
-                        }
484
+                        ims_www_challenge("REG_MAR_REPLY", "$td");
481 485
                         exit;
482 486
                 }
483 487
 	} else {
... ...
@@ -485,21 +489,85 @@ route[REGISTER] {
485 489
 		# We need to check if this user is registered or not
486 490
 		if (!impu_registered("location")) {
487 491
 			xlog("L_ERR", "Not REGISTERED\n");
488
-			save("location");
489
-			if ($avp(saa_return_code) == 1) {
490
-				isc_match_filter_reg("0","location");
491
-				exit;
492
-			}
492
+			save("PRE_REG_SAR_REPLY","location");
493
+                        exit;
493 494
 		} else {
494
-			save("location");
495
-			if($avp(saa_return_code) == 1) {
496
-				isc_match_filter_reg("1","location");
497
-				exit;
498
-			}
495
+			isc_match_filter_reg("1","location");
496
+                        save("REG_SAR_REPLY","location");
497
+                        exit;
499 498
 		}
500 499
 	}
501 500
 }
502 501
 
502
+route[REG_MAR_REPLY]
503
+{
504
+     #this is async so to know status we have to check the reply avp
505
+     xlog("L_DBG","maa_return code is $avp(s:maa_return_code)\n");   
506
+
507
+     switch ($avp(s:maa_return_code)){
508
+             case 1: #success
509
+                     xlog("L_DBG", "MAR success - 401/407 response sent from module\n");
510
+                     break;
511
+             case -1: #failure
512
+                     xlog("L_ERR", "MAR failure - error response sent from module\n");
513
+                     break;
514
+             case -2: #error
515
+                     xlog("L_ERR", "MAR error - sending error response now\n");
516
+                     t_reply("500", "MAR failed");
517
+                     break;
518
+             default:
519
+                     xlog("L_ERR", "Unknown return code from MAR, value is [$avp(s:uaa_return_code)]\n");
520
+                     t_reply("500", "Unknown response code from MAR");
521
+                     break;
522
+     }
523
+     exit;
524
+}
525
+
526
+route[PRE_REG_SAR_REPLY]
527
+{
528
+    xlog("L_DBG","saa_return code is $avp(s:saa_return_code)\n");
529
+        #this is async so to know status we have to check the reply avp
530
+    xlog("L_DBG","saa_return code (for scscf_save on register) is $avp(s:saa_return_code)\n");
531
+    switch ($avp(s:saa_return_code)){
532
+            case 1: #success
533
+                   xlog("L_DBG", "SAR success - 200 response sent from module\n");
534
+                    isc_match_filter_reg("0","location");
535
+                    exit;
536
+            case -1: #failure
537
+                    xlog("L_ERR", "SAR failure - error response sent from module\n");
538
+                    break;
539
+            case -2: #error
540
+                    xlog("L_ERR", "SAR error - error response sent from module\n");
541
+                    break;
542
+            default:
543
+                    xlog("L_ERR", "Unknown return code from SAR, value is [$avp(s:uaa_return_code)]\n");
544
+                    break;
545
+    }
546
+    exit;
547
+}
548
+
549
+route[REG_SAR_REPLY]
550
+{
551
+    xlog("L_DBG","saa_return code is $avp(s:saa_return_code)\n");
552
+    #this is async so to know status we have to check the reply avp
553
+    xlog("L_DBG","saa_return code (for scscf_save on register) is $avp(s:saa_return_code)\n");
554
+    switch ($avp(s:saa_return_code)){
555
+            case 1: #success
556
+                   xlog("L_DBG", "SAR success - 200 response sent from module\n");
557
+                    exit;
558
+            case -1: #failure
559
+                    xlog("L_ERR", "SAR failure - error response sent from module\n");
560
+                    break;
561
+            case -2: #error
562
+                    xlog("L_ERR", "SAR error - error response sent from module\n");
563
+                    break;
564
+            default:
565
+                    xlog("L_ERR", "Unknown return code from SAR, value is [$avp(s:uaa_return_code)]\n");
566
+                    break;
567
+    }
568
+    exit;
569
+}
570
+
503 571
 ######################################################################
504 572
 # Apply privacy, if requested
505 573
 ######################################################################