GSM A DTAP: add UMTS EVS to supported codecs list IE
[metze/wireshark/wip.git] / epan / dissectors / packet-scsi.h
index 7d059426dffdd2934a37babd07de40eca6d995dd..74a745f3d9ce1967b1269371c3313be6565cc1d8 100644 (file)
@@ -5,25 +5,18 @@
  * By Gerald Combs <gerald@wireshark.org>
  * Copyright 2002 Gerald Combs
  *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: GPL-2.0-or-later
  */
 
 #ifndef __PACKET_SCSI_H_
 #define __PACKET_SCSI_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
 #include <epan/exceptions.h>
+#include <epan/srt_table.h>
 
 /* Structure containing itl nexus data :
  * The itlq nexus is a structure containing data specific
@@ -125,7 +118,6 @@ typedef struct _scsi_cdb_table_t {
 #define SCSI_SPC_PERSRESVOUT             0x5F
 #define SCSI_SPC_PREVMEDREMOVAL          0x1E
 #define SCSI_SPC_READBUFFER              0x3C
-#define SCSI_SPC_RCVCOPYRESULTS          0x84
 #define SCSI_SPC_RCVDIAGRESULTS          0x1C
 #define SCSI_SPC_RELEASE6                0x17
 #define SCSI_SPC_RELEASE10               0x57
@@ -227,7 +219,9 @@ extern int hf_scsi_alloclen16;
 #define EXTENDED_FORM              0x08
 #define SERVICE_READ_CAPACITY16           0x10
 #define SERVICE_READ_LONG16       0x11
+#define SERVICE_WRITE_LONG16      0x11
 #define SERVICE_GET_LBA_STATUS     0x12
+#define SERVICE_REPORT_REFERRALS   0x13
 
 extern const value_string service_action_vals[];
 extern const value_string scsi_devid_codeset_val[];
@@ -244,57 +238,53 @@ extern value_string_ext scsi_asc_val_ext;
  * This is semi-common in SCSI and it would be wrong to mark these packets
  * as [malformed packets].
  * These macros will reset the reported length to what the data pdu specified
- * and if a ReportedBoundsError is generated we will instead throw
- * ScsiBoundsError
+ * and if a ContainedBoundsError or ReportedBoundsError is generated we will
+ * instead throw ScsiBoundsError
  *
  * 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;                                      \
+       tvbuff_t *try_tvb;                                              \
+       volatile 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_tvb=tvb_new_subset_length(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);            \
-               }                                                       \
-           } /* TRY */                                                 \
-       CATCH(BoundsError) {                                            \
-               if(short_packet){                                       \
-                       /* this was a short packet */                   \
-                       RETHROW;                                        \
-               } else {                                                \
-                       /* We probably tried to dissect beyond the end  \
-                        * of the alloc len reported in the data        \
-                        * pdu. This is not an error so dont flag it as \
-                        * one                                          \
-                        * it is the alloc_len in the CDB that is the   \
-                        * important one                                \
-                        */                                             \
+                       tvb_get_guint8(try_tvb,try_end_data_offset);    \
                }                                                       \
-           }                                                           \
+       } /* TRY */                                                     \
+       CATCH(BoundsError) {                                            \
+               /* this was a short packet */                           \
+               RETHROW;                                                \
+       }                                                               \
+       CATCH(ContainedBoundsError) {                                   \
+               /* We probably tried to dissect beyond the end          \
+                * of the alloc len reported in the data                \
+                * pdu. This is not an error so don't flag it           \
+                * as one                                               \
+                * it is the alloc_len in the CDB that is the           \
+                * important one                                        \
+                */                                                     \
+       }                                                               \
        CATCH(ReportedBoundsError) {                                    \
-               if(short_packet){                                       \
-                       /* this was a short packet */                   \
-                       RETHROW;                                        \
-               } else {                                                \
-                       /* this packet was not really short but limited \
-                        * due to a short SCSI allocation length        \
-                        */                                             \
-                       THROW(ScsiBoundsError);                         \
-               }                                                       \
-           }                                                           \
+               /* this packet was not really short but limited         \
+                * due to a short SCSI allocation length                \
+                */                                                     \
+               THROW(ScsiBoundsError);                                 \
+       }                                                               \
        ENDTRY;                                                         \
     }
 
@@ -307,8 +297,27 @@ 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;
+
 
+WS_DLL_PUBLIC guint scsistat_param(register_srt_t* srt, const char* opt_arg, char** err);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
 
 #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:
+ */