The Assimilation Project
 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;
163  default:{
164  char * fsstr = fs->baseclass.toString(&fs->baseclass);
165  g_message("CMA Received a FrameSet of type %d [%s] over the 'wire'."
166  , fs->fstype, fsstr);
167  FREE(fsstr); fsstr = NULL;
168  }
169  }
170 
171  l->transport->_netio->ackmessage(l->transport->_netio, srcaddr, fs);
172  UNREF(fs);
173  if (wirepktcount >= maxpkts) {
174  g_message("QUITTING NOW - wirepktcount!");
176  return FALSE;
177  }
178  return TRUE;
179 }
180 
182 gboolean
183 timeout_agent(gpointer ignored)
184 {
185  ReliableUDP* io = CASTTOCLASS(ReliableUDP, nettransport);
186 
187  (void)ignored;
188  if (nano_hbstats.heartbeat_count > (unsigned)maxpkts) {
189  g_message("QUITTING NOW! (heartbeat count)");
190  io->_protocol->closeall(io->_protocol);
192  return FALSE;
193  }
194  return TRUE;
195 }
196 
197 #define OCFCLASS "\"" REQCLASSNAMEFIELD "\": \"ocf\""
198 #define HBPROVIDER "\"" REQPROVIDERNAMEFIELD "\": \"heartbeat\""
199 #define DUMMYTYPE "\"" CONFIGNAME_TYPE "\": \"Dummy\""
200 #define STARTOP "\"" REQOPERATIONNAMEFIELD "\": \"start\""
201 #define STOPOP "\"" REQOPERATIONNAMEFIELD "\": \"stop\""
202 #define MONITOROP "\"" REQOPERATIONNAMEFIELD "\": \"monitor\""
203 #define METADATAOP "\"" REQOPERATIONNAMEFIELD "\": \"meta-data\""
204 #define RESOURCENAME "\"" CONFIGNAME_INSTANCE "\": \"DummyTestGTest01\""
205 #define NULLPARAMS "\"" REQENVIRONNAMEFIELD "\": {}"
206 #define C ","
207 #define REQID(id) "\"" REQIDENTIFIERNAMEFIELD "\": " #id
208 #define REPEAT(repeat) "\"" REQREPEATNAMEFIELD "\": " #repeat
209 #define INITDELAY(delay) "\"" CONFIGNAME_INITDELAY "\": " #delay
210 #define COMMREQUEST OCFCLASS C HBPROVIDER C DUMMYTYPE C RESOURCENAME C NULLPARAMS
211 #define REQUEST(type,id, repeat,delay) \
212  "{" COMMREQUEST C type C REQID(id) C REPEAT(repeat) C INITDELAY(delay)"}"
213 #define START REQUEST(STARTOP, 1, 0, 0) // One shot - no delay
214 #define MONITOR REQUEST(MONITOROP, 2, 0, 0) // Repeat every second - no delay
215 #define STOP REQUEST(STOPOP, 3, 0, 5) // No repeat - 5 second delay
216 
218 void
220 {
221  FrameSet* pkt;
222  NetGSource* netpkt = auth->baseclass.transport;
223  char * nanostr = nanoaddr->baseclass.toString(nanoaddr);
224  GSList* thisgsf;
225  const char * keyid = NULL;
226 
227  (void)ifs;
228  g_message("CMA received startup message from nanoprobe at address %s/%d."
229  , nanostr, nanoaddr->port(nanoaddr));
230  g_free(nanostr); nanostr = NULL;
231  check_JSON(ifs);
232 
233  netpkt->_netio->addalias(netpkt->_netio, nanoaddr, destaddr);
234 
235  // Set up our crypto...
240  for (thisgsf = ifs->framelist; thisgsf; thisgsf=thisgsf->next) {
241  Frame* thisframe = CASTTOCLASS(Frame, thisgsf->data);
242  if (thisframe->type == FRAMETYPE_KEYID) {
243  CstringFrame* csf = CASTTOCLASS(CstringFrame, thisframe);
244  keyid = (const char *)csf->baseclass.value;
245  }else if (keyid && thisframe->type == FRAMETYPE_PUBKEYCURVE25519) {
246  cryptcurve25519_save_public_key(keyid, thisframe->value
247  , thisframe->length);
248  }
249  }
250 
251  // Send the configuration data to our new "client"
252  pkt = create_setconfig(nanoconfig);
253  netpkt->_netio->sendareliablefs(netpkt->_netio, nanoaddr, DEFAULT_FSP_QID, pkt);
254  UNREF(pkt);
255 
256  // Now tell them to send/expect heartbeats to various places
258  netpkt->_netio->sendareliablefs(netpkt->_netio, nanoaddr, DEFAULT_FSP_QID, pkt);
259  UNREF(pkt);
260 
261  {
262  const char * json[] = { START, MONITOR, STOP};
263  unsigned j;
264  // Create a frameset for a few resource operations
266  for (j=0; j < DIMOF(json); j++) {
268  csf->baseclass.setvalue(&csf->baseclass, g_strdup(json[j])
269  , strlen(json[j])+1, g_free);
270  frameset_append_frame(pkt, &csf->baseclass);
271  UNREF2(csf);
272  }
273  netpkt->_netio->sendareliablefs(netpkt->_netio, nanoaddr, DEFAULT_FSP_QID, pkt);
274  UNREF(pkt);
275  }
276 }
277 
278 FSTATIC gboolean
280 {
281  gpointer maybecrypt = g_slist_nth_data(fs->framelist, 1);
282  Frame* mightbecrypt;
283  (void)fromaddr;
285  g_return_val_if_fail(maybecrypt != NULL, FALSE);
286  mightbecrypt = CASTTOCLASS(Frame, maybecrypt);
287  if (mightbecrypt->type != FRAMETYPE_CRYPTCURVE25519) {
288  DUMP("test_cma_authentication: ", &fs->baseclass, " was BAD");
289  return FALSE;
290  }
291  return TRUE;
292 }
293 
302 int
303 main(int argc, char **argv)
304 {
305  const guint8 loopback[] = CONST_IPV6_LOOPBACK;
306  //const guint8 mcastaddrstring[] = CONST_ASSIM_DEFAULT_V4_MCAST;
307  //NetAddr* mcastaddr;
308  const guint8 otheradstring[] = {127,0,0,1};
309  const guint8 otheradstring2[] = {10,10,10,4};
310  const guint8 anyadstring[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
311  guint16 testport = TESTPORT;
312  SignFrame* signature = signframe_glib_new(G_CHECKSUM_SHA256, 0);
313  Listener* otherlistener;
315  PacketDecoder* decoder = nano_packet_decoder();
316  AuthListener* listentonanoprobes;
317 
318 #if 0
319 # ifdef HAVE_MCHECK_PEDANTIC
320  g_assert(mcheck_pedantic(NULL) == 0);
321 # else
322 # ifdef HAVE_MCHECK
323  g_assert(mcheck(NULL) == 0);
324 # endif
325 # endif
326 #endif
327  g_setenv("G_MESSAGES_DEBUG", "all", TRUE);
328 #if 0
329  proj_class_incr_debug(NULL);
330  proj_class_incr_debug(NULL);
331  proj_class_incr_debug(NULL);
332  proj_class_incr_debug(NULL);
333 #endif
334  g_log_set_fatal_mask(NULL, G_LOG_LEVEL_ERROR);
335 
336  if (argc > 1) {
337  maxpkts = atol(argv[1]);
338  g_debug("Max packet count is "FMT_64BIT"d", maxpkts);
339  }
340 
342  g_message("Our OS supports dual ipv4/v6 sockets. Hurray!");
343  }else{
344  g_warning("Our OS DOES NOT support dual ipv4/v6 sockets - this may not work!!");
345  }
346 
347 
348  config->setframe(config, CONFIGNAME_OUTSIG, &signature->baseclass);
349 
350  // Create a network transport object for normal UDP packets
351  nettransport = &(reliableudp_new(0, config, decoder, 0)->baseclass.baseclass);
352  g_return_val_if_fail(NULL != nettransport, 2);
353 
354  // Set up the parameters the 'CMA' is going to send to our 'nanoprobe'
355  // in response to their request for configuration data.
356  nanoconfig = configcontext_new(0);
357  nanoconfig->setint(nanoconfig, CONFIGNAME_INTERVAL, 1);
358  nanoconfig->setint(nanoconfig, CONFIGNAME_TIMEOUT, 3);
359  nanoconfig->setint(nanoconfig, CONFIGNAME_CMAPORT, testport);
360 
361 
362  // Construct the NetAddr we'll talk to (i.e., ourselves) and listen from
363  destaddr = netaddr_ipv6_new(loopback, testport);
364  g_return_val_if_fail(NULL != destaddr, 3);
365  config->setaddr(config, CONFIGNAME_CMAINIT, destaddr);
366  nanoconfig->setaddr(nanoconfig, CONFIGNAME_CMAADDR, destaddr);
367  nanoconfig->setaddr(nanoconfig, CONFIGNAME_CMAFAIL, destaddr);
368  nanoconfig->setaddr(nanoconfig, CONFIGNAME_CMADISCOVER, destaddr);
369 
370  // Construct another couple of NetAddrs to talk to and listen from
371  // for good measure...
372  otheraddr = netaddr_ipv4_new(otheradstring, testport);
373  g_return_val_if_fail(NULL != otheraddr, 4);
374  otheraddr2 = netaddr_ipv4_new(otheradstring2, testport);
375  g_return_val_if_fail(NULL != otheraddr2, 4);
376 
377  // Construct another NetAddr to bind to (anything)
378  anyaddr = netaddr_ipv6_new(anyadstring, testport);
379  g_return_val_if_fail(NULL != destaddr, 5);
380 
381  // Bind to ANY address (as noted above)
382  g_return_val_if_fail(nettransport->bindaddr(nettransport, anyaddr, FALSE),16);
383  //g_return_val_if_fail(nettransport->bindaddr(nettransport, destaddr),16);
384 
385  g_message("NOT Joining multicast address.");
386 #if 0
387  // We can't do this because of encryption and we will likely screw up
388  // others on our network even if that weren't a problem...
389  mcastaddr = netaddr_ipv4_new(mcastaddrstring, testport);
390  g_return_val_if_fail(nettransport->mcastjoin(nettransport, mcastaddr, NULL), 17);
391  UNREF(mcastaddr);
392  g_message("multicast join succeeded.");
393 #endif
394 
395  // Connect up our network transport into the g_main_loop paradigm
396  // so we get dispatched when packets arrive
397  netpkt = netgsource_new(nettransport, NULL, G_PRIORITY_HIGH, FALSE, NULL, 0, NULL);
398 
399  // Set up so that we can observe all unclaimed packets
400  otherlistener = listener_new(config, 0);
401  otherlistener->got_frameset = gotnetpkt;
402  netpkt->addListener(netpkt, 0, otherlistener);
403  otherlistener->associate(otherlistener,netpkt);
404 
405  // Unref the "other" listener - we hold other references to it
406  UNREF(otherlistener);
407 
408  // Pretend to be the CMA...
409  // Listen for packets from our nanoprobes - scattered throughout space...
410  listentonanoprobes = authlistener_new(0, cmalist, config, TRUE, NULL);
411  listentonanoprobes->baseclass.associate(&listentonanoprobes->baseclass, netpkt);
412 
413  nano_start_full("netconfig", 900, netpkt, config, test_cma_authentication);
414 
415  g_timeout_add_seconds(1, timeout_agent, NULL);
416  mainloop = g_main_loop_new(g_main_context_default(), TRUE);
417 
418  /********************************************************************
419  * Start up the main loop - run our test program...
420  * (the one pretending to be both the nanoprobe and the CMA)
421  ********************************************************************/
422  g_main_loop_run(mainloop);
423 
424  /********************************************************************
425  * We exited the main loop. Shut things down.
426  ********************************************************************/
427 
428  nano_shutdown(TRUE); // Tell it to shutdown and print stats
429  g_message("Count of 'other' pkts received:\t%d", wirepktcount);
430 
431  UNREF(nettransport);
432 
433  // Main loop is over - shut everything down, free everything...
434  g_main_loop_unref(mainloop); mainloop=NULL;
435 
436 
437  // Unlink misc dispatcher - this should NOT be necessary...
438  netpkt->addListener(netpkt, 0, NULL);
439 
440  // Dissociate packet actions from the packet source.
441  listentonanoprobes->baseclass.dissociate(&listentonanoprobes->baseclass);
442 
443  // Unref the AuthListener object
444  UNREF2(listentonanoprobes);
445 
446  g_source_destroy(&netpkt->baseclass);
447  g_source_unref(&netpkt->baseclass);
448  //g_main_context_unref(g_main_context_default());
449 
450  // Free signature frame
451  UNREF2(signature);
452 
453  // Free misc addresses
454  UNREF(destaddr);
455  UNREF(otheraddr);
456  UNREF(otheraddr2);
457  UNREF(anyaddr);
458 
459  // Free config object
460  UNREF(config);
461  UNREF(nanoconfig);
462 
463 
464  // At this point - nothing should show up - we should have freed everything
465  if (proj_class_live_object_count() > 0) {
466  g_warning("Too many objects (%d) alive at end of test.",
469  ++errcount;
470  }else{
471  g_message("No objects left alive. Awesome!");
472  }
473  proj_class_finalize_sys(); // Shut down object system to make valgrind happy :-D
474  return(errcount <= 127 ? errcount : 127);
475 }
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
FSTATIC gboolean test_cma_authentication(const FrameSet *fs, NetAddr *)
#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:1220
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
#define FSTATIC
Definition: projectcommon.h:31
gpointer value
Frame Value (pointer)
Definition: frame.h:47
int expected_dead_count
Definition: pcap+mainloop.c:77
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
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
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:66
Header file defining all known FrameSet types THIS FILE MECHANICALLY GENERATED by "/home/alanr/assim/...
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
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.
NetAddr * anyaddr
Definition: pcap+mainloop.c:86
NetGSource * transport
Definition: listener.h:44
NetAddr * destaddr
Definition: pcap+mainloop.c:83
WINEXPORT gboolean nano_initiate_shutdown(void)
Initiate shutdown - return TRUE if we have shut down immediately...
Definition: nanoprobe.c:1336
#define STOP
NanoHbStats nano_hbstats
Definition: nanoprobe.c:64
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
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
NetIO baseclass
Base class (NetIO) object.
Definition: netioudp.h:41
#define DEFAULT_FSP_QID
Default Queue ID.
Definition: fsprotocol.h:129
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:124
#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:1293
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:1256
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
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...