aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorJakub Zawadzki <darkjames-ws@darkjames.pl>2013-12-30 23:58:45 +0000
committerJakub Zawadzki <darkjames-ws@darkjames.pl>2013-12-30 23:58:45 +0000
commita65cbe8e7b3efe25db3cb6861dac302a145655c5 (patch)
tree93ca9fc06a6073589270e0d5cf6f5acef48219d3 /epan
parente1ea055c798fcb920066811483ca2bbfcca84534 (diff)
Add new function: tvb_skip_guint8()
svn path=/trunk/; revision=54505
Diffstat (limited to 'epan')
-rw-r--r--epan/tvbuff.c21
-rw-r--r--epan/tvbuff.h2
2 files changed, 23 insertions, 0 deletions
diff --git a/epan/tvbuff.c b/epan/tvbuff.c
index d6f932d4b5..12b68968bb 100644
--- a/epan/tvbuff.c
+++ b/epan/tvbuff.c
@@ -3212,6 +3212,27 @@ tvb_skip_wsp_return(tvbuff_t *tvb, const gint offset) {
return (counter);
}
+int
+tvb_skip_guint8(tvbuff_t *tvb, int offset, const int maxlength, const guint8 ch)
+{
+ int end, tvb_len;
+
+ /* Get the length remaining */
+ tvb_len = tvb_length(tvb);
+ end = offset + maxlength;
+ if (end >= tvb_len)
+ end = tvb_len;
+
+ while (offset < end) {
+ guint8 tempch = tvb_get_guint8(tvb, offset);
+
+ if (tempch != ch)
+ break;
+ offset++;
+ }
+
+ return offset;
+}
/*
* Format a bunch of data from a tvbuff as bytes, returning a pointer
diff --git a/epan/tvbuff.h b/epan/tvbuff.h
index 55236f08b1..424469130c 100644
--- a/epan/tvbuff.h
+++ b/epan/tvbuff.h
@@ -619,6 +619,8 @@ WS_DLL_PUBLIC gint tvb_skip_wsp(tvbuff_t *tvb, const gint offset,
WS_DLL_PUBLIC gint tvb_skip_wsp_return(tvbuff_t *tvb, const gint offset);
+int tvb_skip_guint8(tvbuff_t *tvb, int offset, const int maxlength, const guint8 ch);
+
/**
* Call strncmp after checking if enough chars left, returning 0 if
* it returns 0 (meaning "equal") and -1 otherwise, otherwise return -1.