diff options
Diffstat (limited to 'freebsd/sbin/ifconfig/ifcarp.c')
-rw-r--r-- | freebsd/sbin/ifconfig/ifcarp.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/freebsd/sbin/ifconfig/ifcarp.c b/freebsd/sbin/ifconfig/ifcarp.c index 96a6dcb9..2537d6be 100644 --- a/freebsd/sbin/ifconfig/ifcarp.c +++ b/freebsd/sbin/ifconfig/ifcarp.c @@ -57,6 +57,7 @@ void setcarp_advbase(const char *,int, int, const struct afswtch *rafp); void setcarp_advskew(const char *, int, int, const struct afswtch *rafp); void setcarp_passwd(const char *, int, int, const struct afswtch *rafp); void setcarp_vhid(const char *, int, int, const struct afswtch *rafp); +void setcarp_state(const char *, int, int, const struct afswtch *rafp); void carp_status(int s) @@ -175,11 +176,34 @@ setcarp_advbase(const char *val, int d, int s, const struct afswtch *afp) return; } +void setcarp_state(const char *val, int d, int s, const struct afswtch *afp) +{ + struct carpreq carpr; + int i; + + bzero((char *)&carpr, sizeof(struct carpreq)); + ifr.ifr_data = (caddr_t)&carpr; + + if (ioctl(s, SIOCGVH, (caddr_t)&ifr) == -1) + err(1, "SIOCGVH"); + + for (i = 0; i <= CARP_MAXSTATE; i++) { + if (!strcasecmp(val, carp_states[i])) { + carpr.carpr_state = i; + break; + } + } + + if (ioctl(s, SIOCSVH, (caddr_t)&ifr) == -1) + err(1, "SIOCSVH"); +} + static struct cmd carp_cmds[] = { DEF_CMD_ARG("advbase", setcarp_advbase), DEF_CMD_ARG("advskew", setcarp_advskew), DEF_CMD_ARG("pass", setcarp_passwd), DEF_CMD_ARG("vhid", setcarp_vhid), + DEF_CMD_ARG("state", setcarp_state), }; static struct afswtch af_carp = { .af_name = "af_carp", |