summaryrefslogtreecommitdiff
path: root/usr.sbin/bgpd
diff options
context:
space:
mode:
authorHenning Brauer <henning@cvs.openbsd.org>2003-12-20 21:14:56 +0000
committerHenning Brauer <henning@cvs.openbsd.org>2003-12-20 21:14:56 +0000
commit16da6d2ee94b057ef5fbfc73701dcd76e24aa81c (patch)
treeb54d55bc0974b6faddd32da695e22afd5a042409 /usr.sbin/bgpd
parentb50914bcbf212c47516493cec8225da4c0cf3313 (diff)
let buf_add take void *data instead of u_char *data and save a zillion
evil casts
Diffstat (limited to 'usr.sbin/bgpd')
-rw-r--r--usr.sbin/bgpd/bgpd.h4
-rw-r--r--usr.sbin/bgpd/buffer.c4
-rw-r--r--usr.sbin/bgpd/imsg.c4
-rw-r--r--usr.sbin/bgpd/mrt.c14
-rw-r--r--usr.sbin/bgpd/session.c41
5 files changed, 30 insertions, 37 deletions
diff --git a/usr.sbin/bgpd/bgpd.h b/usr.sbin/bgpd/bgpd.h
index 9ae18e6875a..e3cfc242c69 100644
--- a/usr.sbin/bgpd/bgpd.h
+++ b/usr.sbin/bgpd/bgpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: bgpd.h,v 1.4 2003/12/20 20:25:20 henning Exp $ */
+/* $OpenBSD: bgpd.h,v 1.5 2003/12/20 21:14:55 henning Exp $ */
/*
* Copyright (c) 2003 Henning Brauer <henning@openbsd.org>
@@ -234,7 +234,7 @@ int session_main(struct bgpd_config *, int[2], int[2]);
/* buffer.c */
struct buf *buf_open(struct peer *, int, ssize_t);
-int buf_add(struct buf *, u_char *, ssize_t);
+int buf_add(struct buf *, void *, ssize_t);
u_char *buf_reserve(struct buf *, ssize_t);
int buf_close(struct buf *);
int buf_write(struct buf *);
diff --git a/usr.sbin/bgpd/buffer.c b/usr.sbin/bgpd/buffer.c
index f93c2660ed6..29c0d693c16 100644
--- a/usr.sbin/bgpd/buffer.c
+++ b/usr.sbin/bgpd/buffer.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: buffer.c,v 1.2 2003/12/20 14:33:09 henning Exp $ */
+/* $OpenBSD: buffer.c,v 1.3 2003/12/20 21:14:55 henning Exp $ */
/*
* Copyright (c) 2003 Henning Brauer <henning@openbsd.org>
@@ -52,7 +52,7 @@ buf_open(struct peer *peer, int sock, ssize_t len)
}
int
-buf_add(struct buf *buf, u_char *data, ssize_t len)
+buf_add(struct buf *buf, void *data, ssize_t len)
{
if (buf->wpos + len > buf->size)
return (-1);
diff --git a/usr.sbin/bgpd/imsg.c b/usr.sbin/bgpd/imsg.c
index 4a7bf9e13f4..ecd6995719c 100644
--- a/usr.sbin/bgpd/imsg.c
+++ b/usr.sbin/bgpd/imsg.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: imsg.c,v 1.3 2003/12/20 18:39:05 henning Exp $ */
+/* $OpenBSD: imsg.c,v 1.4 2003/12/20 21:14:55 henning Exp $ */
/*
* Copyright (c) 2003 Henning Brauer <henning@openbsd.org>
@@ -97,7 +97,7 @@ imsg_compose(int fd, int type, u_int32_t peerid, u_char *data,
wbuf = buf_open(NULL, fd, hdr.len);
if (wbuf == NULL)
fatal("buf_open error", 0);
- if (buf_add(wbuf, (u_char *)&hdr, sizeof(hdr)) == -1)
+ if (buf_add(wbuf, &hdr, sizeof(hdr)) == -1)
fatal("buf_add error", 0);
if (datalen)
if (buf_add(wbuf, data, datalen) == -1)
diff --git a/usr.sbin/bgpd/mrt.c b/usr.sbin/bgpd/mrt.c
index 0495c491d1d..ce0ab77cb56 100644
--- a/usr.sbin/bgpd/mrt.c
+++ b/usr.sbin/bgpd/mrt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mrt.c,v 1.3 2003/12/20 20:53:30 henning Exp $ */
+/* $OpenBSD: mrt.c,v 1.4 2003/12/20 21:14:55 henning Exp $ */
/*
* Copyright (c) 2003 Claudio Jeker <cjeker@diehard.n-r-g.com>
@@ -51,7 +51,7 @@ static int mrt_open(struct mrtdump_config *);
do { \
u_int16_t t; \
t = htons((s)); \
- if (buf_add((x), (u_char *)&t, sizeof(t)) == -1) \
+ if (buf_add((x), &t, sizeof(t)) == -1) \
fatal("buf_add error", 0); \
} while (0)
@@ -59,14 +59,14 @@ static int mrt_open(struct mrtdump_config *);
do { \
u_int32_t t; \
t = htonl((l)); \
- if (buf_add((x), (u_char *)&t, sizeof(t)) == -1) \
+ if (buf_add((x), &t, sizeof(t)) == -1) \
fatal("buf_add error", 0); \
} while (0)
#define DUMP_NLONG(x, l) \
do { \
u_int32_t t = (l); \
- if (buf_add((x), (u_char *)&t, sizeof(t)) == -1) \
+ if (buf_add((x), &t, sizeof(t)) == -1) \
fatal("buf_add error", 0); \
} while (0)
@@ -87,7 +87,7 @@ mrt_dump_bgp_msg(int fd, u_char *pkg, u_int16_t pkglen, int type,
buf = buf_open(NULL, fd, hdr.len);
if (buf == NULL)
fatal("mrt_dump_bgp_msg", errno);
- if (buf_add(buf, (u_char *)&hdr, sizeof(hdr)) == -1)
+ if (buf_add(buf, &hdr, sizeof(hdr)) == -1)
fatal("buf_add error", 0);
mrt_dump_header(buf, MSG_PROTOCOL_BGP4MP, BGP4MP_MESSAGE, len);
@@ -135,7 +135,7 @@ mrt_dump_entry(int fd, struct prefix *p, u_int16_t snum,
buf = buf_open(NULL, fd, hdr.len);
if (buf == NULL)
fatal("mrt_dump_entry", errno);
- if (buf_add(buf, (u_char *)&hdr, sizeof(hdr)) == -1)
+ if (buf_add(buf, &hdr, sizeof(hdr)) == -1)
fatal("buf_add error", 0);
mrt_dump_header(buf, MSG_TABLE_DUMP, AFI_IPv4, len);
@@ -200,7 +200,7 @@ mrt_dump_header(struct buf *buf, u_int16_t type, u_int16_t subtype,
mrt.subtype = ntohs(subtype);
mrt.length = htonl(len);
- if (buf_add(buf, (u_char *)&mrt, sizeof(mrt)) == -1)
+ if (buf_add(buf, &mrt, sizeof(mrt)) == -1)
fatal("buf_add error", 0);
}
diff --git a/usr.sbin/bgpd/session.c b/usr.sbin/bgpd/session.c
index f53fadf57d8..cd3640e3794 100644
--- a/usr.sbin/bgpd/session.c
+++ b/usr.sbin/bgpd/session.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: session.c,v 1.18 2003/12/20 20:24:57 henning Exp $ */
+/* $OpenBSD: session.c,v 1.19 2003/12/20 21:14:55 henning Exp $ */
/*
* Copyright (c) 2003 Henning Brauer <henning@openbsd.org>
@@ -764,17 +764,14 @@ session_open(struct peer *peer)
if ((buf = buf_open(peer, peer->sock, len)) == NULL)
bgp_fsm(peer, EVNT_CON_FATAL);
- errs += buf_add(buf, (u_char *)&msg.header.marker,
- sizeof(msg.header.marker));
- errs += buf_add(buf, (u_char *)&msg.header.len, sizeof(msg.header.len));
- errs += buf_add(buf, (u_char *)&msg.header.type,
- sizeof(msg.header.type));
- errs += buf_add(buf, (u_char *)&msg.version, sizeof(msg.version));
- errs += buf_add(buf, (u_char *)&msg.myas, sizeof(msg.myas));
- errs += buf_add(buf, (u_char *)&msg.holdtime, sizeof(msg.holdtime));
- errs += buf_add(buf, (u_char *)&msg.bgpid, sizeof(msg.bgpid));
- errs += buf_add(buf, (u_char *)&msg.optparamlen,
- sizeof(msg.optparamlen));
+ errs += buf_add(buf, &msg.header.marker, sizeof(msg.header.marker));
+ errs += buf_add(buf, &msg.header.len, sizeof(msg.header.len));
+ errs += buf_add(buf, &msg.header.type, sizeof(msg.header.type));
+ errs += buf_add(buf, &msg.version, sizeof(msg.version));
+ errs += buf_add(buf, &msg.myas, sizeof(msg.myas));
+ errs += buf_add(buf, &msg.holdtime, sizeof(msg.holdtime));
+ errs += buf_add(buf, &msg.bgpid, sizeof(msg.bgpid));
+ errs += buf_add(buf, &msg.optparamlen, sizeof(msg.optparamlen));
if (errs == 0) {
if (buf_close(buf) == -1) {
@@ -803,11 +800,9 @@ session_keepalive(struct peer *peer)
if ((buf = buf_open(peer, peer->sock, len)) == NULL)
bgp_fsm(peer, EVNT_CON_FATAL);
- errs += buf_add(buf, (u_char *)&msg.marker,
- sizeof(msg.marker));
- errs += buf_add(buf, (u_char *)&msg.len, sizeof(msg.len));
- errs += buf_add(buf, (u_char *)&msg.type,
- sizeof(msg.type));
+ errs += buf_add(buf, &msg.marker, sizeof(msg.marker));
+ errs += buf_add(buf, &msg.len, sizeof(msg.len));
+ errs += buf_add(buf, &msg.type, sizeof(msg.type));
if (errs > 0) {
buf_free(buf);
@@ -846,13 +841,11 @@ session_notification(struct peer *peer, u_int8_t errcode, u_int8_t subcode,
if ((buf = buf_open(peer, peer->sock, len)) == NULL)
bgp_fsm(peer, EVNT_CON_FATAL);
- errs += buf_add(buf, (u_char *)&msg.marker,
- sizeof(msg.marker));
- errs += buf_add(buf, (u_char *)&msg.len, sizeof(msg.len));
- errs += buf_add(buf, (u_char *)&msg.type,
- sizeof(msg.type));
- errs += buf_add(buf, (u_char *)&errcode, sizeof(errcode));
- errs += buf_add(buf, (u_char *)&subcode, sizeof(subcode));
+ errs += buf_add(buf, &msg.marker, sizeof(msg.marker));
+ errs += buf_add(buf, &msg.len, sizeof(msg.len));
+ errs += buf_add(buf, &msg.type, sizeof(msg.type));
+ errs += buf_add(buf, &errcode, sizeof(errcode));
+ errs += buf_add(buf, &subcode, sizeof(subcode));
if (datalen > 0)
errs += buf_add(buf, data, datalen);