Text   |  XML   |  ReML   |   Visible Warnings:

Ignored Return Value  at packet-pdcp-lte.c:1440

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

dissect_pdcp_lte

(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/dissectors/packet-pdcp-lte.c)expand/collapse
Show more  
 1407  static void dissect_pdcp_lte(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 1408  {
 1409      const char         *mode;
 1410      proto_tree         *pdcp_tree = NULL;
 1411      proto_item         *root_ti = NULL;
 1412      proto_tree         *rohc_tree = NULL;
 1413      proto_item         *rohc_ti = NULL;
 1414      gint               offset = 0;
 1415      gint               rohc_offset;
 1416      struct pdcp_lte_info  *p_pdcp_info;
 1417      guint8             base_header_byte;
 1418      guint8             udp_checksum_needed = TRUE;
 1419   
 1420      /* Append this protocol name rather than replace. */
 1421      if (check_col(pinfo->cinfo, COL_PROTOCOL))
 1422          col_add_str(pinfo->cinfo, COL_PROTOCOL, "PDCP-LTE");
 1423   
 1424      /* Create pdcp tree. */
 1425      if (tree) {
 1426          root_ti = proto_tree_add_item(tree, proto_pdcp_lte, tvb, offset, -1, FALSE);
 1427          pdcp_tree = proto_item_add_subtree(root_ti, ett_pdcp);
 1428      }
 1429   
 1430   
 1431      /* Look for attached packet info! */
 1432      p_pdcp_info = p_get_proto_data(pinfo->fd, proto_pdcp_lte);
 1433      /* Can't dissect anything without it... */
 1434      if (p_pdcp_info == NULL) {
 1435          return;
 1436      }
 1437   
 1438   
 1439      /* Set mode string */
 1440      mode = val_to_str(p_pdcp_info->mode, rohc_mode_vals, "Error");
 1441   
 1442      /* Show configuration (attached packet) info in tree */
 1443      if (pdcp_tree) {
 1444          show_pdcp_config(pinfo, tvb, pdcp_tree, p_pdcp_info);
 1445      }
 1446   
 1447      /* Show ROHC mode */
 1448      if (p_pdcp_info->rohc_compression &&
 1449          check_col(pinfo->cinfo, COL_INFO)) {
 1450   
 1451          col_append_fstr(pinfo->cinfo, COL_INFO, " (mode=%c)", mode[0]);
 1452      }
 1453   
 1454   
 1455      /* Handle PDCP header (if present) */
 1456      if (!p_pdcp_info->no_header_pdu) {
 1457   
 1458          /*****************************/
 1459          /* Signalling plane messages */
 1460          if (p_pdcp_info->plane == SIGNALING_PLANE) {
 1461              guint32 mac;
 1462              guint32 data_length;
 1463   
 1464              /* 5-bit sequence number */
 1465              proto_tree_add_item(pdcp_tree, hf_pdcp_lte_seq_num_5, tvb, offset, 1, FALSE);
 1466              if (check_col(pinfo->cinfo, COL_INFO)) {
 1467                  col_append_fstr(pinfo->cinfo, COL_INFO, " sn=%u",
 1468                                  tvb_get_guint8(tvb, offset) & 0x1f);
 1469              }
 1470              offset++;
 1471   
 1472   
 1473              /* RRC data is all but last 4 bytes.
 1474                 Call lte-rrc dissector (according to direction and channel type) */
 1475              if (global_pdcp_dissect_signalling_plane_as_rrc) {
 1476                  /* Get appropriate dissector handle */
 1477                  dissector_handle_t rrc_handle = lookup_rrc_dissector_handle(p_pdcp_info);
 1478   
 1479                  if (rrc_handle != 0) {
 1480                      /* Call RRC dissector if have one */
 1481                      tvbuff_t *payload_tvb = tvb_new_subset(tvb, offset,
 1482                                                             tvb_length_remaining(tvb, offset) - 4,
 1483                                                             tvb_length_remaining(tvb, offset) - 4);
 1484                      call_dissector_only(rrc_handle, payload_tvb, pinfo, pdcp_tree);
 1485                  }
 1486                  else {
 1487                       /* Just show data */
 1488                          proto_tree_add_item(pdcp_tree, hf_pdcp_lte_signalling_data, tvb, offset,
 1489                                              tvb_length_remaining(tvb, offset) - 4, FALSE);
 1490                  }
 1491              }
 1492              else {
 1493                  /* Just show as unparsed data */
 1494                  proto_tree_add_item(pdcp_tree, hf_pdcp_lte_signalling_data, tvb, offset,
 1495                                      tvb_length_remaining(tvb, offset) - 4, FALSE);
 1496              }
 1497   
 1498              data_length = tvb_length_remaining(tvb, offset) - 4;
 1499              offset += data_length;
 1500   
 1501              /* Last 4 bytes are MAC */
 1502              mac = tvb_get_ntohl(tvb, offset);
 1503              proto_tree_add_item(pdcp_tree, hf_pdcp_lte_mac, tvb, offset, 4, FALSE);
 1504              offset += 4;
 1505   
 1506              if (check_col(pinfo->cinfo, COL_INFO)) {
 1507                  col_append_fstr(pinfo->cinfo, COL_INFO, " MAC=0x%08x (%u bytes data)",
 1508                                  mac, data_length);
 1509              }
 1510   
 1511              return;
 1512          }
 1513          else if (p_pdcp_info->plane == USER_PLANE) {
 1514   
 1515              /**********************************/
 1516              /* User-plane messages            */
 1517              guint16 seqnum;
 1518              gboolean pdu_type = (tvb_get_guint8(tvb, offset) & 0x80) >> 7;
 1519   
 1520              /* Data/Control flag */
 1521              proto_tree_add_item(pdcp_tree, hf_pdcp_lte_data_control, tvb, offset, 1, FALSE);
 1522   
 1523              if (pdu_type == 1) {
 1524                  /*****************************/
 1525                  /* Use-plane Data            */
 1526   
 1527                  /* Number of sequence number bits depends upon config */
 1528                  if (p_pdcp_info->seqnum_length == PDCP_SN_LENGTH_7_BITS) {
 1529                      seqnum = tvb_get_guint8(tvb, offset) & 0x7f;
 1530                      proto_tree_add_item(pdcp_tree, hf_pdcp_lte_seq_num_7, tvb, offset, 1, FALSE);
 1531                      offset++;
 1532                  }
 1533                  else if (p_pdcp_info->seqnum_length == PDCP_SN_LENGTH_12_BITS) {
 1534                      proto_item *ti;
 1535                      guint8 reserved_value;
 1536   
 1537                      /* 3 reserved bits */
 1538                      ti = proto_tree_add_item(pdcp_tree, hf_pdcp_lte_reserved3, tvb, offset, 1, FALSE);
 1539                      reserved_value = (tvb_get_guint8(tvb, offset) & 0x70) >> 4;
 1540   
 1541                      /* Complain if not 0 */
 1542                      if (reserved_value != 0) {
 1543                          expert_add_info_format(pinfo, ti, PI_MALFORMED, PI_ERROR,
 1544                                                 "Reserved bits have value 0x%x - should be 0x0",
 1545                                                 reserved_value);
 1546                      }
 1547   
 1548                      /* 12-bit sequence number */
 1549                      seqnum = tvb_get_ntohs(tvb, offset) & 0x0fff;
 1550                      proto_tree_add_item(pdcp_tree, hf_pdcp_lte_seq_num_12, tvb, offset, 2, FALSE);
 1551                      offset += 2;
 1552                  }
 1553                  else {
 1554                      /* Not a recognised data format!!!!! */
 1555                      return;
 1556                  }
 1557   
 1558                  if (check_col(pinfo->cinfo, COL_INFO)) {
 1559                      col_append_fstr(pinfo->cinfo, COL_INFO, " sn=%u", seqnum);
 1560                  }
 1561              }
 1562              else {
 1563                  /*******************************/
 1564                  /* User-plane Control messages */
 1565                  guint8 control_pdu_type = (tvb_get_guint8(tvb, offset) & 0x70) >> 4;
 1566                  proto_tree_add_item(pdcp_tree, hf_pdcp_lte_control_pdu_type, tvb, offset, 1, FALSE);
 1567   
 1568                  switch (control_pdu_type) {
 1569                      case 0:    /* PDCP status report */
 1570                          {
 1571                              guint16 fms;
 1572                              guint   not_received = 0;
 1573                              guint   sn;
 1574                              proto_tree *bitmap_tree;
 1575                              proto_item *bitmap_ti;
 1576   
 1577                              /* First-Missing-Sequence SN */
 1578                              fms = tvb_get_ntohs(tvb, offset) & 0x0fff;
 1579                              sn = fms;
 1580                              proto_tree_add_item(pdcp_tree, hf_pdcp_lte_fms, tvb,
 1581                                                  offset, 2, FALSE);
 1582                              offset += 2;
 1583   
 1584                              /* Bitmap tree */
 1585                              bitmap_ti = proto_tree_add_item(pdcp_tree, hf_pdcp_lte_bitmap, tvb,
 1586                                                              offset, -1, FALSE);
 1587                              bitmap_tree = proto_item_add_subtree(bitmap_ti, ett_pdcp_rohc_report_bitmap);
 1588   
 1589   
 1590                              /* For each byte... */
 1591                              for ( ; tvb_length_remaining(tvb, offset); offset++) {
 1592                                  guint bit_offset = 0;
 1593                                  /* .. look for error (0) in each bit */
 1594                                  for ( ; bit_offset < 8; bit_offset++) {
 1595                                      if ((tvb_get_guint8(tvb, offset) >> (7-bit_offset) & 0x1) == 0) {
 1596                                          proto_tree_add_boolean_format_value(bitmap_tree, hf_pdcp_lte_bitmap_not_received, tvb, offset, 1, TRUE,
 1597                                                                              " (SN=%u)", sn);
 1598                                          not_received++;
 1599                                      }
 1600                                      sn = (sn + 1) % 4096;
 1601                                  }
 1602                              }
 1603   
 1604                              proto_item_append_text(bitmap_ti, " (not-received=%u)", not_received);
 1605                              if (check_col(pinfo->cinfo, COL_INFO)) {
 1606                                  col_append_fstr(pinfo->cinfo, COL_INFO,
 1607                                                 " Status Report (fms=%u) not-received=%u",
 1608                                                 fms, not_received);
 1609                              }
 1610                          }
 1611                          return;
 1612   
 1613                      case 1:     /* ROHC Feedback */
 1614                          offset++;
 1615                          break;  /* Drop-through to dissect feedback */
 1616   
 1617                      default:    /* Reserved */
 1618                          return;
 1619                  }
 1620              }
 1621          }
 1622          else {
 1623              /* Invalid plane setting...! */
 1624              if (check_col(pinfo->cinfo, COL_INFO)) {
 1625                  col_append_fstr(pinfo->cinfo, COL_INFO, " - INVALID PLANE (%u)",
 1626                                  p_pdcp_info->plane);
 1627              }
 1628              return;
 1629          }
 1630      }
 1631      else {
 1632          /* Show that its a no-header PDU */
 1633          if (check_col(pinfo->cinfo, COL_INFO)) {
 1634              col_append_str(pinfo->cinfo, COL_INFO, " No-Header ");
 1635          }
 1636      }
 1637   
 1638   
 1639      /* If not compressed with ROHC, show as user-plane data */
 1640      if (!p_pdcp_info->rohc_compression) {
 1641   
 1642          if (global_pdcp_dissect_user_plane_as_ip && (ip_handle != 0)) {
 1643              tvbuff_t *payload_tvb = tvb_new_subset(tvb, offset, -1, -1);
 1644              call_dissector_only(ip_handle, payload_tvb, pinfo, pdcp_tree);
 1645          }
 1646          else {
 1647              if (tvb_length_remaining(tvb, offset) > 0) {
 1648                  if (p_pdcp_info->plane == USER_PLANE) {
 1649                      proto_tree_add_item(pdcp_tree, hf_pdcp_lte_user_plane_data, tvb, offset, -1, FALSE);
 1650                  }
 1651                  else {
 1652                      if (global_pdcp_dissect_signalling_plane_as_rrc) {
 1653                          /* Get appropriate dissector handle */
 1654                          dissector_handle_t rrc_handle = lookup_rrc_dissector_handle(p_pdcp_info);
 1655   
 1656                          if (rrc_handle != 0) {
 1657                              /* Call RRC dissector if have one */
 1658                              tvbuff_t *payload_tvb = tvb_new_subset(tvb, offset,
 1659                                                                     tvb_length_remaining(tvb, offset),
 1660                                                                     tvb_length_remaining(tvb, offset));
 1661                              call_dissector_only(rrc_handle, payload_tvb, pinfo, pdcp_tree);
 1662                          }
 1663                          else {
 1664                               /* Just show data */
 1665                               proto_tree_add_item(pdcp_tree, hf_pdcp_lte_signalling_data, tvb, offset,
 1666                                                   tvb_length_remaining(tvb, offset), FALSE);
 1667                          }
 1668                      }
 1669                      else {
 1670                          proto_tree_add_item(pdcp_tree, hf_pdcp_lte_signalling_data, tvb, offset, -1, FALSE);
 1671                      }
 1672                  }
 1673   
 1674                  if (check_col(pinfo->cinfo, COL_INFO)) {
 1675                      col_append_fstr(pinfo->cinfo, COL_INFO, "(%u bytes data)",
 1676                                      tvb_length_remaining(tvb, offset));
 1677                  }
 1678              }
 1679          }
 1680          return;
 1681      }
 1682   
 1683   
 1684      /***************************/
 1685      /* ROHC packets            */
 1686      /***************************/
 1687   
 1688      if (check_col(pinfo->cinfo, COL_PROTOCOL)) {
 1689          col_append_fstr(pinfo->cinfo, COL_PROTOCOL, "|ROHC(%s)",
 1690                          val_to_str(p_pdcp_info->profile, rohc_profile_vals, "Unkown"));
 1691      }
 1692   
 1693      /* Only attempt ROHC if configured to */
 1694      if (!global_pdcp_dissect_rohc) {
 1695          return;
 1696      }
 1697       
 1698      /* Create pdcp tree. */
 1699      if (pdcp_tree) {
 1700          rohc_ti = proto_tree_add_item(pdcp_tree, hf_pdcp_lte_rohc, tvb, offset, -1, FALSE);
 1701          rohc_tree = proto_item_add_subtree(rohc_ti, ett_pdcp_rohc);
 1702      }
 1703   
 1704      rohc_offset = offset;
 1705   
 1706      /* Skip any leading padding octets (11100000) */
 1707      while (tvb_get_guint8(tvb, offset) == 0xe0) {
 1708          offset++;
 1709      }
 1710      if (offset > rohc_offset) {
 1711          proto_tree_add_item(rohc_tree, hf_pdcp_lte_rohc_padding, tvb, rohc_offset,
 1712                              offset-rohc_offset, FALSE);
 1713      }
 1714   
 1715      /* Add-CID octet */
 1716      if ((p_pdcp_info->cid_inclusion_info == CID_IN_ROHC_PACKET) &&
 1717          !p_pdcp_info->large_cid_present)
 1718      {
 1719          if (((tvb_get_guint8(tvb, offset) >> 4) & 0x0f) == 0x0e) {
 1720              proto_tree_add_item(rohc_tree, hf_pdcp_lte_add_cid, tvb, offset, 1, FALSE);
 1721              offset++;
 1722          }
 1723          else {
 1724              /* Assume CID value of 0 if field absent */
 1725              proto_item *ti = proto_tree_add_uint(rohc_tree, hf_pdcp_lte_add_cid, tvb, offset, 0, 0);
 1726              PROTO_ITEM_SET_GENERATED(ti);
 1727          }
 1728      }
 1729   
 1730      /* Now look at first octet of base header and identify packet type */
 1731      base_header_byte = tvb_get_guint8(tvb, offset);
 1732   
 1733      /* IR (1111110) */
 1734      if ((base_header_byte & 0xfe) == 0xfc) {
 1735          offset = dissect_pdcp_ir_packet(rohc_tree, rohc_ti, tvb, offset, p_pdcp_info, pinfo);
 1736      }
 1737   
 1738      /* IRDYN (11111000) */
 1739      else if (base_header_byte == 0xf8) {
 1740          offset = dissect_pdcp_irdyn_packet(rohc_tree, rohc_ti, tvb, offset, p_pdcp_info, pinfo);
 1741          udp_checksum_needed = FALSE;
 1742      }
 1743   
 1744      /* Feedback (begins with 11110) */
 1745      else if (((base_header_byte & 0xf8) >> 3) == 0x1e) {
 1746          offset = dissect_pdcp_feedback_packet(rohc_tree, rohc_ti, tvb, offset, p_pdcp_info, pinfo);
 1747          return;
 1748      }
 1749   
 1750      /* Packet type 0 (0) */
 1751      else if ((base_header_byte & 0x80) == 0) {
 1752   
 1753          /* TODO: decide type based upon:
 1754             - mode 
 1755             - 2nd bit
 1756             - length remaining (taking into  large-cid) */
 1757   
 1758          /* R-0 begins with 00 */
 1759          if (((base_header_byte & 0xc0) == 0) &&
 1760               (p_pdcp_info->mode == RELIABLE_BIDIRECTIONAL)) {
 1761   
 1762              offset = dissect_pdcp_r_0_packet(rohc_tree, rohc_ti, tvb, offset, p_pdcp_info, pinfo);
 1763          }
 1764   
 1765          /* R-0-CRC begins with 01 */
 1766          else if ((((base_header_byte & 0x40) >> 6) == 1) &&
 1767                    (p_pdcp_info->mode == RELIABLE_BIDIRECTIONAL)) {
 1768   
 1769              offset = dissect_pdcp_r_0_crc_packet(rohc_tree, rohc_ti, tvb, offset, p_pdcp_info, pinfo);
 1770          }
 1771   
 1772          else {
 1773              offset = dissect_pdcp_uo_0_packet(rohc_tree, rohc_ti, tvb, offset, p_pdcp_info, pinfo);
 1774          }
 1775      }
 1776   
 1777      /* Packet type 1 (10) */
 1778      else if (((base_header_byte & 0xc0) >> 6) == 2) {
 1779   
 1780          switch (p_pdcp_info->mode) {
 1781   
 1782              case RELIABLE_BIDIRECTIONAL:
 1783                   /* R-1 if !(ipv4 && rand) */
 1784                   if (!((p_pdcp_info->rohc_ip_version == 4) &&
 1785                        (!p_pdcp_info->rnd))) {
 1786                      offset = dissect_pdcp_r_1_packet(rohc_tree, rohc_ti, tvb, offset, p_pdcp_info, pinfo);
 1787                      return;
 1788                   }
 1789                  else {
 1790                      /* Whether its R-1-ID or R-1-TS depends upon T bit */
 1791                      dissect_pdcp_r_1_ts_or_id_packet(rohc_tree, rohc_ti, tvb, offset, p_pdcp_info, pinfo);
 1792                      return;
 1793                  }
 1794                  break;
 1795   
 1796              case UNIDIRECTIONAL:
 1797              case OPTIMISTIC_BIDIRECTIONAL:
 1798                   /* UO-1 if !(ipv4 && rand) */
 1799                   if (!((p_pdcp_info->rohc_ip_version == 4) &&
 1800                        (!p_pdcp_info->rnd))) {
 1801                      offset = dissect_pdcp_uo_1_packet(rohc_tree, rohc_ti, tvb, offset, p_pdcp_info, pinfo);
 1802                      return;
 1803                   }
 1804                  else {
 1805                      /* Whether its UO-1-ID or UO-1-TS depends upon T bit */
 1806                      dissect_pdcp_uo_1_ts_or_id_packet(rohc_tree, rohc_ti, tvb, offset, p_pdcp_info, pinfo);
 1807                      return;
 1808                  }
 1809   
 1810                  return;  
 1811   
 1812          }
 1813      }
 1814   
 1815      /* Packet type 2 (110) */
 1816      else if (((base_header_byte & 0xe0) >> 5) == 6) {
 1817   
 1818          /* UOR-2 if !(ipv4 && rand) */
 1819          if (!((p_pdcp_info->rohc_ip_version == 4) &&
 1820                (!p_pdcp_info->rnd))) {
 1821   
 1822              offset = dissect_pdcp_uor_2_packet(rohc_tree, rohc_ti, tvb, offset, p_pdcp_info, pinfo);
 1823          }
 1824          else {
 1825              /* Whether its UOR-2-ID or UOR-2-TS depends upon T bit */
 1826              dissect_pdcp_uor_2_ts_or_id_packet(rohc_tree, rohc_ti, tvb, offset, p_pdcp_info, pinfo);
 1827              return;
 1828          }
 1829      }
 1830   
 1831      /* Segment (1111111) */
 1832      else if ((base_header_byte & 0xfe) == 0xfe) {
 1833          /* TODO: */
 1834          return;
 1835      }
 1836   
 1837   
 1838      /* Fields beyond base header */
 1839   
 1840      /* IP-ID */
 1841      if (p_pdcp_info->rnd) {
 1842          proto_tree_add_item(rohc_tree, hf_pdcp_lte_ip_id, tvb, offset, 2, FALSE);
 1843          offset += 2;
 1844      }
 1845   
 1846      /* UDP Checksum */
 1847      if (p_pdcp_info->udp_checkum_present && udp_checksum_needed) {
 1848          proto_tree_add_item(rohc_tree, hf_pdcp_lte_udp_checksum, tvb, offset, 2, FALSE);
 1849          offset += 2;
 1850      }
 1851   
 1852      /* Payload */
 1853      if (tvb_reported_length_remaining(tvb, offset) > 0) {
 1854          proto_tree_add_item(rohc_tree, hf_pdcp_lte_payload, tvb, offset, -1, FALSE);
 1855      }
 1856  }
Show more  




Change Warning 5479.35726 : Ignored Return Value

Priority:
State:
Finding:
Owner:
Note: