summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenning Brauer <henning@cvs.openbsd.org>2003-04-13 19:36:01 +0000
committerHenning Brauer <henning@cvs.openbsd.org>2003-04-13 19:36:01 +0000
commit9b2f5e220fe45b7d5a58213aab77847d514b75f2 (patch)
tree3cd8c7e65758c16d9c1208964d78126fb6f49b04
parent6b80ee09587199877b31faca6357cc89cc16a2a4 (diff)
move the structs node_queue_bw and node_queue_opt to pfctl_parser.h.
let eval_pfqueue() and eval_pfaltq() take a pointer to a struct node_queue_bw instead of two distince bw_absolute and bw_percent parameters.
-rw-r--r--sbin/pfctl/parse.y27
-rw-r--r--sbin/pfctl/pfctl_altq.c27
-rw-r--r--sbin/pfctl/pfctl_parser.h20
3 files changed, 37 insertions, 37 deletions
diff --git a/sbin/pfctl/parse.y b/sbin/pfctl/parse.y
index 37a6f5b66c2..274b24cec61 100644
--- a/sbin/pfctl/parse.y
+++ b/sbin/pfctl/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.357 2003/04/13 17:01:12 henning Exp $ */
+/* $OpenBSD: parse.y,v 1.358 2003/04/13 19:36:00 henning Exp $ */
/*
* Copyright (c) 2001 Markus Friedl. All rights reserved.
@@ -140,20 +140,6 @@ struct node_queue {
struct node_queue *tail;
} *queues = NULL;
-struct node_queue_opt {
- int qtype;
- union {
- struct cbq_opts cbq_opts;
- struct priq_opts priq_opts;
- struct hfsc_opts hfsc_opts;
- } data;
-};
-
-struct node_queue_bw {
- u_int32_t bw_absolute;
- u_int16_t bw_percent;
-};
-
struct node_qassign {
char *qname;
char *pqname;
@@ -3106,6 +3092,7 @@ expand_altq(struct pf_altq *a, struct node_if *interfaces,
struct pf_altq pa, pb;
char qname[PF_QNAME_SIZE];
struct node_queue *n;
+ struct node_queue_bw bw;
int errs = 0;
if ((pf->loadopt & (PFCTL_FLAG_ALTQ | PFCTL_FLAG_ALL)) == 0) {
@@ -3124,8 +3111,7 @@ expand_altq(struct pf_altq *a, struct node_if *interfaces,
yyerror("altq on ! <interface> is not supported");
errs++;
} else {
- if (eval_pfaltq(pf, &pa, bwspec.bw_absolute,
- bwspec.bw_percent))
+ if (eval_pfaltq(pf, &pa, &bwspec))
errs++;
else
if (pfctl_add_altq(pf, &pa))
@@ -3168,7 +3154,9 @@ expand_altq(struct pf_altq *a, struct node_if *interfaces,
pb.pq_u.cbq_opts = pa.pq_u.cbq_opts;
if (pa.scheduler == ALTQT_HFSC)
pb.pq_u.hfsc_opts = pa.pq_u.hfsc_opts;
- if (eval_pfqueue(pf, &pb, pa.ifbandwidth, 0))
+ bw.bw_absolute = pa.ifbandwidth;
+ bw.bw_percent = 0;
+ if (eval_pfqueue(pf, &pb, &bw))
errs++;
else
if (pfctl_add_altq(pf, &pb))
@@ -3276,8 +3264,7 @@ expand_queue(struct pf_altq *a, struct node_if *interfaces,
sizeof(pa.parent)) >= sizeof(pa.parent))
errx(1, "expand_queue: strlcpy");
- if (eval_pfqueue(pf, &pa, bwspec.bw_absolute,
- bwspec.bw_percent))
+ if (eval_pfqueue(pf, &pa, &bwspec))
errs++;
else
if (pfctl_add_altq(pf, &pa))
diff --git a/sbin/pfctl/pfctl_altq.c b/sbin/pfctl/pfctl_altq.c
index 10e417e0447..cc7a885be8c 100644
--- a/sbin/pfctl/pfctl_altq.c
+++ b/sbin/pfctl/pfctl_altq.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pfctl_altq.c,v 1.58 2003/04/12 19:08:40 henning Exp $ */
+/* $OpenBSD: pfctl_altq.c,v 1.59 2003/04/13 19:36:00 henning Exp $ */
/*
* Copyright (C) 2002
@@ -232,13 +232,12 @@ print_queue(const struct pf_altq *a, unsigned level, u_int16_t bwpercent,
* eval_pfaltq computes the discipline parameters.
*/
int
-eval_pfaltq(struct pfctl *pf, struct pf_altq *pa, u_int32_t bw_absolute,
- u_int16_t bw_percent)
+eval_pfaltq(struct pfctl *pf, struct pf_altq *pa, struct node_queue_bw *bw)
{
u_int rate, size, errors = 0;
- if (bw_absolute > 0)
- pa->ifbandwidth = bw_absolute;
+ if (bw->bw_absolute > 0)
+ pa->ifbandwidth = bw->bw_absolute;
else
if ((rate = getifspeed(pa->ifname)) == 0) {
fprintf(stderr, "cannot determine interface bandwidth "
@@ -246,8 +245,8 @@ eval_pfaltq(struct pfctl *pf, struct pf_altq *pa, u_int32_t bw_absolute,
pa->ifname);
errors++;
} else
- if (bw_percent > 0)
- pa->ifbandwidth = rate / 100 * bw_percent;
+ if (bw->bw_percent > 0)
+ pa->ifbandwidth = rate / 100 * bw->bw_percent;
else
pa->ifbandwidth = rate;
@@ -302,8 +301,7 @@ check_commit_altq(int dev, int opts)
* eval_pfqueue computes the queue parameters.
*/
int
-eval_pfqueue(struct pfctl *pf, struct pf_altq *pa, u_int32_t bw_absolute,
- u_int16_t bw_percent)
+eval_pfqueue(struct pfctl *pf, struct pf_altq *pa, struct node_queue_bw *bw)
{
/* should be merged with expand_queue */
struct pf_altq *if_pa, *parent;
@@ -338,13 +336,14 @@ eval_pfqueue(struct pfctl *pf, struct pf_altq *pa, u_int32_t bw_absolute,
pa->qlimit = DEFAULT_QLIMIT;
if (pa->scheduler == ALTQT_CBQ || pa->scheduler == ALTQT_HFSC) {
- if (bw_absolute > 0)
- pa->bandwidth = bw_absolute;
- else if (bw_percent > 0 && parent != NULL)
- pa->bandwidth = parent->bandwidth / 100 * bw_percent;
+ if (bw->bw_absolute > 0)
+ pa->bandwidth = bw->bw_absolute;
+ else if (bw->bw_percent > 0 && parent != NULL)
+ pa->bandwidth = parent->bandwidth / 100 *
+ bw->bw_percent;
else {
fprintf(stderr, "bandwidth for %s invalid (%d / %d)\n",
- pa->qname, bw_absolute, bw_percent);
+ pa->qname, bw->bw_absolute, bw->bw_percent);
return (1);
}
diff --git a/sbin/pfctl/pfctl_parser.h b/sbin/pfctl/pfctl_parser.h
index c5748892dfa..13360d6a143 100644
--- a/sbin/pfctl/pfctl_parser.h
+++ b/sbin/pfctl/pfctl_parser.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: pfctl_parser.h,v 1.53 2003/04/05 23:56:32 henning Exp $ */
+/* $OpenBSD: pfctl_parser.h,v 1.54 2003/04/13 19:36:00 henning Exp $ */
/*
* Copyright (c) 2001 Daniel Hartmeier
@@ -93,6 +93,20 @@ struct node_host {
struct node_host *tail;
};
+struct node_queue_opt {
+ int qtype;
+ union {
+ struct cbq_opts cbq_opts;
+ struct priq_opts priq_opts;
+ struct hfsc_opts hfsc_opts;
+ } data;
+};
+
+struct node_queue_bw {
+ u_int32_t bw_absolute;
+ u_int16_t bw_percent;
+};
+
int pfctl_add_rule(struct pfctl *, struct pf_rule *);
int pfctl_add_altq(struct pfctl *, struct pf_altq *);
int pfctl_add_pool(struct pfctl *, struct pf_pool *, sa_family_t);
@@ -110,8 +124,8 @@ void print_pool(struct pf_pool *, u_int16_t, u_int16_t, sa_family_t, int);
void print_rule(struct pf_rule *, int);
void print_status(struct pf_status *);
-int eval_pfaltq(struct pfctl *, struct pf_altq *, u_int32_t, u_int16_t);
-int eval_pfqueue(struct pfctl *, struct pf_altq *, u_int32_t, u_int16_t);
+int eval_pfaltq(struct pfctl *, struct pf_altq *, struct node_queue_bw *);
+int eval_pfqueue(struct pfctl *, struct pf_altq *, struct node_queue_bw *);
void pfctl_begin_table(void);
void pfctl_append_addr(char *, int, int);