aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-catapult-dct2000.c
diff options
context:
space:
mode:
authorMartin Mathieson <martin.r.mathieson@googlemail.com>2007-07-12 17:31:26 +0000
committerMartin Mathieson <martin.r.mathieson@googlemail.com>2007-07-12 17:31:26 +0000
commitecc4b9ad06620f368f1903418efe11c60da180c2 (patch)
tree960b6aada3af1dd3811ec314215bd9addaf3f0fc /epan/dissectors/packet-catapult-dct2000.c
parentdf2472cb419b5d6dcede50cf9986b1901fd96526 (diff)
Fix parsing of sctpprim header (v1)
svn path=/trunk/; revision=22290
Diffstat (limited to 'epan/dissectors/packet-catapult-dct2000.c')
-rw-r--r--epan/dissectors/packet-catapult-dct2000.c75
1 files changed, 36 insertions, 39 deletions
diff --git a/epan/dissectors/packet-catapult-dct2000.c b/epan/dissectors/packet-catapult-dct2000.c
index 7832120e5b..09c9159c06 100644
--- a/epan/dissectors/packet-catapult-dct2000.c
+++ b/epan/dissectors/packet-catapult-dct2000.c
@@ -114,6 +114,21 @@ static void attach_fp_info(packet_info *pinfo, gboolean received,
const char *protocol_name, int variant);
+/* Return the number of bytes used to encode the length field
+ (we're not interested in the length value itself) */
+static int skipASNLength(guint8 value)
+{
+ if ((value & 0x80) == 0)
+ {
+ return 1;
+ }
+ else
+ {
+ return ((value & 0x03) == 1) ? 2 : 3;
+ }
+}
+
+
/* Look for the protocol data within an ipprim packet.
Only set *data_offset if data field found. */
static gboolean find_ipprim_data_offset(tvbuff_t *tvb, int *data_offset, guint8 direction,
@@ -238,12 +253,12 @@ static gboolean find_ipprim_data_offset(tvbuff_t *tvb, int *data_offset, guint8
Only set *data_offset if data field found. */
static gboolean find_sctpprim_variant1_data_offset(tvbuff_t *tvb, int *data_offset)
{
- guint8 length;
int offset = *data_offset;
/* Get the sctpprim command code. */
guint8 first_tag = tvb_get_guint8(tvb, offset++);
guint8 tag;
+ guint8 first_length_byte;
/* Only accept interested in data requests or indications */
switch (first_tag)
@@ -255,22 +270,8 @@ static gboolean find_sctpprim_variant1_data_offset(tvbuff_t *tvb, int *data_offs
return FALSE;
}
- if (first_tag == 0x04)
- {
- /* Overall length field. msb set indicates 2 bytes */
- if (tvb_get_guint8(tvb, offset) & 0x80)
- {
- offset += 2;
- }
- else
- {
- offset++;
- }
- }
- else
- {
- offset += 3;
- }
+ first_length_byte = tvb_get_guint8(tvb, offset);
+ offset += skipASNLength(first_length_byte);
/* Skip any other fields before reach payload */
while (tvb_length_remaining(tvb, offset) > 2)
@@ -278,7 +279,6 @@ static gboolean find_sctpprim_variant1_data_offset(tvbuff_t *tvb, int *data_offs
/* Look at next tag */
tag = tvb_get_guint8(tvb, offset++);
-
/* Is this the data payload we're expecting? */
if (tag == 0x19)
{
@@ -287,28 +287,25 @@ static gboolean find_sctpprim_variant1_data_offset(tvbuff_t *tvb, int *data_offs
}
else
{
- if (first_tag == 0x62)
- {
- switch (tag)
- {
- case 0x0a: /* dest port */
- case 0x1e: /* strseqnum */
- case 0x0d:
- offset += 2;
- continue;
- case 0x1d:
- case 0x09:
- case 0x0c:
- offset += 4;
- continue;
- }
- }
- else
+ /* Skip length field */
+ offset++;
+ switch (tag)
{
- /* Read length in next byte */
- length = tvb_get_guint8(tvb, offset++);
- /* Skip the following value */
- offset += length;
+ case 0x01: /* sctpInstanceNum */
+ case 0x0a: /* destPort */
+ case 0x1e: /* strseqnum */
+ case 0x0d: /* streamnum */
+ offset += 2;
+ continue;
+ case 0x1d:
+ case 0x09: /* ipv4Address */
+ case 0x0c: /* payloadType */
+ offset += 4;
+ continue;
+
+ default:
+ /* Fail if not a known header field */
+ return FALSE;
}
}
}