1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2016 Intel Corporation.
3 * Copyright(c) 2014 6WIND S.A.
9 #include <sys/sysctl.h>
11 #include <rte_malloc.h>
12 #include <rte_memcpy.h>
14 #include "pcap_osdep.h"
17 osdep_iface_index_get(const char *name)
19 return if_nametoindex(name);
23 osdep_iface_mac_get(const char *if_name, struct rte_ether_addr *mac)
25 struct if_msghdr *ifm;
26 struct sockaddr_dl *sdl;
35 mib[4] = NET_RT_IFLIST;
36 mib[5] = if_nametoindex(if_name);
38 if (sysctl(mib, 6, NULL, &len, NULL, 0) < 0)
44 buf = rte_malloc(NULL, len, 0);
48 if (sysctl(mib, 6, buf, &len, NULL, 0) < 0) {
52 ifm = (struct if_msghdr *)buf;
53 sdl = (struct sockaddr_dl *)(ifm + 1);
55 rte_memcpy(mac->addr_bytes, LLADDR(sdl), RTE_ETHER_ADDR_LEN);