Documentation ¶
Index ¶
- Constants
- func Max(x, y int) int
- func Min(x, y int) int
- type Frame
- type InPktChannel
- type LLDPGlobalInfo
- func (intf *LLDPGlobalInfo) CreatePcapHandler(lldpSnapshotLen int32, lldpPromiscuous bool, lldpTimeout time.Duration) error
- func (intf *LLDPGlobalInfo) DeInitRuntimeInfo()
- func (intf *LLDPGlobalInfo) DeletePcapHandler()
- func (intf *LLDPGlobalInfo) Disable()
- func (intf LLDPGlobalInfo) DumpFrame()
- func (intf *LLDPGlobalInfo) Enable()
- func (intf *LLDPGlobalInfo) FreeDynamicMemory()
- func (intf *LLDPGlobalInfo) GetChassisIdInfo() string
- func (intf *LLDPGlobalInfo) GetEnabledCap() string
- func (intf *LLDPGlobalInfo) GetPeerHostName() string
- func (intf *LLDPGlobalInfo) GetPortIdInfo() string
- func (intf *LLDPGlobalInfo) GetSystemCap() string
- func (intf *LLDPGlobalInfo) GetSystemDescription() string
- func (intf *LLDPGlobalInfo) InitRuntimeInfo(portConf *config.PortInfo)
- func (intf *LLDPGlobalInfo) ReceiveFrames(lldpRxPktCh chan InPktChannel)
- func (intf *LLDPGlobalInfo) StartTxTimer(lldpTxPktCh chan SendPktChannel)
- func (intf *LLDPGlobalInfo) StopCacheTimer()
- func (intf *LLDPGlobalInfo) WritePacket(pkt []byte) bool
- type LLDPServer
- func (svr *LLDPServer) AddPortToUpState(ifIndex int32)
- func (svr *LLDPServer) ChannelHandler()
- func (svr *LLDPServer) CloseAllPktHandlers()
- func (svr *LLDPServer) CloseDB()
- func (svr *LLDPServer) DeInitGlobalDS()
- func (svr *LLDPServer) DeletePortFromUpState(ifIndex int32)
- func (svr *LLDPServer) EntryExist(intfRef string) (int32, bool)
- func (svr *LLDPServer) GetGlobalState(vrf string) *config.GlobalState
- func (svr *LLDPServer) GetIntfState(intfRef string) *config.IntfState
- func (svr *LLDPServer) GetIntfStates(idx, cnt int) (int, int, []config.IntfState)
- func (svr *LLDPServer) GetIntfs(idx, cnt int) (int, int, []config.Intf)
- func (svr *LLDPServer) InitDB() error
- func (svr *LLDPServer) InitGlobalDS()
- func (svr *LLDPServer) InitL2PortInfo(portInfo *config.PortInfo)
- func (svr *LLDPServer) LLDPStartServer(paramsDir string)
- func (svr *LLDPServer) OSSignalHandle()
- func (svr *LLDPServer) PopulateTLV(ifIndex int32, entry *config.IntfState) bool
- func (svr *LLDPServer) ProcessRcvdPkt(rcvdInfo InPktChannel)
- func (svr *LLDPServer) ReadDB() error
- func (svr *LLDPServer) RunGlobalConfig()
- func (svr *LLDPServer) SendFrame(ifIndex int32)
- func (svr *LLDPServer) ServerRxChClose() bool
- func (svr *LLDPServer) SignalHandler(sigChannel <-chan os.Signal)
- func (svr *LLDPServer) StartRxTx(ifIndex int32, rxtxMode uint8)
- func (svr *LLDPServer) StopRxTx(ifIndex int32)
- func (svr *LLDPServer) UpdateCache(sysInfo *config.SystemInfo)
- func (svr *LLDPServer) UpdateL2IntfStateChange(ifIndex int32, state string)
- type SendPktChannel
Constants ¶
const ( // LLDP profiling LLDP_CPU_PROFILE_FILE = "/var/log/lldp.prof" // Consts Init Size/Capacity LLDP_INITIAL_GLOBAL_INFO_CAPACITY = 100 LLDP_RX_PKT_CHANNEL_SIZE = 30 LLDP_TX_PKT_CHANNEL_SIZE = 30 LLDP_PORT_STATE_CHANGE_CHANNEL_SIZE = 200 LLDP_PORT_CONFIG_CHANNEL_SIZE = 5 // Port Operation State LLDP_PORT_STATE_DOWN = "DOWN" LLDP_PORT_STATE_UP = "UP" LLDP_PORT_BROKEN_OUT = "Port broken out" LLDP_BPF_FILTER = "ether proto 0x88cc" LLDP_DEFAULT_TX_INTERVAL = 30 LLDP_DEFAULT_TX_HOLD_MULTIPLIER = 4 LLDP_MIN_FRAME_LENGTH = 12 // this is 12 bytes LLDP_FAST_LEARN_TIMER = 1 // in seconds LLDP_FAST_LEARN_MAX_FRAMES_SEND = 5 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type InPktChannel ¶
type InPktChannel struct {
// contains filtered or unexported fields
}
type LLDPGlobalInfo ¶
type LLDPGlobalInfo struct { // Port information Port config.PortInfo // Pcap Handler for Each Port PcapHandle *pcap.Handle // rx information RxInfo *packet.RX // tx information TxInfo *packet.TX // Reading received info & updating received info lock RxLock *sync.RWMutex // Go Routine Killer Channels RxKill chan bool TxDone chan bool // contains filtered or unexported fields }
func (*LLDPGlobalInfo) CreatePcapHandler ¶
func (intf *LLDPGlobalInfo) CreatePcapHandler(lldpSnapshotLen int32, lldpPromiscuous bool, lldpTimeout time.Duration) error
Create Pcap Handler
func (*LLDPGlobalInfo) DeInitRuntimeInfo ¶
func (intf *LLDPGlobalInfo) DeInitRuntimeInfo()
De-Init l2 port information
func (*LLDPGlobalInfo) DeletePcapHandler ¶
func (intf *LLDPGlobalInfo) DeletePcapHandler()
Delete l2 port pcap handler
func (*LLDPGlobalInfo) Disable ¶
func (intf *LLDPGlobalInfo) Disable()
Based on configuration we will enable disable lldp per port
func (LLDPGlobalInfo) DumpFrame ¶
func (intf LLDPGlobalInfo) DumpFrame()
dump received lldp frame and other TX information
func (*LLDPGlobalInfo) Enable ¶
func (intf *LLDPGlobalInfo) Enable()
Based on configuration we will enable disable lldp per port
func (*LLDPGlobalInfo) FreeDynamicMemory ¶
func (intf *LLDPGlobalInfo) FreeDynamicMemory()
Return back all the memory which was allocated using new
func (*LLDPGlobalInfo) GetChassisIdInfo ¶
func (intf *LLDPGlobalInfo) GetChassisIdInfo() string
Get Chassis Id info
* Based on SubType Return the string, mac address then form string using * net package
func (*LLDPGlobalInfo) GetEnabledCap ¶
func (intf *LLDPGlobalInfo) GetEnabledCap() string
Get Enabled Capability info
* Based on booleans value Return the string, which states what enabled capabilities are enabled
func (*LLDPGlobalInfo) GetPeerHostName ¶
func (intf *LLDPGlobalInfo) GetPeerHostName() string
Get Peer Host Name information
*
func (*LLDPGlobalInfo) GetPortIdInfo ¶
func (intf *LLDPGlobalInfo) GetPortIdInfo() string
Get Port Id info
* Based on SubType Return the string, mac address then form string using * net package
func (*LLDPGlobalInfo) GetSystemCap ¶
func (intf *LLDPGlobalInfo) GetSystemCap() string
Get System Capability info
* Based on booleans value Return the string, which states what system capabilities are enabled
func (*LLDPGlobalInfo) GetSystemDescription ¶
func (intf *LLDPGlobalInfo) GetSystemDescription() string
Get Peer Host Name information
*
func (*LLDPGlobalInfo) InitRuntimeInfo ¶
func (intf *LLDPGlobalInfo) InitRuntimeInfo(portConf *config.PortInfo)
Init l2 port information for global runtime information
func (*LLDPGlobalInfo) ReceiveFrames ¶
func (intf *LLDPGlobalInfo) ReceiveFrames(lldpRxPktCh chan InPktChannel)
Go routine to recieve lldp frames. This go routine is created for all the * ports which are in up state.
func (*LLDPGlobalInfo) StartTxTimer ¶
func (intf *LLDPGlobalInfo) StartTxTimer(lldpTxPktCh chan SendPktChannel)
lldp server go routine to handle tx timer... once the timer fires we will
* send the ifindex on the channel to handle send info * * For fast learning we will send out 5 frames in 5 seconds and then every 30 seconds an update frame will * be send out
func (*LLDPGlobalInfo) StopCacheTimer ¶
func (intf *LLDPGlobalInfo) StopCacheTimer()
Stop RX cache timer
func (*LLDPGlobalInfo) WritePacket ¶
func (intf *LLDPGlobalInfo) WritePacket(pkt []byte) bool
Write packet is helper function to send packet on wire.
* It will inform caller that packet was send successfully and you can go ahead * and cache the pkt or else do not cache the packet as it is corrupted or there * was some error
type LLDPServer ¶
type LLDPServer struct { CfgPlugin plugin.ConfigIntf SysPlugin plugin.SystemIntf //System Information SysInfo *config.SystemInfo // Global LLDP Information Global *config.Global // lldp global config channel GblCfgCh chan *config.Global // lldp per port config IntfCfgCh chan *config.IntfConfig // lldp asic notification channel IfStateCh chan *config.PortState // Update Cache notification channel UpdateCacheCh chan *config.SystemInfo // Event Publish channel for server EventCh chan config.EventInfo // contains filtered or unexported fields }
func LLDPNewServer ¶
func LLDPNewServer(aPlugin plugin.AsicIntf, lPlugin plugin.ConfigIntf, sPlugin plugin.SystemIntf, dbHdl *dbutils.DBUtil) *LLDPServer
Create lldp server object for the main handler..
func (*LLDPServer) AddPortToUpState ¶
func (svr *LLDPServer) AddPortToUpState(ifIndex int32)
* Add ifIndex to lldpUpIntfStateSlice on start rx/tx only if it doesn't exists
func (*LLDPServer) ChannelHandler ¶
func (svr *LLDPServer) ChannelHandler()
To handle all the channels in lldp server... For detail look at the * LLDPInitGlobalDS api to see which all channels are getting initialized
func (*LLDPServer) CloseAllPktHandlers ¶
func (svr *LLDPServer) CloseAllPktHandlers()
On de-init we will be closing all the pcap handlers that are opened up * We will also free up all the pointers from the gblInfo. Otherwise that will * lead to memory leak
func (*LLDPServer) CloseDB ¶
func (svr *LLDPServer) CloseDB()
func (*LLDPServer) DeInitGlobalDS ¶
func (svr *LLDPServer) DeInitGlobalDS()
De-Allocate memory to all the object which are being used by LLDP server
func (*LLDPServer) DeletePortFromUpState ¶
func (svr *LLDPServer) DeletePortFromUpState(ifIndex int32)
delete ifindex from lldpUpIntfStateSlice on port down... we can use this
* if user decides to disable lldp on a port
func (*LLDPServer) EntryExist ¶
func (svr *LLDPServer) EntryExist(intfRef string) (int32, bool)
Api used to get entry.. This is mainly used by LLDP Server API Layer when it get config from
* North Bound Plugin...
func (*LLDPServer) GetGlobalState ¶
func (svr *LLDPServer) GetGlobalState(vrf string) *config.GlobalState
Server get lldp global state
func (*LLDPServer) GetIntfState ¶
func (svr *LLDPServer) GetIntfState(intfRef string) *config.IntfState
Server get lldp interface state per interface
func (*LLDPServer) GetIntfStates ¶
Server get bulk for lldp up intf state's
func (*LLDPServer) InitDB ¶
func (svr *LLDPServer) InitDB() error
func (*LLDPServer) InitGlobalDS ¶
func (svr *LLDPServer) InitGlobalDS()
Allocate memory to all the object which are being used by LLDP server
func (*LLDPServer) InitL2PortInfo ¶
func (svr *LLDPServer) InitL2PortInfo(portInfo *config.PortInfo)
Create global run time information for l2 port and then start rx/tx for that port if state is up
func (*LLDPServer) LLDPStartServer ¶
func (svr *LLDPServer) LLDPStartServer(paramsDir string)
lldp server: 1) Connect to all the clients
* 2) Initialize DB * 3) Read from DB and close DB * 4) Call AsicPlugin for port information * 5) go routine to handle all the channels within lldp server
func (*LLDPServer) OSSignalHandle ¶
func (svr *LLDPServer) OSSignalHandle()
Create os signal handler channel and initiate go routine for that
func (*LLDPServer) PopulateTLV ¶
func (svr *LLDPServer) PopulateTLV(ifIndex int32, entry *config.IntfState) bool
helper function to convert TLV's (chassisID, portID, TTL) from byte
* format to string
func (*LLDPServer) ProcessRcvdPkt ¶
func (svr *LLDPServer) ProcessRcvdPkt(rcvdInfo InPktChannel)
func (*LLDPServer) ReadDB ¶
func (svr *LLDPServer) ReadDB() error
func (*LLDPServer) RunGlobalConfig ¶
func (svr *LLDPServer) RunGlobalConfig()
func (*LLDPServer) SendFrame ¶
func (svr *LLDPServer) SendFrame(ifIndex int32)
API to send a frame when tx timer expires per port
func (*LLDPServer) ServerRxChClose ¶
func (svr *LLDPServer) ServerRxChClose() bool
helper function to inform whether rx channel is closed or open...
* Go routine can be exited using this information
func (*LLDPServer) SignalHandler ¶
func (svr *LLDPServer) SignalHandler(sigChannel <-chan os.Signal)
OS signal handler. * If the process get a sighup signal then close all the pcap handlers. * After that delete all the memory which was used during init process
func (*LLDPServer) StartRxTx ¶
func (svr *LLDPServer) StartRxTx(ifIndex int32, rxtxMode uint8)
Create l2 port pcap handler and then start rx and tx on that pcap * Filter is LLDP_BPF_FILTER = "ether proto 0x88cc" * Note: API should only and only do * 1) pcap create * 2) start go routine for Rx/Tx Frames Packet Handler * 3) Add the port to UP List
func (*LLDPServer) StopRxTx ¶
func (svr *LLDPServer) StopRxTx(ifIndex int32)
Send Signal for stopping rx/tx go routine and timers as the pcap handler for
* the port is deleted
func (*LLDPServer) UpdateCache ¶
func (svr *LLDPServer) UpdateCache(sysInfo *config.SystemInfo)
Api to update system cache on next send frame
func (*LLDPServer) UpdateL2IntfStateChange ¶
func (svr *LLDPServer) UpdateL2IntfStateChange(ifIndex int32, state string)
handle l2 state up/down notifications..
type SendPktChannel ¶
type SendPktChannel struct {
// contains filtered or unexported fields
}