Text   |  XML   |  ReML   |   Visible Warnings:

Format String  at mac_hd_generic_decoder.c:2003

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

dissect_mac_header_generic_decoder

(/home/sate/Testcases/c/cve/wireshark-1.2.0/plugins/wimax/mac_hd_generic_decoder.c)expand/collapse
Show more  
 1489  void dissect_mac_header_generic_decoder(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 1490  {
 1491          guint offset = 0;
 1492          guint payload_offset;
 1493          guint payload_length = 0;
 1494   
 1495          static guint8 frag_number[MAX_CID];
 1496          static guint cid_list[MAX_CID];
 1497          static guint cid_base;
 1498          static char *reassem_str = "Reassembled Data transport PDU (%u bytes)";
 1499          static char *data_str = "Data transport PDU (%u bytes)";
 1500          char *str_ptr;
 1501          gint length, i, cid_index;
 1502          guint tvb_len, ret_length, ubyte, new_tvb_len;
 1503          guint new_payload_len = 0;
 1504          guint mac_ht, mac_ec, mac_esf, mac_ci, mac_eks, mac_len, mac_cid, cid;
 1505          guint ffb_grant_mgmt_subheader, packing_subheader, fragment_subheader;
 1506          guint mesh_subheader;
 1507          guint packing_length;
 1508          guint32 mac_crc, calculated_crc;
 1509          proto_item *parent_item = NULL;
 1510          proto_item *generic_item = NULL;
 1511          proto_tree *generic_tree = NULL;
 1512          proto_item *child_item = NULL;
 1513          proto_tree *child_tree = NULL;
 1514          tvbuff_t *payload_tvb;
 1515          tvbuff_t *data_pdu_tvb;
 1516          fragment_data *payload_frag;
 1517          gboolean first_arq_fb_payload = TRUE;
 1518   
 1519          dissector_handle_t mac_payload_handle;
 1520   
 1521          proto_mac_header_generic_decoder = proto_wimax;
 1522          if (tree)
 1523          {       /* we are being asked for details */
 1524  #ifdef DEBUG 
 1525                  /* update the info column */
 1526                  if (check_col(pinfo->cinfo, COL_INFO))
 1527                  {
 1528                          col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "GMH");
 1529                  }
 1530  #endif
 1531                  /* Get the frame length */
 1532                  tvb_len =  tvb_reported_length(tvb);
 1533                  if (tvb_len < WIMAX_MAC_HEADER_SIZE)
 1534                  {       /* display the error message */
 1535                          generic_item = proto_tree_add_protocol_format(tree, proto_mac_header_generic_decoder, tvb, offset, tvb_len, "Error: the size of Generic MAC Header tvb is too small! (%u bytes)", tvb_len);
 1536                          /* add subtree */
 1537                          generic_tree = proto_item_add_subtree(generic_item, ett_mac_header_generic_decoder);
 1538                          /* display the Generic MAC Header in Hex */
 1539                          proto_tree_add_item(generic_tree, hf_mac_header_generic_value_bytes, tvb, offset, tvb_len, FALSE);
 1540                          return;
 1541                  }
 1542                  /* get the parent */
 1543                  parent_item = proto_tree_get_parent(tree);
 1544                  /* add the MAC header info */
 1545                  proto_item_append_text(parent_item, " - Generic MAC Header");
 1546                  /* display MAC header message */
 1547                  generic_item = proto_tree_add_protocol_format(tree, proto_mac_header_generic_decoder, tvb, offset, WIMAX_MAC_HEADER_SIZE, "Generic MAC Header (%u bytes)", WIMAX_MAC_HEADER_SIZE);
 1548                  /* add MAC header subtree */
 1549                  generic_tree = proto_item_add_subtree(generic_item, ett_mac_header_generic_decoder);
 1550                  /* Decode and display the MAC header */
 1551                  /* Get the first byte */
 1552                  ubyte = tvb_get_guint8(tvb, offset);
 1553                  /* get the Header Type (HT) */
 1554                  mac_ht = ((ubyte & WIMAX_MAC_HEADER_GENERIC_HT_MASK)?1:0);
 1555                  /* get the Encryption Control (EC) */
 1556                  mac_ec = ((ubyte & WIMAX_MAC_HEADER_GENERIC_EC_MASK)?1:0);
 1557                  /* get the sub types */
 1558                  ffb_grant_mgmt_subheader = ((ubyte & GENERIC_SUB_TYPE_0)?1:0);
 1559                  packing_subheader = ((ubyte & GENERIC_SUB_TYPE_1)?1:0);
 1560                  fragment_subheader = ((ubyte & GENERIC_SUB_TYPE_2)?1:0);
 1561                  extended_type = ((ubyte & GENERIC_SUB_TYPE_3)?1:0);
 1562                  arq_fb_payload = ((ubyte & GENERIC_SUB_TYPE_4)?1:0);
 1563                  mesh_subheader = ((ubyte & GENERIC_SUB_TYPE_5)?1:0);
 1564                  /* Get the 2nd byte */
 1565                  ubyte = tvb_get_guint8(tvb, (offset+1));
 1566                  /* get the Extended subheader field (ESF) */
 1567                  mac_esf = ((ubyte & WIMAX_MAC_HEADER_GENERIC_ESF_MASK)?1:0);
 1568                  /* get the CRC indicator (CI) */
 1569                  mac_ci = ((ubyte & WIMAX_MAC_HEADER_GENERIC_CI_MASK)?1:0);
 1570                  /* get the Encryption key sequence (EKS) */
 1571                  mac_eks = ((ubyte & WIMAX_MAC_HEADER_GENERIC_EKS_MASK)>>4);
 1572                  /* get the MAC length */
 1573                  mac_len = (tvb_get_ntohs(tvb, (offset+1)) & WIMAX_MAC_HEADER_GENERIC_LEN);
 1574                  /* get the CID */
 1575                  mac_cid = tvb_get_ntohs(tvb, (offset+3));
 1576                  /* display the Header Type (HT) */
 1577                  proto_tree_add_item(generic_tree, hf_mac_header_generic_ht, tvb, offset, 3, FALSE);
 1578                  /* display the Encryption Control (EC) */
 1579                  proto_tree_add_item(generic_tree, hf_mac_header_generic_ec, tvb, offset, 3, FALSE);
 1580                  /* display the sub-types (Type) */
 1581                  proto_tree_add_item(generic_tree, hf_mac_header_generic_type_5, tvb, offset, 3, FALSE);
 1582                  proto_tree_add_item(generic_tree, hf_mac_header_generic_type_4, tvb, offset, 3, FALSE);
 1583                  proto_tree_add_item(generic_tree, hf_mac_header_generic_type_3, tvb, offset, 3, FALSE);
 1584                  proto_tree_add_item(generic_tree, hf_mac_header_generic_type_2, tvb, offset, 3, FALSE);
 1585                  proto_tree_add_item(generic_tree, hf_mac_header_generic_type_1, tvb, offset, 3, FALSE);
 1586                  proto_tree_add_item(generic_tree, hf_mac_header_generic_type_0, tvb, offset, 3, FALSE);
 1587                  /* display the Extended sub-header Field (ESF) */
 1588                  proto_tree_add_item(generic_tree, hf_mac_header_generic_esf, tvb, offset, 3, FALSE);
 1589                  /* display the CRC Indicator (CI) */
 1590                  proto_tree_add_item(generic_tree, hf_mac_header_generic_ci, tvb, offset, 3, FALSE);
 1591                  /* display the Encryption Key Sequence (EKS) */
 1592                  proto_tree_add_item(generic_tree, hf_mac_header_generic_eks, tvb, offset, 3, FALSE);
 1593                  /* display the reserved field */
 1594                  proto_tree_add_item(generic_tree, hf_mac_header_generic_rsv, tvb, offset, 3, FALSE);
 1595                  /* display the length */
 1596                  proto_tree_add_item(generic_tree, hf_mac_header_generic_len, tvb, offset, 3, FALSE);
 1597                  /* Decode and display the CID */
 1598                  proto_tree_add_item(generic_tree, hf_mac_header_generic_cid, tvb, (offset+3), 2, FALSE);
 1599                  /* Decode and display the HCS */
 1600                  proto_tree_add_item(generic_tree, hf_mac_header_generic_hcs, tvb, (offset+5), 1, FALSE);
 1601                  /* get the frame length without MAC header */
 1602                  length = mac_len - WIMAX_MAC_HEADER_SIZE;
 1603  #ifdef DEBUG 
 1604                  proto_item_append_text(parent_item, "tvb length=%u, mac length=%u, frame length=%u,", tvb_len, mac_len, length);
 1605  #endif
 1606                  /* set the offset for the frame */
 1607                  offset += WIMAX_MAC_HEADER_SIZE;
 1608                  /* the processing of the subheaders is order sensitive */
 1609                  /* do not change the order */
 1610   
 1611                  if (mac_ec)
 1612                  {
 1613                          if (mac_ci)
 1614                          {
 1615                                  if (length >= (gint)sizeof(mac_crc))
 1616                                  {
 1617                                          length -= sizeof(mac_crc);
 1618                                  }
 1619                          }
 1620                          generic_item = proto_tree_add_protocol_format(tree, proto_mac_header_generic_decoder, tvb, offset, length, "Encrypted PDU (%u bytes)", length);
 1621                          /* add payload subtree */
 1622                          generic_tree = proto_item_add_subtree(generic_item, ett_mac_data_pdu_decoder);
 1623                          proto_tree_add_item(generic_tree, hf_mac_header_generic_value_bytes, tvb, offset, length, FALSE);
 1624                          goto check_crc;
 1625                  }
 1626   
 1627                  /* if Extended subheader is present */
 1628                  if (mac_esf)
 1629                  {       /* add the Extended subheader info */
 1630                          proto_item_append_text(parent_item, ", Extended Subheader(s)");
 1631                          ret_length = extended_subheader_decoder(tvb_new_subset(tvb, offset, length, length), pinfo, tree);
 1632                          /* update the length and offset */
 1633                          length -= ret_length;
 1634                          offset += ret_length;
 1635                  }
 1636                  /* if Mesh subheader is present */
 1637                  if (mesh_subheader)
 1638                  {       /* update the info column */
 1639                          if (check_col(pinfo->cinfo, COL_INFO))
 1640                          {
 1641                                  col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "Mesh subhdr");
 1642                          }
 1643                          /* add the Mesh subheader info */
 1644                          proto_item_append_text(parent_item, ", Mesh Subheader");
 1645                          /* display Mesh subheader type */
 1646                          generic_item = proto_tree_add_protocol_format(tree, proto_mac_header_generic_decoder, tvb, offset, length, "Mesh subheader (2 bytes)");
 1647                          /* add Mesh subheader subtree */
 1648                          generic_tree = proto_item_add_subtree(generic_item, ett_mac_mesh_subheader_decoder);
 1649                          /* decode and display the Mesh subheader */
 1650                          proto_tree_add_item(generic_tree, hf_mac_header_generic_mesh_subheader, tvb, offset, 2, FALSE);
 1651                          /* update the length and offset */
 1652                          length -= 2;
 1653                          offset += 2;
 1654                  }
 1655                  /* if Fast-feedback allocation (DL) subheader or Grant management (UL) subheader is present */
 1656                  if (ffb_grant_mgmt_subheader)
 1657                  {       /* check if it is downlink packet */
 1658                          if (is_down_link(&(pinfo->src)))
 1659                          {       /* Fast-feedback allocation (DL) subheader is present */
 1660                                  /* update the info column */
 1661                                  if (check_col(pinfo->cinfo, COL_INFO))
 1662                                  {
 1663                                          col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "Fast-fb subhdr");
 1664                                  }
 1665                                  /* add the Fast-feedback subheader info */
 1666                                  proto_item_append_text(parent_item, ", Fast-feedback Subheader");
 1667                                  /* display Fast-feedback allocation subheader type */
 1668                                  generic_item = proto_tree_add_protocol_format(tree, proto_mac_header_generic_decoder, tvb, offset, length, "Fast-feedback allocation (DL) subheader (%u bytes)", length);
 1669                                  /* add Fast-feedback allocation subheader subtree */
 1670                                  generic_tree = proto_item_add_subtree(generic_item, ett_mac_fast_fb_subheader_decoder);
 1671                                  proto_tree_add_item(generic_tree, hf_mac_header_generic_fast_fb_subhd_alloc_offset, tvb, offset, 1, FALSE);
 1672                                  proto_tree_add_item(generic_tree, hf_mac_header_generic_fast_fb_subhd_fb_type, tvb, offset, 1, FALSE);
 1673                                  /* update the length and offset */
 1674                                  length -= 1;
 1675                                  offset += 1;
 1676                          }
 1677                          else    /* Grant management (UL) subheader is present */
 1678                          {       /* update the info column */
 1679                                  if (check_col(pinfo->cinfo, COL_INFO))
 1680                                  {
 1681                                          col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "Grant mgmt subhdr");
 1682                                  }
 1683                                  /* add the Grant management subheader info */
 1684                                  proto_item_append_text(parent_item, ", Grant Management Subheader");
 1685                                  /* display Grant management subheader type */
 1686                                  generic_item = proto_tree_add_protocol_format(tree, proto_mac_header_generic_decoder, tvb, offset, 2, "Grant management (UL) subheader (2 bytes)");
 1687                                  /* add Grant management subheader subtree */
 1688                                  generic_tree = proto_item_add_subtree(generic_item, ett_mac_grant_mgmt_subheader_decoder);
 1689                                  scheduling_service_type = get_service_type();
 1690                                  switch (scheduling_service_type)
 1691                                  {
 1692                                  case SCHEDULE_SERVICE_TYPE_UGS:
 1693                                          proto_item_append_text(generic_item, ": It looks like UGS is the correct Scheduling Service Type");
 1694                                  break;
 1695                                  case SCHEDULE_SERVICE_TYPE_EXT_RTPS:
 1696                                          proto_item_append_text(generic_item, ": It looks like Extended rtPS is the correct Scheduling Service Type");
 1697                                  break;
 1698                                  case -1:
 1699                                          proto_item_append_text(generic_item, ": Cannot determine the correct Scheduling Service Type");
 1700                                  break;
 1701                                  default:
 1702                                          proto_item_append_text(generic_item, ": It looks like Piggyback Request is the correct Scheduling Service Type");
 1703                                  break;
 1704                                  }
 1705                                  /* Create tree for Scheduling Service Type (UGS) */
 1706                                  child_item = proto_tree_add_item(generic_tree, hf_mac_header_generic_grant_mgmt_ugs_tree, tvb, offset, 2, FALSE);
 1707                                  child_tree = proto_item_add_subtree(child_item, ett_mac_grant_mgmt_subheader_decoder);
 1708                                  proto_tree_add_item(child_tree, hf_mac_header_generic_grant_mgmt_subhd_ugs_si, tvb, offset, 2, FALSE);
 1709                                  proto_tree_add_item(child_tree, hf_mac_header_generic_grant_mgmt_subhd_ugs_pm, tvb, offset, 2, FALSE);
 1710                                  proto_tree_add_item(child_tree, hf_mac_header_generic_grant_mgmt_subhd_ugs_fli, tvb, offset, 2, FALSE);
 1711                                  proto_tree_add_item(child_tree, hf_mac_header_generic_grant_mgmt_subhd_ugs_fl, tvb, offset, 2, FALSE);
 1712                                  proto_tree_add_item(child_tree, hf_mac_header_generic_grant_mgmt_subhd_ugs_rsv, tvb, offset, 2, FALSE);
 1713   
 1714                                  /* Create tree for Scheduling Service Type (Extended RTPS) */
 1715                                  child_item = proto_tree_add_item(generic_tree, hf_mac_header_generic_grant_mgmt_ext_rtps_tree, tvb, offset, 2, FALSE);
 1716                                  child_tree = proto_item_add_subtree(child_item, ett_mac_grant_mgmt_subheader_decoder);
 1717                                  proto_tree_add_item(child_tree, hf_mac_header_generic_grant_mgmt_subhd_ext_pbr, tvb, offset, 2, FALSE);
 1718                                  proto_tree_add_item(child_tree, hf_mac_header_generic_grant_mgmt_subhd_ext_fli, tvb, offset, 2, FALSE);
 1719                                  proto_tree_add_item(child_tree, hf_mac_header_generic_grant_mgmt_subhd_ext_fl, tvb, offset, 2, FALSE);
 1720   
 1721                                  /* Create tree for Scheduling Service Type (Piggyback Request) */
 1722                                  child_item = proto_tree_add_item(generic_tree, hf_mac_header_generic_grant_mgmt_ext_pbr_tree, tvb, offset, 2, FALSE);
 1723                                  child_tree = proto_item_add_subtree(child_item, ett_mac_grant_mgmt_subheader_decoder);
 1724                                  proto_tree_add_item(child_tree, hf_mac_header_generic_grant_mgmt_subhd_pbr, tvb, offset, 2, FALSE);
 1725   
 1726                                  /* update the length and offset */
 1727                                  length -= 2;
 1728                                  offset += 2;
 1729                          }
 1730                  }
 1731                  /* if Fragmentation subheader is present */
 1732                  if (fragment_subheader)
 1733                  {       /* update the info column */
 1734                          if (check_col(pinfo->cinfo, COL_INFO))
 1735                          {
 1736                                  col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "Frag subhdr");
 1737                          }
 1738                          /* add the Fragmentation subheader info */
 1739                          proto_item_append_text(parent_item, ", Frag Subheader");
 1740                          /* display Fragmentation subheader type */
 1741                          generic_item = proto_tree_add_protocol_format(tree, proto_mac_header_generic_decoder, tvb, offset, ((arq_enabled|extended_type)?2:1), "Fragmentation subheader (%u bytes)", ((arq_enabled|extended_type)?2:1));
 1742                          /* add Fragmentation subheader subtree */
 1743                          generic_tree = proto_item_add_subtree(generic_item, ett_mac_frag_subheader_decoder);
 1744                          /* Get the fragment type */
 1745                          frag_type = (tvb_get_guint8(tvb, offset) & FRAGMENT_TYPE_MASK) >> 6;
 1746                          if (arq_fb_payload)
 1747                          {       /* get the sequence number */
 1748                                  seq_number = (tvb_get_ntohs(tvb, offset) & SEQ_NUMBER_MASK_11) >> 3;
 1749                                  /* decode and display the header */
 1750                                  proto_tree_add_item(generic_tree, hf_mac_header_generic_frag_subhd_fc_ext, tvb, offset, 2, FALSE);
 1751                                  proto_tree_add_item(generic_tree, hf_mac_header_generic_frag_subhd_bsn, tvb, offset, 2, FALSE);
 1752                                  proto_tree_add_item(generic_tree, hf_mac_header_generic_frag_subhd_rsv_ext, tvb, offset, 2, FALSE);
 1753                                  /* update the length and offset */
 1754                                  length -= 2;
 1755                                  offset += 2;
 1756                          }
 1757                          else 
 1758                          {
 1759                                  if (extended_type)
 1760                                  {       /* get the sequence number */
 1761                                          seq_number = (tvb_get_ntohs(tvb, offset) & SEQ_NUMBER_MASK_11) >> 3;
 1762                                          /* decode and display the header */
 1763                                          proto_tree_add_item(generic_tree, hf_mac_header_generic_frag_subhd_fc_ext, tvb, offset, 2, FALSE);
 1764                                          proto_tree_add_item(generic_tree, hf_mac_header_generic_frag_subhd_fsn_ext, tvb, offset, 2, FALSE);
 1765                                          proto_tree_add_item(generic_tree, hf_mac_header_generic_frag_subhd_rsv_ext, tvb, offset, 2, FALSE);
 1766                                          /* update the length and offset */
 1767                                          length -= 2;
 1768                                          offset += 2;
 1769                                  }
 1770                                  else 
 1771                                  {       /* get the sequence number */
 1772                                          seq_number = (tvb_get_guint8(tvb, offset) & SEQ_NUMBER_MASK) >> 3;
 1773                                          /* decode and display the header */
 1774                                          proto_tree_add_item(generic_tree, hf_mac_header_generic_frag_subhd_fc, tvb, offset, 1, FALSE);
 1775                                          proto_tree_add_item(generic_tree, hf_mac_header_generic_frag_subhd_fsn, tvb, offset, 1, FALSE);
 1776                                          proto_tree_add_item(generic_tree, hf_mac_header_generic_frag_subhd_rsv, tvb, offset, 1, FALSE);
 1777                                          /* update the length and offset */
 1778                                          length -= 1;
 1779                                          offset += 1;
 1780                                  }
 1781                          }
 1782                          frag_len = length;
 1783                  }
 1784                  else    /* ??? default fragment type: no fragment */
 1785                  {
 1786                          frag_type = NO_FRAG;
 1787                  }
 1788                  /* Decode the MAC payload if there is any */
 1789                  if (mac_ci)
 1790                  {
 1791                          if (length < (gint)sizeof(mac_crc))
 1792                          {       /* display error message */
 1793                                  proto_tree_add_protocol_format(tree, proto_mac_header_generic_decoder, tvb, offset, length, "Error - the frame is too short (%u bytes)", length);
 1794                                  return;
 1795                          }
 1796                          length -= sizeof(mac_crc);
 1797                  }
 1798                  while (length > 0)
 1799                  {
 1800                          frag_len = length; /* Can be changed by Packing subhdr */
 1801                          if (packing_subheader)
 1802                          {
 1803                                  packing_length = decode_packing_subheader(tvb, pinfo, tree, length, offset, parent_item);
 1804                                  length -= packing_length;
 1805                                  offset += packing_length;
 1806                                  generic_item = proto_tree_add_protocol_format(tree, proto_mac_header_generic_decoder, tvb, offset, frag_len, "Data transport PDU (%u bytes)", frag_len);
 1807                                  /* add payload subtree */
 1808                                  generic_tree = proto_item_add_subtree(generic_item, ett_mac_data_pdu_decoder);
 1809                                  proto_tree_add_item(generic_tree, hf_mac_header_generic_value_bytes, tvb, offset, frag_len, FALSE);
 1810                          }
 1811                          /* defragment first if it is fragmented */
 1812                          if (frag_type == NO_FRAG)
 1813                          {       /* not fragmented payload */
 1814                                  payload_tvb =  tvb_new_subset(tvb, offset, frag_len, frag_len);
 1815                                  payload_length = frag_len;
 1816                                  new_payload_len = frag_len;
 1817                          }
 1818                          else    /* fragmented payload */
 1819                          {       /* add the frag */
 1820                                  /* Make sure cid will not match a previous packet with different data */
 1821                                  for (i = 0; i < MAX_CID; i++)
 1822                                  {
 1823                                          if (cid_list[i] == mac_cid)
 1824                                          {
 1825                                                  cid_base = i * (0xFFFFFFFF / MAX_CID);
 1826                                                  break;
 1827                                          }
 1828                                          if (cid_list[i] == 0)
 1829                                          {
 1830                                                  cid_list[i] = mac_cid;
 1831                                                  cid_base = i * (0xFFFFFFFF / MAX_CID);
 1832                                                  break;
 1833                                          }
 1834                                  }
 1835                                  cid_index = i;
 1836                                  while (pinfo->fd->num > cid_adj_array_size)
 1837                                  {
 1838                                          cid_adj_array_size += 1024;
 1839                                          cid_adj_array = g_realloc(cid_adj_array, sizeof(guint) * cid_adj_array_size);
 1840                                          frag_num_array = g_realloc(frag_num_array, sizeof(guint8) * cid_adj_array_size);
 1841                                          /* Clear the added memory */
 1842                                          memset(&cid_adj_array[cid_adj_array_size - 1024], 0, sizeof(guint) * 1024);
 1843                                  }
 1844                                  if (first_gmh)
 1845                                  {
 1846                                          /* New cid_adjust for each packet with fragment(s) */
 1847                                          cid_adjust[cid_index] += cid_vernier[cid_index];
 1848                                          /* cid_vernier must always be 0 at start of packet. */
 1849                                          cid_vernier[cid_index] = 0;
 1850                                  }
 1851                                  /* Create artificial sequence numbers. */
 1852                                  frag_number[cid_index]++;
 1853                                  if (frag_type == FIRST_FRAG)
 1854                                  {
 1855                                          frag_number[cid_index] = 0;
 1856                                  }
 1857                                  if (cid_adj_array[pinfo->fd->num])
 1858                                  {
 1859                                          /* We apparently just clicked on the packet again. */
 1860                                          cid_adjust[cid_index] = cid_adj_array[pinfo->fd->num];
 1861                                          /* Set the frag_number at start of packet. */
 1862                                          if (first_gmh)
 1863                                          {
 1864                                                  frag_number[cid_index] = frag_num_array[pinfo->fd->num];
 1865                                          }
 1866                                  } else {
 1867                                          /* Save for next time we click on this packet. */
 1868                                          cid_adj_array[pinfo->fd->num] = cid_adjust[cid_index];
 1869                                          if (first_gmh)
 1870                                          {
 1871                                                  frag_num_array[pinfo->fd->num] = frag_number[cid_index];
 1872                                          }
 1873                                  }
 1874                                  /* Reset in case we stay in this while() loop to finish the packet. */
 1875                                  first_gmh = FALSE;
 1876                                  cid = cid_base + cid_adjust[cid_index] + cid_vernier[cid_index];
 1877                                  /* Save address pointers. */
 1878                                  save_src = pinfo->src;
 1879                                  save_dst = pinfo->dst;
 1880                                  /* Use dl_src and dl_dst in defrag. */
 1881                                  pinfo->src = pinfo->dl_src;
 1882                                  pinfo->dst = pinfo->dl_dst;
 1883                                  payload_frag = fragment_add_seq(tvb, offset, pinfo, cid, payload_frag_table, frag_number[cid_index], frag_len, ((frag_type==LAST_FRAG)?0:1));
 1884                                  /* Restore address pointers. */
 1885                                  pinfo->src = save_src;
 1886                                  pinfo->dst = save_dst;
 1887                                  if (frag_type == LAST_FRAG)
 1888                                  {
 1889                                          /* Make sure fragment_add_seq() sees next one as a new frame. */
 1890                                          cid_vernier[cid_index]++;
 1891                                  }
 1892                                  /* Don't show reassem packet until last frag. */
 1893                                  proto_tree_add_text(tree, tvb, offset, frag_len, "Payload Fragment (%d bytes)", frag_len);
 1894   
 1895                                  if (payload_frag && frag_type == LAST_FRAG)
 1896                                  {       /* defragmented completely */
 1897                                          payload_length = payload_frag->len;
 1898                                          /* create the new tvb for defragmented frame */
 1899                                          payload_tvb = tvb_new_child_real_data(tvb, payload_frag->data, payload_length, payload_length);
 1900                                          /* add the defragmented data to the data source list */
 1901                                          add_new_data_source(pinfo, payload_tvb, "Reassembled WiMax MAC payload");
 1902                                          /* save the tvb langth */
 1903                                          new_payload_len = payload_length;
 1904                                  }
 1905                                  else /* error or defragment is not complete */
 1906                                  {
 1907                                          payload_tvb = NULL;
 1908  #ifdef DEBUG    /* for debug only */
 1909  /*                                      if (frag_type == LAST_FRAG)*/
 1910                                          {       /* error */
 1911                                                  /* update the info column */
 1912                                                  if (check_col(pinfo->cinfo, COL_INFO))
 1913                                                          col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "Dropped the incomplete frame");
 1914                                          }
 1915  #endif
 1916  #if 0 
 1917                                          if (frag_type == FIRST_FRAG)
 1918                                          {       /* Set up to decode the first fragment (even though next fragment not read yet) */
 1919                                                  payload_tvb =  tvb_new_subset(tvb, offset, length, length);
 1920                                                  payload_length = length;
 1921                                                  frag_len = length;
 1922                                          }
 1923  #endif
 1924                                  }
 1925                          }
 1926                          /* process the defragmented payload */
 1927                          if (payload_tvb)
 1928                          {       /* reset the payload_offset */
 1929                                  payload_offset = 0;
 1930                                  /* process the payload */
 1931                                  if (payload_length > 0)
 1932                                  {
 1933                                          if (!new_payload_len)
 1934                                                  continue;
 1935                                          /* if ARQ Feedback payload is present, it should be the first SDU */
 1936                                          if (first_arq_fb_payload && arq_fb_payload)
 1937                                          {       /* decode and display the ARQ feedback payload */
 1938                                                  first_arq_fb_payload = FALSE;
 1939                                                  ret_length = arq_feedback_payload_decoder(tvb_new_subset(payload_tvb, payload_offset, new_payload_len, new_payload_len), pinfo, generic_tree, parent_item);
 1940  #ifdef DEBUG /* for debug only */
 1941                                                  if (ret_length != new_payload_len)
 1942                                                  {       /* error */
 1943                                                          /* update the info column */
 1944                                                          if (check_col(pinfo->cinfo, COL_INFO))
 1945                                                                  col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "incorrect ARQ fb payload size");
 1946                                                  }
 1947  #endif
 1948                                          }
 1949                                          else    /* decode SDUs */
 1950                                          {       /* check the payload type */
 1951                                                  if (mac_cid == cid_padding)
 1952                                                  {       /* update the info column */
 1953                                                          if (check_col(pinfo->cinfo, COL_INFO))
 1954                                                          {
 1955                                                                  col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "Padding CID");
 1956                                                          }
 1957                                                          /* get the parent */
 1958                                                          generic_item = proto_tree_get_parent(tree);
 1959                                                          /* add the MAC header info */
 1960                                                          proto_item_append_text(generic_item, ", Padding CID");
 1961                                                          /* display padding CID */
 1962                                                          generic_item = proto_tree_add_protocol_format(tree, proto_mac_header_generic_decoder, payload_tvb, payload_offset, new_payload_len, "Padding CID (%u bytes)", new_payload_len);
 1963                                                          /* add payload subtree */
 1964                                                          generic_tree = proto_item_add_subtree(generic_item, ett_mac_header_generic_decoder);
 1965                                                          /* display the Padding CID payload  in Hex */
 1966                                                          proto_tree_add_item(generic_tree, hf_mac_header_generic_value_bytes, payload_tvb, payload_offset, new_payload_len, FALSE);
 1967                                                  }
 1968                                                  else if ((mac_cid <= (2 * global_cid_max_basic)) || (mac_cid == cid_aas_ranging)
 1969                                                          || (mac_cid >= cid_normal_multicast))
 1970                                                  {       /* MAC management message */
 1971                                                          dissect_mac_mgmt_msg_decoder(tvb_new_subset(payload_tvb, payload_offset, new_payload_len, new_payload_len), pinfo, tree);
 1972                                                  }
 1973                                                  else /* data transport PDU */
 1974                                                  {       /* update the info column */
 1975                                                          if (check_col(pinfo->cinfo, COL_INFO))
 1976                                                          {
 1977                                                                  col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "Data");
 1978                                                          }
 1979                                                          /* add the MAC payload info */
 1980                                                          proto_item_append_text(parent_item, ", Data");
 1981                                                          /* display payload info */
 1982                                                          if ((new_payload_len + payload_offset) > payload_length)
 1983                                                          {
 1984                                                                  new_tvb_len = new_payload_len - payload_offset;
 1985                                                          }
 1986                                                          else 
 1987                                                          {
 1988                                                                  new_tvb_len = new_payload_len;
 1989                                                          }
 1990                                                          if (frag_type == LAST_FRAG || frag_type == NO_FRAG)
 1991                                                          {
 1992                                                                  if (frag_type == NO_FRAG)
 1993                                                                  {
 1994                                                                          str_ptr = data_str;
 1995                                                                          new_payload_len = frag_len;
 1996                                                                  }
 1997                                                                  else 
 1998                                                                  {
 1999                                                                          str_ptr = reassem_str;
 2000                                                                  }
 2001                                                                  {
 2002                                                                  data_pdu_tvb = tvb_new_subset(payload_tvb, payload_offset, new_tvb_len, new_tvb_len);
 2003                                                                  generic_item = proto_tree_add_protocol_format(tree, proto_mac_header_generic_decoder, data_pdu_tvb, payload_offset, new_payload_len, str_ptr, new_payload_len);
 2004                                                                  /* add payload subtree */
 2005                                                                  generic_tree = proto_item_add_subtree(generic_item, ett_mac_data_pdu_decoder);
 2006                                                                  /* check the data type */
 2007                                                                  if (tvb_get_guint8(payload_tvb, payload_offset) == IP_HEADER_BYTE)
 2008                                                                  {
 2009                                                                          mac_payload_handle = find_dissector("ip");
 2010                                                                          if (mac_payload_handle)
 2011                                                                                  call_dissector(mac_payload_handle, tvb_new_subset(payload_tvb, payload_offset, new_tvb_len, new_tvb_len), pinfo, generic_tree);
 2012                                                                          else    /* display the Generic MAC Header in Hex */
 2013                                                                                  proto_tree_add_item(generic_tree, hf_mac_header_generic_value_bytes, payload_tvb, payload_offset, new_tvb_len, FALSE);
 2014                                                                  }
 2015                                                                  else    /* display the Generic MAC Header in Hex */
 2016                                                                          proto_tree_add_item(generic_tree, hf_mac_header_generic_value_bytes, payload_tvb, payload_offset, new_tvb_len, FALSE);
 2017                                                                  }
 2018                                                          }
 2019                                                  }
 2020                                          }
 2021                                          payload_length -= new_payload_len;
 2022                                          payload_offset += new_payload_len;
 2023                                  }       /* end of while loop */
 2024                          }       /* end of payload processing */
 2025                          length -= frag_len;
 2026                          offset += frag_len;
 2027                  } /* end of payload decoding */
 2028  check_crc:
 2029                  /* Decode and display the CRC if it is present */
 2030                  if (mac_ci)
 2031                  {
 2032                          /* add the CRC info */
 2033                          proto_item_append_text(parent_item, ", CRC");
 2034                          /* check the length */
 2035                          if (MIN(tvb_len, tvb_reported_length(tvb)) >= mac_len)
 2036                          {       /* get the CRC */
 2037                                  mac_crc = tvb_get_ntohl(tvb, mac_len - sizeof(mac_crc));
 2038                                  /* calculate the CRC */
 2039                                  calculated_crc = wimax_mac_calc_crc32((guint8 *)tvb_get_ptr(tvb, 0, mac_len - sizeof(mac_crc)), mac_len - sizeof(mac_crc));
 2040                                  /* display the CRC */
 2041                                  generic_item = proto_tree_add_item(tree, hf_mac_header_generic_crc, tvb, mac_len - sizeof(mac_crc), sizeof(mac_crc), FALSE);
 2042                                  if (mac_crc != calculated_crc)
 2043                                  {
 2044                                          proto_item_append_text(generic_item, " - incorrect! (should be: 0x%x)", calculated_crc);
 2045                                  }
 2046                          }
 2047                          else 
 2048                          {       /* display error message */
 2049                                  proto_tree_add_protocol_format(tree, proto_mac_header_generic_decoder, tvb, 0, tvb_len, "CRC missing - the frame is too short (%u bytes)", tvb_len);
 2050                          }
 2051                  }
 2052                  else    /* CRC is not included */
 2053                  {       /* add the CRC info */
 2054                          proto_item_append_text(parent_item, ", No CRC");
 2055                          /* display message */
 2056                          proto_tree_add_protocol_format(tree, proto_mac_header_generic_decoder, tvb, 0, tvb_len, "CRC is not included in this frame!");
 2057                  }
 2058          }
 2059  }
Show more  




Change Warning 5569.35877 : Format String

Priority:
State:
Finding:
Owner:
Note: