def sgetnext(self, root): req = self._create_request(SNMP_MSG_GETNEXT) oid = mkoid(root) lib.snmp_add_null_var(req, oid, len(oid)) response = netsnmp_pdu_p() if lib.snmp_synch_response(self.sess, req, byref(response)) == 0: _raise_on_protocol_error(response) result = dict(getResult(response.contents)) lib.snmp_free_pdu(response) return result else: _raise_on_error(self.sess.contents.s_snmp_errno)
def sgetbulk(self, nonrepeaters, maxrepetitions, oids): req = self._create_request(SNMP_MSG_GETBULK) req = cast(req, POINTER(netsnmp_pdu)) req.contents.errstat = nonrepeaters req.contents.errindex = maxrepetitions for oid in oids: oid = mkoid(oid) lib.snmp_add_null_var(req, oid, len(oid)) response = netsnmp_pdu_p() if lib.snmp_synch_response(self.sess, req, byref(response)) == 0: _raise_on_protocol_error(response) result = getResult(response.contents) lib.snmp_free_pdu(response) return result else: _raise_on_error(self.sess.contents.s_snmp_errno)