Cacti (home)ForumsDocumentation
Cacti: offical forums and support
It is currently Wed May 24, 2017 2:46 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: need help on a plugins: bitwise of CDP value
PostPosted: Wed Jan 25, 2017 1:37 am 
Offline
Cacti User

Joined: Wed Dec 07, 2011 9:19 am
Posts: 184
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 ?

_________________
CentOS
Cacti 0.8.8h
Spine 0.8.8h
PIA 3.1
Aggregate 0.75
Monitor 1.3
Settings 0.71
Weathermap 0.98
Thold 0.5
rrdclean 0.41

Own plugin: LinkDiscovery 0.3


Top
 Profile  
 
 Post subject: Re: need help on a plugins: bitwise of CDP value
PostPosted: Wed Jan 25, 2017 3:48 am 
Offline
Developer

Joined: Thu Apr 07, 2005 3:29 pm
Posts: 2534
Location: B/CS Texas
This should give you an example of how to decode it.

Code:
$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";
   }
}


This should print
Quote:
Router
Switch
IGMP conditional filtering
Wifi AP

_________________
CactiEZ CD


Top
 Profile  
 
 Post subject: Re: need help on a plugins: bitwise of CDP value
PostPosted: Thu Jan 26, 2017 9:30 am 
Offline
Cacti User

Joined: Wed Dec 07, 2011 9:19 am
Posts: 184
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!!

_________________
CentOS
Cacti 0.8.8h
Spine 0.8.8h
PIA 3.1
Aggregate 0.75
Monitor 1.3
Settings 0.71
Weathermap 0.98
Thold 0.5
rrdclean 0.41

Own plugin: LinkDiscovery 0.3


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Protected by Anti-Spam ACP Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group