2 * Copyright (C) 1993-2001 by Darren Reed.
4 * See the IPFILTER.LICENCE file for details on licencing.
9 lnth proto source destination src port dst port
13 60 tcp 128.250.20.20 128.250.133.13 2419 telnet
17 0.32 91 04 131.170.1.10 128.250.133.13
18 0.33 566 udp 128.250.37.155 128.250.133.3 901 901
20 #if defined(__sgi) && (IRIX > 602)
21 # include <sys/ptimers.h>
25 #if !defined(__SVR4) && !defined(__GNUC__)
28 #include <sys/types.h>
32 #include <sys/socket.h>
33 #include <sys/ioctl.h>
34 #include <sys/param.h>
36 #include <netinet/in.h>
37 #include <arpa/inet.h>
38 #include <netinet/in_systm.h>
40 #include <netinet/ip_var.h>
42 #include <netinet/ip.h>
43 #include <netinet/tcp.h>
44 #include <netinet/udp.h>
45 #include <netinet/ip_icmp.h>
48 #include "ip_compat.h"
49 #include <netinet/tcpip.h>
54 static const char sccsid
[] = "@(#)ipft_ef.c 1.6 2/4/96 (C)1995 Darren Reed";
55 static const char rcsid
[] = "@(#)$Id: ipft_ef.c,v 2.2.2.5 2003/05/19 12:02:35 darrenr Exp $";
58 static int etherf_open
__P((char *));
59 static int etherf_close
__P((void));
60 static int etherf_readip
__P((char *, int, char **, int *));
62 struct ipread etherf
= { etherf_open
, etherf_close
, etherf_readip
};
64 static FILE *efp
= NULL
;
68 static int etherf_open(fname
)
74 if (!strcmp(fname
, "-")) {
78 efd
= open(fname
, O_RDONLY
);
79 efp
= fdopen(efd
, "r");
85 static int etherf_close()
91 static int etherf_readip(buf
, cnt
, ifn
, dir
)
96 ip_t
*ip
= (ip_t
*)&pkt
;
97 struct protoent
*p
= NULL
;
98 char src
[16], dst
[16], sprt
[16], dprt
[16];
99 char lbuf
[128], len
[8], prot
[8], time
[8], *s
;
100 int slen
, extra
= 0, i
;
102 if (!fgets(lbuf
, sizeof(lbuf
) - 1, efp
))
105 if ((s
= strchr(lbuf
, '\n')))
107 lbuf
[sizeof(lbuf
)-1] = '\0';
109 bzero(&pkt
, sizeof(pkt
));
111 if (sscanf(lbuf
, "%7s %7s %15s %15s %15s %15s", len
, prot
, src
, dst
,
113 if (sscanf(lbuf
, "%7s %7s %7s %15s %15s %15s %15s", time
,
114 len
, prot
, src
, dst
, sprt
, dprt
) != 7)
117 ip
->ip_p
= atoi(prot
);
119 if (!(p
= getprotobyname(prot
)))
121 ip
->ip_p
= p
->p_proto
;
127 s
= strtok(NULL
, " :");
128 ip
->ip_len
+= atoi(s
);
129 if (p
->p_proto
== IPPROTO_TCP
)
130 extra
= sizeof(struct tcphdr
);
131 else if (p
->p_proto
== IPPROTO_UDP
)
132 extra
= sizeof(struct udphdr
);
136 extra
= sizeof(struct igmp
);
140 extra
= sizeof(struct icmp
);
146 (void) inet_aton(src
, &ip
->ip_src
);
147 (void) inet_aton(dst
, &ip
->ip_dst
);
148 ip
->ip_len
= atoi(len
);
149 ip
->ip_hl
= (unsigned)sizeof(ip_t
);
151 slen
= ip
->ip_hl
+ extra
;
153 bcopy((char *)&pkt
, buf
, i
);