summaryrefslogtreecommitdiffstats
path: root/sbin/slattach
diff options
context:
space:
mode:
authordg <dg@FreeBSD.org>1994-09-14 05:40:56 +0000
committerdg <dg@FreeBSD.org>1994-09-14 05:40:56 +0000
commitc5f5d0f6cb0df00093e46ac9f0379fdbecaa25c3 (patch)
tree93c4334186d31a0a9f0abf85a4e9c46c8703adcc /sbin/slattach
parent891e296c7ad59a2799963215248045ffd8be44a9 (diff)
downloadFreeBSD-src-c5f5d0f6cb0df00093e46ac9f0379fdbecaa25c3.zip
FreeBSD-src-c5f5d0f6cb0df00093e46ac9f0379fdbecaa25c3.tar.gz
Fixed slattach to do flags ioctl via network device rather than tty.
Submitted by: Rich Murphey, and fixed up by me.
Diffstat (limited to 'sbin/slattach')
-rw-r--r--sbin/slattach/slattach.c36
1 files changed, 34 insertions, 2 deletions
diff --git a/sbin/slattach/slattach.c b/sbin/slattach/slattach.c
index 8987123..ac4a530 100644
--- a/sbin/slattach/slattach.c
+++ b/sbin/slattach/slattach.c
@@ -284,18 +284,50 @@ void setup_line(int cflag)
/* Put the line in slip discipline. */
void slip_discipline()
{
+ struct ifreq ifr;
int slipdisc = SLIPDISC;
+ int s, tmp_unit = -1;
/* Switch to slip line discipline. */
if (ioctl(fd, TIOCSETD, &slipdisc) < 0) {
syslog(LOG_ERR, "ioctl(TIOCSETD): %m");
exit_handler(1);
}
+
+ /* find out what unit number we were assigned */
+ if (ioctl(fd, SLIOCGUNIT, (caddr_t)&tmp_unit) < 0) {
+ syslog(LOG_ERR, "ioctl(SLIOCGUNIT): %m");
+ exit_handler(1);
+ }
+
+ if (tmp_unit < 0) {
+ syslog(LOG_ERR, "bad unit (%d) from ioctl(SLIOCGUNIT)",tmp_unit);
+ exit_handler(1);
+ }
+
+ /* 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_handler(1);
+ }
+ sprintf(ifr.ifr_name, "sl%d", tmp_unit);
+
+ /* get the flags for the interface */
+ if (ioctl(s, SIOCGIFFLAGS, (caddr_t)&ifr) < 0) {
+ syslog(LOG_ERR, "ioctl (SIOCGIFFLAGS): %m");
+ exit_handler(1);
+ }
+
/* Assert any compression or no-icmp flags. */
- if (ioctl(fd, SIOCSIFFLAGS, &slflags) < 0) {
- syslog(LOG_ERR, "ioctl(SIOCSIFFLAGS): %m");
+#define SLMASK (~(IFF_LINK0 | IFF_LINK1 | IFF_LINK2))
+ ifr.ifr_flags &= SLMASK;
+ ifr.ifr_flags |= slflags;
+ if (ioctl(s, SIOCSIFFLAGS, (caddr_t)&ifr) < 0) {
+ syslog(LOG_ERR, "ioctl (SIOCSIFFLAGS): %m");
exit_handler(1);
}
+ close(s);
}
/* configure the interface, eg. by passing the unit number to a script. */
OpenPOWER on IntegriCloud