nsdp

package module
v0.0.0-...-0840cd6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 24, 2022 License: MIT Imports: 11 Imported by: 0

README

NETGEAR Switch Discovery Protocol

This library implements the NETGEAR switch discovery protocol client

Supported Switches

LICENSE

MIT LICENSE

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSendRequestFailed    = errors.New("nsdp-scan: send request failed")
	ErrFailedToWaitResponse = errors.New("nsdp-scan: failed to wait response")
)

Functions

func AuthV2Password

func AuthV2Password(passphrase, mac, salt []byte) []byte

AuthV2Password based https://github.com/yaamai/go-nsdp/blob/d54b436f/nsdp/auth_v2.go modify

Types

type Callback

type Callback func(*Message)

type Client

type Client struct {
	NextSequence func() uint32
	// contains filtered or unexported fields
}

func NewClient

func NewClient(managerId net.HardwareAddr, localIP net.IP, version Version) (client *Client, err error)

func (*Client) Close

func (c *Client) Close() error

func (*Client) Header

func (c *Client) Header(command Command, agentID net.HardwareAddr) Header

func (*Client) Request

func (c *Client) Request(context context.Context, request *Message) (response *Message, err error)

func (*Client) Scan

func (c *Client) Scan(context context.Context, tags Tags, onCallback Callback) (err error)

Scan Design using method:

ctx, cancel := context.WithCancel(context.Background())
defer cancel()
messages := make(chan *nsdp.Message)
go client.Scan(ctx, nsdp.ScanTags(), messages)
for message := range messages {
    // your business
}

type Command

type Command uint8
const (
	CommandReadRequest   Command = 0x01
	CommandReadResponse  Command = 0x02
	CommandWriteRequest  Command = 0x03
	CommandWriteResponse Command = 0x04
)

func (Command) String

func (c Command) String() string

type DeviceClient

type DeviceClient struct {
	*Client
	AgentID  net.HardwareAddr
	Password []byte
}

func (*DeviceClient) Read

func (c *DeviceClient) Read(context context.Context, tags Tags) (*Message, error)

func (*DeviceClient) Set

func (c *DeviceClient) Set(context context.Context, tags Tags) (response *Message, err error)

func (*DeviceClient) Write

func (c *DeviceClient) Write(context context.Context, tags Tags) (*Message, error)
type Header struct {
	Version    byte
	Command    Command
	Status     uint16
	FailureTLV [4]byte
	ManagerID  [6]byte
	AgentID    [6]byte
	Sequence   uint32
	Signature  [4]byte
}

type Message

type Message struct {
	Header
	Tags Tags
}

func (*Message) ReadFrom

func (m *Message) ReadFrom(r io.Reader) (n int64, err error)

func (*Message) WriteTo

func (m *Message) WriteTo(w io.Writer) (n int64, err error)

type Tag

type Tag uint16

func (Tag) String

func (t Tag) String() string

type Tags

type Tags map[Tag][]byte

func ScanTags

func ScanTags() Tags

func (*Tags) ReadFrom

func (t *Tags) ReadFrom(r io.Reader) (n int64, err error)

func (*Tags) WriteTo

func (t *Tags) WriteTo(w io.Writer) (n int64, err error)

type Version

type Version int
const (
	Version1 Version = 1
	Version2 Version = 2
)

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL