From 04399c00226f91f38b6153819a47118d9cfaaa09 Mon Sep 17 00:00:00 2001 From: Thomas Kolb Date: Wed, 18 Dec 2024 21:01:14 +0100 Subject: [PATCH] Fix byte order in TUN packet header --- impl/test/layer2_over_udp/l2udptest_client.c | 4 ++-- impl/test/layer2_over_udp/l2udptest_digipeater.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/impl/test/layer2_over_udp/l2udptest_client.c b/impl/test/layer2_over_udp/l2udptest_client.c index 5937004..456e82a 100644 --- a/impl/test/layer2_over_udp/l2udptest_client.c +++ b/impl/test/layer2_over_udp/l2udptest_client.c @@ -104,10 +104,10 @@ void rx_data_to_tun(const layer2_data_packet_t *data_packet) switch(data_packet->payload_type) { case L2_PAYLOAD_TYPE_IPV6: - *(uint16_t*)(tun_packet+2) = 0x86dd; + *(uint16_t*)(tun_packet+2) = htons(0x86dd); break; case L2_PAYLOAD_TYPE_IPV4: - *(uint16_t*)(tun_packet+2) = 0x0800; + *(uint16_t*)(tun_packet+2) = htons(0x0800); break; default: LOG(LVL_ERR, "Unsupported payload type: 0x%08x.", data_packet->payload_type); diff --git a/impl/test/layer2_over_udp/l2udptest_digipeater.c b/impl/test/layer2_over_udp/l2udptest_digipeater.c index 32ed7b2..20e5307 100644 --- a/impl/test/layer2_over_udp/l2udptest_digipeater.c +++ b/impl/test/layer2_over_udp/l2udptest_digipeater.c @@ -101,10 +101,10 @@ void rx_data_to_tun(const layer2_data_packet_t *data_packet) switch(data_packet->payload_type) { case L2_PAYLOAD_TYPE_IPV6: - *(uint16_t*)(tun_packet+2) = 0x86dd; + *(uint16_t*)(tun_packet+2) = htons(0x86dd); break; case L2_PAYLOAD_TYPE_IPV4: - *(uint16_t*)(tun_packet+2) = 0x0800; + *(uint16_t*)(tun_packet+2) = htons(0x0800); break; default: LOG(LVL_ERR, "Unsupported payload type: 0x%08x.", data_packet->payload_type);