1 /* pingpool.c -- Show the input/output of a PING operation.
3 * From: Rick van Rein <rick@openfortress.nl>
12 #include <tlspool/commands.h>
13 #include <tlspool/starttls.h>
16 void print_pioc_ping (pingpool_t *pp, char *prefix) {
17 char *date = pp->YYYYMMDD_producer;
18 char *producer = date + 8;
21 if (pp->facilities & PIOF_FACILITY_STARTTLS) {
22 strcat (facil, ",starttls");
23 pp->facilities &= ~PIOF_FACILITY_STARTTLS;
25 if (pp->facilities & PIOF_FACILITY_STARTGSS) {
26 strcat (facil, ",startgss");
27 pp->facilities &= ~PIOF_FACILITY_STARTGSS;
29 if (pp->facilities & PIOF_FACILITY_STARTSSH) {
30 strcat (facil, ",startssh");
31 pp->facilities &= ~PIOF_FACILITY_STARTSSH;
34 sprintf (facil + strlen (facil), ",0%08x", pp->facilities);
36 printf ("%s specdate: %.4s-%.2s-%.2s\n", prefix, date, date+4, date+6);
37 printf ("%s specfrom: %s\n", prefix, producer);
38 printf ("%s facility: %s\n", prefix, facil + 1);
41 int main (int argc, char *argv []) {
42 char *sockpath = NULL;
46 fprintf (stderr, "Usage: %s [socketfile]\n", argv [0]);
52 (void) tlspool_open_poolhandle (sockpath);
54 memset (&pp, 0, sizeof (pp));
55 strcpy (pp.YYYYMMDD_producer, TLSPOOL_IDENTITY_V2);
56 pp.facilities = PIOF_FACILITY_ALL_CURRENT;
58 print_pioc_ping (&pp, "Client ");
61 // What we do now is not what any normal program should do; we ask
62 // for all the facilities that the TLS Pool can provide. That may
63 // include things we never heard of, and may need to mention as an
64 // integer flag value. For a ping utility, that's useful, but for
65 // any sane program it would be a bad example to follow.
68 if (tlspool_ping (&pp) < 0) {
69 perror ("Failed to ping TLS Pool");
72 print_pioc_ping (&pp, "TLS Pool");