aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-fcsb3.c
diff options
context:
space:
mode:
authorRonnie Sahlberg <ronnie_sahlberg@ozemail.com.au>2005-10-10 09:12:33 +0000
committerRonnie Sahlberg <ronnie_sahlberg@ozemail.com.au>2005-10-10 09:12:33 +0000
commit02f562359e0717719b6c4a6be547a444050e8f93 (patch)
treed0aba97ce040041b546a4b87aeb5995d8a355085 /epan/dissectors/packet-fcsb3.c
parent6d67bce2e5ec6c0176791032e957ce606400425f (diff)
remove one array from the stack
dissect one more bitfield properly get rid of some strcpy() svn path=/trunk/; revision=16176
Diffstat (limited to 'epan/dissectors/packet-fcsb3.c')
-rw-r--r--epan/dissectors/packet-fcsb3.c92
1 files changed, 67 insertions, 25 deletions
diff --git a/epan/dissectors/packet-fcsb3.c b/epan/dissectors/packet-fcsb3.c
index 03b643f6d6..6b80824197 100644
--- a/epan/dissectors/packet-fcsb3.c
+++ b/epan/dissectors/packet-fcsb3.c
@@ -60,7 +60,6 @@ static int proto_fc_sbccs = -1;
static int hf_sbccs_chid = -1;
static int hf_sbccs_cuid = -1;
static int hf_sbccs_devaddr = -1;
-static int hf_sbccs_dhflags = -1;
static int hf_sbccs_ccw = -1;
static int hf_sbccs_token = -1;
static int hf_sbccs_dib_iucnt = -1;
@@ -94,10 +93,16 @@ static int hf_sbccs_iui = -1;
static int hf_sbccs_iui_as = -1;
static int hf_sbccs_iui_es = -1;
static int hf_sbccs_iui_val = -1;
+static int hf_sbccs_dhflags = -1;
+static int hf_sbccs_dhflags_end = -1;
+static int hf_sbccs_dhflags_chaining = -1;
+static int hf_sbccs_dhflags_earlyend = -1;
+static int hf_sbccs_dhflags_nocrc = -1;
/* Initialize the subtree pointers */
static gint ett_fc_sbccs = -1;
static gint ett_sbccs_iui = -1;
+static gint ett_sbccs_dhflags = -1;
static dissector_handle_t data_handle;
@@ -266,31 +271,58 @@ dissect_iui_flags (proto_tree *parent_tree, tvbuff_t *tvb, int offset, guint16 f
flags&=(~( 0x07 ));
}
-static gchar *get_dhflags_string (guint8 dhflags, gchar *buffer)
-{
- guint pos = 0;
- buffer[0] = '\0';
+static const true_false_string tfs_sbccs_dhflags_end = {
+ "END bit is set",
+ "end bit is NOT set"
+};
+static const true_false_string tfs_sbccs_dhflags_chaining = {
+ "CHAINING bit is set",
+ "chaining bit is NOT set"
+};
+static const true_false_string tfs_sbccs_dhflags_earlyend = {
+ "EARLYEND bit is set",
+ "earlyend bit is NOT set"
+};
+static const true_false_string tfs_sbccs_dhflags_nocrc = {
+ "NOCRC bit is set",
+ "nocrc bit is NOT set"
+};
- if (dhflags & 0x80) {
- strcpy (&buffer[pos], "End, ");
- pos += 5;
- }
+static void
+dissect_dh_flags (proto_tree *parent_tree, tvbuff_t *tvb, int offset, guint16 flags)
+{
+ proto_item *item=NULL;
+ proto_tree *tree=NULL;
+
+ if(parent_tree){
+ item=proto_tree_add_uint(parent_tree, hf_sbccs_dhflags,
+ tvb, offset, 1, flags);
+ tree=proto_item_add_subtree(item, ett_sbccs_dhflags);
+ }
- if (dhflags & 0x10) {
- strcpy (&buffer[pos], "Chaining, ");
- pos += 10;
- }
+ proto_tree_add_boolean(tree, hf_sbccs_dhflags_end, tvb, offset, 1, flags);
+ if (flags&0x80){
+ proto_item_append_text(item, " End");
+ }
+ flags&=(~( 0x80 ));
- if (dhflags & 0x8) {
- strcpy (&buffer[pos], "Early End, ");
- pos += 11;
- }
+ proto_tree_add_boolean(tree, hf_sbccs_dhflags_chaining, tvb, offset, 1, flags);
+ if (flags&0x10){
+ proto_item_append_text(item, " Chaining");
+ }
+ flags&=(~( 0x10 ));
- if (dhflags & 0x4) {
- strcpy (&buffer[pos], "No CRC");
- }
+ proto_tree_add_boolean(tree, hf_sbccs_dhflags_earlyend, tvb, offset, 1, flags);
+ if (flags&0x08){
+ proto_item_append_text(item, " Early End");
+ }
+ flags&=(~( 0x08 ));
- return (buffer);
+ proto_tree_add_boolean(tree, hf_sbccs_dhflags_nocrc, tvb, offset, 1, flags);
+ if (flags&0x04){
+ proto_item_append_text(item, " No CRC");
+ }
+ flags&=(~( 0x04 ));
}
static gchar *get_ccw_flags_string (guint8 ccw_flags, gchar *buffer)
@@ -490,7 +522,6 @@ dissect_fc_sbccs_sb3_iu_hdr (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree
proto_item *subti;
proto_tree *sb3hdr_tree;
proto_tree *iuhdr_tree;
- gchar buffer[256];
guint8 iui, dhflags;
guint type;
@@ -522,9 +553,7 @@ dissect_fc_sbccs_sb3_iu_hdr (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree
dissect_iui_flags(iuhdr_tree, tvb, offset, iui);
dhflags = tvb_get_guint8 (tvb, offset+1);
- proto_tree_add_uint_format (iuhdr_tree, hf_sbccs_dhflags, tvb, offset, 1,
- dhflags, "DH Flags: 0x%x (%s)",
- dhflags, get_dhflags_string (dhflags, buffer));
+ dissect_dh_flags(iuhdr_tree, tvb, offset+1, dhflags);
proto_tree_add_item (iuhdr_tree, hf_sbccs_ccw, tvb, offset+2, 2, 0);
proto_tree_add_item (iuhdr_tree, hf_sbccs_token, tvb, offset+5, 3, 0);
@@ -990,6 +1019,18 @@ proto_register_fcsbccs (void)
{ &hf_sbccs_iui_val,
{"Val", "sbccs.iui.val", FT_UINT8, BASE_HEX,
VALS(fc_sbccs_iu_val), 0x07, "", HFILL}},
+ { &hf_sbccs_dhflags_end,
+ {"End", "sbccs.dhflags.end", FT_BOOLEAN, 8,
+ TFS(&tfs_sbccs_dhflags_end), 0x80, "", HFILL}},
+ { &hf_sbccs_dhflags_chaining,
+ {"Chaining", "sbccs.dhflags.chaining", FT_BOOLEAN, 8,
+ TFS(&tfs_sbccs_dhflags_chaining), 0x10, "", HFILL}},
+ { &hf_sbccs_dhflags_earlyend,
+ {"Early End", "sbccs.dhflags.earlyend", FT_BOOLEAN, 8,
+ TFS(&tfs_sbccs_dhflags_earlyend), 0x08, "", HFILL}},
+ { &hf_sbccs_dhflags_nocrc,
+ {"No CRC", "sbccs.dhflags.nocrc", FT_BOOLEAN, 8,
+ TFS(&tfs_sbccs_dhflags_nocrc), 0x04, "", HFILL}},
};
@@ -997,6 +1038,7 @@ proto_register_fcsbccs (void)
static gint *ett[] = {
&ett_fc_sbccs,
&ett_sbccs_iui,
+ &ett_sbccs_dhflags,
};
/* Register the protocol name and description */