diff options
-rw-r--r-- | usr.sbin/ospfd/buffer.c | 12 | ||||
-rw-r--r-- | usr.sbin/ospfd/ospfd.h | 3 |
2 files changed, 13 insertions, 2 deletions
diff --git a/usr.sbin/ospfd/buffer.c b/usr.sbin/ospfd/buffer.c index 42d160499ed..41693565a10 100644 --- a/usr.sbin/ospfd/buffer.c +++ b/usr.sbin/ospfd/buffer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: buffer.c,v 1.2 2005/02/01 21:25:18 claudio Exp $ */ +/* $OpenBSD: buffer.c,v 1.3 2005/02/09 14:39:56 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -111,6 +111,16 @@ buf_reserve(struct buf *buf, size_t len) return (b); } +void * +buf_seek(struct buf *buf, size_t pos, size_t len) +{ + /* only allowed to seek in already written parts */ + if (pos + len > buf->wpos) + return (NULL); + + return (buf->buf + pos); +} + int buf_close(struct msgbuf *msgbuf, struct buf *buf) { diff --git a/usr.sbin/ospfd/ospfd.h b/usr.sbin/ospfd/ospfd.h index 6d954ad2442..78e114c50ab 100644 --- a/usr.sbin/ospfd/ospfd.h +++ b/usr.sbin/ospfd/ospfd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ospfd.h,v 1.5 2005/02/07 05:51:00 david Exp $ */ +/* $OpenBSD: ospfd.h,v 1.6 2005/02/09 14:39:56 claudio Exp $ */ /* * Copyright (c) 2004 Esben Norby <norby@openbsd.org> @@ -367,6 +367,7 @@ struct buf *buf_open(size_t); struct buf *buf_dynamic(size_t, size_t); int buf_add(struct buf *, void *, size_t); void *buf_reserve(struct buf *, size_t); +void *buf_seek(struct buf *, size_t, size_t); int buf_close(struct msgbuf *, struct buf *); int buf_write(int, struct buf *); void buf_free(struct buf *); |