|
@@ -290,7 +290,6 @@ static void parse_options(struct ts *ts, int argc, char **argv) {
|
290
|
290
|
int j, i, ca_err = 0, server_err = 1, input_addr_err = 0, output_addr_err = 0, output_intf_err = 0, ident_err = 0, port_set = 0;
|
291
|
291
|
opterr = 0; // Prevent printing of error messages for unknown options in getopt()
|
292
|
292
|
while ((j = getopt_long(argc, argv, short_options, long_options, NULL)) != -1) {
|
293
|
|
- char *p = NULL;
|
294
|
293
|
if (j == '?') {
|
295
|
294
|
fprintf(stderr, "ERROR: Unknown parameter '%s'.\n", argv[optind - 1]);
|
296
|
295
|
exit(EXIT_FAILURE);
|
|
@@ -461,30 +460,7 @@ static void parse_options(struct ts *ts, int argc, char **argv) {
|
461
|
460
|
}
|
462
|
461
|
break;
|
463
|
462
|
case 's': // --camd-server
|
464
|
|
- server_err = 0;
|
465
|
|
- ts->camd.hostname = optarg;
|
466
|
|
- if (optarg[0] == '[') { // Detect IPv6 static address
|
467
|
|
- p = strrchr(optarg, ']');
|
468
|
|
- if (!p) {
|
469
|
|
- fprintf(stderr, "ERROR: Invalid IPv6 address format: %s\n", optarg);
|
470
|
|
- exit(EXIT_FAILURE);
|
471
|
|
- }
|
472
|
|
- ts->camd.hostname = optarg + 1; // Remove first [
|
473
|
|
- *p = 0x00; // Remove last ]
|
474
|
|
- char *p2 = strchr(p + 1, ':');
|
475
|
|
- if (p2) {
|
476
|
|
- *p2 = 0x00;
|
477
|
|
- ts->camd.service = p2 + 1;
|
478
|
|
- port_set = 1;
|
479
|
|
- }
|
480
|
|
- } else {
|
481
|
|
- p = strrchr(optarg, ':');
|
482
|
|
- if (p) {
|
483
|
|
- *p = 0x00;
|
484
|
|
- ts->camd.service = p + 1;
|
485
|
|
- port_set = 1;
|
486
|
|
- }
|
487
|
|
- }
|
|
463
|
+ server_err = !parse_host_and_port(optarg, &ts->camd.hostname, &ts->camd.service, &port_set);
|
488
|
464
|
break;
|
489
|
465
|
case 'U': // --camd-user
|
490
|
466
|
if (strlen(optarg) < 64)
|