mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-12-20 23:54:38 +01:00
sbin/ifconfig: Get carp status with libifconfig
A trivial change now that ifconfig is already using libifconfig. Reviewed by: kp (earlier version) MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D28955
This commit is contained in:
parent
3fe2c68ba2
commit
da393346ac
@ -50,6 +50,8 @@
|
|||||||
#include <err.h>
|
#include <err.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
#include <libifconfig.h>
|
||||||
|
|
||||||
#include "ifconfig.h"
|
#include "ifconfig.h"
|
||||||
|
|
||||||
static const char *carp_states[] = { CARP_STATES };
|
static const char *carp_states[] = { CARP_STATES };
|
||||||
@ -71,16 +73,16 @@ static void
|
|||||||
carp_status(int s)
|
carp_status(int s)
|
||||||
{
|
{
|
||||||
struct carpreq carpr[CARP_MAXVHID];
|
struct carpreq carpr[CARP_MAXVHID];
|
||||||
int i;
|
ifconfig_handle_t *lifh;
|
||||||
|
|
||||||
bzero(carpr, sizeof(struct carpreq) * CARP_MAXVHID);
|
lifh = ifconfig_open();
|
||||||
carpr[0].carpr_count = CARP_MAXVHID;
|
if (lifh == NULL)
|
||||||
ifr.ifr_data = (caddr_t)&carpr;
|
|
||||||
|
|
||||||
if (ioctl(s, SIOCGVH, (caddr_t)&ifr) == -1)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (i = 0; i < carpr[0].carpr_count; i++) {
|
if (ifconfig_carp_get_info(lifh, name, carpr, CARP_MAXVHID) == -1)
|
||||||
|
goto close;
|
||||||
|
|
||||||
|
for (size_t i = 0; i < carpr[0].carpr_count; i++) {
|
||||||
printf("\tcarp: %s vhid %d advbase %d advskew %d",
|
printf("\tcarp: %s vhid %d advbase %d advskew %d",
|
||||||
carp_states[carpr[i].carpr_state], carpr[i].carpr_vhid,
|
carp_states[carpr[i].carpr_state], carpr[i].carpr_vhid,
|
||||||
carpr[i].carpr_advbase, carpr[i].carpr_advskew);
|
carpr[i].carpr_advbase, carpr[i].carpr_advskew);
|
||||||
@ -89,6 +91,8 @@ carp_status(int s)
|
|||||||
else
|
else
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
close:
|
||||||
|
ifconfig_close(lifh);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
Reference in New Issue
Block a user