diff options
| author | David M. Syzdek <david.syzdek@acsalaska.com> | 2020-02-10 12:45:26 -0900 |
|---|---|---|
| committer | David M. Syzdek <david.syzdek@acsalaska.com> | 2020-02-10 12:45:26 -0900 |
| commit | 94f676d590baa0d72ec99674d33f15314385d385 (patch) | |
| tree | 6b0864def74d9157d085325bf65311c0026b28a0 | |
| parent | ec6a997e575c4c414921ce4fce29666b61f08c43 (diff) | |
| download | akcom-udpecho-94f676d590baa0d72ec99674d33f15314385d385.tar.gz akcom-udpecho-94f676d590baa0d72ec99674d33f15314385d385.tar.bz2 akcom-udpecho-94f676d590baa0d72ec99674d33f15314385d385.tar.xz akcom-udpecho-94f676d590baa0d72ec99674d33f15314385d385.zip | |
akcom-udpechod: replacing port struct member with static variable
| -rw-r--r-- | src/akcom-udpechod.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/akcom-udpechod.c b/src/akcom-udpechod.c index f3fad3b..bb90c7d 100644 --- a/src/akcom-udpechod.c +++ b/src/akcom-udpechod.c | |||
| @@ -148,7 +148,6 @@ static int should_stop = 0; | |||
| 148 | 148 | ||
| 149 | struct app_config | 149 | struct app_config |
| 150 | { | 150 | { |
| 151 | uint16_t port; // UDP port number | ||
| 152 | uint16_t echoplus; // enable echo plus | 151 | uint16_t echoplus; // enable echo plus |
| 153 | int drop_perct; // drop percentage | 152 | int drop_perct; // drop percentage |
| 154 | useconds_t delay; // Delay range in microseconds | 153 | useconds_t delay; // Delay range in microseconds |
| @@ -161,7 +160,6 @@ struct app_config | |||
| 161 | }; | 160 | }; |
| 162 | static struct app_config cnf = | 161 | static struct app_config cnf = |
| 163 | { | 162 | { |
| 164 | .port = 30006, | ||
| 165 | .echoplus = 0, | 163 | .echoplus = 0, |
| 166 | .drop_perct = 0, | 164 | .drop_perct = 0, |
| 167 | .delay = 0, | 165 | .delay = 0, |
| @@ -174,6 +172,7 @@ static struct app_config cnf = | |||
| 174 | }; | 172 | }; |
| 175 | static const char * prog_name = "a.out"; | 173 | static const char * prog_name = "a.out"; |
| 176 | static const char * cnf_pidfile = "/var/run/" PROGRAM_NAME ".pid"; | 174 | static const char * cnf_pidfile = "/var/run/" PROGRAM_NAME ".pid"; |
| 175 | static uint16_t cnf_port = 30006; | ||
| 177 | 176 | ||
| 178 | 177 | ||
| 179 | ////////////////// | 178 | ////////////////// |
| @@ -337,7 +336,7 @@ int main(int argc, char * argv[]) | |||
| 337 | break; | 336 | break; |
| 338 | 337 | ||
| 339 | case 'p': | 338 | case 'p': |
| 340 | cnf.port = (uint16_t)(atoi(optarg) & 0xffff); | 339 | cnf_port = (uint16_t)(atoi(optarg) & 0xffff); |
| 341 | break; | 340 | break; |
| 342 | 341 | ||
| 343 | case 'P': | 342 | case 'P': |
| @@ -544,19 +543,19 @@ int my_daemonize(void) | |||
| 544 | { | 543 | { |
| 545 | sa.sin6.sin6_family = AF_INET6; | 544 | sa.sin6.sin6_family = AF_INET6; |
| 546 | sa.sin6.sin6_addr = in6addr_any; | 545 | sa.sin6.sin6_addr = in6addr_any; |
| 547 | sa.sin6.sin6_port = htons(cnf.port); | 546 | sa.sin6.sin6_port = htons(cnf_port); |
| 548 | socklen = sizeof(struct sockaddr_in6); | 547 | socklen = sizeof(struct sockaddr_in6); |
| 549 | } else | 548 | } else |
| 550 | { | 549 | { |
| 551 | if ((rc = inet_pton(AF_INET, cnf.listen, &sa.sin.sin_addr)) == 1) | 550 | if ((rc = inet_pton(AF_INET, cnf.listen, &sa.sin.sin_addr)) == 1) |
| 552 | { | 551 | { |
| 553 | sa.sin.sin_family = AF_INET; | 552 | sa.sin.sin_family = AF_INET; |
| 554 | sa.sin.sin_port = htons(cnf.port); | 553 | sa.sin.sin_port = htons(cnf_port); |
| 555 | socklen = sizeof(struct sockaddr_in); | 554 | socklen = sizeof(struct sockaddr_in); |
| 556 | } else if ((rc = inet_pton(AF_INET6, cnf.listen, &sa.sin6.sin6_addr)) == 1) | 555 | } else if ((rc = inet_pton(AF_INET6, cnf.listen, &sa.sin6.sin6_addr)) == 1) |
| 557 | { | 556 | { |
| 558 | sa.sin6.sin6_family = AF_INET6; | 557 | sa.sin6.sin6_family = AF_INET6; |
| 559 | sa.sin6.sin6_port = htons(cnf.port); | 558 | sa.sin6.sin6_port = htons(cnf_port); |
| 560 | socklen = sizeof(struct sockaddr_in6); | 559 | socklen = sizeof(struct sockaddr_in6); |
| 561 | } else | 560 | } else |
| 562 | { | 561 | { |
| @@ -921,7 +920,7 @@ void my_usage(void) | |||
| 921 | printf(" -h, --help print this help and exit\n"); | 920 | printf(" -h, --help print this help and exit\n"); |
| 922 | printf(" -l addr, --listen=addr bind to IP address (default: all)\n"); | 921 | printf(" -l addr, --listen=addr bind to IP address (default: all)\n"); |
| 923 | printf(" -n, --foreground do not fork\n"); | 922 | printf(" -n, --foreground do not fork\n"); |
| 924 | printf(" -p port, --port=port list on port number (default: %u)\n", cnf.port); | 923 | printf(" -p port, --port=port list on port number (default: %u)\n", cnf_port); |
| 925 | printf(" -P file, --pidfile=file PID file (default: %s)\n", cnf_pidfile); | 924 | printf(" -P file, --pidfile=file PID file (default: %s)\n", cnf_pidfile); |
| 926 | printf(" -r, --rfc RFC compliant echo protocol%s\n", (!(cnf.echoplus)) ? " (default)" : ""); | 925 | printf(" -r, --rfc RFC compliant echo protocol%s\n", (!(cnf.echoplus)) ? " (default)" : ""); |
| 927 | printf(" -u uid, --user=uid setuid to uid (default: none)\n"); | 926 | printf(" -u uid, --user=uid setuid to uid (default: none)\n"); |
