|
The Assimilation Monitoring Project
|
Simple pcap testing code using 'mainloop'. More...
#include <projectcommon.h>#include <stdlib.h>#include <stdio.h>#include <string.h>#include <framesettypes.h>#include <frameset.h>#include <ctype.h>#include <netgsource.h>#include <reliableudp.h>#include <netaddr.h>#include <authlistener.h>#include <signframe.h>#include <cryptframe.h>#include <compressframe.h>#include <intframe.h>#include <addrframe.h>#include <cstringframe.h>#include <frametypes.h>#include <nanoprobe.h>#include <resourcecmd.h>#include <cmalib.h>
Go to the source code of this file.
Macros | |
| #define | TESTPORT 1984 |
| #define | OCFCLASS "\"" REQCLASSNAMEFIELD "\": \"ocf\"" |
| #define | HBPROVIDER "\"" REQPROVIDERNAMEFIELD "\": \"heartbeat\"" |
| #define | DUMMYTYPE "\"" REQTYPENAMEFIELD "\": \"Dummy\"" |
| #define | STARTOP "\"" REQOPERATIONNAMEFIELD "\": \"start\"" |
| #define | STOPOP "\"" REQOPERATIONNAMEFIELD "\": \"stop\"" |
| #define | MONITOROP "\"" REQOPERATIONNAMEFIELD "\": \"monitor\"" |
| #define | METADATAOP "\"" REQOPERATIONNAMEFIELD "\": \"meta-data\"" |
| #define | RESOURCENAME "\"" REQRSCNAMEFIELD "\": \"DummyTestGTest01\"" |
| #define | NULLPARAMS "\"" REQENVIRONNAMEFIELD "\": {}" |
| #define | C "," |
| #define | REQID(id) "\"" REQIDENTIFIERNAMEFIELD "\": " #id |
| #define | REPEAT(repeat) "\"" REQREPEATNAMEFIELD "\": " #repeat |
| #define | INITDELAY(delay) "\"" REQINITDELAYNAMEFIELD "\": " #delay |
| #define | COMMREQUEST OCFCLASS C HBPROVIDER C DUMMYTYPE C RESOURCENAME C NULLPARAMS |
| #define | REQUEST(type, id, repeat, delay) "{" COMMREQUEST C type C REQID(id) C REPEAT(repeat) C INITDELAY(delay)"}" |
| #define | START REQUEST(STARTOP, 1, 0, 0) |
| #define | MONITOR REQUEST(MONITOROP, 2, 1, 0) |
| #define | STOP REQUEST(STOPOP, 3, 0, 5) |
Functions | |
| gboolean | gotnetpkt (Listener *l,FrameSet *fs,NetAddr *srcaddr) |
| Test routine called when an otherwise-unclaimed NetIO packet is received. More... | |
| void | got_heartbeat (HbListener *who) |
| void | got_heartbeat2 (HbListener *who) |
| void | check_JSON (FrameSet *fs) |
| void | fakecma_startup (AuthListener *auth, FrameSet *ifs, NetAddr *nanoaddr) |
| Routine to pretend to be the initial CMA. More... | |
| gboolean | timeout_agent (gpointer ignored) |
| Called every second during tests. More... | |
| int | main (int argc, char **argv) |
| Test program looping and reading LLDP/CDP packets and exercising most of the packet send/receive mechanism and a good bit of nanoprobe and CMA basic infrastructure. More... | |
Variables | |
| int | errcount |
| error count More... | |
| NanoHbStats | nano_hbstats |
| GMainLoop * | mainloop |
| gtest01.c - miscellaneous glib mainloop-based tests. More... | |
| int | expected_dead_count = 1 |
| gint64 | maxpkts = G_MAXINT64 |
| gint64 | pktcount = 0 |
| NetIO * | nettransport |
| NetGSource * | netpkt |
| NetAddr * | destaddr |
| NetAddr * | otheraddr |
| NetAddr * | otheraddr2 |
| NetAddr * | anyaddr |
| int | wirepktcount = 0 |
| int | heartbeatcount = 0 |
| int | pcapcount = 0 |
| ObeyFrameSetTypeMap | cmalist [] |
| ConfigContext * | nanoconfig |
Simple pcap testing code using 'mainloop'.
Listens for CDP or LLDP packets on the network - all using the mainloop dispatch code. Probably a short-lived piece of test code. Well... Maybe not so short-lived, but definitely basic testing.
Here's what it does at the moment:
This file is part of the Assimilation Project.
The Assimilation software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with the Assimilation Project software. If not, see http://www.gnu.org/licenses/
Definition in file pcap+mainloop.c.
| #define C "," |
Definition at line 202 of file pcap+mainloop.c.
| #define COMMREQUEST OCFCLASS C HBPROVIDER C DUMMYTYPE C RESOURCENAME C NULLPARAMS |
Definition at line 206 of file pcap+mainloop.c.
| #define DUMMYTYPE "\"" REQTYPENAMEFIELD "\": \"Dummy\"" |
Definition at line 195 of file pcap+mainloop.c.
| #define HBPROVIDER "\"" REQPROVIDERNAMEFIELD "\": \"heartbeat\"" |
Definition at line 194 of file pcap+mainloop.c.
| #define INITDELAY | ( | delay | ) | "\"" REQINITDELAYNAMEFIELD "\": " #delay |
Definition at line 205 of file pcap+mainloop.c.
| #define METADATAOP "\"" REQOPERATIONNAMEFIELD "\": \"meta-data\"" |
Definition at line 199 of file pcap+mainloop.c.
Definition at line 210 of file pcap+mainloop.c.
Referenced by fakecma_startup().
| #define MONITOROP "\"" REQOPERATIONNAMEFIELD "\": \"monitor\"" |
Definition at line 198 of file pcap+mainloop.c.
| #define NULLPARAMS "\"" REQENVIRONNAMEFIELD "\": {}" |
Definition at line 201 of file pcap+mainloop.c.
| #define OCFCLASS "\"" REQCLASSNAMEFIELD "\": \"ocf\"" |
Definition at line 193 of file pcap+mainloop.c.
| #define REPEAT | ( | repeat | ) | "\"" REQREPEATNAMEFIELD "\": " #repeat |
Definition at line 204 of file pcap+mainloop.c.
| #define REQID | ( | id | ) | "\"" REQIDENTIFIERNAMEFIELD "\": " #id |
Definition at line 203 of file pcap+mainloop.c.
| #define REQUEST | ( | type, | |
| id, | |||
| repeat, | |||
| delay | |||
| ) | "{" COMMREQUEST C type C REQID(id) C REPEAT(repeat) C INITDELAY(delay)"}" |
Definition at line 207 of file pcap+mainloop.c.
| #define RESOURCENAME "\"" REQRSCNAMEFIELD "\": \"DummyTestGTest01\"" |
Definition at line 200 of file pcap+mainloop.c.
Definition at line 209 of file pcap+mainloop.c.
Referenced by fakecma_startup().
| #define STARTOP "\"" REQOPERATIONNAMEFIELD "\": \"start\"" |
Definition at line 196 of file pcap+mainloop.c.
Definition at line 211 of file pcap+mainloop.c.
Referenced by fakecma_startup().
| #define STOPOP "\"" REQOPERATIONNAMEFIELD "\": \"stop\"" |
Definition at line 197 of file pcap+mainloop.c.
| #define TESTPORT 1984 |
Definition at line 63 of file pcap+mainloop.c.
Referenced by main().
| void check_JSON | ( | FrameSet * | fs | ) |
Definition at line 106 of file pcap+mainloop.c.
References _CstringFrame::baseclass, _ConfigContext::baseclass, CASTTOCLASS, cma.cma::config, configcontext_new_JSON_string(), errcount, _FrameSet::framelist, FRAMETYPE_JSDISCOVER, _FrameSet::fstype, _AssimObj::toString, _Frame::type, UNREF, and _Frame::value.
Referenced by fakecma_startup().


| void fakecma_startup | ( | AuthListener * | auth, |
| FrameSet * | fs, | ||
| NetAddr * | nanoaddr | ||
| ) |
Routine to pretend to be the initial CMA.
Definition at line 215 of file pcap+mainloop.c.
References _NetGSource::_netio, _CstringFrame::baseclass, _AuthListener::baseclass, _NetAddr::baseclass, check_JSON(), _Listener::config, create_sendexpecthb(), create_setconfig(), cstringframe_new(), DEFAULT_FSP_QID, DIMOF, frameset_append_frame(), frameset_new(), FRAMESETTYPE_DORSCOP, FRAMESETTYPE_SENDEXPECTHB, FRAMETYPE_RSCJSON, MONITOR, _NetAddr::port, _NetIO::sendareliablefs(), _Frame::setvalue, START, STOP, _AssimObj::toString, _Listener::transport, UNREF, and UNREF2.

| void got_heartbeat | ( | HbListener * | who | ) |
| void got_heartbeat2 | ( | HbListener * | who | ) |
Test routine called when an otherwise-unclaimed NetIO packet is received.
| [in,out] | l | Input GSource |
| [in,out] | fs | FrameSets received |
| [in] | srcaddr | Source address of this packet |
| int main | ( | int | argc, |
| char ** | argv | ||
| ) |
Test program looping and reading LLDP/CDP packets and exercising most of the packet send/receive mechanism and a good bit of nanoprobe and CMA basic infrastructure.
It plays both sides of the game - the CMA and the nanoprobe.
It leaves most of the work of starting up the nanoprobe code to nano_start_full()
Definition at line 271 of file pcap+mainloop.c.
References _NetGSource::addListener, _Listener::associate, authlistener_new(), _NetIOudp::baseclass, _SignFrame::baseclass, _AuthListener::baseclass, _ReliableUDP::baseclass, _NetGSource::baseclass, _NetIO::bindaddr(), cma.cma::config, configcontext_new(), CONFIGNAME_CMAADDR, CONFIGNAME_CMADISCOVER, CONFIGNAME_CMAFAIL, CONFIGNAME_CMAINIT, CONFIGNAME_CMAPORT, CONFIGNAME_DEADTIME, CONFIGNAME_HBPORT, CONFIGNAME_HBTIME, CONFIGNAME_OUTSIG, CONST_ASSIM_DEFAULT_V4_MCAST, CONST_IPV6_LOOPBACK, _Listener::dissociate, errcount, FMT_64BIT, _Listener::got_frameset, gotnetpkt(), listener_new(), mainloop, maxpkts, _NetIO::mcastjoin(), nano_packet_decoder(), nano_shutdown(), nano_start_full(), netaddr_ipv4_new(), netaddr_ipv6_new(), netgsource_new(), netio_is_dual_ipv4v6_stack(), proj_class_dump_live_objects(), proj_class_finalize_sys(), proj_class_incr_debug(), proj_class_live_object_count(), reliableudp_new(), _ConfigContext::setaddr, _ConfigContext::setframe, _ConfigContext::setint, signframe_new(), TESTPORT, timeout_agent(), UNREF, UNREF2, and wirepktcount.

| gboolean timeout_agent | ( | gpointer | ignored | ) |
Called every second during tests.
Definition at line 179 of file pcap+mainloop.c.
References _ReliableUDP::_protocol, CASTTOCLASS, _FsProtocol::closeall, _NanoHbStats::heartbeat_count, cma.cma::io, maxpkts, and nano_initiate_shutdown().
Referenced by main().


| NetAddr* anyaddr |
Definition at line 84 of file pcap+mainloop.c.
Referenced by main().
| ObeyFrameSetTypeMap cmalist[] |
Definition at line 97 of file pcap+mainloop.c.
| NetAddr* destaddr |
Definition at line 81 of file pcap+mainloop.c.
| int expected_dead_count = 1 |
Definition at line 75 of file pcap+mainloop.c.
| int heartbeatcount = 0 |
Definition at line 86 of file pcap+mainloop.c.
| gint64 maxpkts = G_MAXINT64 |
Definition at line 76 of file pcap+mainloop.c.
Referenced by main(), and timeout_agent().
| ConfigContext* nanoconfig |
Definition at line 103 of file pcap+mainloop.c.
| NetGSource* netpkt |
Definition at line 80 of file pcap+mainloop.c.
| NetIO* nettransport |
Definition at line 79 of file pcap+mainloop.c.
| NetAddr* otheraddr |
Definition at line 82 of file pcap+mainloop.c.
| NetAddr* otheraddr2 |
Definition at line 83 of file pcap+mainloop.c.
| int pcapcount = 0 |
Definition at line 87 of file pcap+mainloop.c.
| gint64 pktcount = 0 |
Definition at line 77 of file pcap+mainloop.c.
| int wirepktcount = 0 |
Definition at line 85 of file pcap+mainloop.c.