Fix "might be clobbered by 'longjmp' or 'vfork' [-Werror=clobbered]" warning from gcc 4.9

Rework code related to TRY_SCSI_CDB_ALLOC_LEN macro to simplify and clarify same.
Rename some vars to catch any incorrect usage.

Change-Id: Ibf9465c5ce7670aa1147e0c311c37e582ece427a
Reviewed-on: https://code.wireshark.org/review/1177
Reviewed-by: Bill Meier <wmeier@newsguy.com>
Tested-by: Bill Meier <wmeier@newsguy.com>
This commit is contained in:
Bill Meier 2014-04-16 18:45:45 -04:00
parent b9dd810c4c
commit d51cac21b1
3 changed files with 277 additions and 268 deletions

View File

@ -377,8 +377,8 @@ static const value_string scsi_feature_val[] = {
static value_string_ext scsi_feature_val_ext = VALUE_STRING_EXT_INIT(scsi_feature_val);
static void
dissect_mmc4_getconfiguration (tvbuff_t *tvb, packet_info *pinfo,
proto_tree *tree, guint offset,
dissect_mmc4_getconfiguration (tvbuff_t *tvb_a, packet_info *pinfo,
proto_tree *tree, guint offset_a,
gboolean isreq, gboolean iscdb,
guint payload_len _U_,
scsi_task_data_t *cdata)
@ -386,18 +386,16 @@ dissect_mmc4_getconfiguration (tvbuff_t *tvb, packet_info *pinfo,
{
gint32 len;
guint old_offset;
tvbuff_t *volatile tvb_v = tvb;
volatile guint offset_v = offset;
if (tree && isreq && iscdb) {
proto_tree_add_item (tree, hf_scsi_mmc_getconf_rt, tvb_v, offset_v+0, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_getconf_starting_feature, tvb_v, offset_v+1, 2, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_alloclen16, tvb_v, offset_v+6, 2, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_getconf_rt, tvb_a, offset_a+0, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_getconf_starting_feature, tvb_a, offset_a+1, 2, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_alloclen16, tvb_a, offset_a+6, 2, ENC_BIG_ENDIAN);
/* we need the alloc_len in the response */
if(cdata){
cdata->itlq->alloc_len=tvb_get_ntohs(tvb_v, offset_v+6);
cdata->itlq->alloc_len=tvb_get_ntohs(tvb_a, offset_a+6);
}
proto_tree_add_bitmask(tree, tvb, offset+8, hf_scsi_control,
proto_tree_add_bitmask(tree, tvb_a, offset_a+8, hf_scsi_control,
ett_scsi_control, cdb_control_fields, ENC_BIG_ENDIAN);
}
if(!isreq) {
@ -405,53 +403,53 @@ dissect_mmc4_getconfiguration (tvbuff_t *tvb, packet_info *pinfo,
return;
}
TRY_SCSI_CDB_ALLOC_LEN(pinfo, tvb_v, offset_v, cdata->itlq->alloc_len);
TRY_SCSI_CDB_ALLOC_LEN(cdata->itlq->alloc_len); /* (defines/initializes try_tvb & try_offset) */
len=tvb_get_ntohl(tvb_v, offset_v+0);
proto_tree_add_item (tree, hf_scsi_mmc_data_length, tvb_v, offset_v, 4, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_getconf_current_profile, tvb_v, offset_v+6, 2, ENC_BIG_ENDIAN);
offset_v+=8;
len=tvb_get_ntohl(try_tvb, try_offset+0);
proto_tree_add_item (tree, hf_scsi_mmc_data_length, try_tvb, try_offset, 4, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_getconf_current_profile, try_tvb, try_offset+6, 2, ENC_BIG_ENDIAN);
try_offset+=8;
len-=4;
while(len>0){
guint16 feature;
guint8 additional_length;
guint8 num_linksize;
feature=tvb_get_ntohs(tvb_v, offset_v);
proto_tree_add_item (tree, hf_scsi_mmc_feature, tvb_v, offset_v, 2, ENC_BIG_ENDIAN);
offset_v+=2;
proto_tree_add_item (tree, hf_scsi_mmc_feature_version, tvb_v, offset_v, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_feature_persistent, tvb_v, offset_v, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_feature_current, tvb_v, offset_v, 1, ENC_BIG_ENDIAN);
offset_v+=1;
additional_length=tvb_get_guint8(tvb_v, offset_v);
proto_tree_add_item (tree, hf_scsi_mmc_feature_additional_length, tvb_v, offset_v, 1, ENC_BIG_ENDIAN);
offset_v+=1;
old_offset=offset_v;
feature=tvb_get_ntohs(try_tvb, try_offset);
proto_tree_add_item (tree, hf_scsi_mmc_feature, try_tvb, try_offset, 2, ENC_BIG_ENDIAN);
try_offset+=2;
proto_tree_add_item (tree, hf_scsi_mmc_feature_version, try_tvb, try_offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_feature_persistent, try_tvb, try_offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_feature_current, try_tvb, try_offset, 1, ENC_BIG_ENDIAN);
try_offset+=1;
additional_length=tvb_get_guint8(try_tvb, try_offset);
proto_tree_add_item (tree, hf_scsi_mmc_feature_additional_length, try_tvb, try_offset, 1, ENC_BIG_ENDIAN);
try_offset+=1;
old_offset=try_offset;
switch(feature){
case 0x0000: /* profile list */
while(offset_v<(old_offset+additional_length)){
while(try_offset<(old_offset+additional_length)){
proto_item *it=NULL;
proto_tree *tr=NULL;
guint16 profile;
guint8 cur_profile;
if(tree){
it=proto_tree_add_text(tree, tvb_v, offset_v, 4, "Profile:");
it=proto_tree_add_text(tree, try_tvb, try_offset, 4, "Profile:");
tr=proto_item_add_subtree(it, ett_scsi_mmc_profile);
}
profile=tvb_get_ntohs(tvb_v, offset_v);
proto_tree_add_item (tr, hf_scsi_mmc_feature_profile, tvb_v, offset_v, 2, ENC_BIG_ENDIAN);
profile=tvb_get_ntohs(try_tvb, try_offset);
proto_tree_add_item (tr, hf_scsi_mmc_feature_profile, try_tvb, try_offset, 2, ENC_BIG_ENDIAN);
proto_item_append_text(it, "%s", val_to_str_ext(profile, &scsi_getconf_current_profile_val_ext, "Unknown 0x%04x"));
cur_profile=tvb_get_guint8(tvb_v, offset_v+2);
proto_tree_add_item (tr, hf_scsi_mmc_feature_profile_current, tvb_v, offset_v+2, 1, ENC_BIG_ENDIAN);
cur_profile=tvb_get_guint8(try_tvb, try_offset+2);
proto_tree_add_item (tr, hf_scsi_mmc_feature_profile_current, try_tvb, try_offset+2, 1, ENC_BIG_ENDIAN);
if(cur_profile&0x01){
proto_item_append_text(it, " [CURRENT PROFILE]");
}
offset_v+=4;
try_offset+=4;
}
break;
case 0x001d: /* multi-read */
@ -459,64 +457,64 @@ dissect_mmc4_getconfiguration (tvbuff_t *tvb, packet_info *pinfo,
/* no data for this one */
break;
case 0x001e: /* cd read */
proto_tree_add_item (tree, hf_scsi_mmc_feature_cdread_dap, tvb_v, offset_v, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_feature_cdread_c2flag, tvb_v, offset_v, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_feature_cdread_cdtext, tvb_v, offset_v, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_feature_cdread_dap, try_tvb, try_offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_feature_cdread_c2flag, try_tvb, try_offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_feature_cdread_cdtext, try_tvb, try_offset, 1, ENC_BIG_ENDIAN);
break;
case 0x0021: /* incremental streaming writeable */
proto_tree_add_item (tree, hf_scsi_mmc_feature_dts, tvb_v, offset_v, 2, ENC_BIG_ENDIAN);
offset_v+=2;
proto_tree_add_item (tree, hf_scsi_mmc_feature_isw_buf, tvb_v, offset_v, 1, ENC_BIG_ENDIAN);
offset_v+=1;
num_linksize=tvb_get_guint8(tvb_v, offset_v);
proto_tree_add_item (tree, hf_scsi_mmc_feature_isw_num_linksize, tvb_v, offset_v, 1, ENC_BIG_ENDIAN);
offset_v+=1;
proto_tree_add_item (tree, hf_scsi_mmc_feature_dts, try_tvb, try_offset, 2, ENC_BIG_ENDIAN);
try_offset+=2;
proto_tree_add_item (tree, hf_scsi_mmc_feature_isw_buf, try_tvb, try_offset, 1, ENC_BIG_ENDIAN);
try_offset+=1;
num_linksize=tvb_get_guint8(try_tvb, try_offset);
proto_tree_add_item (tree, hf_scsi_mmc_feature_isw_num_linksize, try_tvb, try_offset, 1, ENC_BIG_ENDIAN);
try_offset+=1;
while(num_linksize--){
proto_tree_add_item (tree, hf_scsi_mmc_feature_isw_linksize, tvb_v, offset_v, 1, ENC_BIG_ENDIAN);
offset_v+=1;
proto_tree_add_item (tree, hf_scsi_mmc_feature_isw_linksize, try_tvb, try_offset, 1, ENC_BIG_ENDIAN);
try_offset+=1;
}
break;
case 0x002a: /* dvd-rw */
proto_tree_add_item (tree, hf_scsi_mmc_feature_dvdrw_write, tvb_v, offset_v, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_feature_dvdrw_quickstart, tvb_v, offset_v, 2, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_feature_dvdrw_closeonly, tvb_v, offset_v, 2, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_feature_dvdrw_write, try_tvb, try_offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_feature_dvdrw_quickstart, try_tvb, try_offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_feature_dvdrw_closeonly, try_tvb, try_offset, 2, ENC_BIG_ENDIAN);
break;
case 0x002b: /* dvd-r */
proto_tree_add_item (tree, hf_scsi_mmc_feature_dvdr_write, tvb_v, offset_v, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_feature_dvdr_write, try_tvb, try_offset, 1, ENC_BIG_ENDIAN);
break;
case 0x002d: /* track at once */
proto_tree_add_item (tree, hf_scsi_mmc_feature_tao_buf, tvb_v, offset_v, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_feature_tao_rwraw, tvb_v, offset_v, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_feature_tao_rwpack, tvb_v, offset_v, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_feature_tao_testwrite, tvb_v, offset_v, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_feature_tao_cdrw, tvb_v, offset_v, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_feature_tao_rwsubcode, tvb_v, offset_v, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_feature_dts, tvb_v, offset_v+2, 2, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_feature_tao_buf, try_tvb, try_offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_feature_tao_rwraw, try_tvb, try_offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_feature_tao_rwpack, try_tvb, try_offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_feature_tao_testwrite, try_tvb, try_offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_feature_tao_cdrw, try_tvb, try_offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_feature_tao_rwsubcode, try_tvb, try_offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_feature_dts, try_tvb, try_offset+2, 2, ENC_BIG_ENDIAN);
break;
case 0x002e: /* session at once */
proto_tree_add_item (tree, hf_scsi_mmc_feature_sao_buf, tvb_v, offset_v, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_feature_sao_sao, tvb_v, offset_v, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_feature_sao_rawms, tvb_v, offset_v, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_feature_sao_raw, tvb_v, offset_v, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_feature_sao_testwrite, tvb_v, offset_v, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_feature_sao_cdrw, tvb_v, offset_v, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_feature_sao_rw, tvb_v, offset_v, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_feature_sao_mcsl, tvb_v, offset_v+1, 3, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_feature_sao_buf, try_tvb, try_offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_feature_sao_sao, try_tvb, try_offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_feature_sao_rawms, try_tvb, try_offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_feature_sao_raw, try_tvb, try_offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_feature_sao_testwrite, try_tvb, try_offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_feature_sao_cdrw, try_tvb, try_offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_feature_sao_rw, try_tvb, try_offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_feature_sao_mcsl, try_tvb, try_offset+1, 3, ENC_BIG_ENDIAN);
break;
case 0x002f: /* dvd-r/-rw*/
proto_tree_add_item (tree, hf_scsi_mmc_feature_dvdr_buf, tvb_v, offset_v, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_feature_dvdr_testwrite, tvb_v, offset_v, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_feature_dvdr_dvdrw, tvb_v, offset_v, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_feature_dvdr_buf, try_tvb, try_offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_feature_dvdr_testwrite, try_tvb, try_offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_feature_dvdr_dvdrw, try_tvb, try_offset, 1, ENC_BIG_ENDIAN);
break;
case 0x0108: /* logical unit serial number */
proto_tree_add_item (tree, hf_scsi_mmc_feature_lun_sn, tvb_v, offset_v, additional_length, ENC_ASCII|ENC_NA);
proto_tree_add_item (tree, hf_scsi_mmc_feature_lun_sn, try_tvb, try_offset, additional_length, ENC_ASCII|ENC_NA);
break;
default:
proto_tree_add_text (tree, tvb_v, offset_v, additional_length,
proto_tree_add_text (tree, try_tvb, try_offset, additional_length,
"SCSI/MMC Unknown Feature data");
break;
}
offset_v=old_offset+additional_length;
try_offset=old_offset+additional_length;
len-=4+additional_length;
}
END_TRY_SCSI_CDB_ALLOC_LEN;
@ -549,8 +547,8 @@ static const value_string scsi_q_subchannel_control_val[] = {
static value_string_ext scsi_q_subchannel_control_val_ext = VALUE_STRING_EXT_INIT(scsi_q_subchannel_control_val);
static void
dissect_mmc4_readtocpmaatip (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
guint offset, gboolean isreq, gboolean iscdb,
dissect_mmc4_readtocpmaatip (tvbuff_t *tvb_a, packet_info *pinfo, proto_tree *tree,
guint offset_a, gboolean isreq, gboolean iscdb,
guint payload_len _U_, scsi_task_data_t *cdata)
{
@ -558,72 +556,72 @@ dissect_mmc4_readtocpmaatip (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree
gint16 len;
if (isreq && iscdb) {
format=tvb_get_guint8(tvb, offset+1)&0x0f;
format=tvb_get_guint8(tvb_a, offset_a+1)&0x0f;
/* save format so we can decode the response */
cdata->itlq->flags=format;
switch(format){
case 0x00:
case 0x01:
proto_tree_add_item (tree, hf_scsi_mmc_readtoc_time, tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_readtoc_time, tvb_a, offset_a, 1, ENC_BIG_ENDIAN);
/* save time so we can pick it up in the response */
if(tvb_get_guint8(tvb, offset)&0x02){
if(tvb_get_guint8(tvb_a, offset_a)&0x02){
cdata->itlq->flags|=0x0100;
}
break;
}
proto_tree_add_item (tree, hf_scsi_mmc_readtoc_format, tvb, offset+1, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_readtoc_format, tvb_a, offset_a+1, 1, ENC_BIG_ENDIAN);
switch(format){
case 0x00:
proto_tree_add_item (tree, hf_scsi_mmc_track, tvb, offset+5, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_track, tvb_a, offset_a+5, 1, ENC_BIG_ENDIAN);
/* save track so we can pick it up in the response */
cdata->itlq->flags|=0x0200;
break;
case 0x02:
proto_tree_add_item (tree, hf_scsi_mmc_session, tvb, offset+5, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_session, tvb_a, offset_a+5, 1, ENC_BIG_ENDIAN);
/* save session so we can pick it up in the response */
cdata->itlq->flags|=0x0400;
break;
}
proto_tree_add_item (tree, hf_scsi_alloclen16, tvb, offset + 6, 2, ENC_BIG_ENDIAN);
cdata->itlq->alloc_len = tvb_get_ntohs(tvb, offset + 6);
proto_tree_add_item (tree, hf_scsi_alloclen16, tvb_a, offset_a + 6, 2, ENC_BIG_ENDIAN);
cdata->itlq->alloc_len = tvb_get_ntohs(tvb_a, offset_a + 6);
proto_tree_add_bitmask(tree, tvb, offset+8, hf_scsi_control,
proto_tree_add_bitmask(tree, tvb_a, offset_a+8, hf_scsi_control,
ett_scsi_control, cdb_control_fields, ENC_BIG_ENDIAN);
}
if(!isreq) {
TRY_SCSI_CDB_ALLOC_LEN(pinfo, tvb, offset, cdata->itlq->alloc_len);
len=tvb_get_ntohs(tvb, offset);
proto_tree_add_item (tree, hf_scsi_mmc_data_length, tvb, offset, 2, ENC_BIG_ENDIAN);
TRY_SCSI_CDB_ALLOC_LEN(cdata->itlq->alloc_len); /* (defines/initializes try_tvb & try_offset) */
len=tvb_get_ntohs(try_tvb, try_offset);
proto_tree_add_item (tree, hf_scsi_mmc_data_length, try_tvb, try_offset, 2, ENC_BIG_ENDIAN);
if(cdata->itlq->flags&0x0200){
proto_tree_add_item (tree, hf_scsi_mmc_first_track, tvb, offset+2, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_readtoc_last_track, tvb, offset+3, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_first_track, try_tvb, try_offset+2, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_readtoc_last_track, try_tvb, try_offset+3, 1, ENC_BIG_ENDIAN);
}
if(cdata->itlq->flags&0x0400){
proto_tree_add_item (tree, hf_scsi_mmc_readtoc_first_session, tvb, offset+2, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_readtoc_last_session, tvb, offset+3, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_readtoc_first_session, try_tvb, try_offset+2, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_readtoc_last_session, try_tvb, try_offset+3, 1, ENC_BIG_ENDIAN);
}
offset+=4;
try_offset+=4;
len-=2;
switch(cdata->itlq->flags&0x000f){
case 0x0:
while(len>0){
proto_tree_add_item (tree, hf_scsi_mmc_q_subchannel_adr, tvb, offset+1, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_q_subchannel_control, tvb, offset+1, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_track, tvb, offset+2, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_q_subchannel_adr, try_tvb, try_offset+1, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_q_subchannel_control, try_tvb, try_offset+1, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_track, try_tvb, try_offset+2, 1, ENC_BIG_ENDIAN);
if(cdata->itlq->flags&0x0100){
proto_tree_add_item (tree, hf_scsi_mmc_track_start_time, tvb, offset+4, 4, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_track_start_time, try_tvb, try_offset+4, 4, ENC_BIG_ENDIAN);
} else {
proto_tree_add_item (tree, hf_scsi_mmc_track_start_address, tvb, offset+4, 4, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_track_start_address, try_tvb, try_offset+4, 4, ENC_BIG_ENDIAN);
}
offset+=8;
try_offset+=8;
len-=8;
}
break;
default:
proto_tree_add_text (tree, tvb, offset, len,
proto_tree_add_text (tree, try_tvb, try_offset, len,
"SCSI/MMC Unknown READ TOC Format:0x%04x",cdata->itlq->flags&0x000f);
break;
}
@ -664,16 +662,16 @@ static const value_string scsi_disc_info_disc_type_val[] = {
};
static void
dissect_mmc4_readdiscinformation (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
guint offset, gboolean isreq, gboolean iscdb,
dissect_mmc4_readdiscinformation (tvbuff_t *tvb_a, packet_info *pinfo, proto_tree *tree,
guint offset_a, gboolean isreq, gboolean iscdb,
guint payload_len _U_, scsi_task_data_t *cdata)
{
if (iscdb) {
proto_tree_add_item (tree, hf_scsi_alloclen16, tvb, offset + 6, 2, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_alloclen16, tvb_a, offset_a + 6, 2, ENC_BIG_ENDIAN);
if (cdata && cdata->itlq) {
cdata->itlq->alloc_len = tvb_get_ntohs(tvb, offset + 6);
cdata->itlq->alloc_len = tvb_get_ntohs(tvb_a, offset_a + 6);
}
proto_tree_add_bitmask(tree, tvb, offset+8, hf_scsi_control,
proto_tree_add_bitmask(tree, tvb_a, offset_a+8, hf_scsi_control,
ett_scsi_control, cdb_control_fields, ENC_BIG_ENDIAN);
}
if (!isreq) {
@ -693,35 +691,35 @@ dissect_mmc4_readdiscinformation (tvbuff_t *tvb, packet_info *pinfo, proto_tree
NULL
};
TRY_SCSI_CDB_ALLOC_LEN(pinfo, tvb, offset, (cdata && cdata->itlq) ? cdata->itlq->alloc_len : 0);
proto_tree_add_item (tree, hf_scsi_mmc_data_length, tvb, 0, 2, ENC_BIG_ENDIAN);
TRY_SCSI_CDB_ALLOC_LEN( (cdata && cdata->itlq) ? cdata->itlq->alloc_len : 0); /* (defines/initializes try_tvb & try_offset) */
proto_tree_add_item (tree, hf_scsi_mmc_data_length, try_tvb, 0, 2, ENC_BIG_ENDIAN);
proto_tree_add_bitmask(tree, tvb, offset + 2, hf_scsi_mmc_disk_flags,
proto_tree_add_bitmask(tree, try_tvb, try_offset + 2, hf_scsi_mmc_disk_flags,
ett_scsi_disk_flags, disk_fields, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_first_track, tvb, offset+3, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_first_track, try_tvb, try_offset+3, 1, ENC_BIG_ENDIAN);
/* number of session offset+4 and offset+9 */
proto_tree_add_uint (tree, hf_scsi_mmc_disc_info_number_of_sessions, tvb, 4, 1, (tvb_get_guint8(tvb, offset+9)<<8)|tvb_get_guint8(tvb, offset+4));
/* number of session try_offset+4 and try_offset+9 */
proto_tree_add_uint (tree, hf_scsi_mmc_disc_info_number_of_sessions, try_tvb, 4, 1, (tvb_get_guint8(try_tvb, try_offset+9)<<8)|tvb_get_guint8(try_tvb, try_offset+4));
/* first track in last session offset+5 and offset+10 */
proto_tree_add_uint (tree, hf_scsi_mmc_disc_info_first_track_in_last_session, tvb, 5, 1, (tvb_get_guint8(tvb, offset+10)<<8)|tvb_get_guint8(tvb, offset+5));
/* first track in last session try_offset+5 and try_offset+10 */
proto_tree_add_uint (tree, hf_scsi_mmc_disc_info_first_track_in_last_session, try_tvb, 5, 1, (tvb_get_guint8(try_tvb, try_offset+10)<<8)|tvb_get_guint8(try_tvb, try_offset+5));
/* last track in last session offset+6 and offset+11 */
proto_tree_add_uint (tree, hf_scsi_mmc_disc_info_last_track_in_last_session, tvb, 6, 1, (tvb_get_guint8(tvb, offset+11)<<8)|tvb_get_guint8(tvb, offset+6));
/* last track in last session try_offset+6 and try_offset+11 */
proto_tree_add_uint (tree, hf_scsi_mmc_disc_info_last_track_in_last_session, try_tvb, 6, 1, (tvb_get_guint8(try_tvb, try_offset+11)<<8)|tvb_get_guint8(try_tvb, try_offset+6));
proto_tree_add_bitmask(tree, tvb, offset + 7, hf_scsi_mmc_format_flags,
proto_tree_add_bitmask(tree, try_tvb, try_offset + 7, hf_scsi_mmc_format_flags,
ett_scsi_format_flags, format_fields, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_disc_info_disc_type, tvb, offset+8, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_disc_info_disc_type, try_tvb, try_offset+8, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_disc_info_disc_identification, tvb, offset+12, 4, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_disc_info_disc_identification, try_tvb, try_offset+12, 4, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_disc_info_last_session_lead_in_start_address, tvb, offset+16, 4, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_disc_info_last_session_lead_in_start_address, try_tvb, try_offset+16, 4, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_disc_info_last_possible_lead_out_start_address, tvb, offset+20, 4, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_disc_info_last_possible_lead_out_start_address, try_tvb, try_offset+20, 4, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_disc_info_disc_bar_code, tvb, offset+24, 8, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_disc_info_disc_bar_code, try_tvb, try_offset+24, 8, ENC_BIG_ENDIAN);
/* XXX should add OPC table decoding here ... */
END_TRY_SCSI_CDB_ALLOC_LEN;
}
@ -978,37 +976,37 @@ static const value_string scsi_rti_address_type_val[] = {
};
static void
dissect_mmc4_readtrackinformation (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
guint offset, gboolean isreq, gboolean iscdb,
dissect_mmc4_readtrackinformation (tvbuff_t *tvb_a, packet_info *pinfo, proto_tree *tree,
guint offset_a, gboolean isreq, gboolean iscdb,
guint payload_len _U_, scsi_task_data_t *cdata)
{
guint8 addresstype;
if (isreq && iscdb) {
addresstype=tvb_get_guint8(tvb, offset)&0x03;
proto_tree_add_item (tree, hf_scsi_mmc_rti_address_type, tvb, offset+0, 1, ENC_BIG_ENDIAN);
addresstype=tvb_get_guint8(tvb_a, offset_a)&0x03;
proto_tree_add_item (tree, hf_scsi_mmc_rti_address_type, tvb_a, offset_a+0, 1, ENC_BIG_ENDIAN);
switch(addresstype){
case 0x00: /* logical block address */
proto_tree_add_item (tree, hf_scsi_mmc_lba, tvb, offset+1,
proto_tree_add_item (tree, hf_scsi_mmc_lba, tvb_a, offset_a+1,
4, ENC_BIG_ENDIAN);
break;
case 0x01: /* logical track number */
proto_tree_add_item (tree, hf_scsi_mmc_track, tvb, offset+1,
proto_tree_add_item (tree, hf_scsi_mmc_track, tvb_a, offset_a+1,
4, ENC_BIG_ENDIAN);
break;
case 0x02: /* logical session number */
proto_tree_add_item (tree, hf_scsi_mmc_session, tvb, offset+1,
proto_tree_add_item (tree, hf_scsi_mmc_session, tvb_a, offset_a+1,
4, ENC_BIG_ENDIAN);
break;
}
proto_tree_add_item (tree, hf_scsi_alloclen16, tvb, offset + 6, 2, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_alloclen16, tvb_a, offset_a + 6, 2, ENC_BIG_ENDIAN);
if (cdata) {
cdata->itlq->alloc_len = tvb_get_ntohs(tvb, offset + 6);
cdata->itlq->alloc_len = tvb_get_ntohs(tvb_a, offset_a + 6);
}
proto_tree_add_bitmask(tree, tvb, offset+8, hf_scsi_control,
proto_tree_add_bitmask(tree, tvb_a, offset_a+8, hf_scsi_control,
ett_scsi_control, cdb_control_fields, ENC_BIG_ENDIAN);
}
if (!isreq) {
@ -1028,44 +1026,44 @@ dissect_mmc4_readtrackinformation (tvbuff_t *tvb, packet_info *pinfo, proto_tree
};
TRY_SCSI_CDB_ALLOC_LEN(pinfo, tvb, offset, cdata->itlq->alloc_len);
proto_tree_add_item (tree, hf_scsi_mmc_data_length, tvb, 0, 2, ENC_BIG_ENDIAN);
/* track offset+2 and offset+32, only use the high byte if we have it */
if (tvb_reported_length(tvb) < 33) {
proto_tree_add_uint (tree, hf_scsi_mmc_track, tvb, 2, 1, tvb_get_guint8(tvb, offset + 2));
TRY_SCSI_CDB_ALLOC_LEN(cdata->itlq->alloc_len); /* (defines/initializes try_tvb & try_offset) */
proto_tree_add_item (tree, hf_scsi_mmc_data_length, try_tvb, 0, 2, ENC_BIG_ENDIAN);
/* track try_offset+2 and try_offset+32, only use the high byte if we have it */
if (tvb_reported_length(try_tvb) < 33) {
proto_tree_add_uint (tree, hf_scsi_mmc_track, try_tvb, 2, 1, tvb_get_guint8(try_tvb, try_offset + 2));
} else {
proto_tree_add_uint (tree, hf_scsi_mmc_track, tvb, 2, 1, (tvb_get_guint8(tvb, offset + 32) << 8) | tvb_get_guint8(tvb, offset + 2));
proto_tree_add_uint (tree, hf_scsi_mmc_track, try_tvb, 2, 1, (tvb_get_guint8(try_tvb, try_offset + 32) << 8) | tvb_get_guint8(try_tvb, try_offset + 2));
}
/* session offset+3 and offset+33 */
if (tvb_reported_length(tvb) < 34) {
proto_tree_add_uint (tree, hf_scsi_mmc_session, tvb, 3, 1, tvb_get_guint8(tvb, offset + 3));
/* session try_offset+3 and try_offset+33 */
if (tvb_reported_length(try_tvb) < 34) {
proto_tree_add_uint (tree, hf_scsi_mmc_session, try_tvb, 3, 1, tvb_get_guint8(try_tvb, try_offset + 3));
} else {
proto_tree_add_uint (tree, hf_scsi_mmc_session, tvb, 3, 1, (tvb_get_guint8(tvb, offset + 33) << 8) | tvb_get_guint8(tvb, offset + 3));
proto_tree_add_uint (tree, hf_scsi_mmc_session, try_tvb, 3, 1, (tvb_get_guint8(try_tvb, try_offset + 33) << 8) | tvb_get_guint8(try_tvb, try_offset + 3));
}
proto_tree_add_bitmask(tree, tvb, offset + 5, hf_scsi_mmc_track_flags,
proto_tree_add_bitmask(tree, try_tvb, try_offset + 5, hf_scsi_mmc_track_flags,
ett_scsi_track_flags, track_fields, ENC_BIG_ENDIAN);
proto_tree_add_bitmask(tree, tvb, offset + 6, hf_scsi_mmc_data_flags,
proto_tree_add_bitmask(tree, try_tvb, try_offset + 6, hf_scsi_mmc_data_flags,
ett_scsi_data_flags, data_fields, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_rti_lra_v, tvb, 7, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_rti_nwa_v, tvb, 7, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_rti_lra_v, try_tvb, 7, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_rti_nwa_v, try_tvb, 7, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_track_start_address, tvb, offset+8, 4, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_track_start_address, try_tvb, try_offset+8, 4, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_next_writable_address, tvb, offset+12, 4, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_next_writable_address, try_tvb, try_offset+12, 4, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_free_blocks, tvb, offset+16, 4, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_free_blocks, try_tvb, try_offset+16, 4, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_fixed_packet_size, tvb, offset+20, 4, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_fixed_packet_size, try_tvb, try_offset+20, 4, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_track_size, tvb, offset+24, 4, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_track_size, try_tvb, try_offset+24, 4, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_last_recorded_address, tvb, offset+28, 4, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_last_recorded_address, try_tvb, try_offset+28, 4, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_read_compatibility_lba, tvb, offset+36, 4, ENC_BIG_ENDIAN);
proto_tree_add_item (tree, hf_scsi_mmc_read_compatibility_lba, try_tvb, try_offset+36, 4, ENC_BIG_ENDIAN);
END_TRY_SCSI_CDB_ALLOC_LEN;
}
}

View File

@ -3040,14 +3040,12 @@ static const int *peripheral_fields[] = {
void
dissect_spc_inquiry(tvbuff_t *tvb, packet_info *pinfo,
proto_tree *tree, guint offset, gboolean isreq,
dissect_spc_inquiry(tvbuff_t *tvb_a, packet_info *pinfo,
proto_tree *tree, guint offset_a, gboolean isreq,
gboolean iscdb, guint32 payload_len,
scsi_task_data_t *cdata)
{
guint8 flags, i, version;
tvbuff_t *volatile tvb_v = tvb;
volatile guint offset_v = offset;
static const int *inq_control_fields[] = {
&hf_scsi_inq_control_vendor_specific,
@ -3084,44 +3082,44 @@ dissect_spc_inquiry(tvbuff_t *tvb, packet_info *pinfo,
};
if (!isreq && ((cdata == NULL) || !(cdata->itlq->flags & 0x3))
&& (tvb_length_remaining(tvb_v, offset_v) >= 1) ) {
&& (tvb_length_remaining(tvb_a, offset_a) >= 1) ) {
/*
* INQUIRY response with device type information; add device type
* to list of known devices & their types if not already known.
*/
if (cdata && cdata->itl) {
cdata->itl->cmdset = tvb_get_guint8(tvb_v, offset_v)&SCSI_DEV_BITS;
cdata->itl->cmdset = tvb_get_guint8(tvb_a, offset_a)&SCSI_DEV_BITS;
}
}
if (isreq && iscdb) {
flags = tvb_get_guint8(tvb_v, offset_v);
flags = tvb_get_guint8(tvb_a, offset_a);
if (cdata) {
cdata->itlq->flags = flags;
}
proto_tree_add_uint_format(tree, hf_scsi_inquiry_flags, tvb_v, offset_v, 1,
proto_tree_add_uint_format(tree, hf_scsi_inquiry_flags, tvb_a, offset_a, 1,
flags, "CMDT = %u, EVPD = %u",
flags & 0x2, flags & 0x1);
if (flags & 0x1) {
proto_tree_add_item(tree, hf_scsi_inquiry_evpd_page, tvb_v, offset_v+1,
proto_tree_add_item(tree, hf_scsi_inquiry_evpd_page, tvb_a, offset_a+1,
1, ENC_BIG_ENDIAN);
col_add_fstr(pinfo->cinfo, COL_INFO, " %s",
val_to_str(tvb_get_guint8(tvb_v, offset_v+1),
val_to_str(tvb_get_guint8(tvb_a, offset_a+1),
scsi_evpd_pagecode_val,
"Unknown VPD 0x%02x"));
} else if (flags & 0x2) {
proto_tree_add_item(tree, hf_scsi_inquiry_cmdt_page, tvb_v, offset_v+1,
proto_tree_add_item(tree, hf_scsi_inquiry_cmdt_page, tvb_a, offset_a+1,
1, ENC_BIG_ENDIAN);
}
proto_tree_add_item(tree, hf_scsi_alloclen16, tvb_v, offset_v+2, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(tree, hf_scsi_alloclen16, tvb_a, offset_a+2, 2, ENC_BIG_ENDIAN);
/* we need the alloc_len in the response */
if (cdata) {
cdata->itlq->alloc_len = tvb_get_ntohs(tvb_v, offset_v+2);
cdata->itlq->alloc_len = tvb_get_ntohs(tvb_a, offset_a+2);
}
proto_tree_add_bitmask(tree, tvb_v, offset_v+4, hf_scsi_inq_control,
proto_tree_add_bitmask(tree, tvb_a, offset_a+4, hf_scsi_inq_control,
ett_scsi_inq_control, inq_control_fields, ENC_BIG_ENDIAN);
} else if (!isreq) {
if (!cdata) {
@ -3129,86 +3127,86 @@ dissect_spc_inquiry(tvbuff_t *tvb, packet_info *pinfo,
}
if (cdata->itlq->flags & 0x1) {
dissect_scsi_evpd(tvb_v, pinfo, tree, offset_v, payload_len);
dissect_scsi_evpd(tvb_a, pinfo, tree, offset_a, payload_len);
return;
}
if (cdata->itlq->flags & 0x2) {
dissect_scsi_cmddt(tvb_v, pinfo, tree, offset_v, payload_len);
dissect_scsi_cmddt(tvb_a, pinfo, tree, offset_a, payload_len);
return;
}
/* These pdus are sometimes truncated by SCSI allocation length
* in the CDB
*/
TRY_SCSI_CDB_ALLOC_LEN(pinfo, tvb_v, offset_v, cdata->itlq->alloc_len);
TRY_SCSI_CDB_ALLOC_LEN(cdata->itlq->alloc_len); /* (defines/initializes try_tvb & try_offset) */
/* Qualifier and DeviceType */
proto_tree_add_bitmask(tree, tvb_v, offset_v, hf_scsi_inq_peripheral, ett_scsi_inq_peripheral, peripheral_fields, ENC_BIG_ENDIAN);
offset_v+=1;
proto_tree_add_bitmask(tree, try_tvb, try_offset, hf_scsi_inq_peripheral, ett_scsi_inq_peripheral, peripheral_fields, ENC_BIG_ENDIAN);
try_offset+=1;
/* RMB */
proto_tree_add_bitmask(tree, tvb_v, offset_v, hf_scsi_inq_rmbflags, ett_scsi_inq_rmbflags, rmb_fields, ENC_BIG_ENDIAN);
offset_v+=1;
proto_tree_add_bitmask(tree, try_tvb, try_offset, hf_scsi_inq_rmbflags, ett_scsi_inq_rmbflags, rmb_fields, ENC_BIG_ENDIAN);
try_offset+=1;
/* Version */
version = tvb_get_guint8(tvb, offset_v);
proto_tree_add_item(tree, hf_scsi_inq_version, tvb_v, offset_v, 1, ENC_BIG_ENDIAN);
offset_v+=1;
version = tvb_get_guint8(try_tvb, try_offset);
proto_tree_add_item(tree, hf_scsi_inq_version, try_tvb, try_offset, 1, ENC_BIG_ENDIAN);
try_offset+=1;
/* aca flags */
switch (version) {
case 3: /* SPC */
proto_tree_add_bitmask(tree, tvb_v, offset_v, hf_scsi_inq_acaflags, ett_scsi_inq_acaflags, aca_fields_spc, ENC_BIG_ENDIAN);
proto_tree_add_bitmask(tree, try_tvb, try_offset, hf_scsi_inq_acaflags, ett_scsi_inq_acaflags, aca_fields_spc, ENC_BIG_ENDIAN);
break;
case 4: /* SPC-2 */
proto_tree_add_bitmask(tree, tvb_v, offset_v, hf_scsi_inq_acaflags, ett_scsi_inq_acaflags, aca_fields_spc2, ENC_BIG_ENDIAN);
proto_tree_add_bitmask(tree, try_tvb, try_offset, hf_scsi_inq_acaflags, ett_scsi_inq_acaflags, aca_fields_spc2, ENC_BIG_ENDIAN);
break;
case 5: /* SPC-3 */
case 6: /* SPC-4 */
proto_tree_add_bitmask(tree, tvb_v, offset_v, hf_scsi_inq_acaflags, ett_scsi_inq_acaflags, aca_fields_spc3, ENC_BIG_ENDIAN);
proto_tree_add_bitmask(tree, try_tvb, try_offset, hf_scsi_inq_acaflags, ett_scsi_inq_acaflags, aca_fields_spc3, ENC_BIG_ENDIAN);
break;
default: /* including version 0 : claims conformance to no standard */
proto_tree_add_bitmask(tree, tvb_v, offset_v, hf_scsi_inq_acaflags, ett_scsi_inq_acaflags, aca_fields_spc3, ENC_BIG_ENDIAN);
proto_tree_add_bitmask(tree, try_tvb, try_offset, hf_scsi_inq_acaflags, ett_scsi_inq_acaflags, aca_fields_spc3, ENC_BIG_ENDIAN);
}
offset_v+=1;
try_offset+=1;
/* Additional Length */
SET_SCSI_DATA_END(tvb_get_guint8(tvb_v, offset_v)+offset);
proto_tree_add_item(tree, hf_scsi_inq_add_len, tvb_v, offset_v, 1, ENC_BIG_ENDIAN);
offset_v+=1;
SET_SCSI_DATA_END(tvb_get_guint8(try_tvb, try_offset)+try_offset);
proto_tree_add_item(tree, hf_scsi_inq_add_len, try_tvb, try_offset, 1, ENC_BIG_ENDIAN);
try_offset+=1;
/* sccs flags */
offset_v = dissect_spc_inq_sccsflags(tvb_v, offset_v, tree, version);
try_offset = dissect_spc_inq_sccsflags(try_tvb, try_offset, tree, version);
/* bque flags */
offset_v = dissect_spc_inq_bqueflags(tvb_v, offset_v, tree, version);
try_offset = dissect_spc_inq_bqueflags(try_tvb, try_offset, tree, version);
/* reladdr flags */
offset_v = dissect_spc_inq_reladrflags(tvb_v, offset_v, tree, version);
try_offset = dissect_spc_inq_reladrflags(try_tvb, try_offset, tree, version);
/* vendor id */
proto_tree_add_item(tree, hf_scsi_inq_vendor_id, tvb_v, offset_v, 8, ENC_ASCII|ENC_NA);
offset_v+=8;
proto_tree_add_item(tree, hf_scsi_inq_vendor_id, try_tvb, try_offset, 8, ENC_ASCII|ENC_NA);
try_offset+=8;
/* product id */
proto_tree_add_item(tree, hf_scsi_inq_product_id, tvb_v, offset_v, 16, ENC_ASCII|ENC_NA);
offset_v+=16;
proto_tree_add_item(tree, hf_scsi_inq_product_id, try_tvb, try_offset, 16, ENC_ASCII|ENC_NA);
try_offset+=16;
/* product revision level */
proto_tree_add_item(tree, hf_scsi_inq_product_rev, tvb_v, offset_v, 4, ENC_ASCII|ENC_NA);
offset_v+=4;
proto_tree_add_item(tree, hf_scsi_inq_product_rev, try_tvb, try_offset, 4, ENC_ASCII|ENC_NA);
try_offset+=4;
/* vendor specific, 20 bytes */
proto_tree_add_item(tree, hf_scsi_inq_vendor_specific, tvb_v, offset_v, 20, ENC_NA);
offset_v+=20;
proto_tree_add_item(tree, hf_scsi_inq_vendor_specific, try_tvb, try_offset, 20, ENC_NA);
try_offset+=20;
/* reserved */
offset_v += 2;
try_offset += 2;
/* version descriptors */
for(i = 0;i<8;i++) {
proto_tree_add_item(tree, hf_scsi_inq_version_desc, tvb_v, offset_v, 2, ENC_BIG_ENDIAN);
offset_v+=2;
proto_tree_add_item(tree, hf_scsi_inq_version_desc, try_tvb, try_offset, 2, ENC_BIG_ENDIAN);
try_offset+=2;
}
END_TRY_SCSI_CDB_ALLOC_LEN;
@ -5010,36 +5008,34 @@ dissect_scsi_lun(proto_tree *tree, tvbuff_t *tvb, guint offset) {
}
void
dissect_spc_reportluns(tvbuff_t *tvb, packet_info *pinfo _U_,
proto_tree *tree, guint offset,
dissect_spc_reportluns(tvbuff_t *tvb_a, packet_info *pinfo _U_,
proto_tree *tree, guint offset_a,
gboolean isreq, gboolean iscdb, guint payload_len _U_,
scsi_task_data_t *cdata _U_)
{
gint listlen;
tvbuff_t *volatile tvb_v = tvb;
volatile guint offset_v = offset;
if (isreq && iscdb) {
proto_tree_add_item(tree, hf_scsi_select_report, tvb_v, offset_v+1, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(tree, hf_scsi_alloclen32, tvb_v, offset_v+5, 4, ENC_BIG_ENDIAN);
proto_tree_add_item(tree, hf_scsi_select_report, tvb_a, offset_a+1, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(tree, hf_scsi_alloclen32, tvb_a, offset_a+5, 4, ENC_BIG_ENDIAN);
if (cdata) {
cdata->itlq->alloc_len = tvb_get_ntohl(tvb_v, offset_v+5);
cdata->itlq->alloc_len = tvb_get_ntohl(tvb_a, offset_a+5);
}
proto_tree_add_bitmask(tree, tvb, offset_v+10, hf_scsi_control,
proto_tree_add_bitmask(tree, tvb_a, offset_a+10, hf_scsi_control,
ett_scsi_control, cdb_control_fields, ENC_BIG_ENDIAN);
} else if (!isreq) {
if (!cdata) {
return;
}
TRY_SCSI_CDB_ALLOC_LEN(pinfo, tvb_v, offset_v, cdata->itlq->alloc_len);
listlen = tvb_get_ntohl(tvb_v, offset_v);
proto_tree_add_item(tree, hf_scsi_reportluns_lun_list_length, tvb_v, offset_v, 4, ENC_BIG_ENDIAN);
offset_v += 8;
TRY_SCSI_CDB_ALLOC_LEN(cdata->itlq->alloc_len); /* (defines/initializes try_tvb & try_offset) */
listlen = tvb_get_ntohl(try_tvb, try_offset);
proto_tree_add_item(tree, hf_scsi_reportluns_lun_list_length, try_tvb, try_offset, 4, ENC_BIG_ENDIAN);
try_offset += 8;
while(listlen>0) {
dissect_scsi_lun(tree, tvb_v, offset_v);
offset_v+=8;
dissect_scsi_lun(tree, try_tvb, try_offset);
try_offset+=8;
listlen-=8;
}
END_TRY_SCSI_CDB_ALLOC_LEN;
@ -5060,54 +5056,52 @@ const value_string report_opcodes_options_vals[] = {
};
void
dissect_spc_mgmt_protocol_in(tvbuff_t *tvb, packet_info *pinfo _U_,
proto_tree *tree, guint offset,
dissect_spc_mgmt_protocol_in(tvbuff_t *tvb_a, packet_info *pinfo _U_,
proto_tree *tree, guint offset_a,
gboolean isreq, gboolean iscdb,
guint payload_len _U_,
scsi_task_data_t *cdata _U_)
{
tvbuff_t *volatile tvb_v = tvb;
volatile guint offset_v = offset;
guint8 service_action;
if (isreq && iscdb) {
service_action = tvb_get_guint8 (tvb_v, offset_v) & 0x1F;
service_action = tvb_get_guint8 (tvb_a, offset_a) & 0x1F;
if (cdata) {
cdata->itlq->flags=service_action;
}
col_append_str(pinfo->cinfo, COL_INFO,
val_to_str(service_action, mpi_action_vals, "Unknown"));
proto_tree_add_item(tree, hf_scsi_mpi_service_action, tvb_v,
offset_v, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(tree, hf_scsi_mpi_service_action, tvb_a,
offset_a, 1, ENC_BIG_ENDIAN);
switch(service_action){
case MPI_REPORT_SUPPORTED_OPERATION_CODES:
proto_tree_add_item(tree, hf_scsi_report_opcodes_rctd,
tvb_v, offset_v+1, 1, ENC_BIG_ENDIAN);
tvb_a, offset_a+1, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(tree, hf_scsi_report_opcodes_options,
tvb_v, offset_v+1, 1, ENC_BIG_ENDIAN);
if (cdata && (tvb_get_guint8(tvb_v, offset_v+1) & 0x07)) {
tvb_a, offset_a+1, 1, ENC_BIG_ENDIAN);
if (cdata && (tvb_get_guint8(tvb_a, offset_a+1) & 0x07)) {
/* Need the one-command parameter format */
cdata->itlq->flags|=0x80;
}
proto_tree_add_item(tree, hf_scsi_report_opcodes_requested_o,
tvb_v, offset_v+2, 1, ENC_BIG_ENDIAN);
tvb_a, offset_a+2, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(tree, hf_scsi_report_opcodes_requested_sa,
tvb_v, offset_v+3, 2, ENC_BIG_ENDIAN);
tvb_a, offset_a+3, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(tree, hf_scsi_alloclen32, tvb_v,
offset_v+5, 4, ENC_BIG_ENDIAN);
proto_tree_add_item(tree, hf_scsi_alloclen32, tvb_a,
offset_a+5, 4, ENC_BIG_ENDIAN);
if (cdata) {
cdata->itlq->alloc_len = tvb_get_ntohl(tvb_v, offset_v+5);
cdata->itlq->alloc_len = tvb_get_ntohl(tvb_a, offset_a+5);
}
break;
default:
proto_tree_add_expert(tree, pinfo, &ei_scsi_no_dissection_for_service_action, tvb_v, offset_v+1, 8);
proto_tree_add_expert(tree, pinfo, &ei_scsi_no_dissection_for_service_action, tvb_a, offset_a+1, 8);
}
proto_tree_add_bitmask(tree, tvb_v, offset_v+10, hf_scsi_control,
proto_tree_add_bitmask(tree, tvb_a, offset_a+10, hf_scsi_control,
ett_scsi_control, cdb_control_fields, ENC_BIG_ENDIAN);
} else if (!isreq) {
@ -5122,109 +5116,109 @@ dissect_spc_mgmt_protocol_in(tvbuff_t *tvb, packet_info *pinfo _U_,
csdata = get_cmdset_data(cdata->itlq, cdata->itl);
it = proto_tree_add_uint(tree, hf_scsi_mpi_service_action, tvb_v, 0, 0, cdata->itlq->flags & 0x7f);
it = proto_tree_add_uint(tree, hf_scsi_mpi_service_action, tvb_a, 0, 0, cdata->itlq->flags & 0x7f);
PROTO_ITEM_SET_GENERATED(it);
TRY_SCSI_CDB_ALLOC_LEN(pinfo, tvb_v, offset_v, cdata->itlq->alloc_len);
TRY_SCSI_CDB_ALLOC_LEN(cdata->itlq->alloc_len); /* (defines/initializes try_tvb & try_offset) */
switch (cdata->itlq->flags & 0x7f) {
case MPI_REPORT_SUPPORTED_OPERATION_CODES:
if (cdata->itlq->flags & 0x80) {
/* one-command format */
proto_tree_add_item(tree, hf_scsi_report_opcodes_ctdp_one,
tvb_v, offset_v+1, 1, ENC_BIG_ENDIAN);
ctdp = tvb_get_guint8(tvb_v, offset_v+1) & 0x80;
try_tvb, try_offset+1, 1, ENC_BIG_ENDIAN);
ctdp = tvb_get_guint8(try_tvb, try_offset+1) & 0x80;
proto_tree_add_item(tree, hf_scsi_report_opcodes_support,
tvb_v, offset_v+1, 1, ENC_BIG_ENDIAN);
try_tvb, try_offset+1, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(tree, hf_scsi_report_opcodes_cdb_length,
tvb_v, offset_v+2, 2, ENC_BIG_ENDIAN);
length = tvb_get_ntohs(tvb_v, offset_v+2);
try_tvb, try_offset+2, 2, ENC_BIG_ENDIAN);
length = tvb_get_ntohs(try_tvb, try_offset+2);
proto_tree_add_item(tree, hf_scsi_report_opcodes_cdb_usage_data,
tvb_v, offset_v+4, length, ENC_NA);
try_tvb, try_offset+4, length, ENC_NA);
if (ctdp) {
proto_tree *tr;
it = proto_tree_add_text(tree, tvb_v, offset_v,
it = proto_tree_add_text(tree, try_tvb, try_offset,
12, "Timeout Descriptor");
tr = proto_item_add_subtree(it,
ett_timeout_descriptor);
proto_tree_add_item(tr, hf_scsi_report_opcodes_tdl,
tvb_v, offset_v, 2, ENC_BIG_ENDIAN);
try_tvb, try_offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(tr, hf_scsi_report_opcodes_npt,
tvb_v, offset_v + 4, 4, ENC_BIG_ENDIAN);
try_tvb, try_offset + 4, 4, ENC_BIG_ENDIAN);
proto_tree_add_item(tr, hf_scsi_report_opcodes_rct,
tvb_v, offset_v + 8, 4, ENC_BIG_ENDIAN);
try_tvb, try_offset + 8, 4, ENC_BIG_ENDIAN);
}
} else {
/* all commands format */
proto_tree_add_item(tree, hf_scsi_report_opcodes_cdl,
tvb_v, offset_v+0, 4, ENC_BIG_ENDIAN);
length = tvb_get_ntohl(tvb_v, offset_v);
offset_v += 4;
try_tvb, try_offset+0, 4, ENC_BIG_ENDIAN);
length = tvb_get_ntohl(try_tvb, try_offset);
try_offset += 4;
while (length >= 20) {
proto_tree *tr;
it = proto_tree_add_text(tree, tvb_v, offset_v,
it = proto_tree_add_text(tree, try_tvb, try_offset,
20, "Command Descriptor: %s",
val_to_str_ext_const(tvb_get_guint8(tvb_v, offset_v+0), csdata->cdb_vals_ext, "Unknown"));
val_to_str_ext_const(tvb_get_guint8(try_tvb, try_offset+0), csdata->cdb_vals_ext, "Unknown"));
tr = proto_item_add_subtree(it,
ett_command_descriptor);
proto_tree_add_item(tr, csdata->hf_opcode,
tvb_v, offset_v+0, 1, ENC_BIG_ENDIAN);
try_tvb, try_offset+0, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(tr, hf_scsi_report_opcodes_sa,
tvb_v, offset_v+2, 2, ENC_BIG_ENDIAN);
try_tvb, try_offset+2, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(tr, hf_scsi_report_opcodes_ctdp,
tvb_v, offset_v+5, 1, ENC_BIG_ENDIAN);
ctdp = tvb_get_guint8(tvb_v, offset_v+5) & 0x02;
try_tvb, try_offset+5, 1, ENC_BIG_ENDIAN);
ctdp = tvb_get_guint8(try_tvb, try_offset+5) & 0x02;
proto_tree_add_item(tr, hf_scsi_report_opcodes_servactv,
tvb_v, offset_v+5, 1, ENC_BIG_ENDIAN);
try_tvb, try_offset+5, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(tr, hf_scsi_report_opcodes_cdb_length,
tvb_v, offset_v+6, 2, ENC_BIG_ENDIAN);
try_tvb, try_offset+6, 2, ENC_BIG_ENDIAN);
offset_v += 8;
try_offset += 8;
length -= 8;
if (!ctdp) {
continue;
}
it = proto_tree_add_text(tree, tvb_v, offset_v,
it = proto_tree_add_text(tree, try_tvb, try_offset,
12, "Timeout Descriptor");
tr = proto_item_add_subtree(it,
ett_timeout_descriptor);
proto_tree_add_item(tr, hf_scsi_report_opcodes_tdl,
tvb_v, offset_v, 2, ENC_BIG_ENDIAN);
try_tvb, try_offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(tr, hf_scsi_report_opcodes_npt,
tvb_v, offset_v + 4, 4, ENC_BIG_ENDIAN);
try_tvb, try_offset + 4, 4, ENC_BIG_ENDIAN);
proto_tree_add_item(tr, hf_scsi_report_opcodes_rct,
tvb_v, offset_v + 8, 4, ENC_BIG_ENDIAN);
try_tvb, try_offset + 8, 4, ENC_BIG_ENDIAN);
offset_v += 12;
try_offset += 12;
length -= 12;
}
}
break;
default:
proto_tree_add_expert(tree, pinfo, &ei_scsi_no_dissection_for_service_action, tvb_v, offset_v+1, 8);
proto_tree_add_expert(tree, pinfo, &ei_scsi_no_dissection_for_service_action, try_tvb, try_offset+1, 8);
}
END_TRY_SCSI_CDB_ALLOC_LEN;

View File

@ -249,29 +249,33 @@ extern value_string_ext scsi_asc_val_ext;
*
* Please see dissect_spc_inquiry() for an example how to use these
* macros.
*
* Note that try_tvb & try_offset are initialized to be used in the code
* bounded by TRY_SCSI_ALLOC_LEN and END_TRY_SCSI_CDB_ALLOC_LEN
*/
#define TRY_SCSI_CDB_ALLOC_LEN(pinfo, tvb, offset, length) \
#define TRY_SCSI_CDB_ALLOC_LEN(length_arg) \
{ \
volatile gboolean short_packet; \
tvbuff_t *new_tvb; \
guint32 end_data_offset=0; \
volatile gboolean try_short_packet; \
tvbuff_t *try_tvb; \
guint try_offset; \
guint32 try_end_data_offset=0; \
\
short_packet=pinfo->fd->cap_len<pinfo->fd->pkt_len; \
new_tvb=tvb_new_subset(tvb, offset, tvb_length_remaining(tvb, offset), length);\
tvb=new_tvb; \
offset=0; \
try_short_packet=pinfo->fd->cap_len<pinfo->fd->pkt_len; \
try_tvb=tvb_new_subset(tvb_a, offset_a, tvb_length_remaining(tvb_a, offset_a), length_arg); \
try_offset=0; \
TRY {
#define END_TRY_SCSI_CDB_ALLOC_LEN \
if(end_data_offset){ \
if(try_end_data_offset){ \
/* just verify we can read all the bytes we were\
* supposed to. \
*/ \
tvb_get_guint8(tvb,end_data_offset); \
tvb_get_guint8(try_tvb,try_end_data_offset); \
} \
} /* TRY */ \
CATCH(BoundsError) { \
if(short_packet){ \
if(try_short_packet){ \
/* this was a short packet */ \
RETHROW; \
} else { \
@ -285,7 +289,7 @@ extern value_string_ext scsi_asc_val_ext;
} \
} \
CATCH(ReportedBoundsError) { \
if(short_packet){ \
if(try_short_packet){ \
/* this was a short packet */ \
RETHROW; \
} else { \
@ -307,8 +311,21 @@ extern value_string_ext scsi_asc_val_ext;
* the future. There is no harm in teaching the dissector about how long
* the data pdu is supposed to be according to alloc_len in the data pdu
*/
#define SET_SCSI_DATA_END(offset) \
end_data_offset=offset;
#define SET_SCSI_DATA_END(offset_arg) \
try_end_data_offset=offset_arg;
#endif
/*
* Editor modelines - http://www.wireshark.org/tools/modelines.html
*
* Local variables:
* c-basic-offset: 8
* tab-width: 8
* indent-tabs-mode: t
* End:
*
* vi: set shiftwidth=8 tabstop=8 noexpandtab:
* :indentSize=8:tabSize=8:noTabs=false:
*/