2 * (C)opyright 1992-1998 Darren Reed. (from tcplog)
4 * See the IPFILTER.LICENCE file for details on licencing.
13 #include <sys/types.h>
15 #include <sys/timeb.h>
16 #include <sys/socket.h>
18 #include <sys/ioctl.h>
20 #include <linux/netdevice.h>
22 #include <netinet/in.h>
23 #include <netinet/in_systm.h>
24 #include <netinet/ip.h>
25 #include <netinet/tcp.h>
29 static const char sccsid
[] = "@(#)slinux.c 1.2 8/25/95";
30 static const char rcsid
[] = "@(#)$Id: slinux.c,v 2.1.4.1 2001/06/26 10:43:22 darrenr Exp $";
33 #define CHUNKSIZE 8192
34 #define BUFSPACE (4*CHUNKSIZE)
37 * Be careful to only include those defined in the flags option for the
38 * interface are included in the header size.
42 static char *eth_dev
= NULL
;
45 int initdevice(dev
, sport
, spare
)
51 eth_dev
= strdup(dev
);
52 if ((fd
= socket(AF_INET
, SOCK_PACKET
, htons(ETHERTYPE_IP
))) == -1)
54 perror("socket(SOCK_PACKET)");
63 * output an IP packet onto a fd opened for /dev/nit
65 int sendip(fd
, pkt
, len
)
72 strncpy(ifr
.ifr_name
, eth_dev
, sizeof(ifr
.ifr_name
));
73 if (ioctl(fd
, SIOCGIFHWADDR
, &ifr
) == -1)
75 perror("SIOCGIFHWADDR");
78 bcopy(ifr
.ifr_hwaddr
.sa_data
, pkt
+ 6, 6);
79 s
.sa_family
= ETHERTYPE_IP
;
80 strncpy(s
.sa_data
, eth_dev
, sizeof(s
.sa_data
));
82 if (sendto(fd
, pkt
, len
, 0, &s
, sizeof(s
)) == -1)