FreeBSD/contrib/bsnmp/lib/snmpagent.c
/*
 * Find a variable for SET/GET and the first GETBULK pass.
 * Return the node pointer. If the search fails, set the errp to
 * the correct SNMPv2 GET exception code.
 */
Find a variable for SET/GET and the first GETBULK pass.
Return the node pointer. If the search fails, set the errp to
the correct SNMPv2 GET exception code.
Find a variable for SET / GET and the first GETBULK pass . Return the node pointer . If the search fails set the errp to the correct SNMPv2 GET exception code .
static struct snmp_node *
find_node(const struct snmp_value *value, enum snmp_syntax *errp)
{
	struct snmp_node *tp;
	if (TR(FIND))
		snmp_debug("find: searching %s",
		    asn_oid2str_r(&value->var, oidbuf));
	for (tp = tree; tp < tree + tree_size; tp++) {
		if (asn_is_suboid(&tp->oid, &value->var))
			goto found;
		if (asn_compare_oid(&tp->oid, &value->var) >= 0)
			break;
	}
	if (TR(FIND))
		snmp_debug("find: no match");
	*errp = SNMP_SYNTAX_NOSUCHOBJECT;
	return (NULL);
  found:
	if (tp->type == SNMP_NODE_LEAF &&
	    (value->var.len != tp->oid.len + 1 ||
	     value->var.subs[tp->oid.len] != 0)) {
		if (TR(FIND))
			snmp_debug("find: bad leaf index");
		*errp = SNMP_SYNTAX_NOSUCHINSTANCE;
		return (NULL);
	}
	if (TR(FIND))
		snmp_debug("find: found %s",
		    asn_oid2str_r(&value->var, oidbuf));
	return (tp);
}
static struct snmp_node * find_node ( const struct snmp_value * value , enum snmp_syntax * errp ) { struct snmp_node * tp ; if ( TR ( FIND ) ) snmp_debug ( " " , asn_oid2str_r ( & value -> var , oidbuf ) ) ; for ( tp = tree ; tp < tree + tree_size ; tp ++ ) { if ( asn_is_suboid ( & tp -> oid , & value -> var ) ) goto found ; if ( asn_compare_oid ( & tp -> oid , & value -> var ) >= 0 ) break ; } if ( TR ( FIND ) ) snmp_debug ( " " ) ; * errp = SNMP_SYNTAX_NOSUCHOBJECT ; return ( NULL ) ; found : if ( tp -> type == SNMP_NODE_LEAF && ( value -> var . len != tp -> oid . len + 1 || value -> var . subs [ tp -> oid . len ] != 0 ) ) { if ( TR ( FIND ) ) snmp_debug ( " " ) ; * errp = SNMP_SYNTAX_NOSUCHINSTANCE ; return ( NULL ) ; } if ( TR ( FIND ) ) snmp_debug ( " " , asn_oid2str_r ( & value -> var , oidbuf ) ) ; return ( tp ) ; }
Find a variable for SET/GET and the first GETBULK pass.
Find a variable for SET / GET and the first GETBULK pass .
/*
	 * If we have an exact match (the entry in the table is a
	 * sub-oid from the variable) we have found what we are for.
	 * If the table oid is higher than the variable, there is no match.
	 */ /* leafs must have a 0 instance identifier */