net: deinline non-critical ethernet functions
[dpdk.git] / lib / librte_net / rte_ether.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2014 Intel Corporation
3  */
4
5 #include <rte_ether.h>
6
7 void
8 rte_eth_random_addr(uint8_t *addr)
9 {
10         uint64_t rand = rte_rand();
11         uint8_t *p = (uint8_t *)&rand;
12
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 */
16 }
17
18 void
19 rte_ether_format_addr(char *buf, uint16_t size,
20                       const struct rte_ether_addr *eth_addr)
21 {
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]);
29 }