Minor cleanup of the radio logger output (packet description).

This commit is contained in:
nifi 2010-04-06 23:38:18 +00:00
parent ac4ba199bc
commit 6d9f904627
3 changed files with 523 additions and 519 deletions

View file

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* 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;
@ -266,6 +266,7 @@ public class RadioLogger extends VisPlugin {
prepareTooltipString(conn);
}
verboseBox.setText(conn.tooltip);
verboseBox.setCaretPosition(0);
}
}
});
@ -427,12 +428,16 @@ public class RadioLogger extends VisPlugin {
if (packet.hasMoreData()) {
byte[] payload = packet.getPayload();
brief.append(StringUtils.toHex(payload, 4));
if (verbose.length() > 0) {
verbose.append("<p>");
}
verbose.append("<b>Payload (")
.append(payload.length).append(" bytes)</b><br><pre>")
.append(StringUtils.hexDump(payload))
.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) {
conn.tooltip = verbose.toString();
}
@ -450,16 +455,16 @@ public class RadioLogger extends VisPlugin {
PacketAnalyzer analyzer = analyzers.get(i);
if (analyzer.matchPacket(packet)) {
int res = analyzer.analyzePacket(packet, brief, verbose);
if (packet.hasMoreData() && brief.length() > 0) {
brief.append('|');
verbose.append("<br>");
}
if (res != PacketAnalyzer.ANALYSIS_OK_CONTINUE) {
/* this was the final or the analysis failed - no analyzable payload possible here... */
return brief.length() > 0;
}
/* continue another round if more bytes left */
analyze = packet.hasMoreData();
if (analyze) {
brief.append('|');
verbose.append("<p>");
}
break;
}
}

View file

@ -42,34 +42,33 @@ public class ICMPv6Analyzer extends PacketAnalyzer {
StringBuffer verbose) {
int type = packet.get(0) & 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 ");
if (type >= 128 && (type - 128) < TYPE_NAME.length) {
brief.append(TYPE_NAME[type - 128]).append(" ");
brief.append(" " + code);
verbose.append("Type: " + TYPE_NAME[type - 128]).append("<br>");
verbose.append("Code:" + code + "<br>");
brief.append(TYPE_NAME[type - 128]).append(' ').append(code);
verbose.append("Type: ").append(TYPE_NAME[type - 128]);
verbose.append(" Code:").append(code);
} else if (type == 155) {
/* RPL */
brief.append("RPL ");
verbose.append("Type: RPL<br>");
verbose.append("Type: RPL Code: ");
switch(code) {
case RPL_CODE_DIS:
brief.append("DIS ");
verbose.append("Code: DIS<br>");
brief.append("DIS");
verbose.append("DIS");
break;
case RPL_CODE_DIO:
brief.append("DIO ");
verbose.append("Code: DIO<br>");
brief.append("DIO");
verbose.append("DIO");
break;
case RPL_CODE_DAO:
brief.append("DAO ");
verbose.append("Code: DAO<br>");
brief.append("DAO");
verbose.append("DAO");
break;
default:
brief.append(" " + code);
verbose.append("Code: " + code);
brief.append(code);
verbose.append(code);
}
}

View file

@ -90,10 +90,10 @@ public class IPHCPacketAnalyzer extends PacketAnalyzer {
verbose.append("<b>IPHC HC-06</b><br>");
verbose.append("tf = " + tf + " nhc = " + nhc + " hlim = " + hlim
+ " cid = " + cid + " sac = " + sac + " sam = " + sam
+ " MCast = " + m + " dac = " + dac + " dam = " + dam + "<br>");
+ " MCast = " + m + " dac = " + dac + " dam = " + dam);
if (cid == 1) {
verbose.append("Contexts: sci=" + (packet.get(2) >> 4) + " dci="
+ (packet.get(2) & 0x0f) + "<br>");
verbose.append("<br>Contexts: sci=" + (packet.get(2) >> 4) + " dci="
+ (packet.get(2) & 0x0f));
sci = packet.get(2) >> 4;
dci = packet.get(2) & 0x0f;
}