diff options
author | smart <smart@cvs.openbsd.org> | 2001-06-25 05:00:59 +0000 |
---|---|---|
committer | smart <smart@cvs.openbsd.org> | 2001-06-25 05:00:59 +0000 |
commit | debe406ce16071698c78d84997754b036aa2f35f (patch) | |
tree | a93f7e709848eb518f4cadd8a1c3b050ae8b2868 | |
parent | 1e7f84dcacd742bb9a7c3bfddbc4c8e254c757d0 (diff) |
Replace magic numbers 1, 6, and 17 with IPPROTO_{ICMP,UDP,TCP}. deraadt@ ok.
-rw-r--r-- | sbin/pfctl/pfctl_parser.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/sbin/pfctl/pfctl_parser.c b/sbin/pfctl/pfctl_parser.c index 0d5fef8b4fb..df5bbcbcc1d 100644 --- a/sbin/pfctl/pfctl_parser.c +++ b/sbin/pfctl/pfctl_parser.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pfctl_parser.c,v 1.4 2001/06/24 23:24:15 provos Exp $ */ +/* $OpenBSD: pfctl_parser.c,v 1.5 2001/06/25 05:00:58 smart Exp $ */ /* * Copyright (c) 2001, Daniel Hartmeier @@ -296,7 +296,8 @@ print_rule(struct rule *r) } if (r->src.port_op) print_port(r->src.port_op, r->src.port[0], - r->src.port[1], r->proto == 6 ? "tcp" : "udp"); + r->src.port[1], + r->proto == IPPROTO_TCP ? "tcp" : "udp"); printf("to "); if (!r->dst.addr) @@ -313,7 +314,8 @@ print_rule(struct rule *r) } if (r->dst.port_op) print_port(r->dst.port_op, r->dst.port[0], - r->dst.port[1], r->proto == 6 ? "tcp" : "udp"); + r->dst.port[1], + r->proto == IPPROTO_TCP ? "tcp" : "udp"); } if (r->flags || r->flagset) { printf("flags "); @@ -406,7 +408,7 @@ rule_port(char *w, u_int8_t p) struct servent *s; if (isdigit(*w)) return (htons(atoi(w))); - s = getservbyname(w, p == 6 ? "tcp" : "udp"); + s = getservbyname(w, p == IPPROTO_TCP ? "tcp" : "udp"); if (s == NULL) return (0); return (s->s_port); @@ -519,7 +521,8 @@ parse_rule(int n, char *l, struct rule *r) } /* source port */ - if (((r->proto == 6) || (r->proto == 17)) && !strcmp(w, "port")) { + if (((r->proto == IPPROTO_TCP) || (r->proto == IPPROTO_UDP)) && + !strcmp(w, "port")) { w = next_word(&l); if (!strcmp(w, "=" )) r->src.port_op = 2; @@ -577,7 +580,8 @@ parse_rule(int n, char *l, struct rule *r) } /* destination port */ - if (((r->proto == 6) || (r->proto == 17)) && !strcmp(w, "port")) { + if (((r->proto == IPPROTO_TCP) || (r->proto == IPPROTO_UDP)) && + !strcmp(w, "port")) { w = next_word(&l); if (!strcmp(w, "=" )) r->dst.port_op = 2; @@ -617,7 +621,7 @@ parse_rule(int n, char *l, struct rule *r) /* flags */ if (!strcmp(w, "flags")) { - if (r->proto != 6) { + if (r->proto != IPPROTO_TCP) { fprintf(stderr, "error on line %i: flags only valid for proto tcp\n", n); return (0); } @@ -631,7 +635,7 @@ parse_rule(int n, char *l, struct rule *r) /* icmp type/code */ if (!strcmp(w, "icmp-type")) { - if (r->proto != 1) { + if (r->proto != IPPROTO_ICMP) { fprintf(stderr, "error on line %i: icmp-type only valid for proto icmp\n", n); return (0); } |