Factor out common code, creating direct_ioctl() and indirect_ioctl()
for the two most prevalent styles of ioctl(2) calls in ifconfig(8).
This commit is contained in:
parent
db80154181
commit
8c460289fe
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: agr.c,v 1.9 2008/05/07 19:55:24 dyoung Exp $ */
|
||||
/* $NetBSD: agr.c,v 1.10 2008/05/07 23:55:06 dyoung Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c)2005 YAMAMOTO Takashi,
|
||||
|
@ -28,7 +28,7 @@
|
|||
|
||||
#include <sys/cdefs.h>
|
||||
#if !defined(lint)
|
||||
__RCSID("$NetBSD: agr.c,v 1.9 2008/05/07 19:55:24 dyoung Exp $");
|
||||
__RCSID("$NetBSD: agr.c,v 1.10 2008/05/07 23:55:06 dyoung Exp $");
|
||||
#endif /* !defined(lint) */
|
||||
|
||||
#include <sys/param.h>
|
||||
|
@ -45,13 +45,14 @@ __RCSID("$NetBSD: agr.c,v 1.9 2008/05/07 19:55:24 dyoung Exp $");
|
|||
#include <stdlib.h>
|
||||
#include <util.h>
|
||||
|
||||
#include "env.h"
|
||||
#include "parse.h"
|
||||
#include "extern.h"
|
||||
#include "agr.h"
|
||||
#include "env.h"
|
||||
#include "extern.h"
|
||||
#include "parse.h"
|
||||
#include "util.h"
|
||||
|
||||
static int checkifname(const char *);
|
||||
static void assertifname(const char *);
|
||||
static int checkifname(prop_dictionary_t);
|
||||
static void assertifname(prop_dictionary_t);
|
||||
|
||||
static const struct kwinst agrkw[] = {
|
||||
{.k_word = "agrport", .k_type = KW_T_NUM, .k_neg = true,
|
||||
|
@ -63,20 +64,22 @@ struct pkw agr = PKW_INITIALIZER(&agr, "agr", NULL, NULL,
|
|||
agrkw, __arraycount(agrkw), NULL);
|
||||
|
||||
static int
|
||||
checkifname(const char *ifname)
|
||||
checkifname(prop_dictionary_t env)
|
||||
{
|
||||
const char *ifname;
|
||||
|
||||
if ((ifname = getifname(env)) == NULL)
|
||||
return 1;
|
||||
|
||||
return strncmp(ifname, "agr", 3) != 0 ||
|
||||
!isdigit((unsigned char)ifname[3]);
|
||||
}
|
||||
|
||||
static void
|
||||
assertifname(const char *ifname)
|
||||
assertifname(prop_dictionary_t env)
|
||||
{
|
||||
|
||||
if (checkifname(ifname)) {
|
||||
if (checkifname(env))
|
||||
errx(EXIT_FAILURE, "valid only with agr(4) interfaces");
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -84,15 +87,9 @@ agrsetport(prop_dictionary_t env, prop_dictionary_t xenv)
|
|||
{
|
||||
char buf[IFNAMSIZ];
|
||||
struct agrreq ar;
|
||||
int s;
|
||||
const char *port;
|
||||
const char *ifname;
|
||||
struct ifreq ifr;
|
||||
int64_t cmd;
|
||||
|
||||
if ((s = getsock(AF_UNSPEC)) == -1)
|
||||
err(EXIT_FAILURE, "%s: getsock", __func__);
|
||||
|
||||
if (!prop_dictionary_get_int64(env, "agrcmd", &cmd)) {
|
||||
warnx("%s.%d", __func__, __LINE__);
|
||||
errno = ENOENT;
|
||||
|
@ -106,19 +103,14 @@ agrsetport(prop_dictionary_t env, prop_dictionary_t xenv)
|
|||
}
|
||||
strlcpy(buf, port, sizeof(buf));
|
||||
|
||||
memset(&ifr, 0, sizeof(ifr));
|
||||
if ((ifname = getifname(env)) == NULL)
|
||||
err(EXIT_FAILURE, "%s: getifname", __func__);
|
||||
assertifname(ifname);
|
||||
estrlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
|
||||
assertifname(env);
|
||||
memset(&ar, 0, sizeof(ar));
|
||||
ar.ar_version = AGRREQ_VERSION;
|
||||
ar.ar_cmd = cmd;
|
||||
ar.ar_buf = buf;
|
||||
ar.ar_buflen = strlen(buf);
|
||||
ifr.ifr_data = &ar;
|
||||
|
||||
if (ioctl(s, SIOCSETAGR, &ifr) == -1)
|
||||
if (indirect_ioctl(env, SIOCSETAGR, &ar) == -1)
|
||||
err(EXIT_FAILURE, "SIOCSETAGR");
|
||||
return 0;
|
||||
}
|
||||
|
@ -132,19 +124,9 @@ agr_status(prop_dictionary_t env, prop_dictionary_t oenv)
|
|||
struct agrportlist *apl;
|
||||
struct agrportinfo *api;
|
||||
int i;
|
||||
int s;
|
||||
const char *ifname;
|
||||
struct ifreq ifr;
|
||||
|
||||
if ((s = getsock(AF_UNSPEC)) == -1)
|
||||
err(EXIT_FAILURE, "%s: getsock", __func__);
|
||||
|
||||
memset(&ifr, 0, sizeof(ifr));
|
||||
if ((ifname = getifname(env)) == NULL)
|
||||
err(EXIT_FAILURE, "%s: getifname", __func__);
|
||||
if (checkifname(ifname))
|
||||
if (checkifname(env))
|
||||
return;
|
||||
estrlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
|
||||
|
||||
again:
|
||||
memset(&ar, 0, sizeof(ar));
|
||||
|
@ -152,9 +134,8 @@ again:
|
|||
ar.ar_cmd = AGRCMD_PORTLIST;
|
||||
ar.ar_buf = buf;
|
||||
ar.ar_buflen = buflen;
|
||||
ifr.ifr_data = &ar;
|
||||
|
||||
if (ioctl(s, SIOCGETAGR, &ifr) == -1) {
|
||||
if (indirect_ioctl(env, SIOCGETAGR, &ar) == -1) {
|
||||
if (errno != E2BIG) {
|
||||
warn("SIOCGETAGR");
|
||||
return;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: carp.c,v 1.8 2008/05/07 20:45:01 dyoung Exp $ */
|
||||
/* $NetBSD: carp.c,v 1.9 2008/05/07 23:55:06 dyoung Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2002 Michael Shalayeff. All rights reserved.
|
||||
|
@ -97,23 +97,11 @@ void
|
|||
carp_status(prop_dictionary_t env, prop_dictionary_t oenv)
|
||||
{
|
||||
const char *state;
|
||||
struct ifreq ifr;
|
||||
struct carpreq carpr;
|
||||
int s;
|
||||
const char *ifname;
|
||||
|
||||
if ((s = getsock(AF_UNSPEC)) == -1)
|
||||
err(EXIT_FAILURE, "%s: getsock", __func__);
|
||||
|
||||
memset(&ifr, 0, sizeof(ifr));
|
||||
memset(&carpr, 0, sizeof(carpr));
|
||||
ifr.ifr_data = &carpr;
|
||||
if ((ifname = getifname(env)) == NULL)
|
||||
err(EXIT_FAILURE, "%s: getifname", __func__);
|
||||
|
||||
estrlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
|
||||
|
||||
if (ioctl(s, SIOCGVH, &ifr) == -1)
|
||||
if (indirect_ioctl(env, SIOCGVH, &carpr) == -1)
|
||||
return;
|
||||
|
||||
if (carpr.carpr_vhid <= 0)
|
||||
|
@ -133,13 +121,7 @@ int
|
|||
setcarp_passwd(prop_dictionary_t env, prop_dictionary_t xenv)
|
||||
{
|
||||
struct carpreq carpr;
|
||||
struct ifreq ifr;
|
||||
int s;
|
||||
prop_data_t data;
|
||||
const char *ifname;
|
||||
|
||||
if ((s = getsock(AF_UNSPEC)) == -1)
|
||||
err(EXIT_FAILURE, "%s: getsock", __func__);
|
||||
|
||||
data = (prop_data_t)prop_dictionary_get(env, "pass");
|
||||
if (data == NULL) {
|
||||
|
@ -147,16 +129,9 @@ setcarp_passwd(prop_dictionary_t env, prop_dictionary_t xenv)
|
|||
return -1;
|
||||
}
|
||||
|
||||
memset(&ifr, 0, sizeof(ifr));
|
||||
memset(&carpr, 0, sizeof(carpr));
|
||||
ifr.ifr_data = &carpr;
|
||||
|
||||
if ((ifname = getifname(env)) == NULL)
|
||||
err(EXIT_FAILURE, "%s: getifname", __func__);
|
||||
|
||||
estrlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
|
||||
|
||||
if (ioctl(s, SIOCGVH, &ifr) == -1)
|
||||
if (indirect_ioctl(env, SIOCGVH, &carpr) == -1)
|
||||
err(EXIT_FAILURE, "SIOCGVH");
|
||||
|
||||
memset(carpr.carpr_key, 0, sizeof(carpr.carpr_key));
|
||||
|
@ -164,7 +139,7 @@ setcarp_passwd(prop_dictionary_t env, prop_dictionary_t xenv)
|
|||
strlcpy((char *)carpr.carpr_key, prop_data_data_nocopy(data),
|
||||
MIN(CARP_KEY_LEN, prop_data_size(data)));
|
||||
|
||||
if (ioctl(s, SIOCSVH, &ifr) == -1)
|
||||
if (indirect_ioctl(env, SIOCSVH, &carpr) == -1)
|
||||
err(EXIT_FAILURE, "SIOCSVH");
|
||||
return 0;
|
||||
}
|
||||
|
@ -172,13 +147,8 @@ setcarp_passwd(prop_dictionary_t env, prop_dictionary_t xenv)
|
|||
int
|
||||
setcarp_vhid(prop_dictionary_t env, prop_dictionary_t xenv)
|
||||
{
|
||||
struct ifreq ifr;
|
||||
struct carpreq carpr;
|
||||
int64_t vhid;
|
||||
int s;
|
||||
|
||||
if ((s = getsock(AF_UNSPEC)) == -1)
|
||||
err(EXIT_FAILURE, "%s: getsock", __func__);
|
||||
|
||||
if (!prop_dictionary_get_int64(env, "vhid", &vhid)) {
|
||||
errno = ENOENT;
|
||||
|
@ -186,14 +156,13 @@ setcarp_vhid(prop_dictionary_t env, prop_dictionary_t xenv)
|
|||
}
|
||||
|
||||
memset(&carpr, 0, sizeof(struct carpreq));
|
||||
ifr.ifr_data = &carpr;
|
||||
|
||||
if (ioctl(s, SIOCGVH, &ifr) == -1)
|
||||
if (indirect_ioctl(env, SIOCGVH, &carpr) == -1)
|
||||
err(EXIT_FAILURE, "SIOCGVH");
|
||||
|
||||
carpr.carpr_vhid = vhid;
|
||||
|
||||
if (ioctl(s, SIOCSVH, &ifr) == -1)
|
||||
if (indirect_ioctl(env, SIOCSVH, &carpr) == -1)
|
||||
err(EXIT_FAILURE, "SIOCSVH");
|
||||
return 0;
|
||||
}
|
||||
|
@ -201,34 +170,22 @@ setcarp_vhid(prop_dictionary_t env, prop_dictionary_t xenv)
|
|||
int
|
||||
setcarp_advskew(prop_dictionary_t env, prop_dictionary_t xenv)
|
||||
{
|
||||
struct ifreq ifr;
|
||||
struct carpreq carpr;
|
||||
int64_t advskew;
|
||||
int s;
|
||||
const char *ifname;
|
||||
|
||||
if ((s = getsock(AF_UNSPEC)) == -1)
|
||||
err(EXIT_FAILURE, "%s: getsock", __func__);
|
||||
|
||||
if (!prop_dictionary_get_int64(env, "advskew", &advskew)) {
|
||||
errno = ENOENT;
|
||||
return -1;
|
||||
}
|
||||
|
||||
memset(&ifr, 0, sizeof(ifr));
|
||||
memset(&carpr, 0, sizeof(carpr));
|
||||
ifr.ifr_data = &carpr;
|
||||
if ((ifname = getifname(env)) == NULL)
|
||||
err(EXIT_FAILURE, "%s: getifname", __func__);
|
||||
|
||||
estrlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
|
||||
|
||||
if (ioctl(s, SIOCGVH, &ifr) == -1)
|
||||
if (indirect_ioctl(env, SIOCGVH, &carpr) == -1)
|
||||
err(EXIT_FAILURE, "SIOCGVH");
|
||||
|
||||
carpr.carpr_advskew = advskew;
|
||||
|
||||
if (ioctl(s, SIOCSVH, &ifr) == -1)
|
||||
if (indirect_ioctl(env, SIOCSVH, &carpr) == -1)
|
||||
err(EXIT_FAILURE, "SIOCSVH");
|
||||
return 0;
|
||||
}
|
||||
|
@ -239,32 +196,20 @@ setcarp_advbase(prop_dictionary_t env, prop_dictionary_t xenv)
|
|||
{
|
||||
struct carpreq carpr;
|
||||
int64_t advbase;
|
||||
int s;
|
||||
struct ifreq ifr;
|
||||
const char *ifname;
|
||||
|
||||
if ((s = getsock(AF_UNSPEC)) == -1)
|
||||
err(EXIT_FAILURE, "%s: getsock", __func__);
|
||||
|
||||
if (!prop_dictionary_get_int64(env, "advbase", &advbase)) {
|
||||
errno = ENOENT;
|
||||
return -1;
|
||||
}
|
||||
|
||||
memset(&ifr, 0, sizeof(ifr));
|
||||
memset(&carpr, 0, sizeof(carpr));
|
||||
ifr.ifr_data = &carpr;
|
||||
if ((ifname = getifname(env)) == NULL)
|
||||
err(EXIT_FAILURE, "%s: getifname", __func__);
|
||||
|
||||
estrlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
|
||||
|
||||
if (ioctl(s, SIOCGVH, &ifr) == -1)
|
||||
if (indirect_ioctl(env, SIOCGVH, &carpr) == -1)
|
||||
err(EXIT_FAILURE, "SIOCGVH");
|
||||
|
||||
carpr.carpr_advbase = advbase;
|
||||
|
||||
if (ioctl(s, SIOCSVH, &ifr) == -1)
|
||||
if (indirect_ioctl(env, SIOCSVH, &carpr) == -1)
|
||||
err(EXIT_FAILURE, "SIOCSVH");
|
||||
return 0;
|
||||
}
|
||||
|
@ -274,33 +219,21 @@ int
|
|||
setcarp_state(prop_dictionary_t env, prop_dictionary_t xenv)
|
||||
{
|
||||
struct carpreq carpr;
|
||||
int s;
|
||||
struct ifreq ifr;
|
||||
int64_t carp_state;
|
||||
const char *ifname;
|
||||
|
||||
if ((s = getsock(AF_UNSPEC)) == -1)
|
||||
err(EXIT_FAILURE, "%s: getsock", __func__);
|
||||
|
||||
if (!prop_dictionary_get_int64(env, "carp_state", &carp_state)) {
|
||||
errno = ENOENT;
|
||||
return -1;
|
||||
}
|
||||
|
||||
memset(&ifr, 0, sizeof(ifr));
|
||||
memset(&carpr, 0, sizeof(carpr));
|
||||
ifr.ifr_data = &carpr;
|
||||
if ((ifname = getifname(env)) == NULL)
|
||||
err(EXIT_FAILURE, "%s: getifname", __func__);
|
||||
|
||||
estrlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
|
||||
|
||||
if (ioctl(s, SIOCGVH, &ifr) == -1)
|
||||
if (indirect_ioctl(env, SIOCGVH, &carpr) == -1)
|
||||
err(EXIT_FAILURE, "SIOCGVH");
|
||||
|
||||
carpr.carpr_state = carp_state;
|
||||
|
||||
if (ioctl(s, SIOCSVH, &ifr) == -1)
|
||||
if (indirect_ioctl(env, SIOCSVH, &carpr) == -1)
|
||||
err(EXIT_FAILURE, "SIOCSVH");
|
||||
return 0;
|
||||
}
|
||||
|
@ -310,10 +243,7 @@ int
|
|||
setcarpdev(prop_dictionary_t env, prop_dictionary_t xenv)
|
||||
{
|
||||
struct carpreq carpr;
|
||||
int s;
|
||||
prop_data_t data;
|
||||
struct ifreq ifr;
|
||||
const char *ifname;
|
||||
|
||||
data = (prop_data_t)prop_dictionary_get(env, "carpdev");
|
||||
if (data == NULL) {
|
||||
|
@ -321,24 +251,15 @@ setcarpdev(prop_dictionary_t env, prop_dictionary_t xenv)
|
|||
return -1;
|
||||
}
|
||||
|
||||
if ((s = getsock(AF_UNSPEC)) == -1)
|
||||
err(EXIT_FAILURE, "%s: getsock", __func__);
|
||||
|
||||
memset(&ifr, 0, sizeof(ifr));
|
||||
memset(&carpr, 0, sizeof(carpr));
|
||||
ifr.ifr_data = &carpr;
|
||||
if ((ifname = getifname(env)) == NULL)
|
||||
err(EXIT_FAILURE, "%s: getifname", __func__);
|
||||
|
||||
estrlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
|
||||
|
||||
if (ioctl(s, SIOCGVH, &ifr) == -1)
|
||||
if (indirect_ioctl(env, SIOCGVH, &carpr) == -1)
|
||||
err(EXIT_FAILURE, "SIOCGVH");
|
||||
|
||||
strlcpy(carpr.carpr_carpdev, prop_data_data_nocopy(data),
|
||||
MIN(sizeof(carpr.carpr_carpdev), prop_data_size(data)));
|
||||
|
||||
if (ioctl(s, SIOCSVH, &ifr) == -1)
|
||||
if (indirect_ioctl(env, SIOCSVH, &carpr) == -1)
|
||||
err(EXIT_FAILURE, "SIOCSVH");
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ieee80211.c,v 1.17 2008/05/07 20:03:27 dyoung Exp $ */
|
||||
/* $NetBSD: ieee80211.c,v 1.18 2008/05/07 23:55:06 dyoung Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983, 1993
|
||||
|
@ -31,7 +31,7 @@
|
|||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: ieee80211.c,v 1.17 2008/05/07 20:03:27 dyoung Exp $");
|
||||
__RCSID("$NetBSD: ieee80211.c,v 1.18 2008/05/07 23:55:06 dyoung Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
|
@ -62,6 +62,7 @@ __RCSID("$NetBSD: ieee80211.c,v 1.17 2008/05/07 20:03:27 dyoung Exp $");
|
|||
#include "ieee80211.h"
|
||||
#include "parse.h"
|
||||
#include "env.h"
|
||||
#include "util.h"
|
||||
|
||||
static int set80211(prop_dictionary_t env, uint16_t, int16_t, int16_t,
|
||||
u_int8_t *);
|
||||
|
@ -169,22 +170,13 @@ set80211(prop_dictionary_t env, uint16_t type, int16_t val, int16_t len,
|
|||
u_int8_t *data)
|
||||
{
|
||||
struct ieee80211req ireq;
|
||||
const char *ifname;
|
||||
int s;
|
||||
|
||||
if ((s = getsock(AF_UNSPEC)) == -1)
|
||||
return -1;
|
||||
|
||||
if ((ifname = getifname(env)) == NULL)
|
||||
return -1;
|
||||
|
||||
(void)memset(&ireq, 0, sizeof(ireq));
|
||||
estrlcpy(ireq.i_name, ifname, sizeof(ireq.i_name));
|
||||
memset(&ireq, 0, sizeof(ireq));
|
||||
ireq.i_type = type;
|
||||
ireq.i_val = val;
|
||||
ireq.i_len = len;
|
||||
ireq.i_data = data;
|
||||
if (ioctl(s, SIOCS80211, &ireq) == -1) {
|
||||
if (direct_ioctl(env, SIOCS80211, &ireq) == -1) {
|
||||
warn("SIOCS80211");
|
||||
return -1;
|
||||
}
|
||||
|
@ -215,25 +207,16 @@ static enum ieee80211_opmode
|
|||
get80211opmode(prop_dictionary_t env)
|
||||
{
|
||||
struct ifmediareq ifmr;
|
||||
const char *ifname;
|
||||
int s;
|
||||
|
||||
if ((s = getsock(AF_UNSPEC)) == -1)
|
||||
return -1;
|
||||
|
||||
if ((ifname = getifname(env)) == NULL)
|
||||
return -1;
|
||||
|
||||
(void) memset(&ifmr, 0, sizeof(ifmr));
|
||||
estrlcpy(ifmr.ifm_name, ifname, sizeof(ifmr.ifm_name));
|
||||
if (ioctl(s, SIOCGIFMEDIA, (caddr_t)&ifmr) >= 0) {
|
||||
if (ifmr.ifm_current & IFM_IEEE80211_ADHOC)
|
||||
return IEEE80211_M_IBSS; /* XXX ahdemo */
|
||||
if (ifmr.ifm_current & IFM_IEEE80211_HOSTAP)
|
||||
return IEEE80211_M_HOSTAP;
|
||||
if (ifmr.ifm_current & IFM_IEEE80211_MONITOR)
|
||||
return IEEE80211_M_MONITOR;
|
||||
}
|
||||
memset(&ifmr, 0, sizeof(ifmr));
|
||||
if (direct_ioctl(env, SIOCGIFMEDIA, &ifmr) == -1)
|
||||
;
|
||||
else if (ifmr.ifm_current & IFM_IEEE80211_ADHOC)
|
||||
return IEEE80211_M_IBSS; /* XXX ahdemo */
|
||||
else if (ifmr.ifm_current & IFM_IEEE80211_HOSTAP)
|
||||
return IEEE80211_M_HOSTAP;
|
||||
else if (ifmr.ifm_current & IFM_IEEE80211_MONITOR)
|
||||
return IEEE80211_M_MONITOR;
|
||||
|
||||
return IEEE80211_M_STA;
|
||||
}
|
||||
|
@ -242,28 +225,14 @@ int
|
|||
setifssid(prop_dictionary_t env, prop_dictionary_t xenv)
|
||||
{
|
||||
struct ieee80211_nwid nwid;
|
||||
int s;
|
||||
ssize_t len;
|
||||
const char *ifname;
|
||||
struct ifreq ifr;
|
||||
|
||||
if ((ifname = getifname(env)) == NULL)
|
||||
return -1;
|
||||
|
||||
if ((s = getsock(AF_UNSPEC)) == -1)
|
||||
err(EXIT_FAILURE, "%s: getsock", __func__);
|
||||
|
||||
memset(&nwid, 0, sizeof(nwid));
|
||||
if ((len = getargdata(env, "ssid", nwid.i_nwid,
|
||||
sizeof(nwid.i_nwid))) == -1)
|
||||
errx(EXIT_FAILURE, "%s: SSID too long", __func__);
|
||||
nwid.i_len = (uint8_t)len;
|
||||
memset(&ifr, 0, sizeof(ifr));
|
||||
if ((ifname = getifname(env)) == NULL)
|
||||
err(EXIT_FAILURE, "%s: getifname", __func__);
|
||||
estrlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
|
||||
ifr.ifr_data = &nwid;
|
||||
if (ioctl(s, SIOCS80211NWID, &ifr) == -1)
|
||||
if (indirect_ioctl(env, SIOCS80211NWID, &nwid) == -1)
|
||||
err(EXIT_FAILURE, "SIOCS80211NWID");
|
||||
return 0;
|
||||
}
|
||||
|
@ -272,18 +241,10 @@ int
|
|||
unsetifbssid(prop_dictionary_t env, prop_dictionary_t xenv)
|
||||
{
|
||||
struct ieee80211_bssid bssid;
|
||||
const char *ifname;
|
||||
int s;
|
||||
|
||||
if ((s = getsock(AF_UNSPEC)) == -1)
|
||||
err(EXIT_FAILURE, "%s: getsock", __func__);
|
||||
memset(&bssid, 0, sizeof(bssid));
|
||||
|
||||
memset(&bssid.i_bssid, 0, sizeof(bssid.i_bssid));
|
||||
|
||||
if ((ifname = getifname(env)) == NULL)
|
||||
return -1;
|
||||
estrlcpy(bssid.i_name, ifname, sizeof(bssid.i_name));
|
||||
if (ioctl(s, SIOCS80211BSSID, &bssid) == -1)
|
||||
if (direct_ioctl(env, SIOCS80211BSSID, &bssid) == -1)
|
||||
err(EXIT_FAILURE, "SIOCS80211BSSID");
|
||||
return 0;
|
||||
}
|
||||
|
@ -293,14 +254,10 @@ setifbssid(prop_dictionary_t env, prop_dictionary_t xenv)
|
|||
{
|
||||
char buf[24];
|
||||
struct ieee80211_bssid bssid;
|
||||
const char *ifname;
|
||||
struct ether_addr *ea;
|
||||
int s;
|
||||
|
||||
if (getargstr(env, "bssid", buf, sizeof(buf)) == -1)
|
||||
errx(EXIT_FAILURE, "%s: BSSID too long", __func__);
|
||||
if ((s = getsock(AF_UNSPEC)) == -1)
|
||||
err(EXIT_FAILURE, "%s: getsock", __func__);
|
||||
|
||||
ea = ether_aton(buf);
|
||||
if (ea == NULL) {
|
||||
|
@ -310,10 +267,7 @@ setifbssid(prop_dictionary_t env, prop_dictionary_t xenv)
|
|||
memcpy(&bssid.i_bssid, ea->ether_addr_octet,
|
||||
sizeof(bssid.i_bssid));
|
||||
|
||||
if ((ifname = getifname(env)) == NULL)
|
||||
return -1;
|
||||
estrlcpy(bssid.i_name, ifname, sizeof(bssid.i_name));
|
||||
if (ioctl(s, SIOCS80211BSSID, &bssid) == -1)
|
||||
if (direct_ioctl(env, SIOCS80211BSSID, &bssid) == -1)
|
||||
err(EXIT_FAILURE, "SIOCS80211BSSID");
|
||||
return 0;
|
||||
}
|
||||
|
@ -335,20 +289,11 @@ int
|
|||
setifchan(prop_dictionary_t env, prop_dictionary_t xenv)
|
||||
{
|
||||
bool rc;
|
||||
const char *ifname;
|
||||
struct ieee80211chanreq channel;
|
||||
int s;
|
||||
|
||||
if ((s = getsock(AF_UNSPEC)) == -1)
|
||||
return -1;
|
||||
|
||||
if ((ifname = getifname(env)) == NULL)
|
||||
return -1;
|
||||
|
||||
estrlcpy(channel.i_name, ifname, sizeof(channel.i_name));
|
||||
rc = prop_dictionary_get_uint16(env, "chan", &channel.i_channel);
|
||||
assert(rc);
|
||||
if (ioctl(s, SIOCS80211CHANNEL, &channel) == -1)
|
||||
if (direct_ioctl(env, SIOCS80211CHANNEL, &channel) == -1)
|
||||
err(EXIT_FAILURE, "SIOCS80211CHANNEL");
|
||||
return 0;
|
||||
}
|
||||
|
@ -356,15 +301,11 @@ setifchan(prop_dictionary_t env, prop_dictionary_t xenv)
|
|||
int
|
||||
setifnwkey(prop_dictionary_t env, prop_dictionary_t xenv)
|
||||
{
|
||||
const char *ifname, *val;
|
||||
const char *val;
|
||||
char buf[256];
|
||||
struct ieee80211_nwkey nwkey;
|
||||
int i;
|
||||
u_int8_t keybuf[IEEE80211_WEP_NKID][16];
|
||||
int s;
|
||||
|
||||
if ((s = getsock(AF_UNSPEC)) == -1)
|
||||
err(EXIT_FAILURE, "%s: getsock", __func__);
|
||||
|
||||
if (getargstr(env, "nwkey", buf, sizeof(buf)) == -1)
|
||||
errx(EXIT_FAILURE, "%s: nwkey too long", __func__);
|
||||
|
@ -418,10 +359,7 @@ setifnwkey(prop_dictionary_t env, prop_dictionary_t xenv)
|
|||
for (; i < IEEE80211_WEP_NKID; i++)
|
||||
nwkey.i_key[i].i_keylen = 0;
|
||||
|
||||
if ((ifname = getifname(env)) == NULL)
|
||||
return -1;
|
||||
estrlcpy(nwkey.i_name, ifname, sizeof(nwkey.i_name));
|
||||
if (ioctl(s, SIOCS80211NWKEY, &nwkey) == -1)
|
||||
if (direct_ioctl(env, SIOCS80211NWKEY, &nwkey) == -1)
|
||||
err(EXIT_FAILURE, "SIOCS80211NWKEY");
|
||||
return 0;
|
||||
}
|
||||
|
@ -429,12 +367,8 @@ setifnwkey(prop_dictionary_t env, prop_dictionary_t xenv)
|
|||
int
|
||||
unsetifnwkey(prop_dictionary_t env, prop_dictionary_t xenv)
|
||||
{
|
||||
const char *ifname;
|
||||
struct ieee80211_nwkey nwkey;
|
||||
int i, s;
|
||||
|
||||
if ((s = getsock(AF_UNSPEC)) == -1)
|
||||
err(EXIT_FAILURE, "%s: getsock", __func__);
|
||||
int i;
|
||||
|
||||
nwkey.i_wepon = 0;
|
||||
nwkey.i_defkid = 1;
|
||||
|
@ -443,11 +377,7 @@ unsetifnwkey(prop_dictionary_t env, prop_dictionary_t xenv)
|
|||
nwkey.i_key[i].i_keydat = NULL;
|
||||
}
|
||||
|
||||
if ((ifname = getifname(env)) == NULL)
|
||||
return -1;
|
||||
|
||||
estrlcpy(nwkey.i_name, ifname, sizeof(nwkey.i_name));
|
||||
if (ioctl(s, SIOCS80211NWKEY, &nwkey) == -1)
|
||||
if (direct_ioctl(env, SIOCS80211NWKEY, &nwkey) == -1)
|
||||
err(EXIT_FAILURE, "SIOCS80211NWKEY");
|
||||
return 0;
|
||||
}
|
||||
|
@ -456,26 +386,16 @@ int
|
|||
setifpowersave(prop_dictionary_t env, prop_dictionary_t xenv)
|
||||
{
|
||||
struct ieee80211_power power;
|
||||
const char *ifname;
|
||||
bool on, rc;
|
||||
int s;
|
||||
|
||||
if ((s = getsock(AF_UNSPEC)) == -1)
|
||||
err(EXIT_FAILURE, "%s: getsock", __func__);
|
||||
|
||||
if ((ifname = getifname(env)) == NULL)
|
||||
return -1;
|
||||
|
||||
estrlcpy(power.i_name, ifname, sizeof(power.i_name));
|
||||
if (ioctl(s, SIOCG80211POWER, &power) == -1) {
|
||||
if (direct_ioctl(env, SIOCG80211POWER, &power) == -1)
|
||||
err(EXIT_FAILURE, "SIOCG80211POWER");
|
||||
}
|
||||
|
||||
rc = prop_dictionary_get_bool(env, "powersave", &on);
|
||||
assert(rc);
|
||||
|
||||
power.i_enabled = on ? 1 : 0;
|
||||
if (ioctl(s, SIOCS80211POWER, &power) == -1) {
|
||||
if (direct_ioctl(env, SIOCS80211POWER, &power) == -1) {
|
||||
warn("SIOCS80211POWER");
|
||||
return -1;
|
||||
}
|
||||
|
@ -486,27 +406,17 @@ int
|
|||
setifpowersavesleep(prop_dictionary_t env, prop_dictionary_t xenv)
|
||||
{
|
||||
struct ieee80211_power power;
|
||||
int s;
|
||||
const char *ifname;
|
||||
int64_t maxsleep;
|
||||
bool rc;
|
||||
|
||||
if ((ifname = getifname(env)) == NULL)
|
||||
return -1;
|
||||
|
||||
rc = prop_dictionary_get_int64(env, "powersavesleep", &maxsleep);
|
||||
assert(rc);
|
||||
|
||||
if ((s = getsock(AF_UNSPEC)) == -1)
|
||||
err(EXIT_FAILURE, "%s: getsock", __func__);
|
||||
|
||||
estrlcpy(power.i_name, ifname, sizeof(power.i_name));
|
||||
if (ioctl(s, SIOCG80211POWER, &power) == -1) {
|
||||
if (direct_ioctl(env, SIOCG80211POWER, &power) == -1)
|
||||
err(EXIT_FAILURE, "SIOCG80211POWER");
|
||||
}
|
||||
|
||||
power.i_maxsleep = maxsleep;
|
||||
if (ioctl(s, SIOCS80211POWER, &power) == -1)
|
||||
if (direct_ioctl(env, SIOCS80211POWER, &power) == -1)
|
||||
err(EXIT_FAILURE, "SIOCS80211POWER");
|
||||
return 0;
|
||||
}
|
||||
|
@ -523,25 +433,13 @@ void
|
|||
ieee80211_statistics(prop_dictionary_t env)
|
||||
{
|
||||
struct ieee80211_stats stats;
|
||||
int s;
|
||||
const char *ifname;
|
||||
struct ifreq ifr;
|
||||
|
||||
if ((s = getsock(AF_UNSPEC)) == -1)
|
||||
err(EXIT_FAILURE, "%s: getsock", __func__);
|
||||
|
||||
if ((ifname = getifname(env)) == NULL)
|
||||
return;
|
||||
|
||||
memset(&ifr, 0, sizeof(ifr));
|
||||
if ((ifname = getifname(env)) == NULL)
|
||||
err(EXIT_FAILURE, "%s: getifname", __func__);
|
||||
estrlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
|
||||
ifr.ifr_buflen = sizeof(stats);
|
||||
ifr.ifr_buf = (caddr_t)&stats;
|
||||
estrlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
|
||||
if (ioctl(s, (zflag) ? SIOCG80211ZSTATS : SIOCG80211STATS,
|
||||
(caddr_t)&ifr) == -1)
|
||||
if (direct_ioctl(env, (zflag) ? SIOCG80211ZSTATS : SIOCG80211STATS,
|
||||
&ifr) == -1)
|
||||
return;
|
||||
#define STAT_PRINT(_member, _desc) \
|
||||
printf("\t" _desc ": %" PRIu32 "\n", stats._member)
|
||||
|
@ -652,21 +550,13 @@ ieee80211_status(prop_dictionary_t env, prop_dictionary_t oenv)
|
|||
struct ether_addr ea;
|
||||
static const u_int8_t zero_macaddr[IEEE80211_ADDR_LEN];
|
||||
enum ieee80211_opmode opmode = get80211opmode(env);
|
||||
int s;
|
||||
const char *ifname;
|
||||
struct ifreq ifr;
|
||||
|
||||
if ((s = getsock(AF_UNSPEC)) == -1)
|
||||
err(EXIT_FAILURE, "%s: getsock", __func__);
|
||||
memset(&bssid, 0, sizeof(bssid));
|
||||
memset(&nwkey, 0, sizeof(nwkey));
|
||||
memset(&nwid, 0, sizeof(nwid));
|
||||
memset(&nwid, 0, sizeof(nwid));
|
||||
|
||||
if ((ifname = getifname(env)) == NULL)
|
||||
err(EXIT_FAILURE, "%s: getifname", __func__);
|
||||
|
||||
memset(&ifr, 0, sizeof(ifr));
|
||||
estrlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
|
||||
ifr.ifr_data = &nwid;
|
||||
estrlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
|
||||
if (ioctl(s, SIOCG80211NWID, &ifr) == -1)
|
||||
if (indirect_ioctl(env, SIOCG80211NWID, &nwid) == -1)
|
||||
return;
|
||||
if (nwid.i_len > IEEE80211_NWID_LEN) {
|
||||
errx(EXIT_FAILURE, "SIOCG80211NWID: wrong length of nwid (%d)", nwid.i_len);
|
||||
|
@ -675,9 +565,8 @@ ieee80211_status(prop_dictionary_t env, prop_dictionary_t oenv)
|
|||
print_string(nwid.i_nwid, nwid.i_len);
|
||||
|
||||
if (opmode == IEEE80211_M_HOSTAP) {
|
||||
estrlcpy(ireq.i_name, ifname, sizeof(ireq.i_name));
|
||||
ireq.i_type = IEEE80211_IOC_HIDESSID;
|
||||
if (ioctl(s, SIOCG80211, &ireq) != -1) {
|
||||
if (direct_ioctl(env, SIOCG80211, &ireq) != -1) {
|
||||
if (ireq.i_val)
|
||||
printf(" [hidden]");
|
||||
else if (vflag)
|
||||
|
@ -685,7 +574,7 @@ ieee80211_status(prop_dictionary_t env, prop_dictionary_t oenv)
|
|||
}
|
||||
|
||||
ireq.i_type = IEEE80211_IOC_APBRIDGE;
|
||||
if (ioctl(s, SIOCG80211, &ireq) != -1) {
|
||||
if (direct_ioctl(env, SIOCG80211, &ireq) != -1) {
|
||||
if (ireq.i_val)
|
||||
printf(" apbridge");
|
||||
else if (vflag)
|
||||
|
@ -693,9 +582,8 @@ ieee80211_status(prop_dictionary_t env, prop_dictionary_t oenv)
|
|||
}
|
||||
}
|
||||
|
||||
estrlcpy(ireq.i_name, ifname, sizeof(ireq.i_name));
|
||||
ireq.i_type = IEEE80211_IOC_FRAGTHRESHOLD;
|
||||
if (ioctl(s, SIOCG80211, &ireq) == -1)
|
||||
if (direct_ioctl(env, SIOCG80211, &ireq) == -1)
|
||||
;
|
||||
else if (ireq.i_val < IEEE80211_FRAG_MAX)
|
||||
printf(" frag %d", ireq.i_val);
|
||||
|
@ -703,9 +591,8 @@ ieee80211_status(prop_dictionary_t env, prop_dictionary_t oenv)
|
|||
printf(" -frag");
|
||||
|
||||
memset(&nwkey, 0, sizeof(nwkey));
|
||||
estrlcpy(nwkey.i_name, ifname, sizeof(nwkey.i_name));
|
||||
/* show nwkey only when WEP is enabled */
|
||||
if (ioctl(s, SIOCG80211NWKEY, &nwkey) == -1 ||
|
||||
if (direct_ioctl(env, SIOCG80211NWKEY, &nwkey) == -1 ||
|
||||
nwkey.i_wepon == 0) {
|
||||
printf("\n");
|
||||
goto skip_wep;
|
||||
|
@ -717,7 +604,7 @@ ieee80211_status(prop_dictionary_t env, prop_dictionary_t oenv)
|
|||
nwkey.i_key[i].i_keydat = keybuf[i];
|
||||
nwkey.i_key[i].i_keylen = sizeof(keybuf[i]);
|
||||
}
|
||||
if (ioctl(s, SIOCG80211NWKEY, &nwkey) == -1) {
|
||||
if (direct_ioctl(env, SIOCG80211NWKEY, &nwkey) == -1) {
|
||||
printf("*****");
|
||||
} else {
|
||||
nwkey_verbose = 0;
|
||||
|
@ -760,8 +647,7 @@ ieee80211_status(prop_dictionary_t env, prop_dictionary_t oenv)
|
|||
printf("\n");
|
||||
|
||||
skip_wep:
|
||||
estrlcpy(power.i_name, ifname, sizeof(power.i_name));
|
||||
if (ioctl(s, SIOCG80211POWER, &power) == -1)
|
||||
if (direct_ioctl(env, SIOCG80211POWER, &power) == -1)
|
||||
goto skip_power;
|
||||
printf("\tpowersave ");
|
||||
if (power.i_enabled)
|
||||
|
@ -771,11 +657,9 @@ ieee80211_status(prop_dictionary_t env, prop_dictionary_t oenv)
|
|||
printf("\n");
|
||||
|
||||
skip_power:
|
||||
estrlcpy(bssid.i_name, ifname, sizeof(bssid.i_name));
|
||||
if (ioctl(s, SIOCG80211BSSID, &bssid) == -1)
|
||||
if (direct_ioctl(env, SIOCG80211BSSID, &bssid) == -1)
|
||||
return;
|
||||
estrlcpy(channel.i_name, ifname, sizeof(channel.i_name));
|
||||
if (ioctl(s, SIOCG80211CHANNEL, &channel) == -1)
|
||||
if (direct_ioctl(env, SIOCG80211CHANNEL, &channel) == -1)
|
||||
return;
|
||||
if (memcmp(bssid.i_bssid, zero_macaddr, IEEE80211_ADDR_LEN) == 0) {
|
||||
if (channel.i_channel != (u_int16_t)-1)
|
||||
|
@ -829,21 +713,12 @@ list_scan(prop_dictionary_t env)
|
|||
char ssid[IEEE80211_NWID_LEN+1];
|
||||
const u_int8_t *cp;
|
||||
int len, ssidmax;
|
||||
int s;
|
||||
const char *ifname;
|
||||
|
||||
if ((s = getsock(AF_UNSPEC)) == -1)
|
||||
err(EXIT_FAILURE, "%s: getsock", __func__);
|
||||
|
||||
if ((ifname = getifname(env)) == NULL)
|
||||
return;
|
||||
|
||||
memset(&ireq, 0, sizeof(ireq));
|
||||
estrlcpy(ireq.i_name, ifname, sizeof(ireq.i_name));
|
||||
ireq.i_type = IEEE80211_IOC_SCAN_RESULTS;
|
||||
ireq.i_data = buf;
|
||||
ireq.i_len = sizeof(buf);
|
||||
if (ioctl(s, SIOCG80211, &ireq) < 0)
|
||||
if (direct_ioctl(env, SIOCG80211, &ireq) < 0)
|
||||
errx(EXIT_FAILURE, "unable to get scan results");
|
||||
len = ireq.i_len;
|
||||
if (len < sizeof(struct ieee80211req_scan_result))
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ifconfig.c,v 1.200 2008/05/07 21:29:27 dyoung Exp $ */
|
||||
/* $NetBSD: ifconfig.c,v 1.201 2008/05/07 23:55:06 dyoung Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997, 1998, 2000 The NetBSD Foundation, Inc.
|
||||
|
@ -69,7 +69,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 1993\n\
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)ifconfig.c 8.2 (Berkeley) 2/16/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: ifconfig.c,v 1.200 2008/05/07 21:29:27 dyoung Exp $");
|
||||
__RCSID("$NetBSD: ifconfig.c,v 1.201 2008/05/07 23:55:06 dyoung Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
@ -140,7 +140,7 @@ int media_current;
|
|||
int mediaopt_set;
|
||||
int mediaopt_clear;
|
||||
|
||||
void check_ifflags_up(const char *);
|
||||
void check_ifflags_up(prop_dictionary_t);
|
||||
|
||||
int notealias(prop_dictionary_t, prop_dictionary_t);
|
||||
int notrailers(prop_dictionary_t, prop_dictionary_t);
|
||||
|
@ -490,7 +490,7 @@ media_status_exec(prop_dictionary_t env, prop_dictionary_t xenv)
|
|||
}
|
||||
|
||||
static void
|
||||
do_setifcaps(int s, const char *ifname, prop_dictionary_t env)
|
||||
do_setifcaps(prop_dictionary_t env)
|
||||
{
|
||||
struct ifcapreq ifcr;
|
||||
prop_data_t d;
|
||||
|
@ -502,8 +502,7 @@ do_setifcaps(int s, const char *ifname, prop_dictionary_t env)
|
|||
assert(sizeof(ifcr) == prop_data_size(d));
|
||||
|
||||
memcpy(&ifcr, prop_data_data_nocopy(d), sizeof(ifcr));
|
||||
estrlcpy(ifcr.ifcr_name, ifname, sizeof(ifcr.ifcr_name));
|
||||
if (ioctl(s, SIOCSIFCAP, &ifcr) == -1)
|
||||
if (direct_ioctl(env, SIOCSIFCAP, &ifcr) == -1)
|
||||
err(EXIT_FAILURE, "SIOCSIFCAP");
|
||||
}
|
||||
|
||||
|
@ -703,10 +702,10 @@ main(int argc, char **argv)
|
|||
}
|
||||
|
||||
do_setifpreference(env);
|
||||
do_setifcaps(s, ifname, env);
|
||||
do_setifcaps(env);
|
||||
|
||||
if (check_up_state == 1)
|
||||
check_ifflags_up(ifname);
|
||||
check_ifflags_up(env);
|
||||
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
@ -838,24 +837,14 @@ list_cloners(prop_dictionary_t env, prop_dictionary_t oenv)
|
|||
static int
|
||||
clone_command(prop_dictionary_t env, prop_dictionary_t xenv)
|
||||
{
|
||||
struct ifreq ifreq;
|
||||
int s;
|
||||
int64_t cmd;
|
||||
const char *ifname;
|
||||
|
||||
if (!prop_dictionary_get_int64(env, "clonecmd", &cmd)) {
|
||||
errno = ENOENT;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((ifname = getifname(env)) == NULL)
|
||||
return -1;
|
||||
|
||||
/* We're called early... */
|
||||
s = getsock(AF_INET);
|
||||
|
||||
estrlcpy(ifreq.ifr_name, ifname, sizeof(ifreq.ifr_name));
|
||||
if (ioctl(s, (unsigned long)cmd, &ifreq) == -1) {
|
||||
if (indirect_ioctl(env, (unsigned long)cmd, NULL) == -1) {
|
||||
warn("%s", __func__);
|
||||
return -1;
|
||||
}
|
||||
|
@ -1081,52 +1070,41 @@ setifdstormask(prop_dictionary_t env, prop_dictionary_t xenv)
|
|||
}
|
||||
|
||||
void
|
||||
check_ifflags_up(const char *ifname)
|
||||
check_ifflags_up(prop_dictionary_t env)
|
||||
{
|
||||
struct ifreq ifreq;
|
||||
int s;
|
||||
struct ifreq ifr;
|
||||
|
||||
s = getsock(AF_UNSPEC);
|
||||
|
||||
estrlcpy(ifreq.ifr_name, ifname, sizeof(ifreq.ifr_name));
|
||||
if (ioctl(s, SIOCGIFFLAGS, &ifreq) == -1)
|
||||
if (direct_ioctl(env, SIOCGIFFLAGS, &ifr) == -1)
|
||||
err(EXIT_FAILURE, "SIOCGIFFLAGS");
|
||||
if (ifreq.ifr_flags & IFF_UP)
|
||||
if (ifr.ifr_flags & IFF_UP)
|
||||
return;
|
||||
ifreq.ifr_flags |= IFF_UP;
|
||||
if (ioctl(s, SIOCSIFFLAGS, &ifreq) == -1)
|
||||
ifr.ifr_flags |= IFF_UP;
|
||||
if (direct_ioctl(env, SIOCSIFFLAGS, &ifr) == -1)
|
||||
err(EXIT_FAILURE, "SIOCSIFFLAGS");
|
||||
}
|
||||
|
||||
int
|
||||
setifflags(prop_dictionary_t env, prop_dictionary_t xenv)
|
||||
{
|
||||
struct ifreq ifreq;
|
||||
struct ifreq ifr;
|
||||
int64_t ifflag;
|
||||
int s;
|
||||
bool rc;
|
||||
const char *ifname;
|
||||
|
||||
s = getsock(AF_INET);
|
||||
|
||||
rc = prop_dictionary_get_int64(env, "ifflag", &ifflag);
|
||||
assert(rc);
|
||||
if ((ifname = getifname(env)) == NULL)
|
||||
return -1;
|
||||
|
||||
estrlcpy(ifreq.ifr_name, ifname, sizeof(ifreq.ifr_name));
|
||||
if (ioctl(s, SIOCGIFFLAGS, &ifreq) == -1)
|
||||
if (direct_ioctl(env, SIOCGIFFLAGS, &ifr) == -1)
|
||||
return -1;
|
||||
|
||||
if (ifflag < 0) {
|
||||
ifflag = -ifflag;
|
||||
if (ifflag == IFF_UP)
|
||||
check_up_state = 0;
|
||||
ifreq.ifr_flags &= ~ifflag;
|
||||
ifr.ifr_flags &= ~ifflag;
|
||||
} else
|
||||
ifreq.ifr_flags |= ifflag;
|
||||
ifr.ifr_flags |= ifflag;
|
||||
|
||||
if (ioctl(s, SIOCSIFFLAGS, &ifreq) == -1)
|
||||
if (direct_ioctl(env, SIOCSIFFLAGS, &ifr) == -1)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
|
@ -1135,19 +1113,11 @@ setifflags(prop_dictionary_t env, prop_dictionary_t xenv)
|
|||
static int
|
||||
getifcaps(prop_dictionary_t env, prop_dictionary_t oenv, struct ifcapreq *oifcr)
|
||||
{
|
||||
const char *ifname;
|
||||
bool rc;
|
||||
int s;
|
||||
struct ifcapreq ifcr;
|
||||
const struct ifcapreq *tmpifcr;
|
||||
prop_data_t capdata;
|
||||
|
||||
if ((s = getsock(AF_UNSPEC)) == -1)
|
||||
return -1;
|
||||
|
||||
if ((ifname = getifname(env)) == NULL)
|
||||
return -1;
|
||||
|
||||
capdata = (prop_data_t)prop_dictionary_get(env, "ifcaps");
|
||||
|
||||
if (capdata != NULL) {
|
||||
|
@ -1156,8 +1126,7 @@ getifcaps(prop_dictionary_t env, prop_dictionary_t oenv, struct ifcapreq *oifcr)
|
|||
return 0;
|
||||
}
|
||||
|
||||
estrlcpy(ifcr.ifcr_name, ifname, sizeof(ifcr.ifcr_name));
|
||||
(void)ioctl(s, SIOCGIFCAP, &ifcr);
|
||||
(void)direct_ioctl(env, SIOCGIFCAP, &ifcr);
|
||||
*oifcr = ifcr;
|
||||
|
||||
capdata = prop_data_create_data(&ifcr, sizeof(ifcr));
|
||||
|
@ -1210,22 +1179,13 @@ setifmetric(prop_dictionary_t env, prop_dictionary_t xenv)
|
|||
{
|
||||
struct ifreq ifr;
|
||||
bool rc;
|
||||
const char *ifname;
|
||||
int s;
|
||||
int64_t metric;
|
||||
|
||||
if ((s = getsock(AF_UNSPEC)) == -1)
|
||||
return -1;
|
||||
|
||||
if ((ifname = getifname(env)) == NULL)
|
||||
return -1;
|
||||
|
||||
rc = prop_dictionary_get_int64(env, "metric", &metric);
|
||||
assert(rc);
|
||||
|
||||
estrlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
|
||||
ifr.ifr_metric = metric;
|
||||
if (ioctl(s, SIOCSIFMETRIC, &ifr) == -1)
|
||||
if (direct_ioctl(env, SIOCSIFMETRIC, &ifr) == -1)
|
||||
warn("SIOCSIFMETRIC");
|
||||
return 0;
|
||||
}
|
||||
|
@ -1234,8 +1194,7 @@ static void
|
|||
do_setifpreference(prop_dictionary_t env)
|
||||
{
|
||||
struct if_addrprefreq ifap;
|
||||
int af, s;
|
||||
const char *ifname;
|
||||
int af;
|
||||
const struct afswtch *afp;
|
||||
prop_data_t d;
|
||||
const struct paddr_prefix *pfx;
|
||||
|
@ -1257,15 +1216,9 @@ do_setifpreference(prop_dictionary_t env)
|
|||
|
||||
pfx = prop_data_data_nocopy(d);
|
||||
|
||||
s = getsock(AF_UNSPEC);
|
||||
|
||||
if ((ifname = getifname(env)) == NULL)
|
||||
err(EXIT_FAILURE, "%s: getifname", __func__);
|
||||
|
||||
strlcpy(ifap.ifap_name, ifname, sizeof(ifap.ifap_name));
|
||||
memcpy(&ifap.ifap_addr, &pfx->pfx_addr,
|
||||
MIN(sizeof(ifap.ifap_addr), pfx->pfx_addr.sa_len));
|
||||
if (ioctl(s, SIOCSIFADDRPREF, &ifap) == -1)
|
||||
if (direct_ioctl(env, SIOCSIFADDRPREF, &ifap) == -1)
|
||||
warn("SIOCSIFADDRPREF");
|
||||
}
|
||||
|
||||
|
@ -1274,22 +1227,13 @@ setifmtu(prop_dictionary_t env, prop_dictionary_t xenv)
|
|||
{
|
||||
int64_t mtu;
|
||||
bool rc;
|
||||
const char *ifname;
|
||||
struct ifreq ifr;
|
||||
int s;
|
||||
|
||||
if ((s = getsock(AF_UNSPEC)) == -1)
|
||||
return -1;
|
||||
|
||||
if ((ifname = getifname(env)) == NULL)
|
||||
return -1;
|
||||
|
||||
rc = prop_dictionary_get_int64(env, "mtu", &mtu);
|
||||
assert(rc);
|
||||
|
||||
estrlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
|
||||
ifr.ifr_mtu = mtu;
|
||||
if (ioctl(s, SIOCSIFMTU, &ifr) == -1)
|
||||
if (direct_ioctl(env, SIOCSIFMTU, &ifr) == -1)
|
||||
warn("SIOCSIFMTU");
|
||||
|
||||
return 0;
|
||||
|
@ -1305,15 +1249,11 @@ media_error(int type, const char *val, const char *opt)
|
|||
void
|
||||
init_current_media(prop_dictionary_t env, prop_dictionary_t oenv)
|
||||
{
|
||||
struct ifmediareq ifmr;
|
||||
int s;
|
||||
const char *ifname;
|
||||
|
||||
if ((s = getsock(AF_UNSPEC)) == -1)
|
||||
err(EXIT_FAILURE, "%s: getsock", __func__);
|
||||
struct ifmediareq ifmr;
|
||||
|
||||
if ((ifname = getifname(env)) == NULL)
|
||||
err(EXIT_FAILURE, "%s: getifname", __func__);
|
||||
err(EXIT_FAILURE, "getifname");
|
||||
|
||||
/*
|
||||
* If we have not yet done so, grab the currently-selected
|
||||
|
@ -1322,9 +1262,8 @@ init_current_media(prop_dictionary_t env, prop_dictionary_t oenv)
|
|||
|
||||
if (prop_dictionary_get(env, "initmedia") == NULL) {
|
||||
memset(&ifmr, 0, sizeof(ifmr));
|
||||
estrlcpy(ifmr.ifm_name, ifname, sizeof(ifmr.ifm_name));
|
||||
|
||||
if (ioctl(s, SIOCGIFMEDIA, &ifmr) == -1) {
|
||||
if (direct_ioctl(env, SIOCGIFMEDIA, &ifmr) == -1) {
|
||||
/*
|
||||
* If we get E2BIG, the kernel is telling us
|
||||
* that there are more, so we can ignore it.
|
||||
|
@ -1349,11 +1288,6 @@ void
|
|||
process_media_commands(prop_dictionary_t env)
|
||||
{
|
||||
struct ifreq ifr;
|
||||
const char *ifname;
|
||||
int s;
|
||||
|
||||
if ((s = getsock(AF_UNSPEC)) == -1)
|
||||
err(EXIT_FAILURE, "%s: getsock", __func__);
|
||||
|
||||
if (prop_dictionary_get(env, "media") == NULL &&
|
||||
prop_dictionary_get(env, "mediaopt") == NULL &&
|
||||
|
@ -1363,9 +1297,6 @@ process_media_commands(prop_dictionary_t env)
|
|||
return;
|
||||
}
|
||||
|
||||
if ((ifname = getifname(env)) == NULL)
|
||||
err(EXIT_FAILURE, "%s: getifname", __func__);
|
||||
|
||||
/*
|
||||
* Media already set up, and commands sanity-checked. Set/clear
|
||||
* any options, and we're ready to go.
|
||||
|
@ -1374,10 +1305,9 @@ process_media_commands(prop_dictionary_t env)
|
|||
media_current &= ~mediaopt_clear;
|
||||
|
||||
memset(&ifr, 0, sizeof(ifr));
|
||||
estrlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
|
||||
ifr.ifr_media = media_current;
|
||||
|
||||
if (ioctl(s, SIOCSIFMEDIA, &ifr) == -1)
|
||||
if (direct_ioctl(env, SIOCSIFMEDIA, &ifr) == -1)
|
||||
err(EXIT_FAILURE, "SIOCSIFMEDIA");
|
||||
}
|
||||
|
||||
|
@ -1565,19 +1495,10 @@ int
|
|||
carrier(prop_dictionary_t env)
|
||||
{
|
||||
struct ifmediareq ifmr;
|
||||
int s;
|
||||
const char *ifname;
|
||||
|
||||
if ((s = getsock(AF_UNSPEC)) == -1)
|
||||
err(EXIT_FAILURE, "%s: getsock", __func__);
|
||||
memset(&ifmr, 0, sizeof(ifmr));
|
||||
|
||||
if ((ifname = getifname(env)) == NULL)
|
||||
err(EXIT_FAILURE, "%s: getifname", __func__);
|
||||
|
||||
(void) memset(&ifmr, 0, sizeof(ifmr));
|
||||
estrlcpy(ifmr.ifm_name, ifname, sizeof(ifmr.ifm_name));
|
||||
|
||||
if (ioctl(s, SIOCGIFMEDIA, &ifmr) == -1) {
|
||||
if (direct_ioctl(env, SIOCGIFMEDIA, &ifmr) == -1) {
|
||||
/*
|
||||
* Interface doesn't support SIOC{G,S}IFMEDIA;
|
||||
* assume ok.
|
||||
|
@ -1629,6 +1550,7 @@ status(const struct sockaddr_dl *sdl, prop_dictionary_t env,
|
|||
} else
|
||||
afp = lookup_af_bynum(af);
|
||||
|
||||
/* get out early if the family is unsupported by the kernel */
|
||||
if ((s = getsock(af)) == -1)
|
||||
err(EXIT_FAILURE, "%s: getsock", __func__);
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: tunnel.c,v 1.12 2008/05/07 20:03:27 dyoung Exp $ */
|
||||
/* $NetBSD: tunnel.c,v 1.13 2008/05/07 23:55:07 dyoung Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983, 1993
|
||||
|
@ -31,7 +31,7 @@
|
|||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: tunnel.c,v 1.12 2008/05/07 20:03:27 dyoung Exp $");
|
||||
__RCSID("$NetBSD: tunnel.c,v 1.13 2008/05/07 23:55:07 dyoung Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
|
@ -82,15 +82,7 @@ settunnel(prop_dictionary_t env, prop_dictionary_t xenv)
|
|||
{
|
||||
const struct paddr_prefix *srcpfx, *dstpfx;
|
||||
struct if_laddrreq req;
|
||||
int s;
|
||||
prop_data_t srcdata, dstdata;
|
||||
const char *ifname;
|
||||
|
||||
if ((s = getsock(AF_UNSPEC)) == -1)
|
||||
err(EXIT_FAILURE, "%s: getsock", __func__);
|
||||
|
||||
if ((ifname = getifname(env)) == NULL)
|
||||
return -1;
|
||||
|
||||
srcdata = (prop_data_t)prop_dictionary_get(env, "tunsrc");
|
||||
dstdata = (prop_data_t)prop_dictionary_get(env, "tundst");
|
||||
|
@ -109,7 +101,6 @@ settunnel(prop_dictionary_t env, prop_dictionary_t xenv)
|
|||
"source and destination address families do not match");
|
||||
|
||||
memset(&req, 0, sizeof(req));
|
||||
estrlcpy(req.iflr_name, ifname, sizeof(req.iflr_name));
|
||||
memcpy(&req.addr, &srcpfx->pfx_addr,
|
||||
MIN(sizeof(req.addr), srcpfx->pfx_addr.sa_len));
|
||||
memcpy(&req.dstaddr, &dstpfx->pfx_addr,
|
||||
|
@ -141,7 +132,7 @@ settunnel(prop_dictionary_t env, prop_dictionary_t xenv)
|
|||
}
|
||||
#endif /* INET6 */
|
||||
|
||||
if (ioctl(s, SIOCSLIFPHYADDR, &req) == -1)
|
||||
if (direct_ioctl(env, SIOCSLIFPHYADDR, &req) == -1)
|
||||
warn("SIOCSLIFPHYADDR");
|
||||
return 0;
|
||||
}
|
||||
|
@ -149,20 +140,7 @@ settunnel(prop_dictionary_t env, prop_dictionary_t xenv)
|
|||
int
|
||||
deletetunnel(prop_dictionary_t env, prop_dictionary_t xenv)
|
||||
{
|
||||
int s;
|
||||
struct ifreq ifr;
|
||||
const char *ifname;
|
||||
|
||||
if ((s = getsock(AF_UNSPEC)) == -1)
|
||||
err(EXIT_FAILURE, "%s: getsock", __func__);
|
||||
|
||||
if ((ifname = getifname(env)) == NULL)
|
||||
return -1;
|
||||
|
||||
memset(&ifr, 0, sizeof(ifr));
|
||||
|
||||
estrlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
|
||||
if (ioctl(s, SIOCDIFPHYADDR, &ifr) == -1)
|
||||
if (indirect_ioctl(env, SIOCDIFPHYADDR, NULL) == -1)
|
||||
err(EXIT_FAILURE, "SIOCDIFPHYADDR");
|
||||
return 0;
|
||||
}
|
||||
|
@ -177,20 +155,11 @@ tunnel_status(prop_dictionary_t env, prop_dictionary_t oenv)
|
|||
const int niflag = NI_NUMERICHOST|NI_NUMERICSERV;
|
||||
struct if_laddrreq req;
|
||||
const struct afswtch *lafp;
|
||||
int s;
|
||||
const char *ifname;
|
||||
|
||||
if ((s = getsock(AF_UNSPEC)) == -1)
|
||||
err(EXIT_FAILURE, "%s: getsock", __func__);
|
||||
|
||||
psrcaddr[0] = pdstaddr[0] = '\0';
|
||||
|
||||
if ((ifname = getifname(env)) == NULL)
|
||||
err(EXIT_FAILURE, "%s: getifname", __func__);
|
||||
|
||||
memset(&req, 0, sizeof(req));
|
||||
estrlcpy(req.iflr_name, ifname, IFNAMSIZ);
|
||||
if (ioctl(s, SIOCGLIFPHYADDR, &req) == -1)
|
||||
if (direct_ioctl(env, SIOCGLIFPHYADDR, &req) == -1)
|
||||
return;
|
||||
lafp = lookup_af_bynum(req.addr.ss_family);
|
||||
#ifdef INET6
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: util.c,v 1.3 2008/05/07 18:17:42 dyoung Exp $ */
|
||||
/* $NetBSD: util.c,v 1.4 2008/05/07 23:55:07 dyoung Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c)2008 David Young. All rights reserved.
|
||||
|
@ -33,10 +33,14 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <util.h>
|
||||
|
||||
#include <sys/socket.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <net/if.h>
|
||||
#include <netinet/in.h> /* XXX */
|
||||
|
||||
#include "env.h"
|
||||
#include "util.h"
|
||||
|
||||
int
|
||||
|
@ -191,3 +195,32 @@ prefixlen_to_mask(int af, int plen)
|
|||
|
||||
return pfx;
|
||||
}
|
||||
|
||||
int
|
||||
direct_ioctl(prop_dictionary_t env, unsigned long cmd, void *data)
|
||||
{
|
||||
const char *ifname;
|
||||
int s;
|
||||
|
||||
if ((s = getsock(AF_UNSPEC)) == -1)
|
||||
err(EXIT_FAILURE, "getsock");
|
||||
|
||||
if ((ifname = getifname(env)) == NULL)
|
||||
err(EXIT_FAILURE, "getifname");
|
||||
|
||||
estrlcpy(data, ifname, IFNAMSIZ);
|
||||
|
||||
return ioctl(s, cmd, data);
|
||||
}
|
||||
|
||||
int
|
||||
indirect_ioctl(prop_dictionary_t env, unsigned long cmd, void *data)
|
||||
{
|
||||
struct ifreq ifr;
|
||||
|
||||
memset(&ifr, 0, sizeof(ifr));
|
||||
|
||||
ifr.ifr_data = data;
|
||||
|
||||
return direct_ioctl(env, cmd, &ifr);
|
||||
}
|
||||
|
|
|
@ -23,5 +23,7 @@ const struct afswtch *lookup_af_bynum(int);
|
|||
void print_string(const u_int8_t *, int);
|
||||
int getsock(int);
|
||||
struct paddr_prefix *prefixlen_to_mask(int, int);
|
||||
int direct_ioctl(prop_dictionary_t, unsigned long, void *);
|
||||
int indirect_ioctl(prop_dictionary_t, unsigned long, void *);
|
||||
|
||||
#endif /* _IFCONFIG_UTIL_H */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: vlan.c,v 1.7 2008/05/07 20:11:15 dyoung Exp $ */
|
||||
/* $NetBSD: vlan.c,v 1.8 2008/05/07 23:55:07 dyoung Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983, 1993
|
||||
|
@ -31,7 +31,7 @@
|
|||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: vlan.c,v 1.7 2008/05/07 20:11:15 dyoung Exp $");
|
||||
__RCSID("$NetBSD: vlan.c,v 1.8 2008/05/07 23:55:07 dyoung Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
|
@ -51,6 +51,7 @@ __RCSID("$NetBSD: vlan.c,v 1.7 2008/05/07 20:11:15 dyoung Exp $");
|
|||
|
||||
#include "env.h"
|
||||
#include "extern.h"
|
||||
#include "util.h"
|
||||
#include "vlan.h"
|
||||
|
||||
struct pinteger vlantag = PINTEGER_INITIALIZER1(&vlantag, "VLAN tag",
|
||||
|
@ -71,52 +72,41 @@ struct pkw vlan = PKW_INITIALIZER(&vlan, "vlan", NULL, NULL,
|
|||
vlankw, __arraycount(vlankw), NULL);
|
||||
|
||||
static int
|
||||
checkifname(const char *ifname)
|
||||
checkifname(prop_dictionary_t env)
|
||||
{
|
||||
const char *ifname;
|
||||
|
||||
if ((ifname = getifname(env)) == NULL)
|
||||
return 1;
|
||||
|
||||
return strncmp(ifname, "vlan", 4) != 0 ||
|
||||
!isdigit((unsigned char)ifname[4]);
|
||||
}
|
||||
|
||||
static int
|
||||
getvlan(prop_dictionary_t env, struct ifreq *ifr, struct vlanreq *vlr,
|
||||
bool quiet)
|
||||
getvlan(prop_dictionary_t env, struct vlanreq *vlr, bool quiet)
|
||||
{
|
||||
int s;
|
||||
const char *ifname;
|
||||
|
||||
if ((s = getsock(AF_UNSPEC)) == -1)
|
||||
err(EXIT_FAILURE, "%s: getsock", __func__);
|
||||
if ((ifname = getifname(env)) == NULL)
|
||||
err(EXIT_FAILURE, "%s: getifname", __func__);
|
||||
|
||||
memset(ifr, 0, sizeof(*ifr));
|
||||
memset(vlr, 0, sizeof(*vlr));
|
||||
|
||||
if (checkifname(ifname)) {
|
||||
if (checkifname(env)) {
|
||||
if (quiet)
|
||||
return -1;
|
||||
errx(EXIT_FAILURE, "valid only with vlan(4) interfaces");
|
||||
}
|
||||
|
||||
estrlcpy(ifr->ifr_name, ifname, sizeof(ifr->ifr_name));
|
||||
ifr->ifr_data = vlr;
|
||||
|
||||
if (ioctl(s, SIOCGETVLAN, ifr) == -1)
|
||||
if (indirect_ioctl(env, SIOCGETVLAN, vlr) == -1)
|
||||
return -1;
|
||||
|
||||
return s;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
setvlan(prop_dictionary_t env, prop_dictionary_t xenv)
|
||||
{
|
||||
struct vlanreq vlr;
|
||||
int s;
|
||||
int64_t tag;
|
||||
struct ifreq ifr;
|
||||
|
||||
if ((s = getvlan(env, &ifr, &vlr, false)) == -1)
|
||||
if (getvlan(env, &vlr, false) == -1)
|
||||
err(EXIT_FAILURE, "%s: getvlan", __func__);
|
||||
|
||||
if (!prop_dictionary_get_int64(env, "vlantag", &tag)) {
|
||||
|
@ -126,7 +116,7 @@ setvlan(prop_dictionary_t env, prop_dictionary_t xenv)
|
|||
|
||||
vlr.vlr_tag = tag;
|
||||
|
||||
if (ioctl(s, SIOCSETVLAN, &ifr) == -1)
|
||||
if (indirect_ioctl(env, SIOCSETVLAN, &vlr) == -1)
|
||||
err(EXIT_FAILURE, "SIOCSETVLAN");
|
||||
return 0;
|
||||
}
|
||||
|
@ -135,12 +125,10 @@ int
|
|||
setvlanif(prop_dictionary_t env, prop_dictionary_t xenv)
|
||||
{
|
||||
struct vlanreq vlr;
|
||||
int s;
|
||||
const char *parent;
|
||||
int64_t tag;
|
||||
struct ifreq ifr;
|
||||
|
||||
if ((s = getvlan(env, &ifr, &vlr, false)) == -1)
|
||||
if (getvlan(env, &vlr, false) == -1)
|
||||
err(EXIT_FAILURE, "%s: getsock", __func__);
|
||||
|
||||
if (!prop_dictionary_get_int64(env, "vlantag", &tag)) {
|
||||
|
@ -156,7 +144,7 @@ setvlanif(prop_dictionary_t env, prop_dictionary_t xenv)
|
|||
if (strcmp(parent, "") != 0)
|
||||
vlr.vlr_tag = (unsigned short)tag;
|
||||
|
||||
if (ioctl(s, SIOCSETVLAN, &ifr) == -1)
|
||||
if (indirect_ioctl(env, SIOCSETVLAN, &vlr) == -1)
|
||||
err(EXIT_FAILURE, "SIOCSETVLAN");
|
||||
return 0;
|
||||
}
|
||||
|
@ -165,10 +153,8 @@ void
|
|||
vlan_status(prop_dictionary_t env, prop_dictionary_t oenv)
|
||||
{
|
||||
struct vlanreq vlr;
|
||||
int s;
|
||||
struct ifreq ifr;
|
||||
|
||||
if ((s = getvlan(env, &ifr, &vlr, true)) == -1)
|
||||
if (getvlan(env, &vlr, true) == -1)
|
||||
return;
|
||||
|
||||
if (vlr.vlr_tag || vlr.vlr_parent[0] != '\0')
|
||||
|
|
Loading…
Reference in New Issue