diff options
author | nate <nate@FreeBSD.org> | 1995-12-04 06:10:29 +0000 |
---|---|---|
committer | nate <nate@FreeBSD.org> | 1995-12-04 06:10:29 +0000 |
commit | 60a6c40d39c73062f73ce74b7bb99e912bd19521 (patch) | |
tree | 5d0f83c4d44b81888d3b349d33c1a27ea750868f /usr.sbin | |
parent | e9c5cc286f0a3d4ecf43a126e710ce7c2e8b1a64 (diff) | |
download | FreeBSD-src-60a6c40d39c73062f73ce74b7bb99e912bd19521.zip FreeBSD-src-60a6c40d39c73062f73ce74b7bb99e912bd19521.tar.gz |
Added support for the slip.hosts options 'normal', 'compress', 'noicmp',
and 'autocmp'.
Obtained from: (mostly) slattach and (slightly) 1.X
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/sliplogin/sliplogin.8 | 20 | ||||
-rw-r--r-- | usr.sbin/sliplogin/sliplogin.c | 62 |
2 files changed, 80 insertions, 2 deletions
diff --git a/usr.sbin/sliplogin/sliplogin.8 b/usr.sbin/sliplogin/sliplogin.8 index d313d4e..5a48db8 100644 --- a/usr.sbin/sliplogin/sliplogin.8 +++ b/usr.sbin/sliplogin/sliplogin.8 @@ -55,14 +55,30 @@ for an entry matching If a matching entry is found, the line is configured appropriately for slip (8-bit transparent i/o) and converted to .Tn SLIP -line -discipline. +line discipline using the optional line discipline parameters. +.Pp +The optional line discipline parameters consist of one or more of +the following; +.Sq normal , +.Sq compress , +.Sq noicmp , +or +.Sq autocomp +which correspond respectively to +.Sq use normal line discipline +(no header compression), +.Sq enable VJ header compression , +.Sq throw away ICMP packets , +and +.Sq auto enable VJ header compression +(only if the remote end of the link also supports it). .Pp Then a shell script is invoked to initialize the slip interface with the appropriate local and remote .Tn IP address, netmask, etc. +.Pp The usual initialization script is .Pa /etc/sliphome/slip.login but, if particular hosts need special initialization, the file diff --git a/usr.sbin/sliplogin/sliplogin.c b/usr.sbin/sliplogin/sliplogin.c index 4cc2537..220ffa8 100644 --- a/usr.sbin/sliplogin/sliplogin.c +++ b/usr.sbin/sliplogin/sliplogin.c @@ -77,6 +77,7 @@ static char sccsid[] = "@(#)sliplogin.c 8.2 (Berkeley) 2/1/94"; #include <termios.h> #include <sys/ioctl.h> #include <net/slip.h> +#include <net/if.h> #include <stdio.h> #include <errno.h> @@ -88,6 +89,7 @@ static char sccsid[] = "@(#)sliplogin.c 8.2 (Berkeley) 2/1/94"; #include "pathnames.h" int unit; +int slip_mode; speed_t speed; int uid; int keepal; @@ -97,6 +99,17 @@ char loginargs[BUFSIZ]; char loginfile[MAXPATHLEN]; char loginname[BUFSIZ]; +struct slip_modes { + char *sm_name; + int sm_or_flag; + int sm_and_flag; +} modes[] = { + "normal", 0 , 0 , + "compress", IFF_LINK0, IFF_LINK2, + "noicmp", IFF_LINK1, 0 , + "autocomp", IFF_LINK2, IFF_LINK0, +}; + void findid(name) char *name; @@ -134,6 +147,18 @@ findid(name) (void) fclose(fp); + slip_mode = 0; + for (i = 0; i < n - 4; i++) { + for (j = 0; j < sizeof(modes)/sizeof(struct slip_modes); + j++) { + if (strcmp(modes[j].sm_name, slopt[i]) == 0) { + slip_mode |= (modes[j].sm_or_flag); + slip_mode &= ~(modes[j].sm_and_flag); + break; + } + } + } + /* * we've found the guy we're looking for -- see if * there's a login file we can use. First check for @@ -259,6 +284,40 @@ hup_handler(s) /* NOTREACHED */ } + +/* Modify the slip line mode and add any compression or no-icmp flags. */ +void line_flags(unit) + int unit; +{ + struct ifreq ifr; + int s; + + /* open a socket as the handle to the interface */ + s = socket(AF_INET, SOCK_DGRAM, 0); + if (s < 0) { + syslog(LOG_ERR, "socket: %m"); + exit(1); + } + sprintf(ifr.ifr_name, "sl%d", unit); + + /* get the flags for the interface */ + if (ioctl(s, SIOCGIFFLAGS, (caddr_t)&ifr) < 0) { + syslog(LOG_ERR, "ioctl (SIOCGIFFLAGS): %m"); + exit(1); + } + + /* Assert any compression or no-icmp flags. */ +#define SLMASK (~(IFF_LINK0 | IFF_LINK1 | IFF_LINK2)) + ifr.ifr_flags &= SLMASK; + ifr.ifr_flags |= slip_mode; + if (ioctl(s, SIOCSIFFLAGS, (caddr_t)&ifr) < 0) { + syslog(LOG_ERR, "ioctl (SIOCSIFFLAGS): %m"); + exit(1); + } + close(s); +} + + main(argc, argv) int argc; char *argv[]; @@ -386,6 +445,9 @@ main(argc, argv) exit(6); } + /* Handle any compression or no-icmp flags. */ + line_flags(unit); + /* reset uid to users' to allow the user to give a signal. */ seteuid(uid); /* twiddle thumbs until we get a signal */ |