Changeset d47ca18 for lib/format_pcap.c


Ignore:
Timestamp:
06/21/17 15:41:47 (4 years ago)
Author:
Richard Sanger <rsanger@…>
Branches:
cachetimestamps, develop, dpdk-ndag, etsilive, master, ndag_format, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance
Children:
e9c089a
Parents:
f398c61
Message:

Fix issue #49 compile issues when missing BPF header file

If pcap was installed but somehow the BPF header was missing.
Libtrace was using two different macros HAVE_BPF and HAVE_BPF_FILTER
to determine if BPF was installed.

HAVE_BPF_FILTER was set if pcap was found, wereas HAVE_BPF was
set if the BPF header was found.

This removes and replaces HAVE_BPF_FILTER with HAVE_BPF.
It also adds ifdef blocks around formats that try to install
BPF filters directly as needed.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/format_pcap.c

    r5e3f16c rd47ca18  
    128128
    129129        /* If a filter has been configured, compile and apply it */
     130#ifdef HAVE_BPF
    130131        if (DATA(libtrace)->filter) {
    131132                if (DATA(libtrace)->filter->flag == 0) {
     
    143144                }
    144145        }
     146#endif
    145147        return 0;
    146148}
     
    152154        switch(option) {
    153155                case TRACE_OPTION_FILTER:
     156#ifdef HAVE_BPF
    154157                        DATA(libtrace)->filter=data;
    155158                        return 0;
     159#else
     160                        return -1;
     161#endif
    156162                case TRACE_OPTION_SNAPLEN:
    157163                        /* Snapping isn't supported directly, so fall thru
     
    211217        switch(option) {
    212218                case TRACE_OPTION_FILTER:
     219#ifdef HAVE_BPF
    213220                        DATA(libtrace)->filter=(libtrace_filter_t*)data;
    214221                        return 0;
     222#else
     223                        return -1;
     224#endif
    215225                case TRACE_OPTION_SNAPLEN:
    216226                        DATA(libtrace)->snaplen=*(int*)data;
     
    298308#endif
    299309        /* Set a filter if one is defined */
     310#ifdef HAVE_BPF
    300311        if (DATA(libtrace)->filter) {
    301312                struct pcap_pkthdr *pcap_hdr = NULL;
     
    342353                        return -1;
    343354        }
     355#endif
    344356        return 0; /* success */
    345357}
Note: See TracChangeset for help on using the changeset viewer.