Minor cleanup of the radio logger output (packet description).
This commit is contained in:
parent
ac4ba199bc
commit
6d9f904627
3 changed files with 523 additions and 519 deletions
|
@ -26,7 +26,7 @@
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* $Id: RadioLogger.java,v 1.34 2010/03/17 22:44:20 nifi Exp $
|
* $Id: RadioLogger.java,v 1.35 2010/04/06 23:38:18 nifi Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja.plugins;
|
package se.sics.cooja.plugins;
|
||||||
|
@ -266,6 +266,7 @@ public class RadioLogger extends VisPlugin {
|
||||||
prepareTooltipString(conn);
|
prepareTooltipString(conn);
|
||||||
}
|
}
|
||||||
verboseBox.setText(conn.tooltip);
|
verboseBox.setText(conn.tooltip);
|
||||||
|
verboseBox.setCaretPosition(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -427,12 +428,16 @@ public class RadioLogger extends VisPlugin {
|
||||||
if (packet.hasMoreData()) {
|
if (packet.hasMoreData()) {
|
||||||
byte[] payload = packet.getPayload();
|
byte[] payload = packet.getPayload();
|
||||||
brief.append(StringUtils.toHex(payload, 4));
|
brief.append(StringUtils.toHex(payload, 4));
|
||||||
|
if (verbose.length() > 0) {
|
||||||
|
verbose.append("<p>");
|
||||||
|
}
|
||||||
verbose.append("<b>Payload (")
|
verbose.append("<b>Payload (")
|
||||||
.append(payload.length).append(" bytes)</b><br><pre>")
|
.append(payload.length).append(" bytes)</b><br><pre>")
|
||||||
.append(StringUtils.hexDump(payload))
|
.append(StringUtils.hexDump(payload))
|
||||||
.append("</pre>");
|
.append("</pre>");
|
||||||
}
|
}
|
||||||
conn.data = (data.length < 10 ? " " : "") + data.length + ": " + brief;
|
conn.data = (data.length < 100 ? (data.length < 10 ? " " : " ") : "")
|
||||||
|
+ data.length + ": " + brief;
|
||||||
if (verbose.length() > 0) {
|
if (verbose.length() > 0) {
|
||||||
conn.tooltip = verbose.toString();
|
conn.tooltip = verbose.toString();
|
||||||
}
|
}
|
||||||
|
@ -450,16 +455,16 @@ public class RadioLogger extends VisPlugin {
|
||||||
PacketAnalyzer analyzer = analyzers.get(i);
|
PacketAnalyzer analyzer = analyzers.get(i);
|
||||||
if (analyzer.matchPacket(packet)) {
|
if (analyzer.matchPacket(packet)) {
|
||||||
int res = analyzer.analyzePacket(packet, brief, verbose);
|
int res = analyzer.analyzePacket(packet, brief, verbose);
|
||||||
|
if (packet.hasMoreData() && brief.length() > 0) {
|
||||||
|
brief.append('|');
|
||||||
|
verbose.append("<br>");
|
||||||
|
}
|
||||||
if (res != PacketAnalyzer.ANALYSIS_OK_CONTINUE) {
|
if (res != PacketAnalyzer.ANALYSIS_OK_CONTINUE) {
|
||||||
/* this was the final or the analysis failed - no analyzable payload possible here... */
|
/* this was the final or the analysis failed - no analyzable payload possible here... */
|
||||||
return brief.length() > 0;
|
return brief.length() > 0;
|
||||||
}
|
}
|
||||||
/* continue another round if more bytes left */
|
/* continue another round if more bytes left */
|
||||||
analyze = packet.hasMoreData();
|
analyze = packet.hasMoreData();
|
||||||
if (analyze) {
|
|
||||||
brief.append('|');
|
|
||||||
verbose.append("<p>");
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,86 +1,85 @@
|
||||||
package se.sics.cooja.plugins.analyzers;
|
package se.sics.cooja.plugins.analyzers;
|
||||||
|
|
||||||
public class ICMPv6Analyzer extends PacketAnalyzer {
|
public class ICMPv6Analyzer extends PacketAnalyzer {
|
||||||
|
|
||||||
public static final byte ICMPv6_DISPATCH = 58;
|
public static final byte ICMPv6_DISPATCH = 58;
|
||||||
|
|
||||||
public static final int ECHO_REQUEST = 128;
|
public static final int ECHO_REQUEST = 128;
|
||||||
public static final int ECHO_REPLY = 129;
|
public static final int ECHO_REPLY = 129;
|
||||||
public static final int GROUP_QUERY = 130;
|
public static final int GROUP_QUERY = 130;
|
||||||
public static final int GROUP_REPORT = 131;
|
public static final int GROUP_REPORT = 131;
|
||||||
public static final int GROUP_REDUCTION = 132;
|
public static final int GROUP_REDUCTION = 132;
|
||||||
public static final int ROUTER_SOLICITATION = 133;
|
public static final int ROUTER_SOLICITATION = 133;
|
||||||
public static final int ROUTER_ADVERTISEMENT = 134;
|
public static final int ROUTER_ADVERTISEMENT = 134;
|
||||||
public static final int NEIGHBOR_SOLICITATION = 135;
|
public static final int NEIGHBOR_SOLICITATION = 135;
|
||||||
public static final int NEIGHBOR_ADVERTISEMENT = 136;
|
public static final int NEIGHBOR_ADVERTISEMENT = 136;
|
||||||
|
|
||||||
public static final int RPL_CODE_DIS = 1; /* DIS message */
|
public static final int RPL_CODE_DIS = 1; /* DIS message */
|
||||||
public static final int RPL_CODE_DIO = 2; /* DIO message */
|
public static final int RPL_CODE_DIO = 2; /* DIO message */
|
||||||
public static final int RPL_CODE_DAO = 4;/* DAO message */
|
public static final int RPL_CODE_DAO = 4;/* DAO message */
|
||||||
|
|
||||||
public static final int FLAG_ROUTER = 0x80;
|
public static final int FLAG_ROUTER = 0x80;
|
||||||
public static final int FLAG_SOLICITED = 0x40;
|
public static final int FLAG_SOLICITED = 0x40;
|
||||||
public static final int FLAG_OVERRIDE = 0x20;
|
public static final int FLAG_OVERRIDE = 0x20;
|
||||||
|
|
||||||
public static final int ON_LINK = 0x80;
|
public static final int ON_LINK = 0x80;
|
||||||
public static final int AUTOCONFIG = 0x40;
|
public static final int AUTOCONFIG = 0x40;
|
||||||
|
|
||||||
public static final int SOURCE_LINKADDR = 1;
|
public static final int SOURCE_LINKADDR = 1;
|
||||||
public static final int TARGET_LINKADDR = 2;
|
public static final int TARGET_LINKADDR = 2;
|
||||||
public static final int PREFIX_INFO = 3;
|
public static final int PREFIX_INFO = 3;
|
||||||
public static final int MTU_INFO = 5;
|
public static final int MTU_INFO = 5;
|
||||||
|
|
||||||
public static final String[] TYPE_NAME = new String[] {
|
public static final String[] TYPE_NAME = new String[] {
|
||||||
"ECHO_REQUEST", "ECHO_REPLY",
|
"ECHO_REQUEST", "ECHO_REPLY",
|
||||||
"GROUP_QUERY", "GROUP_REPORT", "GROUP_REDUCTION",
|
"GROUP_QUERY", "GROUP_REPORT", "GROUP_REDUCTION",
|
||||||
"ROUTER_SOLICITATION", "ROUTER_ADVERTISEMENT",
|
"ROUTER_SOLICITATION", "ROUTER_ADVERTISEMENT",
|
||||||
"NEIGHBOR_SOLICITATION", "NEIGHBOR_ADVERTISEMENT", "REDIRECT",
|
"NEIGHBOR_SOLICITATION", "NEIGHBOR_ADVERTISEMENT", "REDIRECT",
|
||||||
"ROUTER RENUMBER", "NODE INFORMATION QUERY", "NODE INFORMATION RESPONSE"};
|
"ROUTER RENUMBER", "NODE INFORMATION QUERY", "NODE INFORMATION RESPONSE"};
|
||||||
|
|
||||||
|
|
||||||
public int analyzePacket(Packet packet, StringBuffer brief,
|
public int analyzePacket(Packet packet, StringBuffer brief,
|
||||||
StringBuffer verbose) {
|
StringBuffer verbose) {
|
||||||
int type = packet.get(0) & 0xff;
|
int type = packet.get(0) & 0xff;
|
||||||
int code = packet.get(1) & 0xff;
|
int code = packet.get(1) & 0xff;
|
||||||
int checksum = ((packet.get(2) & 0xff) << 8) | packet.get(3) & 0xff;
|
// int checksum = ((packet.get(2) & 0xff) << 8) | packet.get(3) & 0xff;
|
||||||
|
|
||||||
brief.append("ICMPv6 ");
|
brief.append("ICMPv6 ");
|
||||||
if (type >= 128 && (type - 128) < TYPE_NAME.length) {
|
if (type >= 128 && (type - 128) < TYPE_NAME.length) {
|
||||||
brief.append(TYPE_NAME[type - 128]).append(" ");
|
brief.append(TYPE_NAME[type - 128]).append(' ').append(code);
|
||||||
brief.append(" " + code);
|
verbose.append("Type: ").append(TYPE_NAME[type - 128]);
|
||||||
verbose.append("Type: " + TYPE_NAME[type - 128]).append("<br>");
|
verbose.append(" Code:").append(code);
|
||||||
verbose.append("Code:" + code + "<br>");
|
} else if (type == 155) {
|
||||||
} else if (type == 155) {
|
/* RPL */
|
||||||
/* RPL */
|
brief.append("RPL ");
|
||||||
brief.append("RPL ");
|
verbose.append("Type: RPL Code: ");
|
||||||
verbose.append("Type: RPL<br>");
|
switch(code) {
|
||||||
switch(code) {
|
case RPL_CODE_DIS:
|
||||||
case RPL_CODE_DIS:
|
brief.append("DIS");
|
||||||
brief.append("DIS ");
|
verbose.append("DIS");
|
||||||
verbose.append("Code: DIS<br>");
|
break;
|
||||||
break;
|
case RPL_CODE_DIO:
|
||||||
case RPL_CODE_DIO:
|
brief.append("DIO");
|
||||||
brief.append("DIO ");
|
verbose.append("DIO");
|
||||||
verbose.append("Code: DIO<br>");
|
break;
|
||||||
break;
|
case RPL_CODE_DAO:
|
||||||
case RPL_CODE_DAO:
|
brief.append("DAO");
|
||||||
brief.append("DAO ");
|
verbose.append("DAO");
|
||||||
verbose.append("Code: DAO<br>");
|
break;
|
||||||
break;
|
default:
|
||||||
default:
|
brief.append(code);
|
||||||
brief.append(" " + code);
|
verbose.append(code);
|
||||||
verbose.append("Code: " + code);
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
/* remove type, code, crc */
|
||||||
/* remove type, code, crc */
|
packet.consumeBytesStart(4);
|
||||||
packet.consumeBytesStart(4);
|
return ANALYSIS_OK_FINAL;
|
||||||
return ANALYSIS_OK_FINAL;
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
@Override
|
public boolean matchPacket(Packet packet) {
|
||||||
public boolean matchPacket(Packet packet) {
|
return packet.level == NETWORK_LEVEL && packet.lastDispatch == ICMPv6_DISPATCH;
|
||||||
return packet.level == NETWORK_LEVEL && packet.lastDispatch == ICMPv6_DISPATCH;
|
}
|
||||||
}
|
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
|
@ -1,427 +1,427 @@
|
||||||
package se.sics.cooja.plugins.analyzers;
|
package se.sics.cooja.plugins.analyzers;
|
||||||
|
|
||||||
import se.sics.cooja.util.StringUtils;
|
import se.sics.cooja.util.StringUtils;
|
||||||
|
|
||||||
public class IPHCPacketAnalyzer extends PacketAnalyzer {
|
public class IPHCPacketAnalyzer extends PacketAnalyzer {
|
||||||
|
|
||||||
public final static int SICSLOWPAN_UDP_PORT_MIN = 0xF0B0;
|
public final static int SICSLOWPAN_UDP_PORT_MIN = 0xF0B0;
|
||||||
public final static int SICSLOWPAN_UDP_PORT_MAX = 0xF0BF; /* F0B0 + 15 */
|
public final static int SICSLOWPAN_UDP_PORT_MAX = 0xF0BF; /* F0B0 + 15 */
|
||||||
|
|
||||||
public final static int SICSLOWPAN_DISPATCH_IPV6 = 0x41; /* 01000001 = 65 */
|
public final static int SICSLOWPAN_DISPATCH_IPV6 = 0x41; /* 01000001 = 65 */
|
||||||
public final static int SICSLOWPAN_DISPATCH_HC1 = 0x42; /* 01000010 = 66 */
|
public final static int SICSLOWPAN_DISPATCH_HC1 = 0x42; /* 01000010 = 66 */
|
||||||
public final static int SICSLOWPAN_DISPATCH_IPHC = 0x60; /* 011xxxxx = ... */
|
public final static int SICSLOWPAN_DISPATCH_IPHC = 0x60; /* 011xxxxx = ... */
|
||||||
public final static int SICSLOWPAN_DISPATCH_FRAG1 = 0xc0; /* 1100= 0xxx */
|
public final static int SICSLOWPAN_DISPATCH_FRAG1 = 0xc0; /* 1100= 0xxx */
|
||||||
public final static int SICSLOWPAN_DISPATCH_FRAGN = 0xe0; /* 1110= 0xxx */
|
public final static int SICSLOWPAN_DISPATCH_FRAGN = 0xe0; /* 1110= 0xxx */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Values of fields within the IPHC encoding first byte
|
* Values of fields within the IPHC encoding first byte
|
||||||
* (C stands for compressed and I for inline)
|
* (C stands for compressed and I for inline)
|
||||||
*/
|
*/
|
||||||
public final static int SICSLOWPAN_IPHC_TC_C = 0x10;
|
public final static int SICSLOWPAN_IPHC_TC_C = 0x10;
|
||||||
public final static int SICSLOWPAN_IPHC_FL_C = 0x08;
|
public final static int SICSLOWPAN_IPHC_FL_C = 0x08;
|
||||||
public final static int SICSLOWPAN_IPHC_NH_C = 0x04;
|
public final static int SICSLOWPAN_IPHC_NH_C = 0x04;
|
||||||
public final static int SICSLOWPAN_IPHC_TTL_1 = 0x01;
|
public final static int SICSLOWPAN_IPHC_TTL_1 = 0x01;
|
||||||
public final static int SICSLOWPAN_IPHC_TTL_64 = 0x02;
|
public final static int SICSLOWPAN_IPHC_TTL_64 = 0x02;
|
||||||
public final static int SICSLOWPAN_IPHC_TTL_255 = 0x03;
|
public final static int SICSLOWPAN_IPHC_TTL_255 = 0x03;
|
||||||
public final static int SICSLOWPAN_IPHC_TTL_I = 0x00;
|
public final static int SICSLOWPAN_IPHC_TTL_I = 0x00;
|
||||||
|
|
||||||
|
|
||||||
/* Values of fields within the IPHC encoding second byte */
|
/* Values of fields within the IPHC encoding second byte */
|
||||||
public final static int SICSLOWPAN_IPHC_CID = 0x80;
|
public final static int SICSLOWPAN_IPHC_CID = 0x80;
|
||||||
|
|
||||||
public final static int SICSLOWPAN_IPHC_SAC = 0x40;
|
public final static int SICSLOWPAN_IPHC_SAC = 0x40;
|
||||||
public final static int SICSLOWPAN_IPHC_SAM_00 = 0x00;
|
public final static int SICSLOWPAN_IPHC_SAM_00 = 0x00;
|
||||||
public final static int SICSLOWPAN_IPHC_SAM_01 = 0x10;
|
public final static int SICSLOWPAN_IPHC_SAM_01 = 0x10;
|
||||||
public final static int SICSLOWPAN_IPHC_SAM_10 = 0x20;
|
public final static int SICSLOWPAN_IPHC_SAM_10 = 0x20;
|
||||||
public final static int SICSLOWPAN_IPHC_SAM_11 = 0x30;
|
public final static int SICSLOWPAN_IPHC_SAM_11 = 0x30;
|
||||||
|
|
||||||
public final static int SICSLOWPAN_IPHC_M = 0x08;
|
public final static int SICSLOWPAN_IPHC_M = 0x08;
|
||||||
public final static int SICSLOWPAN_IPHC_DAC = 0x04;
|
public final static int SICSLOWPAN_IPHC_DAC = 0x04;
|
||||||
public final static int SICSLOWPAN_IPHC_DAM_00 = 0x00;
|
public final static int SICSLOWPAN_IPHC_DAM_00 = 0x00;
|
||||||
public final static int SICSLOWPAN_IPHC_DAM_01 = 0x01;
|
public final static int SICSLOWPAN_IPHC_DAM_01 = 0x01;
|
||||||
public final static int SICSLOWPAN_IPHC_DAM_10 = 0x02;
|
public final static int SICSLOWPAN_IPHC_DAM_10 = 0x02;
|
||||||
public final static int SICSLOWPAN_IPHC_DAM_11 = 0x03;
|
public final static int SICSLOWPAN_IPHC_DAM_11 = 0x03;
|
||||||
|
|
||||||
private static final int SICSLOWPAN_NDC_UDP_MASK = 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_ID = 0xf0;
|
||||||
private static final int SICSLOWPAN_NHC_UDP_C = 0xf3;
|
private static final int SICSLOWPAN_NHC_UDP_C = 0xf3;
|
||||||
private static final int SICSLOWPAN_NHC_UDP_I = 0xf0;
|
private static final int SICSLOWPAN_NHC_UDP_I = 0xf0;
|
||||||
|
|
||||||
public final static int PROTO_UDP = 17;
|
public final static int PROTO_UDP = 17;
|
||||||
public final static int PROTO_TCP = 6;
|
public final static int PROTO_TCP = 6;
|
||||||
public final static int PROTO_ICMP = 58;
|
public final static int PROTO_ICMP = 58;
|
||||||
|
|
||||||
|
|
||||||
public final static byte[] UNSPECIFIED_ADDRESS =
|
public final static byte[] UNSPECIFIED_ADDRESS =
|
||||||
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||||
|
|
||||||
private static byte[][] addrContexts = new byte[][] {
|
private static byte[][] addrContexts = new byte[][] {
|
||||||
{(byte)0xaa, (byte)0xaa, 0, 0, 0, 0, 0, 0}
|
{(byte)0xaa, (byte)0xaa, 0, 0, 0, 0, 0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
private static final int IPHC_DISPATCH = 0x60;
|
private static final int IPHC_DISPATCH = 0x60;
|
||||||
|
|
||||||
public boolean matchPacket(Packet packet) {
|
public boolean matchPacket(Packet packet) {
|
||||||
return (packet.get(0) & 0xe0) == IPHC_DISPATCH;
|
return (packet.get(0) & 0xe0) == IPHC_DISPATCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int analyzePacket(Packet packet, StringBuffer brief,
|
public int analyzePacket(Packet packet, StringBuffer brief,
|
||||||
StringBuffer verbose) {
|
StringBuffer verbose) {
|
||||||
|
|
||||||
/* if packet has less than 3 bytes it is not interesting ... */
|
/* if packet has less than 3 bytes it is not interesting ... */
|
||||||
if (packet.size() < 3) return ANALYSIS_FAILED;
|
if (packet.size() < 3) return ANALYSIS_FAILED;
|
||||||
|
|
||||||
int tf = (packet.get(0) >> 3) & 0x03;
|
int tf = (packet.get(0) >> 3) & 0x03;
|
||||||
boolean nhc = (packet.get(0) & SICSLOWPAN_IPHC_NH_C) > 0;
|
boolean nhc = (packet.get(0) & SICSLOWPAN_IPHC_NH_C) > 0;
|
||||||
int hlim = (packet.get(0) & 0x03);
|
int hlim = (packet.get(0) & 0x03);
|
||||||
int cid = (packet.get(1) >> 7) & 0x01;
|
int cid = (packet.get(1) >> 7) & 0x01;
|
||||||
int sac = (packet.get(1) >> 6) & 0x01;
|
int sac = (packet.get(1) >> 6) & 0x01;
|
||||||
int sam = (packet.get(1) >> 4) & 0x03;
|
int sam = (packet.get(1) >> 4) & 0x03;
|
||||||
int m = (packet.get(1) >> 3) & 0x01;
|
int m = (packet.get(1) >> 3) & 0x01;
|
||||||
int dac = (packet.get(1) >> 2) & 0x01;
|
int dac = (packet.get(1) >> 2) & 0x01;
|
||||||
int dam = packet.get(1) & 0x03;
|
int dam = packet.get(1) & 0x03;
|
||||||
int sci = 0;
|
int sci = 0;
|
||||||
int dci = 0;
|
int dci = 0;
|
||||||
|
|
||||||
brief.append("IPHC");
|
brief.append("IPHC");
|
||||||
|
|
||||||
/* need to decompress while analyzing - add that later... */
|
/* need to decompress while analyzing - add that later... */
|
||||||
|
|
||||||
verbose.append("<b>IPHC HC-06</b><br>");
|
verbose.append("<b>IPHC HC-06</b><br>");
|
||||||
verbose.append("tf = " + tf + " nhc = " + nhc + " hlim = " + hlim
|
verbose.append("tf = " + tf + " nhc = " + nhc + " hlim = " + hlim
|
||||||
+ " cid = " + cid + " sac = " + sac + " sam = " + sam
|
+ " cid = " + cid + " sac = " + sac + " sam = " + sam
|
||||||
+ " MCast = " + m + " dac = " + dac + " dam = " + dam + "<br>");
|
+ " MCast = " + m + " dac = " + dac + " dam = " + dam);
|
||||||
if (cid == 1) {
|
if (cid == 1) {
|
||||||
verbose.append("Contexts: sci=" + (packet.get(2) >> 4) + " dci="
|
verbose.append("<br>Contexts: sci=" + (packet.get(2) >> 4) + " dci="
|
||||||
+ (packet.get(2) & 0x0f) + "<br>");
|
+ (packet.get(2) & 0x0f));
|
||||||
sci = packet.get(2) >> 4;
|
sci = packet.get(2) >> 4;
|
||||||
dci = packet.get(2) & 0x0f;
|
dci = packet.get(2) & 0x0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
int hc06_ptr = 2 + cid;
|
int hc06_ptr = 2 + cid;
|
||||||
|
|
||||||
int version = 6;
|
int version = 6;
|
||||||
int trafficClass = 0;
|
int trafficClass = 0;
|
||||||
int flowLabel = 0;
|
int flowLabel = 0;
|
||||||
int len = 0;
|
int len = 0;
|
||||||
int proto = 0;
|
int proto = 0;
|
||||||
int ttl = 0;
|
int ttl = 0;
|
||||||
byte[] srcAddress = null;
|
byte[] srcAddress = null;
|
||||||
byte[] destAddress = null;
|
byte[] destAddress = null;
|
||||||
|
|
||||||
int srcPort = 0;
|
int srcPort = 0;
|
||||||
int destPort = 0;
|
int destPort = 0;
|
||||||
|
|
||||||
/* Traffic class and flow label */
|
/* Traffic class and flow label */
|
||||||
if((packet.get(0) & SICSLOWPAN_IPHC_FL_C) == 0) {
|
if((packet.get(0) & SICSLOWPAN_IPHC_FL_C) == 0) {
|
||||||
/* Flow label are carried inline */
|
/* Flow label are carried inline */
|
||||||
if((packet.get(0) & SICSLOWPAN_IPHC_TC_C) == 0) {
|
if((packet.get(0) & SICSLOWPAN_IPHC_TC_C) == 0) {
|
||||||
/* Traffic class is carried inline */
|
/* Traffic class is carried inline */
|
||||||
flowLabel = packet.getInt(hc06_ptr + 1, 3);
|
flowLabel = packet.getInt(hc06_ptr + 1, 3);
|
||||||
int tmp = packet.get(hc06_ptr);
|
int tmp = packet.get(hc06_ptr);
|
||||||
hc06_ptr += 4;
|
hc06_ptr += 4;
|
||||||
/* hc06 format of tc is ECN | DSCP , original is DSCP | ECN */
|
/* hc06 format of tc is ECN | DSCP , original is DSCP | ECN */
|
||||||
trafficClass = ((tmp >> 2) & 0x3f) | (tmp << 6) & (0x80 + 0x40);
|
trafficClass = ((tmp >> 2) & 0x3f) | (tmp << 6) & (0x80 + 0x40);
|
||||||
/* ECN rolled down two steps + lowest DSCP bits at top two bits */
|
/* ECN rolled down two steps + lowest DSCP bits at top two bits */
|
||||||
} else {
|
} else {
|
||||||
/* highest flow label bits + ECN bits */
|
/* highest flow label bits + ECN bits */
|
||||||
int tmp = packet.get(hc06_ptr);
|
int tmp = packet.get(hc06_ptr);
|
||||||
trafficClass = (tmp >> 6) & 0x0f;
|
trafficClass = (tmp >> 6) & 0x0f;
|
||||||
flowLabel = packet.getInt(hc06_ptr + 1, 2);
|
flowLabel = packet.getInt(hc06_ptr + 1, 2);
|
||||||
hc06_ptr += 3;
|
hc06_ptr += 3;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Version is always 6! */
|
/* Version is always 6! */
|
||||||
/* Version and flow label are compressed */
|
/* Version and flow label are compressed */
|
||||||
if((packet.get(0) & SICSLOWPAN_IPHC_TC_C) == 0) {
|
if((packet.get(0) & SICSLOWPAN_IPHC_TC_C) == 0) {
|
||||||
/* Traffic class is inline */
|
/* Traffic class is inline */
|
||||||
trafficClass =((packet.get(hc06_ptr) >> 6) & 0x03);
|
trafficClass =((packet.get(hc06_ptr) >> 6) & 0x03);
|
||||||
trafficClass = (packet.get(hc06_ptr) << 2);
|
trafficClass = (packet.get(hc06_ptr) << 2);
|
||||||
hc06_ptr += 1;
|
hc06_ptr += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Next Header */
|
/* Next Header */
|
||||||
if((packet.get(0) & SICSLOWPAN_IPHC_NH_C) == 0) {
|
if((packet.get(0) & SICSLOWPAN_IPHC_NH_C) == 0) {
|
||||||
/* Next header is carried inline */
|
/* Next header is carried inline */
|
||||||
proto = packet.get(hc06_ptr);
|
proto = packet.get(hc06_ptr);
|
||||||
hc06_ptr += 1;
|
hc06_ptr += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Hop limit */
|
/* Hop limit */
|
||||||
switch(packet.get(0) & 0x03) {
|
switch(packet.get(0) & 0x03) {
|
||||||
case SICSLOWPAN_IPHC_TTL_1:
|
case SICSLOWPAN_IPHC_TTL_1:
|
||||||
ttl = 1;
|
ttl = 1;
|
||||||
break;
|
break;
|
||||||
case SICSLOWPAN_IPHC_TTL_64:
|
case SICSLOWPAN_IPHC_TTL_64:
|
||||||
ttl = 2;
|
ttl = 2;
|
||||||
break;
|
break;
|
||||||
case SICSLOWPAN_IPHC_TTL_255:
|
case SICSLOWPAN_IPHC_TTL_255:
|
||||||
ttl = 255;
|
ttl = 255;
|
||||||
break;
|
break;
|
||||||
case SICSLOWPAN_IPHC_TTL_I:
|
case SICSLOWPAN_IPHC_TTL_I:
|
||||||
ttl = packet.get(hc06_ptr);
|
ttl = packet.get(hc06_ptr);
|
||||||
hc06_ptr += 1;
|
hc06_ptr += 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* context based compression */
|
/* context based compression */
|
||||||
if((packet.get(1) & SICSLOWPAN_IPHC_SAC) > 0) {
|
if((packet.get(1) & SICSLOWPAN_IPHC_SAC) > 0) {
|
||||||
/* Source address */
|
/* Source address */
|
||||||
byte[] context = null;
|
byte[] context = null;
|
||||||
if((packet.get(1) & SICSLOWPAN_IPHC_SAM_11) != SICSLOWPAN_IPHC_SAM_00) {
|
if((packet.get(1) & SICSLOWPAN_IPHC_SAM_11) != SICSLOWPAN_IPHC_SAM_00) {
|
||||||
context = addrContexts[sci];
|
context = addrContexts[sci];
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(packet.get(1) & SICSLOWPAN_IPHC_SAM_11) {
|
switch(packet.get(1) & SICSLOWPAN_IPHC_SAM_11) {
|
||||||
case SICSLOWPAN_IPHC_SAM_00:
|
case SICSLOWPAN_IPHC_SAM_00:
|
||||||
/* copy the unspecificed address */
|
/* copy the unspecificed address */
|
||||||
srcAddress = UNSPECIFIED_ADDRESS;
|
srcAddress = UNSPECIFIED_ADDRESS;
|
||||||
break;
|
break;
|
||||||
case SICSLOWPAN_IPHC_SAM_01: /* 64 bits */
|
case SICSLOWPAN_IPHC_SAM_01: /* 64 bits */
|
||||||
/* copy prefix from context */
|
/* copy prefix from context */
|
||||||
srcAddress = new byte[16];
|
srcAddress = new byte[16];
|
||||||
System.arraycopy(context, 0, srcAddress, 0, 8);
|
System.arraycopy(context, 0, srcAddress, 0, 8);
|
||||||
/* copy IID from packet */
|
/* copy IID from packet */
|
||||||
packet.copy(hc06_ptr, srcAddress, 8, 8);
|
packet.copy(hc06_ptr, srcAddress, 8, 8);
|
||||||
hc06_ptr += 8;
|
hc06_ptr += 8;
|
||||||
break;
|
break;
|
||||||
case SICSLOWPAN_IPHC_SAM_10: /* 16 bits */
|
case SICSLOWPAN_IPHC_SAM_10: /* 16 bits */
|
||||||
/* unicast address */
|
/* unicast address */
|
||||||
srcAddress = new byte[16];
|
srcAddress = new byte[16];
|
||||||
System.arraycopy(context, 0, srcAddress, 0, 8);
|
System.arraycopy(context, 0, srcAddress, 0, 8);
|
||||||
/* copy 6 NULL bytes then 2 last bytes of IID */
|
/* copy 6 NULL bytes then 2 last bytes of IID */
|
||||||
packet.copy(hc06_ptr, srcAddress, 14, 2);
|
packet.copy(hc06_ptr, srcAddress, 14, 2);
|
||||||
hc06_ptr += 2;
|
hc06_ptr += 2;
|
||||||
break;
|
break;
|
||||||
case SICSLOWPAN_IPHC_SAM_11: /* 0-bits */
|
case SICSLOWPAN_IPHC_SAM_11: /* 0-bits */
|
||||||
/* copy prefix from context */
|
/* copy prefix from context */
|
||||||
srcAddress = new byte[16];
|
srcAddress = new byte[16];
|
||||||
System.arraycopy(context, 0, srcAddress, 0, 8);
|
System.arraycopy(context, 0, srcAddress, 0, 8);
|
||||||
/* infer IID from L2 address */
|
/* infer IID from L2 address */
|
||||||
System.arraycopy(packet.llsender, 0, srcAddress,
|
System.arraycopy(packet.llsender, 0, srcAddress,
|
||||||
16 - packet.llsender.length, packet.llsender.length);
|
16 - packet.llsender.length, packet.llsender.length);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* end context based compression */
|
/* end context based compression */
|
||||||
} else {
|
} else {
|
||||||
/* no compression and link local */
|
/* no compression and link local */
|
||||||
switch(packet.get(1) & SICSLOWPAN_IPHC_SAM_11) {
|
switch(packet.get(1) & SICSLOWPAN_IPHC_SAM_11) {
|
||||||
case SICSLOWPAN_IPHC_SAM_00: /* 128 bits */
|
case SICSLOWPAN_IPHC_SAM_00: /* 128 bits */
|
||||||
/* copy whole address from packet */
|
/* copy whole address from packet */
|
||||||
srcAddress = new byte[16];
|
srcAddress = new byte[16];
|
||||||
packet.copy(hc06_ptr, srcAddress, 0, 16);
|
packet.copy(hc06_ptr, srcAddress, 0, 16);
|
||||||
hc06_ptr += 16;
|
hc06_ptr += 16;
|
||||||
break;
|
break;
|
||||||
case SICSLOWPAN_IPHC_SAM_01: /* 64 bits */
|
case SICSLOWPAN_IPHC_SAM_01: /* 64 bits */
|
||||||
srcAddress = new byte[16];
|
srcAddress = new byte[16];
|
||||||
srcAddress[0] = (byte) 0xfe;
|
srcAddress[0] = (byte) 0xfe;
|
||||||
srcAddress[1] = (byte) 0x80;
|
srcAddress[1] = (byte) 0x80;
|
||||||
/* copy IID from packet */
|
/* copy IID from packet */
|
||||||
packet.copy(hc06_ptr, srcAddress, 8, 8);
|
packet.copy(hc06_ptr, srcAddress, 8, 8);
|
||||||
hc06_ptr += 8;
|
hc06_ptr += 8;
|
||||||
break;
|
break;
|
||||||
case SICSLOWPAN_IPHC_SAM_10: /* 16 bits */
|
case SICSLOWPAN_IPHC_SAM_10: /* 16 bits */
|
||||||
srcAddress = new byte[16];
|
srcAddress = new byte[16];
|
||||||
srcAddress[0] = (byte) 0xfe;
|
srcAddress[0] = (byte) 0xfe;
|
||||||
srcAddress[1] = (byte) 0x80;
|
srcAddress[1] = (byte) 0x80;
|
||||||
packet.copy(hc06_ptr, srcAddress, 14, 2);
|
packet.copy(hc06_ptr, srcAddress, 14, 2);
|
||||||
hc06_ptr += 2;
|
hc06_ptr += 2;
|
||||||
break;
|
break;
|
||||||
case SICSLOWPAN_IPHC_SAM_11: /* 0 bits */
|
case SICSLOWPAN_IPHC_SAM_11: /* 0 bits */
|
||||||
/* setup link-local address */
|
/* setup link-local address */
|
||||||
srcAddress = new byte[16];
|
srcAddress = new byte[16];
|
||||||
srcAddress[0] = (byte) 0xfe;
|
srcAddress[0] = (byte) 0xfe;
|
||||||
srcAddress[1] = (byte) 0x80;
|
srcAddress[1] = (byte) 0x80;
|
||||||
/* infer IID from L2 address */
|
/* infer IID from L2 address */
|
||||||
System.arraycopy(packet.llsender, 0, srcAddress,
|
System.arraycopy(packet.llsender, 0, srcAddress,
|
||||||
16 - packet.llsender.length, packet.llsender.length);
|
16 - packet.llsender.length, packet.llsender.length);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Destination address */
|
/* Destination address */
|
||||||
|
|
||||||
/* multicast compression */
|
/* multicast compression */
|
||||||
if((packet.get(1) & SICSLOWPAN_IPHC_M) != 0) {
|
if((packet.get(1) & SICSLOWPAN_IPHC_M) != 0) {
|
||||||
/* context based multicast compression */
|
/* context based multicast compression */
|
||||||
if((packet.get(1) & SICSLOWPAN_IPHC_DAC) != 0) {
|
if((packet.get(1) & SICSLOWPAN_IPHC_DAC) != 0) {
|
||||||
/* TODO: implement this */
|
/* TODO: implement this */
|
||||||
} else {
|
} else {
|
||||||
/* non-context based multicast compression */
|
/* non-context based multicast compression */
|
||||||
switch (packet.get(1) & SICSLOWPAN_IPHC_DAM_11) {
|
switch (packet.get(1) & SICSLOWPAN_IPHC_DAM_11) {
|
||||||
case SICSLOWPAN_IPHC_DAM_00: /* 128 bits */
|
case SICSLOWPAN_IPHC_DAM_00: /* 128 bits */
|
||||||
/* copy whole address from packet */
|
/* copy whole address from packet */
|
||||||
destAddress = new byte[16];
|
destAddress = new byte[16];
|
||||||
packet.copy(hc06_ptr, destAddress, 0, 16);
|
packet.copy(hc06_ptr, destAddress, 0, 16);
|
||||||
hc06_ptr += 16;
|
hc06_ptr += 16;
|
||||||
break;
|
break;
|
||||||
case SICSLOWPAN_IPHC_DAM_01: /* 48 bits FFXX::00XX:XXXX:XXXX */
|
case SICSLOWPAN_IPHC_DAM_01: /* 48 bits FFXX::00XX:XXXX:XXXX */
|
||||||
destAddress = new byte[16];
|
destAddress = new byte[16];
|
||||||
destAddress[0] = (byte) 0xff;
|
destAddress[0] = (byte) 0xff;
|
||||||
destAddress[1] = packet.get(hc06_ptr);
|
destAddress[1] = packet.get(hc06_ptr);
|
||||||
packet.copy(hc06_ptr + 1, destAddress, 11, 5);
|
packet.copy(hc06_ptr + 1, destAddress, 11, 5);
|
||||||
hc06_ptr += 6;
|
hc06_ptr += 6;
|
||||||
break;
|
break;
|
||||||
case SICSLOWPAN_IPHC_DAM_10: /* 32 bits FFXX::00XX:XXXX */
|
case SICSLOWPAN_IPHC_DAM_10: /* 32 bits FFXX::00XX:XXXX */
|
||||||
destAddress = new byte[16];
|
destAddress = new byte[16];
|
||||||
destAddress[0] = (byte) 0xff;
|
destAddress[0] = (byte) 0xff;
|
||||||
destAddress[1] = packet.get(hc06_ptr);
|
destAddress[1] = packet.get(hc06_ptr);
|
||||||
packet.copy(hc06_ptr + 1, destAddress, 13, 3);
|
packet.copy(hc06_ptr + 1, destAddress, 13, 3);
|
||||||
hc06_ptr += 4;
|
hc06_ptr += 4;
|
||||||
break;
|
break;
|
||||||
case SICSLOWPAN_IPHC_DAM_11: /* 8 bits FF02::00XX */
|
case SICSLOWPAN_IPHC_DAM_11: /* 8 bits FF02::00XX */
|
||||||
destAddress = new byte[16];
|
destAddress = new byte[16];
|
||||||
destAddress[0] = (byte) 0xff;
|
destAddress[0] = (byte) 0xff;
|
||||||
destAddress[1] = (byte) 0x02;
|
destAddress[1] = (byte) 0x02;
|
||||||
destAddress[15] = packet.get(hc06_ptr);
|
destAddress[15] = packet.get(hc06_ptr);
|
||||||
hc06_ptr++;
|
hc06_ptr++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* no multicast */
|
/* no multicast */
|
||||||
/* Context based */
|
/* Context based */
|
||||||
if((packet.get(1) & SICSLOWPAN_IPHC_DAC) != 0) {
|
if((packet.get(1) & SICSLOWPAN_IPHC_DAC) != 0) {
|
||||||
byte[] context = addrContexts[dci];
|
byte[] context = addrContexts[dci];
|
||||||
|
|
||||||
switch (packet.get(1) & SICSLOWPAN_IPHC_DAM_11) {
|
switch (packet.get(1) & SICSLOWPAN_IPHC_DAM_11) {
|
||||||
case SICSLOWPAN_IPHC_DAM_01: /* 64 bits */
|
case SICSLOWPAN_IPHC_DAM_01: /* 64 bits */
|
||||||
destAddress = new byte[16];
|
destAddress = new byte[16];
|
||||||
System.arraycopy(context, 0, destAddress, 0, 8);
|
System.arraycopy(context, 0, destAddress, 0, 8);
|
||||||
/* copy IID from packet */
|
/* copy IID from packet */
|
||||||
packet.copy(hc06_ptr, destAddress, 8, 8);
|
packet.copy(hc06_ptr, destAddress, 8, 8);
|
||||||
hc06_ptr += 8;
|
hc06_ptr += 8;
|
||||||
break;
|
break;
|
||||||
case SICSLOWPAN_IPHC_DAM_10: /* 16 bits */
|
case SICSLOWPAN_IPHC_DAM_10: /* 16 bits */
|
||||||
/* unicast address */
|
/* unicast address */
|
||||||
destAddress = new byte[16];
|
destAddress = new byte[16];
|
||||||
System.arraycopy(context, 0, destAddress, 0, 8);
|
System.arraycopy(context, 0, destAddress, 0, 8);
|
||||||
/* copy IID from packet */
|
/* copy IID from packet */
|
||||||
packet.copy(hc06_ptr, destAddress, 14, 2);
|
packet.copy(hc06_ptr, destAddress, 14, 2);
|
||||||
hc06_ptr += 2;
|
hc06_ptr += 2;
|
||||||
break;
|
break;
|
||||||
case SICSLOWPAN_IPHC_DAM_11: /* 0 bits */
|
case SICSLOWPAN_IPHC_DAM_11: /* 0 bits */
|
||||||
/* unicast address */
|
/* unicast address */
|
||||||
destAddress = new byte[16];
|
destAddress = new byte[16];
|
||||||
System.arraycopy(context, 0, destAddress, 0, 8);
|
System.arraycopy(context, 0, destAddress, 0, 8);
|
||||||
/* infer IID from L2 address */
|
/* infer IID from L2 address */
|
||||||
System.arraycopy(packet.llreceiver, 0, destAddress,
|
System.arraycopy(packet.llreceiver, 0, destAddress,
|
||||||
16 - packet.llreceiver.length, packet.llreceiver.length);
|
16 - packet.llreceiver.length, packet.llreceiver.length);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* not context based => link local M = 0, DAC = 0 - same as SAC */
|
/* not context based => link local M = 0, DAC = 0 - same as SAC */
|
||||||
switch (packet.get(1) & SICSLOWPAN_IPHC_DAM_11) {
|
switch (packet.get(1) & SICSLOWPAN_IPHC_DAM_11) {
|
||||||
case SICSLOWPAN_IPHC_DAM_00: /* 128 bits */
|
case SICSLOWPAN_IPHC_DAM_00: /* 128 bits */
|
||||||
destAddress = new byte[16];
|
destAddress = new byte[16];
|
||||||
packet.copy(hc06_ptr, destAddress, 0, 16);
|
packet.copy(hc06_ptr, destAddress, 0, 16);
|
||||||
hc06_ptr += 16;
|
hc06_ptr += 16;
|
||||||
break;
|
break;
|
||||||
case SICSLOWPAN_IPHC_DAM_01: /* 64 bits */
|
case SICSLOWPAN_IPHC_DAM_01: /* 64 bits */
|
||||||
destAddress = new byte[16];
|
destAddress = new byte[16];
|
||||||
destAddress[0] = (byte) 0xfe;
|
destAddress[0] = (byte) 0xfe;
|
||||||
destAddress[1] = (byte) 0x80;
|
destAddress[1] = (byte) 0x80;
|
||||||
packet.copy(hc06_ptr, destAddress, 8, 8);
|
packet.copy(hc06_ptr, destAddress, 8, 8);
|
||||||
hc06_ptr += 8;
|
hc06_ptr += 8;
|
||||||
break;
|
break;
|
||||||
case SICSLOWPAN_IPHC_DAM_10: /* 16 bits */
|
case SICSLOWPAN_IPHC_DAM_10: /* 16 bits */
|
||||||
destAddress = new byte[16];
|
destAddress = new byte[16];
|
||||||
destAddress[0] = (byte) 0xfe;
|
destAddress[0] = (byte) 0xfe;
|
||||||
destAddress[1] = (byte) 0x80;
|
destAddress[1] = (byte) 0x80;
|
||||||
packet.copy(hc06_ptr, destAddress, 14, 2);
|
packet.copy(hc06_ptr, destAddress, 14, 2);
|
||||||
hc06_ptr += 2;
|
hc06_ptr += 2;
|
||||||
break;
|
break;
|
||||||
case SICSLOWPAN_IPHC_DAM_11: /* 0 bits */
|
case SICSLOWPAN_IPHC_DAM_11: /* 0 bits */
|
||||||
destAddress = new byte[16];
|
destAddress = new byte[16];
|
||||||
destAddress[0] = (byte) 0xfe;
|
destAddress[0] = (byte) 0xfe;
|
||||||
destAddress[1] = (byte) 0x80;
|
destAddress[1] = (byte) 0x80;
|
||||||
System.arraycopy(packet.llreceiver, 0, destAddress,
|
System.arraycopy(packet.llreceiver, 0, destAddress,
|
||||||
16 - packet.llreceiver.length, packet.llreceiver.length);
|
16 - packet.llreceiver.length, packet.llreceiver.length);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Next header processing - continued */
|
/* Next header processing - continued */
|
||||||
if(nhc) {
|
if(nhc) {
|
||||||
/* TODO: check if this is correct in hc-06 */
|
/* TODO: check if this is correct in hc-06 */
|
||||||
/* The next header is compressed, NHC is following */
|
/* The next header is compressed, NHC is following */
|
||||||
if((packet.get(hc06_ptr) & SICSLOWPAN_NDC_UDP_MASK) == SICSLOWPAN_NHC_UDP_ID) {
|
if((packet.get(hc06_ptr) & SICSLOWPAN_NDC_UDP_MASK) == SICSLOWPAN_NHC_UDP_ID) {
|
||||||
proto = PROTO_UDP;
|
proto = PROTO_UDP;
|
||||||
switch(packet.get(hc06_ptr)) {
|
switch(packet.get(hc06_ptr)) {
|
||||||
case (byte) SICSLOWPAN_NHC_UDP_C:
|
case (byte) SICSLOWPAN_NHC_UDP_C:
|
||||||
/* 1 byte for NHC, 1 byte for ports, 2 bytes chksum */
|
/* 1 byte for NHC, 1 byte for ports, 2 bytes chksum */
|
||||||
srcPort = SICSLOWPAN_UDP_PORT_MIN + (packet.get(hc06_ptr + 1) >> 4);
|
srcPort = SICSLOWPAN_UDP_PORT_MIN + (packet.get(hc06_ptr + 1) >> 4);
|
||||||
destPort = SICSLOWPAN_UDP_PORT_MIN + (packet.get(hc06_ptr + 1) & 0x0F);
|
destPort = SICSLOWPAN_UDP_PORT_MIN + (packet.get(hc06_ptr + 1) & 0x0F);
|
||||||
// memcpy(&SICSLOWPAN_UDP_BUF->udpchksum, hc06_ptr + 2, 2);
|
// memcpy(&SICSLOWPAN_UDP_BUF->udpchksum, hc06_ptr + 2, 2);
|
||||||
// PRINTF("IPHC: Uncompressed UDP ports (4): %x, %x\n",
|
// PRINTF("IPHC: Uncompressed UDP ports (4): %x, %x\n",
|
||||||
// SICSLOWPAN_UDP_BUF->srcport, SICSLOWPAN_UDP_BUF->destport);
|
// SICSLOWPAN_UDP_BUF->srcport, SICSLOWPAN_UDP_BUF->destport);
|
||||||
hc06_ptr += 4;
|
hc06_ptr += 4;
|
||||||
break;
|
break;
|
||||||
case (byte) SICSLOWPAN_NHC_UDP_I:
|
case (byte) SICSLOWPAN_NHC_UDP_I:
|
||||||
/* 1 byte for NHC, 4 byte for ports, 2 bytes chksum */
|
/* 1 byte for NHC, 4 byte for ports, 2 bytes chksum */
|
||||||
srcPort = packet.getInt(hc06_ptr + 1, 2);
|
srcPort = packet.getInt(hc06_ptr + 1, 2);
|
||||||
destPort = packet.getInt(hc06_ptr + 3, 2);
|
destPort = packet.getInt(hc06_ptr + 3, 2);
|
||||||
// memcpy(&SICSLOWPAN_UDP_BUF->udpchksum, hc06_ptr + 5, 2);
|
// memcpy(&SICSLOWPAN_UDP_BUF->udpchksum, hc06_ptr + 5, 2);
|
||||||
// PRINTF("IPHC: Uncompressed UDP ports (7): %x, %x\n",
|
// PRINTF("IPHC: Uncompressed UDP ports (7): %x, %x\n",
|
||||||
// SICSLOWPAN_UDP_BUF->srcport, SICSLOWPAN_UDP_BUF->destport);
|
// SICSLOWPAN_UDP_BUF->srcport, SICSLOWPAN_UDP_BUF->destport);
|
||||||
|
|
||||||
hc06_ptr += 7;
|
hc06_ptr += 7;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// PRINTF("sicslowpan uncompress_hdr: error unsupported UDP compression\n");
|
// PRINTF("sicslowpan uncompress_hdr: error unsupported UDP compression\n");
|
||||||
return ANALYSIS_FAILED;
|
return ANALYSIS_FAILED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
packet.pos += hc06_ptr;
|
packet.pos += hc06_ptr;
|
||||||
|
|
||||||
// /* IP length field. */
|
// /* IP length field. */
|
||||||
// if(ip_len == 0) {
|
// if(ip_len == 0) {
|
||||||
// /* This is not a fragmented packet */
|
// /* This is not a fragmented packet */
|
||||||
// SICSLOWPAN_IP_BUF->len[0] = 0;
|
// SICSLOWPAN_IP_BUF->len[0] = 0;
|
||||||
// SICSLOWPAN_IP_BUF->len[1] = packetbuf_datalen() - rime_hdr_len + uncomp_hdr_len - UIP_IPH_LEN;
|
// SICSLOWPAN_IP_BUF->len[1] = packetbuf_datalen() - rime_hdr_len + uncomp_hdr_len - UIP_IPH_LEN;
|
||||||
// } else {
|
// } else {
|
||||||
// /* This is a 1st fragment */
|
// /* This is a 1st fragment */
|
||||||
// SICSLOWPAN_IP_BUF->len[0] = (ip_len - UIP_IPH_LEN) >> 8;
|
// SICSLOWPAN_IP_BUF->len[0] = (ip_len - UIP_IPH_LEN) >> 8;
|
||||||
// SICSLOWPAN_IP_BUF->len[1] = (ip_len - UIP_IPH_LEN) & 0x00FF;
|
// SICSLOWPAN_IP_BUF->len[1] = (ip_len - UIP_IPH_LEN) & 0x00FF;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// /* length field in UDP header */
|
// /* length field in UDP header */
|
||||||
// if(SICSLOWPAN_IP_BUF->proto == UIP_PROTO_UDP) {
|
// if(SICSLOWPAN_IP_BUF->proto == UIP_PROTO_UDP) {
|
||||||
// memcpy(&SICSLOWPAN_UDP_BUF->udplen, ipBuf + len[0], 2);
|
// memcpy(&SICSLOWPAN_UDP_BUF->udplen, ipBuf + len[0], 2);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
/*--------------------------------------------- */
|
/*--------------------------------------------- */
|
||||||
|
|
||||||
String protoStr = "" + proto;
|
String protoStr = "" + proto;
|
||||||
if (proto == PROTO_ICMP) {
|
if (proto == PROTO_ICMP) {
|
||||||
protoStr = "ICMPv6";
|
protoStr = "ICMPv6";
|
||||||
} else if (proto == PROTO_UDP) protoStr = "UDP";
|
} else if (proto == PROTO_UDP) protoStr = "UDP";
|
||||||
else if (proto == PROTO_TCP) protoStr = "TCP";
|
else if (proto == PROTO_TCP) protoStr = "TCP";
|
||||||
|
|
||||||
verbose.append("<br><b>IPv6 ").append(protoStr).append("</b><br>");
|
verbose.append("<br><b>IPv6 ").append(protoStr).append("</b><br>");
|
||||||
verbose.append("From ");
|
verbose.append("From ");
|
||||||
printAddress(verbose, srcAddress);
|
printAddress(verbose, srcAddress);
|
||||||
verbose.append(" to ");
|
verbose.append(" to ");
|
||||||
printAddress(verbose, destAddress);
|
printAddress(verbose, destAddress);
|
||||||
|
|
||||||
packet.lastDispatch = (byte) (proto & 0xff);
|
packet.lastDispatch = (byte) (proto & 0xff);
|
||||||
packet.level = NETWORK_LEVEL;
|
packet.level = NETWORK_LEVEL;
|
||||||
return ANALYSIS_OK_CONTINUE;
|
return ANALYSIS_OK_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void printAddress(StringBuffer out, byte[] address) {
|
public static void printAddress(StringBuffer out, byte[] address) {
|
||||||
for (int i = 0; i < 16; i+=2) {
|
for (int i = 0; i < 16; i+=2) {
|
||||||
out.append(StringUtils.toHex((byte) (address[i] & 0xff)) +
|
out.append(StringUtils.toHex((byte) (address[i] & 0xff)) +
|
||||||
StringUtils.toHex((byte) (address[i + 1] & 0xff)));
|
StringUtils.toHex((byte) (address[i + 1] & 0xff)));
|
||||||
if (i < 14) {
|
if (i < 14) {
|
||||||
out.append(":");
|
out.append(":");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue