Text   |  XML   |  ReML   |   Visible Warnings:

Ignored Return Value  at packet-lldp.c:767

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

dissect_lldp_port_id

(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/dissectors/packet-lldp.c)expand/collapse
Show more  
 721  dissect_lldp_port_id(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 offset)
 722  {
 723          guint8 tempType;
 724          guint16 tempShort;
 725          guint32 tempLen = 0;
 726          const char *strPtr;
 727          const guint8 *mac_addr = NULL;
 728          guint32 ip_addr;
 729          struct e_in6_addr ip6_addr;
 730          guint8 addr_family = 0;
 731   
 732          proto_tree      *port_tree = NULL;
 733          proto_item      *tf = NULL;
 734   
 735          /* Get tlv type */
 736          tempShort = tvb_get_ntohs(tvb, offset);
 737          tempType = TLV_TYPE(tempShort);
 738          if (tempType != PORT_ID_TLV_TYPE)
 739                  return -1;
 740   
 741          /* Get tlv length and subtype */
 742          tempLen = TLV_INFO_LEN(tempShort);
 743          tempType = tvb_get_guint8(tvb, (offset+2));
 744   
 745          /* Get port id */
 746          switch (tempType)
 747          {
 748          case 3: /* MAC address */
 749          {
 750                  if (tempLen != 7)
 751                          return -1;      /* Invalid port id */
 752   
 753                  mac_addr=tvb_get_ptr(tvb, (offset+3), 6);
 754                  strPtr = ether_to_str(mac_addr);
 755   
 756                  break;
 757          }
 758          case 4: /* Network address */
 759          {
 760                  /* Get network address family */
 761                  addr_family = tvb_get_guint8(tvb,offset+3);
 762                  /* Check for IPv4 or IPv6 */
 763                  switch(addr_family){
 764                  case AFNUM_INET:
 765                          if (tempLen == 6){
 766                                  ip_addr = tvb_get_ipv4(tvb, (offset+4));
 767                                  strPtr = ip_to_str((guint8 *)&ip_addr);
 768                          }else{
 769                                  return -1;
 770                          }
 771                          break;
 772                  case AFNUM_INET6:
 773                          if  (tempLen == 18){
 774                                  tvb_get_ipv6(tvb, (offset+4), &ip6_addr);
 775                                  strPtr = ip6_to_str(&ip6_addr);
 776                          }else{
 777                                  return -1;      /* Invalid chassis id */
 778                          }
 779                          break;
 780                  default:
 781                          strPtr = tvb_bytes_to_str(tvb, (offset+4), (tempLen-2));
 782                          break;
 783                  }
 784                  break;
 785          }
 786          default:
 787          {
 788                  strPtr = tvb_format_stringzpad(tvb, (offset+3), (tempLen-1));
 789   
 790                  break;
 791          }
 792          }
 793   
 794          if (check_col(pinfo->cinfo, COL_INFO))
 795                  col_append_fstr(pinfo->cinfo, COL_INFO, "Port Id = %s ", strPtr);
 796   
 797          if (tree)
 798          {
 799                  /* Set port tree */
 800                  tf = proto_tree_add_text(tree, tvb, offset, (tempLen + 2), "Port Subtype = %s",
 801                                                                  val_to_str(tempType, port_id_subtypes, "Unknown" ));
 802                  port_tree = proto_item_add_subtree(tf, ett_port_id);
 803   
 804                  proto_tree_add_item(port_tree, hf_lldp_tlv_type, tvb, offset, 2, FALSE);
 805                  proto_tree_add_item(port_tree, hf_lldp_tlv_len, tvb, offset, 2, FALSE);
 806   
 807                  /* Get port id subtype */
 808                  proto_tree_add_item(port_tree, hf_port_id_subtype, tvb, (offset+2), 1, FALSE);
 809   
 810                  /* Get port id */
 811                  /*proto_tree_add_text(port_tree, tvb, (offset+3), (tempLen-1), "Port Id: %s", strPtr);*/
 812                  switch (tempType)
 813                  {
 814                  case 3: /* MAC address */
 815                          proto_tree_add_ether(port_tree, hf_port_id_mac, tvb, (offset+3), 6, mac_addr);
 816                          break;
 817                  case 4: /* Network address */
 818                          /* Network address
 819                           * networkAddress is an octet string that identifies a particular network address family
 820                           * and an associated network address that are encoded in network octet order.
 821                           */
 822                          /* Network address family */
 823                          proto_tree_add_item(port_tree, hf_lldp_network_address_family, tvb, offset+3, 1, FALSE);
 824                          switch(addr_family){
 825                          case AFNUM_INET:
 826                                  proto_tree_add_ipv4(port_tree, hf_port_id_ip4, tvb, (offset+4), 4, ip_addr);
 827                                  break;
 828                          case AFNUM_INET6:
 829                                  proto_tree_add_ipv6(port_tree, hf_port_id_ip6, tvb, (offset+4), 16, ip6_addr.bytes);
 830                                  break;
 831                          default:
 832                                  proto_tree_add_text(port_tree, tvb, (offset+4), (tempLen-2), "Port Id: %s", strPtr);
 833                                  break;
 834                          }
 835                          break;
 836                  default:
 837                          proto_tree_add_text(port_tree, tvb, (offset+3), (tempLen-1), "Port Id: %s", strPtr);
 838                          proto_item_append_text(tf, ", Id: %s", strPtr);
 839                          break;
 840                  }
 841   
 842          }
 843   
 844          return (tempLen + 2);
 845  }
Show more  




Change Warning 5462.35682 : Ignored Return Value

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

Priority:
State:
Finding:
Owner:
Note: