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

Function nat64lsn_parse_prefix

tools/ipfw/nat64lsn.c:342–362  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

340}
341
342static void
343nat64lsn_parse_prefix(const char *arg, int af, void *prefix, uint16_t *plen)
344{
345 char *p, *l;
346
347 p = strdup(arg);
348 if (p == NULL)
349 err(EX_OSERR, NULL);
350 if ((l = strchr(p, '/')) != NULL)
351 *l++ = '\0';
352 if (l == NULL)
353 errx(EX_USAGE, "Prefix length required");
354 if (inet_pton(af, p, prefix) != 1)
355 errx(EX_USAGE, "Bad prefix: %s", p);
356 *plen = (uint16_t)strtol(l, &l, 10);
357 if (*l != '\0' || *plen == 0 || (af == AF_INET && *plen > 32) ||
358 (af == AF_INET6 && *plen > 96))
359 errx(EX_USAGE, "Bad prefix length: %s", arg);
360 nat64lsn_apply_mask(af, prefix, *plen);
361 free(p);
362}
363
364static uint32_t
365nat64lsn_parse_int(const char *arg, const char *desc)

Callers 1

nat64lsn_createFunction · 0.85

Calls 6

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

Tested by

no test coverage detected