"Fossies" - the Fresh Open Source Software Archive

Member "opensips-3.0.1/modules/nathelper/examples/4to6.cfg" (16 Apr 2019, 2754 Bytes) of package /linux/misc/opensips-3.0.1.tar.gz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 # $Id$
    2 #
    3 # Simple application level gateway config script.
    4 #
    5 # Assumes that SER/rtpproxy run on a machine, which connected to
    6 # both IPv4 and IPv6 networks.
    7 #
    8 # Correspondingly, this machine has two IP addresses: one IPv4
    9 # and the second one IPv6
   10 #
   11 # For example:
   12 #
   13 # 192.168.0.1 - "internal" IPv4 address
   14 # 2002:1234:5678::1 - "external" IPv6 address
   15 #
   16 # rtpproxy started with `-l 192.168.0.1 -6 /2002:1234:5678::1' option.
   17 # ser started with `-l 192.168.0.1 -l [2002:1234:5678::1] option.
   18 #
   19 
   20 # ------------------ module loading ----------------------------------
   21 
   22 loadmodule "/usr/local/lib/ser/modules/sl.so"
   23 loadmodule "/usr/local/lib/ser/modules/tm.so"
   24 loadmodule "/usr/local/lib/ser/modules/rr.so"
   25 loadmodule "/usr/local/lib/ser/modules/maxfwd.so"
   26 loadmodule "/usr/local/lib/ser/modules/usrloc.so"
   27 loadmodule "/usr/local/lib/ser/modules/registrar.so"
   28 loadmodule "/usr/local/lib/ser/modules/nathelper.so"
   29 
   30 # ----------------- setting module-specific parameters ---------------
   31 
   32 # -- nathelper params --
   33 
   34 modparam("nathelper", "natping_interval", 15)
   35 
   36 # ------------------ main fun below ----------------------------------
   37 
   38 route {
   39 	# initial sanity checks -- messages with
   40 	# max_forwars == 0, or excessively long requests,
   41 	# or those that don't addressed to us
   42 	if (!mf_process_maxfwd_header("10")) {
   43 		sl_send_reply("483", "Too Many Hops");
   44 		break;
   45 	};
   46 	if (!is_myself("$rd") && $rm == "INVITE") {
   47 		sl_send_reply("403", "Call cannot be served here");
   48 		break;
   49 	};
   50 
   51 	if ($rm == "REGISTER") {
   52 		if ($af == "INET") {
   53 			save("location-inet4");
   54 		} else if ($af == "INET6") {
   55 			save("location-inet6");
   56 		} else {
   57 			sl_send_reply("403", "Call cannot be served here");
   58 		};
   59 		break;
   60 	};
   61 
   62 	if ($rm == "INVITE") {
   63 		if (lookup("location-inet4")) {
   64 			# Comment out three lines below if you want
   65 			# RTP for IPv4->IPv4 calls to go directly
   66 			# between UAs
   67 			if ($af == "INET")
   68 				if (rtpproxy_offer("FAII"))
   69 					t_on_reply("1");
   70 			if ($af == "INET6")
   71 				if (rtpproxy_offer("FAEI"))
   72 					t_on_reply("1");
   73 		} else if (lookup("location-inet6")) {
   74 			if ($af == "INET")
   75 				if (rtpproxy_offer("FAIE"))
   76 					t_on_reply("1");
   77 			# Comment out three lines below if you want
   78 			# RTP for IPv6->IPv6 calls to go directly
   79 			# between UAs
   80 			if ($af == "INET6")
   81 				if (rtpproxy_offer("FAEE"))
   82 					t_on_reply("1");
   83 		} else {
   84 			sl_send_reply("403", "Call cannot be served here");
   85 			break;
   86 		};
   87 	}
   88 
   89 	if ($rm == "BYE" || $rm == "CANCEL")
   90 		unforce_rtp_proxy();
   91 
   92 	# Do strict routing if pre-loaded route headers present
   93 	if (loose_route()) {
   94 		t_relay();
   95 		break;
   96 	};
   97 
   98 	if ($rm == "INVITE")
   99 		record_route();
  100 
  101         if (!t_relay())
  102         	sl_reply_error();
  103 }
  104 
  105 onreply_route[1] {
  106 	if (!($rs=~"183" || $rs=~"200"))
  107 		break;
  108 	rtpproxy_answer("FA");
  109 }