Continue to build functions which don't rely on libpcap, when we don't have libpcap
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 23 Jul 2014 16:49:32 +0000 (12:49 -0400)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 23 Jul 2014 16:50:28 +0000 (12:50 -0400)
src/include/pcap.h
src/lib/pcap.c
src/main/radsniff.c

index c952a35..bf506fe 100644 (file)
@@ -57,7 +57,7 @@
 #endif
 
 #ifndef BIOCIMMEDIATE
-#define BIOCIMMEDIATE (2147762800)
+#  define BIOCIMMEDIATE (2147762800)
 #endif
 
 /*
@@ -70,7 +70,7 @@
 /*
  *     The number of bytes in an ethernet (MAC) address.
  */
-#define ETHER_ADDR_LEN         6
+#define ETHER_ADDR_LEN 6
 
 /*
  *     Structure of a DEC/Intel/Xerox or 802.3 Ethernet header.
@@ -137,6 +137,7 @@ typedef struct radius_packet_t {
 
 #define AUTH_HDR_LEN 20
 
+#  ifdef HAVE_LIBPCAP
 typedef enum {
        PCAP_INVALID = 0,
        PCAP_INTERFACE_IN,
@@ -179,8 +180,9 @@ fr_pcap_t *fr_pcap_init(TALLOC_CTX *ctx, char const *name, fr_pcap_type_t type);
 int fr_pcap_open(fr_pcap_t *handle);
 int fr_pcap_apply_filter(fr_pcap_t *handle, char const *expression);
 char *fr_pcap_device_names(TALLOC_CTX *ctx, fr_pcap_t *handle, char c);
-ssize_t fr_pcap_link_layer_offset(uint8_t const *data, size_t len, int link_type);
+#  endif
+
+ssize_t fr_link_layer_offset(uint8_t const *data, size_t len, int link_type);
 uint16_t fr_udp_checksum(uint8_t const *data, uint16_t len, uint16_t checksum,
                         struct in_addr const src_addr, struct in_addr const dst_addr);
 #endif
-
index 318ca73..25e7f0d 100644 (file)
@@ -327,6 +327,7 @@ char *fr_pcap_device_names(TALLOC_CTX *ctx, fr_pcap_t *pcap, char c)
 
        return buff;
 }
+#endif /* HAVE_LIBPCAP */
 
 /** Returns the length of the link layer header
  *
@@ -344,7 +345,7 @@ char *fr_pcap_device_names(TALLOC_CTX *ctx, fr_pcap_t *pcap, char c)
  * @param link_type value returned from pcap_linktype.
  * @return the length of the header, or -1 on error.
  */
-ssize_t fr_pcap_link_layer_offset(uint8_t const *data, size_t len, int link_type)
+ssize_t fr_link_layer_offset(uint8_t const *data, size_t len, int link_type)
 {
        uint8_t const *p = data;
 
@@ -472,4 +473,3 @@ uint16_t fr_udp_checksum(uint8_t const *data, uint16_t len, uint16_t checksum,
 
        return ((uint16_t) ~sum);
 }
-#endif
index 1b45593..56a2b18 100644 (file)
@@ -1026,7 +1026,7 @@ static void rs_packet_process(uint64_t count, rs_event_t *event, struct pcap_pkt
                rs_time_print(timestr, sizeof(timestr), &header->ts);
        }
 
-       len = fr_pcap_link_layer_offset(data, header->caplen, event->in->link_type);
+       len = fr_link_layer_offset(data, header->caplen, event->in->link_type);
        if (len < 0) {
                REDEBUG("Failed determining link layer header offset");
                return;