aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-csn1.c
diff options
context:
space:
mode:
authorAnders Broman <anders.broman@ericsson.com>2012-02-05 08:14:09 +0000
committerAnders Broman <anders.broman@ericsson.com>2012-02-05 08:14:09 +0000
commit2f024256bf337400ef3a82fa75e6d48d5707e059 (patch)
tree6a117edfda0b071b3e90e80914784596f0244dbc /epan/dissectors/packet-csn1.c
parent9f61b8bdd09834a415df4fafac16d125c0faecd1 (diff)
From Sylvain Munaut:
0001-packet-csn1-Fix-indenting-of-the-CSN_UINT-subsection.patch 0002-packet-csn1-Add-new-maro-M_TYPE_LABEL-to-customize-n.patch 0003-packet-csn1-New-macro-M_FIXED_LABEL-to-customize-str.patch 0004-packet-csn1-Allow-CHOICE-elements-to-re-process-the-.patch 0005-packet-csn1-Make-new-M_CHOICE_IL-option-that-doesn-t.patch 0006-packet-csn-Extend-CSN_SERIALIZE-to-allow-0-bit-of-le.patch https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=6789 svn path=/trunk/; revision=40847
Diffstat (limited to 'epan/dissectors/packet-csn1.c')
-rw-r--r--epan/dissectors/packet-csn1.c101
1 files changed, 62 insertions, 39 deletions
diff --git a/epan/dissectors/packet-csn1.c b/epan/dissectors/packet-csn1.c
index 9f9d698361..8d8f685e3c 100644
--- a/epan/dissectors/packet-csn1.c
+++ b/epan/dissectors/packet-csn1.c
@@ -550,7 +550,7 @@ csnStreamDissector(proto_tree *tree, csnStream_t* ar, const CSN_DESCR* pDescr, t
CSN_DESCR descr[2];
gint16 Status;
csnStream_t arT = *ar;
- proto_item *ti;
+ proto_item *ti = NULL;
proto_tree *test_tree;
descr[0] = pChoice->descr;
@@ -558,22 +558,32 @@ csnStreamDissector(proto_tree *tree, csnStream_t* ar, const CSN_DESCR* pDescr, t
descr[1].type = CSN_END;
pui8 = pui8DATA(data, pDescr->offset);
*pui8 = i;
- proto_tree_add_text(tree, tvb, bit_offset>>3, ((bit_offset+no_of_bits-1)>>3)-(bit_offset>>3)+1, "%s Choice: %s (%d)",
- decode_bits_in_field(bit_offset, no_of_bits, tvb_get_bits8(tvb, bit_offset, no_of_bits)),
- pDescr->sz, value);
- bit_offset += no_of_bits;
- remaining_bits_len -= no_of_bits;
+ if (pDescr->sz) {
+ proto_tree_add_text(tree, tvb, bit_offset>>3, ((bit_offset+no_of_bits-1)>>3)-(bit_offset>>3)+1, "%s Choice: %s (%d)",
+ decode_bits_in_field(bit_offset, no_of_bits, tvb_get_bits8(tvb, bit_offset, no_of_bits)),
+ pDescr->sz, value);
+ }
- ti = proto_tree_add_text(tree, tvb, bit_offset>>3, 1, "%s", pDescr->sz);
- test_tree = proto_item_add_subtree(ti, ett_csn1);
+ if (!pChoice->keep_bits) {
+ bit_offset += no_of_bits;
+ remaining_bits_len -= no_of_bits;
+ }
+
+ if (pDescr->sz) {
+ ti = proto_tree_add_text(tree, tvb, bit_offset>>3, 1, "%s", pDescr->sz);
+ test_tree = proto_item_add_subtree(ti, ett_csn1);
+ } else {
+ test_tree = tree;
+ }
csnStreamInit(&arT, bit_offset, remaining_bits_len);
Status = csnStreamDissector(test_tree, &arT, descr, tvb, data, ett_csn1);
if (Status >= 0)
{
- proto_item_set_len(ti,((arT.bit_offset-1)>>3) - (bit_offset>>3)+1);
+ if (ti)
+ proto_item_set_len(ti,((arT.bit_offset-1)>>3) - (bit_offset>>3)+1);
remaining_bits_len = arT.remaining_bits_len;
bit_offset = arT.bit_offset;
}
@@ -601,25 +611,38 @@ csnStreamDissector(proto_tree *tree, csnStream_t* ar, const CSN_DESCR* pDescr, t
gint16 Status = -1;
proto_item *ti;
proto_tree *test_tree;
- guint8 length = tvb_get_bits8(tvb, bit_offset, length_len);
+ guint8 length = 0;
+
+ if (length_len) {
+ length = tvb_get_bits8(tvb, bit_offset, length_len);
- proto_tree_add_text(tree, tvb, bit_offset>>3, ((bit_offset+length_len-1)>>3)-(bit_offset>>3)+1, "%s %s length: %d",
- decode_bits_in_field(bit_offset, length_len, length),
- pDescr->sz, length);
+ proto_tree_add_text(tree, tvb, bit_offset>>3, ((bit_offset+length_len-1)>>3)-(bit_offset>>3)+1, "%s %s length: %d",
+ decode_bits_in_field(bit_offset, length_len, length),
+ pDescr->sz, length);
- bit_offset += length_len;
- remaining_bits_len -= length_len;
- ti = proto_tree_add_text(tree, tvb, bit_offset>>3, ((bit_offset+length-1)>>3)-(bit_offset>>3) + 1, "%s", pDescr->sz);
+ bit_offset += length_len;
+ remaining_bits_len -= length_len;
+
+ ti = proto_tree_add_text(tree, tvb, bit_offset>>3, ((bit_offset+length-1)>>3)-(bit_offset>>3) + 1, "%s", pDescr->sz);
+ } else {
+ ti = proto_tree_add_text(tree, tvb, bit_offset>>3, 1, "%s", pDescr->sz);
+ }
test_tree = proto_item_add_subtree(ti, ett_csn1);
- csnStreamInit(&arT, bit_offset, length);
+ csnStreamInit(&arT, bit_offset, length > 0 ? length : remaining_bits_len);
Status = serialize(test_tree, &arT, tvb, pvDATA(data, pDescr->offset), ett_csn1);
if (Status >= 0)
{
- remaining_bits_len -= length;
- bit_offset += length;
+ if (length > 0) {
+ remaining_bits_len -= length;
+ bit_offset += length;
+ } else {
+ proto_item_set_len(ti,((arT.bit_offset - bit_offset)>>3)+1);
+ remaining_bits_len = arT.remaining_bits_len;
+ bit_offset = arT.bit_offset;
+ }
pDescr++;
}
else
@@ -712,27 +735,27 @@ csnStreamDissector(proto_tree *tree, csnStream_t* ar, const CSN_DESCR* pDescr, t
guint8 no_of_bits = (guint8) pDescr->i;
if (remaining_bits_len >= no_of_bits)
{
- if (no_of_bits <= 8)
- {
- guint8 ui8 = tvb_get_bits8(tvb, bit_offset, no_of_bits);
- pui8 = pui8DATA(data, pDescr->offset);
- *pui8 = ui8;
- proto_tree_add_bits_item(tree, *(pDescr->serialize.hf_ptr), tvb, bit_offset, no_of_bits, ENC_BIG_ENDIAN);
+ if (no_of_bits <= 8)
+ {
+ guint8 ui8 = tvb_get_bits8(tvb, bit_offset, no_of_bits);
+ pui8 = pui8DATA(data, pDescr->offset);
+ *pui8 = ui8;
+ proto_tree_add_bits_item(tree, *(pDescr->serialize.hf_ptr), tvb, bit_offset, no_of_bits, ENC_BIG_ENDIAN);
- }
- else if (no_of_bits <= 16)
- {
- guint16 ui16 = tvb_get_bits16(tvb, bit_offset, no_of_bits, ENC_BIG_ENDIAN);
- pui16 = pui16DATA(data, pDescr->offset);
- *pui16 = ui16;
- proto_tree_add_bits_item(tree, *(pDescr->serialize.hf_ptr), tvb, bit_offset, no_of_bits, ENC_BIG_ENDIAN);
- }
- else if (no_of_bits <= 32)
- {
- guint32 ui32 = tvb_get_bits32(tvb, bit_offset, no_of_bits, ENC_BIG_ENDIAN);
- pui32 = pui32DATA(data, pDescr->offset);
- *pui32 = ui32;
- proto_tree_add_bits_item(tree, *(pDescr->serialize.hf_ptr), tvb, bit_offset, no_of_bits, ENC_BIG_ENDIAN);
+ }
+ else if (no_of_bits <= 16)
+ {
+ guint16 ui16 = tvb_get_bits16(tvb, bit_offset, no_of_bits, ENC_BIG_ENDIAN);
+ pui16 = pui16DATA(data, pDescr->offset);
+ *pui16 = ui16;
+ proto_tree_add_bits_item(tree, *(pDescr->serialize.hf_ptr), tvb, bit_offset, no_of_bits, ENC_BIG_ENDIAN);
+ }
+ else if (no_of_bits <= 32)
+ {
+ guint32 ui32 = tvb_get_bits32(tvb, bit_offset, no_of_bits, ENC_BIG_ENDIAN);
+ pui32 = pui32DATA(data, pDescr->offset);
+ *pui32 = ui32;
+ proto_tree_add_bits_item(tree, *(pDescr->serialize.hf_ptr), tvb, bit_offset, no_of_bits, ENC_BIG_ENDIAN);
}
else