[cooja] plugins/analyzers/ICMPv6Analyzer: Short names for ICMP types in brief output and more reader-friendly long names

This commit is contained in:
Enrico Joerns 2014-06-19 04:33:44 +02:00
parent ab0be0b150
commit 70a44031bf

View file

@ -32,11 +32,18 @@ public class ICMPv6Analyzer extends PacketAnalyzer {
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 static final String[] BRIEF_TYPE_NAME = new String[]{
"ECHO REQ", "ECHO RPLY",
"GRP QUERY", "GRP REPORT", "GRP REDUCTION",
"RS", "RA",
"NS", "NA", "REDIRECT",
"ROUTER RENUMBER", "NODE INFO QUERY", "NODE INFO RESP"};
@Override @Override
public int analyzePacket(Packet packet, StringBuilder brief, public int analyzePacket(Packet packet, StringBuilder brief,
@ -47,13 +54,13 @@ public class ICMPv6Analyzer extends PacketAnalyzer {
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(' ').append(code); brief.append(BRIEF_TYPE_NAME[type - 128]).append(' ').append(code);
verbose.append("Type: ").append(TYPE_NAME[type - 128]); verbose.append("<br/>Type: ").append(TYPE_NAME[type - 128]);
verbose.append(" Code:").append(code); verbose.append(", Code:").append(code);
} else if (type == 155) { } else if (type == 155) {
/* RPL */ /* RPL */
brief.append("RPL "); brief.append("RPL ");
verbose.append("Type: RPL Code: "); verbose.append("<br/>Type: RPL Code: ");
switch (code) { switch (code) {
case RPL_CODE_DIS: case RPL_CODE_DIS:
brief.append("DIS"); brief.append("DIS");