From efda8edcc521d3b8af866000737e82eabc50d29d Mon Sep 17 00:00:00 2001 From: joxe Date: Fri, 12 Mar 2010 14:23:40 +0000 Subject: [PATCH] fixed UDP uncompression --- .../plugins/analyzers/IPHCPacketAnalyzer.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/tools/cooja/java/se/sics/cooja/plugins/analyzers/IPHCPacketAnalyzer.java b/tools/cooja/java/se/sics/cooja/plugins/analyzers/IPHCPacketAnalyzer.java index 5d2b08625..218598d08 100644 --- a/tools/cooja/java/se/sics/cooja/plugins/analyzers/IPHCPacketAnalyzer.java +++ b/tools/cooja/java/se/sics/cooja/plugins/analyzers/IPHCPacketAnalyzer.java @@ -42,9 +42,10 @@ public class IPHCPacketAnalyzer extends PacketAnalyzer { public final static int SICSLOWPAN_IPHC_DAM_10 = 0x02; public final static int SICSLOWPAN_IPHC_DAM_11 = 0x03; - private static final int SICSLOWPAN_NHC_UDP_ID = 0xf8; - private static final int SICSLOWPAN_NHC_UDP_C = 0xFB; - private static final int SICSLOWPAN_NHC_UDP_I = 0xF8; + private static final int SICSLOWPAN_NDC_UDP_MASK = 0xf8; + private static final int SICSLOWPAN_NHC_UDP_ID = 0xf0; + private static final int SICSLOWPAN_NHC_UDP_C = 0xf3; + private static final int SICSLOWPAN_NHC_UDP_I = 0xf0; public final static int PROTO_UDP = 17; public final static int PROTO_TCP = 6; @@ -71,7 +72,7 @@ public class IPHCPacketAnalyzer extends PacketAnalyzer { if (packet.size() < 3) return ANALYSIS_FAILED; int tf = (packet.get(0) >> 3) & 0x03; - int nh = (packet.get(0) >> 2) & 0x01; + boolean nhc = (packet.get(0) & SICSLOWPAN_IPHC_NH_C) > 0; int hlim = (packet.get(0) & 0x03); int cid = (packet.get(1) >> 7) & 0x01; int sac = (packet.get(1) >> 6) & 0x01; @@ -82,7 +83,7 @@ public class IPHCPacketAnalyzer extends PacketAnalyzer { int sci = 0; int dci = 0; - brief.append("IPHC tf=" + tf + (nh == 1 ? " nh" : "") + " hl=" + hlim + (cid == 1 ? " cid " : "")); + brief.append("IPHC tf=" + tf + (nhc ? " nh" : "") + " hl=" + hlim + (cid == 1 ? " cid " : "")); brief.append((sac == 1 ? " sac" : "") + " sam=" + sam + (m == 1 ? " M" : "") + (dac == 1 ? " dac" : " -") + " dam=" + dam); @@ -92,7 +93,7 @@ public class IPHCPacketAnalyzer extends PacketAnalyzer { /* need to decompress while analyzing - add that later... */ verbose.append("IPHC HC-06
"); - verbose.append("tf = " + tf + " nhc = " + nh + " hlim = " + hlim + verbose.append("tf = " + tf + " nhc = " + nhc + " hlim = " + hlim + " cid = " + cid + " sac = " + sac + " sam = " + sam + " MCast = " + m + " dac = " + dac + " dam = " + dam + "
"); if (cid == 1) { @@ -348,10 +349,10 @@ public class IPHCPacketAnalyzer extends PacketAnalyzer { } /* Next header processing - continued */ - if((packet.get(0) & SICSLOWPAN_IPHC_NH_C) != 0) { + if(nhc) { /* TODO: check if this is correct in hc-06 */ /* The next header is compressed, NHC is following */ - if((packet.get(hc06_ptr) & 0xFC) == SICSLOWPAN_NHC_UDP_ID) { + if((packet.get(hc06_ptr) & SICSLOWPAN_NDC_UDP_MASK) == SICSLOWPAN_NHC_UDP_ID) { proto = PROTO_UDP; switch(packet.get(hc06_ptr)) { case (byte) SICSLOWPAN_NHC_UDP_C: