2 * lib/strip.c This file contains an implementation of the STRIP
5 * Version: strip.c 1.20 1999/04/22 eswierk
7 * Author: Stuart Cheshire <cheshire@cs.stanford.edu>
9 * This program is free software; you can redistribute it
10 * and/or modify it under the terms of the GNU General
11 * Public License as published by the Free Software
12 * Foundation; either version 2 of the License, or (at
13 * your option) any later version.
19 #include <sys/types.h>
20 #include <sys/ioctl.h>
21 #include <sys/socket.h>
22 #include <net/if_arp.h>
23 #include <linux/types.h>
24 #include <linux/if_strip.h>
33 #include "net-support.h"
34 #include "pathnames.h"
39 extern struct hwtype strip_hwtype;
42 pr_strip(unsigned char *ptr)
46 sprintf(buff, "%02x%02x-%02x%02x", *(ptr+2), *(ptr+3), *(ptr+4),
52 in_strip(char *bufp, struct sockaddr *sap)
55 MetricomAddress *haddr = (MetricomAddress *) (sap->sa_data);
58 sap->sa_family = strip_hwtype.type;
60 /* figure out what the device-address should be */
61 i = (bufp[0] == '*') ? 1 : 0;
62 haddr->c[2] = strtol(&bufp[i], 0, 16) >> 8;
63 haddr->c[3] = strtol(&bufp[i], 0, 16) & 0xFF;
65 while (bufp[i] && (bufp[i] != '-'))
71 haddr->c[4] = strtol(&bufp[i+1], 0, 16) >> 8;
72 haddr->c[5] = strtol(&bufp[i+1], 0, 16) & 0xFF;
81 /* Start the STRIP encapsulation on the file descriptor. */
82 static int do_strip(int fd)
85 if (ioctl(fd, TIOCSETD, &disc) < 0)
87 fprintf(stderr, "STRIP_set_disc(%d): %s\n", disc, strerror(errno));
93 struct hwtype strip_hwtype = {
94 "strip", "Metricom Starmode IP", ARPHRD_METRICOM, sizeof(MetricomAddress),
95 pr_strip, in_strip, do_strip, 0
98 #endif /* HAVE_HWSTRIP */