Text   |  XML   |  ReML   |   Visible Warnings:

Useless Assignment  at packet-bgp.c:641

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

mp_addr_to_str

(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/dissectors/packet-bgp.c)expand/collapse
Show more  
 529  mp_addr_to_str (guint16 afi, guint8 safi, tvbuff_t *tvb, gint offset, emem_strbuf_t *strbuf)
 530  {
 531      int                 length;                         /* length of the address in byte */
 532      guint32             ip4addr,ip4addr2;               /* IPv4 address                 */
 533      guint16             rd_type;                        /* Route Distinguisher type     */
 534      struct e_in6_addr   ip6addr;                        /* IPv6 address                 */
 535   
 536      length = 0 ;
 537      switch (afi) {
 538          case AFNUM_INET:
 539                  switch (safi) {
 540                          case SAFNUM_UNICAST:
 541                          case SAFNUM_MULCAST:
 542                          case SAFNUM_UNIMULC:
 543                          case SAFNUM_MPLS_LABEL:
 544                          case SAFNUM_TUNNEL:
 545                                  length = 4 ;
 546                                  ip4addr = tvb_get_ipv4(tvb, offset);
 547                                  ep_strbuf_append(strbuf, ip_to_str((guint8 *)&ip4addr));
 548                                  break;
 549                          case SAFNUM_LAB_VPNUNICAST:
 550                          case SAFNUM_LAB_VPNMULCAST:
 551                          case SAFNUM_LAB_VPNUNIMULC:
 552                                  rd_type=tvb_get_ntohs(tvb,offset) ;
 553                                  switch (rd_type) {
 554                                          case FORMAT_AS2_LOC:
 555                                                  length = 8 + sizeof(ip4addr);
 556                                                  ip4addr = tvb_get_ipv4(tvb, offset + 8);   /* Next Hop */
 557                                                  ep_strbuf_printf(strbuf, "Empty Label Stack RD=%u:%u IPv4=%s",
 558                                                                  tvb_get_ntohs(tvb, offset + 2),
 559                                                                  tvb_get_ntohl(tvb, offset + 4),
 560                                                                  ip_to_str((guint8 *)&ip4addr));
 561                                                  break;
 562                                          case FORMAT_IP_LOC:
 563                                                  length = 8 + sizeof(ip4addr);
 564                                                  ip4addr = tvb_get_ipv4(tvb, offset + 2);   /* IP part of the RD            */
 565                                                  ip4addr2 = tvb_get_ipv4(tvb, offset + 8);  /* Next Hop   */
 566                                                  ep_strbuf_printf(strbuf, "Empty Label Stack RD=%s:%u IPv4=%s",
 567                                                                  ip_to_str((guint8 *)&ip4addr),
 568                                                                  tvb_get_ntohs(tvb, offset + 6),
 569                                                                  ip_to_str((guint8 *)&ip4addr2));
 570                                                  break ;
 571                                          default:
 572                                                  length = 0 ;
 573                                                  ep_strbuf_printf(strbuf, "Unknown (0x%04x) labeled VPN IPv4 address format",rd_type);
 574                                                  break;
 575                                  }
 576                                  break;
 577                          default:
 578                              length = 0 ;
 579                              ep_strbuf_printf(strbuf, "Unknown SAFI (%u) for AFI %u", safi, afi);
 580                              break;
 581                  }
 582                  break;
 583          case AFNUM_INET6:
 584                  switch (safi) {
 585                          case SAFNUM_UNICAST:
 586                          case SAFNUM_MULCAST:
 587                          case SAFNUM_UNIMULC:
 588                          case SAFNUM_MPLS_LABEL:
 589                          case SAFNUM_TUNNEL:
 590                              length = 16 ;
 591                              tvb_get_ipv6(tvb, offset, &ip6addr);
 592                              ep_strbuf_printf(strbuf, "%s", ip6_to_str(&ip6addr));
 593                              break;
 594                          case SAFNUM_LAB_VPNUNICAST:
 595                          case SAFNUM_LAB_VPNMULCAST:
 596                          case SAFNUM_LAB_VPNUNIMULC:
 597                                  rd_type=tvb_get_ntohs(tvb,offset) ;
 598                                  switch (rd_type) {
 599                                          case FORMAT_AS2_LOC:
 600                                                  length = 8 + 16;
 601                                                  tvb_get_ipv6(tvb, offset + 8, &ip6addr); /* Next Hop */
 602                                                  ep_strbuf_printf(strbuf, "Empty Label Stack RD=%u:%u IPv6=%s",
 603                                                                  tvb_get_ntohs(tvb, offset + 2),
 604                                                                  tvb_get_ntohl(tvb, offset + 4),
 605                                                                  ip6_to_str(&ip6addr));
 606                                                  break;
 607                                          case FORMAT_IP_LOC:
 608                                                  length = 8 + 16;
 609                                                  ip4addr = tvb_get_ipv4(tvb, offset + 2);   /* IP part of the RD            */
 610                                                  tvb_get_ipv6(tvb, offset + 8, &ip6addr); /* Next Hop */
 611                                                  ep_strbuf_printf(strbuf, "Empty Label Stack RD=%s:%u IPv6=%s",
 612                                                                  ip_to_str((guint8 *)&ip4addr),
 613                                                                  tvb_get_ntohs(tvb, offset + 6),
 614                                                                  ip6_to_str(&ip6addr));
 615                                                  break ;
 616                                          default:
 617                                                  length = 0 ;
 618                                                  ep_strbuf_printf(strbuf, "Unknown (0x%04x) labeled VPN IPv6 address format",rd_type);
 619                                                  break;
 620                                  }
 621                                  break;
 622                          default:
 623                              length = 0 ;
 624                              ep_strbuf_printf(strbuf, "Unknown SAFI (%u) for AFI %u", safi, afi);
 625                              break;
 626                  }
 627                  break;
 628         case AFNUM_L2VPN:
 629         case AFNUM_L2VPN_OLD:
 630                  switch (safi) {
 631                          case SAFNUM_LAB_VPNUNICAST: /* only labeles prefixes do make sense */
 632                          case SAFNUM_LAB_VPNMULCAST:
 633                          case SAFNUM_LAB_VPNUNIMULC:
 634                          case SAFNUM_VPLS:
 635                              length = 4; /* the next-hop is simply an ipv4 addr */
 636                              ip4addr = tvb_get_ipv4(tvb, offset + 0);
 637                              ep_strbuf_printf(strbuf, "IPv4=%s",
 638                                       ip_to_str((guint8 *)&ip4addr));
 639                              break;
 640                          default:
 641                              length = 0 ;
 642                              ep_strbuf_printf(strbuf, "Unknown SAFI (%u) for AFI %u", safi, afi);
 643                              break;
 644                  }
 645                  break;
 646          default:
 647                  length = 0 ;
 648                  ep_strbuf_printf(strbuf, "Unknown AFI (%u) value", afi);
 649                  break;
 650      }
 651      return(length) ;
 652  }
Show more  




Change Warning 1930.31228 : Useless Assignment

Because they are very similar, this warning shares annotations with warnings 1930.31229, 1930.31230, and 1930.31231.

Priority:
State:
Finding:
Owner:
Note: