Skip to content
Snippets Groups Projects
Commit f5b7eb5d authored by Jakob Olsson's avatar Jakob Olsson
Browse files

map-agent: use ioctl to bring wds iface up

parent fa789102
No related branches found
No related tags found
No related merge requests found
......@@ -29,6 +29,42 @@
#define UCI_WIRELESS "wireless"
#define UCI_WLAN_IFACE "wifi-iface"
int if_updown(const char *ifname, bool up)
{
int fd;
struct ifreq ifr;
short flags;
if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
return -1;
}
memset(&ifr, 0, sizeof(ifr));
strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
if (ioctl(fd, SIOCGIFFLAGS, &ifr) != 0) {
close(fd);
return -1;
}
flags = ifr.ifr_flags;
if (up && !(flags & IFF_UP))
ifr.ifr_flags |= IFF_UP;
if (!up && (flags & IFF_UP))
ifr.ifr_flags &= ~IFF_UP;
if ((flags != ifr.ifr_flags) && (0 != ioctl(fd, SIOCSIFFLAGS, &ifr))) {
close(fd);
return -1;
}
close(fd);
return 0;
}
static bool get_bridge(char *ifname, char *bridge)
{
strncpy(bridge, "br-lan", 15);
......@@ -73,9 +109,10 @@ static int func(struct nl_msg *msg, void *arg)
"bridge %s\n", ifname, bridge);
/* bring up wds interface */
ret = if_setflags(ifname, IFF_UP);
//ret = if_setflags(ifname, IFF_UP);
ret = if_updown(ifname, true);
if (!ret)
printf("Successfully brought up interface %s",
printf("Successfully brought up interface %s\n",
ifname);
break;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment