From efaf089f597a41beccae1ad1b61df29d1548a7fd Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Mon, 13 Jul 2015 18:57:57 +0200 Subject: Move dump into package --- parse/parse.go | 45 +++------------------------------------------ 1 file changed, 3 insertions(+), 42 deletions(-) (limited to 'parse/parse.go') diff --git a/parse/parse.go b/parse/parse.go index f921a8b..ec137cf 100644 --- a/parse/parse.go +++ b/parse/parse.go @@ -1,54 +1,15 @@ package main import ( - "dim13.org/asn1/ber" "fmt" -) - -func dump(b []byte, indent int) { - class, kind, tag, _, value, rest := ber.Split(b) - - for i := indent; i > 0; i-- { - fmt.Print("\t") - } - - switch class { - case ber.Universal: - switch tag { - case ber.Integer: - fmt.Println(tag, ber.UnmarshalInt(value)) - case ber.ObjectIdentifier: - fmt.Println(tag, ber.UnmarshalOID(value)) - case ber.BitString: - fmt.Println(tag, ber.UnmarshalBitString(value), value) - default: - if len(value) > 5 { - fmt.Println(tag, kind, value[:5], "...") - } else { - fmt.Println(tag, kind, value) - } - } - default: - if len(value) > 5 { - fmt.Println(class, kind, byte(tag), value[:5], "...") - } else { - fmt.Println(class, kind, byte(tag), value) - } - } - if len(value) > 0 && kind != ber.Primitive { - dump(value, indent+1) - } - - if len(rest) > 0 { - dump(rest, indent) - } -} + "dim13.org/asn1/ber" +) func main() { for n, s := range session { fmt.Println(">>> packet", n) - dump(s, 0) + ber.Dump(s) fmt.Println("") } } -- cgit v1.2.3