| 21 | }; |
| 22 | |
| 23 | int |
| 24 | cmdline_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 | |
| 54 | int |
| 55 | cmdline_get_help_etheraddr(__rte_unused cmdline_parse_token_hdr_t *tk, |