From c095e7fbaea57a7ec181832571970ff3655e4d60 Mon Sep 17 00:00:00 2001 From: ravd Date: Tue, 26 Nov 2024 15:54:17 +0100 Subject: [PATCH] Make byteswap functions portable and so that sflowtool can build on Mac OSX --- src/sflowtool.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/sflowtool.c b/src/sflowtool.c index 28293df..389f777 100644 --- a/src/sflowtool.c +++ b/src/sflowtool.c @@ -29,7 +29,6 @@ extern "C" { #include #include #include -#include #include #include "sflow.h" /* sFlow v5 */ @@ -41,6 +40,17 @@ extern "C" { #define YES 1 #define NO 0 +static uint32_t bswap_32(uint32_t n) { + return (((n & 0x000000FF)<<24) + + ((n & 0x0000FF00)<<8) + + ((n & 0x00FF0000)>>8) + + ((n & 0xFF000000)>>24)); +} + +static uint16_t bswap_16(uint16_t n) { + return ((n >> 8) | (n << 8)); +} + /* define my own IP header struct - to ease portability */ struct myiphdr {