Avoid deviation of this data in between different byte orders. Assume
that direct callers of nftnl_udata_put() know what they do.
Signed-off-by: Phil Sutter <phil@nwl.cc>
#include <udata.h>
#include <utils.h>
+#include <arpa/inet.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
bool nftnl_udata_put_u32(struct nftnl_udata_buf *buf, uint8_t type,
uint32_t data)
{
- return nftnl_udata_put(buf, type, sizeof(data), &data);
+ uint32_t data_be = htonl(data);
+
+ return nftnl_udata_put(buf, type, sizeof(data_be), &data_be);
}
EXPORT_SYMBOL(nftnl_udata_type);
memcpy(&data, attr->value, sizeof(data));
- return data;
+ return ntohl(data);
}
EXPORT_SYMBOL(nftnl_udata_next);