The Assimilation Project  based on Assimilation version 1.1.7.1474836767
pinger.c
Go to the documentation of this file.
1 
24 #include <stdlib.h>
25 #include <stdio.h>
26 #include <string.h>
27 #include <netaddr.h>
28 #include <frametypes.h>
29 #include <reliableudp.h>
30 #include <authlistener.h>
31 
32 #include <compressframe.h>
33 #include <cryptframe.h>
34 #include <cryptcurve25519.h>
35 #include <intframe.h>
36 #include <cstringframe.h>
37 #include <addrframe.h>
38 #include <ipportframe.h>
39 #include <seqnoframe.h>
40 #include <nvpairframe.h>
41 #include <cryptcurve25519.h>
42 #include <packetdecoder.h>
43 #include <sodium.h>
44 
45 #define CRYPTO_KEYID "pinger"
46 #define CRYPTO_IDENTITY "us chickens"
47 #define PORT 19840
48 
49 #if 1
50 #define RCVLOSS 0.05
51 #define XMITLOSS 0.05
52 #else
53 #define RCVLOSS 0.00
54 #define XMITLOSS 0.00
55 #endif
56 
57 /*
58  * You can either give us a list of addresses, or none.
59  *
60  * If you give us no addresses, we just hang out waiting for someone(s) to ping us
61  * and we pong them back, and ping them too...
62  *
63  * If you give us addresses then we ping them and hang out waiting for pongs and then
64  * we ping back - and so it goes...
65  *
66  */
67 
70 gboolean exit_when_connsdown(gpointer);
71 void usage(const char * cmdname);
73 int pongcount = 2;
74 int maxpingcount = 10;
75 GMainLoop* loop = NULL;
76 gboolean encryption_enabled = FALSE;
77 guint pongsize = 32*1024;
78 
81  {FRAMESETTYPE_SEQPONG, obey_pingpong},
83  {0, NULL}
84 };
85 
86 GHashTable* theircounts = NULL;
87 GHashTable* ourcounts = NULL;
88 
89 gboolean
90 exit_when_connsdown(gpointer unused)
91 {
92  (void)unused;
93  if (transport->_protocol->activeconncount(transport->_protocol) == 0) {
94  fprintf(stderr, "ALL CONNECTIONS SHUT DOWN! calling g_main_quit()\n");
95  g_main_loop_quit(loop);
96  return FALSE;
97  }
98  return TRUE;
99 }
100 void
101 obey_connshut(AuthListener* unused, FrameSet* unusedfs, NetAddr* unusedaddr)
102 {
103  (void)unused;
104  (void)unusedfs;
105  (void)unusedaddr;
106 }
107 
108 static gint pingcount = 1;
109 void
110 obey_pingpong(AuthListener* unused, FrameSet* fs, NetAddr* fromaddr)
111 {
112  char * addrstr = fromaddr->baseclass.toString(&fromaddr->baseclass);
113  FsProtoState state = transport->_protocol->connstate(transport->_protocol, 0, fromaddr);
114 
115  if (fs->fstype == FRAMESETTYPE_SEQPONG) {
116  fprintf(stderr, "Received a SEQPONG packet from %s\n", addrstr);
117  }
118  if (encryption_enabled) {
119  const char * keyid = frameset_sender_key_id(fs);
120  const char * identity = frameset_sender_identity(fs);
121 
122  g_assert(NULL != keyid);
123  g_assert(NULL != identity);
124  g_assert(strcmp(keyid, CRYPTO_KEYID) == 0);
125  g_assert(strcmp(identity, CRYPTO_IDENTITY) == 0);
126  }
127 
128 
129  (void)unused;
130  // Acknowledge that we acted on this message...
131  transport->baseclass.baseclass.ackmessage(&transport->baseclass.baseclass, fromaddr, fs);
132  if (FSPR_INSHUTDOWN(state)) {
133  // Shutting down -- ignore this message...
134  // Note that we DO have to ACK the message...
135  if (addrstr) {
136  g_free(addrstr); addrstr = NULL;
137  }
138  return;
139  }
140  if (fs->fstype == FRAMESETTYPE_SEQPING) {
142  IntFrame* count = intframe_new(FRAMETYPE_CINTVAL, sizeof(pingcount));
143  GSList* flist = NULL;
144  GSList* iter;
145  int j;
146  GSList* slframe;
147  gpointer theirlastcount_p = g_hash_table_lookup(theircounts, fromaddr);
148  gpointer ourlastcount_p = g_hash_table_lookup(ourcounts, fromaddr);
149  gint ournextcount;
150  gboolean foundcount = FALSE;
151 
152  ++pingcount;
153  if (ourlastcount_p == NULL) {
154  ournextcount = 1;
155  REF(fromaddr); // For the 'ourcounts' table
156  }else{
157  ournextcount = GPOINTER_TO_INT(ourlastcount_p)+1;
158  }
159  g_hash_table_insert(ourcounts, fromaddr, GINT_TO_POINTER(ournextcount));
160 
161  count->setint(count, ournextcount);
162  frameset_append_frame(ping, &count->baseclass);
163  UNREF2(count);
164  if (maxpingcount > 0 && pingcount > maxpingcount) {
165  g_message("Shutting down on ping count.");
166  transport->_protocol->closeall(transport->_protocol);
167  g_idle_add(exit_when_connsdown, NULL);
168  }
169  for (slframe = fs->framelist; slframe != NULL; slframe = g_slist_next(slframe)) {
170  Frame* frame = CASTTOCLASS(Frame, slframe->data);
171  if (frame->type == FRAMETYPE_CINTVAL) {
172  IntFrame* cntframe = CASTTOCLASS(IntFrame, frame);
173  gint theirnextcount = (gint)cntframe->getint(cntframe);
174  foundcount = TRUE;
175  if (theirlastcount_p != NULL) {
176  gint theirlastcount = GPOINTER_TO_INT(theirlastcount_p);
177  if (theirnextcount != theirlastcount +1) {
178  char * fromstr = fromaddr->baseclass.toString(&fromaddr->baseclass);
179  g_warning("%s.%d: SEQPING received from %s was %d should have been %d"
180  , __FUNCTION__, __LINE__, fromstr, theirnextcount, theirlastcount+1);
181  g_free(fromstr); fromstr = NULL;
182  }
183  }else if (theirnextcount != 1) {
184  char * fromstr = fromaddr->baseclass.toString(&fromaddr->baseclass);
185  g_warning("%s.%d: First PING received from %s was %d should have been 1"
186  , __FUNCTION__, __LINE__, fromstr, theirnextcount);
187  g_free(fromstr); fromstr = NULL;
188  }
189  g_hash_table_insert(theircounts, fromaddr, GINT_TO_POINTER(theirnextcount));
190  if (theirlastcount_p == NULL) {
191  REF(fromaddr);
192  }
193  }
194  }
195  if (!foundcount) {
196  char * s = fs->baseclass.toString(&fs->baseclass);
197  fprintf(stderr, "Did not find a count in this PING packet=n");
198  fprintf(stderr, "%s", s);
199  FREE(s);
200  }
201 
202 
203  for (j=0; j < pongcount; ++j) {
205  Frame* boatload = frame_new(FRAMETYPE_PKTDATA, 0);
206  gpointer loadofrandom = g_malloc(pongsize);
207  randombytes_buf(loadofrandom, pongsize);
208  boatload->setvalue(boatload, loadofrandom, pongsize, g_free);
209  frameset_append_frame(pong, boatload);
210  UNREF(boatload);
211  flist = g_slist_append(flist, pong);
212  }
213 
214  fprintf(stderr, "Sending a PONG(%d)/PING set to %s\n"
215  , pongcount, addrstr);
216  flist = g_slist_prepend(flist, ping);
217  transport->baseclass.baseclass.sendreliablefs(&transport->baseclass.baseclass, fromaddr, 0, flist);
218  for (iter=flist; iter; iter=iter->next) {
219  FrameSet* fs2 = CASTTOCLASS(FrameSet, iter->data);
220  UNREF(fs2);
221  }
222  g_slist_free(flist); flist = NULL;
223  }
224  if (addrstr) {
225  g_free(addrstr); addrstr = NULL;
226  }
227 }
228 
229 
230 void
231 usage(const char * cmdname)
232 {
233  const char * cmd = strrchr(cmdname, '/');
234  if (cmd != NULL) {
235  cmd++;
236  }else{
237  cmd = cmdname;
238  }
239  fprintf(stderr, "usage: %s [-d debug-level] [-c count ] ip-address1 [ip-address ...]\n", cmd);
240  fprintf(stderr, " -c count-of-ping-packets\n");
241  fprintf(stderr, " -d debug-level [0-5]\n");
242  exit(1);
243 }
244 
245 int
246 main(int argc, char **argv)
247 {
248 // int j;
249  FrameTypeToFrame decodeframes[] = FRAMETYPEMAP;
250  PacketDecoder* decoder = packetdecoder_new(0, decodeframes, DIMOF(decodeframes));
251  SignFrame* signature = signframe_glib_new(G_CHECKSUM_SHA256, 0);
254  const guint8 anyadstring[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
255  NetAddr* anyaddr = netaddr_ipv6_new(anyadstring, PORT);
257  AuthListener* act_on_packets;
258  int liveobjcount;
259 // gboolean optionerror = FALSE;
260 // gboolean moreopts = TRUE;
261 // int option_index = 0;
262 // int c;
263 
264  //static struct option long_options[] = {
265  // {"count", required_argument, 0, 'c'},
266  // {"debug", no_argument, 0, 'd'},
267  //};
268  static int mycount = 0;
269  static int mydebug = 0;
270  static gchar ** optremaining = NULL;
271  static GOptionEntry long_options [] = {
272  {"count", 'c', 0, G_OPTION_ARG_INT, &mycount, "count of ping packets", NULL},
273  {"debug", 'd', 0, G_OPTION_ARG_INT, &mydebug, "debug-level [0-5]", NULL},
274  {"size", 's', 0, G_OPTION_ARG_INT, &pongsize, "pong packet size", NULL},
275  {G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_STRING_ARRAY, &optremaining, "ip_address [ip_address ...]", NULL},
276  {NULL, 0, 0, 0, NULL, NULL, NULL}
277  };
278  int argcount;
279  int exitcode = 0;
280  int insize;
281  int outsize;
282  GError *optionerror;
283  GOptionContext *myOptionContext;
284 
285  myOptionContext = g_option_context_new(" ip_address [ip_address...]");
286  g_option_context_add_main_entries(myOptionContext, long_options, NULL);
287 
288  g_setenv("G_MESSAGES_DEBUG", "all", TRUE);
289  g_log_set_fatal_mask(NULL, (int) G_LOG_LEVEL_ERROR|G_LOG_LEVEL_CRITICAL);
290 
291  if(!(g_option_context_parse(myOptionContext, &argc, &argv, &optionerror))) {
292  g_print("option parsing failed %s\n", optionerror->message);
293  usage(argv[0]);
294  exit(1);
295  }
296 
297  g_option_context_free(myOptionContext);
298  if((mycount != 0) && (mycount > 0)) { // an upper limit as well ?
299  maxpingcount = mycount;
300  }
301  if(mydebug > 0) {
302  if(mydebug > 5) mydebug = 5;
303  while(mydebug--) {
304  proj_class_incr_debug(NULL);
305  }
306  }
307  if(optremaining == NULL || *optremaining == NULL) {
308  usage(argv[0]);
309  exit(1);
310  }
311  // use -- to end option scanning
312 
315  config->setframe(config, CONFIGNAME_OUTSIG, &signature->baseclass);
316  compressionframe->compression_threshold = 1; // Make sure it gets exercised
317  config->setframe(config, CONFIGNAME_COMPRESS, &compressionframe->baseclass);
318  UNREF2(compressionframe);
319  // Encrypt if only one address and it's a loopback address...
320  if (NULL == optremaining[1]) {
321  NetAddr* addr = netaddr_string_new(optremaining[0]);
322  if (addr->islocal(addr)) {
323  addr->setport(addr, PORT);
329  g_message("NOTE: Encryption enabled. Incoming packet Identities will be verified.");
330  encryption_enabled = TRUE;
331  }
332  UNREF(addr);
333  }
334  transport = reliableudp_new(0, config, decoder, 0);
336  transport->baseclass.baseclass.enablepktloss(&transport->baseclass.baseclass, TRUE);
337  g_return_val_if_fail(transport->baseclass.baseclass.bindaddr(&transport->baseclass.baseclass, anyaddr, FALSE),16);
338  insize = transport->baseclass.baseclass.getsockbufsize(&transport->baseclass.baseclass, TRUE);
339  insize = transport->baseclass.baseclass.setsockbufsize(&transport->baseclass.baseclass, TRUE, insize*16);
340  outsize = transport->baseclass.baseclass.getsockbufsize(&transport->baseclass.baseclass, FALSE);
341  outsize = transport->baseclass.baseclass.setsockbufsize(&transport->baseclass.baseclass, FALSE, outsize*16);
342 
343  // Connect up our network transport into the g_main_loop paradigm
344  // so we get dispatched when packets arrive
345  netpkt = netgsource_new(&transport->baseclass.baseclass, NULL, G_PRIORITY_HIGH, FALSE, NULL, 0, NULL);
346  act_on_packets = authlistener_new(0, doit, config, FALSE, NULL);
347  act_on_packets->baseclass.associate(&act_on_packets->baseclass, netpkt);
348  //g_source_ref(&netpkt->baseclass);
349 
350  fprintf(stderr, "Expecting %d packets\n", maxpingcount);
351  fprintf(stderr, "Sending %d SEQPONG packets per SEQPING packet\n", pongcount);
352  fprintf(stderr, "Transmit packet loss: %g\n", XMITLOSS*100);
353  fprintf(stderr, "Receive packet loss: %g\n", RCVLOSS*100);
354  fprintf(stderr, "Pong packet padding: %ld bytes\n", (long)pongsize);
355  fprintf(stderr, "Socket input buffer: %d bytes\n", insize);
356  fprintf(stderr, "Socket output buffer: %d bytes\n", outsize);
357 
358 
359  loop = g_main_loop_new(g_main_context_default(), TRUE);
360 
361  // Kick everything off with a pingy-dingy
362  for(argcount=0; optremaining[argcount]; ++argcount) {
363  FrameSet* ping;
364  NetAddr* toaddr;
365  NetAddr* v6addr;
366  gchar * ipaddr = optremaining[argcount];
367  IntFrame* iframe = intframe_new(FRAMETYPE_CINTVAL, sizeof(pingcount));
368  fprintf(stderr, "ipaddr = %s\n", ipaddr);
369 
370  if (strcmp(ipaddr, "::") == 0) {
371  fprintf(stderr, "WARNING: %s is not a valid ipv4/v6 address for our purposes.\n"
372  , ipaddr);
373  UNREF2(iframe);
374  continue;
375  }
376  toaddr = netaddr_string_new(ipaddr);
377  if (toaddr == NULL) {
378  fprintf(stderr, "WARNING: %s is not a valid ipv4/v6 address.\n"
379  , ipaddr);
380  UNREF2(iframe);
381  continue;
382  }
383  v6addr = toaddr->toIPv6(toaddr); UNREF(toaddr);
384  v6addr->setport(v6addr, PORT);
385  if (g_hash_table_lookup(ourcounts, v6addr)) {
386  fprintf(stderr, "WARNING: %s is a duplicate ipv4/v6 address.\n"
387  , ipaddr);
388  UNREF2(iframe);
389  UNREF(v6addr);
390  continue;
391  }
392  g_hash_table_insert(ourcounts, v6addr, GINT_TO_POINTER(1));
393  REF(v6addr); // For the 'ourcounts' table
394  {
395  char * addrstr= v6addr->baseclass.toString(&v6addr->baseclass);
396  fprintf(stderr, "Sending an initial SEQPING to %s\n", addrstr);
397  g_free(addrstr); addrstr = NULL;
398  }
400  iframe->setint(iframe, 1);
401  frameset_append_frame(ping, &iframe->baseclass);
402  UNREF2(iframe);
403  transport->baseclass.baseclass.sendareliablefs(&transport->baseclass.baseclass, v6addr, 0, ping);
404  UNREF(ping);
405  UNREF(v6addr);
406  }
407  // Free up our argument list
408  g_strfreev(optremaining);
409  optremaining = NULL;
410 
411  UNREF(decoder);
412  UNREF2(signature);
413  UNREF(config);
414  UNREF(anyaddr);
415  g_main_loop_run(loop);
416  act_on_packets->baseclass.dissociate(&act_on_packets->baseclass);
417  UNREF2(act_on_packets);
418 
419  UNREF3(transport); // 'transport' global variable is referenced while the loop is running
420 
421  // Free up our hash tables and they NetAddrs we've held onto
422  {
423  GHashTableIter iter;
424  gpointer key;
425  gpointer value;
426  g_hash_table_iter_init(&iter, theircounts);
427  while (g_hash_table_iter_next(&iter, &key, &value)) {
428  NetAddr* addr = CASTTOCLASS(NetAddr, key);
429  g_hash_table_iter_remove(&iter);
430  UNREF(addr);
431  }
432  g_hash_table_destroy(theircounts); theircounts = NULL;
433  g_hash_table_iter_init(&iter, ourcounts);
434  while (g_hash_table_iter_next(&iter, &key, &value)) {
435  NetAddr* addr = CASTTOCLASS(NetAddr, key);
436  g_hash_table_iter_remove(&iter);
437  UNREF(addr);
438  }
439  g_hash_table_destroy(ourcounts); ourcounts = NULL;
440  }
441  g_main_loop_unref(loop);
442  g_source_unref(&netpkt->baseclass);
443  g_main_context_unref(g_main_context_default());
445  // At this point - nothing should show up - we should have freed everything
446  liveobjcount = proj_class_live_object_count();
447  if (liveobjcount > 0) {
448  g_warning("============ OOPS %d objects still alive ==============================="
449  , liveobjcount);
451  g_warning("Too many objects (%d) alive at end of test.", liveobjcount);
452  exitcode=1;
453  }else{
454  g_message("No objects left alive. Awesome!");
455  }
456  proj_class_finalize_sys(); // Shut down object system to make valgrind happy :-D
457  return exitcode;
458 }
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
int setsockbufsize(const NetIO *self, gboolean forinput, gsize bufsize)
< Set socket buffer size - return new size or -1
WINEXPORT void cryptcurve25519_gen_temp_keypair(const char *key_id)
Generate a temporary (non-persistent) key pair.
Listener baseclass
Definition: authlistener.h:42
GSource baseclass
Parent GSource Object pointer.
Definition: netgsource.h:44
AssimObj baseclass
Definition: frameset.h:47
#define UNREF3(obj)
Definition: assimobj.h:37
#define CRYPTO_IDENTITY
Definition: pinger.c:46
#define FSPR_INSHUTDOWN(state)
Definition: fsprotocol.h:70
void(* setport)(NetAddr *, guint16)
Set port for this NetAddr.
Definition: netaddr.h:45
gboolean sendreliablefs(NetIO *self, NetAddr *dest, guint16 queueid, GSList *fslist)
< Reliably send multiple FrameSets (if possible)
This is an IntFrame class TLV (type, length, value) frame - representing an integer of some specified...
Definition: intframe.h:39
Structure associating FrameSet class types with actions to perform when they&#39;re received.
Definition: authlistener.h:51
#define CRYPTO_KEYID
Definition: pinger.c:45
void setpktloss(NetIO *self, double rcv, double xmit)
< Set desired fraction of packet loss - TESTING ONLY!
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
guint64(* getint)(IntFrame *self)
get value of integer in this IntFrame
Definition: intframe.h:42
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.
IntFrame * intframe_new(guint16 frametype, int intbytes)
Construct new IntFrame object.
Definition: intframe.c:179
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
void(* dissociate)(Listener *self)
Dissociate us from our source.
Definition: listener.h:51
gboolean ackmessage(NetIO *self, NetAddr *dest, FrameSet *frameset)
< User-level ACK of a message sent reliably
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
int pongcount
Definition: pinger.c:73
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
#define FRAMESETTYPE_SEQPING
Are you alive? (can come from anyone)
Definition: framesettypes.h:47
The SignFrame class object - implements digital signatures for FrameSets.
Definition: signframe.h:47
NetAddr *(* toIPv6)(const NetAddr *)
Convert this NetAddr to the IPv6 equivalent.
Definition: netaddr.h:56
NetGSource * netpkt
Definition: nanomain.c:74
WINEXPORT const char * frameset_sender_identity(const FrameSet *self)
Return the identity of this Frameset&#39;s CryptFrame sender – NULL if None or Unknown.
Definition: frameset.c:451
#define RCVLOSS
Definition: pinger.c:50
void obey_pingpong(AuthListener *, FrameSet *fs, NetAddr *)
Definition: pinger.c:110
guint32 compression_threshold
Definition: compressframe.h:43
void(* setvalue)(Frame *self, gpointer value, guint32 length, GDestroyNotify valfinal)
member function for setting value
Definition: frame.h:52
#define FRAMETYPEMAP
Definition: frametypes.h:446
guint16 fstype
Type of frameset.
Definition: frameset.h:52
PacketDecoder * packetdecoder_new(guint objsize, const FrameTypeToFrame *framemap, gint mapsize)
Initialize our frame type map.
Definition: packetdecoder.c:77
enum _FsProtoState FsProtoState
Definition: fsprotocol.h:48
void(* setframe)(ConfigContext *, const char *, Frame *)
Set Frame value.
Definition: configcontext.h:91
Implements the IntFrame class - integers in a frame.
WINEXPORT void cryptframe_shutdown(void)
Shut down our key caches and so on... (destroy our maps)
Definition: cryptframe.c:159
ObeyFrameSetTypeMap doit[]
Definition: pinger.c:79
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 __FUNCTION__
CompressFrame * compressframe_new(guint16 frame_type, guint16 compression_method)
This is our CompressFrame class object - used for representing a compression method.
Definition: compressframe.h:41
void(* setint)(IntFrame *self, guint64 value)
set the integer to the given value
Definition: intframe.h:43
Describes interfaces to CryptFrame (encryption) C-Class It represents the abstract base class for Fra...
Implements the Reliable UDP network I/O transport (ReliableUDP) class.
Frame * frame_new(guint16 frame_type, gsize framesize)
Construct a new frame - allowing for "derived" frame types...
Definition: frame.c:125
#define COMPRESS_ZLIB
Compression using &#39;zlib&#39;.
Definition: compressframe.h:38
This is the AuthListener class. object - which (authorizes and) obeys packets from the Authority...
Definition: authlistener.h:41
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:1092
#define FREE(m)
Our interface to free.
Definition: projectcommon.h:29
#define REF(obj)
Definition: assimobj.h:39
void usage(const char *cmdname)
Definition: pinger.c:231
FsProtocol * _protocol
Queuing, ordering, retransmission and ACKing discipline.
Definition: reliableudp.h:45
Data structure defining the mapping between frametype integers and corresponding demarshalling module...
Definition: packetdecoder.h:37
guint pongsize
Definition: pinger.c:77
WINEXPORT gboolean netaddr_g_hash_equal(gconstpointer lhs, gconstpointer rhs)
g_hash_table equal comparator for a NetAddr
Definition: netaddr.c:426
gchar *(* toString)(gconstpointer)
Produce malloc-ed string representation.
Definition: assimobj.h:58
#define XMITLOSS
Definition: pinger.c:51
guint32 proj_class_live_object_count(void)
Return the count of live C class objects.
Definition: proj_classes.c:406
#define DIMOF(a)
Definition: lldp_min.c:30
WINEXPORT const char * frameset_sender_key_id(const FrameSet *self)
Return the key_id of this Frameset&#39;s CryptFrame sender – NULL if None.
Definition: frameset.c:434
Header file defining the data layouts for our Frames.
NetAddr * anyaddr
Definition: pcap+mainloop.c:86
int maxpingcount
Definition: pinger.c:74
void(* associate)(Listener *self, NetGSource *source)
NetGSource class to associate with
Definition: listener.h:49
gboolean encryption_enabled
Definition: pinger.c:76
#define CONFIGNAME_COMPRESS
Frame to use for compressing/decompressing.
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
GHashTable * ourcounts
Definition: pinger.c:87
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
#define FRAMETYPE_CINTVAL
FRAMETYPE_CINTVAL Frame (frametype 22) Frame subclass - IntFrame class.
Definition: frametypes.h:342
#define FRAMESETTYPE_SEQPONG
I am alive (can go to anyone)
Definition: framesettypes.h:48
gboolean sendareliablefs(NetIO *self, NetAddr *dest, guint16 queueid, FrameSet *frameset)
[out] source address of return result
void enablepktloss(NetIO *self, gboolean enable)
< enable packet loss (as set above)
WINEXPORT void cryptframe_set_encryption_method(CryptFrame *(*method)(const char *sender_key_id, const char *receiver_key_id, gboolean forsending))
Definition: cryptframe.c:518
void(* closeall)(FsProtocol *)
Close all our connections.
Definition: fsprotocol.h:129
int getsockbufsize(const NetIO *self, gboolean forinput)
< Return socket buffer size: -1 on failure
gboolean exit_when_connsdown(gpointer)
Definition: pinger.c:90
guint16 type
Frame Type (see Individual TLV &#39;Frame&#39; 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
Describes interfaces to Address Frame (AddrFrame) C-Class.
Frame baseclass
base Frame class object
Definition: intframe.h:40
Defines interfaces for the NetAddr (network address) object.
int main(int argc, char **argv)
Definition: pinger.c:246
Describes interfaces to Address Frame (IpPortFrame) C-Class.
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
NetIO baseclass
Base class (NetIO) object.
Definition: netioudp.h:41
GMainLoop * loop
Definition: pinger.c:75
FrameSet class - used for collecting Frames when not on the wire, and for marshalling/demarshalling t...
Definition: frameset.h:46
#define PORT
Definition: pinger.c:47
WINEXPORT guint netaddr_g_hash_hash(gconstpointer addrptr)
g_hash_table hash function for a NetAddr
Definition: netaddr.c:435
void obey_connshut(AuthListener *, FrameSet *, NetAddr *)
Definition: pinger.c:101
WINEXPORT void cryptframe_set_signing_key_id(const char *key_id)
Set the default signing key.
Definition: cryptframe.c:416
GHashTable * theircounts
Definition: pinger.c:86
Implements the SeqnoFrame class.
void proj_class_dump_live_objects(void)
Dump all live C class objects (address and Class)
Definition: proj_classes.c:356
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
NetIOudp baseclass
Base class (NetIO) object.
Definition: reliableudp.h:44
NetAddr * netaddr_string_new(const char *addrstr)
Create a NetAddr from an ipv4, ipv6 or MAC address string.
Definition: netaddr.c:976
This file defines a few functions and interfaces for unmarshalling packet data into FrameSets...
Describes interfaces to name/value pair Frame (NVpairFrame) C-Class It holds conventional zero-termin...
#define FRAMETYPE_PKTDATA
FRAMETYPE_PKTDATA Frame (frametype 6) Frame subclass - Frame class.
Definition: frametypes.h:152
#define UNREF2(obj)
Definition: assimobj.h:36
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 FRAMETYPE_COMPRESS
FRAMETYPE_COMPRESS Frame (frametype 3) Frame subclass - CompressFrame class.
Definition: frametypes.h:122
#define CASTTOCLASS(Cclass, obj)
Safely cast &#39;obj&#39; to C-class &#39;class&#39; - verifying that it was registerd as being of type class ...
Definition: proj_classes.h:66
#define UNREF(obj)
Definition: assimobj.h:35
FsProtoState(* connstate)(FsProtocol *, guint16, const NetAddr *)
Return the state of this connection.
Definition: fsprotocol.h:121
gboolean(* islocal)(const NetAddr *self)
Return TRUE if this address is a local address.
Definition: netaddr.h:49
int(* activeconncount)(FsProtocol *)
How many active connections do we have?
Definition: fsprotocol.h:130
The NetGSource class objects integrate NetIO class objects into the g_main_loop paradigm.
Definition: netgsource.h:43
ReliableUDP * transport
Definition: pinger.c:72
#define FRAMESETTYPE_CONNSHUT
Shutting down this connection (can also come from CMA)
Definition: framesettypes.h:37
Describes interfaces to CryptFrame (encryption) C-Class It represents a FrameSet using libsodium (cur...