mirror of
https://github.com/pavel-odintsov/fastnetmon
synced 2024-05-21 19:36:21 +02:00
Added cross platform support for libsflow to fix build on Windows
This commit is contained in:
parent
780e4b7332
commit
e09d02e2d9
|
@ -1,6 +1,10 @@
|
|||
#pragma once
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <winsock.h>
|
||||
#else
|
||||
#include <arpa/inet.h>
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#include <libkern/OSByteOrder.h>
|
||||
|
@ -34,7 +38,11 @@ inline int32_t fast_ntoh(int32_t value) {
|
|||
|
||||
// network (big endian) byte order to host byte order
|
||||
inline uint64_t fast_ntoh(uint64_t value) {
|
||||
#ifdef _WIN32
|
||||
return _byteswap_uint64(value);
|
||||
#else
|
||||
return be64toh(value);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Type safe version of htonl, htons
|
||||
|
@ -52,7 +60,11 @@ inline int32_t fast_hton(int32_t value) {
|
|||
|
||||
inline uint64_t fast_hton(uint64_t value) {
|
||||
// host to big endian (network byte order)
|
||||
#ifdef _WIN32
|
||||
return _byteswap_uint64(value);
|
||||
#else
|
||||
return htobe64(value);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Explicitly remove all other types to avoid implicit conversion
|
||||
|
|
|
@ -10,8 +10,6 @@
|
|||
#include <tuple>
|
||||
#include <vector>
|
||||
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include "../fast_endianless.hpp"
|
||||
|
||||
// We need it for sanity checks
|
||||
|
@ -32,7 +30,7 @@ enum sflow_header_protocol {
|
|||
SFLOW_HEADER_PROTOCOL_IPv6 = 12,
|
||||
};
|
||||
|
||||
// Old fashioned not typed enums for fast comparisions and assignments to
|
||||
// Old fashioned not typed enum for fast comparisons and assignments to
|
||||
// integers
|
||||
enum sflow_sample_type_not_typed_t {
|
||||
SFLOW_SAMPLE_TYPE_FLOW_SAMPLE = 1,
|
||||
|
|
Loading…
Reference in New Issue