Text   |  XML   |  ReML   |   Visible Warnings:

Unreachable Computation  at packet-sip.c:2551

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

dissect_sip_common

(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/dissectors/packet-sip.c)expand/collapse
Show more  
 1778  dissect_sip_common(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree,
 1779      gboolean dissect_other_as_continuation, gboolean use_reassembly)
 1780  {
 1781          int orig_offset;
 1782          gint next_offset, linelen;
 1783          int content_length, datalen, reported_datalen;
 1784          line_type_t line_type;
 1785          tvbuff_t *next_tvb;
 1786          gboolean is_known_request;
 1787          gboolean found_match = FALSE;
 1788          const char *descr;
 1789          guint token_1_len = 0;
 1790          guint current_method_idx = 0;
 1791          proto_item *ts = NULL, *ti = NULL, *th = NULL, *sip_element_item = NULL;
 1792          proto_tree *sip_tree = NULL, *reqresp_tree = NULL , *hdr_tree = NULL,
 1793                  *sip_element_tree = NULL, *message_body_tree = NULL, *cseq_tree = NULL,
 1794                  *via_tree = NULL, *reason_tree = NULL, *rack_tree = NULL;
 1795          guchar contacts = 0, contact_is_star = 0, expires_is_0 = 0;
 1796          guint32 cseq_number = 0;
 1797          guchar  cseq_number_set = 0;
 1798          char    cseq_method[MAX_CSEQ_METHOD_SIZE] = "";
 1799          char    call_id[MAX_CALL_ID_SIZE] = "";
 1800          gchar  *media_type_str_lower_case = NULL;
 1801          char   *content_type_parameter_str = NULL;
 1802          guint   resend_for_packet = 0;
 1803          guint   request_for_response = 0;
 1804          guint32 response_time = 0;
 1805          int     strlen_to_copy;
 1806   
 1807   
 1808          /*
 1809           * Note that "tvb_find_line_end()" will return a value that 
 1810           * is not longer than what's in the buffer, so the
 1811           * "tvb_get_ptr()" calls below won't throw exceptions.
 1812           *
 1813           * Note that "tvb_strneql()" doesn't throw exceptions, so 
 1814           * "sip_parse_line()" won't throw an exception.
 1815           */
 1816          orig_offset = offset;
 1817          linelen = tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE);
 1818          if (tvb_strnlen(tvb, offset, linelen) > -1)
 1819          {
 1820                  /*
 1821                   * There's a NULL in the line,
 1822                   * this may be SIP within another protocol.
 1823                   * This heuristic still needs to improve.
 1824                   */
 1825                  return -2;
 1826          }
 1827          line_type = sip_parse_line(tvb, offset, linelen, &token_1_len);
 1828   
 1829          if (line_type == OTHER_LINE) {
 1830                  /*
 1831                   * This is neither a SIP request nor response.
 1832                   */
 1833                  if (!dissect_other_as_continuation) {
 1834                          /*
 1835                           * We were asked to reject this.
 1836                           */
 1837                          return -2;
 1838                  }
 1839   
 1840                  /*
 1841                   * Just dissect it as a continuation.
 1842                   */
 1843          } else if (use_reassembly) {
 1844                  /*
 1845                   * Yes, it's a request or response.
 1846                   * Do header desegmentation if we've been told to,
 1847                   * and do body desegmentation if we've been told to and
 1848                   * we find a Content-Length header.
 1849                   */
 1850                  if (!req_resp_hdrs_do_reassembly(tvb, offset, pinfo,
 1851                      sip_desegment_headers, sip_desegment_body)) {
 1852                          /*
 1853                           * More data needed for desegmentation.
 1854                           */
 1855                          return -1;
 1856                  }
 1857          }
 1858   
 1859          /* Initialise stat info for passing to tap */
 1860          stat_info = ep_alloc(sizeof(sip_info_value_t));
 1861          stat_info->response_code = 0;
 1862          stat_info->request_method = NULL;
 1863          stat_info->reason_phrase = NULL;
 1864          stat_info->resend = 0;
 1865          stat_info->setup_time = 0;
 1866          stat_info->tap_call_id = NULL;
 1867          stat_info->tap_from_addr = NULL;
 1868          stat_info->tap_to_addr = NULL;
 1869   
 1870          if (check_col(pinfo->cinfo, COL_PROTOCOL))
 1871                  col_set_str(pinfo->cinfo, COL_PROTOCOL, "SIP");
 1872   
 1873          switch (line_type) {
 1874   
 1875          case REQUEST_LINE:
 1876                  is_known_request = sip_is_known_request(tvb, offset, token_1_len, &current_method_idx);
 1877                  descr = is_known_request ? "Request" : "Unknown request";
 1878                  if (check_col(pinfo->cinfo, COL_INFO)) {
 1879                          col_add_fstr(pinfo->cinfo, COL_INFO, "%s: %s",
 1880                                       descr,
 1881                                       tvb_format_text(tvb, offset, linelen - SIP2_HDR_LEN - 1));
 1882                  }
 1883                  break;
 1884   
 1885          case STATUS_LINE:
 1886                  descr = "Status";
 1887                  if (check_col(pinfo->cinfo, COL_INFO)) {
 1888                          col_add_fstr(pinfo->cinfo, COL_INFO, "Status: %s",
 1889                                       tvb_format_text(tvb, offset + SIP2_HDR_LEN + 1, linelen - SIP2_HDR_LEN - 1));
 1890                  }
 1891                  stat_info->reason_phrase = tvb_get_ephemeral_string(tvb, offset + SIP2_HDR_LEN + 5, linelen - (SIP2_HDR_LEN + 5));
 1892                  break;
 1893   
 1894          case OTHER_LINE:
 1895          default: /* Squelch compiler complaints */
 1896                  descr = "Continuation";
 1897                  if (check_col(pinfo->cinfo, COL_INFO))
 1898                          col_set_str(pinfo->cinfo, COL_INFO, "Continuation");
 1899                  break;
 1900          }
 1901   
 1902          if (tree) {
 1903                  ts = proto_tree_add_item(tree, proto_sip, tvb, offset, -1, FALSE);
 1904                  sip_tree = proto_item_add_subtree(ts, ett_sip);
 1905          }
 1906   
 1907          switch (line_type) {
 1908   
 1909          case REQUEST_LINE:
 1910                  if (sip_tree) {
 1911                          ti = proto_tree_add_string(sip_tree, hf_Request_Line, tvb, offset, next_offset-offset,
 1912                                                     tvb_format_text(tvb, offset, linelen));
 1913                          reqresp_tree = proto_item_add_subtree(ti, ett_sip_reqresp);
 1914                  }
 1915                  dfilter_sip_request_line(tvb, reqresp_tree, token_1_len);
 1916                  break;
 1917   
 1918          case STATUS_LINE:
 1919                  if (sip_tree) {
 1920                          ti = proto_tree_add_string(sip_tree, hf_Status_Line, tvb, offset, next_offset-offset,
 1921                                                     tvb_format_text(tvb, offset, linelen));
 1922                          reqresp_tree = proto_item_add_subtree(ti, ett_sip_reqresp);
 1923                  }
 1924                  dfilter_sip_status_line(tvb, reqresp_tree);
 1925                  break;
 1926   
 1927          case OTHER_LINE:
 1928                  if (sip_tree) {
 1929                          ti = proto_tree_add_text(sip_tree, tvb, offset, next_offset,
 1930                                                   "%s line: %s", descr,
 1931                                                   tvb_format_text(tvb, offset, linelen));
 1932                          reqresp_tree = proto_item_add_subtree(ti, ett_sip_reqresp);
 1933                          proto_tree_add_text(sip_tree, tvb, offset, -1,
 1934                                              "Continuation data");
 1935                  }
 1936                  return tvb_length_remaining(tvb, offset);
 1937          }
 1938   
 1939          offset = next_offset;
 1940          if (sip_tree) {
 1941                  th = proto_tree_add_item(sip_tree, hf_msg_hdr, tvb, offset,
 1942                                           tvb_length_remaining(tvb, offset), FALSE);
 1943                  proto_item_set_text(th, "Message Header");
 1944                  hdr_tree = proto_item_add_subtree(th, ett_sip_hdr);
 1945          }
 1946   
 1947          /*
 1948           * Process the headers - if we're not building a protocol tree,
 1949           * we just do this to find the blank line separating the 
 1950           * headers from the message body.
 1951           */
 1952          next_offset = offset;
 1953          content_length = -1;
 1954          while (tvb_reported_length_remaining(tvb, offset) > 0) {
 1955                  gint line_end_offset;
 1956                  gint colon_offset;
 1957                  gint semi_colon_offset;
 1958                  gint len;
 1959                  gint parameter_offset;
 1960                  gint parameter_end_offset;
 1961                  gint parameter_len;
 1962                  gint content_type_len, content_type_parameter_str_len;
 1963                  gint header_len;
 1964                  gchar *header_name;
 1965                  dissector_handle_t ext_hdr_handle;
 1966                  gint hf_index;
 1967                  gint value_offset;
 1968                  gint sub_value_offset;
 1969                  gint comma_offset;
 1970                  guchar c;
 1971                  gint value_len;
 1972                  char *value;
 1973                  gboolean is_no_header_termination = FALSE;
 1974                  proto_item *cause;
 1975                  proto_item *ti;
 1976                  proto_tree *pai_uri_item_tree = NULL;
 1977                  proto_tree *pmiss_uri_item_tree = NULL;
 1978                  proto_tree *ppi_uri_item_tree = NULL;
 1979                  proto_tree *tc_uri_item_tree = NULL;
 1980                  proto_tree *to_uri_item_tree = NULL;
 1981                  proto_tree *from_uri_item_tree = NULL;
 1982                  uri_offset_info uri_offsets;
 1983   
 1984   
 1985   
 1986   
 1987   
 1988                  linelen = tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE);
 1989                  if (linelen == 0) {
 1990                          /*
 1991                           * This is a blank line separating the 
 1992                           * message header from the message body.
 1993                           */
 1994                          offset = next_offset;
 1995                          break;
 1996                  }
 1997   
 1998                  line_end_offset = offset + linelen;
 1999                  if(tvb_reported_length_remaining(tvb, next_offset) == 0){
 2000                          is_no_header_termination = TRUE;
 2001                  }else{
 2002                          while ((c = tvb_get_guint8(tvb, next_offset)) == ' ' || c == '\t')
 2003                          {
 2004                                  /*
 2005                                   * This line end is not a header seperator.
 2006                                   * It just extends the header with another line.
 2007                                   * Look for next line end:
 2008                                   */
 2009                                  linelen += (next_offset - line_end_offset);
 2010                                  linelen += tvb_find_line_end(tvb, next_offset, -1, &next_offset, FALSE);
 2011                                  line_end_offset = offset + linelen;
 2012                          }
 2013                  }
 2014                  colon_offset = tvb_find_guint8(tvb, offset, linelen, ':');
 2015                  if (colon_offset == -1) {
 2016                          /*
 2017                           * Malformed header - no colon after the name.
 2018                           */
 2019                          if(hdr_tree) {
 2020                                  proto_tree_add_text(hdr_tree, tvb, offset,
 2021                                                      next_offset - offset, "%s",
 2022                                                      tvb_format_text(tvb, offset, linelen));
 2023                          }
 2024                  } else {
 2025                          header_len = colon_offset - offset;
 2026                          hf_index = sip_is_known_sip_header(tvb, offset, header_len);
 2027   
 2028                          /*
 2029                           * Skip whitespace after the colon.
 2030                           */
 2031                          value_offset = tvb_skip_wsp(tvb, colon_offset + 1, line_end_offset - (colon_offset + 1));
 2032   
 2033                          /*
 2034                           * Fetch the value.
 2035                           */
 2036                          value_len = (gint) (line_end_offset - value_offset);
 2037                          value = tvb_get_ephemeral_string(tvb, value_offset, value_len);
 2038   
 2039                          if (hf_index == -1) {
 2040                                  proto_item *ti = proto_tree_add_text(hdr_tree, tvb,
 2041                                                                       offset, next_offset - offset, "%s",
 2042                                                                       tvb_format_text(tvb, offset, linelen));
 2043                                  header_name = (gchar*)tvb_get_ephemeral_string(tvb, offset, header_len);
 2044                                  ascii_strdown_inplace(header_name);
 2045                                  ext_hdr_handle = dissector_get_string_handle(ext_hdr_subdissector_table, header_name);
 2046                                  if (ext_hdr_handle != NULL) {
 2047                                          tvbuff_t *next_tvb;
 2048                                          next_tvb = tvb_new_subset(tvb, value_offset, value_len, value_len);
 2049                                          dissector_try_string(ext_hdr_subdissector_table, header_name, next_tvb, pinfo, proto_item_add_subtree(ti, ett_sip_ext_hdr));
 2050                                  } else {
 2051                                          expert_add_info_format(pinfo, ti,
 2052                                                                 PI_UNDECODED, PI_NOTE,
 2053                                                                 "Unrecognised SIP header (%s)",
 2054                                                                 tvb_format_text(tvb, offset, header_len));
 2055                                  }
 2056                          } else {
 2057                                  /*
 2058                                   * Add it to the protocol tree,
 2059                                   * but display the line as is.
 2060                                   */
 2061                                  switch ( hf_index ) {
 2062   
 2063                                          case POS_TO :
 2064                                                  if(hdr_tree) {
 2065                                                          sip_element_item = proto_tree_add_string_format(hdr_tree,
 2066                                                                             hf_header_array[hf_index], tvb,
 2067                                                                             offset, next_offset - offset,
 2068                                                                             value, "%s",
 2069                                                                             tvb_format_text(tvb, offset, linelen));
 2070                                                          sip_element_tree = proto_item_add_subtree( sip_element_item,
 2071                                                                             ett_sip_element);
 2072                                                  }
 2073                                                  /* See if we have a SIP/SIPS uri enclosed in <>, if so anything in front is
 2074                                                   * display info.
 2075                                                   */
 2076                                                  parameter_offset = tvb_find_guint8(tvb, value_offset,value_len, '<');
 2077                                                  if ( parameter_offset != -1){
 2078                                                          len = parameter_offset - value_offset;
 2079                                                          if ( len > 1){
 2080                                                                  /* Something in front, must be display info
 2081                                                                   * TODO: Get rid of trailing space(s)
 2082                                                                   */
 2083                                                                  proto_tree_add_item(sip_element_tree, hf_sip_display, tvb, value_offset,
 2084                                                                                      len, FALSE);
 2085                                                          }
 2086                                                          parameter_offset ++;
 2087                                                          parameter_end_offset = parameter_offset;
 2088                                                          /* RFC3261 paragraph 20 
 2089                                                           * The Contact, From, and To header fields contain a URI.  If the URI
 2090                                                           * contains a comma, question mark or semicolon, the URI MUST be
 2091                                                           * enclosed in angle brackets (< and >).  Any URI parameters are 
 2092                                                           * contained within these brackets.  If the URI is not enclosed in angle 
 2093                                                           * brackets, any semicolon-delimited parameters are header-parameters,
 2094                                                           * not URI parameters.
 2095                                                           */
 2096                                                          while (parameter_end_offset < line_end_offset){
 2097                                                                  parameter_end_offset++;
 2098                                                                  c = tvb_get_guint8(tvb, parameter_end_offset);
 2099                                                                  switch (c) {
 2100                                                                          case '>':
 2101                                                                          case ',':
 2102                                                                          case ';':
 2103                                                                          case '?':
 2104                                                                                  goto separator_found;
 2105                                                                          default :
 2106                                                                          break;
 2107                                                                  }
 2108                                                          }
 2109  separator_found:
 2110                                                          parameter_len = parameter_end_offset - parameter_offset;
 2111                                                          ti = proto_tree_add_item(sip_element_tree, hf_sip_to_addr, tvb, parameter_offset,
 2112                                                                          parameter_len, FALSE);
 2113                                                          to_uri_item_tree = proto_item_add_subtree(ti, ett_sip_to_uri);
 2114   
 2115                                                          /*info for the tap for voip_calls.c*/
 2116                                                          stat_info->tap_to_addr=tvb_get_ephemeral_string(tvb, parameter_offset, parameter_len);
 2117   
 2118                                                          parameter_offset = parameter_end_offset + 1;
 2119                                                          /*
 2120                                                           * URI parameters ?
 2121                                                           */
 2122                                                          parameter_end_offset = tvb_find_guint8(tvb, parameter_offset,( line_end_offset - parameter_offset), ';');
 2123                                                          if ( parameter_end_offset == -1)
 2124                                                                  parameter_end_offset = line_end_offset;
 2125   
 2126                                                          offset = parameter_end_offset;
 2127                                                  }
 2128                                                  else 
 2129                                                  {
 2130                                                          /* Extract SIP/SIPS URI */
 2131                                                          parameter_offset = value_offset;
 2132                                                          while (parameter_offset < line_end_offset 
 2133                                                                 && (tvb_strneql(tvb, parameter_offset, "sip", 3) != 0))
 2134                                                                  parameter_offset++;
 2135                                                          len = parameter_offset - value_offset;
 2136                                                          if ( len > 1){
 2137                                                                  /* Something in front, must be display info
 2138                                                                   * TODO: Get rid of trailing space(s)
 2139                                                                   */
 2140                                                                  proto_tree_add_item(sip_element_tree, hf_sip_display, tvb, value_offset,
 2141                                                                                      len, FALSE);
 2142                                                          }
 2143                                                          parameter_end_offset = tvb_find_guint8(tvb, parameter_offset,
 2144                                                                                                 (line_end_offset - parameter_offset), ';');
 2145                                                          if ( parameter_end_offset == -1)
 2146                                                                  parameter_end_offset = line_end_offset;
 2147                                                          parameter_len = parameter_end_offset - parameter_offset;
 2148                                                          ti = proto_tree_add_item(sip_element_tree, hf_sip_to_addr, tvb, parameter_offset,
 2149                                                                          parameter_len, FALSE);
 2150                                                          to_uri_item_tree = proto_item_add_subtree(ti, ett_sip_to_uri);
 2151   
 2152                                                          /*info for the tap for voip_calls.c*/
 2153                                                          stat_info->tap_to_addr=tvb_get_ephemeral_string(tvb, parameter_offset, parameter_len);
 2154                                                          offset = parameter_end_offset;
 2155                                                  }
 2156                                                  if((dissect_sip_uri(tvb, pinfo, value_offset, line_end_offset+2, &uri_offsets)) != -1)
 2157                                                          {
 2158                                                                  if(uri_offsets.uri_user_end > uri_offsets.uri_user_start)
 2159                                                                  {
 2160                                                                          proto_tree_add_item(to_uri_item_tree, hf_sip_to_user, tvb, uri_offsets.uri_user_start,
 2161                                                                                          uri_offsets.uri_user_end - uri_offsets.uri_user_start + 1, FALSE);
 2162                                                                  }
 2163   
 2164                                                                  proto_tree_add_item(to_uri_item_tree, hf_sip_to_host, tvb, uri_offsets.uri_host_start,
 2165                                                                                          uri_offsets.uri_host_end - uri_offsets.uri_host_start + 1, FALSE);
 2166   
 2167                                                                  if(uri_offsets.uri_host_port_end > uri_offsets.uri_host_port_start)
 2168                                                                  {
 2169                                                                          proto_tree_add_item(to_uri_item_tree, hf_sip_to_port, tvb, uri_offsets.uri_host_port_start,
 2170                                                                                          uri_offsets.uri_host_port_end - uri_offsets.uri_host_port_start + 1, FALSE);
 2171                                                                  }
 2172                                                          }
 2173   
 2174                                                  /* Find parameter tag if present.
 2175                                                   * TODO make this generic to find any interesting parameter 
 2176                                                   * use the same method as for SIP headers ?
 2177                                                   */
 2178   
 2179                                                  parameter_offset = offset;
 2180                                                  while (parameter_offset < line_end_offset 
 2181                                                         && (tvb_strneql(tvb, parameter_offset, "tag=", 4) != 0))
 2182                                                          parameter_offset++;
 2183                                                  if ( parameter_offset < line_end_offset ){ /* Tag found */
 2184                                                          parameter_offset = parameter_offset + 4;
 2185                                                          parameter_end_offset = tvb_find_guint8(tvb, parameter_offset,
 2186                                                                                                 (line_end_offset - parameter_offset), ';');
 2187                                                          if ( parameter_end_offset == -1)
 2188                                                                  parameter_end_offset = line_end_offset;
 2189                                                          parameter_len = parameter_end_offset - parameter_offset;
 2190                                                          proto_tree_add_item(sip_element_tree, hf_sip_tag, tvb, parameter_offset,
 2191                                                                              parameter_len, FALSE);
 2192   
 2193                                                  }
 2194                                          break;
 2195   
 2196                                          case POS_FROM :
 2197                                                  if(hdr_tree) {
 2198                                                          sip_element_item = proto_tree_add_string_format(hdr_tree,
 2199                                                                             hf_header_array[hf_index], tvb,
 2200                                                                             offset, next_offset - offset,
 2201                                                                             value, "%s",
 2202                                                                             tvb_format_text(tvb, offset, linelen));
 2203                                                          sip_element_tree = proto_item_add_subtree( sip_element_item, ett_sip_element);
 2204                                                  }
 2205                                                  /* See if we have a SIP/SIPS uri enclosed in <>, if so anything in front is
 2206                                                   * display info.
 2207                                                   */
 2208                                                  parameter_offset = tvb_find_guint8(tvb, value_offset,value_len, '<');
 2209                                                  if ( parameter_offset != -1){
 2210                                                          len = parameter_offset - value_offset;
 2211                                                          if ( len > 1){
 2212                                                                  /* Something in front, must be display info
 2213                                                                   * TODO: Get rid of trailing space(s)
 2214                                                                   */
 2215                                                                  proto_tree_add_item(sip_element_tree, hf_sip_display, tvb, value_offset,
 2216                                                                                      len, FALSE);
 2217                                                          }
 2218                                                          parameter_offset ++;
 2219                                                          parameter_end_offset = parameter_offset;
 2220                                                          /* RFC3261 paragraph 20 
 2221                                                           * The Contact, From, and To header fields contain a URI.  If the URI
 2222                                                           * contains a comma, question mark or semicolon, the URI MUST be
 2223                                                           * enclosed in angle brackets (< and >).  Any URI parameters are 
 2224                                                           * contained within these brackets.  If the URI is not enclosed in angle 
 2225                                                           * brackets, any semicolon-delimited parameters are header-parameters,
 2226                                                           * not URI parameters.
 2227                                                           */
 2228                                                          while (parameter_end_offset < line_end_offset){
 2229                                                                  parameter_end_offset++;
 2230                                                                  c = tvb_get_guint8(tvb, parameter_end_offset);
 2231                                                                  switch (c) {
 2232                                                                          case '>':
 2233                                                                          case ',':
 2234                                                                          case ';':
 2235                                                                          case '?':
 2236                                                                                  goto separator_found2;
 2237                                                                          default :
 2238                                                                          break;
 2239                                                                  }
 2240                                                          }
 2241  separator_found2:
 2242                                                          parameter_len = parameter_end_offset - parameter_offset;
 2243                                                          ti = proto_tree_add_item(sip_element_tree, hf_sip_from_addr, tvb, parameter_offset,
 2244                                                                          parameter_len, FALSE);
 2245                                                          from_uri_item_tree = proto_item_add_subtree(ti, ett_sip_from_uri);
 2246                                                          /*info for the tap for voip_calls.c*/
 2247                                                          stat_info->tap_from_addr=tvb_get_ephemeral_string(tvb, parameter_offset, parameter_len);
 2248                                                          parameter_offset = parameter_end_offset + 1;
 2249                                                          /*
 2250                                                           * URI parameters ?
 2251                                                           */
 2252                                                          parameter_end_offset = tvb_find_guint8(tvb, parameter_offset,( line_end_offset - parameter_offset), ';');
 2253                                                          if ( parameter_end_offset == -1)
 2254                                                                  parameter_end_offset = line_end_offset;
 2255   
 2256                                                          offset = parameter_end_offset;
 2257                                                  }
 2258                                                  else 
 2259                                                  {
 2260                                                          /* Extract SIP/SIPS URI */
 2261                                                          parameter_offset = value_offset;
 2262                                                          while (parameter_offset < line_end_offset 
 2263                                                                 && (tvb_strneql(tvb, parameter_offset, "sip", 3) != 0))
 2264                                                                  parameter_offset++;
 2265                                                          len = parameter_offset - value_offset;
 2266                                                          if ( len > 1){
 2267                                                                  /* Something in front, must be display info
 2268                                                                   * TODO: Get rid of trailing space(s)
 2269                                                                   */
 2270                                                                  proto_tree_add_item(sip_element_tree, hf_sip_display, tvb, value_offset,
 2271                                                                                      len, FALSE);
 2272                                                          }
 2273                                                          parameter_end_offset = tvb_find_guint8(tvb, parameter_offset,
 2274                                                                                                 (line_end_offset - parameter_offset), ';');
 2275                                                          if ( parameter_end_offset == -1)
 2276                                                                  parameter_end_offset = line_end_offset;
 2277                                                          parameter_len = parameter_end_offset - parameter_offset;
 2278                                                          ti = proto_tree_add_item(sip_element_tree, hf_sip_from_addr, tvb, parameter_offset,
 2279                                                                                          parameter_len, FALSE);
 2280                                                          from_uri_item_tree = proto_item_add_subtree(ti, ett_sip_from_uri);
 2281                                                          /*info for the tap for voip_calls.c*/
 2282                                                          stat_info->tap_from_addr=tvb_get_ephemeral_string(tvb, parameter_offset, parameter_len);
 2283                                                          offset = parameter_end_offset;
 2284                                                  }
 2285                                                  if((dissect_sip_uri(tvb, pinfo, value_offset, line_end_offset+2, &uri_offsets)) != -1)
 2286                                                          {
 2287                                                                  if(uri_offsets.uri_user_end > uri_offsets.uri_user_start)
 2288                                                                  {
 2289                                                                          proto_tree_add_item(from_uri_item_tree, hf_sip_from_user, tvb, uri_offsets.uri_user_start,
 2290                                                                                          uri_offsets.uri_user_end - uri_offsets.uri_user_start + 1, FALSE);
 2291                                                                  }
 2292   
 2293                                                                  proto_tree_add_item(from_uri_item_tree, hf_sip_from_host, tvb, uri_offsets.uri_host_start,
 2294                                                                                          uri_offsets.uri_host_end - uri_offsets.uri_host_start + 1, FALSE);
 2295   
 2296                                                                  if(uri_offsets.uri_host_port_end > uri_offsets.uri_host_port_start)
 2297                                                                  {
 2298                                                                          proto_tree_add_item(from_uri_item_tree, hf_sip_from_port, tvb, uri_offsets.uri_host_port_start,
 2299                                                                                          uri_offsets.uri_host_port_end - uri_offsets.uri_host_port_start + 1, FALSE);
 2300                                                                  }
 2301                                                          }
 2302   
 2303                                                  /* Find parameter tag if present.
 2304                                                   * TODO make this generic to find any interesting parameter 
 2305                                                   * use the same method as for SIP headers ?
 2306                                                   */
 2307   
 2308                                                  parameter_offset = offset;
 2309                                                  while (parameter_offset < line_end_offset 
 2310                                                         && (tvb_strneql(tvb, parameter_offset, "tag=", 4) != 0))
 2311                                                          parameter_offset++;
 2312                                                  if ( parameter_offset < line_end_offset ){ /* Tag found */
 2313                                                          parameter_offset = parameter_offset + 4;
 2314                                                          parameter_end_offset = tvb_find_guint8(tvb, parameter_offset,
 2315                                                                                                 (line_end_offset - parameter_offset), ';');
 2316                                                          if ( parameter_end_offset == -1)
 2317                                                                  parameter_end_offset = line_end_offset;
 2318                                                          parameter_len = parameter_end_offset - parameter_offset;
 2319                                                          proto_tree_add_item(sip_element_tree, hf_sip_tag, tvb, parameter_offset,
 2320                                                                              parameter_len, FALSE);
 2321   
 2322                                                  }
 2323                                          break;
 2324   
 2325                                          case POS_P_ASSERTED_IDENTITY :
 2326                                                  if(hdr_tree)
 2327                                                  {
 2328                                                          sip_element_item = proto_tree_add_string_format(hdr_tree,
 2329                                                                             hf_header_array[hf_index], tvb,
 2330                                                                             offset, next_offset - offset,
 2331                                                                             value, "%s",
 2332                                                                             tvb_format_text(tvb, offset, linelen));
 2333                                                          sip_element_tree = proto_item_add_subtree( sip_element_item,
 2334                                                                             ett_sip_element);
 2335                                                  }
 2336   
 2337   
 2338                                                  if((dissect_sip_uri(tvb, pinfo, value_offset, line_end_offset+2, &uri_offsets)) != -1)
 2339                                                           pai_uri_item_tree = display_sip_uri(tvb, sip_element_tree, &uri_offsets, &sip_pai_uri);
 2340                                                  break;
 2341   
 2342                                          case POS_P_PREFERRED_IDENTITY :
 2343                                                  if(hdr_tree)
 2344                                                  {
 2345                                                          sip_element_item = proto_tree_add_string_format(hdr_tree,
 2346                                                                             hf_header_array[hf_index], tvb,
 2347                                                                             offset, next_offset - offset,
 2348                                                                             value, "%s",
 2349                                                                             tvb_format_text(tvb, offset, linelen));
 2350                                                          sip_element_tree = proto_item_add_subtree( sip_element_item,
 2351                                                                             ett_sip_element);
 2352                                                  }
 2353   
 2354                                                  if((dissect_sip_uri(tvb, pinfo, value_offset, line_end_offset+2, &uri_offsets)) != -1)
 2355                                                           ppi_uri_item_tree = display_sip_uri(tvb, sip_element_tree, &uri_offsets, &sip_ppi_uri);
 2356                                                  break;
 2357   
 2358                                          case POS_PERMISSION_MISSING :
 2359                                                  if(hdr_tree)
 2360                                                  {
 2361                                                          sip_element_item = proto_tree_add_string_format(hdr_tree,
 2362                                                                                 hf_header_array[hf_index], tvb,
 2363                                                                                 offset, next_offset - offset,
 2364                                                                                 value, "%s",
 2365                                                                                 tvb_format_text(tvb, offset, linelen));
 2366   
 2367                                                          sip_element_tree = proto_item_add_subtree( sip_element_item,
 2368                                                                                                                             ett_sip_element);
 2369                                                  }
 2370                                                  if((dissect_sip_uri(tvb, pinfo, value_offset, line_end_offset+2, &uri_offsets)) != -1)
 2371                                                           pmiss_uri_item_tree = display_sip_uri(tvb, sip_element_tree, &uri_offsets, &sip_pmiss_uri);
 2372                                                  break;
 2373   
 2374   
 2375                                          case POS_TRIGGER_CONSENT :
 2376                                                  if(hdr_tree)
 2377                                                  {
 2378                                                          sip_element_item = proto_tree_add_string_format(hdr_tree,
 2379                                                                                         hf_header_array[hf_index], tvb,
 2380                                                                                         offset, next_offset - offset,
 2381                                                                                         value, "%s",
 2382                                                                                         tvb_format_text(tvb, offset, linelen));
 2383   
 2384                                                          sip_element_tree = proto_item_add_subtree( sip_element_item,
 2385                                                                                                                                                  ett_sip_element);
 2386                                                  }
 2387   
 2388                                                  if((dissect_sip_uri(tvb, pinfo, value_offset, line_end_offset+2, &uri_offsets)) != -1) {
 2389   
 2390                                                          tc_uri_item_tree = display_sip_uri(tvb, sip_element_tree, &uri_offsets, &sip_tc_uri);
 2391                                                          if (line_end_offset > uri_offsets.uri_end) {
 2392                                                                  gint hparam_offset = uri_offsets.uri_end + 1;
 2393                                                                  /* Is there a header parameter */
 2394                                                                  if (tvb_find_guint8(tvb, hparam_offset, 1,';')) {
 2395                                                                          while ((hparam_offset != -1 && hparam_offset < line_end_offset) )  {
 2396                                                                                  /* Is this a target-uri ? */
 2397                                                                                  hparam_offset = hparam_offset + 1;
 2398                                                                                  if (tvb_strncaseeql(tvb, hparam_offset, "target-uri=\"", 12) == 0) {
 2399                                                                                          gint turi_start_offset = hparam_offset + 12;
 2400                                                                                          gint turi_end_offset   = tvb_find_guint8(tvb, turi_start_offset, -1,'\"');
 2401                                                                                          if (turi_end_offset != -1)
 2402                                                                                                  proto_tree_add_item(tc_uri_item_tree, hf_sip_tc_turi, tvb, turi_start_offset,(turi_end_offset - turi_start_offset),FALSE);
 2403                                                                                          else 
 2404                                                                                                  break; /* malformed */
 2405                                                                                  }
 2406                                                                                  hparam_offset = tvb_find_guint8(tvb, hparam_offset, -1,';');
 2407                                                                          }
 2408                                                                  }
 2409                                                          }
 2410                                                  }
 2411                                           break;
 2412   
 2413                                          case POS_CSEQ :
 2414                                                  /* Store the sequence number */
 2415                                                  cseq_number = atoi(value);
 2416                                                  cseq_number_set = 1;
 2417                                                  stat_info->tap_cseq_number=cseq_number;
 2418   
 2419                                                  /* Add CSeq  tree */
 2420                                                  if (hdr_tree) {
 2421                                                          sip_element_item = proto_tree_add_string_format(hdr_tree,
 2422                                                                                       hf_header_array[hf_index], tvb,
 2423                                                                                       offset, next_offset - offset,
 2424                                                                                       value, "%s",
 2425                                                                                       tvb_format_text(tvb, offset, linelen));
 2426                                                          cseq_tree = proto_item_add_subtree(sip_element_item, ett_sip_cseq);
 2427                                                  }
 2428   
 2429                                                  /* Walk past number and spaces characters to get to start
 2430                                                     of method name */
 2431                                                  for (sub_value_offset=0; sub_value_offset < (gint)strlen(value); sub_value_offset++)
 2432                                                  {
 2433                                                          if (!isdigit((guchar)value[sub_value_offset]))
 2434                                                          {
 2435                                                                  proto_tree_add_uint(cseq_tree, hf_sip_cseq_seq_no,
 2436                                                                                      tvb, value_offset, sub_value_offset,
 2437                                                                                      cseq_number);
 2438                                                                  break;
 2439                                                          }
 2440                                                  }
 2441   
 2442                                                  for (; sub_value_offset < (gint)strlen(value); sub_value_offset++)
 2443                                                  {
 2444                                                          if (isalpha((guchar)value[sub_value_offset]))
 2445                                                          {
 2446                                                                  /* Have reached start of method name */
 2447                                                                  break;
 2448                                                          }
 2449                                                  }
 2450   
 2451                                                  if (sub_value_offset == (gint)strlen(value))
 2452                                                  {
 2453                                                          /* Didn't find method name */
 2454                                                          THROW(ReportedBoundsError);
 2455                                                          return offset - orig_offset;
 2456                                                  }
 2457   
 2458                                                  /* Extract method name from value */
 2459                                                  strlen_to_copy = (int)strlen(value)-sub_value_offset;
 2460                                                  if (strlen_to_copy > MAX_CSEQ_METHOD_SIZE) {
 2461                                                          /* Note the error in the protocol tree */
 2462                                                          if (hdr_tree) {
 2463                                                                  proto_tree_add_string_format(hdr_tree,
 2464                                                                                               hf_header_array[hf_index], tvb,
 2465                                                                                               offset, next_offset - offset,
 2466                                                                                               value+sub_value_offset, "%s String too big: %d bytes",
 2467                                                                                               sip_headers[POS_CSEQ].name,
 2468                                                                                               strlen_to_copy);
 2469                                                          }
 2470                                                          THROW(ReportedBoundsError);
 2471                                                          return offset - orig_offset;
 2472                                                  }
 2473                                                  else {
 2474                                                          g_strlcpy(cseq_method, value+sub_value_offset, MAX_CSEQ_METHOD_SIZE);
 2475   
 2476                                                          /* Add CSeq method to the tree */
 2477                                                          if (cseq_tree)
 2478                                                          {
 2479                                                                  proto_tree_add_item(cseq_tree, hf_sip_cseq_method, tvb,
 2480                                                                                      value_offset + sub_value_offset, strlen_to_copy, FALSE);
 2481                                                          }
 2482                                                  }
 2483                                          break;
 2484   
 2485                                          case POS_RACK :
 2486                                          {
 2487                                                  int cseq_no_offset;
 2488                                                  int cseq_method_offset;
 2489   
 2490                                                  /* Add RAck  tree */
 2491                                                  if (hdr_tree) {
 2492                                                          sip_element_item = proto_tree_add_string_format(hdr_tree,
 2493                                                                                       hf_header_array[hf_index], tvb,
 2494                                                                                       offset, next_offset - offset,
 2495                                                                                       value, "%s",
 2496                                                                                       tvb_format_text(tvb, offset, linelen));
 2497                                                          rack_tree = proto_item_add_subtree(sip_element_item, ett_sip_rack);
 2498                                                  }
 2499   
 2500                                                  /* RSeq number */
 2501                                                  for (sub_value_offset=0; sub_value_offset < (gint)strlen(value); sub_value_offset++)
 2502                                                  {
 2503                                                          if (!isdigit((guchar)value[sub_value_offset]))
 2504                                                          {
 2505                                                                  proto_tree_add_uint(rack_tree, hf_sip_rack_rseq_no,
 2506                                                                                      tvb, value_offset, sub_value_offset,
 2507                                                                                      atoi(value));
 2508                                                                  break;
 2509                                                          }
 2510                                                  }
 2511   
 2512                                                  /* Get to start of CSeq number */
 2513                                                  for ( ; sub_value_offset < (gint)strlen(value); sub_value_offset++)
 2514                                                  {
 2515                                                          if (value[sub_value_offset] != ' ' &&
 2516                                                          value[sub_value_offset] != '\t')
 2517                                                          {
 2518                                                                  break;
 2519                                                          }
 2520                                                  }
 2521                                                  cseq_no_offset = sub_value_offset;
 2522   
 2523                                                  /* CSeq number */
 2524                                                  for ( ; sub_value_offset < (gint)strlen(value); sub_value_offset++)
 2525                                                  {
 2526                                                          if (!isdigit((guchar)value[sub_value_offset]))
 2527                                                          {
 2528                                                                  proto_tree_add_uint(rack_tree, hf_sip_rack_cseq_no,
 2529                                                                                      tvb, value_offset+cseq_no_offset,
 2530                                                                                      sub_value_offset-cseq_no_offset,
 2531                                                                                      atoi(value+cseq_no_offset));
 2532                                                                  break;
 2533                                                          }
 2534                                                  }
 2535   
 2536                                                  /* Get to start of CSeq method name */
 2537                                                  for ( ; sub_value_offset < (gint)strlen(value); sub_value_offset++)
 2538                                                  {
 2539                                                          if (isalpha((guchar)value[sub_value_offset]))
 2540                                                          {
 2541                                                                  /* Have reached start of method name */
 2542                                                                  break;
 2543                                                          }
 2544                                                  }
 2545                                                  cseq_method_offset = sub_value_offset;
 2546   
 2547                                                  if (sub_value_offset == (gint)strlen(value))
 2548                                                  {
 2549                                                          /* Didn't find method name */
 2550                                                          THROW(ReportedBoundsError);
 2551                                                          return offset - orig_offset;
 2552                                                  }
 2553   
 2554                                                  /* Add CSeq method to the tree */
 2555                                                  if (cseq_tree)
 2556                                                  {
 2557                                                          proto_tree_add_item(rack_tree, hf_sip_rack_cseq_method, tvb,
 2558                                                                              value_offset + sub_value_offset,
 2559                                                                              (int)strlen(value)-sub_value_offset, FALSE);
 2560                                                  }
 2561   
 2562                                                  break;
 2563                                          }
 2564   
 2565                                          case POS_CALL_ID :
 2566                                                  /* Store the Call-id */
 2567                                                  g_strlcpy(call_id, value, MAX_CALL_ID_SIZE);
 2568                                                  stat_info->tap_call_id = ep_strdup(call_id);
 2569   
 2570                                                  /* Add 'Call-id' string item to tree */
 2571                                                  if(hdr_tree) {
 2572                                                          sip_element_item = proto_tree_add_string_format(hdr_tree,
 2573                                                                                       hf_header_array[hf_index], tvb,
 2574                                                                                       offset, next_offset - offset,
 2575                                                                                       value, "%s",
 2576                                                                                       tvb_format_text(tvb, offset, linelen));
 2577                                                  }
 2578                                          break;
 2579   
 2580                                          case POS_EXPIRES :
 2581                                                  if (strcmp(value, "0") == 0)
 2582                                                  {
 2583                                                          expires_is_0 = 1;
 2584                                                  }
 2585                                                  /* Add 'Expires' string item to tree */
 2586                                                  if(hdr_tree) {
 2587                                                          sip_element_item = proto_tree_add_uint(hdr_tree,
 2588                                                                              hf_header_array[hf_index], tvb,
 2589                                                                              offset, next_offset - offset,
 2590                                                                              atoi(value));
 2591                                                  }
 2592                                          break;
 2593   
 2594                                          /*
 2595                                           * Content-Type is the same as Internet 
 2596                                           * media type used by other dissectors,
 2597                                           * appropriate dissector found by
 2598                                           * lookup in "media_type" dissector table.
 2599                                           */
 2600                                          case POS_CONTENT_TYPE :
 2601                                                  if(hdr_tree) {
 2602                                                          sip_element_item = proto_tree_add_string_format(hdr_tree,
 2603                                                                                       hf_header_array[hf_index], tvb,
 2604                                                                                       offset, next_offset - offset,
 2605                                                                                       value, "%s",
 2606                                                                                       tvb_format_text(tvb, offset, linelen));
 2607                                                  }
 2608                                                  content_type_len = value_len;
 2609                                                  semi_colon_offset = tvb_find_guint8(tvb, value_offset, value_len, ';');
 2610                                                  /* Content-Type     =  ( "Content-Type" / "c" ) HCOLON media-type
 2611                                                   * media-type       =  m-type SLASH m-subtype *(SEMI m-parameter)
 2612                                                   * SEMI    =  SWS ";" SWS ; semicolon 
 2613                                                   * LWS  =  [*WSP CRLF] 1*WSP ; linear whitespace
 2614                                                   * SWS  =  [LWS] ; sep whitespace
 2615                                                   */
 2616                                                  if ( semi_colon_offset != -1) {
 2617                                                          gint content_type_end;
 2618                                                          /*
 2619                                                           * Skip whitespace after the semicolon.
 2620                                                           */
 2621                                                          parameter_offset = tvb_skip_wsp(tvb, semi_colon_offset +1, value_offset + value_len - (semi_colon_offset +1));
 2622                                                          content_type_end = tvb_skip_wsp_return(tvb, semi_colon_offset-1);
 2623                                                          content_type_len = content_type_end - value_offset;
 2624                                                          content_type_parameter_str_len = value_offset + value_len - parameter_offset;
 2625                                                          content_type_parameter_str = tvb_get_ephemeral_string(tvb, parameter_offset,
 2626                                                                                       content_type_parameter_str_len);
 2627                                                  }
 2628                                                  media_type_str_lower_case = ascii_strdown_inplace(
 2629                                                      (gchar *)tvb_get_ephemeral_string(tvb, value_offset, content_type_len));
 2630   
 2631                                                  /* Debug code
 2632                                                  proto_tree_add_text(hdr_tree, tvb, value_offset,content_type_len,
 2633                                                                      "media_type_str(lower cased)=%s",media_type_str_lower_case);
 2634                                                  */
 2635                                          break;
 2636   
 2637                                          case POS_CONTENT_LENGTH :
 2638                                                  content_length = atoi(value);
 2639                                                  if(hdr_tree) {
 2640                                                          sip_element_item = proto_tree_add_uint_format(hdr_tree,
 2641                                                                             hf_header_array[hf_index], tvb,
 2642                                                                             offset, next_offset - offset,
 2643                                                                             content_length, "%s",
 2644                                                                             tvb_format_text(tvb, offset, linelen));
 2645                          }
 2646                                                  break;
 2647   
 2648                      case POS_MAX_BREADTH :
 2649                                          case POS_MAX_FORWARDS :
 2650                                          case POS_RSEQ :
 2651                                                  if(hdr_tree) {
 2652                                                          sip_element_item = proto_tree_add_uint(hdr_tree,
 2653                                                                              hf_header_array[hf_index], tvb,
 2654                                                                              offset, next_offset - offset,
 2655                                                                              atoi(value));
 2656                                                  }
 2657                                                  break;
 2658   
 2659                                          case POS_CONTACT :
 2660                                                  if(hdr_tree) {
 2661                                                          sip_element_item = proto_tree_add_string_format(hdr_tree,
 2662                                                                             hf_header_array[hf_index], tvb,
 2663                                                                             offset, next_offset - offset,
 2664                                                                             value, "%s",
 2665                                                                             tvb_format_text(tvb, offset, linelen));
 2666                                                          sip_element_tree = proto_item_add_subtree( sip_element_item,
 2667                                                                             ett_sip_element);
 2668                                                  }
 2669                                                  if (strcmp(value, "*") == 0)
 2670                                                  {
 2671                                                          contact_is_star = 1;
 2672                                                          break;
 2673                                                  }
 2674   
 2675                                                  comma_offset = value_offset;
 2676                                                  while((comma_offset = dissect_sip_contact_item(tvb, pinfo, sip_element_tree, comma_offset, next_offset)) != -1)
 2677                                                  {
 2678                                                          contacts++;
 2679                                                          if(comma_offset == next_offset)
 2680                                                          {
 2681                                                                  /* Line End reached: Stop Parsing */
 2682                                                                  break;
 2683                                                          }
 2684   
 2685                                                          if(tvb_get_guint8(tvb, comma_offset) != ',')
 2686                                                          {
 2687                                                                  /* Undefined value reached: Stop Parsing */
 2688                                                                  break;
 2689                                                          }
 2690                                                          comma_offset++; /* skip comma */
 2691                                                  }
 2692                                          break;
 2693   
 2694                                          case POS_AUTHORIZATION:
 2695                                          case POS_WWW_AUTHENTICATE:
 2696                                          case POS_PROXY_AUTHENTICATE:
 2697                                          case POS_PROXY_AUTHORIZATION:
 2698                                          case POS_AUTHENTICATION_INFO:
 2699                                                  /* Add tree using whole text of line */
 2700                                                  if (hdr_tree) {
 2701                                                          proto_item *ti;
 2702                                                          /* Add whole line as header tree */
 2703                                                          sip_element_item = proto_tree_add_string_format(hdr_tree,
 2704                                                                             hf_header_array[hf_index], tvb,
 2705                                                                             offset, next_offset - offset,
 2706                                                                             value, "%s",
 2707                                                                             tvb_format_text(tvb, offset, linelen));
 2708                                                          sip_element_tree = proto_item_add_subtree( sip_element_item,
 2709                                                                             ett_sip_element);
 2710   
 2711                                                          /* Set sip.auth as a hidden field/filter */
 2712                                                          ti = proto_tree_add_item(hdr_tree, hf_sip_auth, tvb,
 2713                                                                                   offset, next_offset-offset,
 2714                                                                                   FALSE);
 2715                                                          PROTO_ITEM_SET_HIDDEN(ti);
 2716                                                  }
 2717   
 2718                                                  /* Parse each individual parameter in the line */
 2719                                                  comma_offset = tvb_pbrk_guint8(tvb, value_offset, line_end_offset - value_offset, " \t\r\n");
 2720   
 2721                                                  /* Authentication-Info does not begin with the scheme name */
 2722                                                  if (hf_index != POS_AUTHENTICATION_INFO)
 2723                                                  {
 2724                                                          proto_tree_add_item(sip_element_tree, hf_sip_auth_scheme,
 2725                                                                              tvb, value_offset, comma_offset - value_offset,
 2726                                                                              FALSE);
 2727                                                  }
 2728   
 2729                                                  while ((comma_offset = dissect_sip_authorization_item(tvb, sip_element_tree, comma_offset, line_end_offset)) != -1)
 2730                                                  {
 2731                                                          if(comma_offset == line_end_offset)
 2732                                                          {
 2733                                                                  /* Line End reached: Stop Parsing */
 2734                                                                  break;
 2735                                                          }
 2736   
 2737                                                          if(tvb_get_guint8(tvb, comma_offset) != ',')
 2738                                                          {
 2739                                                                  /* Undefined value reached: Stop Parsing */
 2740                                                                  break;
 2741                                                          }
 2742                                                          comma_offset++; /* skip comma */
 2743                                                  }
 2744                                          break;
 2745   
 2746                                          case POS_VIA:
 2747                                                  /* Add Via subtree */
 2748                                                  if (hdr_tree) {
 2749                                                          sip_element_item = proto_tree_add_string_format(hdr_tree,
 2750                                                                                       hf_header_array[hf_index], tvb,
 2751                                                                                       offset, next_offset - offset,
 2752                                                                                       value, "%s",
 2753                                                                                       tvb_format_text(tvb, offset, linelen));
 2754                                                          via_tree = proto_item_add_subtree(sip_element_item, ett_sip_via);
 2755                                                  }
 2756                                                  dissect_sip_via_header(tvb, via_tree, value_offset, line_end_offset);
 2757                                                  break;
 2758                                          case POS_REASON:
 2759                                                  if(hdr_tree) {
 2760                                                          sip_element_item = proto_tree_add_string_format(hdr_tree,
 2761                                                                                       hf_header_array[hf_index], tvb,
 2762                                                                                       offset, next_offset - offset,
 2763                                                                                       value, "%s",
 2764                                                                                       tvb_format_text(tvb, offset, linelen));
 2765                                                          reason_tree = proto_item_add_subtree(sip_element_item, ett_sip_reason);
 2766                                                  }
 2767                                                  dissect_sip_reason_header(tvb, reason_tree, value_offset, line_end_offset);
 2768                                                  break;
 2769                                          default :
 2770                                                  /* Default case is to assume its an FT_STRING field */
 2771                                                  if(hdr_tree) {
 2772                                                          sip_element_item = proto_tree_add_string_format(hdr_tree,
 2773                                                                                       hf_header_array[hf_index], tvb,
 2774                                                                                       offset, next_offset - offset,
 2775                                                                                       value, "%s",
 2776                                                                                       tvb_format_text(tvb, offset, linelen));
 2777                                                  }
 2778                                          break;
 2779                                  }/* end switch */
 2780                          }/*if HF_index */
 2781                  }/* if colon_offset */
 2782                  if (is_no_header_termination == TRUE){
 2783                          /* Header not terminated by empty line CRLF */
 2784                          cause=proto_tree_add_text(hdr_tree, tvb, line_end_offset, -1,
 2785                                                  "[Header not terminated by empty line (CRLF)]");
 2786   
 2787                          proto_item_set_expert_flags(cause, PI_MALFORMED, PI_WARN);
 2788                          expert_add_info_format(pinfo, sip_element_item,
 2789                                  PI_MALFORMED, PI_WARN,
 2790                                  "Header not terminated by empty line (CRLF)");
 2791                  }
 2792                  offset = next_offset;
 2793          }/* End while */
 2794   
 2795          datalen = tvb_length_remaining(tvb, offset);
 2796          reported_datalen = tvb_reported_length_remaining(tvb, offset);
 2797          if (content_length != -1) {
 2798                  if (datalen > content_length)
 2799                          datalen = content_length;
 2800                  if (reported_datalen > content_length)
 2801                          reported_datalen = content_length;
 2802          }
 2803   
 2804          if (datalen > 0) {
 2805                  /*
 2806                   * There's a message body starting at "offset".
 2807                   * Set the length of the header item.
 2808                   */
 2809                  proto_item_set_end(th, tvb, offset);
 2810                  next_tvb = tvb_new_subset(tvb, offset, datalen, reported_datalen);
 2811                  if(sip_tree) {
 2812                          ti = proto_tree_add_item(sip_tree, hf_sip_msg_body, next_tvb, 0, -1,
 2813                                                   FALSE);
 2814                          message_body_tree = proto_item_add_subtree(ti, ett_sip_message_body);
 2815                  }
 2816   
 2817                  /* give the content type parameters to sub dissectors */
 2818   
 2819                  if ( media_type_str_lower_case != NULL ) {
 2820                          void *save_private_data = pinfo->private_data;
 2821                          pinfo->private_data = content_type_parameter_str;
 2822                          found_match = dissector_try_string(media_type_dissector_table,
 2823                                                             media_type_str_lower_case,
 2824                                                             next_tvb, pinfo,
 2825                                                             message_body_tree);
 2826                          pinfo->private_data = save_private_data;
 2827                          /* If no match dump as text */
 2828                  }
 2829                  if ( found_match != TRUE )
 2830                  {
 2831              if (!(dissector_try_heuristic(heur_subdissector_list,
 2832                                            next_tvb, pinfo, message_body_tree))) {
 2833                  int tmp_offset = 0;
 2834                  while (tvb_offset_exists(next_tvb, tmp_offset)) {
 2835                      tvb_find_line_end(next_tvb, tmp_offset, -1, &next_offset, FALSE);
 2836                      linelen = next_offset - tmp_offset;
 2837                      if(message_body_tree) {
 2838                          proto_tree_add_text(message_body_tree, next_tvb,
 2839                                              tmp_offset, linelen, "%s",
 2840                                              tvb_format_text(next_tvb, tmp_offset, linelen));
 2841                          }
 2842                      tmp_offset = next_offset;
 2843                      }/* end while */
 2844                          }
 2845                  }
 2846                  offset += datalen;
 2847          }
 2848   
 2849   
 2850          /* Add to info column interesting things learned from header fields. */
 2851          if (check_col(pinfo->cinfo, COL_INFO))
 2852          {
 2853                  /* Registration requests */
 2854                  if (strcmp(sip_methods[current_method_idx], "REGISTER") == 0)
 2855                  {
 2856                          if (contact_is_star && expires_is_0)
 2857                          {
 2858                                  col_append_str(pinfo->cinfo, COL_INFO, "    (remove all bindings)");
 2859                          }
 2860                          else 
 2861                          if (!contacts)
 2862                          {
 2863                                  col_append_str(pinfo->cinfo, COL_INFO, "    (fetch bindings)");
 2864                          }
 2865                  }
 2866   
 2867                  /* Registration responses */
 2868                  if (line_type == STATUS_LINE && (strcmp(cseq_method, "REGISTER") == 0))
 2869                  {
 2870                          col_append_fstr(pinfo->cinfo, COL_INFO, "    (%d bindings)", contacts);
 2871                  }
 2872          }
 2873          /* Find the total setup time, Must be done before checking for resend 
 2874           * As that will overwrite the "Request packet no".
 2875           */
 2876          if ((line_type == REQUEST_LINE)&&(strcmp(cseq_method, "ACK") == 0))
 2877          {
 2878                  request_for_response = sip_find_invite(pinfo, cseq_method, call_id,
 2879                                                          cseq_number_set, cseq_number,
 2880                                                          &response_time);
 2881                  stat_info->setup_time = response_time;
 2882          }
 2883   
 2884          /* Check if this packet is a resend. */
 2885          resend_for_packet = sip_is_packet_resend(pinfo, cseq_method, call_id,
 2886                                                   cseq_number_set, cseq_number,
 2887                                                   line_type);
 2888          /* Mark whether this is a resend for the tap */
 2889          stat_info->resend = (resend_for_packet > 0);
 2890   
 2891          /* And add the filterable field to the request/response line */
 2892          if (reqresp_tree)
 2893          {
 2894                  proto_item *item;
 2895                  item = proto_tree_add_boolean(reqresp_tree, hf_sip_resend, tvb, orig_offset, 0,
 2896                                                resend_for_packet > 0);
 2897                  PROTO_ITEM_SET_GENERATED(item);
 2898                  if (resend_for_packet > 0)
 2899                  {
 2900                          item = proto_tree_add_uint(reqresp_tree, hf_sip_original_frame,
 2901                                                     tvb, orig_offset, 0, resend_for_packet);
 2902                          PROTO_ITEM_SET_GENERATED(item);
 2903                  }
 2904          }
 2905   
 2906      /* For responses, try to link back to request frame */
 2907          if (line_type == STATUS_LINE)
 2908          {
 2909                  request_for_response = sip_find_request(pinfo, cseq_method, call_id,
 2910                                                          cseq_number_set, cseq_number,
 2911                                                          &response_time);
 2912          }
 2913   
 2914          if (reqresp_tree)
 2915          {
 2916                  proto_item *item;
 2917                  if (request_for_response > 0)
 2918                  {
 2919                          item = proto_tree_add_uint(reqresp_tree, hf_sip_matching_request_frame,
 2920                                                     tvb, orig_offset, 0, request_for_response);
 2921                          PROTO_ITEM_SET_GENERATED(item);
 2922                          item = proto_tree_add_uint(reqresp_tree, hf_sip_response_time,
 2923                                                     tvb, orig_offset, 0, response_time);
 2924                          PROTO_ITEM_SET_GENERATED(item);
 2925                          if ((line_type == STATUS_LINE)&&(strcmp(cseq_method, "BYE") == 0)){
 2926                                  item = proto_tree_add_uint(reqresp_tree, hf_sip_release_time,
 2927                                                            tvb, orig_offset, 0, response_time);
 2928                                  PROTO_ITEM_SET_GENERATED(item);
 2929                          }
 2930                  }
 2931          }
 2932   
 2933          if (ts != NULL)
 2934                  proto_item_set_len(ts, offset - orig_offset);
 2935   
 2936          if (global_sip_raw_text)
 2937                  tvb_raw_text_add(tvb, orig_offset, offset - orig_offset, tree);
 2938   
 2939          /* Report this packet to the tap */
 2940          if (!pinfo->in_error_pkt)
 2941          {
 2942                  tap_queue_packet(sip_tap, pinfo, stat_info);
 2943          }
 2944   
 2945          return offset - orig_offset;
 2946  }
Show more  




Change Warning 2947.32964 : Unreachable Computation

Because they are very similar, this warning shares annotations with warnings 2947.32965 and 2947.32966.

Priority:
State:
Finding:
Owner:
Note: