* Be liberal in accepting a wide variety of notational formats * for MAC address including: * - Linux format six groups of hexadecimal digits separated by colon * - Windows format six groups separated by hyphen * - two groups hexadecimal digits */
| 131 | * - two groups hexadecimal digits |
| 132 | */ |
| 133 | int |
| 134 | rte_ether_unformat_addr(const char *s, struct rte_ether_addr *ea) |
| 135 | { |
| 136 | unsigned int count; |
| 137 | char sep = '\0'; |
| 138 | |
| 139 | count = get_ether_sep(s, &sep); |
| 140 | switch (count) { |
| 141 | case 5: /* i.e 01:23:45:67:89:AB */ |
| 142 | if (get_ether_addr6(s, ea, sep)) |
| 143 | return 0; |
| 144 | break; |
| 145 | case 2: /* i.e 0123.4567.89AB */ |
| 146 | if (get_ether_addr3(s, ea, sep)) |
| 147 | return 0; |
| 148 | break; |
| 149 | default: |
| 150 | break; |
| 151 | } |
| 152 | |
| 153 | rte_errno = EINVAL; |
| 154 | return -1; |
| 155 | } |