aboutsummaryrefslogtreecommitdiffstats
path: root/tvbuff.c
diff options
context:
space:
mode:
authorGilbert Ramirez <gram@alumni.rice.edu>2000-05-15 04:37:27 +0000
committerGilbert Ramirez <gram@alumni.rice.edu>2000-05-15 04:37:27 +0000
commit6c2a7af1f68d5b919f2d52e69e889ef5a1858392 (patch)
treebc4711475e0784dd440ece8106bbd543ae3c1f84 /tvbuff.c
parent0d12107436c4eb3938dd52034c0eb6b99c494939 (diff)
Add accessors for 24-bit integers (which get returned as guint32's).
svn path=/trunk/; revision=1961
Diffstat (limited to 'tvbuff.c')
-rw-r--r--tvbuff.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/tvbuff.c b/tvbuff.c
index e74cb1ab37..e2ed4db385 100644
--- a/tvbuff.c
+++ b/tvbuff.c
@@ -9,7 +9,7 @@
* the data of a backing tvbuff, or can be a composite of
* other tvbuffs.
*
- * $Id: tvbuff.c,v 1.1 2000/05/11 08:16:00 gram Exp $
+ * $Id: tvbuff.c,v 1.2 2000/05/15 04:37:27 gram Exp $
*
* Copyright (c) 2000 by Gilbert Ramirez <gram@xiexie.org>
*
@@ -53,6 +53,10 @@
(guint32)*((guint8 *)p+2)<<8| \
(guint32)*((guint8 *)p+3)<<0)
+#define pntoh24(p) ((guint32)*((guint8 *)p+0)<<16| \
+ (guint32)*((guint8 *)p+1)<<8| \
+ (guint32)*((guint8 *)p+2)<<0)
+
#define pletohs(p) ((guint16) \
((guint16)*((guint8 *)p+1)<<8| \
(guint16)*((guint8 *)p+0)<<0))
@@ -62,6 +66,10 @@
(guint32)*((guint8 *)p+1)<<8| \
(guint32)*((guint8 *)p+0)<<0)
+#define pletoh24(p) ((guint32)*((guint8 *)p+2)<<16| \
+ (guint32)*((guint8 *)p+1)<<8| \
+ (guint32)*((guint8 *)p+0)<<0)
+
typedef struct {
/* The backing tvbuff_t */
@@ -805,6 +813,15 @@ tvb_get_ntohl(tvbuff_t *tvb, gint offset)
return pntohl(ptr);
}
+guint32
+tvb_get_ntoh24(tvbuff_t *tvb, gint offset)
+{
+ guint8* ptr;
+
+ ptr = ensure_contiguous(tvb, offset, 3);
+ return pntoh24(ptr);
+}
+
guint16
tvb_get_letohs(tvbuff_t *tvb, gint offset)
{
@@ -822,3 +839,12 @@ tvb_get_letohl(tvbuff_t *tvb, gint offset)
ptr = ensure_contiguous(tvb, offset, sizeof(guint32));
return pletohl(ptr);
}
+
+guint32
+tvb_get_letoh24(tvbuff_t *tvb, gint offset)
+{
+ guint8* ptr;
+
+ ptr = ensure_contiguous(tvb, offset, 3);
+ return pletoh24(ptr);
+}