diff options
author | Chris Maynard <Christopher.Maynard@GTECH.COM> | 2013-02-17 22:44:47 +0000 |
---|---|---|
committer | Chris Maynard <Christopher.Maynard@GTECH.COM> | 2013-02-17 22:44:47 +0000 |
commit | 77350352300665a54e8dab7bd19140a44dbce6fa (patch) | |
tree | 1bd3294b35f59fa8683006fb3baae266aa266128 /epan/dissectors/packet-sml.c | |
parent | fd44f9a33940527be92a2c9c7d53f2c6da00270d (diff) |
Fix Coverity CID 981983: Unused pointer value.
Additionally:
1) Remove check_col()'s
2) Don't call expert_add_info_format() from within an if (tree) {} block.
3) tvb_reported_length_remaining() can return -1; be sure to handle it.
4) Misc. whitespace changes.
svn path=/trunk/; revision=47722
Diffstat (limited to 'epan/dissectors/packet-sml.c')
-rw-r--r-- | epan/dissectors/packet-sml.c | 393 |
1 files changed, 125 insertions, 268 deletions
diff --git a/epan/dissectors/packet-sml.c b/epan/dissectors/packet-sml.c index 09f4a45249..d134285112 100644 --- a/epan/dissectors/packet-sml.c +++ b/epan/dissectors/packet-sml.c @@ -38,8 +38,8 @@ Short description of the SML protocol on the SML Wireshark Wiki page: http://wi #include <epan/crc16-tvb.h> #include <epan/expert.h> -#define TCP_PORT_SML 0 -#define UDP_PORT_SML 0 +#define TCP_PORT_SML 0 +#define UDP_PORT_SML 0 #define ESC_SEQ_END G_GUINT64_CONSTANT(0x1b1b1b1b1a) #define ESC_SEQ 0x1b1b1b1b @@ -154,8 +154,7 @@ static int hf_sml_unit_R4 = -1; static int hf_sml_scaler_R4 = -1; static int hf_sml_value_R4 = -1; - -static const value_string datatype []= { +static const value_string datatype []={ {0x52, "Integer 8"}, {0x53, "Integer 16"}, {0x54, "Integer cropped"}, @@ -176,7 +175,7 @@ static const value_string datatype []= { {0, NULL} }; -static const value_string sml_abort[]= { +static const value_string sml_abort[]={ {0x00, "Continue"}, {0x01, "Continue at next group"}, {0x02, "Continue than abort"}, @@ -184,7 +183,7 @@ static const value_string sml_abort[]= { {0, NULL} }; -static const value_string sml_body[]= { +static const value_string sml_body[]={ {OPEN_REQ, "PublicOpen.Req"}, {OPEN_RES, "PublicOpen.Res"}, {CLOSE_REQ, "PublicClose.Req"}, @@ -251,7 +250,6 @@ static const range_string bools[]={ {0,0, NULL} }; - static dissector_handle_t data_handle; /* Initialize the subtree pointers */ @@ -353,7 +351,6 @@ static gboolean sml_crc_enabled = FALSE; /*get number of length octets and calculate how many data octets, it's like BER but not the same! */ static void get_length(tvbuff_t *tvb, guint *offset, guint *data, guint *length){ - guint check = 0; guint temp_offset = 0; @@ -364,11 +361,9 @@ static void get_length(tvbuff_t *tvb, guint *offset, guint *data, guint *length) check = tvb_get_guint8(tvb, temp_offset); if (check == OPTIONAL){ *length = 1; - } else if ((check & 0x80) == 0x80){ while ((check & 0x80) == 0x80){ - check = check & 0x0F; *data = *data + check; @@ -377,36 +372,29 @@ static void get_length(tvbuff_t *tvb, guint *offset, guint *data, guint *length) temp_offset+=1; check = tvb_get_guint8(tvb, temp_offset); - } check = check & 0x0F; *data = *data + check; *length+=1; *data = *data - *length; - } - else{ - check = tvb_get_guint8(tvb, temp_offset); check = check & 0x0F; *length+=1; *data = check - *length; - } - -}; +} /*often used fields*/ static void sml_value(tvbuff_t *tvb,proto_tree *insert_tree,guint *offset, guint *data, guint *length){ - proto_item *value = NULL; proto_tree *value_tree = NULL; get_length(tvb, offset, data, length); value = proto_tree_add_bytes_format (insert_tree, hf_sml_value, tvb, *offset, *length + *data, NULL,"value %s", (*data == 0)? ": NOT SET" : ""); - + if (tvb_get_guint8(tvb, *offset) != OPTIONAL){ value_tree = proto_item_add_subtree (value, ett_sml_value); if ((tvb_get_guint8(tvb, *offset) & 0x80) == 0x80 || (tvb_get_guint8(tvb, *offset) & 0xF0) == 0){ @@ -420,12 +408,11 @@ static void sml_value(tvbuff_t *tvb,proto_tree *insert_tree,guint *offset, guint proto_tree_add_item (value_tree, hf_sml_value, tvb, *offset, *data, ENC_NA); *offset+= *data; } - else *offset+=1; - -}; + else + *offset+=1; +} static void sml_time_type(tvbuff_t *tvb, proto_tree *SML_time_tree, guint *offset){ - proto_item *timetype = NULL; proto_tree *timetype_tree = NULL; @@ -436,12 +423,9 @@ static void sml_time_type(tvbuff_t *tvb, proto_tree *SML_time_tree, guint *offse *offset+=1; proto_tree_add_item (timetype_tree, hf_sml_timetype, tvb, *offset, 1, ENC_NA); *offset+=1; - - -}; +} static void field_codepage(tvbuff_t *tvb, proto_tree *insert_tree, guint *offset, guint *data, guint *length){ - proto_item *codepage = NULL; proto_tree *codepage_tree = NULL; @@ -449,20 +433,18 @@ static void field_codepage(tvbuff_t *tvb, proto_tree *insert_tree, guint *offset codepage = proto_tree_add_bytes_format (insert_tree, hf_sml_codepage, tvb, *offset, *length + *data, NULL,"Codepage %s", (*data == 0)? ": NOT SET" : ""); if (*data > 0) { - codepage_tree = proto_item_add_subtree (codepage , ett_sml_codepage); proto_tree_add_text (codepage_tree, tvb, *offset, *length, "Length: %d %s", *data ,plurality(*data, "octet", "octets")); *offset+= *length; proto_tree_add_item (codepage_tree, hf_sml_codepage, tvb, *offset, *data, ENC_NA); *offset+= *data; - } - else *offset+=1; + else + *offset+=1; +} -}; static void field_clientId(tvbuff_t *tvb, proto_tree *insert_tree, guint *offset, guint *data, guint *length){ - proto_item *clientId = NULL; proto_tree *clientId_tree = NULL; @@ -470,31 +452,30 @@ static void field_clientId(tvbuff_t *tvb, proto_tree *insert_tree, guint *offset clientId = proto_tree_add_bytes_format (insert_tree, hf_sml_clientId, tvb, *offset, *length + *data, NULL, "clientID %s", (*data == 0)? ": NOT SET" : ""); if (*data > 0) { - clientId_tree = proto_item_add_subtree (clientId, ett_sml_clientId); proto_tree_add_text (clientId_tree, tvb, *offset, *length, "Length: %d %s", *data, plurality(*data, "octet", "octets")); *offset+=*length; proto_tree_add_item (clientId_tree, hf_sml_clientId, tvb, *offset, *data, ENC_NA); *offset+=*data; } - else *offset+=1; - + else + *offset+=1; +} -}; static void field_reqFileId(tvbuff_t *tvb, proto_tree *insert_tree, guint *offset, guint *data, guint *length){ proto_item *reqFileId = NULL; proto_tree *reqFileId_tree = NULL; get_length(tvb, offset, data, length); reqFileId = proto_tree_add_text (insert_tree, tvb, *offset, *length + *data, "reqFileId"); - + reqFileId_tree = proto_item_add_subtree (reqFileId, ett_sml_reqFileId); proto_tree_add_text (reqFileId_tree, tvb, *offset, *length, "Length: %d %s", *data, plurality(*data, "octet", "octets")); *offset+=*length; proto_tree_add_item (reqFileId_tree, hf_sml_reqFileId, tvb, *offset, *data, ENC_NA); *offset+=*data; +} -}; static void field_serverId(tvbuff_t *tvb, proto_tree *insert_tree, guint *offset, guint *data, guint *length){ proto_item *serverId = NULL; proto_tree *serverId_tree = NULL; @@ -504,17 +485,16 @@ static void field_serverId(tvbuff_t *tvb, proto_tree *insert_tree, guint *offset serverId = proto_tree_add_bytes_format (insert_tree,hf_sml_serverId, tvb, *offset, *length + *data, NULL, "Server ID %s", (*data == 0)? ": NOT SET" : ""); if (*data > 0){ - serverId_tree = proto_item_add_subtree (serverId , ett_sml_serverId); proto_tree_add_text (serverId_tree, tvb, *offset, *length, "Length: %d %s", *data, plurality(*data, "octet", "octets")); *offset+=*length; proto_tree_add_item (serverId_tree, hf_sml_serverId, tvb, *offset, *data, ENC_NA); *offset+=*data; - } - else *offset+=1; + else + *offset+=1; +} -}; static void field_username(tvbuff_t *tvb, proto_tree *insert_tree, guint *offset, guint *data, guint *length){ proto_item *username = NULL; proto_tree *username_tree = NULL; @@ -524,38 +504,35 @@ static void field_username(tvbuff_t *tvb, proto_tree *insert_tree, guint *offset username = proto_tree_add_string_format (insert_tree,hf_sml_username, tvb, *offset, *length + *data, NULL, "Username %s", (*data == 0)? ": NOT SET" : ""); if (*data > 0){ - username_tree = proto_item_add_subtree (username , ett_sml_username); proto_tree_add_text (username_tree, tvb, *offset, *length, "Length: %d %s", *data, plurality(*data, "octet", "octets")); *offset+=*length; proto_tree_add_item (username_tree, hf_sml_username, tvb, *offset, *data, ENC_ASCII | ENC_BIG_ENDIAN); *offset+=*data; - } - else *offset+=1; + else + *offset+=1; +} -}; static void field_password(tvbuff_t *tvb, proto_tree *insert_tree, guint *offset, guint *data, guint *length){ proto_item *password = NULL; proto_tree *password_tree = NULL; - /*Password OPTIONAL*/ get_length(tvb, offset, data, length); password = proto_tree_add_string_format (insert_tree,hf_sml_password, tvb, *offset, *length + *data, NULL, "Password %s", (*data == 0)? ": NOT SET" : ""); if (*data > 0) { - password_tree = proto_item_add_subtree (password, ett_sml_password); proto_tree_add_text (password_tree, tvb, *offset, *length, "Length: %d %s", *data, plurality(*data, "octet", "octets")); *offset+=*length; proto_tree_add_item (password_tree, hf_sml_password, tvb, *offset, *data, ENC_ASCII | ENC_BIG_ENDIAN); *offset+=*data; - } - else *offset+=1; + else + *offset+=1; +} -}; static void field_smlVersion(tvbuff_t *tvb, proto_tree *insert_tree, guint *offset, guint *data, guint *length){ proto_item *smlVersion = NULL; proto_tree *smlVersion_tree = NULL; @@ -565,18 +542,17 @@ static void field_smlVersion(tvbuff_t *tvb, proto_tree *insert_tree, guint *offs smlVersion = proto_tree_add_uint_format (insert_tree, hf_sml_smlVersion, tvb, *offset, *length + *data, *length + *data, "SML-Version %s", (*data == 0)? ": Version 1" : ""); if (*data > 0) { - smlVersion_tree = proto_item_add_subtree (smlVersion, ett_sml_smlVersion); proto_tree_add_item (smlVersion_tree, hf_sml_datatype, tvb, *offset, 1, ENC_NA); *offset+=1; proto_tree_add_item (smlVersion_tree, hf_sml_smlVersion, tvb, *offset, 1,ENC_NA); *offset+=1; - } - else *offset+=1; + else + *offset+=1; +} -}; static void field_globalSignature(tvbuff_t *tvb, proto_tree *insert_tree, guint *offset, guint *data, guint *length){ proto_item *globalSignature = NULL; proto_tree *globalSignature_tree = NULL; @@ -587,16 +563,16 @@ static void field_globalSignature(tvbuff_t *tvb, proto_tree *insert_tree, guint globalSignature = proto_tree_add_bytes_format (insert_tree, hf_sml_globalSignature, tvb, *offset, *length + *data, NULL, "global Signature %s", (*data == 0)? ": NOT SET" : ""); if (*data > 0){ - globalSignature_tree = proto_item_add_subtree (globalSignature, ett_sml_globalSignature); proto_tree_add_text (globalSignature_tree, tvb, *offset, *length, "Length: %d %s", *data, plurality(*data, "octet", "octets")); *offset+=*length; proto_tree_add_item (globalSignature_tree, hf_sml_globalSignature, tvb, *offset, *data, ENC_NA); *offset+=*data; } - else *offset+=1; + else + *offset+=1; +} -}; static void field_listName(tvbuff_t *tvb, proto_tree *insert_tree, guint *offset, guint *data, guint *length){ proto_item *listName = NULL; proto_tree *listName_tree = NULL; @@ -606,17 +582,16 @@ static void field_listName(tvbuff_t *tvb, proto_tree *insert_tree, guint *offset listName = proto_tree_add_bytes_format (insert_tree,hf_sml_listName, tvb, *offset, *length + *data, NULL, "List Name %s", (*data == 0)? ": NOT SET" : ""); if (*data > 0) { - listName_tree = proto_item_add_subtree (listName, ett_sml_listName); proto_tree_add_text (listName_tree, tvb, *offset, *length, "Length: %d %s", *length ,plurality(*data, "octet", "octets")); *offset+=*length; proto_tree_add_item (listName_tree, hf_sml_listName, tvb, *offset, *data, ENC_NA); *offset+=*data; - } - else *offset+=1; + else + *offset+=1; +} -}; static void field_objName(tvbuff_t *tvb, proto_tree *insert_tree, guint *offset, guint *data, guint *length){ proto_item *objName = NULL; proto_tree *objName_tree = NULL; @@ -630,27 +605,26 @@ static void field_objName(tvbuff_t *tvb, proto_tree *insert_tree, guint *offset, *offset+=*length; proto_tree_add_item (objName_tree, hf_sml_objName, tvb, *offset, *data, ENC_NA); *offset+=*data; - -}; +} + static void field_status(tvbuff_t *tvb, proto_tree *insert_tree, guint *offset, guint *data, guint *length){ proto_item *status = NULL; proto_tree *status_tree = NULL; get_length(tvb, offset, data, length); status = proto_tree_add_text (insert_tree, tvb, *offset, *length + *data ,"status %s", (*data == 0)? ": NOT SET" : ""); - - if (*data > 0){ + if (*data > 0){ status_tree = proto_item_add_subtree (status, ett_sml_status); proto_tree_add_item (status_tree, hf_sml_datatype, tvb, *offset, 1, ENC_NA); *offset+=1; proto_tree_add_item (status_tree, hf_sml_status, tvb, *offset, *data, ENC_BIG_ENDIAN); *offset+= *data; } - else *offset+=1; - + else + *offset+=1; +} -}; static void field_unit(tvbuff_t *tvb, proto_tree *insert_tree, guint *offset, guint *data, guint *length){ proto_item *unit = NULL; proto_tree *unit_tree = NULL; @@ -659,25 +633,24 @@ static void field_unit(tvbuff_t *tvb, proto_tree *insert_tree, guint *offset, gu get_length(tvb, offset, data, length); unit = proto_tree_add_uint_format (insert_tree, hf_sml_unit, tvb, *offset, *length + *data, *length + *data, "Unit %s", (*data == 0)? ": NOT SET" : ""); if (*data > 0) { - unit_tree = proto_item_add_subtree (unit, ett_sml_unit); proto_tree_add_item (unit_tree, hf_sml_datatype, tvb, *offset, 1, ENC_NA); *offset+=1; proto_tree_add_item(unit_tree, hf_sml_unit, tvb, *offset, 1, ENC_NA); *offset+=1; - } - else *offset+=1; -}; -static void field_scaler(tvbuff_t *tvb, proto_tree *insert_tree, guint *offset, guint *data, guint *length){ + else + *offset+=1; +} +static void field_scaler(tvbuff_t *tvb, proto_tree *insert_tree, guint *offset, guint *data, guint *length){ proto_item *scaler = NULL; proto_tree *scaler_tree = NULL; /*Scaler OPTIONAL*/ get_length(tvb, offset, data, length); scaler = proto_tree_add_uint_format (insert_tree, hf_sml_scaler, tvb, *offset, *length + *data, *length + *data, "Scaler %s", (*data == 0)? ": NOT SET" : ""); - + if (*data > 0){ scaler_tree = proto_item_add_subtree (scaler, ett_sml_scaler); proto_tree_add_item (scaler_tree, hf_sml_datatype, tvb, *offset, 1, ENC_NA); @@ -685,10 +658,11 @@ static void field_scaler(tvbuff_t *tvb, proto_tree *insert_tree, guint *offset, proto_tree_add_item(scaler_tree, hf_sml_scaler, tvb, *offset, 1, ENC_NA); *offset+=1; } - else *offset+=1; -}; -static void field_valueSignature(tvbuff_t *tvb, proto_tree *insert_tree, guint *offset, guint *data, guint *length){ + else + *offset+=1; +} +static void field_valueSignature(tvbuff_t *tvb, proto_tree *insert_tree, guint *offset, guint *data, guint *length){ proto_item *valueSignature = NULL; proto_tree *valueSignature_tree = NULL; @@ -697,19 +671,17 @@ static void field_valueSignature(tvbuff_t *tvb, proto_tree *insert_tree, guint * valueSignature = proto_tree_add_bytes_format (insert_tree, hf_sml_valueSignature, tvb, *offset, *length + *data, NULL, "ValueSignature %s", (*data == 0)? ": NOT SET" : ""); if (*data > 0){ - valueSignature_tree = proto_item_add_subtree (valueSignature, ett_sml_valueSignature); proto_tree_add_text (valueSignature_tree, tvb, *offset, *length, "Length: %d %s", *data, plurality(*data, "octet", "octets")); *offset+=*length; proto_tree_add_item (valueSignature_tree, hf_sml_valueSignature, tvb, *offset, *data, ENC_NA); *offset+=*data; } - else *offset+=1; - + else + *offset+=1; +} -}; static void field_parameterTreePath(tvbuff_t *tvb, proto_tree *insert_tree, guint *offset, guint *data, guint *length){ - proto_item *parameterTreePath = NULL; proto_tree *parameterTreePath_tree = NULL; @@ -722,10 +694,9 @@ static void field_parameterTreePath(tvbuff_t *tvb, proto_tree *insert_tree, guin *offset+=*length; proto_tree_add_item (parameterTreePath_tree, hf_sml_parameterTreePath, tvb, *offset, *data, ENC_NA); *offset+=*data; +} -}; static void field_ObjReqEntry(tvbuff_t *tvb, proto_tree *insert_tree, guint *offset, guint *data, guint *length){ - proto_item *object_list_Entry = NULL; proto_tree *object_list_Entry_tree = NULL; @@ -737,25 +708,23 @@ static void field_ObjReqEntry(tvbuff_t *tvb, proto_tree *insert_tree, guint *off *offset+=*length; proto_tree_add_item (object_list_Entry_tree, hf_sml_object_list_Entry, tvb, *offset, *data, ENC_NA); *offset+=*data; - -}; -static void field_regPeriod(tvbuff_t *tvb, proto_tree *insert_tree, guint *offset, guint *data, guint *length){ +} +static void field_regPeriod(tvbuff_t *tvb, proto_tree *insert_tree, guint *offset, guint *data, guint *length){ proto_item *regPeriod = NULL; proto_tree *regPeriod_tree = NULL; get_length(tvb, offset, data, length); regPeriod = proto_tree_add_text (insert_tree, tvb, *offset, *length + *data, "regPeriod"); - + regPeriod_tree = proto_item_add_subtree (regPeriod, ett_sml_regPeriod); proto_tree_add_item (regPeriod_tree, hf_sml_datatype, tvb, *offset, 1, ENC_NA); *offset+=1; proto_tree_add_item (regPeriod_tree, hf_sml_regPeriod, tvb, *offset, *data, ENC_BIG_ENDIAN); *offset+=*data; - -}; -static void field_rawdata(tvbuff_t *tvb, proto_tree *insert_tree, guint *offset, guint *data, guint *length){ +} +static void field_rawdata(tvbuff_t *tvb, proto_tree *insert_tree, guint *offset, guint *data, guint *length){ proto_item *rawdata = NULL; proto_tree *rawdata_tree = NULL; @@ -764,18 +733,17 @@ static void field_rawdata(tvbuff_t *tvb, proto_tree *insert_tree, guint *offset, rawdata = proto_tree_add_bytes_format (insert_tree, hf_sml_rawdata, tvb, *offset, *length + *data, NULL, "rawdata %s", (*data == 0)? ": NOT SET" : ""); if (*data > 0){ - rawdata_tree = proto_item_add_subtree (rawdata, ett_sml_rawdata); proto_tree_add_text (rawdata_tree, tvb, *offset, *length, "Length: %d %s", *data, plurality(*data, "octet", "octets")); *offset+=*length; proto_tree_add_item (rawdata_tree, hf_sml_rawdata, tvb, *offset, *data, ENC_NA); *offset+=*data; } - else *offset+=1; + else + *offset+=1; +} -}; static void field_periodSignature(tvbuff_t *tvb, proto_tree *insert_tree, guint *offset, guint *data, guint *length){ - proto_item *periodSignature = NULL; proto_tree *periodSignature_tree = NULL; @@ -784,18 +752,17 @@ static void field_periodSignature(tvbuff_t *tvb, proto_tree *insert_tree, guint periodSignature = proto_tree_add_bytes_format (insert_tree, hf_sml_periodSignature, tvb, *offset, *length + *data, NULL,"periodSignature %s", (*data == 0)? ": NOT SET" : ""); if (*data > 0){ - periodSignature_tree = proto_item_add_subtree (periodSignature, ett_sml_periodSignature); proto_tree_add_text (periodSignature_tree, tvb, *offset, *length, "Length: %d %s", *data, plurality(*data, "octet", "octets")); *offset+=*length; proto_tree_add_item (periodSignature_tree, hf_sml_periodSignature, tvb, *offset, *data, ENC_NA); *offset+=*data; } - else *offset+=1; + else + *offset+=1; +} -}; static void field_actTime(tvbuff_t *tvb, proto_tree *insert_tree, guint *offset, guint *data, guint *length){ - proto_item *actTime = NULL; proto_tree *actTime_tree = NULL; @@ -806,10 +773,9 @@ static void field_actTime(tvbuff_t *tvb, proto_tree *insert_tree, guint *offset, *offset+=1; proto_tree_add_item(actTime_tree, hf_sml_actTime, tvb, *offset, *data, ENC_BIG_ENDIAN); *offset+=*data; +} -}; static void field_valTime(tvbuff_t *tvb, proto_tree *insert_tree, guint *offset, guint *data, guint *length){ - proto_item *valTime = NULL; proto_tree *valTime_tree = NULL; @@ -820,11 +786,9 @@ static void field_valTime(tvbuff_t *tvb, proto_tree *insert_tree, guint *offset, *offset+=1; proto_tree_add_item(valTime_tree, hf_sml_valTime, tvb, *offset, *data, ENC_BIG_ENDIAN); *offset+=*data; - -}; +} static void TupelEntryTree(tvbuff_t *tvb, proto_tree *procParValue_tree, guint *offset){ - proto_item *TupelEntry = NULL; proto_item *SML_time = NULL; proto_item *secIndex = NULL; @@ -1071,11 +1035,9 @@ static void TupelEntryTree(tvbuff_t *tvb, proto_tree *procParValue_tree, guint * *offset+=data; proto_item_set_end(TupelEntry, tvb, *offset); - -}; +} static void child_tree(tvbuff_t *tvb, packet_info *pinfo, proto_tree *insert_tree, guint *offset, guint *data, guint *length){ - proto_item *parameterName = NULL; proto_item *procParValue = NULL; proto_item *child = NULL; @@ -1107,7 +1069,6 @@ static void child_tree(tvbuff_t *tvb, packet_info *pinfo, proto_tree *insert_tre proto_tree_add_item (parameterName_tree, hf_sml_parameterName, tvb, *offset, *data, ENC_NA); *offset+=*data; - /*procParValue OPTIONAL*/ check = tvb_get_guint8(tvb, *offset); @@ -1132,7 +1093,6 @@ static void child_tree(tvbuff_t *tvb, packet_info *pinfo, proto_tree *insert_tre *offset+=1; switch (check) { - case PROC_VALUE: /*value*/ sml_value(tvb, procParValue_tree, offset, data, length); @@ -1172,7 +1132,6 @@ static void child_tree(tvbuff_t *tvb, packet_info *pinfo, proto_tree *insert_tre expert_add_info_format(pinfo, NULL, PI_PROTOCOL, PI_ERROR, "error in Tupel"); return; } - break; case PROC_TIME: @@ -1198,13 +1157,11 @@ static void child_tree(tvbuff_t *tvb, packet_info *pinfo, proto_tree *insert_tre expert_add_info_format(pinfo, procParValue, PI_PROTOCOL, PI_WARN, "invalid procParValue"); break; } - proto_item_set_end(procParValue, tvb, *offset); } else { expert_add_info_format(pinfo, NULL, PI_PROTOCOL, PI_ERROR, "error in procParValue"); return; - } /*child list OPTIONAL*/ @@ -1212,12 +1169,9 @@ static void child_tree(tvbuff_t *tvb, packet_info *pinfo, proto_tree *insert_tre if (check == OPTIONAL){ child = proto_tree_add_text (insert_tree, tvb, *offset, 1, "Child List: NOT SET"); - child_list = proto_item_add_subtree(child, ett_sml_child); *offset+=1; - } else if ((check & 0x0F) != 0){ - if (check == 0x71){ get_length(tvb, offset, data, length); child = proto_tree_add_text(insert_tree, tvb, *offset, -1, "Child List with %d %s", *length + *data, plurality(*length + *data, "element", "elements")); @@ -1245,7 +1199,6 @@ static void child_tree(tvbuff_t *tvb, packet_info *pinfo, proto_tree *insert_tre *offset+=*length; for(i =0 ; i < repeat; i++){ - tree_Entry = proto_tree_add_text (child_list, tvb, *offset, -1, "tree_Entry"); tree_Entry_list = proto_item_add_subtree(tree_Entry, ett_sml_tree_Entry); @@ -1257,21 +1210,17 @@ static void child_tree(tvbuff_t *tvb, packet_info *pinfo, proto_tree *insert_tre child_tree(tvb, pinfo, tree_Entry_list, offset, data, length); proto_item_set_end(tree_Entry, tvb, *offset); - } proto_item_set_end(child, tvb, *offset); - } } else { expert_add_info_format(pinfo, NULL, PI_PROTOCOL, PI_ERROR, "invalid count of elements in child List"); - return; } -}; +} /*messagetypes*/ static void decode_PublicOpenReq (tvbuff_t *tvb, proto_tree *messagebodytree_list, guint *offset){ - guint data = 0; guint length = 0; @@ -1295,10 +1244,9 @@ static void decode_PublicOpenReq (tvbuff_t *tvb, proto_tree *messagebodytree_lis /*sml-Version OPTIONAL*/ field_smlVersion(tvb,messagebodytree_list, offset, &data, &length); +} -}; static void decode_PublicOpenRes (tvbuff_t *tvb, proto_tree *messagebodytree_list, guint *offset){ - proto_item *refTime = NULL; proto_item *SML_time = NULL; @@ -1320,7 +1268,6 @@ static void decode_PublicOpenRes (tvbuff_t *tvb, proto_tree *messagebodytree_lis /*ServerID*/ field_serverId(tvb,messagebodytree_list,offset, &data, &length); - /*RefTime Optional*/ get_length(tvb, offset, &data, &length); @@ -1328,11 +1275,8 @@ static void decode_PublicOpenRes (tvbuff_t *tvb, proto_tree *messagebodytree_lis proto_tree_add_text (messagebodytree_list, tvb, *offset, length + data, "refTime: NOT SET"); *offset+=1; } - else{ - /*SML TIME*/ - SML_time = proto_tree_add_text (messagebodytree_list, tvb, *offset, -1, "refTime"); SML_time_tree = proto_item_add_subtree (SML_time, ett_sml_time); *offset+=1; @@ -1349,13 +1293,11 @@ static void decode_PublicOpenRes (tvbuff_t *tvb, proto_tree *messagebodytree_lis *offset+=data; proto_item_set_end(SML_time,tvb,*offset); } - /*sml-Version OPTIONAL*/ field_smlVersion(tvb, messagebodytree_list, offset, &data, &length); +} -}; static gboolean decode_GetProfile_List_Pack_Req (tvbuff_t *tvb, packet_info *pinfo, proto_tree *messagebodytree_list, guint *offset){ - proto_item *withRawdata = NULL; proto_item *SML_time = NULL; proto_item *beginnTime = NULL; @@ -1392,14 +1334,14 @@ static gboolean decode_GetProfile_List_Pack_Req (tvbuff_t *tvb, packet_info *pin withRawdata = proto_tree_add_uint_format (messagebodytree_list, hf_sml_withRawdata, tvb, *offset, data+length, data+length, "withRawdata %s", (data == 0)? ": NOT SET" : ""); if (data > 0) { - withRawdata_tree = proto_item_add_subtree (withRawdata, ett_sml_withRawdata); proto_tree_add_item (withRawdata_tree, hf_sml_datatype, tvb, *offset, 1, ENC_NA); *offset+=1; proto_tree_add_item (withRawdata_tree, hf_sml_withRawdata, tvb, *offset, 1, ENC_NA); *offset+=1; } - else *offset+=1; + else + *offset+=1; /*beginnTime OPTIONAL*/ get_length(tvb, offset, &data, &length); @@ -1408,9 +1350,7 @@ static gboolean decode_GetProfile_List_Pack_Req (tvbuff_t *tvb, packet_info *pin proto_tree_add_text (messagebodytree_list, tvb, *offset, length + data, "beginnTime: NOT SET"); *offset+=1; } - else { - /*SML TIME*/ SML_time = proto_tree_add_text (messagebodytree_list, tvb, *offset, -1, "beginnTime"); SML_time_tree = proto_item_add_subtree (SML_time, ett_sml_time); @@ -1429,7 +1369,6 @@ static gboolean decode_GetProfile_List_Pack_Req (tvbuff_t *tvb, packet_info *pin proto_item_set_end(SML_time,tvb,*offset); } - /*endTime OPTIONAL*/ get_length(tvb, offset, &data, &length); @@ -1437,9 +1376,7 @@ static gboolean decode_GetProfile_List_Pack_Req (tvbuff_t *tvb, packet_info *pin proto_tree_add_text (messagebodytree_list, tvb, *offset, length + data, "endTime: NOT SET"); *offset+=1; } - else { - /*SML TIME*/ SML_time = proto_tree_add_text (messagebodytree_list, tvb, *offset, -1, "endTime"); SML_time_tree = proto_item_add_subtree (SML_time, ett_sml_time); @@ -1479,7 +1416,6 @@ static gboolean decode_GetProfile_List_Pack_Req (tvbuff_t *tvb, packet_info *pin } proto_item_set_end(treepath, tvb, *offset); - /*object_list*/ if (tvb_get_guint8(tvb,*offset) == OPTIONAL){ proto_tree_add_text (messagebodytree_list, tvb, *offset, 1, "object_List: NOT SET"); @@ -1500,14 +1436,12 @@ static gboolean decode_GetProfile_List_Pack_Req (tvbuff_t *tvb, packet_info *pin return TRUE; } - *offset+=length; for (i=0; i< repeat; i++) { field_ObjReqEntry(tvb, object_list_list, offset, &data, &length); } proto_item_set_end(object_list, tvb, *offset); - } /*dasDetails*/ @@ -1518,7 +1452,6 @@ static gboolean decode_GetProfile_List_Pack_Req (tvbuff_t *tvb, packet_info *pin *offset+=1; } else if ((check & 0xF0) == LONG_LIST || (check & 0xF0) == SHORT_LIST){ - get_length(tvb, offset, &data, &length); dasDetails = proto_tree_add_text(messagebodytree_list, tvb, *offset, -1, "dasDetails with %d %s", length+data, plurality(length+data, "element", "elements")); dasDetails_list = proto_item_add_subtree(dasDetails, ett_sml_dasDetails); @@ -1531,11 +1464,10 @@ static gboolean decode_GetProfile_List_Pack_Req (tvbuff_t *tvb, packet_info *pin expert_add_info_format(pinfo, NULL, PI_PROTOCOL, PI_ERROR, "invalid count of elements in dasDetails"); return TRUE; } - return FALSE; -}; -static gboolean decode_GetProfilePackRes(tvbuff_t *tvb, packet_info *pinfo, proto_tree *messagebodytree_list, guint *offset){ +} +static gboolean decode_GetProfilePackRes(tvbuff_t *tvb, packet_info *pinfo, proto_tree *messagebodytree_list, guint *offset){ proto_item *SML_time = NULL; proto_item *treepath = NULL; proto_item *periodList = NULL; @@ -1556,7 +1488,6 @@ static gboolean decode_GetProfilePackRes(tvbuff_t *tvb, packet_info *pinfo, prot proto_tree *valuelist_list = NULL; proto_tree *value_List_Entry_list = NULL; - guint i = 0; guint d = 0; guint repeat = 0; @@ -1594,7 +1525,6 @@ static gboolean decode_GetProfilePackRes(tvbuff_t *tvb, packet_info *pinfo, prot return TRUE; } - *offset+=length; for (i=0; i< repeat; i++) { @@ -1721,19 +1651,19 @@ static gboolean decode_GetProfilePackRes(tvbuff_t *tvb, packet_info *pinfo, prot profileSignature = proto_tree_add_bytes_format (messagebodytree_list, hf_sml_profileSignature, tvb, *offset, length+data, NULL, "profileSignature %s", (data == 0)? ": NOT SET" : ""); if (data > 0){ - profileSignature_tree = proto_item_add_subtree (profileSignature, ett_sml_profileSignature); proto_tree_add_text (profileSignature_tree, tvb, *offset, length, "Length: %d %s", data, plurality(data, "octet", "octets")); *offset+=length; proto_tree_add_item (profileSignature_tree, hf_sml_profileSignature, tvb, *offset, data, ENC_NA); *offset+=data; } - else *offset+=1; + else + *offset+=1; return FALSE; -}; -static gboolean decode_GetProfileListRes(tvbuff_t *tvb, packet_info *pinfo, proto_tree *messagebodytree_list, guint *offset){ +} +static gboolean decode_GetProfileListRes(tvbuff_t *tvb, packet_info *pinfo, proto_tree *messagebodytree_list, guint *offset){ proto_item *SML_time = NULL; proto_item *treepath = NULL; proto_item *periodList = NULL; @@ -1794,7 +1724,6 @@ static gboolean decode_GetProfileListRes(tvbuff_t *tvb, packet_info *pinfo, prot *offset+=1; } else { - /*SML TIME*/ SML_time = proto_tree_add_text (messagebodytree_list, tvb, *offset, -1, "valTime"); SML_time_tree = proto_item_add_subtree (SML_time, ett_sml_time); @@ -1808,7 +1737,6 @@ static gboolean decode_GetProfileListRes(tvbuff_t *tvb, packet_info *pinfo, prot /*Status*/ field_status(tvb, messagebodytree_list, offset, &data, &length); - /*period-List*/ get_length(tvb, offset, &data, &length); repeat = (data+length); @@ -1848,7 +1776,6 @@ static gboolean decode_GetProfileListRes(tvbuff_t *tvb, packet_info *pinfo, prot field_valueSignature(tvb, periodList_Entry_list, offset, &data, &length); proto_item_set_end(periodList_Entry, tvb, *offset); - } proto_item_set_end(periodList, tvb, *offset); @@ -1859,9 +1786,9 @@ static gboolean decode_GetProfileListRes(tvbuff_t *tvb, packet_info *pinfo, prot field_periodSignature(tvb, messagebodytree_list, offset, &data, &length); return FALSE; -}; -static void decode_GetListReq (tvbuff_t *tvb, proto_tree *messagebodytree_list, guint *offset){ +} +static void decode_GetListReq (tvbuff_t *tvb, proto_tree *messagebodytree_list, guint *offset){ guint data = 0; guint length = 0; @@ -1879,11 +1806,9 @@ static void decode_GetListReq (tvbuff_t *tvb, proto_tree *messagebodytree_list, /*listName*/ field_listName(tvb,messagebodytree_list,offset, &data, &length); +} - -}; static gboolean decode_GetListRes (tvbuff_t *tvb, packet_info *pinfo, proto_tree *messagebodytree_list, guint *offset){ - proto_item *actSensorTime = NULL; proto_item *valList = NULL; proto_item *listSignature = NULL; @@ -1919,9 +1844,7 @@ static gboolean decode_GetListRes (tvbuff_t *tvb, packet_info *pinfo, proto_tree proto_tree_add_text (messagebodytree_list, tvb, *offset, length + data, "actSensorTime: NOT SET"); *offset+=1; } - else { - /*SML TIME*/ SML_time = proto_tree_add_text (messagebodytree_list, tvb, *offset, -1, "actSensorTime"); SML_time_tree = proto_item_add_subtree (SML_time, ett_sml_time); @@ -1940,8 +1863,6 @@ static gboolean decode_GetListRes (tvbuff_t *tvb, packet_info *pinfo, proto_tree proto_item_set_end(SML_time,tvb,*offset); } - - /*valList*/ get_length(tvb, offset, &data, &length); repeat = (length + data); @@ -1960,7 +1881,6 @@ static gboolean decode_GetListRes (tvbuff_t *tvb, packet_info *pinfo, proto_tree *offset+=length; for (i=0; i < repeat; i++){ - get_length(tvb, offset, &data, &length); valList = proto_tree_add_text (valtree_list, tvb, *offset, -1, "valListEntry"); valList_list = proto_item_add_subtree (valList, ett_sml_valList); @@ -1980,7 +1900,6 @@ static gboolean decode_GetListRes (tvbuff_t *tvb, packet_info *pinfo, proto_tree *offset+=1; } else { - /*SML TIME*/ SML_time = proto_tree_add_text (valList_list, tvb, *offset, -1, "valTime"); SML_time_tree = proto_item_add_subtree (SML_time, ett_sml_time); @@ -1991,7 +1910,6 @@ static gboolean decode_GetListRes (tvbuff_t *tvb, packet_info *pinfo, proto_tree proto_item_set_end(SML_time, tvb, *offset); } - /*unit OPTIONAL*/ field_unit(tvb, valList_list, offset, &data, &length); @@ -2008,21 +1926,19 @@ static gboolean decode_GetListRes (tvbuff_t *tvb, packet_info *pinfo, proto_tree } proto_item_set_end(valtree, tvb, *offset); - /*List Signature OPTIONAL*/ get_length(tvb, offset, &data, &length); listSignature = proto_tree_add_bytes_format (messagebodytree_list, hf_sml_listSignature, tvb, *offset, length+data, NULL, "ListSignature %s", (data == 0)? ": NOT SET" : ""); if (data > 0){ - listSignature_tree = proto_item_add_subtree (listSignature, ett_sml_listSignature); proto_tree_add_text (listSignature_tree, tvb, *offset, length, "Length: %d %s", data, plurality(data, "byte", "bytes")); *offset+=length; proto_tree_add_item (listSignature_tree, hf_sml_listSignature, tvb, *offset, data, ENC_NA); *offset+=data; } - else *offset+=1; - + else + *offset+=1; /*actGatewayTime OPTIONAL*/ get_length(tvb, offset, &data, &length); @@ -2032,7 +1948,6 @@ static gboolean decode_GetListRes (tvbuff_t *tvb, packet_info *pinfo, proto_tree *offset+=1; } else{ - /*SML TIME*/ SML_time = proto_tree_add_text (messagebodytree_list, tvb, *offset, -1, "actGatewayTime"); SML_time_tree = proto_item_add_subtree (SML_time, ett_sml_time); @@ -2049,11 +1964,10 @@ static gboolean decode_GetListRes (tvbuff_t *tvb, packet_info *pinfo, proto_tree *offset+=data; proto_item_set_end(SML_time,tvb,*offset); } - return FALSE; -}; -static gboolean decode_GetProcParameterReq(tvbuff_t *tvb, packet_info *pinfo, proto_tree *messagebodytree_list, guint *offset){ +} +static gboolean decode_GetProcParameterReq(tvbuff_t *tvb, packet_info *pinfo, proto_tree *messagebodytree_list, guint *offset){ proto_item *treepath = NULL; proto_item *attribute = NULL; @@ -2096,26 +2010,24 @@ static gboolean decode_GetProcParameterReq(tvbuff_t *tvb, packet_info *pinfo, pr } proto_item_set_end(treepath, tvb, *offset); - /*attribute*/ get_length(tvb, offset, &data, &length); attribute = proto_tree_add_bytes_format (messagebodytree_list,hf_sml_attribute, tvb, *offset, length+data, NULL, "attribute %s", (data == 0)? ": NOT SET" : ""); if (data > 0) { - attribute_tree = proto_item_add_subtree (attribute, ett_sml_attribute); proto_tree_add_text (attribute_tree, tvb, *offset, length, "Length: %d %s", data, plurality(data, "octet", "octets")); *offset+=length; proto_tree_add_item (attribute_tree, hf_sml_attribute, tvb, *offset, data, ENC_NA); *offset+=data; - } - else *offset+=1; + else + *offset+=1; return FALSE; -}; -static gboolean decode_GetProcParameterRes(tvbuff_t *tvb, packet_info *pinfo, proto_tree *messagebodytree_list, guint *offset){ +} +static gboolean decode_GetProcParameterRes(tvbuff_t *tvb, packet_info *pinfo, proto_tree *messagebodytree_list, guint *offset){ proto_item *treepath = NULL; proto_item *parameterTree =NULL; @@ -2167,11 +2079,10 @@ static gboolean decode_GetProcParameterRes(tvbuff_t *tvb, packet_info *pinfo, pr child_tree(tvb, pinfo,parameterTree_list, offset, &data, &length); proto_item_set_end(parameterTree, tvb, *offset); - return FALSE; -}; -static gboolean decode_SetProcParameterReq(tvbuff_t *tvb, packet_info *pinfo,proto_tree *messagebodytree_list, guint *offset){ +} +static gboolean decode_SetProcParameterReq(tvbuff_t *tvb, packet_info *pinfo,proto_tree *messagebodytree_list, guint *offset){ proto_item *treepath = NULL; proto_item *parameterTree = NULL; @@ -2214,7 +2125,6 @@ static gboolean decode_SetProcParameterReq(tvbuff_t *tvb, packet_info *pinfo,pro } proto_item_set_end(treepath, tvb, *offset); - /*prameterTree*/ get_length(tvb, offset, &data, &length); parameterTree = proto_tree_add_text(messagebodytree_list, tvb, *offset, -1, "prameterTree with %d %s", length+data, plurality(length+data, "element", "elements")); @@ -2230,11 +2140,10 @@ static gboolean decode_SetProcParameterReq(tvbuff_t *tvb, packet_info *pinfo,pro child_tree(tvb, pinfo,parameterTree_list, offset, &data, &length); proto_item_set_end(parameterTree, tvb, *offset); - return FALSE; -}; -static gboolean decode_AttentionRes(tvbuff_t *tvb, packet_info *pinfo, proto_tree *messagebodytree_list, guint *offset){ +} +static gboolean decode_AttentionRes(tvbuff_t *tvb, packet_info *pinfo, proto_tree *messagebodytree_list, guint *offset){ proto_item *attentionNo = NULL; proto_item *attentionMsg = NULL; proto_item *attentionDetails = NULL; @@ -2277,11 +2186,11 @@ static gboolean decode_AttentionRes(tvbuff_t *tvb, packet_info *pinfo, proto_tre proto_tree_add_item (attentionMsg_tree, hf_sml_attentionMsg, tvb, *offset, data, ENC_ASCII | ENC_BIG_ENDIAN); *offset+=data; } - else *offset+=1; + else + *offset+=1; /*attentiondetails*/ if (tvb_get_guint8(tvb,*offset) == OPTIONAL){ - proto_tree_add_text (messagebodytree_list, tvb, *offset, 1, "attentionDetails: NOT SET"); *offset+=1; } @@ -2302,11 +2211,10 @@ static gboolean decode_AttentionRes(tvbuff_t *tvb, packet_info *pinfo, proto_tre } return FALSE; -}; +} /*dissect SML-File*/ static void dissect_sml_file(tvbuff_t *tvb, packet_info *pinfo, gint *offset, proto_tree *sml_tree){ - proto_item *file = NULL; proto_item *mainlist = NULL; proto_item *trans = NULL; @@ -2347,34 +2255,31 @@ static void dissect_sml_file(tvbuff_t *tvb, packet_info *pinfo, gint *offset, pr guint start_offset; start_offset = *offset; - end_offset = tvb_reported_length_remaining(tvb, *offset); + if (end_offset <= 0){ + return; + } if (tvb_get_ntoh40(tvb, end_offset-8) != ESC_SEQ_END && pinfo->can_desegment){ if (tvb_get_guint8(tvb, end_offset-1) != ZERO){ - - pinfo->desegment_offset = start_offset; - pinfo->desegment_len = DESEGMENT_ONE_MORE_SEGMENT; - return; + pinfo->desegment_offset = start_offset; + pinfo->desegment_len = DESEGMENT_ONE_MORE_SEGMENT; + return; } else if (tvb_get_guint8(tvb, end_offset-4) != UNSIGNED16 && tvb_get_guint8(tvb, end_offset-3) != UNSIGNED8){ - - pinfo->desegment_offset = start_offset; - pinfo->desegment_len = DESEGMENT_ONE_MORE_SEGMENT; - return; + pinfo->desegment_offset = start_offset; + pinfo->desegment_len = DESEGMENT_ONE_MORE_SEGMENT; + return; } } - while(!close1 && !close2){ - if (sml_reassemble){ file = proto_tree_add_text(sml_tree,tvb, *offset, -1 , "----SML-File----"); } /*check if escape*/ if (tvb_get_ntohl(tvb, *offset) == ESC_SEQ){ - crc_file_len = *offset; /*Escape Start*/ proto_tree_add_item (sml_tree, hf_sml_esc, tvb, *offset, 4, ENC_BIG_ENDIAN); @@ -2391,14 +2296,13 @@ static void dissect_sml_file(tvbuff_t *tvb, packet_info *pinfo, gint *offset, pr } } - while (!close1){ crc_msg_len = *offset; /*List*/ get_length(tvb, offset, &data, &length); mainlist = proto_tree_add_text (sml_tree, tvb, *offset, -1, "List with %d %s", length+data, plurality(length+data, "element", "elements")); - + mainlist_list = proto_item_add_subtree (mainlist, ett_sml_mainlist); if (tvb_get_guint8(tvb, *offset) != LIST_6_ELEMENTS) { expert_add_info_format(pinfo, mainlist, PI_PROTOCOL, PI_ERROR, "invalid count of elements"); @@ -2462,7 +2366,6 @@ static void dissect_sml_file(tvbuff_t *tvb, packet_info *pinfo, gint *offset, pr *offset+=length; switch (messagebody_switch){ - case OPEN_REQ: col_append_str (pinfo->cinfo, COL_INFO, "OpenReq; "); proto_item_append_text(mainlist, " [Open Request]"); @@ -2473,7 +2376,6 @@ static void dissect_sml_file(tvbuff_t *tvb, packet_info *pinfo, gint *offset, pr proto_item_append_text(mainlist, " [Open Response]"); decode_PublicOpenRes(tvb, messagebodytree_list, offset); break; - case CLOSE_REQ: col_append_str (pinfo->cinfo, COL_INFO, "CloseReq; "); proto_item_append_text(mainlist, " [Close Request]"); @@ -2484,7 +2386,6 @@ static void dissect_sml_file(tvbuff_t *tvb, packet_info *pinfo, gint *offset, pr proto_item_append_text(mainlist, " [Close Response]"); field_globalSignature(tvb, messagebodytree_list, offset, &data, &length); break; - case PROFILEPACK_REQ: col_append_str (pinfo->cinfo, COL_INFO, "GetProfilePackReq; "); proto_item_append_text(mainlist, " [GetProfilePack Request]"); @@ -2495,7 +2396,6 @@ static void dissect_sml_file(tvbuff_t *tvb, packet_info *pinfo, gint *offset, pr proto_item_append_text(mainlist, " [GetProfilePack Response]"); msg_error = decode_GetProfilePackRes(tvb, pinfo,messagebodytree_list, offset); break; - case PROFILELIST_REQ: col_append_str (pinfo->cinfo, COL_INFO, "GetProfileListReq; "); proto_item_append_text(mainlist, " [GetProfileList Request]"); @@ -2506,7 +2406,6 @@ static void dissect_sml_file(tvbuff_t *tvb, packet_info *pinfo, gint *offset, pr proto_item_append_text(mainlist, " [GetProfileList Response]"); msg_error = decode_GetProfileListRes(tvb, pinfo,messagebodytree_list, offset); break; - case GETPROCPARAMETER_REQ: col_append_str (pinfo->cinfo, COL_INFO, "GetProcParameterReq; "); proto_item_append_text(mainlist, " [GetProcParameter Request]"); @@ -2517,13 +2416,11 @@ static void dissect_sml_file(tvbuff_t *tvb, packet_info *pinfo, gint *offset, pr proto_item_append_text(mainlist, " [GetProcParameter Response]"); msg_error = decode_GetProcParameterRes(tvb, pinfo,messagebodytree_list, offset); break; - case SETPROCPARAMETER_REQ: col_append_str (pinfo->cinfo, COL_INFO, "SetProcParameterReq; "); proto_item_append_text(mainlist, " [SetProcParameter Request]"); msg_error = decode_SetProcParameterReq(tvb, pinfo,messagebodytree_list, offset); break; - case GETLIST_REQ: col_append_str (pinfo->cinfo, COL_INFO, "GetListReq; "); proto_item_append_text(mainlist, " [GetList Request]"); @@ -2534,14 +2431,11 @@ static void dissect_sml_file(tvbuff_t *tvb, packet_info *pinfo, gint *offset, pr proto_item_append_text(mainlist, " [GetList Response]"); msg_error = decode_GetListRes(tvb, pinfo,messagebodytree_list, offset); break; - case ATTENTION: col_append_str (pinfo->cinfo, COL_INFO, "AttentionRes; "); proto_item_append_text(mainlist, " [Attention Response]"); msg_error = decode_AttentionRes(tvb, pinfo,messagebodytree_list, offset); break; - - default : expert_add_info_format(pinfo, messagebodytree, PI_PROTOCOL, PI_ERROR, "unknown messagetype"); return; @@ -2572,7 +2466,6 @@ static void dissect_sml_file(tvbuff_t *tvb, packet_info *pinfo, gint *offset, pr *offset+=data; if (sml_crc_enabled) { - crc_msg_len = *offset - crc_msg_len - 3; crc_check = crc16_ccitt_tvb_offset(tvb, *offset - crc_msg_len - 3, crc_msg_len); crc_ref = tvb_get_letohs(tvb, *offset-2); @@ -2586,7 +2479,6 @@ static void dissect_sml_file(tvbuff_t *tvb, packet_info *pinfo, gint *offset, pr proto_tree_add_text (crc16_tree, tvb, *offset, 0, "[CRC Bad %X]", crc_check); expert_add_info_format(pinfo, crc16, PI_PROTOCOL, PI_WARN, "CRC error"); } - } else { proto_tree_add_text (crc16_tree, tvb, *offset, 0, "[CRC validation disabled]"); @@ -2602,11 +2494,9 @@ static void dissect_sml_file(tvbuff_t *tvb, packet_info *pinfo, gint *offset, pr return; } - proto_item_set_end(mainlist, tvb, *offset); - - if (tvb_reported_length_remaining(tvb, *offset) != 0){ + if (tvb_reported_length_remaining(tvb, *offset) > 0){ check = tvb_get_guint8(tvb, *offset); if (check == LIST_6_ELEMENTS){ @@ -2621,8 +2511,8 @@ static void dissect_sml_file(tvbuff_t *tvb, packet_info *pinfo, gint *offset, pr pinfo->desegment_len = DESEGMENT_ONE_MORE_SEGMENT; return; } - else return; - + else + return; } /*Padding*/ @@ -2640,7 +2530,6 @@ static void dissect_sml_file(tvbuff_t *tvb, packet_info *pinfo, gint *offset, pr *offset+=length; } - /*Escape Ende*/ if(tvb_get_ntoh40(tvb, *offset) != ESC_SEQ_END){ expert_add_info_format(pinfo, NULL, PI_PROTOCOL, PI_ERROR, "escapesequence error"); @@ -2649,7 +2538,6 @@ static void dissect_sml_file(tvbuff_t *tvb, packet_info *pinfo, gint *offset, pr proto_tree_add_item (sml_tree, hf_sml_esc, tvb, *offset, 4, ENC_BIG_ENDIAN); *offset+=4; - /*MSG END*/ msgend = proto_tree_add_item (sml_tree, hf_sml_end, tvb, *offset, 4, ENC_BIG_ENDIAN); msgend_tree = proto_item_add_subtree (msgend, ett_sml_msgend); @@ -2659,7 +2547,6 @@ static void dissect_sml_file(tvbuff_t *tvb, packet_info *pinfo, gint *offset, pr proto_tree_add_item (msgend_tree, hf_sml_crc16, tvb, *offset, 2, ENC_BIG_ENDIAN); *offset+=2; - if (sml_crc_enabled && sml_reassemble){ crc_file_len = *offset - crc_file_len - 2; crc_check = crc16_ccitt_tvb_offset(tvb,*offset-crc_file_len-2, crc_file_len); @@ -2674,19 +2561,16 @@ static void dissect_sml_file(tvbuff_t *tvb, packet_info *pinfo, gint *offset, pr proto_tree_add_text (msgend_tree, tvb, *offset, 0, "[CRC Bad %X]", crc_check); expert_add_info_format(pinfo, msgend, PI_PROTOCOL, PI_WARN, "CRC error (messages not reassembled ?)"); } - } else { proto_tree_add_text (msgend_tree, tvb, *offset, 0, "[CRC validation disabled]"); } - - available = tvb_reported_length_remaining(tvb, *offset); - if (available == 0){ + if (available <= 0){ close2 = TRUE; } - else if (available > 0){ + else { if (sml_reassemble){ proto_item_set_end(file, tvb, *offset); } @@ -2694,14 +2578,12 @@ static void dissect_sml_file(tvbuff_t *tvb, packet_info *pinfo, gint *offset, pr proto_tree_add_text(sml_tree,tvb, *offset, 0 , "---New SML File---"); } close1 = FALSE; - } } -}; +} /* main */ static void dissect_sml (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { - proto_item *sml_item = NULL; proto_tree *sml_tree = NULL; @@ -2712,34 +2594,19 @@ static void dissect_sml (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { return; } + col_add_str(pinfo->cinfo, COL_PROTOCOL, "SML"); + col_clear(pinfo->cinfo,COL_INFO); - if (check_col(pinfo->cinfo, COL_PROTOCOL)) - col_add_str(pinfo->cinfo, COL_PROTOCOL, "SML"); - - /* Clear out stuff in the info column */ - if(check_col(pinfo->cinfo,COL_INFO)){ - col_clear(pinfo->cinfo,COL_INFO); - - } - - if (tree) { - - /* create display subtree for the protocol */ - sml_item = proto_tree_add_item(tree, proto_sml, tvb, 0, -1, ENC_NA); - - sml_tree = proto_item_add_subtree(sml_item, ett_sml); - - dissect_sml_file(tvb, pinfo, &offset, sml_tree); - } -}; - + /* create display subtree for the protocol */ + sml_item = proto_tree_add_item(tree, proto_sml, tvb, 0, -1, ENC_NA); + sml_tree = proto_item_add_subtree(sml_item, ett_sml); + dissect_sml_file(tvb, pinfo, &offset, sml_tree); +} void proto_register_sml (void) { - module_t *sml_module; static hf_register_info hf[] = { - { &hf_sml_esc, { "Escape", "sml.esc", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }}, { &hf_sml_version_1, @@ -2877,11 +2744,9 @@ void proto_register_sml (void) { { &hf_sml_value_R3, { "value_R3", "sml.valueR3", FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL }}, { &hf_sml_value_R4, - { "value_R4", "sml.valueR4", FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL }}, - + { "value_R4", "sml.valueR4", FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL }} }; - /* Setup protocol subtree array */ static gint *ett[] = { &ett_sml, @@ -2974,30 +2839,22 @@ void proto_register_sml (void) { &ett_sml_value_R4, &ett_sml_tree_Entry, &ett_sml_dasDetails, - &ett_sml_attentionDetails, + &ett_sml_attentionDetails }; proto_sml = proto_register_protocol("Smart Message Language","SML", "sml"); - sml_module = prefs_register_protocol(proto_sml, proto_reg_handoff_sml); prefs_register_bool_preference (sml_module, "reassemble", "Enable reassemble", "Enable reassembling (default is enabled)", &sml_reassemble); - prefs_register_bool_preference (sml_module, "crc", "Enable crc calculation", "Enable crc (default is disabled)", &sml_crc_enabled); - prefs_register_uint_preference(sml_module, "tcp.port", "SML TCP Port", "Set the TCP port for SML (Default is 0), recommended port is 7259", 10, &tcp_port_pref); - prefs_register_uint_preference(sml_module, "udp.port", "SML UDP Port", "Set the UDP port for SML (Default is 0), recommended port is 7259", 10, &udp_port_pref); - proto_register_field_array(proto_sml, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); - } - void proto_reg_handoff_sml(void) { - static gboolean initialized = FALSE; static int old_tcp_port; static int old_udp_port; @@ -3017,8 +2874,8 @@ void proto_reg_handoff_sml(void) { dissector_add_uint("tcp.port", tcp_port_pref, sml_handle); dissector_add_uint("udp.port", udp_port_pref, sml_handle); - } + /* * Editor modelines - http://www.wireshark.org/tools/modelines.html * |