lldpd

package module
v0.0.0-...-05380e3 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2023 License: MIT Imports: 13 Imported by: 1

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

This section is empty.

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 InterfaceFilterFn

type InterfaceFilterFn func(*net.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 *net.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 *net.Interface)

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

func (*LLDPD) SetOption

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

SetOption runs a functional option against LLDPD.

type Logger

type Logger interface {
	// Info logs informational messages.
	Info(keyvals ...interface{})
	// Error logs error messages.
	Error(keyvals ...interface{})
}

Logger is a logging adapter interface

func Adapt

func Adapt(l *logrus.Entry) Logger

Adapt creates a Logger backed from a logrus Entry.

type Option

type Option func(*LLDPD) error

Option is a functional option handler for LLDPD.

func InterfaceFilter

func InterfaceFilter(fn InterfaceFilterFn) Option

InterfaceFilter allows a user to filter interfaces

func PortLookup

func PortLookup(fn PortLookupFn) Option

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

func ReplyUnicast

func ReplyUnicast() Option

ReplyUnicast instructs the daemon to send lldp PDU's to the src mac address, instead of the lldp broadcast address

func SourceAddress

func SourceAddress(addr net.HardwareAddr) Option

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

type PortLookupFn

type PortLookupFn func(*net.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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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