Hello,
I'm developing a plugin that scan my network and via CDP memorise all switch/router, and the link between them.
For that I'm using CDP and the capabilities of the device. This capabilities is a binary ORed field with the following value:
Router: 0x01
TB Bridge: 0x02
SR Bridge: 0x04
Switch: 0x08
Host: 0x10
IGMP conditional filtering: 0x20
Repeater: 0x40
VoIP Phone: 0x80
Remotely-Managed Device: 0x100
for a switch it has to be 0x08, and that match most device; for Cisco Nexus switch, in L3 config, it's look like I have to get the code 0x200, to avoid Wifi Access point.
But I can make it work, the cdp data I get is an hex string with this value:
00 00 02 29
I try many different mix and data conversion, i'm still unable to figure out how to do a binary & between the CDP data and the hexcode of the Switch I have.
anyone willing to give me some help on this ?
need help on a plugins: bitwise of CDP value
Moderators: Developers, Moderators
need help on a plugins: bitwise of CDP value
Test
Almalinux
php 8.2.14
mariadb 10.6.16
Cacti 1.2.27
Spine 1.2.27
RRD 1.7.2
thold 1.8
monitor 2.5
syslog 3.2
flowview: 3.3
weathermap 1.0 Beta
Almalinux
php 8.2.14
mariadb 10.6.16
Cacti 1.2.27
Spine 1.2.27
RRD 1.7.2
thold 1.8
monitor 2.5
syslog 3.2
flowview: 3.3
weathermap 1.0 Beta
Re: need help on a plugins: bitwise of CDP value
This should give you an example of how to decode it.
This should print
Code: Select all
$code = 0x0229;
$types = array(
'Router' => 0x01,
'TB Bridge' => 0x02,
'SR Bridge' => 0x4,
'Switch' => 0x08,
'Host' => 0x10,
'IGMP conditional filtering' => 0x20,
'Repeater' => 0x40,
'VoIP Phone' => 0x80,
'Remotely-Managed Device' => 0x100,
'Wifi AP' => 0x200
);
foreach ($types as $t => $c) {
if ($code & $c) {
print "$t\n";
}
}
Router
Switch
IGMP conditional filtering
Wifi AP
Re: need help on a plugins: bitwise of CDP value
Thanks finally I decide to use a case/switch situation, that let me filter some device that advertise itself as switch, but dose not fit my needs!!
Test
Almalinux
php 8.2.14
mariadb 10.6.16
Cacti 1.2.27
Spine 1.2.27
RRD 1.7.2
thold 1.8
monitor 2.5
syslog 3.2
flowview: 3.3
weathermap 1.0 Beta
Almalinux
php 8.2.14
mariadb 10.6.16
Cacti 1.2.27
Spine 1.2.27
RRD 1.7.2
thold 1.8
monitor 2.5
syslog 3.2
flowview: 3.3
weathermap 1.0 Beta
Who is online
Users browsing this forum: No registered users and 1 guest