4 * (C)opyright 1992-1998 Darren Reed. (from tcplog)
6 * See the IPFILTER.LICENCE file for details on licencing.
15 #include <sys/types.h>
17 #include <sys/timeb.h>
18 #include <sys/socket.h>
20 #include <sys/ioctl.h>
22 #include <linux/netdevice.h>
24 #include <netinet/in.h>
25 #include <netinet/ip.h>
26 #include <netinet/tcp.h>
27 #include "ip_compat.h"
31 static const char sccsid
[] = "@(#)slinux.c 1.1 12/3/95 (C) 1995 Darren Reed";
34 #define BUFSPACE 32768
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
;
52 ip
= (struct ip
*)&tip
;
53 tcp
= (tcphdr_t
*)(ip
+ 1);
55 bcopy(bp
, (char *)&tip
, sizeof(tip
));
56 bcopy(bp
+ (ip
.ip_hl
<< 2), (char *)tcp
, sizeof(*tcp
));
57 if (0 == detect(ip
, tcp
))
63 void readloop(fd
, port
, dst
)
67 static u_char buf
[BUFSPACE
];
69 register u_char
*bp
= buf
;
72 time_t now
= time(NULL
);
77 bzero((char *)&dest
, dlen
);
78 cc
= recvfrom(fd
, buf
, BUFSPACE
, 0, &dest
, &dlen
);
80 if ((time(NULL
) - now
) > timeout
)
85 if (bp
[12] != 0x8 || bp
[13] != 0)
86 continue; /* not ip */
89 * get rid of non-tcp or fragmented packets here.
91 if (cc
>= sizeof(struct tcpiphdr
))
93 if (((bp
[14+9] != IPPROTO_TCP
) &&
94 (bp
[14+9] != IPPROTO_UDP
)) ||
95 (bp
[14+6] & 0x1f) || (bp
[14+6] & 0xff))
97 done
+= ack_recv(bp
+ 14);
104 int initdevice(dev
, tout
)
110 eth_dev
= strdup(dev
);
111 if ((fd
= socket(AF_INET
, SOCK_PACKET
, htons(ETHERTYPE_IP
))) == -1)
113 perror("socket(SOCK_PACKET)");