The Assimilation Project  based on Assimilation version 1.1.7.1474836767
ArpDiscovery class

Class providing an ARP Discovery class for discovering IP/MAC address resolution - subclass of Discovery class. More...

Collaboration diagram for ArpDiscovery class:

Functions

FSTATIC void _arpdiscovery_finalize (AssimObj *dself)
 finalize a ArpDiscovery object More...
 
FSTATIC gboolean _arpdiscovery_discover (Discovery *self)
 Discover member function for timed discovery – not applicable – return FALSE. More...
 
FSTATIC gboolean _arpdiscovery_first_discovery (gpointer gself)
 A GSourceFunc to be called for the first (random) discovery only More...
 
FSTATIC gboolean _arpdiscovery_gsourcefunc (gpointer gself)
 Function which periodically sends our ARP cache upstream. More...
 
FSTATIC gboolean _arpdiscovery_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 an ARP packet. More...
 
ArpDiscoveryarpdiscovery_new (ConfigContext *arpconfig, gint priority, GMainContext *mcontext, NetGSource *iosrc, ConfigContext *config, gsize objsize)
 ArpDiscovery constructor - good for listening to ARP packets via pcap. More...
 
FSTATIC void _arpdiscovery_sendarpcache (ArpDiscovery *self)
 Function for sending the ARP info in JSON to the CMA. More...
 

Detailed Description

Class providing an ARP Discovery class for discovering IP/MAC address resolution - subclass of Discovery class.

We deal with the ARP protocol in order to "hear" our IP/MAC address configuration.

Function Documentation

FSTATIC gboolean _arpdiscovery_discover ( Discovery self)

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

Parameters
[in,out]self

Definition at line 132 of file arpdiscovery.c.

References FSTATIC.

Referenced by arpdiscovery_new().

Here is the caller graph for this function:

FSTATIC gboolean _arpdiscovery_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 an ARP packet.

It examines the ARP packet and sees if it is the same IP address and MAC address as previously discovered. A hash table is built of IP/MAC addresses. If the IP address is new, it adds it to the hash table. If not new, then it checks to see if the corresponding MAC address has changed. If so, then it adds it to the hash table. All we really care about are those two fields (Sender IP & MAC addresses)–the rest we leave to the CMA.

< Hardware type (network byte order)

< Protocol type (network byte order)

< Hardware address length (should be 6 or 8)

< Protocol address lenght (should be 4 for IPV4 addresses)

< opcode (net byte order - we care about 1 and 2)

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 177 of file arpdiscovery.c.

References _Discovery::_config, ARP_HDR_LEN, ARP_HLN_LEN, ARP_HRD_LEN, ARP_PKT_OFFSET, ARP_PLN_LEN, ARP_PRO_LEN, _NetAddr::baseclass, CASTTOCLASS, CONFIGNAME_CMADISCOVER, DEBUGMSG3, cma.drawwithdot::dest, _NetAddr::equal, _ConfigContext::getaddr, netaddr_ipv4_new(), netaddr_macaddr_new(), tlv_get_guint16(), tlv_get_guint8(), _NetAddr::toIPv6, _AssimObj::toString, and UNREF.

Referenced by arpdiscovery_new().

Here is the call graph for this function:

Here is the caller graph for this function:

FSTATIC void _arpdiscovery_finalize ( AssimObj self)

finalize a ArpDiscovery object

Definition at line 105 of file arpdiscovery.c.

References CASTTOCLASS, FSTATIC, g_info, and UNREF.

Referenced by arpdiscovery_new().

Here is the caller graph for this function:

FSTATIC gboolean _arpdiscovery_first_discovery ( gpointer  gself)

A GSourceFunc to be called for the first (random) discovery only

Parameters
[in,out]gselfPointer to 'self'

Definition at line 141 of file arpdiscovery.c.

References _arpdiscovery_gsourcefunc(), _arpdiscovery_sendarpcache(), CASTTOCLASS, CONFIGNAME_INTERVAL, DEBUGMSG3, and FSTATIC.

Referenced by arpdiscovery_new().

Here is the call graph for this function:

Here is the caller graph for this function:

FSTATIC gboolean _arpdiscovery_gsourcefunc ( gpointer  gself)

Function which periodically sends our ARP cache upstream.

Parameters
[in,out]gselfPointer to 'self'

Definition at line 162 of file arpdiscovery.c.

References _arpdiscovery_sendarpcache(), CASTTOCLASS, and FSTATIC.

Referenced by _arpdiscovery_first_discovery().

Here is the call graph for this function:

Here is the caller graph for this function:

FSTATIC void _arpdiscovery_sendarpcache ( ArpDiscovery self)

Function for sending the ARP info in JSON to the CMA.

Definition at line 358 of file arpdiscovery.c.

References configcontext_new_JSON_string(), DEBUG, DEBUGMSG3, FREE, and UNREF.

Referenced by _arpdiscovery_first_discovery(), and _arpdiscovery_gsourcefunc().

Here is the call graph for this function:

Here is the caller graph for this function:

ArpDiscovery* arpdiscovery_new ( ConfigContext arpconfig,
gint  priority,
GMainContext *  mcontext,
NetGSource iosrc,
ConfigContext config,
gsize  objsize 
)

ArpDiscovery constructor - good for listening to ARP packets via pcap.

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

Definition at line 286 of file arpdiscovery.c.

References _arpdiscovery_discover(), _arpdiscovery_dispatch(), _arpdiscovery_finalize(), _arpdiscovery_first_discovery(), _AssimObj::_finalize, _ArpDiscovery::arpconfig, _ArpDiscovery::ArpMap, _ArpDiscovery::ArpMapData, _Discovery::baseclass, BINDDEBUG, configcontext_new_JSON_string(), CONFIGNAME_DEVNAME, CONFIGNAME_INSTANCE, CONFIGNAME_INTERVAL, DEBUGMSG3, DEFAULT_ARP_SENDINTERVAL, _Discovery::discover, discovery_new(), discovery_register(), DUMP3, ENABLE_ARP, _ArpDiscovery::finalize, FSTATIC, g_source_pcap_new(), _ConfigContext::getconfig, _ConfigContext::getint, _ConfigContext::getstring, nano_random, NEWSUBCLASS, proj_get_sysname(), REF, _ConfigContext::setint, _ConfigContext::setstring, _ArpDiscovery::source, and _ArpDiscovery::timeout_source.

Referenced by nano_schedule_discovery().

Here is the call graph for this function:

Here is the caller graph for this function: