Commit b2959130 authored by Bruno Randolf's avatar Bruno Randolf

move endian conversion to util.h

add host-to-le conversion macros too.

the reason i cant use #define _BSD_SOURCE is that older glibc versions don't
support it, so i am copying the relevant parts.
parent 799af736
......@@ -23,8 +23,6 @@
#include <net/if_arp.h>
#include <netinet/ip.h>
#include <netinet/udp.h>
#include <endian.h>
#include <byteswap.h>
#include "prism_header.h"
#include "ieee80211_radiotap.h"
......@@ -37,15 +35,6 @@
#include "main.h"
#include "util.h"
#if BYTE_ORDER == LITTLE_ENDIAN
#define le64toh(x) (x)
#define le32toh(x) (x)
#define le16toh(x) (x)
#else
#define le64toh(x) bswap_64(x)
#define le32toh(x) bswap_32(x)
#define le16toh(x) bswap_16(x)
#endif
static int parse_prism_header(unsigned char** buf, int len, struct packet_info* current_packet);
static int parse_radiotap_header(unsigned char** buf, int len, struct packet_info* current_packet);
......
......@@ -21,6 +21,8 @@
#define _UTIL_H_
#include <stdio.h>
#include <endian.h>
#include <byteswap.h>
#if DO_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
......@@ -28,6 +30,22 @@
#define DEBUG(...)
#endif
#if BYTE_ORDER == LITTLE_ENDIAN
#define le64toh(x) (x)
#define le32toh(x) (x)
#define le16toh(x) (x)
#define htole64(x) (x)
#define htole32(x) (x)
#define htole16(x) (x)
#else
#define le64toh(x) bswap_64(x)
#define le32toh(x) bswap_32(x)
#define le16toh(x) bswap_16(x)
#define htole64(x) bswap_64(x)
#define htole32(x) bswap_32(x)
#define htole16(x) bswap_16(x)
#endif
void
dump_packet(const unsigned char* buf, int len);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment