]>
git.ipfire.org Git - thirdparty/hostap.git/blob - src/ap/vlan_ifconfig.c
2 * hostapd / VLAN ifconfig helpers
3 * Copyright 2003, Instant802 Networks, Inc.
4 * Copyright 2005-2006, Devicescape Software, Inc.
5 * Copyright (c) 2009, Jouni Malinen <j@w1.fi>
7 * This software may be distributed under the terms of the BSD license.
8 * See README for more details.
11 #include "utils/includes.h"
13 #include <sys/ioctl.h>
15 #include "utils/common.h"
16 #include "vlan_util.h"
19 int ifconfig_helper(const char *if_name
, int up
)
24 if ((fd
= socket(AF_INET
, SOCK_STREAM
, 0)) < 0) {
25 wpa_printf(MSG_ERROR
, "VLAN: %s: socket(AF_INET,SOCK_STREAM) "
26 "failed: %s", __func__
, strerror(errno
));
30 os_memset(&ifr
, 0, sizeof(ifr
));
31 os_strlcpy(ifr
.ifr_name
, if_name
, IFNAMSIZ
);
33 if (ioctl(fd
, SIOCGIFFLAGS
, &ifr
) != 0) {
34 wpa_printf(MSG_ERROR
, "VLAN: %s: ioctl(SIOCGIFFLAGS) failed "
35 "for interface %s: %s",
36 __func__
, if_name
, strerror(errno
));
42 ifr
.ifr_flags
|= IFF_UP
;
44 ifr
.ifr_flags
&= ~IFF_UP
;
46 if (ioctl(fd
, SIOCSIFFLAGS
, &ifr
) != 0) {
47 wpa_printf(MSG_ERROR
, "VLAN: %s: ioctl(SIOCSIFFLAGS) failed "
48 "for interface %s (up=%d): %s",
49 __func__
, if_name
, up
, strerror(errno
));
59 int ifconfig_up(const char *if_name
)
61 wpa_printf(MSG_DEBUG
, "VLAN: Set interface %s up", if_name
);
62 return ifconfig_helper(if_name
, 1);