summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2019-09-02 17:03:11 +0200
committerJustus Winter <justus@sequoia-pgp.org>2019-09-02 17:03:11 +0200
commitcf0c186e5b2b77865560e0ff68cd96f60b7edfc9 (patch)
tree73733acc1ee5a4a4d904add0ce790b77859bbfaa
parent88a4babae6ffe69a954fa745436653379f7713cc (diff)
tool: Hexdump packet bodies.
-rw-r--r--tool/src/commands/dump.rs25
1 files changed, 23 insertions, 2 deletions
diff --git a/tool/src/commands/dump.rs b/tool/src/commands/dump.rs
index 579b9ad7..e88851ea 100644
--- a/tool/src/commands/dump.rs
+++ b/tool/src/commands/dump.rs
@@ -651,11 +651,32 @@ impl PacketDumper {
if let Some(map) = map {
writeln!(output, "{}", i)?;
let mut hd = hex::Dumper::new(output, self.indentation_for_hexdump(
- i, map.iter().map(|f| f.name.len()).max()
+ i, map.iter()
+ .map(|f| if f.name == "body" { 16 } else { f.name.len() })
+ .max()
.expect("we always have one entry")));
for field in map.iter() {
- hd.write(field.data, field.name)?;
+ if field.name == "body" {
+ hd.write_labeled(field.data, |offset, data| {
+ let mut l = String::new();
+ for _ in 0..offset {
+ l.push(' ');
+ }
+ for &c in data {
+ l.push(if c < 32 {
+ '.'
+ } else if c < 128 {
+ c.into()
+ } else {
+ '.'
+ })
+ }
+ Some(l)
+ })?;
+ } else {
+ hd.write(field.data, field.name)?;
+ }
}
let output = hd.into_inner();