Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix detection of DLT_* macros #29

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

h3xx
Copy link
Contributor

@h3xx h3xx commented Jul 9, 2023

pcap.h in its entirety must be included in order for bpf.h to work properly.

Example test program, compiler output:
#include <stdio.h>
#include <pcap/bpf.h>

int main(void) {
#ifdef DLT_IEEE802_11
    printf("Yes\n");
#endif
}

Output:

In file included from t.c:2:
/usr/include/pcap/bpf.h:97:9: error: unknown type name 'u_int'
   97 | typedef u_int bpf_u_int32;
      |         ^~~~~
/usr/include/pcap/bpf.h:117:9: error: unknown type name 'u_int'
  117 |         u_int bf_len;
      |         ^~~~~
/usr/include/pcap/bpf.h:245:9: error: unknown type name 'u_short'
  245 |         u_short code;
      |         ^~~~~~~
/usr/include/pcap/bpf.h:246:9: error: unknown type name 'u_char'
  246 |         u_char  jt;
      |         ^~~~~~
/usr/include/pcap/bpf.h:247:9: error: unknown type name 'u_char'
  247 |         u_char  jf;
      |         ^~~~~~
/usr/include/pcap/bpf.h:271:10: error: unknown type name 'u_int'
  271 | PCAP_API u_int  bpf_filter(const struct bpf_insn *, const u_char *, u_int, u_int);
      |          ^~~~~
/usr/include/pcap/bpf.h:271:59: error: unknown type name 'u_char'
  271 | PCAP_API u_int  bpf_filter(const struct bpf_insn *, const u_char *, u_int, u_int);
      |                                                           ^~~~~~
/usr/include/pcap/bpf.h:271:69: error: unknown type name 'u_int'; did you mean 'int'?
  271 | PCAP_API u_int  bpf_filter(const struct bpf_insn *, const u_char *, u_int, u_int);
      |                                                                     ^~~~~
      |                                                                     int
/usr/include/pcap/bpf.h:271:76: error: unknown type name 'u_int'; did you mean 'int'?
  271 | PCAP_API u_int  bpf_filter(const struct bpf_insn *, const u_char *, u_int, u_int);
      |                                                                            ^~~~~
      |                                                                            int

Changing the example program to include only pcap.h works.

Linux x86_64
libpcap 1.10.4
gcc 13.1.0

pcap.h in its entirety must be included in order for bpf.h to work
properly.
@h3xx
Copy link
Contributor Author

h3xx commented Jul 9, 2023

Also, at some point, these macros were moved to pcap/dlt.h.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant