4 * (C)opyright 1992-1998 Darren Reed. (from tcplog)
6 * See the IPFILTER.LICENCE file for details on licencing.
16 #include <sys/types.h>
18 #include <sys/timeb.h>
19 #include <sys/socket.h>
21 #include <sys/ioctl.h>
23 #include <linux/netdevice.h>
25 #include <netinet/in.h>
26 #include <netinet/in_systm.h>
27 #include <netinet/ip.h>
28 #include <netinet/tcp.h>
32 static const char sccsid[] = "@(#)slinux.c 1.2 8/25/95";
33 static const char rcsid[] = "@(#)$Id: slinux.c,v 2.3 2001/06/09 17:09:26 darrenr Exp $";
36 #define CHUNKSIZE 8192
37 #define BUFSPACE (4*CHUNKSIZE)
40 * Be careful to only include those defined in the flags option for the
41 * interface are included in the header size.
45 static char *eth_dev = NULL;
48 int initdevice(dev, spare)
54 eth_dev = strdup(dev);
55 if ((fd = socket(AF_INET, SOCK_PACKET, htons(ETHERTYPE_IP))) == -1)
57 perror("socket(SOCK_PACKET)");
66 * output an IP packet onto a fd opened for /dev/nit
68 int sendip(fd, pkt, len)
75 strncpy(ifr.ifr_name, eth_dev, sizeof(ifr.ifr_name));
76 if (ioctl(fd, SIOCGIFHWADDR, &ifr) == -1)
78 perror("SIOCGIFHWADDR");
81 bcopy(ifr.ifr_hwaddr.sa_data, pkt + 6, 6);
82 s.sa_family = ETHERTYPE_IP;
83 strncpy(s.sa_data, eth_dev, sizeof(s.sa_data));
85 if (sendto(fd, pkt, len, 0, &s, sizeof(s)) == -1)