Added support for the slip.hosts options 'normal', 'compress', 'noicmp',

and 'autocmp'.

Obtained from: (mostly) slattach and (slightly) 1.X
This commit is contained in:
Nate Williams 1995-12-04 06:10:29 +00:00
parent f205c88775
commit 5e15ba9fd8
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=12615
3 changed files with 86 additions and 6 deletions

View File

@ -1,11 +1,13 @@
# @(#)slip.hosts 8.1 (Berkeley) 6/6/93
#
# login local-addr remote-addr mask opt1 opt2
# (normal,compress,noicmp)
# login local-addr remote-addr mask option(s)
#
# option(s) consist of the following: (see the sliplogin man page)
# (normal,compress,noicmp,autocomp)
#
Schez vangogh chez 0xffffff00 compress
Sjun vangogh 128.32.130.36 0xffffff00 normal
Sleconte vangogh leconte 0xffffff00 compress
Sleeb vangogh leeb 0xffffff00 compress
Smjk vangogh pissaro-sl 0xffffff00 compress
Soxford vangogh oxford 0xffffff00 compress
Smjk vangogh pissaro-sl 0xffffff00 noicmp
Soxford vangogh oxford 0xffffff00 autocomp

View File

@ -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

View File

@ -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 */