device

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IfOperUnknown        = 0
	IfOperNotPresent     = 1
	IfOperDown           = 2
	IfOperLowerLayerDown = 3
	IfOperTesting        = 4
	IfOperDormant        = 5
	IfOperUp             = 6
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	DeviceUpdate(DeviceInterface)
}

Client represents a client of the device server

type Device

type Device struct {
	HardwareAddr net.HardwareAddr
	// contains filtered or unexported fields
}

Device represents a network device

func (*Device) GetAddrs

func (d *Device) GetAddrs() []*bnet.Prefix

GetAddrs gets the IP addresses on the interface

func (*Device) GetIndex

func (d *Device) GetIndex() uint64

GetIndex gets the interface ifIndex

func (*Device) GetName

func (d *Device) GetName() string

GetName gets the devices name

func (*Device) GetOperState

func (d *Device) GetOperState() uint8

GetOperState gets the operational state

type DeviceInterface

type DeviceInterface interface {
	GetIndex() uint64
	GetOperState() uint8
	GetAddrs() []*bnet.Prefix
}

type MockServer

type MockServer struct {
	Called            bool
	UnsubscribeCalled bool
	C                 Client
	Name              string
	UnsubscribeName   string
}

func (*MockServer) DeviceDownEvent added in v0.1.8

func (ms *MockServer) DeviceDownEvent(name string, addrs []*net.Prefix)

func (*MockServer) DeviceUpEvent added in v0.1.8

func (ms *MockServer) DeviceUpEvent(name string, addrs []*net.Prefix)

func (*MockServer) Start added in v0.1.8

func (ms *MockServer) Start() error

func (*MockServer) Subscribe

func (ms *MockServer) Subscribe(c Client, n string)

func (*MockServer) Unsubscribe

func (ms *MockServer) Unsubscribe(c Client, n string)

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server represents a device server

func New

func New() (*Server, error)

New creates a new device server

func (*Server) Start

func (ds *Server) Start() error

Start starts the device server

func (*Server) Stop

func (ds *Server) Stop()

Stop stops the device server

func (*Server) Subscribe

func (ds *Server) Subscribe(client Client, devName string)

Subscribe allows a client to subscribe for status updates on interface `devName`

func (*Server) Unsubscribe

func (ds *Server) Unsubscribe(client Client, devName string)

Unsubscribe unsubscribes a client

type Updater

type Updater interface {
	Subscribe(Client, string)
	Unsubscribe(Client, string)
	Start() error
}

Updater is a device updater interface

Jump to

Keyboard shortcuts

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