# or, if -lc was given, userv root ipif is replaced with the argument(s) to
# successive -lc options.
+# Copyright (C) 1999 Ian Jackson
+#
+# This is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with userv-utils; if not, write to the Free Software
+# Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# $Id$
+
use Socket;
use POSIX;
use Fcntl;
quit "tunnel endpoint closed by system";
}
while (($p= index($upbuf,"\300")) >= 0) {
- if (!defined(send L,substr($upbuf,0,$p+1),0,$rs)) {
+ if ($p && !defined(send L,substr($upbuf,0,$p),0,$rs)) {
warning("transmit error: $!");
} else {
if (!$upyet) {
warning("got packet from incorrect peer $rsp_from");
next;
}
+ $downbuf= "\300".$downbuf."\300";
if (!defined($r= syswrite(DW,$downbuf,length $downbuf))) {
warning("tunnel endpoint write error: $!");
} elsif ($r != length $downbuf) {
alarm($timeout) if $timeout;
}
}
+ if ($! == ECONNREFUSED) { quit("tunnel closed at remote end"); }
$! == EAGAIN || warning("receive error: $!");
}