diff --git a/sbin/ifconfig/carp.c b/sbin/ifconfig/carp.c --- a/sbin/ifconfig/carp.c +++ b/sbin/ifconfig/carp.c @@ -50,6 +50,8 @@ #include #include +#include + #include "ifconfig.h" static const char *carp_states[] = { CARP_STATES }; @@ -71,15 +73,19 @@ carp_status(int s) { struct carpreq carpr[CARP_MAXVHID]; + ifconfig_handle_t *lifh; + const char *name; int i; - bzero(carpr, sizeof(struct carpreq) * CARP_MAXVHID); - carpr[0].carpr_count = CARP_MAXVHID; - ifr.ifr_data = (caddr_t)&carpr; - - if (ioctl(s, SIOCGVH, (caddr_t)&ifr) == -1) + lifh = ifconfig_open(); + if (lifh == NULL) return; + name = ifr.ifr_name; + + if (ifconfig_carp_get_info(lifh, name, carpr, CARP_MAXVHID) == -1) + goto close; + for (i = 0; i < carpr[0].carpr_count; i++) { printf("\tcarp: %s vhid %d advbase %d advskew %d", carp_states[carpr[i].carpr_state], carpr[i].carpr_vhid, @@ -89,6 +95,8 @@ else printf("\n"); } +close: + ifconfig_close(lifh); } static void