Text   |  XML   |  ReML   |   Visible Warnings:

Unreachable Control Flow  at packet-catapult-dct2000.c:2110

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

dissect_catapult_dct2000

(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/dissectors/packet-catapult-dct2000.c)expand/collapse
Show more  
 1519  dissect_catapult_dct2000(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 1520  {
 1521      proto_tree  *dct2000_tree = NULL;
 1522      proto_item  *ti = NULL;
 1523      gint        offset = 0;
 1524      gint        context_length;
 1525      guint8      port_number;
 1526      gint        protocol_start;
 1527      gint        protocol_length;
 1528      gint        timestamp_start;
 1529      gint        timestamp_length;
 1530      gint        variant_start;
 1531      gint        variant_length;
 1532      gint        outhdr_start;
 1533      gint        outhdr_length;
 1534      guint8      direction;
 1535      tvbuff_t    *next_tvb;
 1536      int         encap;
 1537      dissector_handle_t protocol_handle = 0;
 1538      dissector_handle_t heur_protocol_handle = 0;
 1539      int sub_dissector_result = 0;
 1540      char        *protocol_name;
 1541   
 1542      /* Set Protocol */
 1543      if (check_col(pinfo->cinfo, COL_PROTOCOL))
 1544      {
 1545          col_set_str(pinfo->cinfo, COL_PROTOCOL, "DCT2000");
 1546      }
 1547   
 1548      /* Clear Info */
 1549      if (check_col(pinfo->cinfo, COL_INFO))
 1550      {
 1551          col_clear(pinfo->cinfo, COL_INFO);
 1552      }
 1553   
 1554      /* Create root (protocol) tree. */
 1555      if (tree)
 1556      {
 1557          ti = proto_tree_add_item(tree, proto_catapult_dct2000, tvb, offset, -1, FALSE);
 1558          dct2000_tree = proto_item_add_subtree(ti, ett_catapult_dct2000);
 1559      }
 1560   
 1561      /*********************************************************************/
 1562      /* Note that these are the fields of the stub header as written out  */
 1563      /* by the wiretap module                                             */
 1564   
 1565      /* Context Name */
 1566      context_length = tvb_strsize(tvb, offset);
 1567      if (dct2000_tree) {
 1568          proto_tree_add_item(dct2000_tree, hf_catapult_dct2000_context, tvb,
 1569                              offset, context_length, FALSE);
 1570      }
 1571      offset += context_length;
 1572   
 1573      /* Context port number */
 1574      port_number = tvb_get_guint8(tvb, offset);
 1575      if (dct2000_tree) {
 1576          proto_tree_add_item(dct2000_tree, hf_catapult_dct2000_port_number, tvb,
 1577                              offset, 1, FALSE);
 1578      }
 1579      offset++;
 1580   
 1581      /* Timestamp in file */
 1582      timestamp_start = offset;
 1583      timestamp_length = tvb_strsize(tvb, offset);
 1584      if (dct2000_tree) {
 1585          /* TODO: this is *very* slow, but float version adds trailing digits when 
 1586                   displayed as a custom column... */
 1587          proto_tree_add_double(dct2000_tree, hf_catapult_dct2000_timestamp, tvb,
 1588                                offset, timestamp_length,
 1589                                atof(tvb_get_ptr(tvb, offset, timestamp_length)));
 1590      }
 1591      offset += timestamp_length;
 1592   
 1593   
 1594      /* DCT2000 protocol name */
 1595      protocol_start = offset;
 1596      protocol_length = tvb_strsize(tvb, offset);
 1597      if (dct2000_tree) {
 1598          proto_tree_add_item(dct2000_tree, hf_catapult_dct2000_protocol, tvb,
 1599                              offset, protocol_length, FALSE);
 1600      }
 1601      offset += protocol_length;
 1602   
 1603      /* Protocol Variant */
 1604      variant_start = offset;
 1605      variant_length = tvb_strsize(tvb, offset);
 1606      if (dct2000_tree) {
 1607          proto_tree_add_item(dct2000_tree, hf_catapult_dct2000_variant, tvb,
 1608                              offset, variant_length, FALSE);
 1609      }
 1610      offset += variant_length;
 1611   
 1612      /* Outhdr (shown as string) */
 1613      outhdr_start = offset;
 1614      outhdr_length = tvb_strsize(tvb, offset);
 1615      if ((outhdr_length > 1) && dct2000_tree)
 1616      {
 1617          proto_tree_add_item(dct2000_tree, hf_catapult_dct2000_outhdr, tvb,
 1618                              offset, outhdr_length, FALSE);
 1619      }
 1620      offset += outhdr_length;
 1621   
 1622   
 1623      /* Direction */
 1624      direction = tvb_get_guint8(tvb, offset);
 1625      if (dct2000_tree) {
 1626          proto_tree_add_item(dct2000_tree, hf_catapult_dct2000_direction, tvb,
 1627                              offset, 1, FALSE);
 1628      }
 1629      offset++;
 1630   
 1631      /* Read frame encapsulation set by wiretap */
 1632      if (dct2000_tree) {
 1633          proto_tree_add_item(dct2000_tree, hf_catapult_dct2000_encap, tvb, offset, 1, FALSE);
 1634      }
 1635      encap = tvb_get_guint8(tvb, offset);
 1636      offset++;
 1637   
 1638      if (dct2000_tree)
 1639      {
 1640          /* Set selection length of dct2000 tree */
 1641          proto_item_set_len(dct2000_tree, offset);
 1642      }
 1643   
 1644      /* Add useful details to protocol tree label */
 1645      protocol_name = (char*)tvb_get_ptr(tvb, protocol_start, protocol_length);
 1646      if (tree)
 1647      {
 1648          proto_item_append_text(ti, "   context=%s.%u   t=%s   %c   prot=%s (v=%s)",
 1649                                 tvb_get_ptr(tvb, 0, context_length),
 1650                                 port_number,
 1651                                 tvb_get_ptr(tvb, timestamp_start, timestamp_length),
 1652                                 (direction == 0) ? 'S' : 'R',
 1653                                 protocol_name,
 1654                                 tvb_get_ptr(tvb, variant_start, variant_length));
 1655      }
 1656   
 1657   
 1658   
 1659      /* FP protocols need info from outhdr attached */
 1660      if ((strcmp(protocol_name, "fp") == 0) ||
 1661          (strcmp(protocol_name, "fp_r4") == 0) ||
 1662          (strcmp(protocol_name, "fp_r5") == 0) ||
 1663          (strcmp(protocol_name, "fp_r6") == 0) ||
 1664          (strcmp(protocol_name, "fp_r7") == 0) ||
 1665          (strcmp(protocol_name, "fpiur_r5") == 0))
 1666      {
 1667          parse_outhdr_string(tvb_get_ptr(tvb, outhdr_start, outhdr_length));
 1668          attach_fp_info(pinfo, direction, protocol_name,
 1669                         atoi((char*)tvb_get_ptr(tvb, variant_start, variant_length)));
 1670      }
 1671   
 1672      /* LTE MAC needs info attached */
 1673      else if (strcmp(protocol_name, "mac_r8_lte") == 0)
 1674      {
 1675          parse_outhdr_string(tvb_get_ptr(tvb, outhdr_start, outhdr_length));
 1676          attach_mac_lte_info(pinfo);
 1677      }
 1678   
 1679      /* LTE RLC needs info attached */
 1680      else if (strcmp(protocol_name, "rlc_r8_lte") == 0)
 1681      {
 1682          parse_outhdr_string(tvb_get_ptr(tvb, outhdr_start, outhdr_length));
 1683          attach_rlc_lte_info(pinfo);
 1684      }
 1685   
 1686      /* LTE PDCP needs info attached */
 1687      else if (strcmp(protocol_name, "pdcp_r8_lte") == 0)
 1688      {
 1689          parse_outhdr_string(tvb_get_ptr(tvb, outhdr_start, outhdr_length));
 1690          attach_pdcp_lte_info(pinfo);
 1691      }
 1692   
 1693   
 1694      /* Note that the first item of pinfo->pseudo_header->dct2000 will contain
 1695         the pseudo-header needed (in some cases) by the Wireshark dissector that 
 1696         this packet data will be handed off to. */
 1697   
 1698   
 1699      /***********************************************************************/
 1700      /* Now hand off to the dissector of intended packet encapsulation type */
 1701   
 1702      /* Get protocol handle, and set p2p_dir where necessary.
 1703         (packet-frame.c won't copy it from pseudo-header because it doesn't
 1704          know about Catapult DCT2000 encap type...)
 1705      */
 1706      switch (encap)
 1707      {
 1708          case WTAP_ENCAP_RAW_IP:
 1709              protocol_handle = find_dissector("ip");
 1710              break;
 1711          case WTAP_ENCAP_ETHERNET:
 1712              protocol_handle = find_dissector("eth_withoutfcs");
 1713              break;
 1714          case WTAP_ENCAP_ISDN:
 1715              protocol_handle = find_dissector("lapd");
 1716              pinfo->p2p_dir = pinfo->pseudo_header->isdn.uton;
 1717              break;
 1718          case WTAP_ENCAP_ATM_PDUS_UNTRUNCATED:
 1719              protocol_handle = find_dissector("atm_untruncated");
 1720              break;
 1721          case WTAP_ENCAP_PPP:
 1722              protocol_handle = find_dissector("ppp_hdlc");
 1723              pinfo->p2p_dir = pinfo->pseudo_header->p2p.sent;
 1724              break;
 1725          case DCT2000_ENCAP_SSCOP:
 1726              protocol_handle = find_dissector("sscop");
 1727              break;
 1728          case WTAP_ENCAP_FRELAY:
 1729              protocol_handle = find_dissector("fr");
 1730              break;
 1731          case DCT2000_ENCAP_MTP2:
 1732              protocol_handle = find_dissector("mtp2");
 1733              break;
 1734          case DCT2000_ENCAP_NBAP:
 1735              protocol_handle = find_dissector("nbap");
 1736              break;
 1737   
 1738          case DCT2000_ENCAP_UNHANDLED:
 1739              /**********************************************************/
 1740              /* The wiretap module wasn't able to set an encapsulation */
 1741              /* type, but it may still be possible to dissect the data */
 1742              /* if we know about the protocol or if we can recognise   */
 1743              /* and parse or skip a primitive header                   */
 1744              /**********************************************************/
 1745   
 1746              /* Show context.port in src or dest column as appropriate */
 1747              if (check_col(pinfo->cinfo, COL_DEF_SRC) && direction == 0)
 1748              {
 1749                  col_add_fstr(pinfo->cinfo, COL_DEF_SRC,
 1750                               "%s.%u",
 1751                               tvb_get_ptr(tvb, 0, context_length),
 1752                               port_number);
 1753              }
 1754              else 
 1755              if (check_col(pinfo->cinfo, COL_DEF_DST) && direction == 1)
 1756              {
 1757                  col_add_fstr(pinfo->cinfo, COL_DEF_DST,
 1758                               "%s.%u",
 1759                               tvb_get_ptr(tvb, 0, context_length),
 1760                               port_number);
 1761              }
 1762   
 1763   
 1764              /**************************************************************************/
 1765              /* These protocols have no encapsulation type, just look them up directly */
 1766              if (strcmp(protocol_name, "mac_r8_lte") == 0)
 1767              {
 1768                  protocol_handle = mac_lte_handle;
 1769              }
 1770   
 1771              else 
 1772              if (strcmp(protocol_name, "rlc_r8_lte") == 0)
 1773              {
 1774                  protocol_handle = rlc_lte_handle;
 1775              }
 1776   
 1777              else 
 1778              if (strcmp(protocol_name, "pdcp_r8_lte") == 0)
 1779              {
 1780                  /* Dissect proprietary header, then pass remainder to PDCP */
 1781                  dissect_pdcp_lte(tvb, offset, pinfo, tree);
 1782                  return;
 1783              }
 1784   
 1785   
 1786              /* Work with generic XML protocol. */
 1787              else 
 1788              if (strcmp(protocol_name, "xml") == 0)
 1789              {
 1790                  protocol_handle = find_dissector("xml");
 1791              }
 1792   
 1793   
 1794              /* Attempt to show tty messages as raw text */
 1795              else 
 1796              if (strcmp(protocol_name, "tty") == 0)
 1797              {
 1798                  dissect_tty_lines(tvb, pinfo, dct2000_tree, offset);
 1799                  return;
 1800              }
 1801   
 1802              else 
 1803              if (strcmp(protocol_name, "sipprim") == 0)
 1804              {
 1805                  protocol_handle = find_dissector("sipprim");
 1806              }
 1807   
 1808              else 
 1809              if ((strcmp(protocol_name, "rrc_r8_lte") == 0) ||
 1810                  (strcmp(protocol_name, "rrcpdcpprim_r8_lte") == 0))
 1811              {
 1812                  /* Dissect proprietary header, then pass remainder 
 1813                     to RRC (depending upon direction and channel type) */
 1814                  dissect_rrc_lte(tvb, offset, pinfo, tree);
 1815                  return;
 1816              }
 1817   
 1818   
 1819              /* Many DCT2000 protocols have at least one IPPrim variant. If the
 1820                 protocol name can be matched to a dissector, try to find the
 1821                 UDP/TCP data inside and dissect it.
 1822              */
 1823   
 1824              if (!protocol_handle && catapult_dct2000_try_ipprim_heuristic)
 1825              {
 1826                  guint32      source_addr_offset = 0, dest_addr_offset = 0;
 1827                  guint8       source_addr_length = 0, dest_addr_length = 0;
 1828                  guint32      source_port_offset = 0, dest_port_offset = 0;
 1829                  port_type    type_of_port = PT_NONE;
 1830                  guint16      conn_id_offset = 0;
 1831                  int          offset_before_ipprim_header = offset;
 1832   
 1833                  /* Will give up if couldn't match protocol anyway... */
 1834                  heur_protocol_handle = look_for_dissector(protocol_name);
 1835                  if ((heur_protocol_handle != 0) &&
 1836                      find_ipprim_data_offset(tvb, &offset, direction,
 1837                                              &source_addr_offset, &source_addr_length,
 1838                                              &dest_addr_offset, &dest_addr_length,
 1839                                              &source_port_offset, &dest_port_offset,
 1840                                              &type_of_port,
 1841                                              &conn_id_offset))
 1842                  {
 1843                      proto_tree *ipprim_tree;
 1844                      proto_item *ipprim_ti;
 1845   
 1846                      /* Will use this dissector then. */
 1847                      protocol_handle = heur_protocol_handle;
 1848   
 1849                      /* Add address parameters to tree */
 1850                      /* Unfortunately can't automatically create a conversation filter for this...
 1851                         I *could* create a fake IP header from these details, but then it would be tricky
 1852                         to get the FP dissector called as it has no well-known ports or heuristics... */
 1853                      ipprim_ti =  proto_tree_add_string_format(dct2000_tree, hf_catapult_dct2000_ipprim_addresses,
 1854                                                         tvb, offset_before_ipprim_header, 0,
 1855                                                         "", "IPPrim transport (%s): %s:%u -> %s:%u",
 1856                                                         (type_of_port == PT_UDP) ? "UDP" : "TCP",
 1857                                                         (source_addr_offset) ?
 1858                                                             ((source_addr_length == 4) ?
 1859                                                                (char *)get_hostname(tvb_get_ipv4(tvb, source_addr_offset)) :
 1860                                                                "<ipv6-address>"
 1861                                                              ) :
 1862                                                             "0.0.0.0",
 1863                                                         (source_port_offset) ?
 1864                                                             tvb_get_ntohs(tvb, source_port_offset) :
 1865                                                             0,
 1866                                                         (dest_addr_offset) ?
 1867                                                           ((source_addr_length == 4) ?
 1868                                                                (char *)get_hostname(tvb_get_ipv4(tvb, dest_addr_offset)) :
 1869                                                                "<ipv6-address>"
 1870                                                              ) :
 1871                                                             "0.0.0.0",
 1872                                                         (dest_port_offset) ?
 1873                                                             tvb_get_ntohs(tvb, dest_port_offset) :
 1874                                                             0);
 1875                      if ((type_of_port == PT_TCP) && (conn_id_offset != 0)) {
 1876                          proto_item_append_text(ipprim_ti, " (conn_id=%u)", tvb_get_ntohs(tvb, conn_id_offset));
 1877                      }
 1878   
 1879                      /* Add these IPPRIM fields inside an IPPRIM subtree */
 1880                      ipprim_tree = proto_item_add_subtree(ipprim_ti, ett_catapult_dct2000_ipprim);
 1881   
 1882                      /* Try to add right stuff to pinfo so conversation stuff works... */
 1883                      pinfo->ptype = type_of_port;
 1884                      switch (type_of_port) {
 1885                          case PT_UDP:
 1886                              pinfo->ipproto = IP_PROTO_UDP;
 1887                              break;
 1888                          case PT_TCP:
 1889                              pinfo->ipproto = IP_PROTO_TCP;
 1890                              break;
 1891                          default:
 1892                              pinfo->ipproto = IP_PROTO_NONE;
 1893                      }
 1894   
 1895                      /* Add addresses & ports into ipprim tree.
 1896                         Also set address info in pinfo for conversations... */
 1897                      if (source_addr_offset != 0)
 1898                      {
 1899                          proto_item *addr_ti;
 1900   
 1901                          SET_ADDRESS(&pinfo->net_src,
 1902                                      (source_addr_length == 4) ? AT_IPv4 : AT_IPv6,
 1903                                      source_addr_length,
 1904                                      (tvb_get_ptr(tvb, source_addr_offset, source_addr_length)));
 1905                          SET_ADDRESS(&pinfo->src,
 1906                                      (source_addr_length == 4) ? AT_IPv4 : AT_IPv6,
 1907                                      source_addr_length,
 1908                                      (tvb_get_ptr(tvb, source_addr_offset, source_addr_length)));
 1909   
 1910                          proto_tree_add_item(ipprim_tree,
 1911                                              (source_addr_length == 4) ?  
 1912                                                  hf_catapult_dct2000_ipprim_src_addr_v4 :
 1913                                                  hf_catapult_dct2000_ipprim_src_addr_v6,
 1914                                              tvb, source_addr_offset, source_addr_length, FALSE);
 1915   
 1916                          /* Add hidden item for "side-less" addr */
 1917                          addr_ti = proto_tree_add_item(ipprim_tree,
 1918                                                        (source_addr_length == 4) ?
 1919                                                            hf_catapult_dct2000_ipprim_addr_v4 :
 1920                                                            hf_catapult_dct2000_ipprim_addr_v6,
 1921                                                        tvb, source_addr_offset,
 1922                                                        source_addr_length, FALSE);
 1923                          PROTO_ITEM_SET_HIDDEN(addr_ti);
 1924                      }
 1925                      if (source_port_offset != 0)
 1926                      {
 1927                          proto_item *port_ti;
 1928   
 1929                          pinfo->srcport = tvb_get_ntohs(tvb, source_port_offset);
 1930   
 1931                          proto_tree_add_item(ipprim_tree,
 1932                                              (type_of_port == PT_UDP) ?
 1933                                                 hf_catapult_dct2000_ipprim_udp_src_port :
 1934                                                 hf_catapult_dct2000_ipprim_tcp_src_port,
 1935                                              tvb, source_port_offset, 2, FALSE);
 1936                          port_ti = proto_tree_add_item(ipprim_tree,
 1937                                                        (type_of_port == PT_UDP) ?
 1938                                                            hf_catapult_dct2000_ipprim_udp_port :
 1939                                                            hf_catapult_dct2000_ipprim_tcp_port,
 1940                                                        tvb, source_port_offset, 2, FALSE);
 1941                          PROTO_ITEM_SET_HIDDEN(port_ti);
 1942                      }
 1943                      if (dest_addr_offset != 0)
 1944                      {
 1945                          proto_item *addr_ti;
 1946   
 1947                          SET_ADDRESS(&pinfo->net_dst,
 1948                                      (dest_addr_length == 4) ? AT_IPv4 : AT_IPv6,
 1949                                      dest_addr_length,
 1950                                      (tvb_get_ptr(tvb, dest_addr_offset, dest_addr_length)));
 1951                          SET_ADDRESS(&pinfo->dst,
 1952                                      (dest_addr_length == 4) ? AT_IPv4 : AT_IPv6,
 1953                                      dest_addr_length,
 1954                                      (tvb_get_ptr(tvb, dest_addr_offset, dest_addr_length)));
 1955                          proto_tree_add_item(ipprim_tree,
 1956                                              (dest_addr_length == 4) ?  
 1957                                                  hf_catapult_dct2000_ipprim_dst_addr_v4 :
 1958                                                  hf_catapult_dct2000_ipprim_dst_addr_v6,
 1959                                              tvb, dest_addr_offset, dest_addr_length, FALSE);
 1960   
 1961                          /* Add hidden item for "side-less" addr */
 1962                          addr_ti = proto_tree_add_item(ipprim_tree,
 1963                                                        (dest_addr_length == 4) ?  
 1964                                                            hf_catapult_dct2000_ipprim_addr_v4 :
 1965                                                            hf_catapult_dct2000_ipprim_addr_v6,
 1966                                                        tvb, dest_addr_offset, dest_addr_length, FALSE);
 1967                          PROTO_ITEM_SET_HIDDEN(addr_ti);
 1968                      }
 1969                      if (dest_port_offset != 0)
 1970                      {
 1971                          proto_item *port_ti;
 1972   
 1973                          pinfo->destport = tvb_get_ntohs(tvb, dest_port_offset);
 1974   
 1975                          proto_tree_add_item(ipprim_tree,
 1976                                              (type_of_port == PT_UDP) ?
 1977                                                 hf_catapult_dct2000_ipprim_udp_dst_port :
 1978                                                 hf_catapult_dct2000_ipprim_tcp_dst_port,
 1979                                              tvb, dest_port_offset, 2, FALSE);
 1980                          port_ti = proto_tree_add_item(ipprim_tree,
 1981                                                        (type_of_port == PT_UDP) ?
 1982                                                            hf_catapult_dct2000_ipprim_udp_port :
 1983                                                            hf_catapult_dct2000_ipprim_tcp_port,
 1984                                                        tvb, dest_port_offset, 2, FALSE);
 1985                          PROTO_ITEM_SET_HIDDEN(port_ti);
 1986                      }
 1987                      if (conn_id_offset != 0)
 1988                      {
 1989                          proto_tree_add_item(ipprim_tree,
 1990                                              hf_catapult_dct2000_ipprim_conn_id,
 1991                                              tvb, conn_id_offset, 2, FALSE);
 1992                      }
 1993   
 1994   
 1995                      /* Set source and dest columns now (will be overwriiten if 
 1996                         src and dst IP addresses set) */
 1997                      if (source_addr_offset && check_col(pinfo->cinfo, COL_DEF_SRC))
 1998                      {
 1999                          col_append_fstr(pinfo->cinfo, COL_DEF_SRC,
 2000                                          "(%s:%u)",
 2001                                          (char*)get_hostname(tvb_get_ipv4(tvb, source_addr_offset)),
 2002                                          tvb_get_ntohs(tvb, source_port_offset));
 2003                      }
 2004                      if (dest_addr_offset && check_col(pinfo->cinfo, COL_DEF_DST))
 2005                      {
 2006                          col_append_fstr(pinfo->cinfo, COL_DEF_DST,
 2007                                          "(%s:%u)",
 2008                                          (char*)get_hostname(tvb_get_ipv4(tvb, dest_addr_offset)),
 2009                                          tvb_get_ntohs(tvb, dest_port_offset));
 2010                      }
 2011   
 2012                      /* Set length for IPPrim tree */
 2013                      proto_item_set_len(ipprim_tree, offset - offset_before_ipprim_header);
 2014                  }
 2015              }
 2016   
 2017   
 2018              /* Try SCTP Prim heuristic if configured to */
 2019              if (!protocol_handle && catapult_dct2000_try_sctpprim_heuristic)
 2020              {
 2021                  guint32      dest_addr_offset = 0;
 2022                  guint16      dest_addr_length = 0;
 2023                  guint32      dest_port_offset = 0;
 2024                  int          offset_before_sctpprim_header = offset;
 2025   
 2026                  heur_protocol_handle = look_for_dissector(protocol_name);
 2027                  if ((heur_protocol_handle != 0) &&
 2028                      (find_sctpprim_variant1_data_offset(tvb, &offset,
 2029                                                          &dest_addr_offset,
 2030                                                          &dest_addr_length,
 2031                                                          &dest_port_offset) ||
 2032                       find_sctpprim_variant3_data_offset(tvb, &offset,
 2033                                                          &dest_addr_offset,
 2034                                                          &dest_addr_length,
 2035                                                          &dest_port_offset)))
 2036                  {
 2037                      proto_tree *sctpprim_tree;
 2038                      proto_item *ti_local;
 2039   
 2040                      /* Will use this dissector then. */
 2041                      protocol_handle = heur_protocol_handle;
 2042   
 2043                      ti_local =  proto_tree_add_string_format(dct2000_tree, hf_catapult_dct2000_sctpprim_addresses,
 2044                                                         tvb, offset_before_sctpprim_header, 0,
 2045                                                         "", "SCTPPrim transport:  -> %s:%u",
 2046                                                         (dest_addr_offset) ?
 2047                                                           ((dest_addr_length == 4) ?
 2048                                                                (char *)get_hostname(tvb_get_ipv4(tvb, dest_addr_offset)) :
 2049                                                                "<ipv6-address>"
 2050                                                              ) :
 2051                                                             "0.0.0.0",
 2052                                                         (dest_port_offset) ?
 2053                                                           tvb_get_ntohs(tvb, dest_port_offset) :
 2054                                                           0);
 2055   
 2056                      /* Add these SCTPPRIM fields inside an SCTPPRIM subtree */
 2057                      sctpprim_tree = proto_item_add_subtree(ti_local, ett_catapult_dct2000_sctpprim);
 2058   
 2059                      pinfo->ipproto = IP_PROTO_SCTP;
 2060   
 2061                      /* Destination address */
 2062                      if (dest_addr_offset != 0)
 2063                      {
 2064                          proto_item *addr_ti;
 2065   
 2066                          SET_ADDRESS(&pinfo->net_dst,
 2067                                      (dest_addr_length == 4) ? AT_IPv4 : AT_IPv6,
 2068                                      dest_addr_length,
 2069                                      (tvb_get_ptr(tvb, dest_addr_offset, dest_addr_length)));
 2070                          SET_ADDRESS(&pinfo->dst,
 2071                                      (dest_addr_length == 4) ? AT_IPv4 : AT_IPv6,
 2072                                      dest_addr_length,
 2073                                      (tvb_get_ptr(tvb, dest_addr_offset, dest_addr_length)));
 2074                          proto_tree_add_item(sctpprim_tree,
 2075                                              (dest_addr_length == 4) ?  
 2076                                                  hf_catapult_dct2000_sctpprim_dst_addr_v4 :
 2077                                                  hf_catapult_dct2000_sctpprim_dst_addr_v6,
 2078                                              tvb, dest_addr_offset, dest_addr_length, FALSE);
 2079   
 2080                          /* Add hidden item for "side-less" addr */
 2081                          addr_ti = proto_tree_add_item(sctpprim_tree,
 2082                                                        (dest_addr_length == 4) ?  
 2083                                                            hf_catapult_dct2000_sctpprim_addr_v4 :
 2084                                                            hf_catapult_dct2000_sctpprim_addr_v6,
 2085                                                        tvb, dest_addr_offset, dest_addr_length, FALSE);
 2086                          PROTO_ITEM_SET_HIDDEN(addr_ti);
 2087                      }
 2088   
 2089                      if (dest_port_offset != 0)
 2090                      {
 2091                          pinfo->destport = tvb_get_ntohs(tvb, dest_port_offset);
 2092   
 2093                          proto_tree_add_item(sctpprim_tree,
 2094                                              hf_catapult_dct2000_sctpprim_dst_port,
 2095                                              tvb, dest_port_offset, 2, FALSE);
 2096                      }
 2097   
 2098                      /* Set length for SCTPPrim tree */
 2099                      proto_item_set_len(sctpprim_tree, offset - offset_before_sctpprim_header);
 2100                  }
 2101              }
 2102   
 2103              break;
 2104   
 2105          default:
 2106              /* !! If get here, there is a mismatch between 
 2107                 this dissector and the wiretap module catapult_dct2000.c !!
 2108              */
 2109              DISSECTOR_ASSERT_NOT_REACHED();
 2110              return;
 2111      }
 2112   
 2113   
 2114      /* Try appropriate dissector, if one has been selected */
 2115      if (protocol_handle != 0)
 2116      {
 2117          /* Dissect the remainder of the frame using chosen protocol handle */
 2118          next_tvb = tvb_new_subset(tvb, offset, -1, tvb_reported_length(tvb)-offset);
 2119          sub_dissector_result = call_dissector_only(protocol_handle, next_tvb, pinfo, tree);
 2120      }
 2121   
 2122   
 2123      if (protocol_handle == 0 || sub_dissector_result == 0)
 2124      {
 2125          /* Could get here because:
 2126             - encap is DCT2000_ENCAP_UNHANDLED and we still didn't handle it, OR 
 2127             - desired protocol is unavailable (probably disabled), OR 
 2128             - protocol rejected our data
 2129             Show remaining bytes as unparsed data */
 2130          proto_tree_add_item(dct2000_tree, hf_catapult_dct2000_unparsed_data,
 2131                              tvb, offset, -1, FALSE);
 2132   
 2133          if (check_col(pinfo->cinfo, COL_INFO))
 2134          {
 2135              col_add_fstr(pinfo->cinfo, COL_INFO,
 2136                           "Not dissected  (context=%s.%u   t=%s   %c   prot=%s (v=%s))",
 2137                           tvb_get_ptr(tvb, 0, context_length),
 2138                           port_number,
 2139                           tvb_get_ptr(tvb, timestamp_start, timestamp_length),
 2140                           (direction == 0) ? 'S' : 'R',
 2141                           tvb_get_ptr(tvb, protocol_start, protocol_length),
 2142                           tvb_get_ptr(tvb, variant_start, variant_length));
 2143          }
 2144      }
 2145      else 
 2146      {
 2147          /* Show number of dissected bytes */
 2148          if (dct2000_tree) {
 2149              proto_item *ti_local = proto_tree_add_uint(dct2000_tree,
 2150                                                   hf_catapult_dct2000_dissected_length,
 2151                                                   tvb, 0, 0, tvb_reported_length(tvb)-offset);
 2152              PROTO_ITEM_SET_GENERATED(ti_local);
 2153          }
 2154      }
 2155  }
Show more  




Change Warning 1971.33401 : Unreachable Control Flow

Priority:
State:
Finding:
Owner:
Note: