MCPcopy Create free account
hub / github.com/esnet/iperf / iperf_parse_hostname

Function iperf_parse_hostname

src/iperf_api.c:1063–1099  ·  view source on GitHub ↗

* iperf_parse_hostname tries to split apart a string into hostname % * interface parts, which are returned in **p and **p1, if they * exist. If the %interface part is detected, and it's not an IPv6 * link local address, then returns 1, else returns 0. * * Modifies the string pointed to by spec in-place due to the use of * strtok(3). The caller should strdup(3) or otherwise copy the string *

Source from the content-addressed store, hash-verified

1061 * if an unmodified copy is needed.
1062 */
1063int
1064iperf_parse_hostname(struct iperf_test *test, char *spec, char **p, char **p1) {
1065 struct in6_addr ipv6_addr;
1066
1067 // Format is <addr>[%<device>]
1068 if ((*p = strtok(spec, "%")) != NULL &&
1069 (*p1 = strtok(NULL, "%")) != NULL) {
1070
1071 /*
1072 * If an IPv6 literal for a link-local address, then
1073 * tell the caller to leave the "%" in the hostname.
1074 */
1075 if (inet_pton(AF_INET6, *p, &ipv6_addr) == 1 &&
1076 IN6_IS_ADDR_LINKLOCAL(&ipv6_addr)) {
1077 if (test->debug) {
1078 iperf_printf(test, "IPv6 link-local address literal detected\n");
1079 }
1080 return 0;
1081 }
1082 /*
1083 * Other kind of address or FQDN. The interface name after
1084 * "%" is a shorthand for --bind-dev.
1085 */
1086 else {
1087 if (test->debug) {
1088 iperf_printf(test, "p %s p1 %s\n", *p, *p1);
1089 }
1090 return 1;
1091 }
1092 }
1093 else {
1094 if (test->debug) {
1095 iperf_printf(test, "noparse\n");
1096 }
1097 return 0;
1098 }
1099}
1100
1101int
1102iperf_parse_arguments(struct iperf_test *test, int argc, char **argv)

Callers 1

iperf_parse_argumentsFunction · 0.85

Calls 1

iperf_printfFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…