Browse code

kamailio.cfg: coherent formating

- compacted some sub-routes by reducing if-block identation with returns

Daniel-Constantin Mierla authored on 19/09/2014 19:55:24
Showing 1 changed files
... ...
@@ -461,8 +461,7 @@ request_route {
461 461
 	route(NATDETECT);
462 462
 
463 463
 	# CANCEL processing
464
-	if (is_method("CANCEL"))
465
-	{
464
+	if (is_method("CANCEL")) {
466 465
 		if (t_check_trans()) {
467 466
 			route(RELAY);
468 467
 		}
... ...
@@ -491,8 +490,7 @@ request_route {
491 491
 		record_route();
492 492
 
493 493
 	# account only INVITEs
494
-	if (is_method("INVITE"))
495
-	{
494
+	if (is_method("INVITE")) {
496 495
 		setflag(FLT_ACC); # do accounting
497 496
 	}
498 497
 
... ...
@@ -507,8 +505,7 @@ request_route {
507 507
 	# handle registrations
508 508
 	route(REGISTRAR);
509 509
 
510
-	if ($rU==$null)
511
-	{
510
+	if ($rU==$null) {
512 511
 		# request with no Username in RURI
513 512
 		sl_send_reply("484","Address Incomplete");
514 513
 		exit;
... ...
@@ -521,7 +518,7 @@ request_route {
521 521
 	route(LOCATION);
522 522
 }
523 523
 
524
-
524
+# Wrapper for relaying requests
525 525
 route[RELAY] {
526 526
 
527 527
 	# enable additional event routes for forwarded requests
... ...
@@ -584,66 +581,66 @@ route[REQINIT] {
584 584
 
585 585
 # Handle requests within SIP dialogs
586 586
 route[WITHINDLG] {
587
-	if (has_totag()) {
588
-		# sequential request withing a dialog should
589
-		# take the path determined by record-routing
590
-		if (loose_route()) {
591
-			route(DLGURI);
592
-			if (is_method("BYE")) {
593
-				setflag(FLT_ACC); # do accounting ...
594
-				setflag(FLT_ACCFAILED); # ... even if the transaction fails
595
-			}
596
-			else if ( is_method("ACK") ) {
597
-				# ACK is forwarded statelessy
598
-				route(NATMANAGE);
599
-			}
600
-			else if ( is_method("NOTIFY") ) {
601
-				# Add Record-Route for in-dialog NOTIFY as per RFC 6665.
602
-				record_route();
603
-			}
587
+	if (!has_totag()) return;
588
+
589
+	# sequential request withing a dialog should
590
+	# take the path determined by record-routing
591
+	if (loose_route()) {
592
+		route(DLGURI);
593
+		if (is_method("BYE")) {
594
+			setflag(FLT_ACC); # do accounting ...
595
+			setflag(FLT_ACCFAILED); # ... even if the transaction fails
596
+		}
597
+		else if ( is_method("ACK") ) {
598
+			# ACK is forwarded statelessy
599
+			route(NATMANAGE);
600
+		}
601
+		else if ( is_method("NOTIFY") ) {
602
+			# Add Record-Route for in-dialog NOTIFY as per RFC 6665.
603
+			record_route();
604
+		}
605
+		route(RELAY);
606
+		exit;
607
+	}
608
+
609
+	if (is_method("SUBSCRIBE") && uri == myself) {
610
+		# in-dialog subscribe requests
611
+		route(PRESENCE);
612
+		exit;
613
+	}
614
+	if ( is_method("ACK") ) {
615
+		if ( t_check_trans() ) {
616
+			# no loose-route, but stateful ACK;
617
+			# must be an ACK after a 487
618
+			# or e.g. 404 from upstream server
604 619
 			route(RELAY);
620
+			exit;
605 621
 		} else {
606
-			if (is_method("SUBSCRIBE") && uri == myself) {
607
-				# in-dialog subscribe requests
608
-				route(PRESENCE);
609
-				exit;
610
-			}
611
-			if ( is_method("ACK") ) {
612
-				if ( t_check_trans() ) {
613
-					# no loose-route, but stateful ACK;
614
-					# must be an ACK after a 487
615
-					# or e.g. 404 from upstream server
616
-					route(RELAY);
617
-					exit;
618
-				} else {
619
-					# ACK without matching transaction ... ignore and discard
620
-					exit;
621
-				}
622
-			}
623
-			sl_send_reply("404","Not here");
622
+			# ACK without matching transaction ... ignore and discard
623
+			exit;
624 624
 		}
625
-		exit;
626 625
 	}
626
+	sl_send_reply("404","Not here");
627
+	exit;
627 628
 }
628 629
 
629 630
 # Handle SIP registrations
630 631
 route[REGISTRAR] {
631
-	if (is_method("REGISTER"))
632
-	{
633
-		if(isflagset(FLT_NATS))
634
-		{
635
-			setbflag(FLB_NATB);
636
-			# uncomment next line to do SIP NAT pinging 
637
-			## setbflag(FLB_NATSIPPING);
638
-		}
639
-		if (!save("location"))
640
-			sl_reply_error();
632
+	if (!is_method("REGISTER")) return;
641 633
 
642
-		exit;
634
+	if(isflagset(FLT_NATS)) {
635
+		setbflag(FLB_NATB);
636
+#!ifdef WITH_NATSIPPING
637
+		# do SIP NAT pinging
638
+		setbflag(FLB_NATSIPPING);
639
+#!endif
643 640
 	}
641
+	if (!save("location"))
642
+		sl_reply_error();
643
+	exit;
644 644
 }
645 645
 
646
-# USER location service
646
+# User location service
647 647
 route[LOCATION] {
648 648
 
649 649
 #!ifdef WITH_SPEEDDIAL
... ...
@@ -676,8 +673,7 @@ route[LOCATION] {
676 676
 	}
677 677
 
678 678
 	# when routing via usrloc, log the missed calls also
679
-	if (is_method("INVITE"))
680
-	{
679
+	if (is_method("INVITE")) {
681 680
 		setflag(FLT_ACCMISSED);
682 681
 	}
683 682
 
... ...
@@ -685,7 +681,7 @@ route[LOCATION] {
685 685
 	exit;
686 686
 }
687 687
 
688
-# Presence server route
688
+# Presence server processing
689 689
 route[PRESENCE] {
690 690
 	if(!is_method("PUBLISH|SUBSCRIBE"))
691 691
 		return;
... ...
@@ -698,14 +694,12 @@ route[PRESENCE] {
698 698
 	}
699 699
 
700 700
 #!ifdef WITH_PRESENCE
701
-	if (!t_newtran())
702
-	{
701
+	if (!t_newtran()) {
703 702
 		sl_reply_error();
704 703
 		exit;
705 704
 	}
706 705
 
707
-	if(is_method("PUBLISH"))
708
-	{
706
+	if(is_method("PUBLISH")) {
709 707
 		handle_publish();
710 708
 		t_release();
711 709
 	} else if(is_method("SUBSCRIBE")) {
... ...
@@ -716,21 +710,19 @@ route[PRESENCE] {
716 716
 #!endif
717 717
 	
718 718
 	# if presence enabled, this part will not be executed
719
-	if (is_method("PUBLISH") || $rU==$null)
720
-	{
719
+	if (is_method("PUBLISH") || $rU==$null) {
721 720
 		sl_send_reply("404", "Not here");
722 721
 		exit;
723 722
 	}
724 723
 	return;
725 724
 }
726 725
 
727
-# Authentication route
726
+# IP authorization and user uthentication
728 727
 route[AUTH] {
729 728
 #!ifdef WITH_AUTH
730 729
 
731 730
 #!ifdef WITH_IPAUTH
732
-	if((!is_method("REGISTER")) && allow_source_address())
733
-	{
731
+	if((!is_method("REGISTER")) && allow_source_address()) {
734 732
 		# source IP allowed
735 733
 		return;
736 734
 	}
... ...
@@ -749,8 +741,7 @@ route[AUTH] {
749 749
 	}
750 750
 	# if caller is not local subscriber, then check if it calls
751 751
 	# a local destination, otherwise deny, not an open relay here
752
-	if (from_uri!=myself && uri!=myself)
753
-	{
752
+	if (from_uri!=myself && uri!=myself) {
754 753
 		sl_send_reply("403","Not relaying");
755 754
 		exit;
756 755
 	}
... ...
@@ -759,7 +750,7 @@ route[AUTH] {
759 759
 	return;
760 760
 }
761 761
 
762
-# Caller NAT detection route
762
+# Caller NAT detection
763 763
 route[NATDETECT] {
764 764
 #!ifdef WITH_NAT
765 765
 	force_rport();
... ...
@@ -776,7 +767,7 @@ route[NATDETECT] {
776 776
 	return;
777 777
 }
778 778
 
779
-# RTPProxy control
779
+# RTPProxy control and singaling updates for NAT traversal
780 780
 route[NATMANAGE] {
781 781
 #!ifdef WITH_NAT
782 782
 	if (is_request()) {
... ...
@@ -820,11 +811,11 @@ route[DLGURI] {
820 820
 
821 821
 # Routing to foreign domains
822 822
 route[SIPOUT] {
823
-	if (!uri==myself)
824
-	{
825
-		append_hf("P-hint: outbound\r\n");
826
-		route(RELAY);
827
-	}
823
+	if (uri==myself) return;
824
+
825
+	append_hf("P-hint: outbound\r\n");
826
+	route(RELAY);
827
+	exit;
828 828
 }
829 829
 
830 830
 # PSTN GW routing
... ...
@@ -881,7 +872,7 @@ route[XMLRPC] {
881 881
 }
882 882
 #!endif
883 883
 
884
-# route to voicemail server
884
+# Routing to voicemail server
885 885
 route[TOVOICEMAIL] {
886 886
 #!ifdef WITH_VOICEMAIL
887 887
 	if(!is_method("INVITE|SUBSCRIBE"))
... ...
@@ -910,20 +901,20 @@ route[TOVOICEMAIL] {
910 910
 	return;
911 911
 }
912 912
 
913
-# manage outgoing branches
913
+# Manage outgoing branches
914 914
 branch_route[MANAGE_BRANCH] {
915 915
 	xdbg("new branch [$T_branch_idx] to $ru\n");
916 916
 	route(NATMANAGE);
917 917
 }
918 918
 
919
-# manage incoming replies
919
+# Manage incoming replies
920 920
 onreply_route[MANAGE_REPLY] {
921 921
 	xdbg("incoming reply\n");
922 922
 	if(status=~"[12][0-9][0-9]")
923 923
 		route(NATMANAGE);
924 924
 }
925 925
 
926
-# manage failure routing cases
926
+# Manage failure routing cases
927 927
 failure_route[MANAGE_FAILURE] {
928 928
 	route(NATMANAGE);
929 929