Documentation
¶
Index ¶
- Constants
- type CDPDiscoverer
- func (d *CDPDiscoverer) InjectCDPNeighbor(deviceID, platform, version, portID, mgmtAddr string, capabilities uint32, ...)
- func (d *CDPDiscoverer) ParseCDPData(data []byte) (*Neighbor, error)
- func (d *CDPDiscoverer) SendCDPPacket(deviceID, platform string) error
- func (d *CDPDiscoverer) Start(neighborChan chan<- Neighbor) error
- func (d *CDPDiscoverer) Stop()
- type CDPHeader
- type CDPTLV
- type DiscoveryProtocol
- type DiscoveryResult
- type LLDPDiscoverer
- type LLDPFrame
- type LLDPTLV
- type MNDPDiscoverer
- type MNDPPacket
- type MikroTikNeighbor
- type Neighbor
- type NeighborScanner
- func (ns *NeighborScanner) GetNeighbors() []Neighbor
- func (ns *NeighborScanner) GetNeighborsWithSSH() []Neighbor
- func (ns *NeighborScanner) GetUpdateChannel() <-chan Neighbor
- func (ns *NeighborScanner) StartDiscovery(duration time.Duration) (*DiscoveryResult, error)
- func (ns *NeighborScanner) StartDiscoveryWithoutSSHCheck(duration time.Duration) (*DiscoveryResult, error)
- func (ns *NeighborScanner) Stop()
- type TLV
- type TLVTag
Constants ¶
const ( // CDP uses SNAP encapsulation with these values CDPMulticast = "01:00:0c:cc:cc:cc" // CDP multicast MAC address CDPEtherType = 0x2000 // CDP EtherType (actually uses SNAP) CDPLLC = 0xAAAA // LLC header for CDP CDPOrganizationCode = 0x00000C // Cisco organization code CDPProtocolID = 0x2000 // CDP protocol ID in SNAP header )
const ( CDPTLVDeviceID = 0x0001 CDPTLVAddress = 0x0002 CDPTLVPortID = 0x0003 CDPTLVCapabilities = 0x0004 CDPTLVVersion = 0x0005 CDPTLVPlatform = 0x0006 CDPTLVIPPrefix = 0x0007 CDPTLVVTPDomain = 0x0009 CDPTLVNativeVLAN = 0x000a CDPTLVDuplex = 0x000b CDPTLVApplianceID = 0x000c CDPTLVApplianceVLAN = 0x000e CDPTLVPowerConsumption = 0x0010 CDPTLVMTU = 0x0011 CDPTLVExtendedTrust = 0x0012 CDPTLVUntrustedCOS = 0x0013 CDPTLVSystemName = 0x0014 CDPTLVSystemOID = 0x0015 CDPTLVMgmtAddress = 0x0016 CDPTLVLocation = 0x0017 CDPTLVExternalPortID = 0x0018 CDPTLVPowerRequested = 0x0019 CDPTLVPowerAvailable = 0x001a CDPTLVPortUnidirectional = 0x001b )
CDP TLV Types (according to Wireshark documentation)
const ( CDPCapRouter = 0x01 CDPCapTBBridge = 0x02 CDPCapSRBridge = 0x04 CDPCapSwitch = 0x08 CDPCapHost = 0x10 CDPCapIGMPFilter = 0x20 CDPCapRepeater = 0x40 CDPCapPhone = 0x80 CDPCapRemote = 0x100 )
CDP Capabilities
const ( LLDPMulticast = "01:80:C2:00:00:0E" // LLDP multicast MAC address LLDPEtherType = 0x88CC // LLDP EtherType LLDPDefaultTTL = 120 // Default TTL in seconds LLDPTxInterval = 30 // Transmission interval in seconds LLDPTxHoldMulti = 4 // Hold multiplier LLDPReinitDelay = 2 // Reinit delay in seconds LLDPTxDelay = 2 // Tx delay in seconds )
LLDP Constants based on IEEE 802.1AB
const ( LLDPTLVEndOfLLDPDU = 0 // Mandatory LLDPTLVChassisID = 1 // Mandatory LLDPTLVPortID = 2 // Mandatory LLDPTLVTimeToLive = 3 // Mandatory LLDPTLVPortDescription = 4 // Optional LLDPTLVSystemName = 5 // Optional LLDPTLVSystemDesc = 6 // Optional LLDPTLVSystemCaps = 7 // Optional LLDPTLVMgmtAddr = 8 // Optional LLDPTLVOrgSpecific = 127 // Organizationally Specific TLVs )
LLDP TLV Types
const ( LLDPChassisIDChassisComponent = 1 LLDPChassisIDInterfaceAlias = 2 LLDPChassisIDPortComponent = 3 LLDPChassisIDMACAddress = 4 LLDPChassisIDNetworkAddress = 5 LLDPChassisIDInterfaceName = 6 LLDPChassisIDLocallyAssigned = 7 )
LLDP Chassis ID Subtypes
const ( LLDPPortIDInterfaceAlias = 1 LLDPPortIDPortComponent = 2 LLDPPortIDMACAddress = 3 LLDPPortIDNetworkAddress = 4 LLDPPortIDInterfaceName = 5 LLDPPortIDAgentCircuitID = 6 LLDPPortIDLocallyAssigned = 7 )
LLDP Port ID Subtypes
const ( LLDPSysCapOther = 0x01 LLDPSysCapRepeater = 0x02 LLDPSysCapBridge = 0x04 LLDPSysCapWLANAP = 0x08 LLDPSysCapRouter = 0x10 LLDPSysCapTelephone = 0x20 LLDPSysCapDocsisCable = 0x40 LLDPSysCapStationOnly = 0x80 )
LLDP System Capabilities
const ( MNDPPort = 5678 MNDPMulticast = "255.255.255.255" MaxPacketSize = 1500 IPv6LinkLocalAll = "ff02::1" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CDPDiscoverer ¶
type CDPDiscoverer struct {
// contains filtered or unexported fields
}
CDPDiscoverer handles Cisco Discovery Protocol Note: This is a simulation since CDP requires raw Layer 2 access
func NewCDPDiscoverer ¶
func NewCDPDiscoverer() (*CDPDiscoverer, error)
NewCDPDiscoverer creates a new CDP discoverer
func (*CDPDiscoverer) InjectCDPNeighbor ¶
func (d *CDPDiscoverer) InjectCDPNeighbor(deviceID, platform, version, portID, mgmtAddr string, capabilities uint32, neighborChan chan<- Neighbor)
InjectCDPNeighbor allows manual injection of CDP neighbor data for testing
func (*CDPDiscoverer) ParseCDPData ¶
func (d *CDPDiscoverer) ParseCDPData(data []byte) (*Neighbor, error)
ParseCDPData is a public method that can be used for testing or manual CDP packet processing It wraps the internal parseCDPPacket method for external use
func (*CDPDiscoverer) SendCDPPacket ¶
func (d *CDPDiscoverer) SendCDPPacket(deviceID, platform string) error
SendCDPPacket sends a CDP advertisement (requires root privileges)
func (*CDPDiscoverer) Start ¶
func (d *CDPDiscoverer) Start(neighborChan chan<- Neighbor) error
Start begins CDP discovery simulation
type DiscoveryProtocol ¶
type DiscoveryProtocol string
DiscoveryProtocol represents the protocol used to discover the device
const ( ProtocolMNDP DiscoveryProtocol = "MNDP" ProtocolCDP DiscoveryProtocol = "CDP" ProtocolLLDP DiscoveryProtocol = "LLDP" )
type DiscoveryResult ¶
type DiscoveryResult struct {
TotalFound int
WithSSH int
Neighbors []Neighbor
Duration time.Duration
ByProtocol map[DiscoveryProtocol]int
}
DiscoveryResult contains the results of a neighbor discovery scan
type LLDPDiscoverer ¶
type LLDPDiscoverer struct {
// contains filtered or unexported fields
}
LLDPDiscoverer handles Link Layer Discovery Protocol
func NewLLDPDiscoverer ¶
func NewLLDPDiscoverer() (*LLDPDiscoverer, error)
NewLLDPDiscoverer creates a new LLDP discoverer
func (*LLDPDiscoverer) ExtractMgmtAddress ¶
func (d *LLDPDiscoverer) ExtractMgmtAddress(tlvValue []byte) string
extractMgmtAddress extracts management address from LLDP management address TLV
func (*LLDPDiscoverer) Start ¶
func (d *LLDPDiscoverer) Start(neighborChan chan<- Neighbor) error
Start begins LLDP discovery
type LLDPFrame ¶
type LLDPFrame struct {
ChassisID *LLDPTLV
PortID *LLDPTLV
TTL *LLDPTLV
PortDescription *LLDPTLV
SystemName *LLDPTLV
SystemDesc *LLDPTLV
SystemCaps *LLDPTLV
MgmtAddr *LLDPTLV
OrgTLVs []*LLDPTLV
}
LLDPFrame represents a complete LLDP frame
type MNDPDiscoverer ¶
type MNDPDiscoverer struct {
// contains filtered or unexported fields
}
MNDPDiscoverer handles MikroTik Neighbor Discovery Protocol
func NewMNDPDiscoverer ¶
func NewMNDPDiscoverer() (*MNDPDiscoverer, error)
NewMNDPDiscoverer creates a new MNDP discoverer
func (*MNDPDiscoverer) SendMNDPDiscovery ¶
func (d *MNDPDiscoverer) SendMNDPDiscovery() error
SendMNDPDiscovery sends an MNDP discovery packet
func (*MNDPDiscoverer) Start ¶
func (d *MNDPDiscoverer) Start(neighborChan chan<- Neighbor) error
Start begins listening for MNDP packets
type MNDPPacket ¶
MNDPPacket represents a MikroTik Neighbor Discovery Protocol packet
type MikroTikNeighbor ¶
type MikroTikNeighbor = Neighbor
MikroTikNeighbor represents a discovered MikroTik device (for backward compatibility)
type Neighbor ¶
type Neighbor struct {
MACAddress string
Identity string
Version string
Platform string
Uptime time.Duration
SoftwareID string
Board string
UnpackedData string
IPv6Address string
InterfaceName string
IPAddress string
SSHPort int
HasSSH bool
HasTelnet bool
Protocol DiscoveryProtocol
DeviceID string
PortID string
SystemName string
SystemDesc string
PortDesc string
MgmtAddr string
TTL uint16
Capabilities uint32
NativeVLAN uint16
VLANs []uint16
PowerAvailable uint32
PowerRequested uint32
DiscoveredAt time.Time
}
Neighbor represents a discovered network device
type NeighborScanner ¶
type NeighborScanner struct {
// contains filtered or unexported fields
}
NeighborScanner handles the overall neighbor discovery process
func NewNeighborScanner ¶
func NewNeighborScanner() *NeighborScanner
NewNeighborScanner creates a new neighbor scanner
func (*NeighborScanner) GetNeighbors ¶
func (ns *NeighborScanner) GetNeighbors() []Neighbor
GetNeighbors returns all discovered neighbors
func (*NeighborScanner) GetNeighborsWithSSH ¶
func (ns *NeighborScanner) GetNeighborsWithSSH() []Neighbor
GetNeighborsWithSSH returns only neighbors that have SSH connectivity
func (*NeighborScanner) GetUpdateChannel ¶
func (ns *NeighborScanner) GetUpdateChannel() <-chan Neighbor
GetUpdateChannel returns the update channel
func (*NeighborScanner) StartDiscovery ¶
func (ns *NeighborScanner) StartDiscovery(duration time.Duration) (*DiscoveryResult, error)
StartDiscovery starts the neighbor discovery process
func (*NeighborScanner) StartDiscoveryWithoutSSHCheck ¶
func (ns *NeighborScanner) StartDiscoveryWithoutSSHCheck(duration time.Duration) (*DiscoveryResult, error)
StartDiscoveryWithoutSSHCheck starts the neighbor discovery process without SSH connectivity checks
type TLVTag ¶
type TLVTag uint16
TLVTag represents MNDP TLV tag types
const ( TagMNDP TLVTag = 0 TagMACAddr TLVTag = 1 TagIdentity TLVTag = 5 TagVersion TLVTag = 7 TagPlatform TLVTag = 8 TagUptime TLVTag = 10 TagSoftwareID TLVTag = 11 TagBoard TLVTag = 12 TagUnpack TLVTag = 14 TagIPv6Addr TLVTag = 15 TagInterfaceName TLVTag = 16 TagIPv4Addr TLVTag = 17 TagMAX TLVTag = TagIPv4Addr )