(/home/sate/Testcases/c/cve/wireshark-1.2.0/plugins/wimax/mac_hd_generic_decoder.c) |
| |
| 1489 | | | void (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 , , ; |
| 1506 | | | guint ; |
| 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_wimax; |
| 1522 | | | if (tree) |
| 1523 | | | { |
| 1524 | | | #ifdef DEBUG |
| 1525 | | | |
| 1526 | | | if (check_col(pinfo->cinfo, COL_INFO)) |
| 1527 | | | { |
| 1528 | | | col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "GMH"); |
| 1529 | | | } |
| 1530 | | | #endif |
| 1531 | | | |
| 1532 | | | tvb_len = tvb_reported_length(tvb); |
| 1533 | | | if (tvb_len < ) |
| 1534 | | | { |
| 1535 | | | generic_item = proto_tree_add_protocol_format(tree, , tvb, offset, tvb_len, "Error: the size of Generic MAC tvb is too small! (%u bytes)", tvb_len); |
| 1536 | | | |
| 1537 | | | generic_tree = proto_item_add_subtree(generic_item, ); |
| 1538 | | | |
| 1539 | | | proto_tree_add_item(generic_tree, , tvb, offset, tvb_len, FALSE); |
| 1540 | | | return; |
| 1541 | | | } |
| 1542 | | | |
| 1543 | | | parent_item = proto_tree_get_parent(tree); |
| 1544 | | | |
| 1545 | | | proto_item_append_text(parent_item, " - Generic MAC "); |
| 1546 | | | |
| 1547 | | | generic_item = proto_tree_add_protocol_format(tree, , tvb, offset, , "Generic MAC (%u bytes)", ); |
| 1548 | | | |
| 1549 | | | generic_tree = proto_item_add_subtree(generic_item, ); |
| 1550 | | | |
| 1551 | | | |
| 1552 | | | ubyte = tvb_get_guint8(tvb, offset); |
| 1553 | | | |
| 1554 | | | mac_ht = ((ubyte & )?1:0); |
| 1555 | | | |
| 1556 | | | mac_ec = ((ubyte & )?1:0); |
| 1557 | | | |
| 1558 | | | = ((ubyte & GENERIC_SUB_TYPE_0)?1:0); |
| 1559 | | | = ((ubyte & GENERIC_SUB_TYPE_1)?1:0); |
| 1560 | | | = ((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 | | | = ((ubyte & GENERIC_SUB_TYPE_5)?1:0); |
| 1564 | | | |
| 1565 | | | ubyte = tvb_get_guint8(tvb, (offset+1)); |
| 1566 | | | |
| 1567 | | | mac_esf = ((ubyte & )?1:0); |
| 1568 | | | |
| 1569 | | | mac_ci = ((ubyte & )?1:0); |
| 1570 | | | |
| 1571 | | | mac_eks = ((ubyte & )>>4); |
| 1572 | | | |
| 1573 | | | mac_len = (tvb_get_ntohs(tvb, (offset+1)) & ); |
| 1574 | | | |
| 1575 | | | mac_cid = tvb_get_ntohs(tvb, (offset+3)); |
| 1576 | | | |
| 1577 | | | proto_tree_add_item(generic_tree, , tvb, offset, 3, FALSE); |
| 1578 | | | |
| 1579 | | | proto_tree_add_item(generic_tree, , tvb, offset, 3, FALSE); |
| 1580 | | | |
| 1581 | | | proto_tree_add_item(generic_tree, , tvb, offset, 3, FALSE); |
| 1582 | | | proto_tree_add_item(generic_tree, , tvb, offset, 3, FALSE); |
| 1583 | | | proto_tree_add_item(generic_tree, , tvb, offset, 3, FALSE); |
| 1584 | | | proto_tree_add_item(generic_tree, , tvb, offset, 3, FALSE); |
| 1585 | | | proto_tree_add_item(generic_tree, , tvb, offset, 3, FALSE); |
| 1586 | | | proto_tree_add_item(generic_tree, , tvb, offset, 3, FALSE); |
| 1587 | | | |
| 1588 | | | proto_tree_add_item(generic_tree, , tvb, offset, 3, FALSE); |
| 1589 | | | |
| 1590 | | | proto_tree_add_item(generic_tree, , tvb, offset, 3, FALSE); |
| 1591 | | | |
| 1592 | | | proto_tree_add_item(generic_tree, , tvb, offset, 3, FALSE); |
| 1593 | | | |
| 1594 | | | proto_tree_add_item(generic_tree, , tvb, offset, 3, FALSE); |
| 1595 | | | |
| 1596 | | | proto_tree_add_item(generic_tree, , tvb, offset, 3, FALSE); |
| 1597 | | | |
| 1598 | | | proto_tree_add_item(generic_tree, , tvb, (offset+3), 2, FALSE); |
| 1599 | | | |
| 1600 | | | proto_tree_add_item(generic_tree, , tvb, (offset+5), 1, FALSE); |
| 1601 | | | |
| 1602 | | | length = mac_len - ; |
| 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 | | | |
| 1607 | | | offset += ; |
| 1608 | | | |
| 1609 | | | |
| 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, , tvb, offset, length, "Encrypted PDU (%u bytes)", length); |
| 1621 | | | |
| 1622 | | | generic_tree = proto_item_add_subtree(generic_item, ett_mac_data_pdu_decoder); |
| 1623 | | | proto_tree_add_item(generic_tree, , tvb, offset, length, FALSE); |
| 1624 | | | goto check_crc; |
| 1625 | | | } |
| 1626 | | | |
| 1627 | | | |
| 1628 | | | if (mac_esf) |
| 1629 | | | { |
| 1630 | | | proto_item_append_text(parent_item, ", Extended (s)"); |
| 1631 | | | ret_length = (tvb_new_subset(tvb, offset, length, length), pinfo, tree); |
| 1632 | | | |
| 1633 | | | length -= ret_length; |
| 1634 | | | offset += ret_length; |
| 1635 | | | } |
| 1636 | | | |
| 1637 | | | if () |
| 1638 | | | { |
| 1639 | | | if (check_col(pinfo->cinfo, COL_INFO)) |
| 1640 | | | { |
| 1641 | | | col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "Mesh subhdr"); |
| 1642 | | | } |
| 1643 | | | |
| 1644 | | | proto_item_append_text(parent_item, ", Mesh "); |
| 1645 | | | |
| 1646 | | | generic_item = proto_tree_add_protocol_format(tree, , tvb, offset, length, "Mesh (2 bytes)"); |
| 1647 | | | |
| 1648 | | | generic_tree = proto_item_add_subtree(generic_item, ); |
| 1649 | | | |
| 1650 | | | proto_tree_add_item(generic_tree, , tvb, offset, 2, FALSE); |
| 1651 | | | |
| 1652 | | | length -= 2; |
| 1653 | | | offset += 2; |
| 1654 | | | } |
| 1655 | | | |
| 1656 | | | if () |
| 1657 | | | { |
| 1658 | | | if (is_down_link(&(pinfo->src))) |
| 1659 | | | { |
| 1660 | | | |
| 1661 | | | if (check_col(pinfo->cinfo, COL_INFO)) |
| 1662 | | | { |
| 1663 | | | col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "Fast-fb subhdr"); |
| 1664 | | | } |
| 1665 | | | |
| 1666 | | | proto_item_append_text(parent_item, ", Fast-feedback "); |
| 1667 | | | |
| 1668 | | | generic_item = proto_tree_add_protocol_format(tree, , tvb, offset, length, "Fast-feedback allocation (DL) (%u bytes)", length); |
| 1669 | | | |
| 1670 | | | generic_tree = proto_item_add_subtree(generic_item, ); |
| 1671 | | | proto_tree_add_item(generic_tree, , tvb, offset, 1, FALSE); |
| 1672 | | | proto_tree_add_item(generic_tree, , tvb, offset, 1, FALSE); |
| 1673 | | | |
| 1674 | | | length -= 1; |
| 1675 | | | offset += 1; |
| 1676 | | | } |
| 1677 | | | else |
| 1678 | | | { |
| 1679 | | | if (check_col(pinfo->cinfo, COL_INFO)) |
| 1680 | | | { |
| 1681 | | | col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "Grant mgmt subhdr"); |
| 1682 | | | } |
| 1683 | | | |
| 1684 | | | proto_item_append_text(parent_item, ", Grant Management "); |
| 1685 | | | |
| 1686 | | | generic_item = proto_tree_add_protocol_format(tree, , tvb, offset, 2, "Grant management (UL) (2 bytes)"); |
| 1687 | | | |
| 1688 | | | generic_tree = proto_item_add_subtree(generic_item, ); |
| 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 | | | |
| 1706 | | | child_item = proto_tree_add_item(generic_tree, , tvb, offset, 2, FALSE); |
| 1707 | | | child_tree = proto_item_add_subtree(child_item, ); |
| 1708 | | | proto_tree_add_item(child_tree, , tvb, offset, 2, FALSE); |
| 1709 | | | proto_tree_add_item(child_tree, , tvb, offset, 2, FALSE); |
| 1710 | | | proto_tree_add_item(child_tree, , tvb, offset, 2, FALSE); |
| 1711 | | | proto_tree_add_item(child_tree, , tvb, offset, 2, FALSE); |
| 1712 | | | proto_tree_add_item(child_tree, , tvb, offset, 2, FALSE); |
| 1713 | | | |
| 1714 | | | |
| 1715 | | | child_item = proto_tree_add_item(generic_tree, , tvb, offset, 2, FALSE); |
| 1716 | | | child_tree = proto_item_add_subtree(child_item, ); |
| 1717 | | | proto_tree_add_item(child_tree, , tvb, offset, 2, FALSE); |
| 1718 | | | proto_tree_add_item(child_tree, , tvb, offset, 2, FALSE); |
| 1719 | | | proto_tree_add_item(child_tree, , tvb, offset, 2, FALSE); |
| 1720 | | | |
| 1721 | | | |
| 1722 | | | child_item = proto_tree_add_item(generic_tree, , tvb, offset, 2, FALSE); |
| 1723 | | | child_tree = proto_item_add_subtree(child_item, ); |
| 1724 | | | proto_tree_add_item(child_tree, , tvb, offset, 2, FALSE); |
| 1725 | | | |
| 1726 | | | |
| 1727 | | | length -= 2; |
| 1728 | | | offset += 2; |
| 1729 | | | } |
| 1730 | | | } |
| 1731 | | | |
| 1732 | | | if () |
| 1733 | | | { |
| 1734 | | | if (check_col(pinfo->cinfo, COL_INFO)) |
| 1735 | | | { |
| 1736 | | | col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "Frag subhdr"); |
| 1737 | | | } |
| 1738 | | | |
| 1739 | | | proto_item_append_text(parent_item, ", Frag "); |
| 1740 | | | |
| 1741 | | | generic_item = proto_tree_add_protocol_format(tree, , tvb, offset, ((arq_enabled|extended_type)?2:1), "Fragmentation (%u bytes)", ((arq_enabled|extended_type)?2:1)); |
| 1742 | | | |
| 1743 | | | generic_tree = proto_item_add_subtree(generic_item, ); |
| 1744 | | | |
| 1745 | | | frag_type = (tvb_get_guint8(tvb, offset) & FRAGMENT_TYPE_MASK) >> 6; |
| 1746 | | | if (arq_fb_payload) |
| 1747 | | | { |
| 1748 | | | seq_number = (tvb_get_ntohs(tvb, offset) & SEQ_NUMBER_MASK_11) >> 3; |
| 1749 | | | |
| 1750 | | | proto_tree_add_item(generic_tree, , tvb, offset, 2, FALSE); |
| 1751 | | | proto_tree_add_item(generic_tree, , tvb, offset, 2, FALSE); |
| 1752 | | | proto_tree_add_item(generic_tree, , tvb, offset, 2, FALSE); |
| 1753 | | | |
| 1754 | | | length -= 2; |
| 1755 | | | offset += 2; |
| 1756 | | | } |
| 1757 | | | else |
| 1758 | | | { |
| 1759 | | | if (extended_type) |
| 1760 | | | { |
| 1761 | | | seq_number = (tvb_get_ntohs(tvb, offset) & SEQ_NUMBER_MASK_11) >> 3; |
| 1762 | | | |
| 1763 | | | proto_tree_add_item(generic_tree, , tvb, offset, 2, FALSE); |
| 1764 | | | proto_tree_add_item(generic_tree, , tvb, offset, 2, FALSE); |
| 1765 | | | proto_tree_add_item(generic_tree, , tvb, offset, 2, FALSE); |
| 1766 | | | |
| 1767 | | | length -= 2; |
| 1768 | | | offset += 2; |
| 1769 | | | } |
| 1770 | | | else |
| 1771 | | | { |
| 1772 | | | seq_number = (tvb_get_guint8(tvb, offset) & SEQ_NUMBER_MASK) >> 3; |
| 1773 | | | |
| 1774 | | | proto_tree_add_item(generic_tree, , tvb, offset, 1, FALSE); |
| 1775 | | | proto_tree_add_item(generic_tree, , tvb, offset, 1, FALSE); |
| 1776 | | | proto_tree_add_item(generic_tree, , tvb, offset, 1, FALSE); |
| 1777 | | | |
| 1778 | | | length -= 1; |
| 1779 | | | offset += 1; |
| 1780 | | | } |
| 1781 | | | } |
| 1782 | | | frag_len = length; |
| 1783 | | | } |
| 1784 | | | else |
| 1785 | | | { |
| 1786 | | | frag_type = NO_FRAG; |
| 1787 | | | } |
| 1788 | | | |
| 1789 | | | if (mac_ci) |
| 1790 | | | { |
| 1791 | | | if (length < (gint)sizeof(mac_crc)) |
| 1792 | | | { |
| 1793 | | | proto_tree_add_protocol_format(tree, , 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; |
| 1801 | | | if () |
| 1802 | | | { |
| 1803 | | | packing_length = (tvb, pinfo, tree, length, offset, parent_item); |
| 1804 | | | length -= packing_length; |
| 1805 | | | offset += packing_length; |
| 1806 | | | generic_item = proto_tree_add_protocol_format(tree, , tvb, offset, frag_len, "Data transport PDU (%u bytes)", frag_len); |
| 1807 | | | |
| 1808 | | | generic_tree = proto_item_add_subtree(generic_item, ett_mac_data_pdu_decoder); |
| 1809 | | | proto_tree_add_item(generic_tree, , tvb, offset, frag_len, FALSE); |
| 1810 | | | } |
| 1811 | | | |
| 1812 | | | if (frag_type == NO_FRAG) |
| 1813 | | | { |
| 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 |
| 1819 | | | { |
| 1820 | | | |
| 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 | | | |
| 1842 | | | memset(&cid_adj_array[cid_adj_array_size - 1024], 0, sizeof(guint) * 1024); |
| 1843 | | | } |
| 1844 | | | if (first_gmh) |
| 1845 | | | { |
| 1846 | | | |
| 1847 | | | cid_adjust[cid_index] += cid_vernier[cid_index]; |
| 1848 | | | |
| 1849 | | | cid_vernier[cid_index] = 0; |
| 1850 | | | } |
| 1851 | | | |
| 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 | | | |
| 1860 | | | cid_adjust[cid_index] = cid_adj_array[pinfo->fd->num]; |
| 1861 | | | |
| 1862 | | | if (first_gmh) |
| 1863 | | | { |
| 1864 | | | frag_number[cid_index] = frag_num_array[pinfo->fd->num]; |
| 1865 | | | } |
| 1866 | | | } else { |
| 1867 | | | |
| 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 | | | |
| 1875 | | | first_gmh = FALSE; |
| 1876 | | | cid = cid_base + cid_adjust[cid_index] + cid_vernier[cid_index]; |
| 1877 | | | |
| 1878 | | | save_src = pinfo->src; |
| 1879 | | | save_dst = pinfo->dst; |
| 1880 | | | |
| 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 | | | |
| 1885 | | | pinfo->src = save_src; |
| 1886 | | | pinfo->dst = save_dst; |
| 1887 | | | if (frag_type == LAST_FRAG) |
| 1888 | | | { |
| 1889 | | | |
| 1890 | | | cid_vernier[cid_index]++; |
| 1891 | | | } |
| 1892 | | | |
| 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 | | | { |
| 1897 | | | payload_length = payload_frag->len; |
| 1898 | | | |
| 1899 | | | payload_tvb = tvb_new_child_real_data(tvb, payload_frag->data, payload_length, payload_length); |
| 1900 | | | |
| 1901 | | | add_new_data_source(pinfo, payload_tvb, "Reassembled WiMax MAC payload"); |
| 1902 | | | |
| 1903 | | | new_payload_len = payload_length; |
| 1904 | | | } |
| 1905 | | | else |
| 1906 | | | { |
| 1907 | | | payload_tvb = NULL; |
| 1908 | | | #ifdef DEBUG |
| 1909 | | | |
| 1910 | | | { |
| 1911 | | | |
| 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 | | | { |
| 1919 | | | payload_tvb = tvb_new_subset(tvb, offset, length, length); |
| 1920 | | | payload_length = length; |
| 1921 | | | frag_len = length; |
| 1922 | | | } |
| 1923 | | | #endif |
| 1924 | | | } |
| 1925 | | | } |
| 1926 | | | |
| 1927 | | | if (payload_tvb) |
| 1928 | | | { |
| 1929 | | | payload_offset = 0; |
| 1930 | | | |
| 1931 | | | if (payload_length > 0) |
| 1932 | | | { |
| 1933 | | | if (!new_payload_len) |
| 1934 | | | continue; |
| 1935 | | | |
| 1936 | | | if (first_arq_fb_payload && arq_fb_payload) |
| 1937 | | | { |
| 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 |
| 1941 | | | if (ret_length != new_payload_len) |
| 1942 | | | { |
| 1943 | | | |
| 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 |
| 1950 | | | { |
| 1951 | | | if (mac_cid == cid_padding) |
| 1952 | | | { |
| 1953 | | | if (check_col(pinfo->cinfo, COL_INFO)) |
| 1954 | | | { |
| 1955 | | | col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "Padding CID"); |
| 1956 | | | } |
| 1957 | | | |
| 1958 | | | generic_item = proto_tree_get_parent(tree); |
| 1959 | | | |
| 1960 | | | proto_item_append_text(generic_item, ", Padding CID"); |
| 1961 | | | |
| 1962 | | | generic_item = proto_tree_add_protocol_format(tree, , payload_tvb, payload_offset, new_payload_len, "Padding CID (%u bytes)", new_payload_len); |
| 1963 | | | |
| 1964 | | | generic_tree = proto_item_add_subtree(generic_item, ); |
| 1965 | | | |
| 1966 | | | proto_tree_add_item(generic_tree, , 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 | | | { |
| 1971 | | | dissect_mac_mgmt_msg_decoder(tvb_new_subset(payload_tvb, payload_offset, new_payload_len, new_payload_len), pinfo, tree); |
| 1972 | | | } |
| 1973 | | | else |
| 1974 | | | { |
| 1975 | | | if (check_col(pinfo->cinfo, COL_INFO)) |
| 1976 | | | { |
| 1977 | | | col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "Data"); |
| 1978 | | | } |
| 1979 | | | |
| 1980 | | | proto_item_append_text(parent_item, ", Data"); |
| 1981 | | | |
| 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, , data_pdu_tvb, payload_offset, new_payload_len, str_ptr, new_payload_len); |
Format String
proto_tree_add_protocol_format() is being called with a format string that is not constant. The format string (sixth argument) may not match the other arguments to proto_tree_add_protocol_format(); this could lead to security or stability problems. proto_tree_add_protocol_format() is usually called with strings that look like format strings in this project. |
|
| 2004 | | | |
| 2005 | | | generic_tree = proto_item_add_subtree(generic_item, ett_mac_data_pdu_decoder); |
| 2006 | | | |
| 2007 | | | if (tvb_get_guint8(payload_tvb, payload_offset) == ) |
| 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 |
| 2013 | | | proto_tree_add_item(generic_tree, , payload_tvb, payload_offset, new_tvb_len, FALSE); |
| 2014 | | | } |
| 2015 | | | else |
| 2016 | | | proto_tree_add_item(generic_tree, , 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 | | | } |
| 2024 | | | } |
| 2025 | | | length -= frag_len; |
| 2026 | | | offset += frag_len; |
| 2027 | | | } |
| 2028 | | | check_crc: |
| 2029 | | | |
| 2030 | | | if (mac_ci) |
| 2031 | | | { |
| 2032 | | | |
| 2033 | | | proto_item_append_text(parent_item, ", CRC"); |
| 2034 | | | |
| 2035 | | | if (MIN(tvb_len, tvb_reported_length(tvb)) >= mac_len)
x /usr/include/glib-2.0/glib/gmacros.h |
| |
201 | #define MIN(a, b) (((a) < (b)) ? (a) : (b)) |
| |
|
| 2036 | | | { |
| 2037 | | | mac_crc = tvb_get_ntohl(tvb, mac_len - sizeof(mac_crc)); |
| 2038 | | | |
| 2039 | | | calculated_crc = wimax_mac_calc_crc32((guint8 *)tvb_get_ptr(tvb, 0, mac_len - sizeof(mac_crc)), mac_len - sizeof(mac_crc)); |
| 2040 | | | |
| 2041 | | | generic_item = proto_tree_add_item(tree, , 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 | | | { |
| 2049 | | | proto_tree_add_protocol_format(tree, , tvb, 0, tvb_len, "CRC missing - the frame is too short (%u bytes)", tvb_len); |
| 2050 | | | } |
| 2051 | | | } |
| 2052 | | | else |
| 2053 | | | { |
| 2054 | | | proto_item_append_text(parent_item, ", No CRC"); |
| 2055 | | | |
| 2056 | | | proto_tree_add_protocol_format(tree, , tvb, 0, tvb_len, "CRC is not included in this frame!"); |
| 2057 | | | } |
| 2058 | | | } |
| 2059 | | | } |
| |