summaryrefslogtreecommitdiff
path: root/usr.sbin/ldpd
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2010-05-26 13:56:09 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2010-05-26 13:56:09 +0000
commit4b9cf3ab192c7e5b1ee8b915d25de6b18cbd1f7e (patch)
treec8f546660680faabd30571e97e67f49483698059 /usr.sbin/ldpd
parentf11125202098e763efa8b52b0e92bfac7a124175 (diff)
Rename some imsg bits to make namespace collisions less likely buf to
ibuf, buf_read to ibuf_read, READ_BUF_SIZE to IBUF_READ_SIZE. ok henning gilles claudio jacekm deraadt
Diffstat (limited to 'usr.sbin/ldpd')
-rw-r--r--usr.sbin/ldpd/address.c20
-rw-r--r--usr.sbin/ldpd/buffer.c66
-rw-r--r--usr.sbin/ldpd/hello.c14
-rw-r--r--usr.sbin/ldpd/imsg.c22
-rw-r--r--usr.sbin/ldpd/imsg.h42
-rw-r--r--usr.sbin/ldpd/init.c12
-rw-r--r--usr.sbin/ldpd/keepalive.c6
-rw-r--r--usr.sbin/ldpd/labelmapping.c50
-rw-r--r--usr.sbin/ldpd/ldpd.c6
-rw-r--r--usr.sbin/ldpd/ldpd.h4
-rw-r--r--usr.sbin/ldpd/ldpe.c4
-rw-r--r--usr.sbin/ldpd/ldpe.h10
-rw-r--r--usr.sbin/ldpd/neighbor.c4
-rw-r--r--usr.sbin/ldpd/notification.c16
-rw-r--r--usr.sbin/ldpd/packet.c20
15 files changed, 148 insertions, 148 deletions
diff --git a/usr.sbin/ldpd/address.c b/usr.sbin/ldpd/address.c
index 54d60c0f0d0..e0bf23d0e11 100644
--- a/usr.sbin/ldpd/address.c
+++ b/usr.sbin/ldpd/address.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: address.c,v 1.4 2010/02/25 17:40:46 claudio Exp $ */
+/* $OpenBSD: address.c,v 1.5 2010/05/26 13:56:07 nicm Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
@@ -39,12 +39,12 @@
extern struct ldpd_conf *leconf;
-void gen_address_list_tlv(struct buf *, struct iface *, u_int16_t);
+void gen_address_list_tlv(struct ibuf *, struct iface *, u_int16_t);
void
send_address(struct nbr *nbr, struct iface *iface)
{
- struct buf *buf;
+ struct ibuf *buf;
struct iface *niface;
u_int16_t size, iface_count = 0;
@@ -53,7 +53,7 @@ send_address(struct nbr *nbr, struct iface *iface)
log_debug("send_address: neighbor ID %s", inet_ntoa(nbr->id));
- if ((buf = buf_open(LDP_MAX_LEN)) == NULL)
+ if ((buf = ibuf_open(LDP_MAX_LEN)) == NULL)
fatal("send_address");
/* XXX: multiple address on the same iface? */
@@ -141,7 +141,7 @@ recv_address(struct nbr *nbr, char *buf, u_int16_t len)
}
void
-gen_address_list_tlv(struct buf *buf, struct iface *iface, u_int16_t size)
+gen_address_list_tlv(struct ibuf *buf, struct iface *iface, u_int16_t size)
{
struct address_list_tlv alt;
struct iface *niface;
@@ -155,19 +155,19 @@ gen_address_list_tlv(struct buf *buf, struct iface *iface, u_int16_t size)
/* XXX: just ipv4 for now */
alt.family = htons(ADDR_IPV4);
- buf_add(buf, &alt, sizeof(alt));
+ ibuf_add(buf, &alt, sizeof(alt));
if (iface == NULL)
LIST_FOREACH(niface, &leconf->iface_list, entry)
- buf_add(buf, &niface->addr, sizeof(niface->addr));
+ ibuf_add(buf, &niface->addr, sizeof(niface->addr));
else
- buf_add(buf, &iface->addr, sizeof(iface->addr));
+ ibuf_add(buf, &iface->addr, sizeof(iface->addr));
}
void
send_address_withdraw(struct nbr *nbr, struct iface *iface)
{
- struct buf *buf;
+ struct ibuf *buf;
u_int16_t size;
if (nbr->iface->passive)
@@ -175,7 +175,7 @@ send_address_withdraw(struct nbr *nbr, struct iface *iface)
log_debug("send_address_withdraw: neighbor ID %s", inet_ntoa(nbr->id));
- if ((buf = buf_open(LDP_MAX_LEN)) == NULL)
+ if ((buf = ibuf_open(LDP_MAX_LEN)) == NULL)
fatal("send_address_withdraw");
/* XXX: multiple address on the same iface? */
diff --git a/usr.sbin/ldpd/buffer.c b/usr.sbin/ldpd/buffer.c
index 603a53d60ff..256f37758cc 100644
--- a/usr.sbin/ldpd/buffer.c
+++ b/usr.sbin/ldpd/buffer.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: buffer.c,v 1.4 2009/09/15 10:54:59 jacekm Exp $ */
+/* $OpenBSD: buffer.c,v 1.5 2010/05/26 13:56:07 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/ldpd/hello.c b/usr.sbin/ldpd/hello.c
index 4712a9e782f..d6cb184727e 100644
--- a/usr.sbin/ldpd/hello.c
+++ b/usr.sbin/ldpd/hello.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hello.c,v 1.5 2010/05/19 15:28:51 claudio Exp $ */
+/* $OpenBSD: hello.c,v 1.6 2010/05/26 13:56:07 nicm Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
@@ -39,14 +39,14 @@
struct hello_prms_tlv *tlv_decode_hello_prms(char *, u_int16_t);
int tlv_decode_opt_hello_prms(char *, u_int16_t,
struct in_addr *, u_int32_t *);
-int gen_hello_prms_tlv(struct iface *, struct buf *,
+int gen_hello_prms_tlv(struct iface *, struct ibuf *,
u_int16_t);
int
send_hello(struct iface *iface)
{
struct sockaddr_in dst;
- struct buf *buf;
+ struct ibuf *buf;
u_int16_t size;
dst.sin_port = htons(LDP_PORT);
@@ -57,7 +57,7 @@ send_hello(struct iface *iface)
if (iface->passive)
return (0);
- if ((buf = buf_open(LDP_MAX_LEN)) == NULL)
+ if ((buf = ibuf_open(LDP_MAX_LEN)) == NULL)
fatal("send_hello");
size = LDP_HDR_SIZE + sizeof(struct ldp_msg) +
@@ -74,7 +74,7 @@ send_hello(struct iface *iface)
gen_hello_prms_tlv(iface, buf, size);
send_packet(iface, buf->buf, buf->wpos, &dst);
- buf_free(buf);
+ ibuf_free(buf);
return (0);
}
@@ -151,7 +151,7 @@ recv_hello(struct iface *iface, struct in_addr src, char *buf, u_int16_t len)
}
int
-gen_hello_prms_tlv(struct iface *iface, struct buf *buf, u_int16_t size)
+gen_hello_prms_tlv(struct iface *iface, struct ibuf *buf, u_int16_t size)
{
struct hello_prms_tlv parms;
@@ -165,7 +165,7 @@ gen_hello_prms_tlv(struct iface *iface, struct buf *buf, u_int16_t size)
parms.holdtime = htons(iface->holdtime);
parms.reserved = 0;
- return (buf_add(buf, &parms, sizeof(parms)));
+ return (ibuf_add(buf, &parms, sizeof(parms)));
}
struct hello_prms_tlv *
diff --git a/usr.sbin/ldpd/imsg.c b/usr.sbin/ldpd/imsg.c
index c87867354b9..798511b290a 100644
--- a/usr.sbin/ldpd/imsg.c
+++ b/usr.sbin/ldpd/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:07 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/ldpd/imsg.h b/usr.sbin/ldpd/imsg.h
index 9fd3f2f4964..43564710bb2 100644
--- a/usr.sbin/ldpd/imsg.h
+++ b/usr.sbin/ldpd/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:07 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/ldpd/init.c b/usr.sbin/ldpd/init.c
index b8f1601d9a1..31556a670e2 100644
--- a/usr.sbin/ldpd/init.c
+++ b/usr.sbin/ldpd/init.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: init.c,v 1.4 2010/02/25 17:40:46 claudio Exp $ */
+/* $OpenBSD: init.c,v 1.5 2010/05/26 13:56:07 nicm Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
@@ -37,12 +37,12 @@
#include "log.h"
#include "ldpe.h"
-int gen_init_prms_tlv(struct buf *, struct nbr *, u_int16_t);
+int gen_init_prms_tlv(struct ibuf *, struct nbr *, u_int16_t);
void
send_init(struct nbr *nbr)
{
- struct buf *buf;
+ struct ibuf *buf;
u_int16_t size;
if (nbr->iface->passive)
@@ -50,7 +50,7 @@ send_init(struct nbr *nbr)
log_debug("send_init: neighbor ID %s", inet_ntoa(nbr->id));
- if ((buf = buf_open(LDP_MAX_LEN)) == NULL)
+ if ((buf = ibuf_open(LDP_MAX_LEN)) == NULL)
fatal("send_init");
size = LDP_HDR_SIZE + sizeof(struct ldp_msg) + SESS_PRMS_SIZE;
@@ -105,7 +105,7 @@ recv_init(struct nbr *nbr, char *buf, u_int16_t len)
}
int
-gen_init_prms_tlv(struct buf *buf, struct nbr *nbr, u_int16_t size)
+gen_init_prms_tlv(struct ibuf *buf, struct nbr *nbr, u_int16_t size)
{
struct sess_prms_tlv parms;
@@ -124,5 +124,5 @@ gen_init_prms_tlv(struct buf *buf, struct nbr *nbr, u_int16_t size)
/* XXX: nbr lspace */
parms.lspace_id = 0;
- return (buf_add(buf, &parms, SESS_PRMS_SIZE));
+ return (ibuf_add(buf, &parms, SESS_PRMS_SIZE));
}
diff --git a/usr.sbin/ldpd/keepalive.c b/usr.sbin/ldpd/keepalive.c
index ccf3d997668..2e9152a1b4e 100644
--- a/usr.sbin/ldpd/keepalive.c
+++ b/usr.sbin/ldpd/keepalive.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: keepalive.c,v 1.5 2010/02/25 17:40:46 claudio Exp $ */
+/* $OpenBSD: keepalive.c,v 1.6 2010/05/26 13:56:07 nicm Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
@@ -40,13 +40,13 @@
void
send_keepalive(struct nbr *nbr)
{
- struct buf *buf;
+ struct ibuf *buf;
u_int16_t size;
if (nbr->iface->passive)
return;
- if ((buf = buf_open(LDP_MAX_LEN)) == NULL)
+ if ((buf = ibuf_open(LDP_MAX_LEN)) == NULL)
fatal("send_keepalive");
size = LDP_HDR_SIZE + sizeof(struct ldp_msg);
diff --git a/usr.sbin/ldpd/labelmapping.c b/usr.sbin/ldpd/labelmapping.c
index 966fec475dd..21f99f0a06d 100644
--- a/usr.sbin/ldpd/labelmapping.c
+++ b/usr.sbin/ldpd/labelmapping.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: labelmapping.c,v 1.10 2010/05/25 09:40:10 claudio Exp $ */
+/* $OpenBSD: labelmapping.c,v 1.11 2010/05/26 13:56:07 nicm Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
@@ -37,8 +37,8 @@
#include "log.h"
#include "ldpe.h"
-void gen_fec_tlv(struct buf *, u_int32_t, u_int8_t);
-void gen_label_tlv(struct buf *, u_int32_t);
+void gen_fec_tlv(struct ibuf *, u_int32_t, u_int8_t);
+void gen_label_tlv(struct ibuf *, u_int32_t);
u_int32_t tlv_decode_label(struct label_tlv *);
int tlv_decode_fec_elm(char *, u_int16_t, u_int8_t *, u_int32_t *,
@@ -48,7 +48,7 @@ int tlv_decode_fec_elm(char *, u_int16_t, u_int8_t *, u_int32_t *,
void
send_labelmapping(struct nbr *nbr)
{
- struct buf *buf;
+ struct ibuf *buf;
struct mapping_entry *me;
struct ldp_hdr *ldp_hdr;
u_int16_t tlv_size, size;
@@ -58,7 +58,7 @@ send_labelmapping(struct nbr *nbr)
log_debug("send_labelmapping: neighbor ID %s", inet_ntoa(nbr->id));
- if ((buf = buf_open(LDP_MAX_LEN)) == NULL)
+ if ((buf = ibuf_open(LDP_MAX_LEN)) == NULL)
fatal("send_labelmapping");
/* real size will be set up later */
@@ -78,7 +78,7 @@ send_labelmapping(struct nbr *nbr)
/* XXX: should we remove them first? */
nbr_mapping_list_clr(nbr, &nbr->mapping_list);
- ldp_hdr = buf_seek(buf, 0, sizeof(struct ldp_hdr));
+ ldp_hdr = ibuf_seek(buf, 0, sizeof(struct ldp_hdr));
ldp_hdr->length = htons(size);
evbuf_enqueue(&nbr->wbuf, buf);
@@ -161,7 +161,7 @@ recv_labelmapping(struct nbr *nbr, char *buf, u_int16_t len)
void
send_labelrequest(struct nbr *nbr)
{
- struct buf *buf;
+ struct ibuf *buf;
struct mapping_entry *me;
struct ldp_hdr *ldp_hdr;
u_int16_t tlv_size, size;
@@ -171,7 +171,7 @@ send_labelrequest(struct nbr *nbr)
log_debug("send_labelrequest: neighbor ID %s", inet_ntoa(nbr->id));
- if ((buf = buf_open(LDP_MAX_LEN)) == NULL)
+ if ((buf = ibuf_open(LDP_MAX_LEN)) == NULL)
fatal("send_labelrequest");
/* real size will be set up later */
@@ -190,7 +190,7 @@ send_labelrequest(struct nbr *nbr)
/* XXX: should we remove them first? */
nbr_mapping_list_clr(nbr, &nbr->request_list);
- ldp_hdr = buf_seek(buf, 0, sizeof(struct ldp_hdr));
+ ldp_hdr = ibuf_seek(buf, 0, sizeof(struct ldp_hdr));
ldp_hdr->length = htons(size);
evbuf_enqueue(&nbr->wbuf, buf);
@@ -260,7 +260,7 @@ recv_labelrequest(struct nbr *nbr, char *buf, u_int16_t len)
void
send_labelwithdraw(struct nbr *nbr)
{
- struct buf *buf;
+ struct ibuf *buf;
struct mapping_entry *me;
struct ldp_hdr *ldp_hdr;
u_int16_t tlv_size, size;
@@ -270,7 +270,7 @@ send_labelwithdraw(struct nbr *nbr)
log_debug("send_labelwithdraw: neighbor ID %s", inet_ntoa(nbr->id));
- if ((buf = buf_open(LDP_MAX_LEN)) == NULL)
+ if ((buf = ibuf_open(LDP_MAX_LEN)) == NULL)
fatal("send_labelwithdraw");
/* real size will be set up later */
@@ -297,7 +297,7 @@ send_labelwithdraw(struct nbr *nbr)
/* XXX: should we remove them first? */
nbr_mapping_list_clr(nbr, &nbr->withdraw_list);
- ldp_hdr = buf_seek(buf, 0, sizeof(struct ldp_hdr));
+ ldp_hdr = ibuf_seek(buf, 0, sizeof(struct ldp_hdr));
ldp_hdr->length = htons(size);
evbuf_enqueue(&nbr->wbuf, buf);
@@ -391,7 +391,7 @@ recv_labelwithdraw(struct nbr *nbr, char *buf, u_int16_t len)
void
send_labelrelease(struct nbr *nbr)
{
- struct buf *buf;
+ struct ibuf *buf;
struct mapping_entry *me;
struct ldp_hdr *ldp_hdr;
u_int16_t tlv_size, size;
@@ -401,7 +401,7 @@ send_labelrelease(struct nbr *nbr)
log_debug("send_labelrelease: neighbor ID %s", inet_ntoa(nbr->id));
- if ((buf = buf_open(LDP_MAX_LEN)) == NULL)
+ if ((buf = ibuf_open(LDP_MAX_LEN)) == NULL)
fatal("send_labelrelease");
/* real size will be set up later */
@@ -428,7 +428,7 @@ send_labelrelease(struct nbr *nbr)
/* XXX: should we remove them first? */
nbr_mapping_list_clr(nbr, &nbr->release_list);
- ldp_hdr = buf_seek(buf, 0, sizeof(struct ldp_hdr));
+ ldp_hdr = ibuf_seek(buf, 0, sizeof(struct ldp_hdr));
ldp_hdr->length = htons(size);
evbuf_enqueue(&nbr->wbuf, buf);
@@ -522,7 +522,7 @@ recv_labelrelease(struct nbr *nbr, char *buf, u_int16_t len)
void
send_labelabortreq(struct nbr *nbr)
{
- struct buf *buf;
+ struct ibuf *buf;
u_int16_t size;
if (nbr->iface->passive)
@@ -530,7 +530,7 @@ send_labelabortreq(struct nbr *nbr)
log_debug("send_labelabortreq: neighbor ID %s", inet_ntoa(nbr->id));
- if ((buf = buf_open(LDP_MAX_LEN)) == NULL)
+ if ((buf = ibuf_open(LDP_MAX_LEN)) == NULL)
fatal("send_labelabortreq");
size = LDP_HDR_SIZE + sizeof(struct ldp_msg);
@@ -573,7 +573,7 @@ recv_labelabortreq(struct nbr *nbr, char *buf, u_int16_t len)
/* Other TLV related functions */
void
-gen_fec_tlv(struct buf *buf, u_int32_t prefix, u_int8_t prefixlen)
+gen_fec_tlv(struct ibuf *buf, u_int32_t prefix, u_int8_t prefixlen)
{
struct fec_tlv ft;
u_int8_t type;
@@ -585,20 +585,20 @@ gen_fec_tlv(struct buf *buf, u_int32_t prefix, u_int8_t prefixlen)
ft.length = htons(sizeof(type) + sizeof(family) + sizeof(prefixlen) +
len);
- buf_add(buf, &ft, sizeof(ft));
+ ibuf_add(buf, &ft, sizeof(ft));
type = FEC_PREFIX;
family = htons(FEC_IPV4);
- buf_add(buf, &type, sizeof(type));
- buf_add(buf, &family, sizeof(family));
- buf_add(buf, &prefixlen, sizeof(prefixlen));
+ ibuf_add(buf, &type, sizeof(type));
+ ibuf_add(buf, &family, sizeof(family));
+ ibuf_add(buf, &prefixlen, sizeof(prefixlen));
if (len)
- buf_add(buf, &prefix, len);
+ ibuf_add(buf, &prefix, len);
}
void
-gen_label_tlv(struct buf *buf, u_int32_t label)
+gen_label_tlv(struct ibuf *buf, u_int32_t label)
{
struct label_tlv lt;
@@ -606,7 +606,7 @@ gen_label_tlv(struct buf *buf, u_int32_t label)
lt.length = htons(sizeof(label));
lt.label = htonl(label);
- buf_add(buf, &lt, sizeof(lt));
+ ibuf_add(buf, &lt, sizeof(lt));
}
u_int32_t
diff --git a/usr.sbin/ldpd/ldpd.c b/usr.sbin/ldpd/ldpd.c
index 290822d8ea0..bca79578bb6 100644
--- a/usr.sbin/ldpd/ldpd.c
+++ b/usr.sbin/ldpd/ldpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ldpd.c,v 1.7 2010/03/03 10:17:05 claudio Exp $ */
+/* $OpenBSD: ldpd.c,v 1.8 2010/05/26 13:56:07 nicm Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -528,9 +528,9 @@ imsg_compose_event(struct imsgev *iev, u_int16_t type,
}
void
-evbuf_enqueue(struct evbuf *eb, struct buf *buf)
+evbuf_enqueue(struct evbuf *eb, struct ibuf *buf)
{
- buf_close(&eb->wbuf, buf);
+ ibuf_close(&eb->wbuf, buf);
evbuf_event_add(eb);
}
diff --git a/usr.sbin/ldpd/ldpd.h b/usr.sbin/ldpd/ldpd.h
index 1947219051c..236065e1900 100644
--- a/usr.sbin/ldpd/ldpd.h
+++ b/usr.sbin/ldpd/ldpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ldpd.h,v 1.20 2010/05/25 13:29:45 claudio Exp $ */
+/* $OpenBSD: ldpd.h,v 1.21 2010/05/26 13:56:07 nicm Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
@@ -422,7 +422,7 @@ void merge_config(struct ldpd_conf *, struct ldpd_conf *);
int imsg_compose_event(struct imsgev *, u_int16_t, u_int32_t, pid_t,
int, void *, u_int16_t);
void imsg_event_add(struct imsgev *);
-void evbuf_enqueue(struct evbuf *, struct buf *);
+void evbuf_enqueue(struct evbuf *, struct ibuf *);
void evbuf_event_add(struct evbuf *);
void evbuf_init(struct evbuf *, int, void (*)(int, short, void *), void *);
void evbuf_clear(struct evbuf *);
diff --git a/usr.sbin/ldpd/ldpe.c b/usr.sbin/ldpd/ldpe.c
index 6b634834cfb..14a410f38c2 100644
--- a/usr.sbin/ldpd/ldpe.c
+++ b/usr.sbin/ldpd/ldpe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ldpe.c,v 1.9 2010/05/19 15:28:51 claudio Exp $ */
+/* $OpenBSD: ldpe.c,v 1.10 2010/05/26 13:56:07 nicm Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -210,7 +210,7 @@ ldpe(struct ldpd_conf *xconf, int pipe_parent2ldpe[2], int pipe_ldpe2lde[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("ldpe");
/* start interfaces */
diff --git a/usr.sbin/ldpd/ldpe.h b/usr.sbin/ldpd/ldpe.h
index 88bc5355383..f0fe3d05b3e 100644
--- a/usr.sbin/ldpd/ldpe.h
+++ b/usr.sbin/ldpd/ldpe.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ldpe.h,v 1.9 2010/05/19 15:28:51 claudio Exp $ */
+/* $OpenBSD: ldpe.h,v 1.10 2010/05/26 13:56:08 nicm Exp $ */
/*
* Copyright (c) 2004, 2005, 2008 Esben Norby <norby@openbsd.org>
@@ -54,7 +54,7 @@ struct nbr {
struct in_addr addr;
struct in_addr id;
- struct buf_read *rbuf;
+ struct ibuf_read *rbuf;
struct iface *iface;
time_t uptime;
@@ -89,7 +89,7 @@ int recv_keepalive(struct nbr *, char *, u_int16_t);
/* notification.c */
void send_notification_nbr(struct nbr *, u_int32_t, u_int32_t, u_int32_t);
-struct buf *send_notification(u_int32_t, struct iface *, u_int32_t,
+struct ibuf *send_notification(u_int32_t, struct iface *, u_int32_t,
u_int32_t);
int recv_notification(struct nbr *, char *, u_int16_t);
@@ -189,8 +189,8 @@ void nbr_mapping_list_clr(struct nbr *,
struct ctl_nbr *nbr_to_ctl(struct nbr *);
/* packet.c */
-int gen_ldp_hdr(struct buf *, struct iface *, u_int16_t);
-int gen_msg_tlv(struct buf *, u_int32_t, u_int16_t);
+int gen_ldp_hdr(struct ibuf *, struct iface *, u_int16_t);
+int gen_msg_tlv(struct ibuf *, u_int32_t, u_int16_t);
int send_packet(struct iface *, void *, size_t, struct sockaddr_in *);
void disc_recv_packet(int, short, void *);
void session_accept(int, short, void *);
diff --git a/usr.sbin/ldpd/neighbor.c b/usr.sbin/ldpd/neighbor.c
index ad445344ac4..db1e1f9dc86 100644
--- a/usr.sbin/ldpd/neighbor.c
+++ b/usr.sbin/ldpd/neighbor.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: neighbor.c,v 1.14 2010/05/25 09:26:12 claudio Exp $ */
+/* $OpenBSD: neighbor.c,v 1.15 2010/05/26 13:56:08 nicm Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
@@ -229,7 +229,7 @@ nbr_new(u_int32_t nbr_id, u_int16_t lspace, struct iface *iface)
if ((nbr = calloc(1, sizeof(*nbr))) == NULL)
fatal("nbr_new");
- if ((nbr->rbuf = calloc(1, sizeof(struct buf_read))) == NULL)
+ if ((nbr->rbuf = calloc(1, sizeof(struct ibuf_read))) == NULL)
fatal("nbr_new");
nbr->state = NBR_STA_DOWN;
diff --git a/usr.sbin/ldpd/notification.c b/usr.sbin/ldpd/notification.c
index 0708a6027a1..52650908a09 100644
--- a/usr.sbin/ldpd/notification.c
+++ b/usr.sbin/ldpd/notification.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: notification.c,v 1.6 2010/05/14 13:49:09 claudio Exp $ */
+/* $OpenBSD: notification.c,v 1.7 2010/05/26 13:56:08 nicm Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
@@ -37,13 +37,13 @@
#include "log.h"
#include "ldpe.h"
-int gen_status_tlv(struct buf *, u_int32_t, u_int32_t, u_int32_t);
+int gen_status_tlv(struct ibuf *, u_int32_t, u_int32_t, u_int32_t);
void
send_notification_nbr(struct nbr *nbr, u_int32_t status, u_int32_t msgid,
u_int32_t type)
{
- struct buf *buf;
+ struct ibuf *buf;
if (nbr->iface->passive)
return;
@@ -52,14 +52,14 @@ send_notification_nbr(struct nbr *nbr, u_int32_t status, u_int32_t msgid,
evbuf_enqueue(&nbr->wbuf, buf);
}
-struct buf *
+struct ibuf *
send_notification(u_int32_t status, struct iface *iface, u_int32_t msgid,
u_int32_t type)
{
- struct buf *buf;
+ struct ibuf *buf;
u_int16_t size;
- if ((buf = buf_open(LDP_MAX_LEN)) == NULL)
+ if ((buf = ibuf_open(LDP_MAX_LEN)) == NULL)
fatal("send_notification");
size = LDP_HDR_SIZE + sizeof(struct ldp_msg) + STATUS_SIZE;
@@ -121,7 +121,7 @@ recv_notification(struct nbr *nbr, char *buf, u_int16_t len)
}
int
-gen_status_tlv(struct buf *buf, u_int32_t status, u_int32_t msgid,
+gen_status_tlv(struct ibuf *buf, u_int32_t status, u_int32_t msgid,
u_int32_t type)
{
struct status_tlv st;
@@ -135,5 +135,5 @@ gen_status_tlv(struct buf *buf, u_int32_t status, u_int32_t msgid,
st.msg_id = msgid;
st.msg_type = type;
- return (buf_add(buf, &st, STATUS_SIZE));
+ return (ibuf_add(buf, &st, STATUS_SIZE));
}
diff --git a/usr.sbin/ldpd/packet.c b/usr.sbin/ldpd/packet.c
index df224545a4d..12613b7c454 100644
--- a/usr.sbin/ldpd/packet.c
+++ b/usr.sbin/ldpd/packet.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: packet.c,v 1.11 2010/05/14 13:49:09 claudio Exp $ */
+/* $OpenBSD: packet.c,v 1.12 2010/05/26 13:56:08 nicm Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
@@ -43,12 +43,12 @@ int ldp_hdr_sanity_check(struct ldp_hdr *, u_int16_t,
const struct iface *);
struct iface *find_iface(struct ldpd_conf *, unsigned int, struct in_addr);
struct iface *session_find_iface(struct ldpd_conf *, struct in_addr);
-ssize_t session_get_pdu(struct buf_read *, char **);
+ssize_t session_get_pdu(struct ibuf_read *, char **);
static int msgcnt = 0;
int
-gen_ldp_hdr(struct buf *buf, struct iface *iface, u_int16_t size)
+gen_ldp_hdr(struct ibuf *buf, struct iface *iface, u_int16_t size)
{
struct ldp_hdr ldp_hdr;
@@ -62,11 +62,11 @@ gen_ldp_hdr(struct buf *buf, struct iface *iface, u_int16_t size)
ldp_hdr.lsr_id = ldpe_router_id();
ldp_hdr.lspace_id = iface->lspace_id;
- return (buf_add(buf, &ldp_hdr, LDP_HDR_SIZE));
+ return (ibuf_add(buf, &ldp_hdr, LDP_HDR_SIZE));
}
int
-gen_msg_tlv(struct buf *buf, u_int32_t type, u_int16_t size)
+gen_msg_tlv(struct ibuf *buf, u_int32_t type, u_int16_t size)
{
struct ldp_msg msg;
@@ -78,7 +78,7 @@ gen_msg_tlv(struct buf *buf, u_int32_t type, u_int16_t size)
msg.length = htons(size);
msg.msgid = htonl(++msgcnt);
- return (buf_add(buf, &msg, sizeof(msg)));
+ return (ibuf_add(buf, &msg, sizeof(msg)));
}
/* send and receive packets */
@@ -131,7 +131,7 @@ disc_recv_packet(int fd, short event, void *bula)
/* setup buffer */
bzero(&msg, sizeof(msg));
iov.iov_base = buf = pkt_ptr;
- iov.iov_len = READ_BUF_SIZE;
+ iov.iov_len = IBUF_READ_SIZE;
msg.msg_name = &src;
msg.msg_namelen = sizeof(src);
msg.msg_iov = &iov;
@@ -278,12 +278,12 @@ session_accept(int fd, short event, void *bula)
nbr = nbr_find_ip(iface, src.sin_addr.s_addr);
if (nbr == NULL) {
- struct buf *buf;
+ struct ibuf *buf;
/* If there is no neighbor matching there is no
Hello adjacency: try to send notification */
buf = send_notification(S_NO_HELLO, iface, 0, 0);
write(newfd, buf->buf, buf->wpos);
- buf_free(buf);
+ ibuf_free(buf);
close(newfd);
return;
}
@@ -489,7 +489,7 @@ session_find_iface(struct ldpd_conf *xconf, struct in_addr src)
}
ssize_t
-session_get_pdu(struct buf_read *r, char **b)
+session_get_pdu(struct ibuf_read *r, char **b)
{
struct ldp_hdr l;
size_t av, dlen, left;