1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2014 Intel Corporation
8 rte_eth_random_addr(uint8_t *addr)
10 uint64_t rand = rte_rand();
11 uint8_t *p = (uint8_t *)&rand;
13 rte_memcpy(addr, p, RTE_ETHER_ADDR_LEN);
14 addr[0] &= (uint8_t)~RTE_ETHER_GROUP_ADDR; /* clear multicast bit */
15 addr[0] |= RTE_ETHER_LOCAL_ADMIN_ADDR; /* set local assignment bit */
19 rte_ether_format_addr(char *buf, uint16_t size,
20 const struct rte_ether_addr *eth_addr)
22 snprintf(buf, size, "%02X:%02X:%02X:%02X:%02X:%02X",
23 eth_addr->addr_bytes[0],
24 eth_addr->addr_bytes[1],
25 eth_addr->addr_bytes[2],
26 eth_addr->addr_bytes[3],
27 eth_addr->addr_bytes[4],
28 eth_addr->addr_bytes[5]);