Changeset View
Changeset View
Standalone View
Standalone View
sbin/ifconfig/iffib.c
Show First 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | |||||
static void | static void | ||||
fib_status(int s) | fib_status(int s) | ||||
{ | { | ||||
struct ifreq ifr; | struct ifreq ifr; | ||||
memset(&ifr, 0, sizeof(ifr)); | memset(&ifr, 0, sizeof(ifr)); | ||||
strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); | strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); | ||||
if (ioctl(s, SIOCGIFFIB, (caddr_t)&ifr) == 0 && | |||||
if (ioctl(s, SIOCGIFFIB, (caddr_t)&ifr) < 0) | ifr.ifr_fib != RT_DEFAULT_FIB) | ||||
return; | |||||
/* Ignore if it is the default. */ | |||||
if (ifr.ifr_fib == 0) | |||||
return; | |||||
printf("\tfib: %u\n", ifr.ifr_fib); | printf("\tfib: %u\n", ifr.ifr_fib); | ||||
memset(&ifr, 0, sizeof(ifr)); | |||||
strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); | |||||
if (ioctl(s, SIOCGTUNFIB, (caddr_t)&ifr) == 0 && | |||||
ifr.ifr_fib != RT_DEFAULT_FIB) | |||||
printf("\ttunnelfib: %u\n", ifr.ifr_fib); | |||||
} | } | ||||
static void | static void | ||||
setiffib(const char *val, int dummy __unused, int s, | setiffib(const char *val, int dummy __unused, int s, | ||||
const struct afswtch *afp) | const struct afswtch *afp) | ||||
{ | { | ||||
unsigned long fib; | unsigned long fib; | ||||
char *ep; | char *ep; | ||||
fib = strtoul(val, &ep, 0); | fib = strtoul(val, &ep, 0); | ||||
if (*ep != '\0' || fib > UINT_MAX) { | if (*ep != '\0' || fib > UINT_MAX) { | ||||
warn("fib %s not valid", val); | warn("fib %s not valid", val); | ||||
return; | return; | ||||
} | } | ||||
strncpy(ifr.ifr_name, name, sizeof (ifr.ifr_name)); | strncpy(ifr.ifr_name, name, sizeof (ifr.ifr_name)); | ||||
ifr.ifr_fib = fib; | ifr.ifr_fib = fib; | ||||
if (ioctl(s, SIOCSIFFIB, (caddr_t)&ifr) < 0) | if (ioctl(s, SIOCSIFFIB, (caddr_t)&ifr) < 0) | ||||
warn("ioctl (SIOCSIFFIB)"); | warn("ioctl (SIOCSIFFIB)"); | ||||
} | } | ||||
static void | |||||
settunfib(const char *val, int dummy __unused, int s, | |||||
const struct afswtch *afp) | |||||
{ | |||||
unsigned long fib; | |||||
char *ep; | |||||
fib = strtoul(val, &ep, 0); | |||||
if (*ep != '\0' || fib > UINT_MAX) { | |||||
warn("fib %s not valid", val); | |||||
return; | |||||
} | |||||
strncpy(ifr.ifr_name, name, sizeof (ifr.ifr_name)); | |||||
ifr.ifr_fib = fib; | |||||
if (ioctl(s, SIOCSTUNFIB, (caddr_t)&ifr) < 0) | |||||
warn("ioctl (SIOCSTUNFIB)"); | |||||
} | |||||
static struct cmd fib_cmds[] = { | static struct cmd fib_cmds[] = { | ||||
DEF_CMD_ARG("fib", setiffib), | DEF_CMD_ARG("fib", setiffib), | ||||
DEF_CMD_ARG("tunnelfib", settunfib), | |||||
}; | }; | ||||
static struct afswtch af_fib = { | static struct afswtch af_fib = { | ||||
.af_name = "af_fib", | .af_name = "af_fib", | ||||
.af_af = AF_UNSPEC, | .af_af = AF_UNSPEC, | ||||
.af_other_status = fib_status, | .af_other_status = fib_status, | ||||
}; | }; | ||||
Show All 11 Lines |