diff options
author | Vincent Bernat <bernat@luffy.cx> | 2012-05-31 13:30:28 +0200 |
---|---|---|
committer | Vincent Bernat <bernat@luffy.cx> | 2012-06-25 19:03:23 +0200 |
commit | 8046ba6ec4d6e87bf8da6563c0f3e5e66c4652b3 (patch) | |
tree | 1b38b2eae4e1cee042f96a42217b14647159bf0f /lib/snmp.c | |
parent | agentx: add appropriate documentation (diff) | |
download | frr-8046ba6ec4d6e87bf8da6563c0f3e5e66c4652b3.tar.xz frr-8046ba6ec4d6e87bf8da6563c0f3e5e66c4652b3.zip |
snmp: let handlers accept OID from a lesser prefix
Most table handlers do not expect to be given an OID whose prefix is
outside what they can handle. This is not a problem with the SMUX
implementation since it always correct the OID such that the prefix
matches. However, this is not the case for the AgentX
implementation. A new function, smux_header_table() is used to do this
normalization.
Diffstat (limited to 'lib/snmp.c')
-rw-r--r-- | lib/snmp.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/snmp.c b/lib/snmp.c index d7b1d9539..79595a1ea 100644 --- a/lib/snmp.c +++ b/lib/snmp.c @@ -110,4 +110,24 @@ smux_header_generic (struct variable *v, oid *name, size_t *length, int exact, return MATCH_SUCCEEDED; } + +int +smux_header_table (struct variable *v, oid *name, size_t *length, int exact, + size_t *var_len, WriteMethod **write_method) +{ + /* If the requested OID name is less than OID prefix we + handle, adjust it to our prefix. */ + if ((oid_compare (name, *length, v->name, v->namelen)) < 0) + { + if (exact) + return MATCH_FAILED; + oid_copy(name, v->name, v->namelen); + *length = v->namelen; + } + + *write_method = 0; + *var_len = sizeof(long); + + return MATCH_SUCCEEDED; +} #endif /* HAVE_SNMP */ |