MCPcopy Create free account
hub / github.com/F-Stack/f-stack / nptv6_parse_prefix

Function nptv6_parse_prefix

tools/ipfw/nptv6.c:165–184  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

163
164
165static void
166nptv6_parse_prefix(const char *arg, struct in6_addr *prefix, int *len)
167{
168 char *p, *l;
169
170 p = strdup(arg);
171 if (p == NULL)
172 err(EX_OSERR, NULL);
173 if ((l = strchr(p, '/')) != NULL)
174 *l++ = '\0';
175 if (inet_pton(AF_INET6, p, prefix) != 1)
176 errx(EX_USAGE, "Bad prefix: %s", p);
177 if (l != NULL) {
178 *len = (int)strtol(l, &l, 10);
179 if (*l != '\0' || *len <= 0 || *len > 64)
180 errx(EX_USAGE, "Bad prefix length: %s", arg);
181 } else
182 *len = 0;
183 free(p);
184}
185/*
186 * Creates new nptv6 instance
187 * ipfw nptv6 <NAME> create int_prefix <prefix> ext_prefix <prefix>

Callers 1

nptv6_createFunction · 0.85

Calls 5

strdupFunction · 0.85
strchrFunction · 0.85
inet_ptonFunction · 0.85
strtolFunction · 0.85
freeFunction · 0.50

Tested by

no test coverage detected