summaryrefslogtreecommitdiff
path: root/usr.sbin/ospf6d
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/ospf6d')
-rw-r--r--usr.sbin/ospf6d/buffer.c66
-rw-r--r--usr.sbin/ospf6d/database.c16
-rw-r--r--usr.sbin/ospf6d/hello.c16
-rw-r--r--usr.sbin/ospf6d/imsg.c22
-rw-r--r--usr.sbin/ospf6d/imsg.h42
-rw-r--r--usr.sbin/ospf6d/lsack.c14
-rw-r--r--usr.sbin/ospf6d/lsreq.c12
-rw-r--r--usr.sbin/ospf6d/lsupdate.c34
-rw-r--r--usr.sbin/ospf6d/ospfe.c88
-rw-r--r--usr.sbin/ospf6d/ospfe.h6
-rw-r--r--usr.sbin/ospf6d/packet.c10
11 files changed, 163 insertions, 163 deletions
diff --git a/usr.sbin/ospf6d/buffer.c b/usr.sbin/ospf6d/buffer.c
index adba24d73d2..cea9406880a 100644
--- a/usr.sbin/ospf6d/buffer.c
+++ b/usr.sbin/ospf6d/buffer.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: buffer.c,v 1.5 2009/09/15 10:54:59 jacekm Exp $ */
+/* $OpenBSD: buffer.c,v 1.6 2010/05/26 13:56:08 nicm Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -28,16 +28,16 @@
#include "imsg.h"
-int buf_realloc(struct buf *, size_t);
-void buf_enqueue(struct msgbuf *, struct buf *);
-void buf_dequeue(struct msgbuf *, struct buf *);
+int ibuf_realloc(struct ibuf *, size_t);
+void ibuf_enqueue(struct msgbuf *, struct ibuf *);
+void ibuf_dequeue(struct msgbuf *, struct ibuf *);
-struct buf *
-buf_open(size_t len)
+struct ibuf *
+ibuf_open(size_t len)
{
- struct buf *buf;
+ struct ibuf *buf;
- if ((buf = calloc(1, sizeof(struct buf))) == NULL)
+ if ((buf = calloc(1, sizeof(struct ibuf))) == NULL)
return (NULL);
if ((buf->buf = malloc(len)) == NULL) {
free(buf);
@@ -49,15 +49,15 @@ buf_open(size_t len)
return (buf);
}
-struct buf *
-buf_dynamic(size_t len, size_t max)
+struct ibuf *
+ibuf_dynamic(size_t len, size_t max)
{
- struct buf *buf;
+ struct ibuf *buf;
if (max < len)
return (NULL);
- if ((buf = buf_open(len)) == NULL)
+ if ((buf = ibuf_open(len)) == NULL)
return (NULL);
if (max > 0)
@@ -67,7 +67,7 @@ buf_dynamic(size_t len, size_t max)
}
int
-buf_realloc(struct buf *buf, size_t len)
+ibuf_realloc(struct ibuf *buf, size_t len)
{
u_char *b;
@@ -87,10 +87,10 @@ buf_realloc(struct buf *buf, size_t len)
}
int
-buf_add(struct buf *buf, const void *data, size_t len)
+ibuf_add(struct ibuf *buf, const void *data, size_t len)
{
if (buf->wpos + len > buf->size)
- if (buf_realloc(buf, len) == -1)
+ if (ibuf_realloc(buf, len) == -1)
return (-1);
memcpy(buf->buf + buf->wpos, data, len);
@@ -99,12 +99,12 @@ buf_add(struct buf *buf, const void *data, size_t len)
}
void *
-buf_reserve(struct buf *buf, size_t len)
+ibuf_reserve(struct ibuf *buf, size_t len)
{
void *b;
if (buf->wpos + len > buf->size)
- if (buf_realloc(buf, len) == -1)
+ if (ibuf_realloc(buf, len) == -1)
return (NULL);
b = buf->buf + buf->wpos;
@@ -113,7 +113,7 @@ buf_reserve(struct buf *buf, size_t len)
}
void *
-buf_seek(struct buf *buf, size_t pos, size_t len)
+ibuf_seek(struct ibuf *buf, size_t pos, size_t len)
{
/* only allowed to seek in already written parts */
if (pos + len > buf->wpos)
@@ -123,28 +123,28 @@ buf_seek(struct buf *buf, size_t pos, size_t len)
}
size_t
-buf_size(struct buf *buf)
+ibuf_size(struct ibuf *buf)
{
return (buf->wpos);
}
size_t
-buf_left(struct buf *buf)
+ibuf_left(struct ibuf *buf)
{
return (buf->max - buf->wpos);
}
void
-buf_close(struct msgbuf *msgbuf, struct buf *buf)
+ibuf_close(struct msgbuf *msgbuf, struct ibuf *buf)
{
- buf_enqueue(msgbuf, buf);
+ ibuf_enqueue(msgbuf, buf);
}
int
-buf_write(struct msgbuf *msgbuf)
+ibuf_write(struct msgbuf *msgbuf)
{
struct iovec iov[IOV_MAX];
- struct buf *buf;
+ struct ibuf *buf;
unsigned int i = 0;
ssize_t n;
@@ -176,7 +176,7 @@ buf_write(struct msgbuf *msgbuf)
}
void
-buf_free(struct buf *buf)
+ibuf_free(struct ibuf *buf)
{
free(buf->buf);
free(buf);
@@ -193,14 +193,14 @@ msgbuf_init(struct msgbuf *msgbuf)
void
msgbuf_drain(struct msgbuf *msgbuf, size_t n)
{
- struct buf *buf, *next;
+ struct ibuf *buf, *next;
for (buf = TAILQ_FIRST(&msgbuf->bufs); buf != NULL && n > 0;
buf = next) {
next = TAILQ_NEXT(buf, entry);
if (buf->rpos + n >= buf->wpos) {
n -= buf->wpos - buf->rpos;
- buf_dequeue(msgbuf, buf);
+ ibuf_dequeue(msgbuf, buf);
} else {
buf->rpos += n;
n = 0;
@@ -211,17 +211,17 @@ msgbuf_drain(struct msgbuf *msgbuf, size_t n)
void
msgbuf_clear(struct msgbuf *msgbuf)
{
- struct buf *buf;
+ struct ibuf *buf;
while ((buf = TAILQ_FIRST(&msgbuf->bufs)) != NULL)
- buf_dequeue(msgbuf, buf);
+ ibuf_dequeue(msgbuf, buf);
}
int
msgbuf_write(struct msgbuf *msgbuf)
{
struct iovec iov[IOV_MAX];
- struct buf *buf;
+ struct ibuf *buf;
unsigned int i = 0;
ssize_t n;
struct msghdr msg;
@@ -284,14 +284,14 @@ msgbuf_write(struct msgbuf *msgbuf)
}
void
-buf_enqueue(struct msgbuf *msgbuf, struct buf *buf)
+ibuf_enqueue(struct msgbuf *msgbuf, struct ibuf *buf)
{
TAILQ_INSERT_TAIL(&msgbuf->bufs, buf, entry);
msgbuf->queued++;
}
void
-buf_dequeue(struct msgbuf *msgbuf, struct buf *buf)
+ibuf_dequeue(struct msgbuf *msgbuf, struct ibuf *buf)
{
TAILQ_REMOVE(&msgbuf->bufs, buf, entry);
@@ -299,5 +299,5 @@ buf_dequeue(struct msgbuf *msgbuf, struct buf *buf)
close(buf->fd);
msgbuf->queued--;
- buf_free(buf);
+ ibuf_free(buf);
}
diff --git a/usr.sbin/ospf6d/database.c b/usr.sbin/ospf6d/database.c
index 20c818eb55f..5590cf91eb6 100644
--- a/usr.sbin/ospf6d/database.c
+++ b/usr.sbin/ospf6d/database.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: database.c,v 1.9 2008/12/28 20:08:31 claudio Exp $ */
+/* $OpenBSD: database.c,v 1.10 2010/05/26 13:56:08 nicm Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -43,11 +43,11 @@ send_db_description(struct nbr *nbr)
struct in6_addr dst;
struct db_dscrp_hdr dd_hdr;
struct lsa_entry *le, *nle;
- struct buf *buf;
+ struct ibuf *buf;
int ret = 0;
u_int8_t bits = 0;
- if ((buf = buf_open(nbr->iface->mtu - sizeof(struct ip))) == NULL)
+ if ((buf = ibuf_open(nbr->iface->mtu - sizeof(struct ip))) == NULL)
fatal("send_db_description");
/* OSPF header */
@@ -55,7 +55,7 @@ send_db_description(struct nbr *nbr)
goto fail;
/* reserve space for database description header */
- if (buf_reserve(buf, sizeof(dd_hdr)) == NULL)
+ if (ibuf_reserve(buf, sizeof(dd_hdr)) == NULL)
goto fail;
switch (nbr->state) {
@@ -94,7 +94,7 @@ send_db_description(struct nbr *nbr)
buf->wpos + sizeof(struct lsa_hdr) < buf->max -
MD5_DIGEST_LENGTH; le = nle) {
nbr->dd_end = nle = TAILQ_NEXT(le, entry);
- if (buf_add(buf, le->le_lsa, sizeof(struct lsa_hdr)))
+ if (ibuf_add(buf, le->le_lsa, sizeof(struct lsa_hdr)))
goto fail;
}
break;
@@ -141,7 +141,7 @@ send_db_description(struct nbr *nbr)
dd_hdr.bits = bits;
dd_hdr.dd_seq_num = htonl(nbr->dd_seq_num);
- memcpy(buf_seek(buf, sizeof(struct ospf_hdr), sizeof(dd_hdr)),
+ memcpy(ibuf_seek(buf, sizeof(struct ospf_hdr), sizeof(dd_hdr)),
&dd_hdr, sizeof(dd_hdr));
/* calculate checksum */
@@ -151,11 +151,11 @@ send_db_description(struct nbr *nbr)
/* transmit packet */
ret = send_packet(nbr->iface, buf->buf, buf->wpos, &dst);
done:
- buf_free(buf);
+ ibuf_free(buf);
return (ret);
fail:
log_warn("send_db_description");
- buf_free(buf);
+ ibuf_free(buf);
return (-1);
}
diff --git a/usr.sbin/ospf6d/hello.c b/usr.sbin/ospf6d/hello.c
index becf70ee21d..0b961719125 100644
--- a/usr.sbin/ospf6d/hello.c
+++ b/usr.sbin/ospf6d/hello.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hello.c,v 1.15 2010/02/01 10:22:06 jacekm Exp $ */
+/* $OpenBSD: hello.c,v 1.16 2010/05/26 13:56:08 nicm Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -41,7 +41,7 @@ send_hello(struct iface *iface)
struct in6_addr dst;
struct hello_hdr hello;
struct nbr *nbr;
- struct buf *buf;
+ struct ibuf *buf;
int ret;
u_int32_t opts;
@@ -62,8 +62,8 @@ send_hello(struct iface *iface)
fatalx("send_hello: unknown interface type");
}
- /* XXX READ_BUF_SIZE */
- if ((buf = buf_dynamic(PKG_DEF_SIZE, READ_BUF_SIZE)) == NULL)
+ /* XXX IBUF_READ_SIZE */
+ if ((buf = ibuf_dynamic(PKG_DEF_SIZE, IBUF_READ_SIZE)) == NULL)
fatal("send_hello");
/* OSPF header */
@@ -91,13 +91,13 @@ send_hello(struct iface *iface)
} else
hello.bd_rtr = 0;
- if (buf_add(buf, &hello, sizeof(hello)))
+ if (ibuf_add(buf, &hello, sizeof(hello)))
goto fail;
/* active neighbor(s) */
LIST_FOREACH(nbr, &iface->nbr_list, entry) {
if ((nbr->state >= NBR_STA_INIT) && (nbr != iface->self))
- if (buf_add(buf, &nbr->id, sizeof(nbr->id)))
+ if (ibuf_add(buf, &nbr->id, sizeof(nbr->id)))
goto fail;
}
@@ -107,11 +107,11 @@ send_hello(struct iface *iface)
ret = send_packet(iface, buf->buf, buf->wpos, &dst);
- buf_free(buf);
+ ibuf_free(buf);
return (ret);
fail:
log_warn("send_hello");
- buf_free(buf);
+ ibuf_free(buf);
return (-1);
}
diff --git a/usr.sbin/ospf6d/imsg.c b/usr.sbin/ospf6d/imsg.c
index c87867354b9..7bd1ee09c51 100644
--- a/usr.sbin/ospf6d/imsg.c
+++ b/usr.sbin/ospf6d/imsg.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: imsg.c,v 1.8 2010/04/07 18:09:39 nicm Exp $ */
+/* $OpenBSD: imsg.c,v 1.9 2010/05/26 13:56:08 nicm Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -135,7 +135,7 @@ int
imsg_compose(struct imsgbuf *ibuf, u_int32_t type, u_int32_t peerid,
pid_t pid, int fd, void *data, u_int16_t datalen)
{
- struct buf *wbuf;
+ struct ibuf *wbuf;
if ((wbuf = imsg_create(ibuf, type, peerid, pid, datalen)) == NULL)
return (-1);
@@ -154,7 +154,7 @@ int
imsg_composev(struct imsgbuf *ibuf, u_int32_t type, u_int32_t peerid,
pid_t pid, int fd, const struct iovec *iov, int iovcnt)
{
- struct buf *wbuf;
+ struct ibuf *wbuf;
int i, datalen = 0;
for (i = 0; i < iovcnt; i++)
@@ -175,11 +175,11 @@ imsg_composev(struct imsgbuf *ibuf, u_int32_t type, u_int32_t peerid,
}
/* ARGSUSED */
-struct buf *
+struct ibuf *
imsg_create(struct imsgbuf *ibuf, u_int32_t type, u_int32_t peerid,
pid_t pid, u_int16_t datalen)
{
- struct buf *wbuf;
+ struct ibuf *wbuf;
struct imsg_hdr hdr;
datalen += IMSG_HEADER_SIZE;
@@ -193,7 +193,7 @@ imsg_create(struct imsgbuf *ibuf, u_int32_t type, u_int32_t peerid,
hdr.peerid = peerid;
if ((hdr.pid = pid) == 0)
hdr.pid = ibuf->pid;
- if ((wbuf = buf_dynamic(datalen, MAX_IMSGSIZE)) == NULL) {
+ if ((wbuf = ibuf_dynamic(datalen, MAX_IMSGSIZE)) == NULL) {
return (NULL);
}
if (imsg_add(wbuf, &hdr, sizeof(hdr)) == -1)
@@ -203,18 +203,18 @@ imsg_create(struct imsgbuf *ibuf, u_int32_t type, u_int32_t peerid,
}
int
-imsg_add(struct buf *msg, void *data, u_int16_t datalen)
+imsg_add(struct ibuf *msg, void *data, u_int16_t datalen)
{
if (datalen)
- if (buf_add(msg, data, datalen) == -1) {
- buf_free(msg);
+ if (ibuf_add(msg, data, datalen) == -1) {
+ ibuf_free(msg);
return (-1);
}
return (datalen);
}
void
-imsg_close(struct imsgbuf *ibuf, struct buf *msg)
+imsg_close(struct imsgbuf *ibuf, struct ibuf *msg)
{
struct imsg_hdr *hdr;
@@ -226,7 +226,7 @@ imsg_close(struct imsgbuf *ibuf, struct buf *msg)
hdr->len = (u_int16_t)msg->wpos;
- buf_close(&ibuf->w, msg);
+ ibuf_close(&ibuf->w, msg);
}
void
diff --git a/usr.sbin/ospf6d/imsg.h b/usr.sbin/ospf6d/imsg.h
index 9fd3f2f4964..4e914c08e18 100644
--- a/usr.sbin/ospf6d/imsg.h
+++ b/usr.sbin/ospf6d/imsg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: imsg.h,v 1.5 2010/04/27 21:04:04 nicm Exp $ */
+/* $OpenBSD: imsg.h,v 1.6 2010/05/26 13:56:08 nicm Exp $ */
/*
* Copyright (c) 2006, 2007 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -18,12 +18,12 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#define READ_BUF_SIZE 65535
+#define IBUF_READ_SIZE 65535
#define IMSG_HEADER_SIZE sizeof(struct imsg_hdr)
#define MAX_IMSGSIZE 16384
-struct buf {
- TAILQ_ENTRY(buf) entry;
+struct ibuf {
+ TAILQ_ENTRY(ibuf) entry;
u_char *buf;
size_t size;
size_t max;
@@ -33,13 +33,13 @@ struct buf {
};
struct msgbuf {
- TAILQ_HEAD(, buf) bufs;
+ TAILQ_HEAD(, ibuf) bufs;
u_int32_t queued;
int fd;
};
-struct buf_read {
- u_char buf[READ_BUF_SIZE];
+struct ibuf_read {
+ u_char buf[IBUF_READ_SIZE];
u_char *rptr;
size_t wpos;
};
@@ -51,7 +51,7 @@ struct imsg_fd {
struct imsgbuf {
TAILQ_HEAD(, imsg_fd) fds;
- struct buf_read r;
+ struct ibuf_read r;
struct msgbuf w;
int fd;
pid_t pid;
@@ -75,16 +75,16 @@ struct imsg {
/* buffer.c */
-struct buf *buf_open(size_t);
-struct buf *buf_dynamic(size_t, size_t);
-int buf_add(struct buf *, const void *, size_t);
-void *buf_reserve(struct buf *, size_t);
-void *buf_seek(struct buf *, size_t, size_t);
-size_t buf_size(struct buf *);
-size_t buf_left(struct buf *);
-void buf_close(struct msgbuf *, struct buf *);
-int buf_write(struct msgbuf *);
-void buf_free(struct buf *);
+struct ibuf *ibuf_open(size_t);
+struct ibuf *ibuf_dynamic(size_t, size_t);
+int ibuf_add(struct ibuf *, const void *, size_t);
+void *ibuf_reserve(struct ibuf *, size_t);
+void *ibuf_seek(struct ibuf *, size_t, size_t);
+size_t ibuf_size(struct ibuf *);
+size_t ibuf_left(struct ibuf *);
+void ibuf_close(struct msgbuf *, struct ibuf *);
+int ibuf_write(struct msgbuf *);
+void ibuf_free(struct ibuf *);
void msgbuf_init(struct msgbuf *);
void msgbuf_clear(struct msgbuf *);
int msgbuf_write(struct msgbuf *);
@@ -98,10 +98,10 @@ int imsg_compose(struct imsgbuf *, u_int32_t, u_int32_t, pid_t,
int, void *, u_int16_t);
int imsg_composev(struct imsgbuf *, u_int32_t, u_int32_t, pid_t,
int, const struct iovec *, int);
-struct buf *imsg_create(struct imsgbuf *, u_int32_t, u_int32_t, pid_t,
+struct ibuf *imsg_create(struct imsgbuf *, u_int32_t, u_int32_t, pid_t,
u_int16_t);
-int imsg_add(struct buf *, void *, u_int16_t);
-void imsg_close(struct imsgbuf *, struct buf *);
+int imsg_add(struct ibuf *, void *, u_int16_t);
+void imsg_close(struct imsgbuf *, struct ibuf *);
void imsg_free(struct imsg *);
int imsg_flush(struct imsgbuf *);
void imsg_clear(struct imsgbuf *);
diff --git a/usr.sbin/ospf6d/lsack.c b/usr.sbin/ospf6d/lsack.c
index 0561c73ffc2..80dd887e35c 100644
--- a/usr.sbin/ospf6d/lsack.c
+++ b/usr.sbin/ospf6d/lsack.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lsack.c,v 1.4 2007/10/16 13:01:07 norby Exp $ */
+/* $OpenBSD: lsack.c,v 1.5 2010/05/26 13:56:08 nicm Exp $ */
/*
* Copyright (c) 2004, 2005, 2007 Esben Norby <norby@openbsd.org>
@@ -37,11 +37,11 @@ void start_ls_ack_tx_timer_now(struct iface *);
int
send_ls_ack(struct iface *iface, struct in6_addr addr, void *data, size_t len)
{
- struct buf *buf;
+ struct ibuf *buf;
int ret;
- /* XXX READ_BUF_SIZE */
- if ((buf = buf_dynamic(PKG_DEF_SIZE, READ_BUF_SIZE)) == NULL)
+ /* XXX IBUF_READ_SIZE */
+ if ((buf = ibuf_dynamic(PKG_DEF_SIZE, IBUF_READ_SIZE)) == NULL)
fatal("send_ls_ack");
/* OSPF header */
@@ -49,7 +49,7 @@ send_ls_ack(struct iface *iface, struct in6_addr addr, void *data, size_t len)
goto fail;
/* LS ack(s) */
- if (buf_add(buf, data, len))
+ if (ibuf_add(buf, data, len))
goto fail;
/* calculate checksum */
@@ -58,11 +58,11 @@ send_ls_ack(struct iface *iface, struct in6_addr addr, void *data, size_t len)
ret = send_packet(iface, buf->buf, buf->wpos, &addr);
- buf_free(buf);
+ ibuf_free(buf);
return (ret);
fail:
log_warn("send_ls_ack");
- buf_free(buf);
+ ibuf_free(buf);
return (-1);
}
diff --git a/usr.sbin/ospf6d/lsreq.c b/usr.sbin/ospf6d/lsreq.c
index d460579b09c..97295dac9b9 100644
--- a/usr.sbin/ospf6d/lsreq.c
+++ b/usr.sbin/ospf6d/lsreq.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lsreq.c,v 1.4 2009/06/06 09:02:46 eric Exp $ */
+/* $OpenBSD: lsreq.c,v 1.5 2010/05/26 13:56:08 nicm Exp $ */
/*
* Copyright (c) 2004, 2005, 2007 Esben Norby <norby@openbsd.org>
@@ -36,10 +36,10 @@ send_ls_req(struct nbr *nbr)
struct in6_addr dst;
struct ls_req_hdr ls_req_hdr;
struct lsa_entry *le, *nle;
- struct buf *buf;
+ struct ibuf *buf;
int ret;
- if ((buf = buf_open(nbr->iface->mtu - sizeof(struct ip))) == NULL)
+ if ((buf = ibuf_open(nbr->iface->mtu - sizeof(struct ip))) == NULL)
fatal("send_ls_req");
switch (nbr->iface->type) {
@@ -69,7 +69,7 @@ send_ls_req(struct nbr *nbr)
ls_req_hdr.type = le->le_lsa->type;
ls_req_hdr.ls_id = le->le_lsa->ls_id;
ls_req_hdr.adv_rtr = le->le_lsa->adv_rtr;
- if (buf_add(buf, &ls_req_hdr, sizeof(ls_req_hdr)))
+ if (ibuf_add(buf, &ls_req_hdr, sizeof(ls_req_hdr)))
goto fail;
}
@@ -79,11 +79,11 @@ send_ls_req(struct nbr *nbr)
ret = send_packet(nbr->iface, buf->buf, buf->wpos, &dst);
- buf_free(buf);
+ ibuf_free(buf);
return (ret);
fail:
log_warn("send_ls_req");
- buf_free(buf);
+ ibuf_free(buf);
return (-1);
}
diff --git a/usr.sbin/ospf6d/lsupdate.c b/usr.sbin/ospf6d/lsupdate.c
index c4dbb6b05b6..558b684a2ea 100644
--- a/usr.sbin/ospf6d/lsupdate.c
+++ b/usr.sbin/ospf6d/lsupdate.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lsupdate.c,v 1.4 2009/06/06 09:02:46 eric Exp $ */
+/* $OpenBSD: lsupdate.c,v 1.5 2010/05/26 13:56:08 nicm Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -35,9 +35,9 @@
extern struct ospfd_conf *oeconf;
extern struct imsgev *iev_rde;
-struct buf *prepare_ls_update(struct iface *);
-int add_ls_update(struct buf *, struct iface *, void *, int, u_int16_t);
-int send_ls_update(struct buf *, struct iface *, struct in6_addr, u_int32_t);
+struct ibuf *prepare_ls_update(struct iface *);
+int add_ls_update(struct ibuf *, struct iface *, void *, int, u_int16_t);
+int send_ls_update(struct ibuf *, struct iface *, struct in6_addr, u_int32_t);
void ls_retrans_list_insert(struct nbr *, struct lsa_entry *);
void ls_retrans_list_remove(struct nbr *, struct lsa_entry *);
@@ -146,12 +146,12 @@ lsa_flood(struct iface *iface, struct nbr *originator, struct lsa_hdr *lsa_hdr,
return (dont_ack == 2);
}
-struct buf *
+struct ibuf *
prepare_ls_update(struct iface *iface)
{
- struct buf *buf;
+ struct ibuf *buf;
- if ((buf = buf_open(iface->mtu - sizeof(struct ip))) == NULL)
+ if ((buf = ibuf_open(iface->mtu - sizeof(struct ip))) == NULL)
fatal("prepare_ls_update");
/* OSPF header */
@@ -159,18 +159,18 @@ prepare_ls_update(struct iface *iface)
goto fail;
/* reserve space for number of lsa field */
- if (buf_reserve(buf, sizeof(u_int32_t)) == NULL)
+ if (ibuf_reserve(buf, sizeof(u_int32_t)) == NULL)
goto fail;
return (buf);
fail:
log_warn("prepare_ls_update");
- buf_free(buf);
+ ibuf_free(buf);
return (NULL);
}
int
-add_ls_update(struct buf *buf, struct iface *iface, void *data, int len,
+add_ls_update(struct ibuf *buf, struct iface *iface, void *data, int len,
u_int16_t older)
{
size_t pos;
@@ -180,7 +180,7 @@ add_ls_update(struct buf *buf, struct iface *iface, void *data, int len,
return (0);
pos = buf->wpos;
- if (buf_add(buf, data, len)) {
+ if (ibuf_add(buf, data, len)) {
log_warn("add_ls_update");
return (0);
}
@@ -191,19 +191,19 @@ add_ls_update(struct buf *buf, struct iface *iface, void *data, int len,
if ((age += older + iface->transmit_delay) >= MAX_AGE)
age = MAX_AGE;
age = htons(age);
- memcpy(buf_seek(buf, pos, sizeof(age)), &age, sizeof(age));
+ memcpy(ibuf_seek(buf, pos, sizeof(age)), &age, sizeof(age));
return (1);
}
int
-send_ls_update(struct buf *buf, struct iface *iface, struct in6_addr addr,
+send_ls_update(struct ibuf *buf, struct iface *iface, struct in6_addr addr,
u_int32_t nlsa)
{
int ret;
nlsa = htonl(nlsa);
- memcpy(buf_seek(buf, sizeof(struct ospf_hdr), sizeof(nlsa)),
+ memcpy(ibuf_seek(buf, sizeof(struct ospf_hdr), sizeof(nlsa)),
&nlsa, sizeof(nlsa));
/* calculate checksum */
if (upd_ospf_hdr(buf, iface))
@@ -211,11 +211,11 @@ send_ls_update(struct buf *buf, struct iface *iface, struct in6_addr addr,
ret = send_packet(iface, buf->buf, buf->wpos, &addr);
- buf_free(buf);
+ ibuf_free(buf);
return (ret);
fail:
log_warn("send_ls_update");
- buf_free(buf);
+ ibuf_free(buf);
return (-1);
}
@@ -416,7 +416,7 @@ ls_retrans_timer(int fd, short event, void *bula)
struct in6_addr addr;
struct nbr *nbr = bula;
struct lsa_entry *le;
- struct buf *buf;
+ struct ibuf *buf;
time_t now;
int d;
u_int32_t nlsa = 0;
diff --git a/usr.sbin/ospf6d/ospfe.c b/usr.sbin/ospf6d/ospfe.c
index 3daf39e233a..b87de73540c 100644
--- a/usr.sbin/ospf6d/ospfe.c
+++ b/usr.sbin/ospf6d/ospfe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ospfe.c,v 1.28 2009/06/06 09:02:46 eric Exp $ */
+/* $OpenBSD: ospfe.c,v 1.29 2010/05/26 13:56:08 nicm Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -178,7 +178,7 @@ ospfe(struct ospfd_conf *xconf, int pipe_parent2ospfe[2], int pipe_ospfe2rde[2],
TAILQ_INIT(&ctl_conns);
control_listen();
- if ((pkt_ptr = calloc(1, READ_BUF_SIZE)) == NULL)
+ if ((pkt_ptr = calloc(1, IBUF_READ_SIZE)) == NULL)
fatal("ospfe");
/* start interfaces */
@@ -704,7 +704,7 @@ orig_rtr_lsa_area(struct area *area)
struct lsa_rtr lsa_rtr;
struct lsa_rtr_link rtr_link;
struct iface *iface;
- struct buf *buf;
+ struct ibuf *buf;
struct nbr *nbr, *self = NULL;
u_int32_t flags;
u_int16_t chksum;
@@ -712,16 +712,16 @@ orig_rtr_lsa_area(struct area *area)
log_debug("orig_rtr_lsa: area %s", inet_ntoa(area->id));
- /* XXX READ_BUF_SIZE */
- if ((buf = buf_dynamic(sizeof(lsa_hdr), READ_BUF_SIZE)) == NULL)
+ /* XXX IBUF_READ_SIZE */
+ if ((buf = ibuf_dynamic(sizeof(lsa_hdr), IBUF_READ_SIZE)) == NULL)
fatal("orig_rtr_lsa");
/* reserve space for LSA header and LSA Router header */
- if (buf_reserve(buf, sizeof(lsa_hdr)) == NULL)
- fatal("orig_rtr_lsa: buf_reserve failed");
+ if (ibuf_reserve(buf, sizeof(lsa_hdr)) == NULL)
+ fatal("orig_rtr_lsa: ibuf_reserve failed");
- if (buf_reserve(buf, sizeof(lsa_rtr)) == NULL)
- fatal("orig_rtr_lsa: buf_reserve failed");
+ if (ibuf_reserve(buf, sizeof(lsa_rtr)) == NULL)
+ fatal("orig_rtr_lsa: ibuf_reserve failed");
/* links */
LIST_FOREACH(iface, &area->iface_list, entry) {
@@ -744,7 +744,7 @@ orig_rtr_lsa_area(struct area *area)
rtr_link.iface_id = htonl(iface->ifindex);
rtr_link.nbr_iface_id = htonl(nbr->iface_id);
rtr_link.nbr_rtr_id = nbr->id.s_addr;
- if (buf_add(buf, &rtr_link, sizeof(rtr_link)))
+ if (ibuf_add(buf, &rtr_link, sizeof(rtr_link)))
fatalx("orig_rtr_lsa: buf_add failed");
}
continue;
@@ -769,7 +769,7 @@ orig_rtr_lsa_area(struct area *area)
rtr_link.iface_id = htonl(iface->ifindex);
rtr_link.nbr_iface_id = htonl(iface->dr->iface_id);
rtr_link.nbr_rtr_id = iface->dr->id.s_addr;
- if (buf_add(buf, &rtr_link,
+ if (ibuf_add(buf, &rtr_link,
sizeof(rtr_link)))
fatalx("orig_rtr_lsa: "
"buf_add failed");
@@ -795,7 +795,7 @@ orig_rtr_lsa_area(struct area *area)
else
rtr_link.metric = htons(iface->metric);
virtual = 1;
- if (buf_add(buf, &rtr_link, sizeof(rtr_link)))
+ if (ibuf_add(buf, &rtr_link, sizeof(rtr_link)))
fatalx("orig_rtr_lsa: buf_add failed");
log_debug("orig_rtr_lsa: virtual link, "
@@ -809,7 +809,7 @@ orig_rtr_lsa_area(struct area *area)
rtr_link.data = 0xffffffff;
rtr_link.type = LINK_TYPE_STUB_NET;
rtr_link.metric = htons(iface->metric);
- if (buf_add(buf, &rtr_link, sizeof(rtr_link)))
+ if (ibuf_add(buf, &rtr_link, sizeof(rtr_link)))
fatalx("orig_rtr_lsa: buf_add failed");
LIST_FOREACH(nbr, &iface->nbr_list, entry) {
@@ -829,7 +829,7 @@ orig_rtr_lsa_area(struct area *area)
else
rtr_link.metric =
htons(iface->metric);
- if (buf_add(buf, &rtr_link,
+ if (ibuf_add(buf, &rtr_link,
sizeof(rtr_link)))
fatalx("orig_rtr_lsa: "
"buf_add failed");
@@ -869,7 +869,7 @@ orig_rtr_lsa_area(struct area *area)
LSA_24_SETLO(lsa_rtr.opts, area_ospf_options(area));
LSA_24_SETHI(lsa_rtr.opts, flags);
lsa_rtr.opts = htonl(lsa_rtr.opts);
- memcpy(buf_seek(buf, sizeof(lsa_hdr), sizeof(lsa_rtr)),
+ memcpy(ibuf_seek(buf, sizeof(lsa_hdr), sizeof(lsa_rtr)),
&lsa_rtr, sizeof(lsa_rtr));
/* LSA header */
@@ -881,10 +881,10 @@ orig_rtr_lsa_area(struct area *area)
lsa_hdr.seq_num = htonl(INIT_SEQ_NUM);
lsa_hdr.len = htons(buf->wpos);
lsa_hdr.ls_chksum = 0; /* updated later */
- memcpy(buf_seek(buf, 0, sizeof(lsa_hdr)), &lsa_hdr, sizeof(lsa_hdr));
+ memcpy(ibuf_seek(buf, 0, sizeof(lsa_hdr)), &lsa_hdr, sizeof(lsa_hdr));
chksum = htons(iso_cksum(buf->buf, buf->wpos, LS_CKSUM_OFFSET));
- memcpy(buf_seek(buf, LS_CKSUM_OFFSET, sizeof(chksum)),
+ memcpy(ibuf_seek(buf, LS_CKSUM_OFFSET, sizeof(chksum)),
&chksum, sizeof(chksum));
if (self)
@@ -894,7 +894,7 @@ orig_rtr_lsa_area(struct area *area)
log_warnx("orig_rtr_lsa: empty area %s",
inet_ntoa(area->id));
- buf_free(buf);
+ ibuf_free(buf);
}
void
@@ -902,32 +902,32 @@ orig_net_lsa(struct iface *iface)
{
struct lsa_hdr lsa_hdr;
struct nbr *nbr;
- struct buf *buf;
+ struct ibuf *buf;
struct lsa_net lsa_net;
int num_rtr = 0;
u_int16_t chksum;
- /* XXX READ_BUF_SIZE */
- if ((buf = buf_dynamic(sizeof(lsa_hdr), READ_BUF_SIZE)) == NULL)
+ /* XXX IBUF_READ_SIZE */
+ if ((buf = ibuf_dynamic(sizeof(lsa_hdr), IBUF_READ_SIZE)) == NULL)
fatal("orig_net_lsa");
/* reserve space for LSA header and options field */
- if (buf_reserve(buf, sizeof(lsa_hdr) + sizeof(lsa_net)) == NULL)
- fatal("orig_net_lsa: buf_reserve failed");
+ if (ibuf_reserve(buf, sizeof(lsa_hdr) + sizeof(lsa_net)) == NULL)
+ fatal("orig_net_lsa: ibuf_reserve failed");
lsa_net.opts = 0;
/* fully adjacent neighbors + self */
LIST_FOREACH(nbr, &iface->nbr_list, entry)
if (nbr->state & NBR_STA_FULL) {
- if (buf_add(buf, &nbr->id, sizeof(nbr->id)))
- fatal("orig_net_lsa: buf_add failed");
+ if (ibuf_add(buf, &nbr->id, sizeof(nbr->id)))
+ fatal("orig_net_lsa: ibuf_add failed");
lsa_net.opts |= nbr->options;
num_rtr++;
}
if (num_rtr == 1) {
/* non transit net therefor no need to generate a net lsa */
- buf_free(buf);
+ ibuf_free(buf);
return;
}
@@ -944,20 +944,20 @@ orig_net_lsa(struct iface *iface)
lsa_hdr.seq_num = htonl(INIT_SEQ_NUM);
lsa_hdr.len = htons(buf->wpos);
lsa_hdr.ls_chksum = 0; /* updated later */
- memcpy(buf_seek(buf, 0, sizeof(lsa_hdr)), &lsa_hdr, sizeof(lsa_hdr));
+ memcpy(ibuf_seek(buf, 0, sizeof(lsa_hdr)), &lsa_hdr, sizeof(lsa_hdr));
lsa_net.opts &= lsa_net.opts & htonl(LSA_24_MASK);
- memcpy(buf_seek(buf, sizeof(lsa_hdr), sizeof(lsa_net)), &lsa_net,
+ memcpy(ibuf_seek(buf, sizeof(lsa_hdr), sizeof(lsa_net)), &lsa_net,
sizeof(lsa_net));
chksum = htons(iso_cksum(buf->buf, buf->wpos, LS_CKSUM_OFFSET));
- memcpy(buf_seek(buf, LS_CKSUM_OFFSET, sizeof(chksum)),
+ memcpy(ibuf_seek(buf, LS_CKSUM_OFFSET, sizeof(chksum)),
&chksum, sizeof(chksum));
imsg_compose_event(iev_rde, IMSG_LS_UPD, iface->self->peerid, 0,
-1, buf->buf, buf->wpos);
- buf_free(buf);
+ ibuf_free(buf);
}
void
@@ -966,7 +966,7 @@ orig_link_lsa(struct iface *iface)
struct lsa_hdr lsa_hdr;
struct lsa_link lsa_link;
struct lsa_prefix lsa_prefix;
- struct buf *buf;
+ struct ibuf *buf;
struct iface_addr *ia;
struct in6_addr prefix;
unsigned int num_prefix = 0;
@@ -992,14 +992,14 @@ orig_link_lsa(struct iface *iface)
fatalx("orig_link_lsa: unknown interface type");
}
- /* XXX READ_BUF_SIZE */
- if ((buf = buf_dynamic(sizeof(lsa_hdr) + sizeof(lsa_link),
- READ_BUF_SIZE)) == NULL)
+ /* XXX IBUF_READ_SIZE */
+ if ((buf = ibuf_dynamic(sizeof(lsa_hdr) + sizeof(lsa_link),
+ IBUF_READ_SIZE)) == NULL)
fatal("orig_link_lsa");
/* reserve space for LSA header and LSA link header */
- if (buf_reserve(buf, sizeof(lsa_hdr) + sizeof(lsa_link)) == NULL)
- fatal("orig_link_lsa: buf_reserve failed");
+ if (ibuf_reserve(buf, sizeof(lsa_hdr) + sizeof(lsa_link)) == NULL)
+ fatal("orig_link_lsa: ibuf_reserve failed");
/* link-local address, and all prefixes configured on interface */
TAILQ_FOREACH(ia, &iface->ifa_list, entry) {
@@ -1015,11 +1015,11 @@ orig_link_lsa(struct iface *iface)
lsa_prefix.metric = 0;
inet6applymask(&prefix, &ia->addr, ia->prefixlen);
log_debug("orig_link_lsa: prefix %s", log_in6addr(&prefix));
- if (buf_add(buf, &lsa_prefix, sizeof(lsa_prefix)))
- fatal("orig_link_lsa: buf_add failed");
- if (buf_add(buf, &prefix.s6_addr[0],
+ if (ibuf_add(buf, &lsa_prefix, sizeof(lsa_prefix)))
+ fatal("orig_link_lsa: ibuf_add failed");
+ if (ibuf_add(buf, &prefix.s6_addr[0],
LSA_PREFIXSIZE(ia->prefixlen)))
- fatal("orig_link_lsa: buf_add failed");
+ fatal("orig_link_lsa: ibuf_add failed");
num_prefix++;
}
@@ -1029,7 +1029,7 @@ orig_link_lsa(struct iface *iface)
LSA_24_SETLO(lsa_link.opts, options);
lsa_link.opts = htonl(lsa_link.opts);
lsa_link.numprefix = htonl(num_prefix);
- memcpy(buf_seek(buf, sizeof(lsa_hdr), sizeof(lsa_link)),
+ memcpy(ibuf_seek(buf, sizeof(lsa_hdr), sizeof(lsa_link)),
&lsa_link, sizeof(lsa_link));
/* LSA header */
@@ -1041,16 +1041,16 @@ orig_link_lsa(struct iface *iface)
lsa_hdr.seq_num = htonl(INIT_SEQ_NUM);
lsa_hdr.len = htons(buf->wpos);
lsa_hdr.ls_chksum = 0; /* updated later */
- memcpy(buf_seek(buf, 0, sizeof(lsa_hdr)), &lsa_hdr, sizeof(lsa_hdr));
+ memcpy(ibuf_seek(buf, 0, sizeof(lsa_hdr)), &lsa_hdr, sizeof(lsa_hdr));
chksum = htons(iso_cksum(buf->buf, buf->wpos, LS_CKSUM_OFFSET));
- memcpy(buf_seek(buf, LS_CKSUM_OFFSET, sizeof(chksum)),
+ memcpy(ibuf_seek(buf, LS_CKSUM_OFFSET, sizeof(chksum)),
&chksum, sizeof(chksum));
imsg_compose_event(iev_rde, IMSG_LS_UPD, iface->self->peerid, 0,
-1, buf->buf, buf->wpos);
- buf_free(buf);
+ ibuf_free(buf);
}
u_int32_t
diff --git a/usr.sbin/ospf6d/ospfe.h b/usr.sbin/ospf6d/ospfe.h
index ef99a587f57..cce785d2657 100644
--- a/usr.sbin/ospf6d/ospfe.h
+++ b/usr.sbin/ospf6d/ospfe.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ospfe.h,v 1.15 2009/03/29 16:24:38 stsp Exp $ */
+/* $OpenBSD: ospfe.h,v 1.16 2010/05/26 13:56:08 nicm Exp $ */
/*
* Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org>
@@ -225,8 +225,8 @@ struct ctl_nbr *nbr_to_ctl(struct nbr *);
struct lsa_hdr *lsa_hdr_new(void);
/* packet.c */
-int gen_ospf_hdr(struct buf *, struct iface *, u_int8_t);
-int upd_ospf_hdr(struct buf *, struct iface *);
+int gen_ospf_hdr(struct ibuf *, struct iface *, u_int8_t);
+int upd_ospf_hdr(struct ibuf *, struct iface *);
int send_packet(struct iface *, void *, size_t, struct in6_addr *);
void recv_packet(int, short, void *);
diff --git a/usr.sbin/ospf6d/packet.c b/usr.sbin/ospf6d/packet.c
index 4bea8456228..ebb5b345254 100644
--- a/usr.sbin/ospf6d/packet.c
+++ b/usr.sbin/ospf6d/packet.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: packet.c,v 1.9 2008/03/24 16:11:04 deraadt Exp $ */
+/* $OpenBSD: packet.c,v 1.10 2010/05/26 13:56:08 nicm Exp $ */
/*
* Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org>
@@ -44,7 +44,7 @@ struct iface *find_iface(struct ospfd_conf *, unsigned int,
struct in6_addr *);
int
-gen_ospf_hdr(struct buf *buf, struct iface *iface, u_int8_t type)
+gen_ospf_hdr(struct ibuf *buf, struct iface *iface, u_int8_t type)
{
struct ospf_hdr ospf_hdr;
@@ -57,15 +57,15 @@ gen_ospf_hdr(struct buf *buf, struct iface *iface, u_int8_t type)
ospf_hdr.instance = DEFAULT_INSTANCE_ID;
ospf_hdr.zero = 0; /* must be zero */
- return (buf_add(buf, &ospf_hdr, sizeof(ospf_hdr)));
+ return (ibuf_add(buf, &ospf_hdr, sizeof(ospf_hdr)));
}
int
-upd_ospf_hdr(struct buf *buf, struct iface *iface)
+upd_ospf_hdr(struct ibuf *buf, struct iface *iface)
{
struct ospf_hdr *ospf_hdr;
- if ((ospf_hdr = buf_seek(buf, 0, sizeof(ospf_hdr))) == NULL)
+ if ((ospf_hdr = ibuf_seek(buf, 0, sizeof(ospf_hdr))) == NULL)
fatalx("upd_ospf_hdr: buf_seek failed");
/* update length */