FreeBSD/contrib/bsnmp/lib/snmpagent.c
/*
 * Execute a GETNEXT operation. The tree is rooted at the global 'root'.
 * Build the response PDU on the fly. The return is:
 */
Execute a GETNEXT operation. The tree is rooted at the global 'root'.
Build the response PDU on the fly. The return is.
Execute a GETNEXT operation . The tree is rooted at the global ' root ' . Build the response PDU on the fly . The return is .
enum snmp_ret
snmp_getnext(struct snmp_pdu *pdu, struct asn_buf *resp_b,
    struct snmp_pdu *resp, void *data)
{
	struct context context;
	u_int i;
	enum asn_err err;
	enum snmp_ret result;
	memset(&context, 0, sizeof(context));
	context.ctx.data = data;
	snmp_pdu_create_response(pdu, resp);
	if (snmp_pdu_encode_header(resp_b, resp))
		return (SNMP_RET_IGN);
	for (i = 0; i < pdu->nbindings; i++) {
		result = do_getnext(&context, &pdu->bindings[i],
		    &resp->bindings[i], pdu);
		if (result != SNMP_RET_OK) {
			pdu->error_index = i + 1;
			snmp_pdu_free(resp);
			return (result);
		}
		resp->nbindings++;
		err = snmp_binding_encode(resp_b, &resp->bindings[i]);
		if (err == ASN_ERR_EOBUF) {
			pdu->error_status = SNMP_ERR_TOOBIG;
			pdu->error_index = 0;
			snmp_pdu_free(resp);
			return (SNMP_RET_ERR);
		}
		if (err != ASN_ERR_OK) {
			if (TR(GET))
				snmp_debug("getnext: binding encoding: %u", err);
			pdu->error_status = SNMP_ERR_GENERR;
			pdu->error_index = i + 1;
			snmp_pdu_free(resp);
			return (SNMP_RET_ERR);
		}
	}
	if (snmp_fix_encoding(resp_b, resp) != SNMP_CODE_OK) {
		snmp_debug("getnext: failed to encode PDU");
		return (SNMP_RET_ERR);
	}
	return (SNMP_RET_OK);
}
enum snmp_ret snmp_getnext ( struct snmp_pdu * pdu , struct asn_buf * resp_b , struct snmp_pdu * resp , void * data ) { struct context context ; u_int i ; enum asn_err err ; enum snmp_ret result ; memset ( & context , 0 , sizeof ( context ) ) ; context . ctx . data = data ; snmp_pdu_create_response ( pdu , resp ) ; if ( snmp_pdu_encode_header ( resp_b , resp ) ) return ( SNMP_RET_IGN ) ; for ( i = 0 ; i < pdu -> nbindings ; i ++ ) { result = do_getnext ( & context , & pdu -> bindings [ i ] , & resp -> bindings [ i ] , pdu ) ; if ( result != SNMP_RET_OK ) { pdu -> error_index = i + 1 ; snmp_pdu_free ( resp ) ; return ( result ) ; } resp -> nbindings ++ ; err = snmp_binding_encode ( resp_b , & resp -> bindings [ i ] ) ; if ( err == ASN_ERR_EOBUF ) { pdu -> error_status = SNMP_ERR_TOOBIG ; pdu -> error_index = 0 ; snmp_pdu_free ( resp ) ; return ( SNMP_RET_ERR ) ; } if ( err != ASN_ERR_OK ) { if ( TR ( GET ) ) snmp_debug ( " " , err ) ; pdu -> error_status = SNMP_ERR_GENERR ; pdu -> error_index = i + 1 ; snmp_pdu_free ( resp ) ; return ( SNMP_RET_ERR ) ; } } if ( snmp_fix_encoding ( resp_b , resp ) != SNMP_CODE_OK ) { snmp_debug ( " " ) ; return ( SNMP_RET_ERR ) ; } return ( SNMP_RET_OK ) ; }
Execute a GETNEXT operation.
Execute a GETNEXT operation .