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

Function cmdline_parse_etheraddr

dpdk/lib/cmdline/cmdline_parse_etheraddr.c:23–52  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21};
22
23int
24cmdline_parse_etheraddr(__rte_unused cmdline_parse_token_hdr_t *tk,
25 const char *buf, void *res, unsigned ressize)
26{
27 unsigned int token_len = 0;
28 char ether_str[RTE_ETHER_ADDR_FMT_SIZE];
29 struct rte_ether_addr tmp;
30
31 if (res && ressize < sizeof(tmp))
32 return -1;
33
34 if (!buf || ! *buf)
35 return -1;
36
37 while (!cmdline_isendoftoken(buf[token_len]))
38 token_len++;
39
40 /* if token doesn't match possible string lengths... */
41 if (token_len >= RTE_ETHER_ADDR_FMT_SIZE)
42 return -1;
43
44 strlcpy(ether_str, buf, token_len + 1);
45
46 if (rte_ether_unformat_addr(ether_str, &tmp) < 0)
47 return -1;
48
49 if (res)
50 memcpy(res, &tmp, sizeof(tmp));
51 return token_len;
52}
53
54int
55cmdline_get_help_etheraddr(__rte_unused cmdline_parse_token_hdr_t *tk,

Callers 6

parse_mac_addrFunction · 0.85
parse_eth_destFunction · 0.85
parse_eth_destFunction · 0.85

Calls 4

cmdline_isendoftokenFunction · 0.85
rte_ether_unformat_addrFunction · 0.85
strlcpyFunction · 0.50
memcpyFunction · 0.50