summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2004-02-19 13:54:59 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2004-02-19 13:54:59 +0000
commitab07350c16c79d16babb36da629198c73a1497b5 (patch)
tree41595ba2bafa7881347f58e3f922b82c7e80a280 /usr.sbin
parent66c12e8fef994277c60a99cb9e108d32aea1310b (diff)
Make the code more portable. Add some missing header files and make the use
of the queue(3) makros more portable. OK henning@ some time ago.
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/bgpd/bgpd.c7
-rw-r--r--usr.sbin/bgpd/buffer.c3
-rw-r--r--usr.sbin/bgpd/mrt.c8
-rw-r--r--usr.sbin/bgpd/parse.y3
-rw-r--r--usr.sbin/bgpd/rde.c13
-rw-r--r--usr.sbin/bgpd/rde_attr.c8
-rw-r--r--usr.sbin/bgpd/rde_rib.c16
7 files changed, 25 insertions, 33 deletions
diff --git a/usr.sbin/bgpd/bgpd.c b/usr.sbin/bgpd/bgpd.c
index 2beedd33250..fd7c1cb0083 100644
--- a/usr.sbin/bgpd/bgpd.c
+++ b/usr.sbin/bgpd/bgpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bgpd.c,v 1.79 2004/02/09 23:16:46 henning Exp $ */
+/* $OpenBSD: bgpd.c,v 1.80 2004/02/19 13:54:58 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -378,15 +378,14 @@ reconfigure(char *conffile, struct bgpd_config *conf, struct mrt_head *mrt_l,
&p->conf, sizeof(struct peer_config)) == -1)
return (-1);
}
- for (n = TAILQ_FIRST(&net_l); n != TAILQ_END(&net_l);
- n = TAILQ_FIRST(&net_l)) {
+ while ((n = TAILQ_FIRST(&net_l)) != NULL) {
if (imsg_compose(&ibuf_rde, IMSG_RECONF_NETWORK, 0,
&n->net, sizeof(struct network_config)) == -1)
return (-1);
TAILQ_REMOVE(&net_l, n, network_l);
free(n);
}
- for (r = TAILQ_FIRST(rules_l); r != NULL; r = TAILQ_FIRST(rules_l)) {
+ while ((r = TAILQ_FIRST(rules_l)) != NULL) {
if (imsg_compose(&ibuf_rde, IMSG_RECONF_FILTER, 0,
r, sizeof(struct filter_rule)) == -1)
return (-1);
diff --git a/usr.sbin/bgpd/buffer.c b/usr.sbin/bgpd/buffer.c
index 74f9f7915c3..b10618fd437 100644
--- a/usr.sbin/bgpd/buffer.c
+++ b/usr.sbin/bgpd/buffer.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: buffer.c,v 1.16 2004/02/17 22:41:40 henning Exp $ */
+/* $OpenBSD: buffer.c,v 1.17 2004/02/19 13:54:58 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -23,6 +23,7 @@
#include <stdlib.h>
#include <err.h>
#include <errno.h>
+#include <limits.h>
#include <string.h>
#include <unistd.h>
diff --git a/usr.sbin/bgpd/mrt.c b/usr.sbin/bgpd/mrt.c
index 82b3b17ca52..bc2cb13a4d4 100644
--- a/usr.sbin/bgpd/mrt.c
+++ b/usr.sbin/bgpd/mrt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mrt.c,v 1.25 2004/02/02 21:29:50 henning Exp $ */
+/* $OpenBSD: mrt.c,v 1.26 2004/02/19 13:54:58 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org>
@@ -565,7 +565,7 @@ mrt_select(struct mrt_head *mc, struct pollfd *pfd, struct mrt **mrt,
int t;
now = time(NULL);
- for (m = LIST_FIRST(mc); m != LIST_END(mc); m = xm) {
+ for (m = LIST_FIRST(mc); m != NULL; m = xm) {
xm = LIST_NEXT(m, list);
if (m->state == MRT_STATE_TOREMOVE) {
imsg_compose(m->ibuf, IMSG_MRT_END, 0,
@@ -750,8 +750,8 @@ mrt_mergeconfig(struct mrt_head *xconf, struct mrt_head *nconf)
xm->state = MRT_STATE_TOREMOVE;
/* free config */
- for (m = LIST_FIRST(nconf); m != LIST_END(nconf); m = xm) {
- xm = LIST_NEXT(m, list);
+ while ((m = LIST_FIRST(nconf)) != NULL) {
+ LIST_REMOVE(m, list);
free(m);
}
diff --git a/usr.sbin/bgpd/parse.y b/usr.sbin/bgpd/parse.y
index d2b5c67e9ce..cecddb5258a 100644
--- a/usr.sbin/bgpd/parse.y
+++ b/usr.sbin/bgpd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.56 2004/02/10 23:10:23 henning Exp $ */
+/* $OpenBSD: parse.y,v 1.57 2004/02/19 13:54:58 claudio Exp $ */
/*
* Copyright (c) 2002, 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -28,6 +28,7 @@
#include <ctype.h>
#include <err.h>
#include <errno.h>
+#include <limits.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
diff --git a/usr.sbin/bgpd/rde.c b/usr.sbin/bgpd/rde.c
index bc02e797c0d..6f0636d4535 100644
--- a/usr.sbin/bgpd/rde.c
+++ b/usr.sbin/bgpd/rde.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde.c,v 1.81 2004/02/18 23:18:16 claudio Exp $ */
+/* $OpenBSD: rde.c,v 1.82 2004/02/19 13:54:58 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -19,8 +19,10 @@
#include <sys/types.h>
#include <errno.h>
+#include <limits.h>
#include <pwd.h>
#include <poll.h>
+#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -281,7 +283,7 @@ rde_dispatch_imsg_parent(struct imsgbuf *ibuf)
if (nconf == NULL)
fatalx("got IMSG_RECONF_DONE but no config");
for (p = LIST_FIRST(&peerlist);
- p != LIST_END(&peerlist); p = np) {
+ p != NULL; p = np) {
np = LIST_NEXT(p, peer_l);
switch (p->conf.reconf_action) {
case RECONF_NONE:
@@ -840,9 +842,7 @@ peer_down(u_int32_t id)
up_down(peer);
/* walk through per peer RIB list and remove all prefixes. */
- for (asp = LIST_FIRST(&peer->path_h);
- asp != LIST_END(&peer->path_h);
- asp = nasp) {
+ for (asp = LIST_FIRST(&peer->path_h); asp != NULL; asp = nasp) {
nasp = LIST_NEXT(asp, peer_l);
path_remove(asp);
}
@@ -868,8 +868,7 @@ network_init(struct network_head *net_l)
snprintf(peerself.conf.descr, sizeof(peerself.conf.descr),
"LOCAL AS %hu", conf->as);
- for (n = TAILQ_FIRST(net_l); n != TAILQ_END(net_l);
- n = TAILQ_FIRST(net_l)) {
+ while ((n = TAILQ_FIRST(net_l)) != NULL) {
TAILQ_REMOVE(net_l, n, network_l);
network_add(&n->net);
free(n);
diff --git a/usr.sbin/bgpd/rde_attr.c b/usr.sbin/bgpd/rde_attr.c
index b21349b2732..e4185f45923 100644
--- a/usr.sbin/bgpd/rde_attr.c
+++ b/usr.sbin/bgpd/rde_attr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde_attr.c,v 1.10 2004/02/19 10:55:41 claudio Exp $ */
+/* $OpenBSD: rde_attr.c,v 1.11 2004/02/19 13:54:58 claudio Exp $ */
/*
* Copyright (c) 2004 Claudio Jeker <claudio@openbsd.org>
@@ -339,7 +339,7 @@ attr_compare(struct attr_flags *a, struct attr_flags *b)
return (-1);
for (oa = TAILQ_FIRST(&a->others), ob = TAILQ_FIRST(&b->others);
- oa != TAILQ_END(&a->others) && ob != TAILQ_END(&a->others);
+ oa != NULL && ob != NULL;
oa = TAILQ_NEXT(oa, attr_l), ob = TAILQ_NEXT(ob, attr_l)) {
if (oa->type > ob->type)
return (1);
@@ -355,9 +355,9 @@ attr_compare(struct attr_flags *a, struct attr_flags *b)
if (r < 0)
return (-1);
}
- if (oa != TAILQ_END(&a->others))
+ if (oa != NULL)
return (1);
- if (ob != TAILQ_END(&a->others))
+ if (ob != NULL)
return (-1);
return (0);
}
diff --git a/usr.sbin/bgpd/rde_rib.c b/usr.sbin/bgpd/rde_rib.c
index c40e3db9535..3c2948dc2a6 100644
--- a/usr.sbin/bgpd/rde_rib.c
+++ b/usr.sbin/bgpd/rde_rib.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde_rib.c,v 1.33 2004/02/09 01:56:18 henning Exp $ */
+/* $OpenBSD: rde_rib.c,v 1.34 2004/02/19 13:54:58 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org>
@@ -176,9 +176,7 @@ path_remove(struct rde_aspath *asp)
RIB_STAT(path_remove);
- for (p = LIST_FIRST(&asp->prefix_h);
- p != LIST_END(&asp->prefix_h);
- p = np) {
+ for (p = LIST_FIRST(&asp->prefix_h); p != NULL; p = np) {
np = LIST_NEXT(p, path_l);
prefix_destroy(p);
}
@@ -488,9 +486,7 @@ void
prefix_destroy(struct prefix *p)
{
struct pt_entry *pte;
- struct rde_aspath *asp;
- asp = p->aspath;
pte = p->prefix;
prefix_unlink(p);
prefix_free(p);
@@ -509,13 +505,9 @@ prefix_network_clean(struct rde_peer *peer, time_t reloadtime)
struct prefix *p, *xp;
struct pt_entry *pte;
- for (asp = LIST_FIRST(&peer->path_h);
- asp != LIST_END(&peer->path_h);
- asp = xasp) {
+ for (asp = LIST_FIRST(&peer->path_h); asp != NULL; asp = xasp) {
xasp = LIST_NEXT(asp, peer_l);
- for (p = LIST_FIRST(&asp->prefix_h);
- p != LIST_END(&asp->prefix_h);
- p = xp) {
+ for (p = LIST_FIRST(&asp->prefix_h); p != NULL; p = xp) {
xp = LIST_NEXT(p, path_l);
if (reloadtime > p->lastchange) {
pte = p->prefix;