| 521 | } |
| 522 | |
| 523 | static void parse_opts(int argc, char **argv) |
| 524 | { |
| 525 | const char *cfg_test; |
| 526 | const int max_udp_payload_len = IP_MAXPACKET - |
| 527 | sizeof(struct ipv6hdr) - |
| 528 | sizeof(struct tcphdr) - |
| 529 | 40 /* max tcp options */; |
| 530 | int c; |
| 531 | char *daddr = NULL; |
| 532 | |
| 533 | if (argc <= 1) { |
| 534 | usage(argv[0]); |
| 535 | exit(0); |
| 536 | } |
| 537 | |
| 538 | cfg_payload_len = max_udp_payload_len; |
| 539 | |
| 540 | while ((c = getopt(argc, argv, "46D:p:s:t:n:z:I:b:l:dC:T:Ryv")) != -1) { |
| 541 | switch (c) { |
| 542 | case '4': |
| 543 | if (cfg_family != PF_UNSPEC) |
| 544 | t_error(1, 0, "Pass one of -4 or -6"); |
| 545 | cfg_family = PF_INET; |
| 546 | cfg_alen = sizeof(struct sockaddr_in); |
| 547 | break; |
| 548 | case '6': |
| 549 | if (cfg_family != PF_UNSPEC) |
| 550 | t_error(1, 0, "Pass one of -4 or -6"); |
| 551 | cfg_family = PF_INET6; |
| 552 | cfg_alen = sizeof(struct sockaddr_in6); |
| 553 | break; |
| 554 | case 'I': |
| 555 | cfg_ifname = optarg; |
| 556 | break; |
| 557 | case 'D': |
| 558 | daddr = optarg; |
| 559 | break; |
| 560 | case 'p': |
| 561 | cfg_port = strtoul(optarg, NULL, 0); |
| 562 | break; |
| 563 | case 's': |
| 564 | cfg_payload_len = strtoul(optarg, NULL, 0); |
| 565 | break; |
| 566 | case 't': |
| 567 | cfg_runtime_ms = 200 + strtoul(optarg, NULL, 10) * 1000; |
| 568 | break; |
| 569 | case 'n': |
| 570 | cfg_nr_reqs = strtoul(optarg, NULL, 0); |
| 571 | break; |
| 572 | case 'z': |
| 573 | cfg_zc = strtoul(optarg, NULL, 0); |
| 574 | break; |
| 575 | case 'b': |
| 576 | cfg_fixed_buf = strtoul(optarg, NULL, 0); |
| 577 | break; |
| 578 | case 'l': |
| 579 | cfg_hugetlb = strtoul(optarg, NULL, 0); |
| 580 | break; |