Commit 8223aa6a authored by Pavel Tvrdík's avatar Pavel Tvrdík

Socktest: Recv multicast/destination address

Load multicast address at receive into daddr
parent c9b1ec65
......@@ -217,9 +217,10 @@ parse_int(const char *src, int *dst)
void
parse_args(int argc, char **argv, int need_daddr)
parse_args(int argc, char **argv, int is_send)
{
const char *opt_list = "umbRi:l:B:p:v:t:";
int is_recv = !is_send;
const char *opt_list = is_send ? "umbRi:l:B:p:v:t:" : "um:bRi:l:B:p:v:t:";
int c;
while ((c = getopt(argc, argv, opt_list)) >= 0)
......@@ -230,6 +231,8 @@ parse_args(int argc, char **argv, int need_daddr)
break;
case 'm':
cf_mcast = 1;
if (is_recv)
parse_addr(optarg, &cf_daddr);
break;
case 'b':
cf_bcast = 1;
......@@ -261,16 +264,16 @@ parse_args(int argc, char **argv, int need_daddr)
goto usage;
}
if (optind + need_daddr != argc)
if (optind + is_send != argc)
goto usage;
if (need_daddr)
if (is_send)
parse_addr(argv[optind], &cf_daddr);
return;
usage:
printf("Usage: %s [-u] [-m|-b] [-B baddr] [-R] [-i iface] [-l addr] [-p port] [-v value] [-t ttl]%s\n",
argv[0], need_daddr ? " daddr" : "");
printf("Usage: %s [-u] [-m%s|-b] [-B baddr] [-R] [-i iface] [-l addr] [-p port] [-v value] [-t ttl]%s\n",
argv[0], is_recv ? " maddr" : "", is_send ? " daddr" : "");
exit(1);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment