diff options
author | paul <paul> | 2006-01-10 15:35:19 +0100 |
---|---|---|
committer | paul <paul> | 2006-01-10 15:35:19 +0100 |
commit | 4b201d46348b81bd9d59aa626c81f7457ea6ef38 (patch) | |
tree | b841d11214e5ec8ff4904d193c5e0b7c4e741a50 /lib/stream.h | |
parent | remove dead code (from David Young) (diff) | |
download | frr-4b201d46348b81bd9d59aa626c81f7457ea6ef38.tar.xz frr-4b201d46348b81bd9d59aa626c81f7457ea6ef38.zip |
[stream] Add quad-word support and stream_resize
2006-01-10 Paul Jakma <paul.jakma@sun.com>
* stream.c: (stream_new) Allocate stream data as seperate object.
(stream_free) free the data.
(stream_resize) new function, resize stream to new size.
(stream_{get,put}q*) new functions to get/put quad word size
types.
* stream.h: (struct stream) make data seperate from the stream.
Export new stream_resize and quad-word get/put functions.
Diffstat (limited to 'lib/stream.h')
-rw-r--r-- | lib/stream.h | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/lib/stream.h b/lib/stream.h index 564fa3ca6..d2d2e4011 100644 --- a/lib/stream.h +++ b/lib/stream.h @@ -103,7 +103,7 @@ struct stream size_t getp; /* next get position */ size_t endp; /* last valid data position */ size_t size; /* size of data segment */ - unsigned char data[]; /* data pointer */ + unsigned char *data; /* data pointer */ }; /* First in first out queue structure. */ @@ -127,12 +127,19 @@ struct stream_fifo #define STREAM_DATA(S) ((S)->data) #define STREAM_REMAIN(S) STREAM_WRITEABLE((S)) -/* Stream prototypes. */ +/* Stream prototypes. + * For stream_{put,get}S, the S suffix mean: + * + * c: character (unsigned byte) + * w: word (two bytes) + * l: long (two words) + * q: quad (four words) + */ extern struct stream *stream_new (size_t); extern void stream_free (struct stream *); extern struct stream * stream_copy (struct stream *new, struct stream *src); extern struct stream *stream_dup (struct stream *); - +extern size_t stream_resize (struct stream *, size_t); extern size_t stream_get_getp (struct stream *); extern size_t stream_get_endp (struct stream *); extern size_t stream_get_size (struct stream *); @@ -150,6 +157,8 @@ extern int stream_putw (struct stream *, u_int16_t); extern int stream_putw_at (struct stream *, size_t, u_int16_t); extern int stream_putl (struct stream *, u_int32_t); extern int stream_putl_at (struct stream *, size_t, u_int32_t); +extern int stream_putq (struct stream *, uint64_t); +extern int stream_putq_at (struct stream *, size_t, uint64_t); extern int stream_put_ipv4 (struct stream *, u_int32_t); extern int stream_put_in_addr (struct stream *, struct in_addr *); extern int stream_put_prefix (struct stream *, struct prefix *); @@ -161,6 +170,8 @@ extern u_int16_t stream_getw (struct stream *); extern u_int16_t stream_getw_from (struct stream *, size_t); extern u_int32_t stream_getl (struct stream *); extern u_int32_t stream_getl_from (struct stream *, size_t); +extern uint64_t stream_getq (struct stream *); +extern uint64_t stream_getq_from (struct stream *, size_t); extern u_int32_t stream_get_ipv4 (struct stream *); #undef stream_read |