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

Function get_ether_addr3

dpdk/lib/net/rte_ether.c:73–99  ·  view source on GitHub ↗

Convert 0011:2233:4455 to ethernet address */

Source from the content-addressed store, hash-verified

71
72/* Convert 0011:2233:4455 to ethernet address */
73static bool get_ether_addr3(const char *s, struct rte_ether_addr *ea,
74 const char sep)
75{
76 int i, j;
77
78 for (i = 0; i < RTE_ETHER_ADDR_LEN; i += 2) {
79 uint16_t w = 0;
80
81 for (j = 0; j < 4; j++) {
82 int8_t x;
83
84 x = get_xdigit(*s++);
85 if (x < 0)
86 return false; /* not a hex digit */
87 w = (w << 4) | x;
88 }
89
90 ea->addr_bytes[i] = w >> 8;
91 ea->addr_bytes[i + 1] = w & 0xff;
92
93 if (i < RTE_ETHER_ADDR_LEN - 2 &&
94 *s++ != sep)
95 return false;
96 }
97
98 return *s == '\0';
99}
100
101/*
102 * Scan input to see if separated by dash, colon or period

Callers 1

rte_ether_unformat_addrFunction · 0.85

Calls 1

get_xdigitFunction · 0.85

Tested by

no test coverage detected