diff options
| author | David M. Syzdek <david.syzdek@acsalaska.com> | 2022-07-21 17:33:41 -0800 |
|---|---|---|
| committer | David M. Syzdek <david.syzdek@acsalaska.com> | 2022-07-21 17:33:41 -0800 |
| commit | 9c14692a2689bbb2251aeae6dd7fb51d7f5ec646 (patch) | |
| tree | d450c080f2869395096aaf4b7c2335b02e3051be | |
| parent | c0cfe7d9316bd158a407686f612e7fb90c19f5a6 (diff) | |
| download | akcom-udpecho-9c14692a2689bbb2251aeae6dd7fb51d7f5ec646.tar.gz akcom-udpecho-9c14692a2689bbb2251aeae6dd7fb51d7f5ec646.tar.bz2 akcom-udpecho-9c14692a2689bbb2251aeae6dd7fb51d7f5ec646.tar.xz akcom-udpecho-9c14692a2689bbb2251aeae6dd7fb51d7f5ec646.zip | |
akcom-udpecho: adding typedef for struct udp_echo_plus
| -rw-r--r-- | src/akcom-udpecho.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/akcom-udpecho.c b/src/akcom-udpecho.c index 5a4b1f7..888a2b4 100644 --- a/src/akcom-udpecho.c +++ b/src/akcom-udpecho.c | |||
| @@ -120,7 +120,7 @@ union my_sa | |||
| 120 | }; | 120 | }; |
| 121 | 121 | ||
| 122 | 122 | ||
| 123 | struct udp_echo_plus | 123 | typedef struct udp_echo_plus |
| 124 | { | 124 | { |
| 125 | uint32_t req_sn; | 125 | uint32_t req_sn; |
| 126 | uint32_t res_sn; | 126 | uint32_t res_sn; |
| @@ -129,7 +129,7 @@ struct udp_echo_plus | |||
| 129 | uint32_t failures; | 129 | uint32_t failures; |
| 130 | uint32_t iteration; | 130 | uint32_t iteration; |
| 131 | uint8_t bytes[]; | 131 | uint8_t bytes[]; |
| 132 | }; | 132 | } echoplus_t; |
| 133 | 133 | ||
| 134 | 134 | ||
| 135 | ///////////////// | 135 | ///////////////// |
| @@ -150,7 +150,7 @@ static const char * cnf_port = "30006"; | |||
| 150 | static const char * cnf_host = NULL; | 150 | static const char * cnf_host = NULL; |
| 151 | static int cnf_ai_family = PF_UNSPEC; | 151 | static int cnf_ai_family = PF_UNSPEC; |
| 152 | static unsigned long cnf_interval = 1; | 152 | static unsigned long cnf_interval = 1; |
| 153 | static size_t cnf_packetsize = sizeof(struct udp_echo_plus); | 153 | static size_t cnf_packetsize = sizeof(echoplus_t); |
| 154 | static int should_stop = 0; | 154 | static int should_stop = 0; |
| 155 | 155 | ||
| 156 | 156 | ||
| @@ -230,8 +230,8 @@ main( | |||
| 230 | struct timespec start; | 230 | struct timespec start; |
| 231 | struct timespec now; | 231 | struct timespec now; |
| 232 | struct pollfd fds[2]; | 232 | struct pollfd fds[2]; |
| 233 | struct udp_echo_plus * sndbuff; | 233 | echoplus_t * sndbuff; |
| 234 | struct udp_echo_plus * rcvbuff; | 234 | echoplus_t * rcvbuff; |
| 235 | 235 | ||
| 236 | // getopt options | 236 | // getopt options |
| 237 | static char short_opt[] = "46c:dehi:qrs:t:vV"; | 237 | static char short_opt[] = "46c:dehi:qrs:t:vV"; |
| @@ -340,8 +340,8 @@ main( | |||
| 340 | }; | 340 | }; |
| 341 | 341 | ||
| 342 | // adjust defaults | 342 | // adjust defaults |
| 343 | if (cnf_packetsize < sizeof(struct udp_echo_plus)) | 343 | if (cnf_packetsize < sizeof(echoplus_t)) |
| 344 | cnf_packetsize = sizeof(struct udp_echo_plus); | 344 | cnf_packetsize = sizeof(echoplus_t); |
| 345 | 345 | ||
| 346 | // allocate receive buffer | 346 | // allocate receive buffer |
| 347 | if ((rcvbuff = malloc(cnf_packetsize)) == NULL) | 347 | if ((rcvbuff = malloc(cnf_packetsize)) == NULL) |
| @@ -357,9 +357,9 @@ main( | |||
| 357 | free(rcvbuff); | 357 | free(rcvbuff); |
| 358 | return(1); | 358 | return(1); |
| 359 | }; | 359 | }; |
| 360 | memset(sndbuff, 0, sizeof(struct udp_echo_plus)); | 360 | memset(sndbuff, 0, sizeof(echoplus_t)); |
| 361 | sndbuff->iteration = htonl(1); | 361 | sndbuff->iteration = htonl(1); |
| 362 | if (cnf_packetsize > sizeof(struct udp_echo_plus)) | 362 | if (cnf_packetsize > sizeof(echoplus_t)) |
| 363 | { | 363 | { |
| 364 | if ((fd = open("/dev/urandom", O_RDONLY)) == -1) | 364 | if ((fd = open("/dev/urandom", O_RDONLY)) == -1) |
| 365 | { | 365 | { |
| @@ -368,7 +368,7 @@ main( | |||
| 368 | free(sndbuff); | 368 | free(sndbuff); |
| 369 | return(1); | 369 | return(1); |
| 370 | }; | 370 | }; |
| 371 | if (read(fd, sndbuff->bytes, cnf_packetsize-sizeof(struct udp_echo_plus)) == -1) | 371 | if (read(fd, sndbuff->bytes, cnf_packetsize-sizeof(echoplus_t)) == -1) |
| 372 | { | 372 | { |
| 373 | fprintf(stderr, "%s: read(): %s\n", prog_name, strerror(errno)); | 373 | fprintf(stderr, "%s: read(): %s\n", prog_name, strerror(errno)); |
| 374 | close(fd); | 374 | close(fd); |
