Deleted Added
sdiff udiff text old ( 126354 ) new ( 126355 )
full compact
1/* $OpenBSD: pfctl_altq.c,v 1.77 2003/08/22 21:50:34 david Exp $ */
2
3/*
4 * Copyright (c) 2002
5 * Sony Computer Science Laboratories Inc.
6 * Copyright (c) 2002, 2003 Henning Brauer <henning@openbsd.org>
7 *
8 * Permission to use, copy, modify, and distribute this software for any

--- 7 unchanged lines hidden (view full) ---

16 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 */
20
21#include <sys/types.h>
22#include <sys/ioctl.h>
23#include <sys/socket.h>
24#include <sys/limits.h>
25
26#include <net/if.h>
27#include <netinet/in.h>
28#include <net/pfvar.h>
29
30#include <err.h>
31#include <errno.h>
32#include <math.h>

--- 36 unchanged lines hidden (view full) ---

69static int is_gsc_under_sc(struct gen_sc *,
70 struct service_curve *);
71static void gsc_destroy(struct gen_sc *);
72static struct segment *gsc_getentry(struct gen_sc *, double);
73static int gsc_add_seg(struct gen_sc *, double, double, double,
74 double);
75static double sc_x2y(struct service_curve *, double);
76
77u_int32_t getifspeed(char *);
78u_long getifmtu(char *);
79int eval_queue_opts(struct pf_altq *, struct node_queue_opt *,
80 u_int32_t);
81u_int32_t eval_bwspec(struct node_queue_bw *, u_int32_t);
82void print_hfsc_sc(const char *, u_int, u_int, u_int,
83 const struct node_hfsc_sc *);
84
85static u_int32_t max_qid = 1;

--- 148 unchanged lines hidden (view full) ---

234eval_pfaltq(struct pfctl *pf, struct pf_altq *pa, struct node_queue_bw *bw,
235 struct node_queue_opt *opts)
236{
237 u_int rate, size, errors = 0;
238
239 if (bw->bw_absolute > 0)
240 pa->ifbandwidth = bw->bw_absolute;
241 else
242 if ((rate = getifspeed(pa->ifname)) == 0) {
243 fprintf(stderr, "cannot determine interface bandwidth "
244 "for %s, specify an absolute bandwidth\n",
245 pa->ifname);
246 errors++;
247 } else if ((pa->ifbandwidth = eval_bwspec(bw, rate)) == 0)
248 pa->ifbandwidth = rate;
249
250 errors += eval_queue_opts(pa, opts, pa->ifbandwidth);

--- 613 unchanged lines hidden (view full) ---

864 return (1);
865 } else
866 return (0);
867}
868
869/*
870 * admission control using generalized service curve
871 */
872#define INFINITY HUGE_VAL /* positive infinity defined in <math.h> */
873
874/* add a new service curve to a generalized service curve */
875static void
876gsc_add_sc(struct gen_sc *gsc, struct service_curve *sc)
877{
878 if (is_sc_null(sc))
879 return;
880 if (sc->d != 0)

--- 184 unchanged lines hidden (view full) ---

1065 if ((int)(rate * 100) % 100)
1066 snprintf(buf, RATESTR_MAX, "%.2f%cb", rate, unit[i]);
1067 else
1068 snprintf(buf, RATESTR_MAX, "%d%cb", (int)rate, unit[i]);
1069
1070 return (buf);
1071}
1072
1073u_int32_t
1074getifspeed(char *ifname)
1075{
1076 int s;
1077 struct ifreq ifr;
1078 struct if_data ifrdat;
1079
1080 if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
1081 err(1, "socket");

--- 4 unchanged lines hidden (view full) ---

1086 if (ioctl(s, SIOCGIFDATA, (caddr_t)&ifr) == -1)
1087 err(1, "SIOCGIFDATA");
1088 if (shutdown(s, SHUT_RDWR) == -1)
1089 err(1, "shutdown");
1090 if (close(s))
1091 err(1, "close");
1092 return ((u_int32_t)ifrdat.ifi_baudrate);
1093}
1094
1095u_long
1096getifmtu(char *ifname)
1097{
1098 int s;
1099 struct ifreq ifr;
1100
1101 if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0)

--- 109 unchanged lines hidden ---