2 * (C)opyright 1992-1998 Darren Reed. (from tcplog)
4 * See the IPFILTER.LICENCE file for details on licencing.
6 * The author of this software makes no garuntee about the
7 * performance of this package or its suitability to fulfill any purpose.
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/ip.h>
27 #include <netinet/tcp.h>
28 #include "ip_compat.h"
32 static const char sccsid[] = "@(#)slinux.c 1.1 12/3/95 (C) 1995 Darren Reed";
35 #define BUFSPACE 32768
38 * Be careful to only include those defined in the flags option for the
39 * interface are included in the header size.
43 static char *eth_dev = NULL;
53 ip = (struct ip *)&tip;
54 tcp = (tcphdr_t *)(ip + 1);
56 bcopy(bp, (char *)&tip, sizeof(tip));
57 bcopy(bp + (ip.ip_hl << 2), (char *)tcp, sizeof(*tcp));
58 if (0 == detect(ip, tcp))
64 void readloop(fd, port, dst)
68 static u_char buf[BUFSPACE];
70 register u_char *bp = buf;
73 time_t now = time(NULL);
78 bzero((char *)&dest, dlen);
79 cc = recvfrom(fd, buf, BUFSPACE, 0, &dest, &dlen);
81 if ((time(NULL) - now) > timeout)
86 if (bp[12] != 0x8 || bp[13] != 0)
87 continue; /* not ip */
90 * get rid of non-tcp or fragmented packets here.
92 if (cc >= sizeof(struct tcpiphdr))
94 if (((bp[14+9] != IPPROTO_TCP) &&
95 (bp[14+9] != IPPROTO_UDP)) ||
96 (bp[14+6] & 0x1f) || (bp[14+6] & 0xff))
98 done += ack_recv(bp + 14);
105 int initdevice(dev, tout)
111 eth_dev = strdup(dev);
112 if ((fd = socket(AF_INET, SOCK_PACKET, htons(ETHERTYPE_IP))) == -1)
114 perror("socket(SOCK_PACKET)");