#ifndef COMMON_H
#define COMMON_H

#include <endian.h>
#if __BYTE_ORDER == __LITTLE_ENDIAN
#define le_to_host16(n) (n)
#define host_to_le16(n) (n)
#else
#include <byteswap.h>
#define le_to_host16(n) bswap_16(n)
#define host_to_le16(n) bswap_16(n)
#endif


typedef unsigned int u32;
typedef unsigned short u16;
typedef unsigned char u8;

int hostapd_get_rand(u8 *buf, size_t len);
void hostapd_hexdump(const char *title, u8 *buf, size_t len);


static inline void print_char(char c)
{
	if (c >= 32 && c < 127)
		printf("%c", c);
	else
		printf("<%02x>", c);
}


static inline void fprint_char(FILE *f, char c)
{
	if (c >= 32 && c < 127)
		fprintf(f, "%c", c);
	else
		fprintf(f, "<%02x>", c);
}

#endif /* COMMON_H */
