packet

package
v0.0.0-...-a4e6d7a Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2017 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LLDP_MAX_TTL             = 65535
	LLDP_PROTO_DST_MAC       = "01:80:c2:00:00:0e"
	LLDP_TOTAL_TLV_SUPPORTED = 8
)

Variables

This section is empty.

Functions

func EncodeMandatoryTLV

func EncodeMandatoryTLV(Subtype byte, ID []byte) []byte

Encode Mandatory tlv, chassis id and port id

func EncodeMgmtTLV

func EncodeMgmtTLV(tlv *layers.LLDPMgmtAddress) []byte
  TLV Type = 8, 7 bits             ----
					|--> 2 bytes
 *  TLV Length = 9 bits....	     ----
 *  Value: N bytes
 *     Subtype is 1 byte
 *     Address is []byte
 *     IntefaceSubtype is 1 byte
 *     IntefaceNumber uint32 <<< this is system interface number which is IfIndex in our case
 *     OID string

func EncodeTLV

func EncodeTLV(tlv *layers.LinkLayerDiscoveryValue) []byte

Marshall tlv information into binary form 1) Check type value 2) Check Length

func Min

func Min(x, y int) int

Types

type RX

type RX struct {
	RxRunning bool
	// ethernet frame Info (used for rx/tx)
	SrcMAC net.HardwareAddr // NOTE: Please be informed this is Peer Mac Addr
	DstMAC net.HardwareAddr

	// lldp rx information
	RxFrame         *layers.LinkLayerDiscovery
	RxLinkInfo      *layers.LinkLayerDiscoveryInfo
	ClearCacheTimer *time.Timer

	// cache last packet and see if we need to update current information or not
	LastPkt []byte
}

func RxInit

func RxInit() *RX

func (*RX) CheckPeerEntry

func (rxInfo *RX) CheckPeerEntry(port string, eCh chan config.EventInfo, ifIndex int32)

* Handle TTL timer. Once the timer expires, we will delete the remote entry * if timer is running then reset the value

func (*RX) Process

func (p *RX) Process(rxInfo *RX, pkt gopacket.Packet) (int, error)

func (*RX) VerifyFrame

func (p *RX) VerifyFrame(lldpInfo *layers.LinkLayerDiscovery) error
Upon receiving incoming packet check whether all the madatory layer info is

* correct or not.. If not then treat the packet as corrupted and move on

type TX

type TX struct {
	DstMAC                  net.HardwareAddr
	MessageTxInterval       int
	MessageTxHoldMultiplier int

	TxTimer *time.Timer
	// contains filtered or unexported fields
}

func TxInit

func TxInit(interval, hold int) *TX

func (*TX) DeleteCacheFrame

func (t *TX) DeleteCacheFrame()

We have deleted the pcap handler and hence we will invalid the cache buffer

func (*TX) Frame

func (t *TX) Frame(port config.PortInfo, sysInfo *config.SystemInfo) []byte
Function to send out lldp frame to peer on timer expiry.

* if a cache entry is present then use that otherwise create a new lldp frame * A new frame will be constructed: * 1) if it is first time send * 2) if there is config object update

func (*TX) SetCache

func (t *TX) SetCache(use bool)

func (*TX) StopTxTimer

func (t *TX) StopTxTimer()

Stop Send Tx timer... as we have already delete the pcap handle

func (*TX) UseCache

func (t *TX) UseCache() bool

Jump to

Keyboard shortcuts

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