diff options
author | Daniel Hartmeier <dhartmei@cvs.openbsd.org> | 2001-06-25 00:02:56 +0000 |
---|---|---|
committer | Daniel Hartmeier <dhartmei@cvs.openbsd.org> | 2001-06-25 00:02:56 +0000 |
commit | 3f538dc72c8ae7e4a261f8bf2d4becf66e88517d (patch) | |
tree | b262cb9e8d525198deef3e9ee18bfee7ff5440dd | |
parent | 7d83caee1620a10da905e3db3b57be77a510deba (diff) |
use only ioctl return values found in errno.h
-rw-r--r-- | sbin/pfctl/pfctl.c | 17 | ||||
-rw-r--r-- | sys/net/pf.c | 30 | ||||
-rw-r--r-- | sys/net/pfvar.h | 16 |
3 files changed, 18 insertions, 45 deletions
diff --git a/sbin/pfctl/pfctl.c b/sbin/pfctl/pfctl.c index bca77e75e5f..cf48cb3d3d4 100644 --- a/sbin/pfctl/pfctl.c +++ b/sbin/pfctl/pfctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pfctl.c,v 1.5 2001/06/24 23:44:07 art Exp $ */ +/* $OpenBSD: pfctl.c,v 1.6 2001/06/25 00:02:55 dhartmei Exp $ */ /* * Copyright (c) 2001, Daniel Hartmeier @@ -51,23 +51,10 @@ static void usage(char *); static char *load_file(char *, size_t *); int main(int, char *[]); -static char *errormsg[] = { - "invalid operation", /* ERROR_INVALID_OP */ - "packetfilter is running", /* ERROR_ALREADY_RUNNING */ - "packetfilter not running", /* ERROR_NOT_RUNNING */ - "invalid parameters", /* ERROR_INVALID_PARAMETERS */ - "memory allocation failed" /* ERROR_MALLOC */ -}; - static void printerror(char *s) { - char *msg; - if ((errno >= 100) && (errno < MAX_ERROR_NUM)) - msg = errormsg[errno-100]; - else - msg = strerror(errno); - fprintf(stderr, "ERROR: %s: %s\n", s, msg); + fprintf(stderr, "ERROR: %s: %s\n", s, strerror(errno)); return; } diff --git a/sys/net/pf.c b/sys/net/pf.c index 72e02cb9fa3..edc7ad4f72c 100644 --- a/sys/net/pf.c +++ b/sys/net/pf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pf.c,v 1.17 2001/06/24 23:56:32 itojun Exp $ */ +/* $OpenBSD: pf.c,v 1.18 2001/06/25 00:02:54 dhartmei Exp $ */ /* * Copyright (c) 2001, Daniel Hartmeier @@ -518,13 +518,13 @@ pfioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p) if ((cmd != DIOCSTART) && (cmd != DIOCSTOP) && (cmd != DIOCCLRSTATES)) { ub = (struct pfioc *)addr; if (ub == NULL) - return ERROR_INVALID_PARAMETERS; + return EINVAL; kb = malloc(ub->size, M_DEVBUF, M_NOWAIT); if (kb == NULL) - return ERROR_MALLOC; + return ENOMEM; if (copyin(ub->buffer, kb, ub->size)) { free(kb, M_DEVBUF); - return ERROR_INVALID_PARAMETERS; + return EIO; } } @@ -540,7 +540,7 @@ pfioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p) case DIOCSTART: if (status.running) - error = ERROR_ALREADY_RUNNING; + error = EINVAL; else { u_int32_t states = status.states; bzero(&status, sizeof(struct status)); @@ -553,7 +553,7 @@ pfioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p) case DIOCSTOP: if (!status.running) - error = ERROR_NOT_RUNNING; + error = EINVAL; else { status.running = 0; printf("packetfilter: stopped\n"); @@ -573,7 +573,7 @@ pfioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p) rule = pool_get(&pf_rule_pl, PR_NOWAIT); if (rule == NULL) { - error = ERROR_MALLOC; + error = ENOMEM; goto done; } bcopy(rules + n, rule, sizeof(struct rule)); @@ -582,7 +582,7 @@ pfioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p) rule->ifp = ifunit(rule->ifname); if (rule->ifp == NULL) { pool_put(&pf_rule_pl, rule); - error = ERROR_INVALID_PARAMETERS; + error = EINVAL; goto done; } } @@ -623,14 +623,14 @@ pfioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p) nat = pool_get(&pf_nat_pl, PR_NOWAIT); if (nat == NULL) { - error = ERROR_MALLOC; + error = ENOMEM; goto done; } bcopy(nats + n, nat, sizeof(struct nat)); nat->ifp = ifunit(nat->ifname); if (nat->ifp == NULL) { pool_put(&pf_nat_pl, nat); - error = ERROR_INVALID_PARAMETERS; + error = EINVAL; goto done; } nat->next = nathead; @@ -666,14 +666,14 @@ pfioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p) rdr = pool_get(&pf_rdr_pl, PR_NOWAIT); if (rdr == NULL) { - error = ERROR_MALLOC; + error = ENOMEM; goto done; } bcopy(rdrs + n, rdr, sizeof(struct rdr)); rdr->ifp = ifunit(rdr->ifname); if (rdr->ifp == NULL) { pool_put(&pf_rdr_pl, rdr); - error = ERROR_INVALID_PARAMETERS; + error = EINVAL; goto done; } rdr->next = rdrhead; @@ -728,7 +728,7 @@ pfioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p) char *ifname = (char *)kb; struct ifnet *ifp = ifunit(ifname); if (ifp == NULL) - error = ERROR_INVALID_PARAMETERS; + error = EINVAL; else status_ifp = ifp; break; @@ -749,7 +749,7 @@ pfioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p) } default: - error = ERROR_INVALID_OP; + error = ENODEV; break; } @@ -757,7 +757,7 @@ done: splx(s); if (kb != NULL) { if (copyout(kb, ub->buffer, ub->size)) - error = ERROR_INVALID_PARAMETERS; + error = EIO; free(kb, M_DEVBUF); } return error; diff --git a/sys/net/pfvar.h b/sys/net/pfvar.h index 1ca7d44375d..c8b1525e8ce 100644 --- a/sys/net/pfvar.h +++ b/sys/net/pfvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pfvar.h,v 1.5 2001/06/24 23:44:00 art Exp $ */ +/* $OpenBSD: pfvar.h,v 1.6 2001/06/25 00:02:54 dhartmei Exp $ */ /* * Copyright (c) 2001, Daniel Hartmeier @@ -155,20 +155,6 @@ struct pfioc { #define DIOCSETSTATUSIF _IOWR('D', 11, struct pfioc) #define DIOCGETSTATUS _IOWR('D', 12, struct pfioc) -/* - * ioctl errors - */ - -enum error_msg { - NO_ERROR=0, - ERROR_INVALID_OP=100, - ERROR_ALREADY_RUNNING, - ERROR_NOT_RUNNING, - ERROR_INVALID_PARAMETERS, - ERROR_MALLOC, - MAX_ERROR_NUM -}; - #ifdef _KERNEL |