Skip to content

Commit

Permalink
some other portability fix
Browse files Browse the repository at this point in the history
  • Loading branch information
yersinia committed Jan 31, 2012
1 parent 784a82c commit f6bb6e8
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
16 changes: 9 additions & 7 deletions p0f.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,6 @@

#include <pcap.h>

#ifdef HAVE_NET_BPF_H
# include <net/bpf.h>
#else
#ifdef HAVE_PCAP_BPF_H
# include <pcap-bpf.h>
#endif
#endif /* !NET_BPF */

#include "types.h"
#include "debug.h"
Expand All @@ -56,6 +49,15 @@
#include "fp_http.h"
#include "p0f.h"

#ifdef HAVE_NET_BPF_H
#include <net/bpf.h>
#else
#ifdef HAVE_PCAP_BPF_H
#include <pcap-bpf.h>
#endif /*HAVE_PCAP_BPF_H*/
#endif /* HAVE_NET_BPF_H */


#ifndef PF_INET6
# define PF_INET6 10
#endif /* !PF_INET6 */
Expand Down
1 change: 1 addition & 0 deletions p0f.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#include "types.h"
#include "process.h"
#include "system.h"

extern u8 daemon_mode;
extern s32 link_type;
Expand Down
18 changes: 16 additions & 2 deletions process.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@
#include "fp_mtu.h"
#include "fp_http.h"

#ifdef HAVE_NET_BPF_H
#include <net/bpf.h>
#else
#ifdef HAVE_PCAP_BPF_H
#include <pcap-bpf.h>
#endif /*HAVE_PCAP_BPF_H*/
#endif /* HAVE_NET_BPF_H */

u64 packet_cnt; /* Total number of packets processed */

static s8 link_off = -1; /* Link-specific IP header offset */
Expand Down Expand Up @@ -87,12 +95,17 @@ static void find_offset(const u8* data, s32 total_len) {

switch (link_type) {

#ifdef DLT_RAW
case DLT_RAW: link_off = 0; return;

#endif /* DLT_RAW */
#ifdef DLT_NULL
case DLT_NULL:
#endif /* DLT_NULL */
case DLT_PPP: link_off = 4; return;

#ifdef DLT_LOOP
case DLT_LOOP:
#endif /* DLT_LOOP */

#ifdef DLT_PPP_SERIAL
case DLT_PPP_SERIAL:
Expand All @@ -107,8 +120,9 @@ static void find_offset(const u8* data, s32 total_len) {
#endif /* DLT_LINUX_SLL */

case DLT_PFLOG: link_off = 28; return;

#ifdef DLT_IEEE802_11
case DLT_IEEE802_11: link_off = 32; return;
#endif /* DLT_IEEE802_11 */
}

/* If this fails, try to auto-detect. There is a slight risk that if the
Expand Down

0 comments on commit f6bb6e8

Please sign in to comment.