The Assimilation Project
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups 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);
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 
225  (void)ifs;
226  // Override what the default ("real") nano startup did for/to us
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  // Send the configuration data to our new "client"
234  pkt = create_setconfig(nanoconfig);
235  netpkt->_netio->sendareliablefs(netpkt->_netio, nanoaddr, DEFAULT_FSP_QID, pkt);
236  UNREF(pkt);
237 
238  // Now tell them to send/expect heartbeats to various places
240  netpkt->_netio->sendareliablefs(netpkt->_netio, nanoaddr, DEFAULT_FSP_QID, pkt);
241  UNREF(pkt);
242 
244  netpkt->_netio->sendareliablefs(netpkt->_netio, nanoaddr, DEFAULT_FSP_QID, pkt);
245  UNREF(pkt);
246 
248  netpkt->_netio->sendareliablefs(netpkt->_netio, nanoaddr, DEFAULT_FSP_QID, pkt);
249  UNREF(pkt);
250 
251  {
252  const char * json[] = { START, MONITOR, STOP};
253  unsigned j;
254  // Create a frameset for a few resource operations
256  for (j=0; j < DIMOF(json); j++) {
258  csf->baseclass.setvalue(&csf->baseclass, g_strdup(json[j])
259  , strlen(json[j])+1, g_free);
260  frameset_append_frame(pkt, &csf->baseclass);
261  UNREF2(csf);
262  }
263  netpkt->_netio->sendareliablefs(netpkt->_netio, nanoaddr, DEFAULT_FSP_QID, pkt);
264  UNREF(pkt);
265  }
266 }
267 
268 FSTATIC gboolean
270 {
273  return NULL != fs;
274 }
275 
284 int
285 main(int argc, char **argv)
286 {
287  const guint8 loopback[] = CONST_IPV6_LOOPBACK;
288  const guint8 mcastaddrstring[] = CONST_ASSIM_DEFAULT_V4_MCAST;
289  NetAddr* mcastaddr;
290  const guint8 otheradstring[] = {127,0,0,1};
291  const guint8 otheradstring2[] = {10,10,10,4};
292  const guint8 anyadstring[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
293  guint16 testport = TESTPORT;
294  SignFrame* signature = signframe_glib_new(G_CHECKSUM_SHA256, 0);
295  Listener* otherlistener;
297  PacketDecoder* decoder = nano_packet_decoder();
298  AuthListener* listentonanoprobes;
299 
300 #if 0
301 # ifdef HAVE_MCHECK_PEDANTIC
302  g_assert(mcheck_pedantic(NULL) == 0);
303 # else
304 # ifdef HAVE_MCHECK
305  g_assert(mcheck(NULL) == 0);
306 # endif
307 # endif
308 #endif
309  g_setenv("G_MESSAGES_DEBUG", "all", TRUE);
310 #if 0
311  proj_class_incr_debug(NULL);
312  proj_class_incr_debug(NULL);
313  proj_class_incr_debug(NULL);
314  proj_class_incr_debug(NULL);
315  proj_class_incr_debug(NULL);
316 #endif
317  g_log_set_fatal_mask(NULL, G_LOG_LEVEL_ERROR);
318 
319  if (argc > 1) {
320  maxpkts = atol(argv[1]);
321  g_debug("Max packet count is "FMT_64BIT"d", maxpkts);
322  }
323 
325  g_message("Our OS supports dual ipv4/v6 sockets. Hurray!");
326  }else{
327  g_warning("Our OS DOES NOT support dual ipv4/v6 sockets - this may not work!!");
328  }
329 
330 
331  config->setframe(config, CONFIGNAME_OUTSIG, &signature->baseclass);
332 
333  // Create a network transport object for normal UDP packets
334  nettransport = &(reliableudp_new(0, config, decoder, 0)->baseclass.baseclass);
335  g_return_val_if_fail(NULL != nettransport, 2);
336 
337  // Set up the parameters the 'CMA' is going to send to our 'nanoprobe'
338  // in response to their request for configuration data.
339  nanoconfig = configcontext_new(0);
340  nanoconfig->setint(nanoconfig, CONFIGNAME_INTERVAL, 1);
341  nanoconfig->setint(nanoconfig, CONFIGNAME_TIMEOUT, 3);
342  nanoconfig->setint(nanoconfig, CONFIGNAME_CMAPORT, testport);
343 
344 
345  // Construct the NetAddr we'll talk to (i.e., ourselves) and listen from
346  destaddr = netaddr_ipv6_new(loopback, testport);
347  g_return_val_if_fail(NULL != destaddr, 3);
348  config->setaddr(config, CONFIGNAME_CMAINIT, destaddr);
349  nanoconfig->setaddr(nanoconfig, CONFIGNAME_CMAADDR, destaddr);
350  nanoconfig->setaddr(nanoconfig, CONFIGNAME_CMAFAIL, destaddr);
351  nanoconfig->setaddr(nanoconfig, CONFIGNAME_CMADISCOVER, destaddr);
352 
353  // Set up our crypto...
359 
360  // Construct another couple of NetAddrs to talk to and listen from
361  // for good measure...
362  otheraddr = netaddr_ipv4_new(otheradstring, testport);
363  g_return_val_if_fail(NULL != otheraddr, 4);
364  otheraddr2 = netaddr_ipv4_new(otheradstring2, testport);
365  g_return_val_if_fail(NULL != otheraddr2, 4);
368 
369  // Construct another NetAddr to bind to (anything)
370  anyaddr = netaddr_ipv6_new(anyadstring, testport);
371  g_return_val_if_fail(NULL != destaddr, 5);
372 
373  // Bind to ANY address (as noted above)
374  g_return_val_if_fail(nettransport->bindaddr(nettransport, anyaddr, FALSE),16);
375  //g_return_val_if_fail(nettransport->bindaddr(nettransport, destaddr),16);
376 
377  g_message("Joining multicast address.");
378  mcastaddr = netaddr_ipv4_new(mcastaddrstring, testport);
379  g_return_val_if_fail(nettransport->mcastjoin(nettransport, mcastaddr, NULL), 17);
380  UNREF(mcastaddr);
381  g_message("multicast join succeeded.");
382 
383  // Connect up our network transport into the g_main_loop paradigm
384  // so we get dispatched when packets arrive
385  netpkt = netgsource_new(nettransport, NULL, G_PRIORITY_HIGH, FALSE, NULL, 0, NULL);
386 
387  // Set up so that we can observe all unclaimed packets
388  otherlistener = listener_new(config, 0);
389  otherlistener->got_frameset = gotnetpkt;
390  netpkt->addListener(netpkt, 0, otherlistener);
391  otherlistener->associate(otherlistener,netpkt);
392 
393  // Unref the "other" listener - we hold other references to it
394  UNREF(otherlistener);
395 
396  // Pretend to be the CMA...
397  // Listen for packets from our nanoprobes - scattered throughout space...
398  listentonanoprobes = authlistener_new(0, cmalist, config, TRUE, NULL);
399  listentonanoprobes->baseclass.associate(&listentonanoprobes->baseclass, netpkt);
400 
401  nano_start_full("netconfig", 900, netpkt, config, NULL);
402 
403  g_timeout_add_seconds(1, timeout_agent, NULL);
404  mainloop = g_main_loop_new(g_main_context_default(), TRUE);
405 
406  /********************************************************************
407  * Start up the main loop - run our test program...
408  * (the one pretending to be both the nanoprobe and the CMA)
409  ********************************************************************/
410  g_main_loop_run(mainloop);
411 
412  /********************************************************************
413  * We exited the main loop. Shut things down.
414  ********************************************************************/
415 
416  nano_shutdown(TRUE); // Tell it to shutdown and print stats
417  g_message("Count of 'other' pkts received:\t%d", wirepktcount);
418 
419  UNREF(nettransport);
420 
421  // Main loop is over - shut everything down, free everything...
422  g_main_loop_unref(mainloop); mainloop=NULL;
423 
424 
425  // Unlink misc dispatcher - this should NOT be necessary...
426  netpkt->addListener(netpkt, 0, NULL);
427 
428  // Dissociate packet actions from the packet source.
429  listentonanoprobes->baseclass.dissociate(&listentonanoprobes->baseclass);
430 
431  // Unref the AuthListener object
432  UNREF2(listentonanoprobes);
433 
434  g_source_destroy(&netpkt->baseclass);
435  g_source_unref(&netpkt->baseclass);
436  //g_main_context_unref(g_main_context_default());
437 
438  // Free signature frame
439  UNREF2(signature);
440 
441  // Free misc addresses
442  UNREF(destaddr);
443  UNREF(otheraddr);
444  UNREF(otheraddr2);
445  UNREF(anyaddr);
446 
447  // Free config object
448  UNREF(config);
449  UNREF(nanoconfig);
450 
451  // At this point - nothing should show up - we should have freed everything
452  if (proj_class_live_object_count() > 0) {
453  g_warning("Too many objects (%d) alive at end of test.",
456  ++errcount;
457  }else{
458  g_message("No objects left alive. Awesome!");
459  }
460  proj_class_finalize_sys(); // Shut down object system to make valgrind happy :-D
461  return(errcount <= 127 ? errcount : 127);
462 }
WINEXPORT void cryptcurve25519_gen_temp_keypair(const char *key_id)
Generate a temporary (non-persistent) key pair.
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
#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
#define CRYPTO_KEYID
Definition: pcap+mainloop.c:65
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:1209
gint64 pktcount
Definition: pcap+mainloop.c:79
#define CONFIGNAME_CMAPORT
Default Port for contacting the CMA.
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 void nano_start_full(const char *initdiscoverpath, guint discover_interval, NetGSource *io, ConfigContext *config, gboolean(*authfunc)(const FrameSet *))
Here is how the startup process works:
Definition: nanoprobe.c:1245
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:272
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
FSTATIC gboolean test_cma_authentication(const FrameSet *fs)
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:763
#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
#define CONST_ASSIM_DEFAULT_V4_MCAST
This is our reserved multicast address.
Definition: netaddr.h:84
WINEXPORT gboolean nano_initiate_shutdown(void)
Initiate shutdown - return TRUE if we have shut down immediately...
Definition: nanoprobe.c:1324
#define STOP
WINEXPORT void cryptframe_set_dest_public_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:444
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
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
#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.
WINEXPORT void cryptframe_set_encryption_method(CryptFrame *(*method)(const char *sender_key_id, const char *receiver_key_id))
Definition: cryptframe.c:471
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.
WINEXPORT CryptFrame * cryptcurve25519_new_generic(const char *sender_key_id, const char *receiver_key_id)
Generic "new" function to use with cryptframe_set_encryption_method()
NetIO baseclass
Base class (NetIO) object.
Definition: netioudp.h:41
#define DEFAULT_FSP_QID
Default Queue ID.
Definition: fsprotocol.h:127
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:122
#define FRAMESETTYPE_SENDEXPECTHB
Send Heartbeats to these addresses, and expect them as well.
Definition: framesettypes.h:49
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:1281
Implements NetIO GSource object.
WINEXPORT void cryptframe_set_signing_key_id(const char *key_id)
Set the default signing key.
Definition: cryptframe.c:391
#define FRAMESETTYPE_STARTUP
System originating packet looking for heartbeat configuration.
Definition: framesettypes.h:38
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
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 *)
<Join multicast group
#define START
#define UNREF2(obj)
Definition: assimobj.h:36
void fakecma_startup(AuthListener *, FrameSet *fs, NetAddr *)
Routine to pretend to be the initial CMA.
#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:58
The NetGSource class objects integrate NetIO class objects into the g_main_loop paradigm.
Definition: netgsource.h:43
AuthListener * authlistener_new(gsize objsize, ObeyFrameSetTypeMap *map, ConfigContext *config, gboolean autoack, gboolean(*authenticator)(const FrameSet *fs))
Construct a new Listener - setting up GSource and timeout data structures for it. ...
Definition: authlistener.c:133
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)
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...