18d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt/*
28d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * Linux ioctl helper functions for driver wrappers
38d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt * Copyright (c) 2002-2010, Jouni Malinen <j@w1.fi>
48d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt *
5c5ec7f57ead87efa365800228aa0b09a12d9e6c4Dmitry Shmidt * This software may be distributed under the terms of the BSD license.
6c5ec7f57ead87efa365800228aa0b09a12d9e6c4Dmitry Shmidt * See README for more details.
78d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt */
88d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
98d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#include "utils/includes.h"
108d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#include <sys/ioctl.h>
118d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#include <net/if.h>
128d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#include <net/if_arp.h>
138d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
148d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#include "utils/common.h"
158d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#include "linux_ioctl.h"
168d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
178d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
188d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtint linux_set_iface_flags(int sock, const char *ifname, int dev_up)
198d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
208d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	struct ifreq ifr;
211f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	int ret;
228d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
238d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (sock < 0)
248d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		return -1;
258d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
268d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	os_memset(&ifr, 0, sizeof(ifr));
278d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	os_strlcpy(ifr.ifr_name, ifname, IFNAMSIZ);
288d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
298d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (ioctl(sock, SIOCGIFFLAGS, &ifr) != 0) {
301f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt		ret = errno ? -errno : -999;
318d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		wpa_printf(MSG_ERROR, "Could not read interface %s flags: %s",
328d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt			   ifname, strerror(errno));
331f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt		return ret;
348d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	}
358d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
368d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (dev_up) {
378d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		if (ifr.ifr_flags & IFF_UP)
388d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt			return 0;
398d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		ifr.ifr_flags |= IFF_UP;
408d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	} else {
418d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		if (!(ifr.ifr_flags & IFF_UP))
428d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt			return 0;
438d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		ifr.ifr_flags &= ~IFF_UP;
448d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	}
458d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
468d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (ioctl(sock, SIOCSIFFLAGS, &ifr) != 0) {
471f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt		ret = errno ? -errno : -999;
4861d9df3e62aaa0e87ad05452fcb95142159a17b6Dmitry Shmidt		wpa_printf(MSG_ERROR, "Could not set interface %s flags (%s): "
4961d9df3e62aaa0e87ad05452fcb95142159a17b6Dmitry Shmidt			   "%s",
5061d9df3e62aaa0e87ad05452fcb95142159a17b6Dmitry Shmidt			   ifname, dev_up ? "UP" : "DOWN", strerror(errno));
511f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt		return ret;
528d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	}
538d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
548d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	return 0;
558d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
568d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
578d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
581f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidtint linux_iface_up(int sock, const char *ifname)
591f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt{
601f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	struct ifreq ifr;
611f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	int ret;
621f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt
631f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	if (sock < 0)
641f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt		return -1;
651f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt
661f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	os_memset(&ifr, 0, sizeof(ifr));
671f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	os_strlcpy(ifr.ifr_name, ifname, IFNAMSIZ);
681f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt
691f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	if (ioctl(sock, SIOCGIFFLAGS, &ifr) != 0) {
701f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt		ret = errno ? -errno : -999;
711f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt		wpa_printf(MSG_ERROR, "Could not read interface %s flags: %s",
721f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt			   ifname, strerror(errno));
731f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt		return ret;
741f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	}
751f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt
761f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt	return !!(ifr.ifr_flags & IFF_UP);
771f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt}
781f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt
791f69aa52ea2e0a73ac502565df8c666ee49cab6aDmitry Shmidt
808d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtint linux_get_ifhwaddr(int sock, const char *ifname, u8 *addr)
818d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
828d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	struct ifreq ifr;
838d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
848d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	os_memset(&ifr, 0, sizeof(ifr));
858d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	os_strlcpy(ifr.ifr_name, ifname, IFNAMSIZ);
868d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (ioctl(sock, SIOCGIFHWADDR, &ifr)) {
878d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		wpa_printf(MSG_ERROR, "Could not get interface %s hwaddr: %s",
888d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt			   ifname, strerror(errno));
898d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		return -1;
908d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	}
918d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
928d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (ifr.ifr_hwaddr.sa_family != ARPHRD_ETHER) {
938d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		wpa_printf(MSG_ERROR, "%s: Invalid HW-addr family 0x%04x",
948d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt			   ifname, ifr.ifr_hwaddr.sa_family);
958d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		return -1;
968d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	}
978d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	os_memcpy(addr, ifr.ifr_hwaddr.sa_data, ETH_ALEN);
988d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
998d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	return 0;
1008d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
1018d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
1028d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
1038d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtint linux_set_ifhwaddr(int sock, const char *ifname, const u8 *addr)
1048d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
1058d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	struct ifreq ifr;
1068d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
1078d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	os_memset(&ifr, 0, sizeof(ifr));
1088d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	os_strlcpy(ifr.ifr_name, ifname, IFNAMSIZ);
1098d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	os_memcpy(ifr.ifr_hwaddr.sa_data, addr, ETH_ALEN);
1108d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER;
1118d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
1128d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (ioctl(sock, SIOCSIFHWADDR, &ifr)) {
1138d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		wpa_printf(MSG_DEBUG, "Could not set interface %s hwaddr: %s",
1148d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt			   ifname, strerror(errno));
1158d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		return -1;
1168d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	}
1178d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
1188d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	return 0;
1198d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
1208d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
1218d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
1228d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#ifndef SIOCBRADDBR
1238d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#define SIOCBRADDBR 0x89a0
1248d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#endif
1258d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#ifndef SIOCBRDELBR
1268d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#define SIOCBRDELBR 0x89a1
1278d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#endif
1288d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#ifndef SIOCBRADDIF
1298d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#define SIOCBRADDIF 0x89a2
1308d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#endif
1318d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#ifndef SIOCBRDELIF
1328d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#define SIOCBRDELIF 0x89a3
1338d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt#endif
1348d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
1358d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
1368d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtint linux_br_add(int sock, const char *brname)
1378d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
1388d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (ioctl(sock, SIOCBRADDBR, brname) < 0) {
1398d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		wpa_printf(MSG_DEBUG, "Could not add bridge %s: %s",
1408d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt			   brname, strerror(errno));
1418d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		return -1;
1428d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	}
1438d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
1448d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	return 0;
1458d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
1468d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
1478d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
1488d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtint linux_br_del(int sock, const char *brname)
1498d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
1508d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (ioctl(sock, SIOCBRDELBR, brname) < 0) {
1518d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		wpa_printf(MSG_DEBUG, "Could not remove bridge %s: %s",
1528d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt			   brname, strerror(errno));
1538d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		return -1;
1548d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	}
1558d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
1568d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	return 0;
1578d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
1588d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
1598d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
1608d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtint linux_br_add_if(int sock, const char *brname, const char *ifname)
1618d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
1628d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	struct ifreq ifr;
1638d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	int ifindex;
1648d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
1658d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	ifindex = if_nametoindex(ifname);
1668d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (ifindex == 0)
1678d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		return -1;
1688d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
1698d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	os_memset(&ifr, 0, sizeof(ifr));
1708d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	os_strlcpy(ifr.ifr_name, brname, IFNAMSIZ);
1718d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	ifr.ifr_ifindex = ifindex;
1728d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (ioctl(sock, SIOCBRADDIF, &ifr) < 0) {
1738d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		wpa_printf(MSG_DEBUG, "Could not add interface %s into bridge "
1748d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt			   "%s: %s", ifname, brname, strerror(errno));
1758d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		return -1;
1768d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	}
1778d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
1788d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	return 0;
1798d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
1808d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
1818d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
1828d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtint linux_br_del_if(int sock, const char *brname, const char *ifname)
1838d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
1848d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	struct ifreq ifr;
1858d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	int ifindex;
1868d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
1878d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	ifindex = if_nametoindex(ifname);
1888d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (ifindex == 0)
1898d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		return -1;
1908d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
1918d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	os_memset(&ifr, 0, sizeof(ifr));
1928d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	os_strlcpy(ifr.ifr_name, brname, IFNAMSIZ);
1938d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	ifr.ifr_ifindex = ifindex;
1948d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (ioctl(sock, SIOCBRDELIF, &ifr) < 0) {
1958d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		wpa_printf(MSG_DEBUG, "Could not remove interface %s from "
1968d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt			   "bridge %s: %s", ifname, brname, strerror(errno));
1978d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		return -1;
1988d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	}
1998d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
2008d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	return 0;
2018d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
2028d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
2038d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt
2048d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidtint linux_br_get(char *brname, const char *ifname)
2058d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt{
2068d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	char path[128], brlink[128], *pos;
2078d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	os_snprintf(path, sizeof(path), "/sys/class/net/%s/brport/bridge",
2088d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		    ifname);
2098d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	os_memset(brlink, 0, sizeof(brlink));
2108d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (readlink(path, brlink, sizeof(brlink) - 1) < 0)
2118d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		return -1;
2128d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	pos = os_strrchr(brlink, '/');
2138d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	if (pos == NULL)
2148d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt		return -1;
2158d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	pos++;
2168d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	os_strlcpy(brname, pos, IFNAMSIZ);
2178d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt	return 0;
2188d520ff1dc2da35cdca849e982051b86468016d8Dmitry Shmidt}
219