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 --- ber/class.go | 146 +++++++++++++++++++++++++++--------------------------- ber/class_test.go | 2 +- 2 files changed, 74 insertions(+), 74 deletions(-) (limited to 'ber') diff --git a/ber/class.go b/ber/class.go index 0a98b80..92a5509 100644 --- a/ber/class.go +++ b/ber/class.go @@ -3,18 +3,18 @@ package ber type Class byte const ( - Universal Class = iota << 6 - Application - ContextSpecific - Private + classUniversal Class = iota << 6 + classApplication + classContextSpecific + classPrivate classMask Class = 3 << 6 ) var classNames = map[Class]string{ - Universal: "Universal", - Application: "Application", - ContextSpecific: "Context-specific", - Private: "Private", + classUniversal: "Universal", + classApplication: "Application", + classContextSpecific: "Context-specific", + classPrivate: "Private", } func (c Class) String() string { return classNames[c] } @@ -22,14 +22,14 @@ func (c Class) String() string { return classNames[c] } type Kind byte const ( - Primitive Kind = iota << 5 - Constructed + kindPrimitive Kind = iota << 5 + kindConstructed kindMask Kind = 1 << 5 ) var kindNames = map[Kind]string{ - Primitive: "Primitive", - Constructed: "Constructed", + kindPrimitive: "Primitive", + kindConstructed: "Constructed", } func (k Kind) String() string { return kindNames[k] } @@ -37,70 +37,70 @@ func (k Kind) String() string { return kindNames[k] } type Tag int const ( - EOT Tag = iota - Boolean - Integer - BitString - OctetString - Null - ObjectIdentifier - ObjectDescriptor - InstanceOf - Real - Enumerated - EmbeddedPDV - UTF8String - RelativeOID + tagEOT Tag = iota + tagBoolean + tagInteger + tagBitString + tagOctetString + tagNull + tagObjectIdentifier + tagObjectDescriptor + tagInstanceOf + tagReal + tagEnumerated + tagEmbeddedPDV + tagUTF8String + tagRelativeOID _ _ - Sequence // SequenceOf - Set // SetOf - NumericString - PrintableString - TeletexString // T61String - VideotexString - IA5String - UTCTime - GeneralizedTime - GraphicString - VisibleString // ISO646String - GeneralString - UniversalString - CharacterString - BMPString + tagSequence // SequenceOf + tagSet // SetOf + tagNumericString + tagPrintableString + tagTeletexString // T61String + tagVideotexString + tagIA5String + tagUTCTime + tagGeneralizedTime + tagGraphicString + tagVisibleString // ISO646String + tagGeneralString + tagUniversalString + tagCharacterString + tagBMPString tagMask Tag = (1 << 5) - 1 ) var tagNames = map[Tag]string{ - EOT: "End-of-Content", - Boolean: "Boolean", - Integer: "Integer", - BitString: "Bit String", - OctetString: "Octet String", - Null: "Null", - ObjectIdentifier: "Object Identifier", - ObjectDescriptor: "Object Descriptor", - InstanceOf: "Instance Of", - Real: "Real", - Enumerated: "Enumerated", - EmbeddedPDV: "Embedded PDV", - UTF8String: "UTF8 String", - RelativeOID: "Relative OID", - Sequence: "Sequence / Of", - Set: "Set / Of", - NumericString: "Numeric String", - PrintableString: "Printable String", - TeletexString: "Teletext String", - VideotexString: "Videotex String", - IA5String: "IA5 String", - UTCTime: "UTC Time", - GeneralizedTime: "Generalized Time", - GraphicString: "Graphic String", - VisibleString: "Visible String", - GeneralString: "General String", - UniversalString: "Universal String", - CharacterString: "Character String", - BMPString: "BMP String", + tagEOT: "End-of-Content", + tagBoolean: "Boolean", + tagInteger: "Integer", + tagBitString: "Bit String", + tagOctetString: "Octet String", + tagNull: "Null", + tagObjectIdentifier: "Object Identifier", + tagObjectDescriptor: "Object Descriptor", + tagInstanceOf: "Instance Of", + tagReal: "Real", + tagEnumerated: "Enumerated", + tagEmbeddedPDV: "Embedded PDV", + tagUTF8String: "UTF8 String", + tagRelativeOID: "Relative OID", + tagSequence: "Sequence / Of", + tagSet: "Set / Of", + tagNumericString: "Numeric String", + tagPrintableString: "Printable String", + tagTeletexString: "Teletext String", + tagVideotexString: "Videotex String", + tagIA5String: "IA5 String", + tagUTCTime: "UTC Time", + tagGeneralizedTime: "Generalized Time", + tagGraphicString: "Graphic String", + tagVisibleString: "Visible String", + tagGeneralString: "General String", + tagUniversalString: "Universal String", + tagCharacterString: "Character String", + tagBMPString: "BMP String", } func (t Tag) String() string { return tagNames[t] } @@ -118,10 +118,10 @@ func Ident(b []byte) (Class, Kind, Tag, int) { } func Length(b []byte) (int, int) { - if b[0] & 0x80 != 0 { + if b[0]&0x80 != 0 { l := int(b[0] & 0x7f) - i := unmarshalUint(b[1:l+1]) - return int(i), int(l+1) + i := unmarshalUint(b[1 : l+1]) + return int(i), int(l + 1) } else { return int(b[0]), 1 } diff --git a/ber/class_test.go b/ber/class_test.go index d56cd87..90fe1f8 100644 --- a/ber/class_test.go +++ b/ber/class_test.go @@ -11,7 +11,7 @@ var berTestData = []byte{ func ExampleIdent() { for _, test := range berTestData { c, k, t, _ := Ident([]byte{test}) - if c == Universal { + if c == classUniversal { fmt.Printf("%#x: %v %v %v\n", test, c, k, t) } else { -- cgit v1.2.3