The Assimilation Project  based on Assimilation version 0.5.1435932971
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
pcap+mainloop.c
Go to the documentation of this file.
1 
37 #include <projectcommon.h>
38 #include <stdlib.h>
39 #include <stdio.h>
40 #include <string.h>
41 #ifdef HAVE_MCHECK_H
42 # include <mcheck.h>
43 #endif
44 #include <framesettypes.h>
45 #include <frameset.h>
46 #include <ctype.h>
47 #include <netgsource.h>
48 #include <reliableudp.h>
49 #include <netaddr.h>
50 #include <authlistener.h>
51 #include <signframe.h>
52 #include <cryptframe.h>
53 #include <compressframe.h>
54 #include <intframe.h>
55 #include <addrframe.h>
56 #include <cstringframe.h>
57 #include <frametypes.h>
58 #include <nanoprobe.h>
59 #include <resourcecmd.h>
60 #include <cmalib.h>
61 #include <cryptcurve25519.h>
62 
63 
64 #define TESTPORT 1984
65 #define CRYPTO_KEYID CMA_KEY_PREFIX "999999b"
66 
67 #ifdef WIN32
68 WINIMPORT int errcount;
69 WINIMPORT NanoHbStats nano_hbstats;
70 WINIMPORT GMainLoop* mainloop;
71 #else
72 extern int errcount;
74 GMainLoop* mainloop;
75 #endif
76 
78 gint64 maxpkts = G_MAXINT64;
79 gint64 pktcount = 0;
80 GMainLoop* mainloop;
87 int wirepktcount = 0;
88 
89 gboolean gotnetpkt(Listener*, FrameSet* fs, NetAddr* srcaddr);
90 void got_heartbeat(HbListener* who);
91 void got_heartbeat2(HbListener* who);
92 void check_JSON(FrameSet* fs);
93 FSTATIC gboolean test_cma_authentication(const FrameSet*fs, NetAddr*);
94 
96 gboolean timeout_agent(gpointer ignored);
97 
100  {0, NULL},
101 };
102 
103 
105 
106 void
108 {
109  GSList* fptr;
110  int jsoncount = 0;
111  int errcount = 0;
112 
113  //g_debug("Frameset type is: %d", fs->fstype);
114  for (fptr=fs->framelist; fptr; fptr=fptr->next) {
115  Frame* frame = CASTTOCLASS(Frame, fptr->data);
116  CstringFrame* csf;
118  //g_debug("Frame type is: %d", frame->type);
119  if (frame->type != FRAMETYPE_JSDISCOVER) {
120  continue;
121  }
122  ++jsoncount;
123  // Ahh! JSON data. Let's parse it!
124  csf = CASTTOCLASS(CstringFrame, frame);
126  if (config == NULL) {
127  g_warning("JSON text did not parse correctly [%s]"
128  , (char*)csf->baseclass.value);
129  ++errcount;
130  }else{
131  char * tostr = config->baseclass.toString(config);
132  g_message("PARSED JSON: %s", tostr);
133  g_free(tostr); tostr = NULL;
134  UNREF(config);
135  }
136  }
137  g_message("%d JSON strings parsed. %d errors.", jsoncount, errcount);
138 }
139 
141 gboolean
143  FrameSet* fs,
144  NetAddr* srcaddr
145  )
146 {
147  (void)l; (void)srcaddr;
148  ++wirepktcount;
149  switch(fs->fstype) {
150  case FRAMESETTYPE_HBDEAD:
151  g_message("CMA Received dead host notification (type %d) over the 'wire'."
152  , fs->fstype);
153  break;
155  g_message("CMA Received switch discovery data (type %d) over the 'wire'."
156  , fs->fstype);
157  break;
159  g_message("CMA Received JSON discovery data (type %d) over the 'wire'."
160  , fs->fstype);
161  check_JSON(fs);
162  break;
164  g_message("CMA Received resource operation data (type %d) over the 'wire'."
165  , fs->fstype);
166  check_JSON(fs);
167  break;
168  default:{
169  char * fsstr = fs->baseclass.toString(&fs->baseclass);
170  g_message("CMA Received a FrameSet of type %d [%s] over the 'wire'."
171  , fs->fstype, fsstr);
172  FREE(fsstr); fsstr = NULL;
173  }
174  }
175 
176  l->transport->_netio->ackmessage(l->transport->_netio, srcaddr, fs);
177  UNREF(fs);
178  if (wirepktcount >= maxpkts) {
179  g_message("QUITTING NOW - wirepktcount!");
181  return FALSE;
182  }
183  return TRUE;
184 }
185 
187 gboolean
188 timeout_agent(gpointer ignored)
189 {
190  ReliableUDP* io = CASTTOCLASS(ReliableUDP, nettransport);
191 
192  (void)ignored;
193  if (nano_hbstats.heartbeat_count > (unsigned)maxpkts) {
194  g_message("QUITTING NOW! (heartbeat count)");
195  io->_protocol->closeall(io->_protocol);
197  return FALSE;
198  }
199  return TRUE;
200 }
201 
202 #define OCFCLASS "\"" REQCLASSNAMEFIELD "\": \"ocf\""
203 #define HBPROVIDER "\"" REQPROVIDERNAMEFIELD "\": \"heartbeat\""
204 #define DUMMYTYPE "\"" CONFIGNAME_TYPE "\": \"Dummy\""
205 #define STARTOP "\"" REQOPERATIONNAMEFIELD "\": \"start\""
206 #define STOPOP "\"" REQOPERATIONNAMEFIELD "\": \"stop\""
207 #define UMONITOROP "\"" REQOPERATIONNAMEFIELD "\": \""MONITOROP"\""
208 #define UMETADATAOP "\"" REQOPERATIONNAMEFIELD "\": \""METADATAOP"\""
209 #define RESOURCENAME "\"" CONFIGNAME_INSTANCE "\": \"DummyTestGTest01\""
210 #define NULLPARAMS "\"" REQENVIRONNAMEFIELD "\": {}"
211 #define C ","
212 #define REQID(id) "\"" REQIDENTIFIERNAMEFIELD "\": " #id
213 #define REPEAT(repeat) "\"" REQREPEATNAMEFIELD "\": " #repeat
214 #define INITDELAY(delay) "\"" CONFIGNAME_INITDELAY "\": " #delay
215 #define COMMREQUEST OCFCLASS C HBPROVIDER C DUMMYTYPE C RESOURCENAME C NULLPARAMS
216 #define REQUEST(type,id, repeat,delay) \
217  "{" COMMREQUEST C type C REQID(id) C REPEAT(repeat) C INITDELAY(delay)"}"
218 #define START REQUEST(STARTOP, 1, 0, 0) // One shot - no delay
219 #define MONITOR REQUEST(UMONITOROP, 2, 0, 0) // Repeat every second - no delay
220 #define STOP REQUEST(STOPOP, 3, 0, 5) // No repeat - 5 second delay
221 
222 #define ETHNAME "eth0"
223 #define ETHDEV "\"" CONFIGNAME_DEVNAME "\": \"" ETHNAME "\""
224 #define SWTYPE "\"" CONFIGNAME_TYPE "\": \"#SWITCH\""
225 #define SWINST "\"" CONFIGNAME_INSTANCE "\": \"#_SWITCH_" ETHNAME "\""
226 #define SWINSTNM "#_SWITCH_" ETHNAME
227 #define SWPROTOS "\"" CONFIGNAME_SWPROTOS "\": [\"lldp\", \"cdp\"]"
228 #define ARPTYPE "\"" CONFIGNAME_TYPE "\": \"#ARP\""
229 #define ARPINST "\"" CONFIGNAME_INSTANCE "\": \"#_ARP_" ETHNAME "\""
230 #define ARPINSTNM "#_ARP_" ETHNAME
231 #define SWITCHDISCOVER "{" SWTYPE ", " SWINST ", " ETHDEV ", " SWPROTOS "}"
232 #define ARPDISCOVER "{" ARPTYPE ", " ARPINST ", " ETHDEV "}"
233 
235 void
237 {
238  FrameSet* pkt;
239  NetGSource* netpkt = auth->baseclass.transport;
240  char * nanostr = nanoaddr->baseclass.toString(nanoaddr);
241  GSList* thisgsf;
242  const char * keyid = NULL;
243 
244  (void)ifs;
245  g_message("CMA received startup message from nanoprobe at address %s/%d."
246  , nanostr, nanoaddr->port(nanoaddr));
247  g_free(nanostr); nanostr = NULL;
248  check_JSON(ifs);
249 
250  netpkt->_netio->addalias(netpkt->_netio, nanoaddr, destaddr);
251 
252  // Set up our crypto...
257  for (thisgsf = ifs->framelist; thisgsf; thisgsf=thisgsf->next) {
258  Frame* thisframe = CASTTOCLASS(Frame, thisgsf->data);
259  if (thisframe->type == FRAMETYPE_KEYID) {
260  CstringFrame* csf = CASTTOCLASS(CstringFrame, thisframe);
261  keyid = (const char *)csf->baseclass.value;
262  }else if (keyid && thisframe->type == FRAMETYPE_PUBKEYCURVE25519) {
263  cryptcurve25519_save_public_key(keyid, thisframe->value
264  , thisframe->length);
265  }
266  }
267 
268  // Send the configuration data to our new "client"
269  pkt = create_setconfig(nanoconfig);
270  netpkt->_netio->sendareliablefs(netpkt->_netio, nanoaddr, DEFAULT_FSP_QID, pkt);
271  UNREF(pkt);
272 
273  // Now tell them to send/expect heartbeats to various places
275  netpkt->_netio->sendareliablefs(netpkt->_netio, nanoaddr, DEFAULT_FSP_QID, pkt);
276  UNREF(pkt);
277 
278  {
279  const char * monopjson[] = { START, MONITOR, STOP};
280  unsigned j;
281  // Create a frameset for a few resource operations
283  for (j=0; j < DIMOF(monopjson); j++) {
285  csf->baseclass.setvalue(&csf->baseclass, g_strdup(monopjson[j])
286  , strlen(monopjson[j])+1, g_free);
287  frameset_append_frame(pkt, &csf->baseclass);
288  UNREF2(csf);
289  }
290  netpkt->_netio->sendareliablefs(netpkt->_netio, nanoaddr, DEFAULT_FSP_QID, pkt);
291  UNREF(pkt);
292  }
293  {
294  const char * discoverjson[] = {SWITCHDISCOVER, ARPDISCOVER};
295  const char * discoverinstnm[] = {SWINSTNM, ARPINSTNM};
296  unsigned j;
297  // Create a frameset for a few discovery operations
299  for (j=0; j < DIMOF(discoverjson); j++) {
302  fprintf(stderr, "Creating discovery frameset: %s: %s\n"
303  , discoverinstnm[j]
304  , discoverjson[j]);
305  inst->baseclass.setvalue(&inst->baseclass, g_strdup(discoverjson[j])
306  , strlen(discoverjson[j])+1, g_free);
307  frameset_append_frame(pkt, &inst->baseclass);
308  UNREF2(inst);
309  csf->baseclass.setvalue(&csf->baseclass, g_strdup(discoverjson[j])
310  , strlen(discoverjson[j])+1, g_free);
311  frameset_append_frame(pkt, &csf->baseclass);
312  UNREF2(csf);
313  }
314  netpkt->_netio->sendareliablefs(netpkt->_netio, nanoaddr, DEFAULT_FSP_QID, pkt);
315  UNREF(pkt);
316  }
318  netpkt->_netio->sendareliablefs(netpkt->_netio, nanoaddr, DEFAULT_FSP_QID, pkt);
319  UNREF(pkt);
320  g_info("ACKSTARTUP packet queued to send");
321 }
322 
324 FSTATIC gboolean
326 {
327  gpointer maybecrypt = g_slist_nth_data(fs->framelist, 1);
328  Frame* mightbecrypt;
329  (void)fromaddr;
331  g_return_val_if_fail(maybecrypt != NULL, FALSE);
332  mightbecrypt = CASTTOCLASS(Frame, maybecrypt);
333  if (mightbecrypt->type != FRAMETYPE_CRYPTCURVE25519) {
334  DUMP("test_cma_authentication: ", &fs->baseclass, " was BAD");
335  return FALSE;
336  }
337  return TRUE;
338 }
339 
348 int
349 main(int argc, char **argv)
350 {
351  const guint8 loopback[] = CONST_IPV6_LOOPBACK;
352  //const guint8 mcastaddrstring[] = CONST_ASSIM_DEFAULT_V4_MCAST;
353  //NetAddr* mcastaddr;
354  const guint8 otheradstring[] = {127,0,0,1};
355  const guint8 otheradstring2[] = {10,10,10,4};
356  const guint8 anyadstring[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
357  guint16 testport = TESTPORT;
358  SignFrame* signature = signframe_glib_new(G_CHECKSUM_SHA256, 0);
359  Listener* otherlistener;
361  PacketDecoder* decoder = nano_packet_decoder();
362  AuthListener* listentonanoprobes;
363  ReliableUDP* rtransport;
364 
365 #if 0
366 # ifdef HAVE_MCHECK_PEDANTIC
367  g_assert(mcheck_pedantic(NULL) == 0);
368 # else
369 # ifdef HAVE_MCHECK
370  g_assert(mcheck(NULL) == 0);
371 # endif
372 # endif
373 #endif
374  g_setenv("G_MESSAGES_DEBUG", "all", TRUE);
375 #if 0
376  proj_class_incr_debug(NULL);
377  proj_class_incr_debug(NULL);
378  proj_class_incr_debug(NULL);
379  proj_class_incr_debug(NULL);
380 #endif
381  g_log_set_fatal_mask(NULL, G_LOG_LEVEL_ERROR);
382 
383  if (argc > 1) {
384  maxpkts = atol(argv[1]);
385  g_debug("Max packet count is "FMT_64BIT"d", maxpkts);
386  }
387 
389  g_message("Our OS supports dual ipv4/v6 sockets. Hurray!");
390  }else{
391  g_warning("Our OS DOES NOT support dual ipv4/v6 sockets - this may not work!!");
392  }
393 
394 
395  config->setframe(config, CONFIGNAME_OUTSIG, &signature->baseclass);
396 
397  // Create a network transport object for normal UDP packets
398  rtransport = reliableudp_new(0, config, decoder, 0);
399  rtransport->_protocol->window_size = 8;
400  nettransport = &(rtransport->baseclass.baseclass);
401  g_return_val_if_fail(NULL != nettransport, 2);
402 
403  // Set up the parameters the 'CMA' is going to send to our 'nanoprobe'
404  // in response to their request for configuration data.
405  nanoconfig = configcontext_new(0);
406  nanoconfig->setint(nanoconfig, CONFIGNAME_INTERVAL, 1);
407  nanoconfig->setint(nanoconfig, CONFIGNAME_TIMEOUT, 3);
408  nanoconfig->setint(nanoconfig, CONFIGNAME_CMAPORT, testport);
409 
410 
411  // Construct the NetAddr we'll talk to (i.e., ourselves) and listen from
412  destaddr = netaddr_ipv6_new(loopback, testport);
413  g_return_val_if_fail(NULL != destaddr, 3);
414  config->setaddr(config, CONFIGNAME_CMAINIT, destaddr);
415  nanoconfig->setaddr(nanoconfig, CONFIGNAME_CMAADDR, destaddr);
416  nanoconfig->setaddr(nanoconfig, CONFIGNAME_CMAFAIL, destaddr);
417  nanoconfig->setaddr(nanoconfig, CONFIGNAME_CMADISCOVER, destaddr);
418 
419  // Construct another couple of NetAddrs to talk to and listen from
420  // for good measure...
421  otheraddr = netaddr_ipv4_new(otheradstring, testport);
422  g_return_val_if_fail(NULL != otheraddr, 4);
423  otheraddr2 = netaddr_ipv4_new(otheradstring2, testport);
424  g_return_val_if_fail(NULL != otheraddr2, 4);
425 
426  // Construct another NetAddr to bind to (anything)
427  anyaddr = netaddr_ipv6_new(anyadstring, testport);
428  g_return_val_if_fail(NULL != destaddr, 5);
429 
430  // Bind to ANY address (as noted above)
431  g_return_val_if_fail(nettransport->bindaddr(nettransport, anyaddr, FALSE),16);
432  //g_return_val_if_fail(nettransport->bindaddr(nettransport, destaddr),16);
433 
434  g_message("NOT Joining multicast address.");
435 #if 0
436  // We can't do this because of encryption and we will likely screw up
437  // others on our network even if that weren't a problem...
438  mcastaddr = netaddr_ipv4_new(mcastaddrstring, testport);
439  g_return_val_if_fail(nettransport->mcastjoin(nettransport, mcastaddr, NULL), 17);
440  UNREF(mcastaddr);
441  g_message("multicast join succeeded.");
442 #endif
443 
444  // Connect up our network transport into the g_main_loop paradigm
445  // so we get dispatched when packets arrive
446  netpkt = netgsource_new(nettransport, NULL, G_PRIORITY_HIGH, FALSE, NULL, 0, NULL);
447 
448  // Set up so that we can observe all unclaimed packets
449  otherlistener = listener_new(config, 0);
450  otherlistener->got_frameset = gotnetpkt;
451  netpkt->addListener(netpkt, 0, otherlistener);
452  otherlistener->associate(otherlistener,netpkt);
453 
454  // Unref the "other" listener - we hold other references to it
455  UNREF(otherlistener);
456 
457  // Pretend to be the CMA...
458  // Listen for packets from our nanoprobes - scattered throughout space...
459  listentonanoprobes = authlistener_new(0, cmalist, config, TRUE, NULL);
460  listentonanoprobes->baseclass.associate(&listentonanoprobes->baseclass, netpkt);
461 
462  nano_start_full("netconfig", 900, netpkt, config, test_cma_authentication);
463 
464  g_timeout_add_seconds(1, timeout_agent, NULL);
465  mainloop = g_main_loop_new(g_main_context_default(), TRUE);
466 
467  /********************************************************************
468  * Start up the main loop - run our test program...
469  * (the one pretending to be both the nanoprobe and the CMA)
470  ********************************************************************/
471  g_main_loop_run(mainloop);
472 
473  /********************************************************************
474  * We exited the main loop. Shut things down.
475  ********************************************************************/
476 
477  nano_shutdown(TRUE); // Tell it to shutdown and print stats
478  g_message("Count of 'other' pkts received:\t%d", wirepktcount);
479 
480  UNREF(nettransport);
481 
482  // Main loop is over - shut everything down, free everything...
483  g_main_loop_unref(mainloop); mainloop=NULL;
484 
485 
486  // Unlink misc dispatcher - this should NOT be necessary...
487  netpkt->addListener(netpkt, 0, NULL);
488 
489  // Dissociate packet actions from the packet source.
490  listentonanoprobes->baseclass.dissociate(&listentonanoprobes->baseclass);
491 
492  // Unref the AuthListener object
493  UNREF2(listentonanoprobes);
494 
495  g_source_destroy(&netpkt->baseclass);
496  g_source_unref(&netpkt->baseclass);
497  //g_main_context_unref(g_main_context_default());
498 
499  // Free signature frame
500  UNREF2(signature);
501 
502  // Free misc addresses
503  UNREF(destaddr);
504  UNREF(otheraddr);
505  UNREF(otheraddr2);
506  UNREF(anyaddr);
507 
508  // Free config object
509  UNREF(config);
510  UNREF(nanoconfig);
511 
512 
513  // At this point - nothing should show up - we should have freed everything
514  if (proj_class_live_object_count() > 0) {
515  g_warning("Too many objects (%d) alive at end of test.",
518  ++errcount;
519  }else{
520  g_message("No objects left alive. Awesome!");
521  }
522  proj_class_finalize_sys(); // Shut down object system to make valgrind happy :-D
523  return(errcount <= 127 ? errcount : 127);
524 }
WINEXPORT gboolean cryptframe_set_dest_key_id(NetAddr *destaddr, const char *key_id)
Set the encryption key to use when sending to destaddr Set destkey to NULL to stop encrypting to that...
Definition: cryptframe.c:470
ConfigContext * configcontext_new_JSON_string(const char *jsontext)
Construct a ConfigContext object from the given JSON string.
Listener baseclass
Definition: authlistener.h:42
#define FRAMESETTYPE_HBDEAD
System named in packet appears to be dead.
Definition: framesettypes.h:39
#define CONFIGNAME_CMADISCOVER
Address of where to send discovery reports.
#define CONFIGNAME_INTERVAL
How long to wait between events.
void check_JSON(FrameSet *fs)
GSource baseclass
Parent GSource Object pointer.
Definition: netgsource.h:44
AssimObj baseclass
Definition: frameset.h:47
guint32 length
Frame Length.
Definition: frame.h:46
#define FRAMESETTYPE_JSDISCOVERY
Packet contains JSON-formatted discovery data.
Definition: framesettypes.h:45
guint16(* port)(const NetAddr *self)
Return port from this address.
Definition: netaddr.h:46
Structure associating FrameSet class types with actions to perform when they're received.
Definition: authlistener.h:51
NetIO * _netio
netio this object is based on
Definition: netgsource.h:50
PacketDecoder * nano_packet_decoder(void)
Return our nanoprobe packet decoder map.
Definition: nanoprobe.c:1292
gint64 pktcount
Definition: pcap+mainloop.c:79
#define CONFIGNAME_CMAPORT
Default Port for contacting the CMA.
void(* addalias)(NetIO *, NetAddr *, NetAddr *)
Add an alias to our received address alias table.
Definition: netio.h:87
Describes interfaces to Signature Frame (Signframe) C-Class - providing digital signatures.
Listener * listener_new(ConfigContext *config, gsize objsize)
Construct a new Listener - setting up GSource and timeout data structures for it. ...
Definition: listener.c:82
NetIOudp is a NetIOudp class subclass specialized to provide reliable UDP connections.
Definition: reliableudp.h:43
WINEXPORT SignFrame * signframe_glib_new(GChecksumType sigtype, gsize framesize)
Construct a new SignFrame - allowing for "derived" frame types...
Definition: signframe.c:334
GMainLoop * mainloop
gtest01.c - miscellaneous glib mainloop-based tests.
Definition: pcap+mainloop.c:74
#define FRAMETYPE_JSDISCOVER
FRAMETYPE_JSDISCOVER Frame (frametype 19) Frame subclass - CstringFrame class.
Definition: frametypes.h:308
Implements minimal client-oriented Frame and Frameset capabilities.
ObeyFrameSetTypeMap cmalist[]
Definition: pcap+mainloop.c:98
This is the base Frame class object (in-memory TLV (type, length, value)) for every general component...
Definition: frame.h:43
#define CONFIGNAME_OUTSIG
SignFrame to use to sign/verify packets.
WINEXPORT gboolean cryptframe_associate_identity(const char *identity, const char *key_id)
Associate the given key id with the given identity Note that it is OK to associate multiple key ids w...
Definition: cryptframe.c:293
gboolean ackmessage(NetIO *self, NetAddr *dest, FrameSet *frameset)
< User-level ACK of a message sent reliably
gboolean gotnetpkt(Listener *, FrameSet *fs, NetAddr *srcaddr)
Test routine called when an otherwise-unclaimed NetIO packet is received.
NetGSource * netgsource_new(NetIO *iosrc, GDestroyNotify notify, gint priority, gboolean can_recurse, GMainContext *context, gsize objsize, gpointer userdata)
Create a new (abstract) NetGSource object.
Definition: netgsource.c:74
void proj_class_finalize_sys(void)
Shut down (finalize) our object class system. Only do on shutdown to make valgrind happy :-D...
Definition: proj_classes.c:88
Describes interfaces to C-String Frame (Cstringframe) C-Class It holds conventional zero-terminated b...
AssimObj baseclass
Definition: netaddr.h:44
FrameSet * frameset_new(guint16 frameset_type)
Construct a new frameset of the given type.
Definition: frameset.c:110
gboolean bindaddr(NetIO *self, const NetAddr *, gboolean silent)
<[in] Bind this NetIO to the given address
NetAddr * netaddr_ipv4_new(gconstpointer ipbuf, guint16 port)
Create new NetAddr from a IPv4 address.
Definition: netaddr.c:1024
The SignFrame class object - implements digital signatures for FrameSets.
Definition: signframe.h:47
FSTATIC gboolean test_cma_authentication(const FrameSet *fs, NetAddr *)
Routine to (fake) validate that we have proper authentication...
#define FSTATIC
Definition: projectcommon.h:31
gpointer value
Frame Value (pointer)
Definition: frame.h:47
int expected_dead_count
Definition: pcap+mainloop.c:77
guint window_size
Window size of our connections.
Definition: fsprotocol.h:113
NetAddr * otheraddr
Definition: pcap+mainloop.c:84
NetIO * nettransport
Definition: pcap+mainloop.c:81
guint64 heartbeat_count
Definition: nanoprobe.h:33
guint16 fstype
Type of frameset.
Definition: frameset.h:52
#define SWITCHDISCOVER
int wirepktcount
Definition: pcap+mainloop.c:87
void(* setaddr)(ConfigContext *, const char *, NetAddr *)
Set NetAddr value.
Definition: configcontext.h:93
void(* setframe)(ConfigContext *, const char *, Frame *)
Set Frame value.
Definition: configcontext.h:91
Implements the IntFrame class - integers in a frame.
AssimObj baseclass
Definition: configcontext.h:72
void frameset_append_frame(FrameSet *fs, Frame *f)
Append frame to the front of the end of the frame list.
Definition: frameset.c:143
#define FRAMETYPE_DISCJSON
FRAMETYPE_DISCJSON Frame (frametype 26) Frame subclass - CstringFrame class.
Definition: frametypes.h:394
Describes interfaces to CryptFrame (encryption) C-Class It represents the abstract base class for Fra...
#define CONFIGNAME_TIMEOUT
How before declaring a serious problem...
Implements the Reliable UDP network I/O transport (ReliableUDP) class.
int main(int argc, char **argv)
Test program looping and reading LLDP/CDP packets and exercising most of the packet send/receive mech...
int errcount
error count
Definition: nanoprobe.c:67
Header file defining all known FrameSet types THIS FILE MECHANICALLY GENERATED by "/home/alanr/assim/...
#define FRAMESETTYPE_DODISCOVER
Perform (repeating) JSON discovery action.
Definition: framesettypes.h:58
ConfigContext * nanoconfig
This is the AuthListener class. object - which (authorizes and) obeys packets from the Authority...
Definition: authlistener.h:41
#define CONST_IPV6_LOOPBACK
Definition: netaddr.h:76
FrameSet * create_sendexpecthb(ConfigContext *config, guint16 msgtype, NetAddr *addrs, int addrcount)
Create a FrameSet class to send and expect heartbeats from the same sets of addresses.
Definition: cmalib.c:42
gboolean netio_is_dual_ipv4v6_stack(void)
Definition: netio.c:854
#define FRAMETYPE_RSCJSON
FRAMETYPE_RSCJSON Frame (frametype 27) Frame subclass - CstringFrame class.
Definition: frametypes.h:406
Describes interfaces to C-String Frame (Compressframe) C-Class It holds conventional zero-terminated ...
NetAddr * netaddr_ipv6_new(gconstpointer ipbuf, guint16 port)
Create new NetAddr from a IPv6 address.
Definition: netaddr.c:1032
#define CMA_IDENTITY_NAME
Definition: nanoprobe.h:42
#define FMT_64BIT
Format designator for a 64 bit integer.
Definition: projectcommon.h:32
#define FREE(m)
Our interface to free.
Definition: projectcommon.h:29
FsProtocol * _protocol
Queuing, ordering, retransmission and ACKing discipline.
Definition: reliableudp.h:45
#define ARPINSTNM
include file defining functions to be called by a main to instantiate a nanoprobe.
This is the base HbListener class. object - which listens for heartbeats from a particular sender...
Definition: hblistener.h:44
void got_heartbeat(HbListener *who)
This is our CstringFrame class object - used for holding C-style NULL terminated strings.
Definition: cstringframe.h:36
guint32 proj_class_live_object_count(void)
Return the count of live C class objects.
Definition: proj_classes.c:406
Project common header file.
#define DIMOF(a)
Definition: lldp_min.c:30
gint64 maxpkts
Definition: pcap+mainloop.c:78
Header file defining the data layouts for our Frames.
#define FRAMESETTYPE_ACKSTARTUP
Acknowledge full response to STARTUP packet.
Definition: framesettypes.h:62
NetAddr * anyaddr
Definition: pcap+mainloop.c:86
NetGSource * transport
Definition: listener.h:44
NetAddr * destaddr
Definition: pcap+mainloop.c:83
#define FRAMETYPE_DISCNAME
FRAMETYPE_DISCNAME Frame (frametype 24) Frame subclass - CstringFrame class.
Definition: frametypes.h:368
WINEXPORT gboolean nano_initiate_shutdown(void)
Initiate shutdown - return TRUE if we have shut down immediately...
Definition: nanoprobe.c:1408
#define STOP
NanoHbStats nano_hbstats
Definition: nanoprobe.c:65
void(* setint)(ConfigContext *, const char *name, gint value)
Set integer value.
Definition: configcontext.h:75
ReliableUDP * reliableudp_new(gsize objsize, ConfigContext *config, PacketDecoder *decoder, guint rexmit_timer_uS)
Construct new UDP NetIO object (and its socket, etc)
Definition: reliableudp.c:69
void proj_class_incr_debug(const char *Cclass)
Increment debug level for this class and all its subclasses by one.
Definition: proj_classes.c:140
ConfigContext * config
Definition: listener.h:43
#define FRAMETYPE_PUBKEYCURVE25519
FRAMETYPE_PUBKEYCURVE25519 Frame (frametype 30) Frame subclass - Frame class.
Definition: frametypes.h:443
gboolean sendareliablefs(NetIO *self, NetAddr *dest, guint16 queueid, FrameSet *frameset)
[out] source address of return result
void(* addListener)(NetGSource *, guint16, Listener *)
Register a new listener.
Definition: netgsource.h:55
WINEXPORT void cryptframe_set_encryption_method(CryptFrame *(*method)(const char *sender_key_id, const char *receiver_key_id, gboolean forsending))
Definition: cryptframe.c:518
#define MONITOR
#define FRAMESETTYPE_SWDISCOVER
Packet encapsulates switch discovery packet.
Definition: framesettypes.h:44
#define TESTPORT
Definition: pcap+mainloop.c:64
#define SWINSTNM
guint16 type
Frame Type (see Individual TLV 'Frame' data types and layouts (by TLV type) - frameformats.h )
Definition: frame.h:45
GSList * framelist
List of frames in this FrameSet.
Definition: frameset.h:48
The NetAddr class class represents a general network address - whether IP, MAC, or any other type of ...
Definition: netaddr.h:43
#define CONFIGNAME_CMAADDR
Address of the Collective Management authority.
Describes interfaces to Address Frame (AddrFrame) C-Class.
FrameSet * create_setconfig(ConfigContext *cfg)
Create a FRAMESETTYPE_SETCONFIG FrameSet class.
Definition: cmalib.c:111
gboolean(* got_frameset)(Listener *self, FrameSet *fs, NetAddr *na)
called when a FrameSet arrives
Definition: listener.h:45
Defines interfaces for the NetAddr (network address) object.
AuthListener * authlistener_new(gsize objsize, ObeyFrameSetTypeMap *map, ConfigContext *config, gboolean autoack, gboolean(*authenticator)(const FrameSet *fs, NetAddr *))
Construct a new Listener - setting up GSource and timeout data structures for it. ...
Definition: authlistener.c:133
#define DUMP(prefix, obj, suffix)
Definition: proj_classes.h:94
#define g_info(...)
Definition: projectcommon.h:66
NetIO baseclass
Base class (NetIO) object.
Definition: netioudp.h:41
#define DEFAULT_FSP_QID
Default Queue ID.
Definition: fsprotocol.h:134
WINEXPORT gboolean cryptcurve25519_save_public_key(const char *key_id, gpointer public_key, int keysize)
Save a public key away to disk so it's completely usable...
FrameSet class - used for collecting Frames when not on the wire, and for marshalling/demarshalling t...
Definition: frameset.h:46
gchar *(* toString)(gconstpointer)
Produce malloc-ed string representation.
Definition: assimobj.h:58
void(* closeall)(FsProtocol *)
Close all our connections.
Definition: fsprotocol.h:129
#define ARPDISCOVER
#define FRAMESETTYPE_SENDEXPECTHB
Send Heartbeats to these addresses, and expect them as well.
Definition: framesettypes.h:51
WINEXPORT void nano_shutdown(gboolean report)
Shut down the things started up by nano_start_full() - mainly free storage to make valgrind happy...
Definition: nanoprobe.c:1365
WINEXPORT void nano_start_full(const char *initdiscoverpath, guint discover_interval, NetGSource *io, ConfigContext *config, gboolean(*authfunc)(const FrameSet *, NetAddr *))
Here is how the startup process works:
Definition: nanoprobe.c:1328
Implements NetIO GSource object.
#define FRAMESETTYPE_STARTUP
Nanoprobe originating packet is starting up.
Definition: framesettypes.h:35
void(* dissociate)(Listener *self)
Dissociate us from our source.
Definition: listener.h:51
#define CONFIGNAME_CMAFAIL
Address of where to send failure reports.
#define CONFIGNAME_CMAINIT
Initial startup contact address for the CMA.
Implements the resource command abstract class.
void proj_class_dump_live_objects(void)
Dump all live C class objects (address and Class)
Definition: proj_classes.c:356
void(* associate)(Listener *self, NetGSource *source)
NetGSource class to associate with
Definition: listener.h:49
Defines Listener interfaces for packets coming from the Collective Authority.
ConfigContext * configcontext_new(gsize objsize)
Construct a new ConfigContext object - with no values defaulted.
Frame baseclass
Base Frame class object.
Definition: signframe.h:48
WINEXPORT const char * cryptframe_get_signing_key_id(void)
Return the key_id of the default signing key.
Definition: cryptframe.c:434
NetAddr * otheraddr2
Definition: pcap+mainloop.c:85
NetIOudp baseclass
Base class (NetIO) object.
Definition: reliableudp.h:44
void(* setvalue)(Frame *self, gpointer value, guint32 length, GDestroyNotify valfinal)
member function for setting value
Definition: frame.h:52
gboolean mcastjoin(NetIO *self, const NetAddr *, const NetAddr *)
#define FRAMETYPE_KEYID
FRAMETYPE_KEYID Frame (frametype 29) Frame subclass - CstringFrame class.
Definition: frametypes.h:430
#define START
#define UNREF2(obj)
Definition: assimobj.h:36
void fakecma_startup(AuthListener *, FrameSet *fs, NetAddr *)
Routine to pretend to be the initial CMA.
WINEXPORT CryptFrame * cryptcurve25519_new_generic(const char *sender_key_id, const char *receiver_key_id, gboolean forsending)
Generic "new" function to use with cryptframe_set_encryption_method()
#define CASTTOCLASS(Cclass, obj)
Safely cast 'obj' to C-class 'class' - verifying that it was registerd as being of type class ...
Definition: proj_classes.h:66
#define UNREF(obj)
Definition: assimobj.h:35
This is a basic NetIO class abstract class for doing network I/O.
Definition: netio.h:58
#define FRAMESETTYPE_RSCOPREPLY
Packet contains return result from a resource operation.
Definition: framesettypes.h:46
Basic utility functions for the CMA.
gboolean timeout_agent(gpointer ignored)
Called every second during tests.
#define FRAMESETTYPE_DORSCOP
Do a (possibly-repeating) JSON resource action.
Definition: framesettypes.h:60
The NetGSource class objects integrate NetIO class objects into the g_main_loop paradigm.
Definition: netgsource.h:43
This is the Listener class. object - which generically listens for packets.
Definition: listener.h:41
NetGSource * netpkt
Definition: pcap+mainloop.c:82
void got_heartbeat2(HbListener *who)
#define FRAMETYPE_CRYPTCURVE25519
FRAMETYPE_CRYPTCURVE25519 Frame (frametype 2) Frame subclass - CryptCurve25519 class.
Definition: frametypes.h:104
WINEXPORT CstringFrame * cstringframe_new(guint16 frame_type, gsize framesize)
Construct a new CstringFrame - allowing for "derived" frame types...
Definition: cstringframe.c:101
Describes interfaces to CryptFrame (encryption) C-Class It represents a FrameSet using libsodium (cur...