aboutsummaryrefslogtreecommitdiff
path: root/ber
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-09-26 01:12:56 +0200
committerDimitri Sokolyuk <demon@dim13.org>2015-09-26 01:12:56 +0200
commit5af0f05f46a87c088123dc8a3f099cd393270e1e (patch)
tree9d4dd4d136f65495b5e4d140ecb830d9dc2b7a03 /ber
parent0f6b658abb865dd6f95efc6b4fe5d05d849c332b (diff)
Geting closer
Diffstat (limited to 'ber')
-rw-r--r--ber/new/common.go3
-rw-r--r--ber/new/dump.go29
2 files changed, 27 insertions, 5 deletions
diff --git a/ber/new/common.go b/ber/new/common.go
index feb257e..b5884ae 100644
--- a/ber/new/common.go
+++ b/ber/new/common.go
@@ -21,7 +21,8 @@ func (s *state) subState() *state {
}
func (s *state) next() []byte {
- return s.Next(s.unmarshalLen())
+ l := s.unmarshalLen()
+ return s.Next(l)
}
type OID []int
diff --git a/ber/new/dump.go b/ber/new/dump.go
index 787ba11..9fc206e 100644
--- a/ber/new/dump.go
+++ b/ber/new/dump.go
@@ -12,9 +12,30 @@ func (s *state) dump(indent int) string {
if s.Len() == 0 {
return ""
}
- fmt.Println(s.Len(), s.Bytes())
- h := s.ident()
- fmt.Printf("%*s%v\n", 2*indent, "", h)
- s.subState().dump(indent + 1)
+ //fmt.Printf("%*s%x %x\n", 2*indent, "", s.Len(), s.Bytes())
+ for s.Len() > 0 {
+ h := s.ident()
+ fmt.Printf("%*s%v: ", 2*indent, "", h)
+ if h.Class == classUniversal && h.Kind == kindPrimitive {
+ switch h.Tag {
+ case tagInteger, tagEnumerated:
+ fmt.Println(s.unmarshalInt())
+ case tagBoolean:
+ fmt.Println(s.unmarshalBool())
+ case tagObjectIdentifier:
+ fmt.Println(s.unmarshalOID())
+ case tagBitString:
+ fmt.Println(s.unmarshalBitString())
+ case tagIA5String, tagOctetString:
+ fmt.Println(s.unmarshalString())
+ default:
+ fmt.Println("")
+ s.next()
+ }
+ } else {
+ fmt.Println("")
+ s.subState().dump(indent + 1)
+ }
+ }
return s.dump(indent)
}