The Assimilation Project
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
SwitchDiscovery class

Class providing a switch discovery class for discovering network switch properties - subclass of Discovery class. More...

Collaboration diagram for SwitchDiscovery class:

Data Structures

struct  _SwitchDiscoveryType
 

Macros

#define DEFAULT_PROTOS   (ENABLE_LLDP|ENABLE_CDP)
 

Typedefs

typedef struct _SwitchDiscoveryType SwitchDiscoveryType
 

Functions

FSTATIC void _switchdiscovery_finalize (AssimObj *dself)
 finalize a SwitchDiscovery object More...
 
FSTATIC gboolean _switchdiscovery_discover (Discovery *self)
 Discover member function for timed discovery – not applicable – return FALSE. More...
 
FSTATIC gboolean _switchdiscovery_dispatch (GSource_pcap_t *gsource,pcap_t *capstruct,gconstpointer pkt,gconstpointer pend,const struct pcap_pkthdr *pkthdr,const char *capturedev,gpointer selfptr)
 Internal pcap gsource dispatch routine - called when we get a packet. More...
 
FSTATIC guint _switchdiscovery_setprotocols (ConfigContext *cfg)
 
SwitchDiscoveryswitchdiscovery_new (ConfigContext *swconfig, gint priority, GMainContext *mcontext, NetGSource *iosrc, ConfigContext *config, gsize objsize)
 SwitchDiscovery constructor. More...
 
FSTATIC gboolean _switchdiscovery_cache_info (SwitchDiscovery *self,gconstpointer pkt,gconstpointer pktend)
 

Detailed Description

Class providing a switch discovery class for discovering network switch properties - subclass of Discovery class.

We deal with things like CDP, LDP and so on in order to "hear" our switch/port configuration.

Macro Definition Documentation

#define DEFAULT_PROTOS   (ENABLE_LLDP|ENABLE_CDP)

Definition at line 114 of file switchdiscovery.c.

Referenced by _switchdiscovery_setprotocols().

Typedef Documentation

typedef struct _SwitchDiscoveryType SwitchDiscoveryType

Definition at line 196 of file switchdiscovery.c.

Function Documentation

FSTATIC gboolean _switchdiscovery_cache_info ( SwitchDiscovery self,
gconstpointer  pkt,
gconstpointer  pktend 
)
Returns
TRUE if this data is new or has changed from our previously cached version.
Todo:
deal with switches that send both LLDP and CDP packets
Parameters
[in,out]selfOur SwitchDiscovery object
[in]pktPointer to the packet just read in
[in]pktendPointer to first byte past 'pkt'

Definition at line 210 of file switchdiscovery.c.

References DIMOF, and FREE.

Referenced by _switchdiscovery_dispatch().

Here is the caller graph for this function:

FSTATIC gboolean _switchdiscovery_discover ( Discovery self)

Discover member function for timed discovery – not applicable – return FALSE.

Parameters
[in,out]self

Definition at line 70 of file switchdiscovery.c.

Referenced by switchdiscovery_new().

Here is the caller graph for this function:

FSTATIC gboolean _switchdiscovery_dispatch ( GSource_pcap_t gsource,
pcap_t *  capstruct,
gconstpointer  pkt,
gconstpointer  pend,
const struct pcap_pkthdr *  pkthdr,
const char *  capturedev,
gpointer  selfptr 
)

Internal pcap gsource dispatch routine - called when we get a packet.

It examines the packet and sees if it is the same switch id and port ID as previously. If there is no previous packet, or something has changed, it constructs a packet encapsulating the captured packet, then sends this encapsulated packet "upstream" to the CMA. All we care about about are those two fields - the rest we leave to the CMA.

Don't cache if we can't send - and don't send if we have sent this info previously.

Parameters
[in]gsourceGsource object causing dispatch
[in]capstructPointer to structure capturing for us
[in]pktPointer to the packet just read in
[in]pendPointer to first byte past 'pkt'
[in]pkthdrlibpcap packet header
[in]capturedevDevice being captured
[in,out]selfptrpointer to our Discover object

Definition at line 84 of file switchdiscovery.c.

References _Discovery::_config, _Discovery::_iosource, _NetGSource::_netio, _switchdiscovery_cache_info(), CASTTOCLASS, CONFIGNAME_CMADISCOVER, construct_pcap_frameset(), DEFAULT_FSP_QID, FRAMESETTYPE_SWDISCOVER, _ConfigContext::getaddr, _NetIO::sendareliablefs(), transport, and UNREF.

Referenced by switchdiscovery_new().

Here is the call graph for this function:

Here is the caller graph for this function:

FSTATIC void _switchdiscovery_finalize ( AssimObj self)

finalize a SwitchDiscovery object

Definition at line 43 of file switchdiscovery.c.

References CASTTOCLASS, and g_info.

Referenced by switchdiscovery_new().

Here is the caller graph for this function:

FSTATIC guint _switchdiscovery_setprotocols ( ConfigContext cfg)
SwitchDiscovery* switchdiscovery_new ( ConfigContext swconfig,
gint  priority,
GMainContext *  mcontext,
NetGSource iosrc,
ConfigContext config,
gsize  objsize 
)

SwitchDiscovery constructor.

Good for discovering switch information via pcap-enabled discovery protocols (like LLDP and CDP)

<[in] instance name

<[in] device to listen on

<[in] what protocols to listen to

Parameters
[in]swconfigSwitch discoveryconfiguration info
[in]prioritysource priority
[in,out]mcontextmainloop context
[in,out]iosrcI/O object
[in,out]configGlobal configuration
[in]objsizeobject size

Definition at line 155 of file switchdiscovery.c.

References _AssimObj::_finalize, _switchdiscovery_discover(), _switchdiscovery_dispatch(), _switchdiscovery_finalize(), _switchdiscovery_setprotocols(), _Discovery::baseclass, CASTTOCLASS, CONFIGNAME_DEVNAME, CONFIGNAME_INSTANCE, _Discovery::discover, discovery_new(), discovery_register(), _SwitchDiscovery::finalize, g_source_pcap_new(), _ConfigContext::getstring, _SwitchDiscovery::portid, _SwitchDiscovery::portidlen, proj_class_register_subclassed(), _SwitchDiscovery::source, _SwitchDiscovery::switchid, and _SwitchDiscovery::switchidlen.

Referenced by nano_schedule_discovery().

Here is the call graph for this function:

Here is the caller graph for this function: