4 #include <net-snmp/mib_api.h>
5 #include <net-snmp/pdu_api.h>
6 #include <net-snmp/session_api.h>
9 mib_TxtToOid(char *Buf, oid ** OidP, size_t * LenP)
11 return read_objid(Buf, *OidP, LenP);
15 mib_OidToTxt(oid * O, size_t OidLen, char *Buf, size_t BufLen)
17 _sprint_objid(Buf, O, OidLen);
24 snmp_pdu_type(netsnmp_pdu *PDU)
26 switch (PDU->command) {
30 case SNMP_MSG_GETNEXT:
33 case SNMP_MSG_RESPONSE:
39 case SNMP_MSG_GETBULK:
62 * cmu_snmp_parse - emulate CMU library's snmp_parse.
64 * Parse packet, storing results into PDU.
65 * Returns community string if success, NULL if fail.
66 * WARNING: may return a zero length community string.
69 * Some CMU-aware apps call init_mib(), but do not
70 * initialize a session.
71 * Check Reqid to make sure that this module is initialized.
75 cmu_snmp_parse(netsnmp_session * session,
76 netsnmp_pdu *pdu, u_char * data, size_t length)
80 snmp_sess_init(session); /* gimme a break! */
82 switch (pdu->version) {
85 case SNMP_DEFAULT_VERSION:
90 #ifndef NO_INTERNAL_VARLIST
91 if (snmp_parse(0, session, pdu, data, length) != SNMP_ERR_NOERROR) {
96 * while there are two versions of variable_list:
97 * use an internal variable list for snmp_parse;
101 netsnmp_pdu *snmp_clone_pdu(netsnmp_pdu *);
102 netsnmp_pdu *snmp_2clone_pdu(netsnmp_pdu *from_pdu,
103 netsnmp_pdu *to_pdu);
106 ipdu = snmp_clone_pdu(pdu);
107 if (snmp_parse(0, session, ipdu, data, length) != SNMP_ERR_NOERROR) {
108 snmp_free_internal_pdu(ipdu);
111 pdu = snmp_2clone_pdu(ipdu, pdu);
112 snmp_free_internal_pdu(ipdu);
114 #endif /* NO_INTERNAL_VAR_LIST */
117 * Add a null to meet the caller's expectations.
120 bufp = (u_char *) malloc(1 + pdu->community_len);
121 if (bufp && pdu->community_len) {
122 memcpy(bufp, pdu->community, pdu->community_len);
123 bufp[pdu->community_len] = '\0';
129 #endif /* CMU_COMPATIBLE */