| 1 |
#include <net-snmp/net-snmp-config.h> |
| 2 |
#include <net-snmp/net-snmp-includes.h> |
| 3 |
#include <net-snmp/agent/net-snmp-agent-includes.h> |
| 4 |
|
| 5 |
#include "header_generic.h" |
| 6 |
|
| 7 |
/* |
| 8 |
* header_generic(... |
| 9 |
* Arguments: |
| 10 |
* vp IN - pointer to variable entry that points here |
| 11 |
* name IN/OUT - IN/name requested, OUT/name found |
| 12 |
* length IN/OUT - length of IN/OUT oid's |
| 13 |
* exact IN - TRUE if an exact match was requested |
| 14 |
* var_len OUT - length of variable or 0 if function returned |
| 15 |
* write_method |
| 16 |
* |
| 17 |
*/ |
| 18 |
|
| 19 |
/*******************************************************************-o-****** |
| 20 |
* generic_header |
| 21 |
* |
| 22 |
* Parameters: |
| 23 |
* *vp (I) Pointer to variable entry that points here. |
| 24 |
* *name (I/O) Input name requested, output name found. |
| 25 |
* *length (I/O) Length of input and output oid's. |
| 26 |
* exact (I) TRUE if an exact match was requested. |
| 27 |
* *var_len (O) Length of variable or 0 if function returned. |
| 28 |
* (**write_method) Hook to name a write method (UNUSED). |
| 29 |
* |
| 30 |
* Returns: |
| 31 |
* MATCH_SUCCEEDED If vp->name matches name (accounting for exact bit). |
| 32 |
* MATCH_FAILED Otherwise, |
| 33 |
* |
| 34 |
* |
| 35 |
* Check whether variable (vp) matches name. |
| 36 |
*/ |
| 37 |
int |
| 38 |
header_generic(struct variable *vp, |
| 39 |
oid * name, |
| 40 |
size_t * length, |
| 41 |
int exact, size_t * var_len, WriteMethod ** write_method) |
| 42 |
{ |
| 43 |
oid newname[MAX_OID_LEN]; |
| 44 |
int result; |
| 45 |
|
| 46 |
DEBUGMSGTL(("util_funcs", "header_generic: ")); |
| 47 |
DEBUGMSGOID(("util_funcs", name, *length)); |
| 48 |
DEBUGMSG(("util_funcs", " exact=%d\n", exact)); |
| 49 |
|
| 50 |
memcpy((char *) newname, (char *) vp->name, |
| 51 |
(int) vp->namelen * sizeof(oid)); |
| 52 |
newname[vp->namelen] = 0; |
| 53 |
result = snmp_oid_compare(name, *length, newname, vp->namelen + 1); |
| 54 |
DEBUGMSGTL(("util_funcs", " result: %d\n", result)); |
| 55 |
if ((exact && (result != 0)) || (!exact && (result >= 0))) |
| 56 |
return (MATCH_FAILED); |
| 57 |
memcpy((char *) name, (char *) newname, |
| 58 |
((int) vp->namelen + 1) * sizeof(oid)); |
| 59 |
*length = vp->namelen + 1; |
| 60 |
|
| 61 |
*write_method = (WriteMethod*)0; |
| 62 |
*var_len = sizeof(long); /* default to 'long' results */ |
| 63 |
return (MATCH_SUCCEEDED); |
| 64 |
} |