Text   |  XML   |  ReML   |   Visible Warnings:

Ignored Return Value  at packet-ldss.c:296

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

dissect_ldss_broadcast

(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/dissectors/packet-ldss.c)expand/collapse
Show more  
 267  dissect_ldss_broadcast(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 268  {
 269          guint16 messageID;
 270          guint8 digest_type;
 271          guint8 compression;
 272          guint32 cookie;
 273          guint8 *digest;
 274          guint64 size;
 275          guint64 offset;
 276          guint32 targetTime;
 277          guint16 port;
 278          guint16 rate;
 279          guint16 messageDetail = INFERRED_NONE;
 280   
 281          proto_tree      *ti, *ldss_tree;
 282   
 283          const gchar *packet_type, *packet_detail;
 284       
 285          messageID   = tvb_get_ntohs  (tvb,  0);
 286          digest_type = tvb_get_guint8 (tvb,  2);
 287          compression = tvb_get_guint8 (tvb,  3);
 288          cookie      = tvb_get_ntohl  (tvb,  4);
 289          digest      = tvb_memdup     (tvb,  8, DIGEST_LEN);
 290          size        = tvb_get_ntoh64 (tvb, 40);
 291          offset      = tvb_get_ntoh64 (tvb, 48);
 292          targetTime  = tvb_get_ntohl  (tvb, 56);
 293          port        = tvb_get_ntohs  (tvb, 64);
 294          rate        = tvb_get_ntohs  (tvb, 66);
 295       
 296          packet_type = val_to_str(messageID, ldss_message_id_value, "unknown");
 297   
 298          if (messageID == MESSAGE_ID_WILLSEND) {
 299                  if (cookie == 0) {
 300                          /* Shutdown: Dishonor promises from this peer. Current 
 301                           * implementation abuses WillSend for this. */
 302                          messageDetail = INFERRED_PEERSHUTDOWN;
 303                  }
 304                  else if (size == 0 && offset == 0) {
 305                          /* NeedFile search failed - going to WAN */
 306                          messageDetail = INFERRED_WANDOWNLOAD;
 307                  }
 308                  else if (size > 0) {
 309                          /* Size is known (not always the case) */
 310                          if (size == offset) {
 311                                  /* File is available for pull on this peer's TCP port */
 312                                  messageDetail = INFERRED_OFFER;
 313                          }
 314                          else {
 315                                  /* WAN download progress announcement from this peer */
 316                                  messageDetail = INFERRED_PROMISE;
 317                          }
 318                  }
 319          }
 320          else if (messageID == MESSAGE_ID_NEEDFILE) {
 321                  messageDetail = INFERRED_SEARCH;
 322          }
 323          packet_detail = val_to_str(messageDetail, ldss_inferred_info, "unknown");
 324   
 325          /* Set the info column */
 326          if (check_col(pinfo->cinfo, COL_INFO)) {
 327                  col_add_fstr(pinfo->cinfo, COL_INFO, "LDSS Broadcast (%s%s)",
 328                               packet_type,
 329                               packet_detail);
 330          }
 331                           
 332          /* If we have a non-null tree (ie we are building the proto_tree 
 333           * instead of just filling out the columns), then give more detail. */
 334          if (tree) {
 335                  ti = proto_tree_add_item(tree, proto_ldss,
 336                                           tvb, 0, (tvb_length(tvb) > 72) ? tvb_length(tvb) : 72, FALSE);
 337                  ldss_tree = proto_item_add_subtree(ti, ett_ldss_broadcast);
 338   
 339                  ti = proto_tree_add_item(ldss_tree, hf_ldss_message_id,
 340                                           tvb, 0, 2, FALSE);
 341                  ti = proto_tree_add_uint(ldss_tree, hf_ldss_message_detail,
 342                                           tvb, 0, 0, messageDetail);
 343                  PROTO_ITEM_SET_GENERATED(ti);
 344                  ti = proto_tree_add_item(ldss_tree, hf_ldss_digest_type,
 345                                           tvb, 2,            1,  FALSE);
 346                  ti = proto_tree_add_item(ldss_tree, hf_ldss_compression,
 347                                           tvb, 3,            1,  FALSE);
 348                  ti = proto_tree_add_uint_format_value(ldss_tree, hf_ldss_cookie,
 349                                                        tvb, 4,       4,  FALSE,
 350                                                        "0x%x%s",
 351                                                        cookie,
 352                                                        (cookie == 0)
 353                                                        ? " - shutdown (promises from this peer are no longer valid)"
 354                                                        : "");
 355                  ti = proto_tree_add_item(ldss_tree, hf_ldss_digest,
 356                                           tvb, 8,            DIGEST_LEN, FALSE);
 357                  ti = proto_tree_add_item(ldss_tree, hf_ldss_size,
 358                                           tvb, 40,    8, FALSE);
 359                  ti = proto_tree_add_item(ldss_tree, hf_ldss_offset,
 360                                           tvb, 48,    8, FALSE);
 361                  ti = proto_tree_add_uint_format_value(ldss_tree, hf_ldss_target_time,
 362                                                        tvb, 56,    4,    FALSE,
 363                                                        "%d:%02d:%02d",
 364                                                        (int)(targetTime / 3600),
 365                                                        (int)((targetTime / 60) % 60),
 366                                                        (int)(targetTime % 60));
 367                  ti = proto_tree_add_item(ldss_tree, hf_ldss_reserved_1,
 368                                           tvb, 60,    4, FALSE);
 369                  ti = proto_tree_add_uint_format_value(ldss_tree, hf_ldss_port,
 370                                                        tvb, 64,    2,    FALSE,
 371                                                        "%d%s",
 372                                                        port,
 373                                                        (messageID == MESSAGE_ID_WILLSEND &&
 374                                                         size > 0 &&
 375                                                         size == offset)
 376                                                        ? " - file can be pulled at this TCP port"
 377                                                        : (messageID == MESSAGE_ID_NEEDFILE 
 378                                                           ? " - file can be pushed to this TCP port"
 379                                                           : ""));
 380                  ti = proto_tree_add_uint_format_value(ldss_tree, hf_ldss_rate,
 381                                                        tvb, 66,    2,    FALSE,
 382                                                        "%ld",
 383                                                        (rate > 0)
 384                                                        ? (long)floor(exp(rate * G_LN2 / 2048))
 385                                                        : 0);
 386                  ti = proto_tree_add_item(ldss_tree, hf_ldss_priority,
 387                                           tvb, 68, 2, FALSE);
 388                  ti = proto_tree_add_item(ldss_tree, hf_ldss_property_count,
 389                                           tvb, 70, 2, FALSE);
 390                  if (tvb_length(tvb) > 72) {
 391                          ti = proto_tree_add_item(ldss_tree, hf_ldss_properties,
 392                                                   tvb, 72, tvb_length(tvb) - 72, FALSE);
 393                  }
 394          }
 395   
 396          /* Finally, store the broadcast and register ourselves to dissect
 397           * any pushes or pulls that result from this broadcast. All data
 398           * is pushed/pulled over TCP using the port from the broadcast
 399           * packet's port field.
 400           * Track each by a TCP conversation with the remote end wildcarded.
 401           * The TCP conv tracks back to a broadcast conv to determine what it 
 402           * is in response to.
 403           *
 404           * These steps only need to be done once per packet, so a variable 
 405           * tracks the highest frame number seen. Handles the case of first frame
 406           * being frame zero. */
 407          if (messageDetail != INFERRED_PEERSHUTDOWN &&
 408              (highest_num_seen == 0 ||
 409               highest_num_seen < pinfo->fd->num)) {
 410   
 411                  ldss_broadcast_t *data;
 412   
 413                  /* Populate data from the broadcast */
 414                  data = se_alloc0(sizeof(ldss_broadcast_t));
 415                  data->num = pinfo->fd->num;
 416                  data->ts = pinfo->fd->abs_ts;
 417                  data->message_id = messageID;
 418                  data->message_detail = messageDetail;
 419                  data->port = port;
 420                  data->size = size;
 421                  data->offset = offset;
 422                  data->compression = compression;
 423   
 424                  data->file = se_alloc0(sizeof(ldss_file_t));
 425                  data->file->digest = digest;
 426                  data->file->digest_type = digest_type;
 427   
 428                  data->broadcaster = se_alloc0(sizeof(ldss_broadcaster_t));
 429                  COPY_ADDRESS(&data->broadcaster->addr, &pinfo->src);
 430                  data->broadcaster->port = port;
 431   
 432                  /* Dissect any future pushes/pulls */
 433                  if (port > 0) {
 434                          prepare_ldss_transfer_conv(data);
 435                  }
 436   
 437                  /* Record that the frame was processed */
 438                  highest_num_seen = pinfo->fd->num;
 439          }
 440   
 441          return tvb_length(tvb);
 442  }
Show more  




Change Warning 5485.35753 : Ignored Return Value

Because they are very similar, this warning shares annotations with warning 5485.35754.

Priority:
State:
Finding:
Owner:
Note: