aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/akcom-udpecho.c
diff options
context:
space:
mode:
authorDavid M. Syzdek <david.syzdek@acsalaska.com>2022-07-21 16:00:58 -0800
committerDavid M. Syzdek <david.syzdek@acsalaska.com>2022-07-21 16:00:58 -0800
commitcb948a2ef0c0f88b16df2cb512b6585713e7ee65 (patch)
tree7cb10231414deebef65ca521f9ab04189ec52e73 /src/akcom-udpecho.c
parent49b497dc2bdbf1b58faec6c2475d3d55d3148c75 (diff)
downloadakcom-udpecho-cb948a2ef0c0f88b16df2cb512b6585713e7ee65.tar.gz
akcom-udpecho-cb948a2ef0c0f88b16df2cb512b6585713e7ee65.tar.bz2
akcom-udpecho-cb948a2ef0c0f88b16df2cb512b6585713e7ee65.tar.xz
akcom-udpecho-cb948a2ef0c0f88b16df2cb512b6585713e7ee65.zip
akcom-udpecho: adding ability to print packet information
Diffstat (limited to 'src/akcom-udpecho.c')
-rw-r--r--src/akcom-udpecho.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/akcom-udpecho.c b/src/akcom-udpecho.c
index ceae224..2ce1cb5 100644
--- a/src/akcom-udpecho.c
+++ b/src/akcom-udpecho.c
@@ -147,6 +147,7 @@ union udp_buffer
147 147
148static const char * prog_name = PROGRAM_NAME; 148static const char * prog_name = PROGRAM_NAME;
149static uint32_t cnf_count = 0; 149static uint32_t cnf_count = 0;
150static int cnf_debug = 0;
150static int cnf_echoplus = 0; 151static int cnf_echoplus = 0;
151static int cnf_verbose = 0; 152static int cnf_verbose = 0;
152static int cnf_silent = 0; 153static int cnf_silent = 0;
@@ -222,9 +223,10 @@ int main(int argc, char * argv[])
222 union udp_buffer rcvbuff; 223 union udp_buffer rcvbuff;
223 224
224 // getopt options 225 // getopt options
225 static char short_opt[] = "46c:ehi:qrs:t:vV"; 226 static char short_opt[] = "46c:dehi:qrs:t:vV";
226 static struct option long_opt[] = 227 static struct option long_opt[] =
227 { 228 {
229 {"debug", no_argument, 0, 'd'},
228 {"echoplus", no_argument, 0, 'e'}, 230 {"echoplus", no_argument, 0, 'e'},
229 {"help", no_argument, 0, 'h'}, 231 {"help", no_argument, 0, 'h'},
230 {"quiet", no_argument, 0, 'q'}, 232 {"quiet", no_argument, 0, 'q'},
@@ -268,6 +270,10 @@ int main(int argc, char * argv[])
268 cnf_count = (uint32_t)strtoul(optarg, NULL, 10); 270 cnf_count = (uint32_t)strtoul(optarg, NULL, 10);
269 break; 271 break;
270 272
273 case 'd':
274 cnf_debug = 1;
275 break;
276
271 case 'e': 277 case 'e':
272 cnf_echoplus = 1; 278 cnf_echoplus = 1;
273 break; 279 break;
@@ -492,6 +498,13 @@ int main(int argc, char * argv[])
492 rcvbuff.echoplus->reply_time = ntohl(rcvbuff.echoplus->reply_time); 498 rcvbuff.echoplus->reply_time = ntohl(rcvbuff.echoplus->reply_time);
493 rcvbuff.echoplus->failures = ntohl(rcvbuff.echoplus->failures); 499 rcvbuff.echoplus->failures = ntohl(rcvbuff.echoplus->failures);
494 rcvbuff.echoplus->iteration = ntohl(1); 500 rcvbuff.echoplus->iteration = ntohl(1);
501 if ((cnf_debug))
502 {
503 printf(" packet: GenSN/REspSN: %08" PRIx32 " %08" PRIx32 "\n", rcvbuff.echoplus->req_sn, rcvbuff.echoplus->res_sn);
504 printf(" Recv/Reply Time: %08" PRIx32 " %08" PRIx32 "\n", rcvbuff.echoplus->recv_time, rcvbuff.echoplus->reply_time);
505 printf(" Failures: %08" PRIx32 "\n", rcvbuff.echoplus->failures);
506 printf(" Iteration: %08" PRIx32 "\n", rcvbuff.echoplus->iteration);
507 };
495 rcvd++; 508 rcvd++;
496 delay = rcvbuff.echoplus->reply_time - rcvbuff.echoplus->recv_time; 509 delay = rcvbuff.echoplus->reply_time - rcvbuff.echoplus->recv_time;
497 delay /= 100000000; 510 delay /= 100000000;
@@ -583,6 +596,7 @@ void my_usage(void)
583 printf(" -4 connect via IPv4 only\n"); 596 printf(" -4 connect via IPv4 only\n");
584 printf(" -6 connect via IPv6 only\n"); 597 printf(" -6 connect via IPv6 only\n");
585 printf(" -c count stop after sending count packets\n"); 598 printf(" -c count stop after sending count packets\n");
599 printf(" -d, --debug print packet debugging information\n");
586 printf(" -e, --echoplus expect echo plus response%s\n", ((cnf_echoplus)) ? " (default)" : ""); 600 printf(" -e, --echoplus expect echo plus response%s\n", ((cnf_echoplus)) ? " (default)" : "");
587 printf(" -h, --help print this help and exit\n"); 601 printf(" -h, --help print this help and exit\n");
588 printf(" -i interval interval between packet (default: %lu sec)\n", cnf_interval); 602 printf(" -i interval interval between packet (default: %lu sec)\n", cnf_interval);