Text   |  XML   |  ReML   |   Visible Warnings:

Ignored Return Value  at packet-fcoe.c:152

No properties have been set. | edit properties
Jump to warning location ↓ warning details...
Show Events | Options

dissect_fcoe

(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/dissectors/packet-fcoe.c)expand/collapse
Show more  
 114  dissect_fcoe(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 115  {
 116      gint crc_offset;
 117      gint eof_offset;
 118      gint frame_len = 0;
 119      gint header_len = FCOE_HEADER_LEN;
 120      guint version;
 121      const char *ver;
 122      guint16  len_sof;
 123      gint bytes_remaining;
 124      guint8 sof = 0;
 125      guint8 eof = 0;
 126      const char *eof_str;
 127      const char *crc_msg;
 128      const char *len_msg;
 129      proto_item *ti;
 130      proto_item *item;
 131      proto_tree *fcoe_tree = NULL;
 132      proto_tree *crc_tree;
 133      tvbuff_t *next_tvb;
 134      gboolean crc_exists;
 135      guint32 crc_computed = 0;
 136      guint32 crc = 0;
 137   
 138      /*
 139       * For now, handle both the version defined before and after August 2007.
 140       * In the newer version, byte 1 is reserved and always zero.  In the old
 141       * version, it'll never be zero.
 142       */
 143      if (tvb_get_guint8(tvb, 1)) {
 144          header_len = 2;
 145          len_sof = tvb_get_ntohs(tvb, 0);
 146          frame_len = ((len_sof & 0x3ff0) >> 2) - 4;
 147          sof = len_sof & 0xf;
 148          sof |= (sof < 8) ? 0x30 : 0x20;
 149          version = len_sof >> 14;
 150          ver = "pre-T11 ";
 151          if (version != 0)
 152              ver = ep_strdup_printf(ver, "pre-T11 ver %d ", version);
 153      } else {
 154          frame_len = tvb_reported_length_remaining(tvb, 0) -
 155            FCOE_HEADER_LEN - FCOE_TRAILER_LEN;
 156          sof = tvb_get_guint8(tvb, FCOE_HEADER_LEN - 1);
 157   
 158          /*
 159           * Only version 0 is defined at this point.
 160           * Don't print the version in the short summary if it is zero.
 161           */
 162          ver = "";
 163          version = tvb_get_guint8(tvb, 0) >> 4;
 164          if (version != 0)
 165              ver = ep_strdup_printf(ver, "ver %d ", version);
 166      }
 167      if (check_col(pinfo->cinfo, COL_PROTOCOL))  
 168          col_set_str(pinfo->cinfo, COL_PROTOCOL, "FCoE");
 169      crc_offset = header_len + frame_len;
 170      eof_offset = crc_offset + 4;
 171      bytes_remaining = tvb_length_remaining(tvb, header_len);
 172      if (bytes_remaining > frame_len)
 173          bytes_remaining = frame_len;        /* backing length */
 174      next_tvb = tvb_new_subset(tvb, header_len, bytes_remaining, frame_len);
 175       
 176      if (tree) {
 177   
 178          eof_str = "none";
 179          if (tvb_bytes_exist(tvb, eof_offset, 1)) {
 180              eof = tvb_get_guint8(tvb, eof_offset);
 181              eof_str = val_to_str(eof, fcoe_eof_vals, "0x%x");
 182          }
 183   
 184          /*
 185           * Check the CRC.
 186           */
 187          crc_msg = "";
 188          crc_exists = tvb_bytes_exist(tvb, crc_offset, 4);
 189          if (crc_exists) {
 190              crc = tvb_get_ntohl(tvb, crc_offset);
 191              crc_computed = crc32_802_tvb(next_tvb, frame_len);
 192              if (crc != crc_computed) {
 193                  crc_msg = " [bad FC CRC]";
 194              }
 195          }
 196          len_msg = "";
 197          if ((frame_len % 4) != 0 || frame_len < 24) {
 198              len_msg = " [invalid length]";
 199          }
 200   
 201          ti = proto_tree_add_protocol_format(tree, proto_fcoe, tvb, 0,
 202                                              header_len,
 203                                              "FCoE %s(%s/%s) %d bytes%s%s", ver,
 204                                              val_to_str(sof, fcoe_sof_vals,
 205                                                         "0x%x"),
 206                                              eof_str, frame_len, crc_msg,
 207                                              len_msg);
 208   
 209          /* Dissect the FCoE header */
 210   
 211          fcoe_tree = proto_item_add_subtree(ti, ett_fcoe);
 212          proto_tree_add_uint(fcoe_tree, hf_fcoe_ver, tvb, 0, 1, version);
 213          if (tvb_get_guint8(tvb, 1)) {
 214              proto_tree_add_uint(fcoe_tree, hf_fcoe_len, tvb, 0, 2, frame_len);
 215          }
 216          proto_tree_add_uint(fcoe_tree, hf_fcoe_sof, tvb,
 217            header_len - 1, 1, sof);
 218   
 219          /*
 220           * Create the CRC information.
 221           */
 222          if (crc_exists) {
 223              if (crc == crc_computed) {
 224                  item = proto_tree_add_uint_format(fcoe_tree, hf_fcoe_crc, tvb,
 225                                             crc_offset, 4, crc,
 226                                             "CRC: %8.8x [valid]", crc);
 227              } else {
 228                  item = proto_tree_add_uint_format(fcoe_tree, hf_fcoe_crc, tvb,
 229                                             crc_offset, 4, crc,
 230                                             "CRC: %8.8x "
 231                                             "[error: should be %8.8x]",
 232                                             crc, crc_computed);
 233                  expert_add_info_format(pinfo, item, PI_CHECKSUM, PI_ERROR,
 234                                         "Bad FC CRC %8.8x %8.x",
 235                                         crc, crc_computed);
 236              }
 237              proto_tree_set_appendix(fcoe_tree, tvb, crc_offset,  
 238                                      tvb_length_remaining (tvb, crc_offset));
 239          } else {
 240              item = proto_tree_add_text(fcoe_tree, tvb, crc_offset, 0,  
 241                                         "CRC: [missing]");
 242          }
 243          crc_tree = proto_item_add_subtree(item, ett_fcoe_crc);
 244          ti = proto_tree_add_boolean(crc_tree, hf_fcoe_crc_bad, tvb,
 245                                      crc_offset, 4,
 246                                      crc_exists && crc != crc_computed);
 247          PROTO_ITEM_SET_GENERATED(ti);
 248          ti = proto_tree_add_boolean(crc_tree, hf_fcoe_crc_good, tvb,
 249                                      crc_offset, 4,
 250                                      crc_exists && crc == crc_computed);
 251          PROTO_ITEM_SET_GENERATED(ti);
 252   
 253          /*
 254           * Interpret the EOF.
 255           */
 256          if (tvb_bytes_exist(tvb, eof_offset, 1)) {
 257              proto_tree_add_item(fcoe_tree, hf_fcoe_eof, tvb, eof_offset, 1, 0);
 258          }
 259      }
 260   
 261      /* Set the SOF/EOF flags in the packet_info header */
 262      pinfo->sof_eof = 0;
 263      if (sof == FCOE_SOFi3 || sof == FCOE_SOFi2 || sof == FCOE_SOFi4) {
 264          pinfo->sof_eof = PINFO_SOF_FIRST_FRAME;
 265      } else if (sof == FCOE_SOFf) {
 266          pinfo->sof_eof = PINFO_SOF_SOFF;
 267      }
 268   
 269      if (eof != FCOE_EOFn) {
 270          pinfo->sof_eof |= PINFO_EOF_LAST_FRAME;
 271      } else if (eof != FCOE_EOFt) {
 272          pinfo->sof_eof |= PINFO_EOF_INVALID;
 273      }
 274   
 275      /* Call the FC Dissector if this is carrying an FC frame */
 276       
 277      if (fc_handle) {
 278          call_dissector(fc_handle, next_tvb, pinfo, tree);
 279      } else if (data_handle) {
 280          call_dissector(data_handle, next_tvb, pinfo, tree);
 281      }
 282  }
Show more  




Change Warning 5433.35666 : Ignored Return Value

Priority:
State:
Finding:
Owner:
Note: