diff options
author | Eric Faurot <eric@cvs.openbsd.org> | 2009-06-02 22:02:02 +0000 |
---|---|---|
committer | Eric Faurot <eric@cvs.openbsd.org> | 2009-06-02 22:02:02 +0000 |
commit | 1fba9f48387d03cee6ca93ba2eae4d56f81c0721 (patch) | |
tree | cb2c31c16308756e8e3ab89c7fe3ca8cfa9e56a0 /usr.sbin/relayd | |
parent | 471fbc1af6e634eba6dfa609568aea0893793bc1 (diff) |
bring in buf_seek, buf_size and buf_left from bgpd
ok pyr@
Diffstat (limited to 'usr.sbin/relayd')
-rw-r--r-- | usr.sbin/relayd/buffer.c | 24 | ||||
-rw-r--r-- | usr.sbin/relayd/relayd.h | 5 |
2 files changed, 27 insertions, 2 deletions
diff --git a/usr.sbin/relayd/buffer.c b/usr.sbin/relayd/buffer.c index 2f606dc2103..2aec7667d32 100644 --- a/usr.sbin/relayd/buffer.c +++ b/usr.sbin/relayd/buffer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: buffer.c,v 1.15 2009/06/02 21:44:22 eric Exp $ */ +/* $OpenBSD: buffer.c,v 1.16 2009/06/02 22:02:01 eric Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -119,6 +119,28 @@ 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); +} + +size_t +buf_size(struct buf *buf) +{ + return (buf->wpos); +} + +size_t +buf_left(struct buf *buf) +{ + return (buf->max - buf->wpos); +} + int buf_close(struct msgbuf *msgbuf, struct buf *buf) { diff --git a/usr.sbin/relayd/relayd.h b/usr.sbin/relayd/relayd.h index d2874385266..2bc243868c2 100644 --- a/usr.sbin/relayd/relayd.h +++ b/usr.sbin/relayd/relayd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: relayd.h,v 1.117 2009/06/02 21:44:22 eric Exp $ */ +/* $OpenBSD: relayd.h,v 1.118 2009/06/02 22:02:01 eric Exp $ */ /* * Copyright (c) 2006, 2007 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -789,6 +789,9 @@ 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 *); int buf_close(struct msgbuf *, struct buf *); void buf_free(struct buf *); void msgbuf_init(struct msgbuf *); |