summaryrefslogtreecommitdiff
path: root/lib/stream.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/stream.c')
-rw-r--r--lib/stream.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/lib/stream.c b/lib/stream.c
index fe77e2a2ad..809e749fb9 100644
--- a/lib/stream.c
+++ b/lib/stream.c
@@ -543,6 +543,28 @@ stream_get_ipv4 (struct stream *s)
return l;
}
+float
+stream_getf (struct stream *s)
+{
+ union {
+ float r;
+ uint32_t d;
+ } u;
+ u.d = stream_getl (s);
+ return u.r;
+}
+
+double
+stream_getd (struct stream *s)
+{
+ union {
+ double r;
+ uint64_t d;
+ } u;
+ u.d = stream_getq (s);
+ return u.r;
+}
+
/* Copy to source to stream.
*
* XXX: This uses CHECK_SIZE and hence has funny semantics -> Size will wrap
@@ -671,6 +693,28 @@ stream_putq (struct stream *s, uint64_t q)
}
int
+stream_putf (struct stream *s, float f)
+{
+ union {
+ float i;
+ uint32_t o;
+ } u;
+ u.i = f;
+ return stream_putl (s, u.o);
+}
+
+int
+stream_putd (struct stream *s, double d)
+{
+ union {
+ double i;
+ uint64_t o;
+ } u;
+ u.i = d;
+ return stream_putq (s, u.o);
+}
+
+int
stream_putc_at (struct stream *s, size_t putp, u_char c)
{
STREAM_VERIFY_SANE(s);