~ubuntu-branches/ubuntu/trusty/net-snmp/trusty

« back to all changes in this revision

Viewing changes to agent/mibgroup/agentx/protocol.c

  • Committer: Bazaar Package Importer
  • Author(s): Jochen Friedrich
  • Date: 2009-11-12 16:17:40 UTC
  • mto: (1.4.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 32.
  • Revision ID: james.westby@ubuntu.com-20091112161740-t2xvix834vmtxa9f
Tags: upstream-5.4.2.1~dfsg
ImportĀ upstreamĀ versionĀ 5.4.2.1~dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
1402
1402
 
1403
1403
        memcpy(data_buf, &tmp64, sizeof(tmp64));
1404
1404
        *data_len = sizeof(tmp64);
1405
 
        bufp += 2 * sizeof(long);
 
1405
        bufp    += 8;
1406
1406
        *length -= 8;
1407
1407
        break;
1408
1408
 
1532
1532
             size_t len)
1533
1533
{
1534
1534
    register u_char *bufp = data;
1535
 
    u_char          buffer[BUFSIZ];
 
1535
    u_char          buffer[SNMP_MAX_MSG_SIZE];
1536
1536
    u_char         *prefix_ptr;
1537
1537
    oid             oid_buffer[MAX_OID_LEN], end_oid_buf[MAX_OID_LEN];
1538
 
    size_t          buf_len = BUFSIZ;
 
1538
    size_t          buf_len = sizeof(buffer);
1539
1539
    size_t          oid_buf_len = MAX_OID_LEN;
1540
1540
    size_t          end_oid_buf_len = MAX_OID_LEN;
1541
1541
 
1591
1591
    if (pdu->flags & AGENTX_MSG_FLAG_NON_DEFAULT_CONTEXT) {
1592
1592
        DEBUGDUMPHEADER("recv", "Context");
1593
1593
        bufp = agentx_parse_string(bufp, length, buffer, &buf_len,
1594
 
                                   pdu->
1595
 
                                   flags &
 
1594
                                   pdu->flags &
1596
1595
                                   AGENTX_FLAGS_NETWORK_BYTE_ORDER);
1597
1596
        DEBUGINDENTLESS();
1598
1597
        if (bufp == NULL)
1601
1600
        pdu->community_len = buf_len;
1602
1601
        snmp_clone_mem((void **) &pdu->community,
1603
1602
                       (void *) buffer, (unsigned) buf_len);
1604
 
        buf_len = BUFSIZ;
 
1603
        buf_len = sizeof(buffer);
1605
1604
    }
1606
1605
 
1607
1606
    DEBUGDUMPHEADER("recv", "PDU");
1618
1617
        DEBUGDUMPHEADER("recv", "Subagent OID");
1619
1618
        bufp = agentx_parse_oid(bufp, length, NULL,
1620
1619
                                oid_buffer, &oid_buf_len,
1621
 
                                pdu->
1622
 
                                flags & AGENTX_FLAGS_NETWORK_BYTE_ORDER);
 
1620
                                pdu->flags & AGENTX_FLAGS_NETWORK_BYTE_ORDER);
1623
1621
        DEBUGINDENTLESS();
1624
1622
        if (bufp == NULL) {
1625
1623
            DEBUGINDENTLESS();
1627
1625
        }
1628
1626
        DEBUGDUMPHEADER("recv", "Subagent Description");
1629
1627
        bufp = agentx_parse_string(bufp, length, buffer, &buf_len,
1630
 
                                   pdu->
1631
 
                                   flags &
 
1628
                                   pdu->flags &
1632
1629
                                   AGENTX_FLAGS_NETWORK_BYTE_ORDER);
1633
1630
        DEBUGINDENTLESS();
1634
1631
        if (bufp == NULL) {
1639
1636
                              ASN_OCTET_STR, buffer, buf_len);
1640
1637
 
1641
1638
        oid_buf_len = MAX_OID_LEN;
1642
 
        buf_len = BUFSIZ;
 
1639
        buf_len = sizeof(buffer);
1643
1640
        break;
1644
1641
 
1645
1642
    case AGENTX_MSG_CLOSE:
1674
1671
        DEBUGDUMPHEADER("recv", "Registration OID");
1675
1672
        bufp = agentx_parse_oid(bufp, length, NULL,
1676
1673
                                oid_buffer, &oid_buf_len,
1677
 
                                pdu->
1678
 
                                flags & AGENTX_FLAGS_NETWORK_BYTE_ORDER);
 
1674
                                pdu->flags & AGENTX_FLAGS_NETWORK_BYTE_ORDER);
1679
1675
        DEBUGINDENTLESS();
1680
1676
        if (bufp == NULL) {
1681
1677
            DEBUGINDENTLESS();
1683
1679
        }
1684
1680
 
1685
1681
        if (pdu->range_subid) {
1686
 
            range_bound = agentx_parse_int(bufp,
1687
 
                                           pdu->
1688
 
                                           flags &
 
1682
            range_bound = agentx_parse_int(bufp, pdu->flags &
1689
1683
                                           AGENTX_FLAGS_NETWORK_BYTE_ORDER);
1690
1684
            bufp += 4;
1691
1685
            *length -= 4;
1709
1703
 
1710
1704
    case AGENTX_MSG_GETBULK:
1711
1705
        DEBUGDUMPHEADER("recv", "Non-repeaters");
1712
 
        pdu->non_repeaters = agentx_parse_short(bufp,
1713
 
                                                pdu->
1714
 
                                                flags &
 
1706
        pdu->non_repeaters = agentx_parse_short(bufp, pdu->flags &
1715
1707
                                                AGENTX_FLAGS_NETWORK_BYTE_ORDER);
1716
1708
        DEBUGINDENTLESS();
1717
1709
        DEBUGDUMPHEADER("recv", "Max-repeaters");
1718
 
        pdu->max_repetitions = agentx_parse_short(bufp + 2,
1719
 
                                                  pdu->
1720
 
                                                  flags &
 
1710
        pdu->max_repetitions = agentx_parse_short(bufp + 2, pdu->flags &
1721
1711
                                                  AGENTX_FLAGS_NETWORK_BYTE_ORDER);
1722
1712
        DEBUGINDENTLESS();
1723
1713
        bufp += 4;
1737
1727
        while (*length > 0) {
1738
1728
            bufp = agentx_parse_oid(bufp, length, &inc,
1739
1729
                                    oid_buffer, &oid_buf_len,
1740
 
                                    pdu->
1741
 
                                    flags &
 
1730
                                    pdu->flags &
1742
1731
                                    AGENTX_FLAGS_NETWORK_BYTE_ORDER);
1743
1732
            if (bufp == NULL) {
1744
1733
                DEBUGINDENTLESS();
1747
1736
            }
1748
1737
            bufp = agentx_parse_oid(bufp, length, NULL,
1749
1738
                                    end_oid_buf, &end_oid_buf_len,
1750
 
                                    pdu->
1751
 
                                    flags &
 
1739
                                    pdu->flags &
1752
1740
                                    AGENTX_FLAGS_NETWORK_BYTE_ORDER);
1753
1741
            if (bufp == NULL) {
1754
1742
                DEBUGINDENTLESS();
1786
1774
        /*
1787
1775
         * sysUpTime 
1788
1776
         */
1789
 
        pdu->time = agentx_parse_int(bufp,
1790
 
                                     pdu->
1791
 
                                     flags &
 
1777
        pdu->time = agentx_parse_int(bufp, pdu->flags &
1792
1778
                                     AGENTX_FLAGS_NETWORK_BYTE_ORDER);
1793
1779
        bufp += 4;
1794
1780
        *length -= 4;
1795
1781
 
1796
 
        pdu->errstat = agentx_parse_short(bufp,
1797
 
                                          pdu->
1798
 
                                          flags &
 
1782
        pdu->errstat = agentx_parse_short(bufp, pdu->flags &
1799
1783
                                          AGENTX_FLAGS_NETWORK_BYTE_ORDER);
1800
1784
        pdu->errindex =
1801
1785
            agentx_parse_short(bufp + 2,
1802
 
                               pdu->
1803
 
                               flags & AGENTX_FLAGS_NETWORK_BYTE_ORDER);
 
1786
                               pdu->flags & AGENTX_FLAGS_NETWORK_BYTE_ORDER);
1804
1787
        bufp += 4;
1805
1788
        *length -= 4;
1806
1789
        /*
1822
1805
            bufp = agentx_parse_varbind(bufp, length, &type,
1823
1806
                                        oid_buffer, &oid_buf_len,
1824
1807
                                        buffer, &buf_len,
1825
 
                                        pdu->
1826
 
                                        flags &
 
1808
                                        pdu->flags &
1827
1809
                                        AGENTX_FLAGS_NETWORK_BYTE_ORDER);
1828
1810
            if (bufp == NULL) {
1829
1811
                DEBUGINDENTLESS();
1834
1816
                                  (u_char) type, buffer, buf_len);
1835
1817
 
1836
1818
            oid_buf_len = MAX_OID_LEN;
1837
 
            buf_len = BUFSIZ;
 
1819
            buf_len = sizeof(buffer);
1838
1820
        }
1839
1821
        DEBUGINDENTLESS();
1840
1822
        break;
1856
1838
         */
1857
1839
        bufp = agentx_parse_oid(bufp, length, NULL,
1858
1840
                                oid_buffer, &oid_buf_len,
1859
 
                                pdu->
1860
 
                                flags & AGENTX_FLAGS_NETWORK_BYTE_ORDER);
 
1841
                                pdu->flags & AGENTX_FLAGS_NETWORK_BYTE_ORDER);
1861
1842
        if (bufp == NULL)
1862
1843
            return SNMPERR_ASN_PARSE_ERR;
1863
1844
        bufp = agentx_parse_string(bufp, length, buffer, &buf_len,
1864
 
                                   pdu->
1865
 
                                   flags &
 
1845
                                   pdu->flags &
1866
1846
                                   AGENTX_FLAGS_NETWORK_BYTE_ORDER);
1867
1847
        if (bufp == NULL)
1868
1848
            return SNMPERR_ASN_PARSE_ERR;
1870
1850
                              ASN_OCTET_STR, buffer, buf_len);
1871
1851
 
1872
1852
        oid_buf_len = MAX_OID_LEN;
1873
 
        buf_len = BUFSIZ;
 
1853
        buf_len = sizeof(buffer);
1874
1854
        break;
1875
1855
 
1876
1856
    case AGENTX_MSG_REMOVE_AGENT_CAPS:
1879
1859
         */
1880
1860
        bufp = agentx_parse_oid(bufp, length, NULL,
1881
1861
                                oid_buffer, &oid_buf_len,
1882
 
                                pdu->
1883
 
                                flags & AGENTX_FLAGS_NETWORK_BYTE_ORDER);
 
1862
                                pdu->flags & AGENTX_FLAGS_NETWORK_BYTE_ORDER);
1884
1863
        if (bufp == NULL)
1885
1864
            return SNMPERR_ASN_PARSE_ERR;
1886
1865
        snmp_add_null_var(pdu, oid_buffer, oid_buf_len);