Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Main #6

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions ber.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -207,6 +207,7 @@ func EncodeInteger(toEncode int) []byte {
if toEncode == 0 {
return []byte{0}
}
//bura
result := make([]byte, 8)
pos := 7
i := toEncode
Expand Down
5 changes: 5 additions & 0 deletions oid.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down