From 5e495822509400e1a0fa50002d3b0fa846cbda83 Mon Sep 17 00:00:00 2001 From: Philipp Raich Date: Thu, 19 May 2022 13:50:56 +0200 Subject: [PATCH] sixlowpan: fix UDP_NHC port decompression --- src/sixlowpan/model/sixlowpan-net-device.cc | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/sixlowpan/model/sixlowpan-net-device.cc b/src/sixlowpan/model/sixlowpan-net-device.cc index 35d5b344c..8b7da315f 100644 --- a/src/sixlowpan/model/sixlowpan-net-device.cc +++ b/src/sixlowpan/model/sixlowpan-net-device.cc @@ -2199,22 +2199,18 @@ SixLowPanNetDevice::DecompressLowPanUdpNhc (Ptr packet, Ipv6Address sadd break; case SixLowPanUdpNhcExtension::PORTS_ALL_SRC_LAST_DST: udpHeader.SetSourcePort (encoding.GetSrcPort ()); - temp = 0xf0; - temp |= (temp << 8) | encoding.GetDstPort (); + temp = (0xf0 << 8) | encoding.GetDstPort (); udpHeader.SetDestinationPort (temp); break; case SixLowPanUdpNhcExtension::PORTS_LAST_SRC_ALL_DST: - temp = 0xf0; - temp |= (temp << 8) | encoding.GetSrcPort (); + temp = (0xf0 << 8) | encoding.GetSrcPort (); udpHeader.SetSourcePort (temp); udpHeader.SetDestinationPort (encoding.GetDstPort ()); break; case SixLowPanUdpNhcExtension::PORTS_LAST_SRC_LAST_DST: - temp = 0xf0b; - temp |= (temp << 4) | encoding.GetSrcPort (); + temp = (0xf0b << 4) | encoding.GetSrcPort (); udpHeader.SetSourcePort (temp); - temp = 0xf0b; - temp |= (temp << 4) | encoding.GetDstPort (); + temp = (0xf0b << 4) | encoding.GetDstPort (); udpHeader.SetDestinationPort (temp); break; }