1 --- Makefile.in.org 2007-06-10 22:02:36.594026862 +0000
2 +++ Makefile.in 2007-06-10 22:03:08.811408859 +0000
6 CFLAGS = $(CCOPT) $(INCLS) $(DEFS)
7 -CFLAGS_SHAREDLIB = -shared -Wl,-soname,$(SOLIBRARY).$(MAJ)
8 +CFLAGS_SHAREDLIB = -shared -Wl,-soname,$(SOLIBRARY).$(MAJ) -lpfring
11 INSTALL_PROGRAM = @INSTALL_PROGRAM@
12 --- pcap-int.h_ 2005-07-07 06:56:04.000000000 +0000
13 +++ pcap-int.h 2006-01-11 17:47:18.000000000 +0000
29 struct pcap_pkthdr pcap_header; /* This is needed for the pcap_next_ex() to work */
37 --- pcap-linux.c_ 2005-08-16 04:25:26.000000000 +0000
38 +++ pcap-linux.c 2007-04-09 22:42:47.000000000 +0000
40 * shorter, on the wire, than the IP header said it should have been.
48 handle->snapshot = snaplen;
49 handle->md.timeout = to_ms;
52 + handle->ring = pfring_open((char*)device, promisc);
54 + if(handle->ring != NULL) {
55 + handle->fd = handle->ring->fd;
56 + handle->bufsize = handle->snapshot;
57 + handle->linktype = DLT_EN10MB;
60 + /* printf("Open HAVE_PF_RING(%s)\n", device); */
62 + /* printf("Open HAVE_PF_RING(%s) failed. Fallback to pcap\n", device); */
65 * NULL and "any" are special devices which give us the hint to
66 * monitor all devices.
69 handle->bufsize = handle->snapshot;
75 /* Allocate the buffer */
78 int packet_len, caplen;
79 struct pcap_pkthdr pcap_header;
85 + if (handle->break_loop) {
87 + * Yes - clear the flag that indicates that it
88 + * has, and return -2 as an indication that we
89 + * were told to break out of the loop.
91 + * Patch courtesy of Michael Stiller <ms@2scale.net>
93 + handle->break_loop = 0;
97 + packet_len = pfring_recv(handle->ring, (char*)handle->buffer,
99 + (struct pfring_pkthdr*)&pcap_header,
100 + 1 /* wait_for_incoming_packet */);
101 + if (packet_len > 0) {
102 + bp = handle->buffer;
103 + packet_len = pcap_header.len;
104 + caplen = pcap_header.caplen; /* ensure that our capture length does not exceed our snapshot length */
106 + if (caplen > handle->snapshot)
107 + caplen = handle->snapshot;
108 + if (caplen > handle->bufsize) /* sanity check and prevent buffer overruns, paranoia in the extreme */
109 + caplen = handle->bufsize;
111 + pcap_header.caplen = caplen; /* reset our header capture length for the callee! */
113 + goto pfring_pcap_read_packet;
114 + } else if (packet_len == -1 && errno == EINTR)
122 #ifdef HAVE_PF_PACKET_SOCKETS
124 * If this is a cooked device, leave extra room for a
130 + pfring_pcap_read_packet:
134 * XXX: According to the kernel source we should get the real
135 * packet len if calling recvfrom with MSG_TRUNC set. It does
140 +#ifndef HAVE_PF_RING
141 /* Fill in our own header data */
143 if (ioctl(handle->fd, SIOCGSTAMP, &pcap_header.ts) == -1) {
144 snprintf(handle->errbuf, sizeof(handle->errbuf),
145 "SIOCGSTAMP: %s", pcap_strerror(errno));
148 pcap_header.caplen = caplen;
149 pcap_header.len = packet_len;
154 @@ -1701,6 +1765,13 @@
155 struct pcap *p, *prevp;
160 + pfring_close(handle->ring);
165 if (handle->md.clear_promisc) {
167 * We put the interface into promiscuous mode; take
168 @@ -2140,7 +2211,13 @@
169 * the filtering done in userland even if it could have been
170 * done in the kernel.
172 - if (setsockopt(handle->fd, SOL_SOCKET, SO_ATTACH_FILTER,
173 + if (setsockopt(handle->fd,
180 &total_fcode, sizeof(total_fcode)) == 0) {
183 @@ -2149,6 +2226,7 @@
187 +#ifndef HAVE_PF_RING
189 * Save the socket's current mode, and put it in
190 * non-blocking mode; we drain it by reading packets
191 @@ -2171,12 +2249,19 @@
199 * Now attach the new filter.
201 - ret = setsockopt(handle->fd, SOL_SOCKET, SO_ATTACH_FILTER,
202 + ret = setsockopt(handle->fd,
209 fcode, sizeof(*fcode));
210 if (ret == -1 && total_filter_on) {
212 @@ -2213,3 +2298,9 @@
213 &dummy, sizeof(dummy));
218 +int pcap_set_cluster(pfring *ring, u_int clusterId) { return(pfring_set_cluster(ring, clusterId)); }
219 +int pcap_remove_from_cluster(pfring *ring) { return(pfring_remove_from_cluster(ring)); }
220 +int pcap_set_reflector(pfring *ring, char *reflectorDevice) { return(pfring_set_reflector(ring, reflectorDevice)); }