lldpd

package module
v0.0.0-...-fb4eb5d Latest Latest
Warning

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

Go to latest
Published: May 12, 2021 License: MIT Imports: 12 Imported by: 0

README

lldpd GoDoc Go Report Card

Package lldpd attempts to create an opinionated LLDP daemon.

MIT Licensed.

This package is still unfinished. The API is highly unstable.

Documentation

Index

Constants

View Source
const (
	IF_ADD linkOp = 1
	IF_DEL linkOp = 2
)

Variables

View Source
var LldpMulticaseAddress = []byte{0x01, 0x80, 0xc2, 0x00, 0x00, 0x0e}

sudo ip maddr add 01:80:c2:00:00:0e dev eth0

Functions

func NewNLListener

func NewNLListener(log Logger) *nlListener

NewNLListener listens on rtnetlink for addition and removal of interfaces and inform users on the Messages channel.

Types

type ErrListenFn

type ErrListenFn func(err error, ifi raw.Interface)

type HandleInputFn

type HandleInputFn func(*Message) (*Message, error)

type InterfaceFilterFn

type InterfaceFilterFn func(raw.Interface) bool

InterfaceFilterFn is the function used to filter interface This function is called once for every interface the daemon can potentially listen on. It should return true if the daemon should listen on the interface.

type LLDPD

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

LLDPD is the server for LLDP PDU's It will always listen passively. This means, it will only send LLDP PDU's in response to a received PDU.

func New

func New(opts ...Option) *LLDPD

New will return a new LLDPD server with the optional options configured.

func (*LLDPD) CancelListenOn

func (l *LLDPD) CancelListenOn(ifi raw.Interface)

CancelListenOn will stop listening on the interface

func (*LLDPD) Listen

func (l *LLDPD) Listen() error

Listen will start the main listener loop

func (*LLDPD) ListenOn

func (l *LLDPD) ListenOn(ifi raw.Interface)

ListenOn will listen on the specified interface for LLDP PDU's

func (*LLDPD) Send

func (l *LLDPD) Send(msg *Message) error

func (*LLDPD) SetOption

func (p *LLDPD) SetOption(option Option) error

SetOption runs a functional option against LLDPD.

type Logger

type Logger interface {
	Info(...interface{})
	Error(...interface{})
	Errorf(string, ...interface{})
}

type Message

type Message struct {
	From  *raw.Addr
	To    *raw.Addr
	Frame *lldp.Frame
	Ifi   raw.Interface
}

type NormalLoger

type NormalLoger struct {
}

func (*NormalLoger) Error

func (n *NormalLoger) Error(args ...interface{})

func (*NormalLoger) Errorf

func (n *NormalLoger) Errorf(fmt string, args ...interface{})

func (*NormalLoger) Info

func (n *NormalLoger) Info(args ...interface{})

type Option

type Option func(*LLDPD) error

Option is a functional option handler for LLDPD.

func HandleInput

func HandleInput(fn HandleInputFn) Option

PortLookup allows a user to use a different port description lookup mechanism

func InterfaceFilter

func InterfaceFilter(fn InterfaceFilterFn) Option

InterfaceFilter allows a user to filter interfaces

func OnListenErr

func OnListenErr(fn ErrListenFn) Option

func OnListenSuccess

func OnListenSuccess(fn SuccessListenFn) Option

func PortLookup

func PortLookup(fn PortLookupFn) Option

PortLookup allows a user to use a different port description lookup mechanism

func SetLogger

func SetLogger(log Logger) Option

func SourceAddress

func SourceAddress(fn SetSourceAddressFn) Option

SourceAddress sets the ethernet source address to use for LLDP PDU's

type PortLookupFn

type PortLookupFn func(raw.Interface) string

PortLookupFn is the function used to respond with a different port description. This function is called once, on first receive of an LLDP PDU on a port and the reply is cached untill restart.

type SetSourceAddressFn

type SetSourceAddressFn func(raw.Interface) ([]byte, lldp.ChassisIDSubtype)

type SuccessListenFn

type SuccessListenFn func(ifi raw.Interface)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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