diff --git a/ber.go b/ber.go index 016b153..73efde5 100644 --- a/ber.go +++ b/ber.go @@ -28,7 +28,7 @@ import ( ) // BERType constants for the Type of the TLV field. -type BERType uint8 +type BERType uint16 // Constants for the different types of the TLV fields. const ( @@ -153,7 +153,7 @@ func DecodeLength(toparse []byte) (int, int, error) { // DecodeCounter64 decodes a counter64. func DecodeCounter64(toparse []byte) (uint64, error) { - if len(toparse) > 8 { + if len(toparse) > 16 { return 0, fmt.Errorf("don't support more than 64 bits") } var val uint64 @@ -166,7 +166,7 @@ func DecodeCounter64(toparse []byte) (uint64, error) { // DecodeInteger decodes an integer. Will error out if it's longer than 64 bits. func DecodeInteger(toparse []byte) (int, error) { - if len(toparse) > 8 { + if len(toparse) > 16 { return 0, fmt.Errorf("don't support more than 64 bits") } val := 0 @@ -178,7 +178,7 @@ func DecodeInteger(toparse []byte) (int, error) { // DecodeIntegerSigned decodes a signed integer. Will error out if it's longer than 64 bits. func DecodeIntegerSigned(toparse []byte) (int, error) { - if len(toparse) > 8 { + if len(toparse) > 16 { return 0, fmt.Errorf("don't support more than 64 bits") } val := 0 @@ -207,6 +207,7 @@ func EncodeInteger(toEncode int) []byte { if toEncode == 0 { return []byte{0} } + //bura result := make([]byte, 8) pos := 7 i := toEncode diff --git a/oid.go b/oid.go index 91efb3b..a456a09 100644 --- a/oid.go +++ b/oid.go @@ -11,11 +11,14 @@ import ( "math" "strconv" "strings" + ) // The SNMP object identifier type. type Oid []int + +//test // String returns the string representation for this oid object. func (o Oid) String() string { /* A zero-length Oid has to be valid as it's often used as the start of a @@ -49,9 +52,11 @@ func ParseOid(oid string) (Oid, error) { oid = oid[1:] } oidParts := strings.Split(oid, ".") + parsedVal, err := strconv.ParseInt(val) res := make([]int, len(oidParts)) for idx, val := range oidParts { parsedVal, err := strconv.Atoi(val) + //parsedVal, err := binary.BigEndian.Uint64(val) if err != nil { return nil, err }