diff options
| author | Alexander V. Chernikov <melifaro@FreeBSD.org> | 2023-05-23 17:02:12 +0000 |
|---|---|---|
| committer | Alexander V. Chernikov <melifaro@FreeBSD.org> | 2023-05-24 10:40:34 +0000 |
| commit | 6e3a9d7f2c8dc18dc901d4f860a65028c0a82a64 (patch) | |
| tree | 2aadbdd46f837dc467e89f11e2345daa2e6c3e4d /sbin/ifconfig/ifpfsync.c | |
| parent | 44cd85d42e5ddb1d5811b388218e14582e078bf8 (diff) | |
Diffstat (limited to 'sbin/ifconfig/ifpfsync.c')
| -rw-r--r-- | sbin/ifconfig/ifpfsync.c | 68 |
1 files changed, 27 insertions, 41 deletions
diff --git a/sbin/ifconfig/ifpfsync.c b/sbin/ifconfig/ifpfsync.c index eb214ed6e634..8fd15962c2d0 100644 --- a/sbin/ifconfig/ifpfsync.c +++ b/sbin/ifconfig/ifpfsync.c @@ -50,15 +50,6 @@ #include "ifconfig.h" -void setpfsync_syncdev(const char *, int, int, const struct afswtch *); -void unsetpfsync_syncdev(const char *, int, int, const struct afswtch *); -void setpfsync_syncpeer(const char *, int, int, const struct afswtch *); -void unsetpfsync_syncpeer(const char *, int, int, const struct afswtch *); -void setpfsync_syncpeer(const char *, int, int, const struct afswtch *); -void setpfsync_maxupd(const char *, int, int, const struct afswtch *); -void setpfsync_defer(const char *, int, int, const struct afswtch *); -void pfsync_status(int); - static int pfsync_do_ioctl(int s, uint cmd, nvlist_t **nvl) { @@ -173,15 +164,15 @@ pfsync_syncpeer_nvlist_to_sockaddr(const nvlist_t *nvl, return (0); } -void -setpfsync_syncdev(const char *val, int d, int s, const struct afswtch *rafp) +static void +setpfsync_syncdev(if_ctx *ctx, const char *val, int dummy __unused) { nvlist_t *nvl = nvlist_create(0); if (strlen(val) > IFNAMSIZ) errx(1, "interface name %s is too long", val); - if (pfsync_do_ioctl(s, SIOCGETPFSYNCNV, &nvl) == -1) + if (pfsync_do_ioctl(ctx->io_s, SIOCGETPFSYNCNV, &nvl) == -1) err(1, "SIOCGETPFSYNCNV"); if (nvlist_exists_string(nvl, "syncdev")) @@ -189,17 +180,16 @@ setpfsync_syncdev(const char *val, int d, int s, const struct afswtch *rafp) nvlist_add_string(nvl, "syncdev", val); - if (pfsync_do_ioctl(s, SIOCSETPFSYNCNV, &nvl) == -1) + if (pfsync_do_ioctl(ctx->io_s, SIOCSETPFSYNCNV, &nvl) == -1) err(1, "SIOCSETPFSYNCNV"); } -/* ARGSUSED */ -void -unsetpfsync_syncdev(const char *val, int d, int s, const struct afswtch *rafp) +static void +unsetpfsync_syncdev(if_ctx *ctx, const char *val, int dummy __unused) { nvlist_t *nvl = nvlist_create(0); - if (pfsync_do_ioctl(s, SIOCGETPFSYNCNV, &nvl) == -1) + if (pfsync_do_ioctl(ctx->io_s, SIOCGETPFSYNCNV, &nvl) == -1) err(1, "SIOCGETPFSYNCNV"); if (nvlist_exists_string(nvl, "syncdev")) @@ -207,13 +197,12 @@ unsetpfsync_syncdev(const char *val, int d, int s, const struct afswtch *rafp) nvlist_add_string(nvl, "syncdev", ""); - if (pfsync_do_ioctl(s, SIOCSETPFSYNCNV, &nvl) == -1) + if (pfsync_do_ioctl(ctx->io_s, SIOCSETPFSYNCNV, &nvl) == -1) err(1, "SIOCSETPFSYNCNV"); } -/* ARGSUSED */ -void -setpfsync_syncpeer(const char *val, int d, int s, const struct afswtch *rafp) +static void +setpfsync_syncpeer(if_ctx *ctx, const char *val, int dummy __unused) { struct addrinfo *peerres; struct sockaddr_storage addr; @@ -221,7 +210,7 @@ setpfsync_syncpeer(const char *val, int d, int s, const struct afswtch *rafp) nvlist_t *nvl = nvlist_create(0); - if (pfsync_do_ioctl(s, SIOCGETPFSYNCNV, &nvl) == -1) + if (pfsync_do_ioctl(ctx->io_s, SIOCGETPFSYNCNV, &nvl) == -1) err(1, "SIOCGETPFSYNCNV"); if ((ecode = getaddrinfo(val, NULL, NULL, &peerres)) != 0) @@ -251,23 +240,22 @@ setpfsync_syncpeer(const char *val, int d, int s, const struct afswtch *rafp) nvlist_add_nvlist(nvl, "syncpeer", pfsync_sockaddr_to_syncpeer_nvlist(&addr)); - if (pfsync_do_ioctl(s, SIOCSETPFSYNCNV, &nvl) == -1) + if (pfsync_do_ioctl(ctx->io_s, SIOCSETPFSYNCNV, &nvl) == -1) err(1, "SIOCSETPFSYNCNV"); nvlist_destroy(nvl); freeaddrinfo(peerres); } -/* ARGSUSED */ -void -unsetpfsync_syncpeer(const char *val, int d, int s, const struct afswtch *rafp) +static void +unsetpfsync_syncpeer(if_ctx *ctx, const char *val, int dummy __unused) { struct sockaddr_storage addr; memset(&addr, 0, sizeof(addr)); nvlist_t *nvl = nvlist_create(0); - if (pfsync_do_ioctl(s, SIOCGETPFSYNCNV, &nvl) == -1) + if (pfsync_do_ioctl(ctx->io_s, SIOCGETPFSYNCNV, &nvl) == -1) err(1, "SIOCGETPFSYNCNV"); if (nvlist_exists_nvlist(nvl, "syncpeer")) @@ -276,15 +264,14 @@ unsetpfsync_syncpeer(const char *val, int d, int s, const struct afswtch *rafp) nvlist_add_nvlist(nvl, "syncpeer", pfsync_sockaddr_to_syncpeer_nvlist(&addr)); - if (pfsync_do_ioctl(s, SIOCSETPFSYNCNV, &nvl) == -1) + if (pfsync_do_ioctl(ctx->io_s, SIOCSETPFSYNCNV, &nvl) == -1) err(1, "SIOCSETPFSYNCNV"); nvlist_destroy(nvl); } -/* ARGSUSED */ -void -setpfsync_maxupd(const char *val, int d, int s, const struct afswtch *rafp) +static void +setpfsync_maxupd(if_ctx *ctx, const char *val, int dummy __unused) { int maxupdates; nvlist_t *nvl = nvlist_create(0); @@ -293,38 +280,37 @@ setpfsync_maxupd(const char *val, int d, int s, const struct afswtch *rafp) if ((maxupdates < 0) || (maxupdates > 255)) errx(1, "maxupd %s: out of range", val); - if (pfsync_do_ioctl(s, SIOCGETPFSYNCNV, &nvl) == -1) + if (pfsync_do_ioctl(ctx->io_s, SIOCGETPFSYNCNV, &nvl) == -1) err(1, "SIOCGETPFSYNCNV"); nvlist_free_number(nvl, "maxupdates"); nvlist_add_number(nvl, "maxupdates", maxupdates); - if (pfsync_do_ioctl(s, SIOCSETPFSYNCNV, &nvl) == -1) + if (pfsync_do_ioctl(ctx->io_s, SIOCSETPFSYNCNV, &nvl) == -1) err(1, "SIOCSETPFSYNCNV"); nvlist_destroy(nvl); } -/* ARGSUSED */ -void -setpfsync_defer(const char *val, int d, int s, const struct afswtch *rafp) +static void +setpfsync_defer(if_ctx *ctx, const char *val, int d) { nvlist_t *nvl = nvlist_create(0); - if (pfsync_do_ioctl(s, SIOCGETPFSYNCNV, &nvl) == -1) + if (pfsync_do_ioctl(ctx->io_s, SIOCGETPFSYNCNV, &nvl) == -1) err(1, "SIOCGETPFSYNCNV"); nvlist_free_number(nvl, "flags"); nvlist_add_number(nvl, "flags", d ? PFSYNCF_DEFER : 0); - if (pfsync_do_ioctl(s, SIOCSETPFSYNCNV, &nvl) == -1) + if (pfsync_do_ioctl(ctx->io_s, SIOCSETPFSYNCNV, &nvl) == -1) err(1, "SIOCSETPFSYNCNV"); nvlist_destroy(nvl); } -void -pfsync_status(int s) +static void +pfsync_status(if_ctx *ctx) { nvlist_t *nvl; char syncdev[IFNAMSIZ]; @@ -336,7 +322,7 @@ pfsync_status(int s) nvl = nvlist_create(0); - if (pfsync_do_ioctl(s, SIOCGETPFSYNCNV, &nvl) == -1) { + if (pfsync_do_ioctl(ctx->io_s, SIOCGETPFSYNCNV, &nvl) == -1) { nvlist_destroy(nvl); return; } |
