From ed97339bd2c0ce6875987d0dbd1086894a43a169 Mon Sep 17 00:00:00 2001 From: ibrahimtopbasi Date: Tue, 17 Oct 2023 15:41:53 +0300 Subject: [PATCH 1/6] Update oid.go --- oid.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/oid.go b/oid.go index 91efb3b..b6af2b3 100644 --- a/oid.go +++ b/oid.go @@ -51,7 +51,8 @@ func ParseOid(oid string) (Oid, error) { oidParts := strings.Split(oid, ".") res := make([]int, len(oidParts)) for idx, val := range oidParts { - parsedVal, err := strconv.Atoi(val) + //parsedVal, err := strconv.Atoi(val) + parsedVal, err := binary.BigEndian.Uint64(val) if err != nil { return nil, err } From 0dc9a8830b6bcdf0c86d33b8d309ba25887f7ceb Mon Sep 17 00:00:00 2001 From: ibrahimtopbasi Date: Tue, 17 Oct 2023 15:47:10 +0300 Subject: [PATCH 2/6] Update oid.go --- oid.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/oid.go b/oid.go index b6af2b3..b6b66ef 100644 --- a/oid.go +++ b/oid.go @@ -11,6 +11,8 @@ import ( "math" "strconv" "strings" + "encoding/binary" + ) // The SNMP object identifier type. From 7f5131fe75c56e741effb6804621aaf2c9ce6f70 Mon Sep 17 00:00:00 2001 From: ibrahimtopbasi Date: Tue, 17 Oct 2023 15:51:20 +0300 Subject: [PATCH 3/6] Update oid.go --- oid.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/oid.go b/oid.go index b6b66ef..d6da626 100644 --- a/oid.go +++ b/oid.go @@ -11,7 +11,6 @@ import ( "math" "strconv" "strings" - "encoding/binary" ) @@ -53,8 +52,8 @@ func ParseOid(oid string) (Oid, error) { oidParts := strings.Split(oid, ".") res := make([]int, len(oidParts)) for idx, val := range oidParts { - //parsedVal, err := strconv.Atoi(val) - parsedVal, err := binary.BigEndian.Uint64(val) + parsedVal, err := strconv.Atoi(val) + //parsedVal, err := binary.BigEndian.Uint64(val) if err != nil { return nil, err } From 8dca4343357239dec2269b689633cafebab1119b Mon Sep 17 00:00:00 2001 From: ibrahimtopbasi Date: Tue, 17 Oct 2023 15:54:37 +0300 Subject: [PATCH 4/6] Update oid.go --- oid.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/oid.go b/oid.go index d6da626..5f68b4d 100644 --- a/oid.go +++ b/oid.go @@ -17,6 +17,8 @@ import ( // 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 From d5a771cd7d84ec419f126c89065c7d2ac8bc7198 Mon Sep 17 00:00:00 2001 From: ibrahimtopbasi Date: Tue, 17 Oct 2023 17:21:39 +0300 Subject: [PATCH 5/6] Update oid.go --- oid.go | 1 + 1 file changed, 1 insertion(+) diff --git a/oid.go b/oid.go index 5f68b4d..a456a09 100644 --- a/oid.go +++ b/oid.go @@ -52,6 +52,7 @@ 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) From 264980f194663277cd8ea66c70576eef5545ff22 Mon Sep 17 00:00:00 2001 From: ibrahimtopbasi Date: Tue, 17 Oct 2023 18:09:49 +0300 Subject: [PATCH 6/6] aad --- ber.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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