source: lib/format_bpf.c @ 10553bf

4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivelibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change on this file since 10553bf was 10553bf, checked in by Shane Alcock <salcock@…>, 6 years ago

Fix various build errors and warnings on OS X

  • Property mode set to 100644
File size: 19.7 KB
Line 
1/*
2 * This file is part of libtrace
3 *
4 * Copyright (c) 2007,2008,2009,2010 The University of Waikato, Hamilton,
5 * New Zealand.
6 *
7 * Authors: Daniel Lawson
8 *          Perry Lorier
9 *          Shane Alcock
10 *         
11 * All rights reserved.
12 *
13 * This code has been developed by the University of Waikato WAND
14 * research group. For further information please see http://www.wand.net.nz/
15 *
16 * libtrace is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2 of the License, or
19 * (at your option) any later version.
20 *
21 * libtrace is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with libtrace; if not, write to the Free Software
28 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
29 *
30 * $Id$
31 *
32 */
33
34#include "libtrace.h"
35#include "libtrace_int.h"
36#include "format_helper.h"
37#include "config.h"
38#include "stdlib.h"
39
40#ifdef HAVE_INTTYPES_H
41#  include <inttypes.h>
42#else
43# error "Can't find inttypes.h"
44#endif
45
46#include <sys/socket.h>
47
48#include <sys/types.h>
49#include <sys/time.h>
50#include <sys/ioctl.h>
51
52#include <string.h>
53#include <net/if.h>
54#include <sys/ioctl.h>
55#include <errno.h>
56#include <fcntl.h>
57#include <unistd.h>
58
59/* This format deals with the BSD Native capture format, perhaps better
60 * known as BPF, which is the equivalent of the Linux Native format for
61 * *BSD systems.
62 *
63 * This is a LIVE capture format - we're always dealing with reading from an
64 * interface.
65 *
66 * This format does not support writing, but BPF packet records can be easily
67 * converted to PCAP or ERF.
68 */ 
69
70struct lt_bpf_timeval {
71        uint32_t tv_sec;
72        uint32_t tv_usec;
73};
74
75struct libtrace_bpf_hdr {
76        struct lt_bpf_timeval bh_tstamp;        /* timestamp */
77        uint32_t bh_caplen;             /* capture length */
78        uint32_t bh_datalen;            /* wire length */
79        uint16_t bh_hdrlen;             /* header length (incl padding) */
80};
81
82#ifndef BPF_TIMEVAL
83#define BPF_TIMEVAL timeval
84#endif
85
86struct local_bpf_hdr {
87        struct BPF_TIMEVAL bh_tstamp;
88        uint32_t bh_caplen;
89        uint32_t bh_datalen;
90        uint16_t bh_hdrlen;
91};
92
93#define BPFHDR(x) ((struct libtrace_bpf_hdr *)((x)->header))
94
95#if HAVE_DECL_BIOCSETIF
96/* "Global" data that is stored for each BPF input trace */
97struct libtrace_format_data_t {
98        /* The file descriptor that is being captured from */
99        int fd; 
100        /* The snap length for the capture */
101        int snaplen;
102        /* A boolean flag indicating whether the capture interface should be
103         * in promiscuous mode */ 
104        int promisc;
105        /* A buffer to write captured data into */
106        void *buffer;
107        /* The current read location in the capture buffer */
108        void *bufptr;
109        /* The total size of the capture buffer */
110        unsigned int buffersize;
111        /* The amount of space remaining before the capture buffer is full */
112        int remaining;
113        /* The linktype of the capture interface */ 
114        unsigned int linktype;
115        /* Statistics about how many packets have been dropped, received etc. */
116        struct bpf_stat stats;
117        /* A boolean flag indicating whether the statistics are up-to-date */
118        int stats_valid;
119};
120
121#define FORMATIN(x) ((struct libtrace_format_data_t*)((x->format_data)))
122
123
124/* Attempts to determine if a given filename could refer to a BPF interface */
125static int bpf_probe_filename(const char *filename)
126{
127        return (if_nametoindex(filename) != 0);
128}
129
130/* Initialises a BPF input trace */
131static int bpf_init_input(libtrace_t *libtrace) 
132{
133        libtrace->format_data = (struct libtrace_format_data_t *)
134                malloc(sizeof(struct libtrace_format_data_t));
135       
136        /* Throw some default values into the format data */
137        FORMATIN(libtrace)->fd = -1;
138        FORMATIN(libtrace)->promisc = 0;
139        FORMATIN(libtrace)->snaplen = 65536;
140        FORMATIN(libtrace)->stats_valid = 0;
141
142        return 0;
143}
144
145/* Starts a BPF input trace */
146static int bpf_start_input(libtrace_t *libtrace)
147{
148        int bpfid=0;
149        struct bpf_version bv;
150        struct ifreq ifr;
151        unsigned int v;
152
153        /* Find and open a bpf device */
154        do {
155                char buffer[64];
156                snprintf(buffer,sizeof(buffer),"/dev/bpf%d", bpfid);
157                bpfid++;
158               
159                FORMATIN(libtrace)->fd = open(buffer, O_RDONLY);
160        } while(FORMATIN(libtrace)->fd == -1 && errno == EBUSY);
161
162        if (FORMATIN(libtrace)->fd == -1) {
163                trace_set_err(libtrace,TRACE_ERR_INIT_FAILED,
164                                "No free bpf devices");
165                return -1;
166        }
167
168        /* Check the BPF Version is ok */
169        if (ioctl(FORMATIN(libtrace)->fd, BIOCVERSION, &bv) == -1) {
170                trace_set_err(libtrace,errno,
171                                "Failed to read the bpf version");
172                close(FORMATIN(libtrace)->fd);
173                return -1;
174        }
175
176        if (bv.bv_major != BPF_MAJOR_VERSION) {
177                trace_set_err(libtrace,errno, 
178                        "Unknown kernel BPF version (%d.%d, libtrace requires at least %d.%d)",
179                        bv.bv_major,
180                        bv.bv_minor,
181                        BPF_MAJOR_VERSION,
182                        BPF_MINOR_VERSION);
183                close(FORMATIN(libtrace)->fd);
184                return -1;
185        }
186
187        if (bv.bv_minor < BPF_MINOR_VERSION) {
188                trace_set_err(libtrace,errno, "Kernel version too old (%d.%d, libtrace requires at least %d.%d)",
189                        bv.bv_major,
190                        bv.bv_minor,
191                        BPF_MAJOR_VERSION,
192                        BPF_MINOR_VERSION);
193                close(FORMATIN(libtrace)->fd);
194                return -1;
195        }
196
197        /* We assume the default kernel buffer size is sufficient. */
198        if (ioctl(FORMATIN(libtrace)->fd, BIOCGBLEN,
199                        &FORMATIN(libtrace)->buffersize)==-1) {
200                trace_set_err(libtrace,errno,"Failed to find buffer length");
201                close(FORMATIN(libtrace)->fd);
202                return -1;
203        }
204
205        FORMATIN(libtrace)->buffer = malloc(FORMATIN(libtrace)->buffersize);
206        FORMATIN(libtrace)->bufptr = FORMATIN(libtrace)->buffer;
207        FORMATIN(libtrace)->remaining = 0;
208
209        /* Attach to the device */
210        strncpy(ifr.ifr_name, libtrace->uridata, sizeof(ifr.ifr_name));
211        if (ioctl(FORMATIN(libtrace)->fd, BIOCSETIF, &ifr) == -1) {
212                trace_set_err(libtrace,errno,"Failed to attach");
213                close(FORMATIN(libtrace)->fd);
214                return -1;
215        }
216
217        /* Set the link type */
218        if (ioctl(FORMATIN(libtrace)->fd, BIOCGDLT,
219                         &FORMATIN(libtrace)->linktype) == -1) {
220                trace_set_err(libtrace,errno,"Failed to retrieve link type");
221                close(FORMATIN(libtrace)->fd);
222                return -1;
223        }
224       
225        /* TODO: If BIOCGDLTLIST exists then we should perhaps do something
226         *       with it.  We don't have the same concept of multiple DLT's
227         *       as pcap does.  We grab the rawest possible thing and then
228         *       decode packets by understanding the protocols.  So perhaps
229         *       we should setup a rating of DLT's that we'll prefer in order.
230         *       For example we should try and get 802.11 frames rather than
231         *       802.3 frames.  The general rule should be "whatever actually
232         *       went over the air", although of course if we don't support
233         *       what went over the air we should fall back to something we
234         *       /do/ support.
235         */
236       
237        /* Using timeouts seems sucky.  We'll always use immediate mode.  We
238         * pray the kernel is smart enough that if a another packet arrives
239         * while we're processing this one that it will buffer them into it's
240         * kernel buffer so we can receive packets later. (It'll need to do this
241         * to deal with us spending time processing the last 'n' packets anyway)
242         */
243       
244        v=1;
245        if (ioctl(FORMATIN(libtrace)->fd, BIOCIMMEDIATE, &v) == -1) {
246                trace_set_err(libtrace,errno,"Failed to set immediate mode");
247                close(FORMATIN(libtrace)->fd);
248                return -1;
249        }
250
251        /* Set promiscous mode, if the user has asked us to do so */
252        if (FORMATIN(libtrace)->promisc) {
253                if (ioctl(FORMATIN(libtrace)->fd, BIOCPROMISC, NULL) == -1) {
254                        trace_set_err(libtrace,errno,
255                                "Failed to set promisc mode");
256                        close(FORMATIN(libtrace)->fd);
257                        return -1;
258
259                }
260        }
261
262        FORMATIN(libtrace)->stats_valid = 0;
263
264        /* TODO: we should always set a bpf filter for snapping */
265
266        /* We're done! */
267        return 0;
268}
269
270/* Gets a count of the number of packets received on the BPF interface */
271static uint64_t bpf_get_received_packets(libtrace_t *trace)
272{
273        if (trace->format_data == NULL)
274                return (uint64_t)-1;
275
276        if (FORMATIN(trace)->fd == -1) {
277                /* Almost certainly a 'dead' trace so there is no socket
278                 * for us to query */
279                return (uint64_t) -1;
280        }
281        /* If we're called with stats_valid == 0, or we're called again
282         * then refresh the stats.  Don't refresh the stats if we're called
283         * immediately after get_dropped_packets
284         */
285        if ((FORMATIN(trace)->stats_valid & 1)
286                || (FORMATIN(trace)->stats_valid == 0)) {
287                ioctl(FORMATIN(trace)->fd, BIOCGSTATS, &FORMATIN(trace)->stats);
288                FORMATIN(trace)->stats_valid |= 1;
289        }
290
291        return FORMATIN(trace)->stats.bs_recv;
292}
293
294/* Gets a count of the number of packets dropped on the BPF interface */
295static uint64_t bpf_get_dropped_packets(libtrace_t *trace)
296{
297        if (trace->format_data == NULL)
298                return (uint64_t)-1;
299
300        if (FORMATIN(trace)->fd == -1) {
301                /* Almost certainly a 'dead' trace so there is no socket
302                 * for us to query */
303                return (uint64_t) -1;
304        }
305        /* If we're called with stats_valid == 0, or we're called again
306         * then refresh the stats.  Don't refresh the stats if we're called
307         * immediately after get_received_packets
308         */
309        if ((FORMATIN(trace)->stats_valid & 2) 
310                || (FORMATIN(trace)->stats_valid == 0)) {
311                ioctl(FORMATIN(trace)->fd, BIOCGSTATS, &FORMATIN(trace)->stats);
312                FORMATIN(trace)->stats_valid |= 2;
313        }
314
315        return FORMATIN(trace)->stats.bs_drop;
316}
317
318static void bpf_get_statistics(libtrace_t *trace, libtrace_stat_t *stat) {
319        uint64_t dropped = bpf_get_dropped_packets(trace);
320        uint64_t received = bpf_get_received_packets(trace);
321
322        if (dropped != (uint64_t)-1) {
323                stat->dropped_valid = 1;
324                stat->dropped = dropped;
325        }
326
327        if (received != (uint64_t) -1) {
328                stat->received_valid = 1;
329                stat->received = received;
330        }
331
332}
333
334/* Pauses a BPF input trace */
335static int bpf_pause_input(libtrace_t *libtrace)
336{
337        close(FORMATIN(libtrace)->fd);
338        FORMATIN(libtrace)->fd=-1;
339
340        return 0;
341}
342
343/* Closes a BPF input trace */
344static int bpf_fin_input(libtrace_t *libtrace) 
345{
346        free(libtrace->format_data);
347        return 0;
348}
349
350/* Configures a BPF input trace */
351static int bpf_config_input(libtrace_t *libtrace,
352                trace_option_t option,
353                void *data)
354{
355        switch(option) {
356                case TRACE_OPTION_SNAPLEN:
357                        FORMATIN(libtrace)->snaplen=*(int*)data;
358                        return 0;
359                case TRACE_OPTION_PROMISC:
360                        FORMATIN(libtrace)->promisc=*(int*)data;
361                        return 0;
362                case TRACE_OPTION_FILTER:
363                        /* We don't support bpf filters in any special way
364                         * so return an error and let libtrace deal with
365                         * emulating it
366                         */
367                        break;
368                case TRACE_OPTION_META_FREQ:
369                        /* No meta-data for this format */
370                        break;
371                case TRACE_OPTION_EVENT_REALTIME:
372                        /* Captures are always realtime */
373                        break;
374                case TRACE_OPTION_HASHER:
375                        /* TODO investigate hashing in BSD? */
376                        break;
377
378                /* Avoid default: so that future options will cause a warning
379                 * here to remind us to implement it, or flag it as
380                 * unimplementable
381                 */
382        }
383        return -1;
384}
385
386#endif  /* HAVE_DECL_BIOCSETIF */
387
388/* Converts a buffer containing a recently read BPF packet record into a
389 * libtrace packet */
390static int bpf_prepare_packet(libtrace_t *libtrace UNUSED, 
391                libtrace_packet_t *packet,
392                void *buffer, libtrace_rt_types_t rt_type, uint32_t flags) {
393       
394        struct local_bpf_hdr orig;
395        struct local_bpf_hdr *ptr;
396        struct libtrace_bpf_hdr *replace;
397
398        /* If the packet previously owned a buffer that is not the buffer
399         * that contains the new packet data, we're going to need to free the
400         * old one to avoid memory leaks */
401        if (packet->buffer != buffer &&
402                        packet->buf_control == TRACE_CTRL_PACKET) {
403                free(packet->buffer);
404        }
405
406        /* Set the buffer owner appropriately */
407        if ((flags & TRACE_PREP_OWN_BUFFER) == TRACE_PREP_OWN_BUFFER) {
408                packet->buf_control = TRACE_CTRL_PACKET;
409        } else
410                packet->buf_control = TRACE_CTRL_EXTERNAL;
411
412        /* Update the packet pointers and type appropriately */
413        packet->buffer = buffer;
414        packet->header = buffer;
415        packet->type = rt_type;
416
417        /* FreeBSD is stupid and uses a timeval in the bpf header
418         * structure. This means that sometimes our timestamp consumes
419         * 8 bytes and sometimes it consumes 16 bytes.
420         *
421         * Let's try to standardise our header a bit, hopefully without
422         * overwriting anything else important */
423
424        if (sizeof(struct BPF_TIMEVAL) != sizeof(struct lt_bpf_timeval)) {     
425               
426                ptr = ((struct local_bpf_hdr *)(packet->header));
427                replace = ((struct libtrace_bpf_hdr *)(packet->header));
428                orig = *ptr;
429
430                replace->bh_tstamp.tv_sec = (uint32_t) (orig.bh_tstamp.tv_sec & 0xffffffff);
431                replace->bh_tstamp.tv_usec = (uint32_t) (orig.bh_tstamp.tv_usec & 0xffffffff);
432                replace->bh_caplen = orig.bh_caplen;
433                replace->bh_datalen = orig.bh_datalen;
434                replace->bh_hdrlen = orig.bh_hdrlen;
435
436
437        }
438
439        /* Find the payload */
440        /* TODO: Pcap deals with a padded FDDI linktype here */
441        packet->payload=(char *)buffer + BPFHDR(packet)->bh_hdrlen;
442
443        return 0;
444}
445
446#if HAVE_DECL_BIOCSETIF
447
448/* Reads the next packet record from a BPF interface and writes it into a
449 * libtrace packet */   
450static int bpf_read_packet(libtrace_t *libtrace, libtrace_packet_t *packet) 
451{
452        uint32_t flags = 0;
453        fd_set readfds;
454        struct timeval tout;
455        int ret;
456
457        packet->type = bpf_linktype_to_rt(FORMATIN(libtrace)->linktype);
458
459        while (FORMATIN(libtrace)->remaining <= 0) {
460                tout.tv_sec = 0;
461                tout.tv_usec = 500000;
462                FD_ZERO(&readfds);
463                FD_SET(FORMATIN(libtrace)->fd, &readfds);
464
465                ret = select(FORMATIN(libtrace)->fd + 1, &readfds, NULL,
466                                NULL, &tout);
467                if (ret < 0 && errno != EINTR) {
468                        trace_set_err(libtrace, errno, "select");
469                        return -1;
470                } else if (ret < 0) {
471                        continue;
472                }
473
474                if (FD_ISSET(FORMATIN(libtrace)->fd, &readfds)) {
475                        /* Packets are available, read into buffer */
476                        ret=read(FORMATIN(libtrace)->fd,
477                                FORMATIN(libtrace)->buffer,
478                                FORMATIN(libtrace)->buffersize);
479
480                        if (ret == -1) {
481                                trace_set_err(libtrace,errno,"Failed to read");
482                                return -1;
483                        }
484
485                        if (ret == 0) {
486                                /* EOF */
487                                return 0;
488                        }
489
490                        FORMATIN(libtrace)->remaining=ret;
491                        FORMATIN(libtrace)->bufptr=
492                                        FORMATIN(libtrace)->buffer;
493                        break;
494                }
495
496                /* Timed out -- check if we should halt */
497                if (libtrace_halt)
498                        return 0;
499        }
500       
501        /* We do NOT want anything trying to free the memory the packet is
502         * stored in */
503        flags |= TRACE_PREP_DO_NOT_OWN_BUFFER;
504
505        if (packet->buf_control == TRACE_CTRL_PACKET)
506                free(packet->buffer);
507
508        /* Update 'packet' to point to the first packet in our capture
509         * buffer */
510        if (bpf_prepare_packet(libtrace, packet, FORMATIN(libtrace)->bufptr,
511                        packet->type, flags)) {
512                return -1;
513        }
514       
515
516        /* Skip past the packet record we're going to return, making sure
517         * that we deal with padding correctly */
518        FORMATIN(libtrace)->bufptr+=
519                BPF_WORDALIGN(BPFHDR(packet)->bh_hdrlen
520                +BPFHDR(packet)->bh_caplen);
521        FORMATIN(libtrace)->remaining-=
522                BPF_WORDALIGN(BPFHDR(packet)->bh_hdrlen
523                +BPFHDR(packet)->bh_caplen);
524
525        return BPFHDR(packet)->bh_datalen+BPFHDR(packet)->bh_hdrlen;
526}
527
528#endif  /* HAVE_DECL_BIOCSETIF */
529
530/* Returns the linktype for the interface that we are capturing from */
531static libtrace_linktype_t bpf_get_link_type(const libtrace_packet_t *packet) {
532        /* Convert the linktype that we recorded when we started the trace
533         * into a suitable libtrace linktype */
534        return pcap_linktype_to_libtrace(rt_to_pcap_linktype(packet->type));
535}
536
537/* Returns the direction for a given BPF packet record */
538static libtrace_direction_t bpf_get_direction(const libtrace_packet_t *packet UNUSED) {
539        /* BPF sadly can't do direction tagging */
540        return ~0;
541}
542
543/* Returns the timestamp for a given BPF packet record, in the form of a
544 * struct timeval */
545static struct timeval bpf_get_timeval(const libtrace_packet_t *packet) 
546{
547        struct timeval tv;
548        /* OpenBSD uses a bpf_timeval rather than a timeval so we must copy
549         * each timeval element individually rather than doing a structure
550         * assignment */
551        tv.tv_sec = BPFHDR(packet)->bh_tstamp.tv_sec;
552        tv.tv_usec = BPFHDR(packet)->bh_tstamp.tv_usec;
553
554        return tv;
555}
556
557/* Returns the capture length for a given BPF packet record */
558static int bpf_get_capture_length(const libtrace_packet_t *packet)
559{
560        /* BPF doesn't include the FCS in its caplen field, but libtrace
561         * does so we need to add this extra 4 bytes */
562        return BPFHDR(packet)->bh_caplen+4;
563}
564
565/* Returns the wire length for a given BPF packet record */
566static int bpf_get_wire_length(const libtrace_packet_t *packet) 
567{
568
569        /* BPF doesn't include the FCS in its datalen field, but libtrace
570         * does so we need to add this extra 4 bytes */
571        return BPFHDR(packet)->bh_datalen+4;
572}
573
574/* Returns the framing length for a given BPF packet record */
575static int bpf_get_framing_length(UNUSED
576                const libtrace_packet_t *packet) 
577{
578        return BPFHDR(packet)->bh_hdrlen;
579}
580
581#if HAVE_DECL_BIOCSETIF
582/* Returns the file descriptor that the capture interface is operating on */
583static int bpf_get_fd(const libtrace_t *trace) {
584        return FORMATIN(trace)->fd;
585}
586
587/* Prints some slightly useful help text for the BPF capture format */
588static void bpf_help() {
589        printf("bpf format module: $Revision: 1782 $\n");
590        printf("Supported input URIs:\n");
591        printf("\tbpf:\n");
592        printf("\n");
593        return;
594}
595static struct libtrace_format_t bpf = {
596        "bpf",
597        "$Id$",
598        TRACE_FORMAT_BPF,
599        bpf_probe_filename,     /* probe filename */
600        NULL,                   /* probe magic */
601        bpf_init_input,         /* init_input */
602        bpf_config_input,       /* config_input */
603        bpf_start_input,        /* start_input */
604        bpf_pause_input,        /* pause_input */
605        NULL,                   /* init_output */
606        NULL,                   /* config_output */
607        NULL,                   /* start_ouput */
608        bpf_fin_input,          /* fin_input */
609        NULL,                   /* fin_output */
610        bpf_read_packet,        /* read_packet */
611        bpf_prepare_packet,     /* prepare_packet */
612        NULL,                   /* fin_packet */
613        NULL,                   /* write_packet */
614        bpf_get_link_type,      /* get_link_type */
615        bpf_get_direction,      /* get_direction */
616        NULL,                   /* set_direction */
617        NULL,                   /* get_erf_timestamp */
618        bpf_get_timeval,        /* get_timeval */
619        NULL,                   /* get_timespec */
620        NULL,                   /* get_seconds */
621        NULL,                   /* seek_erf */
622        NULL,                   /* seek_timeval */
623        NULL,                   /* seek_seconds */
624        bpf_get_capture_length, /* get_capture_length */
625        bpf_get_wire_length,    /* get_wire_length */
626        bpf_get_framing_length, /* get_framing_length */
627        NULL,                   /* set_capture_length */
628        NULL,                   /* get_received_packets */
629        NULL,                   /* get_filtered_packets */
630        NULL,                   /* get_dropped_packets */
631        bpf_get_statistics,     /* get_statistics */
632        bpf_get_fd,             /* get_fd */
633        trace_event_device,     /* trace_event */
634        bpf_help,               /* help */
635        NULL,                   /* next pointer */
636        NON_PARALLEL(true)
637};
638#else   /* HAVE_DECL_BIOCSETIF */
639/* Prints some slightly useful help text for the BPF capture format */
640static void bpf_help() {
641        printf("bpf format module: $Revision: 1782 $\n");
642        printf("Not supported on this host\n");
643        return;
644}
645static struct libtrace_format_t bpf = {
646        "bpf",
647        "$Id$",
648        TRACE_FORMAT_BPF,
649        NULL,                   /* probe filename */
650        NULL,                   /* probe magic */
651        NULL,                   /* init_input */
652        NULL,                   /* config_input */
653        NULL,                   /* start_input */
654        NULL,                   /* pause_input */
655        NULL,                   /* init_output */
656        NULL,                   /* config_output */
657        NULL,                   /* start_ouput */
658        NULL,                   /* fin_input */
659        NULL,                   /* fin_output */
660        NULL,                   /* read_packet */
661        bpf_prepare_packet,     /* prepare_packet */
662        NULL,                   /* fin_packet */
663        NULL,                   /* write_packet */
664        bpf_get_link_type,      /* get_link_type */
665        bpf_get_direction,      /* get_direction */
666        NULL,                   /* set_direction */
667        NULL,                   /* get_erf_timestamp */
668        bpf_get_timeval,        /* get_timeval */
669        NULL,                   /* get_timespec */
670        NULL,                   /* get_seconds */
671        NULL,                   /* seek_erf */
672        NULL,                   /* seek_timeval */
673        NULL,                   /* seek_seconds */
674        bpf_get_capture_length, /* get_capture_length */
675        bpf_get_wire_length,    /* get_wire_length */
676        bpf_get_framing_length, /* get_framing_length */
677        NULL,                   /* set_capture_length */
678        NULL,                   /* get_received_packets */
679        NULL,                   /* get_filtered_packets */
680        NULL,                   /* get_dropped_packets */
681        NULL,                   /* get_statistics */
682        NULL,                   /* get_fd */
683        NULL,                   /* trace_event */
684        bpf_help,               /* help */
685        NULL,                   /* next pointer */
686        NON_PARALLEL(true)
687};
688#endif  /* HAVE_DECL_BIOCSETIF */
689
690void bpf_constructor() {
691        register_format(&bpf);
692}
Note: See TracBrowser for help on using the repository browser.