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

Function parse_ipv6_addr

dpdk/examples/ipsec-secgw/parser.c:77–106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

75}
76
77int
78parse_ipv6_addr(const char *token, struct in6_addr *ipv6, uint32_t *mask)
79{
80 char ip_str[256] = {0};
81 char *pch;
82
83 pch = strchr(token, '/');
84 if (pch != NULL) {
85 strlcpy(ip_str, token,
86 RTE_MIN((unsigned int long)(pch - token + 1),
87 sizeof(ip_str)));
88 pch += 1;
89 if (is_str_num(pch) != 0)
90 return -EINVAL;
91 if (mask)
92 *mask = atoi(pch);
93 } else {
94 strlcpy(ip_str, token, sizeof(ip_str));
95 if (mask)
96 *mask = 0;
97 }
98
99 if (strlen(ip_str) >= INET6_ADDRSTRLEN)
100 return -EINVAL;
101
102 if (inet_pton(AF_INET6, ip_str, ipv6) != 1)
103 return -EINVAL;
104
105 return 0;
106}
107
108int
109parse_range(const char *token, uint16_t *low, uint16_t *high)

Callers 4

ipv6_addr_cpyFunction · 0.70
parse_sp6_tokensFunction · 0.70
parse_sa_tokensFunction · 0.70
parse_rt_tokensFunction · 0.70

Calls 4

strchrFunction · 0.85
is_str_numFunction · 0.85
inet_ptonFunction · 0.85
strlcpyFunction · 0.50

Tested by

no test coverage detected