chiark / gitweb /
Print "still open" messages.
[userv-utils.git] / ipif / udptunnel
index b76a9da002393bb1cc433bfda9290144e21a7a47..09595d104bf80d4d73672cbe2bfa642844560de6 100755 (executable)
@@ -19,8 +19,8 @@
 #            <public-local-addr>,<public-local-port>
 #            <public-remote-addr>,<public-remote-port>
 #            <private-local-addr>,<private-remote-addr>,<mtu>,<proto>
-#            <keepalive>,<timeout>
-#            <extra-local-nets> <extra-remote-nets>
+#            <keepalive>,<timeout>[,<reannounce>]
+#            <extra-nets-for-local-cmd> <extra-nets-for-remote-cmd>
 #          [ <remote-command> [<remote-args> ...] ]
 #
 # proto may be slip or cslip
@@ -41,8 +41,8 @@
 #                     <public-remote-addr'>,<public-remote-port'>
 #                     <public-local-addr'>,<public-local-port'>
 #                     <private-remote-addr>,<private-local-addr>,<mtu>,<proto>
-#                     <keepalive>,<timeout>
-#                     <extra-remote-nets> <extra-local-nets>
+#                     <keepalive>,<timeout>[,<reannounce>]
+#                     <extra-nets-for-remote-cmd> <extra-nets-for-local-cmd>
 #
 
 # If it was given Print for <public-remote-foo'>, this command's first
 #   <public-local-foo>   <public-local-foo'>     <public-local-foo'>
 #                        (-m not specified)      (-m specified)
 #   actual addr/port     that addr/port         `Wait'
-#   `Wait'               the chosen address     `Wait'
 #   `Print'              the chosen address     `Wait'
+#   `Any'                `Wait' for addr,       `Wait'
+#                         chosen port for port
 #
 # udptunnel will userv ipif locally, as
 #    userv root ipif <private-local-addr>,<private-remote-addr>,<mtu>,<proto>
-#                    <extra-local-nets>
+#                    <extra-nets-for-local-cmd>
 # or, if -l was given, userv root ipif is replaced with the argument(s)
 # following -l option(s) until `.'.
 #
@@ -226,8 +227,16 @@ m/^([.0-9]+),([.0-9]+),(\d+),(slip|cslip)$/
 ($lva,$rva,$mtu,$proto) = ($1,$2,$3,$4);
 
 $_= shift @ARGV;
-m/^(\d+),(\d+)$/ or quit("keepalive,timeout missing or bad syntax");
-($keepalive,$timeout)= ($1,$2);
+if (m/^(\d+),(\d+)$/) {
+    ($keepalive,$timeout,$reannounce)= ($1+0,$2+0,0);
+    $ka_to_ra= "$keepalive,$timeout";
+} elsif (m/^(\d+),(\d+),(\d+)$/) {
+    ($keepalive,$timeout,$reannounce)= ($1+0,$2+0,$3);
+           "$keepalive,$timeout",
+    $ka_to_ra= "$keepalive,$timeout,$reannounce";
+} else {
+    quit("keepalive,timeout missing or bad syntax");
+}
 $keepalive && ($timeout > $keepalive*2) or quit("timeout must be < 2*keepalive")
     if $timeout;
 
@@ -266,9 +275,9 @@ if (@ARGV) {
     @rcmd= (@ARGV,
            @remoteopts,
            "$rad,$rpd",
-           $masq ? 'Wait,Wait' : $lapd,
+           $masq ? 'Wait,Wait' : $las eq 'Any' ? "Wait,$lpd" : $lapd,
            "$rva,$lva,$mtu,$proto",
-           "$keepalive,$timeout",
+           $ka_to_ra,
            $rexn, $lexn);
     debug("remote command @rcmd");
 
@@ -360,7 +369,7 @@ $xfwdopts.= 'w' if $dump;
 
 @fcmd= ($fcmd, $xfwdopts,
        fileno(L), fileno(DW), fileno(UR), fileno(DUMPKEYS),
-       $mtu, $keepalive, $timeout,
+       $mtu, $keepalive, $timeout, $reannounce,
        @rapf,
        @encryption);
 debug("forwarding command @fcmd.");