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

Update embed with mibs dir #38

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
6 changes: 3 additions & 3 deletions cmd/embed/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import (
"flag"
"os"

"github.com/sleepinggenius2/gosmi"
"github.com/min-oc/gosmi"
)

//go:embed FIZBIN-MIB.mib
//go:embed mibs
var fs embed.FS

func main() {
Expand All @@ -18,7 +18,7 @@ func main() {

gosmi.Init()

gosmi.SetFS(gosmi.NamedFS("Embed Example", fs))
gosmi.SetFS(gosmi.NamedFS("mibs", fs))

m, err := gosmi.GetModule(*module)
if err != nil {
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion cmd/parse/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"os"

"github.com/alecthomas/repr"
"github.com/sleepinggenius2/gosmi/parser"
"github.com/min-oc/gosmi/parser"
)

func main() {
Expand Down
4 changes: 2 additions & 2 deletions cmd/smi/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"os"
"strings"

"github.com/sleepinggenius2/gosmi"
"github.com/sleepinggenius2/gosmi/types"
"github.com/min-oc/gosmi"
"github.com/min-oc/gosmi/types"
)

type arrayStrings []string
Expand Down
2 changes: 1 addition & 1 deletion config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package gosmi
import (
"os"

"github.com/sleepinggenius2/gosmi/smi"
"github.com/min-oc/gosmi/smi"
)

func Init() {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/sleepinggenius2/gosmi
module github.com/min-oc/gosmi

go 1.16

Expand Down
2 changes: 1 addition & 1 deletion models/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strconv"
"time"

"github.com/sleepinggenius2/gosmi/types"
"github.com/min-oc/gosmi/types"
)

type Format byte
Expand Down
2 changes: 1 addition & 1 deletion models/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package models
import (
"time"

"github.com/sleepinggenius2/gosmi/types"
"github.com/min-oc/gosmi/types"
)

type Import struct {
Expand Down
2 changes: 1 addition & 1 deletion models/node.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package models

import (
"github.com/sleepinggenius2/gosmi/types"
"github.com/min-oc/gosmi/types"
)

type Node struct {
Expand Down
2 changes: 1 addition & 1 deletion models/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"errors"
"fmt"

"github.com/sleepinggenius2/gosmi/types"
"github.com/min-oc/gosmi/types"
)

type BaseNode struct {
Expand Down
2 changes: 1 addition & 1 deletion models/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"sync"

"github.com/sleepinggenius2/gosmi/types"
"github.com/min-oc/gosmi/types"
)

type Enum struct {
Expand Down
6 changes: 3 additions & 3 deletions module.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package gosmi
import (
"fmt"

"github.com/sleepinggenius2/gosmi/models"
"github.com/sleepinggenius2/gosmi/smi"
"github.com/sleepinggenius2/gosmi/types"
"github.com/min-oc/gosmi/models"
"github.com/min-oc/gosmi/smi"
"github.com/min-oc/gosmi/types"
)

type SmiModule struct {
Expand Down
6 changes: 3 additions & 3 deletions node.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package gosmi
import (
"fmt"

"github.com/sleepinggenius2/gosmi/models"
"github.com/sleepinggenius2/gosmi/smi"
"github.com/sleepinggenius2/gosmi/types"
"github.com/min-oc/gosmi/models"
"github.com/min-oc/gosmi/smi"
"github.com/min-oc/gosmi/types"
)

type SmiNode struct {
Expand Down
2 changes: 1 addition & 1 deletion notification.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package gosmi

import (
"github.com/sleepinggenius2/gosmi/smi"
"github.com/min-oc/gosmi/smi"
)

type Notification struct {
Expand Down
2 changes: 1 addition & 1 deletion parser/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

"github.com/alecthomas/participle/lexer"

"github.com/sleepinggenius2/gosmi/types"
"github.com/min-oc/gosmi/types"
)

type SubIdentifier struct {
Expand Down
2 changes: 1 addition & 1 deletion parser/compliance.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package parser
import (
"github.com/alecthomas/participle/lexer"

"github.com/sleepinggenius2/gosmi/types"
"github.com/min-oc/gosmi/types"
)

type AgentCapabilityVariation struct {
Expand Down
2 changes: 1 addition & 1 deletion parser/macro.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

"github.com/alecthomas/participle/lexer"

"github.com/sleepinggenius2/gosmi/types"
"github.com/min-oc/gosmi/types"
)

type MacroBody struct {
Expand Down
2 changes: 1 addition & 1 deletion parser/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

"github.com/alecthomas/participle/lexer"

"github.com/sleepinggenius2/gosmi/types"
"github.com/min-oc/gosmi/types"
)

type Date string
Expand Down
2 changes: 1 addition & 1 deletion parser/notification.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package parser
import (
"github.com/alecthomas/participle/lexer"

"github.com/sleepinggenius2/gosmi/types"
"github.com/min-oc/gosmi/types"
)

type NotificationGroup struct {
Expand Down
2 changes: 1 addition & 1 deletion parser/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package parser
import (
"github.com/alecthomas/participle/lexer"

"github.com/sleepinggenius2/gosmi/types"
"github.com/min-oc/gosmi/types"
)

type ObjectGroup struct {
Expand Down
2 changes: 1 addition & 1 deletion parser/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package parser
import (
"github.com/alecthomas/participle/lexer"

"github.com/sleepinggenius2/gosmi/types"
"github.com/min-oc/gosmi/types"
)

type TextualConvention struct {
Expand Down
6 changes: 3 additions & 3 deletions smi/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"runtime"
"strings"

"github.com/sleepinggenius2/gosmi/smi/internal"
"github.com/sleepinggenius2/gosmi/types"
"github.com/min-oc/gosmi/smi/internal"
"github.com/min-oc/gosmi/types"
)

const (
Expand All @@ -29,7 +29,7 @@ var DefaultSmiPaths []string = []string{
type FS = internal.FS
type NamedFS = internal.NamedFS

func NewNamedFS(name string, fs FS) NamedFS { return NamedFS{Name: "[" + name + "]", FS: fs} }
func NewNamedFS(name string, fs FS) NamedFS { return NamedFS{Name: name, FS: fs} }

func checkInit() {
if !internal.Initialized() {
Expand Down
4 changes: 2 additions & 2 deletions smi/internal/handle.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package internal

import (
"github.com/sleepinggenius2/gosmi/parser"
"github.com/sleepinggenius2/gosmi/types"
"github.com/min-oc/gosmi/parser"
"github.com/min-oc/gosmi/types"
)

const WellKnownModuleName types.SmiIdentifier = "<well-known>"
Expand Down
2 changes: 1 addition & 1 deletion smi/internal/import.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package internal

import (
"github.com/sleepinggenius2/gosmi/types"
"github.com/min-oc/gosmi/types"
)

var importConversions map[types.SmiImport]types.SmiImport = map[types.SmiImport]types.SmiImport{
Expand Down
2 changes: 1 addition & 1 deletion smi/internal/macro.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package internal

import (
"github.com/sleepinggenius2/gosmi/types"
"github.com/min-oc/gosmi/types"
)

type Macro struct {
Expand Down
19 changes: 14 additions & 5 deletions smi/internal/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ import (
"os"
"path/filepath"
"strings"
"sync"
"time"

"github.com/sleepinggenius2/gosmi/parser"
"github.com/sleepinggenius2/gosmi/types"
"github.com/min-oc/gosmi/parser"
"github.com/min-oc/gosmi/types"
)

type Module struct {
Expand Down Expand Up @@ -173,6 +174,7 @@ func (x *Module) getTrapTypePlaceholder(enterprise types.SmiIdentifier, line int
}

type ModuleMap struct {
sync.RWMutex
First *Module

last *Module
Expand All @@ -181,6 +183,8 @@ type ModuleMap struct {
}

func (x *ModuleMap) Add(m *Module) {
x.Lock()
defer x.Unlock()
if m.IsWellKnown() {
x.wellKnown = m
}
Expand All @@ -199,6 +203,8 @@ func (x *ModuleMap) Add(m *Module) {
}

func (x *ModuleMap) Get(name types.SmiIdentifier) *Module {
x.RLock()
defer x.RUnlock()
if name == WellKnownModuleName {
return x.wellKnown
}
Expand Down Expand Up @@ -303,7 +309,10 @@ func GetModuleFile(name string) (string, io.ReadCloser, error) {
}

for _, path := range smiHandle.Paths {
dirEntries, err := path.FS.ReadDir(".")
if filepath.IsAbs(path.Name) {
path.Name = ""
}
dirEntries, err := path.FS.ReadDir(path.Name)
if err != nil {
return path.Name, nil, fmt.Errorf("Read directory: %w", err)
}
Expand All @@ -321,8 +330,8 @@ func GetModuleFile(name string) (string, io.ReadCloser, error) {
}
switch ext {
case "", "mib", "my", "mi2", "txt":
fullpath := filepath.Join(path.Name, dirEntry.Name())
r, err := path.FS.Open(dirEntry.Name())
fullpath := path.Name + "/" + dirEntry.Name()
r, err := path.FS.Open(fullpath)
if err != nil {
return fullpath, nil, fmt.Errorf("Open file: %w", err)
}
Expand Down
10 changes: 9 additions & 1 deletion smi/internal/node.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package internal

import (
"github.com/sleepinggenius2/gosmi/types"
"sync"

"github.com/min-oc/gosmi/types"
)

type Node struct {
Expand Down Expand Up @@ -33,20 +35,24 @@ func (x *Node) IsRoot() bool {
}

type NodeChildMap struct {
sync.RWMutex
First *Node

last *Node
m map[types.SmiSubId]*Node
}

func (x *NodeChildMap) Add(n *Node) {

existing := x.Get(n.SubId)
if existing != nil {
for obj := n.FirstObject; obj != nil; obj = obj.NextSameNode {
existing.AddObject(obj)
}
return
}
x.Lock()
defer x.Unlock()
if n.Parent != nil && n.Parent.Oid != nil {
n.Oid = types.NewOid(n.Parent.Oid, n.SubId)
n.OidLen = n.Parent.OidLen + 1
Expand Down Expand Up @@ -82,6 +88,8 @@ func (x *NodeChildMap) Add(n *Node) {
}

func (x *NodeChildMap) Get(id types.SmiSubId) *Node {
x.RLock()
defer x.RUnlock()
if x.m == nil {
return nil
}
Expand Down
4 changes: 2 additions & 2 deletions smi/internal/object.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package internal

import (
"github.com/sleepinggenius2/gosmi/parser"
"github.com/sleepinggenius2/gosmi/types"
"github.com/min-oc/gosmi/parser"
"github.com/min-oc/gosmi/types"
)

type Option struct {
Expand Down
4 changes: 2 additions & 2 deletions smi/internal/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"sort"
"strconv"

"github.com/sleepinggenius2/gosmi/parser"
"github.com/sleepinggenius2/gosmi/types"
"github.com/min-oc/gosmi/parser"
"github.com/min-oc/gosmi/types"
)

type Type struct {
Expand Down
2 changes: 1 addition & 1 deletion smi/internal/types.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package internal

import (
"github.com/sleepinggenius2/gosmi/types"
"github.com/min-oc/gosmi/types"
)

type List struct {
Expand Down
4 changes: 2 additions & 2 deletions smi/macro.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package smi
import (
"unsafe"

"github.com/sleepinggenius2/gosmi/smi/internal"
"github.com/sleepinggenius2/gosmi/types"
"github.com/min-oc/gosmi/smi/internal"
"github.com/min-oc/gosmi/types"
)

// SmiMacro *smiGetMacro(SmiModule *smiModulePtr, char *macro)
Expand Down
Loading