| 1 |
/* |
| 2 |
* HP specific stuff that OpenView recognizes |
| 3 |
*/ |
| 4 |
|
| 5 |
#include <net-snmp/net-snmp-config.h> |
| 6 |
|
| 7 |
#include <signal.h> |
| 8 |
#ifdef HAVE_MACHINE_PARAM_H |
| 9 |
#include <machine/param.h> |
| 10 |
#endif |
| 11 |
#ifdef HAVE_SYS_VMMETER_H |
| 12 |
#include <sys/vmmeter.h> |
| 13 |
#endif |
| 14 |
#ifdef HAVE_STRING_H |
| 15 |
#include <string.h> |
| 16 |
#endif |
| 17 |
|
| 18 |
#include <net-snmp/net-snmp-includes.h> |
| 19 |
#include <net-snmp/agent/net-snmp-agent-includes.h> |
| 20 |
|
| 21 |
#include "hpux.h" |
| 22 |
#include "mibdefs.h" |
| 23 |
|
| 24 |
void |
| 25 |
int_hpux(void) |
| 26 |
{ |
| 27 |
|
| 28 |
/* |
| 29 |
* define the structure we're going to ask the agent to register our |
| 30 |
* information at |
| 31 |
*/ |
| 32 |
struct variable2 hp_variables[] = { |
| 33 |
{HPCONF, ASN_INTEGER, NETSNMP_OLDAPI_RWRITE, |
| 34 |
var_hp, 1, {HPCONF}}, |
| 35 |
{HPRECONFIG, ASN_INTEGER, NETSNMP_OLDAPI_RWRITE, |
| 36 |
var_hp, 1, {HPRECONFIG}}, |
| 37 |
{HPFLAG, ASN_INTEGER, NETSNMP_OLDAPI_RWRITE, |
| 38 |
var_hp, 1, {HPFLAG}}, |
| 39 |
{HPLOGMASK, ASN_INTEGER, NETSNMP_OLDAPI_RWRITE, |
| 40 |
var_hp, 1, {ERRORFLAG}}, |
| 41 |
{HPSTATUS, ASN_INTEGER, NETSNMP_OLDAPI_RWRITE, |
| 42 |
var_hp, 1, {ERRORMSG}} |
| 43 |
}; |
| 44 |
|
| 45 |
struct variable2 hptrap_variables[] = { |
| 46 |
{HPTRAP, ASN_IPADDRESS, NETSNMP_OLDAPI_RWRITE, |
| 47 |
var_hp, 1, {HPTRAP}}, |
| 48 |
}; |
| 49 |
|
| 50 |
/* |
| 51 |
* Define the OID pointer to the top of the mib tree that we're |
| 52 |
* registering underneath |
| 53 |
*/ |
| 54 |
oid hp_variables_oid[] = |
| 55 |
{ 1, 3, 6, 1, 4, 1, 11, 2, 13, 1, 2, 1 }; |
| 56 |
oid hptrap_variables_oid[] = |
| 57 |
{ 1, 3, 6, 1, 4, 1, 11, 2, 13, 2 }; |
| 58 |
|
| 59 |
/* |
| 60 |
* register ourselves with the agent to handle our mib tree |
| 61 |
*/ |
| 62 |
REGISTER_MIB("ucd-snmp/hpux:hp", hp_variables, variable2, |
| 63 |
hp_variables_oid); |
| 64 |
REGISTER_MIB("ucd-snmp/hpux:hptrap", hptrap_variables, variable2, |
| 65 |
hptrap_variables_oid); |
| 66 |
|
| 67 |
} |
| 68 |
|
| 69 |
|
| 70 |
#ifdef RESERVED_FOR_FUTURE_USE |
| 71 |
int |
| 72 |
writeHP(int action, |
| 73 |
u_char * var_val, |
| 74 |
u_char var_val_type, |
| 75 |
int var_val_len, u_char * statP, oid * name, int name_len) |
| 76 |
{ |
| 77 |
DODEBUG("Gotto: writeHP\n"); |
| 78 |
return SNMP_ERR_NOERROR; |
| 79 |
} |
| 80 |
#endif |
| 81 |
|
| 82 |
unsigned char * |
| 83 |
var_hp(struct variable *vp, |
| 84 |
oid * name, |
| 85 |
size_t * length, |
| 86 |
int exact, size_t * var_len, WriteMethod ** write_method) |
| 87 |
{ |
| 88 |
|
| 89 |
oid newname[MAX_OID_LEN]; |
| 90 |
int result; |
| 91 |
static long long_ret; |
| 92 |
|
| 93 |
memcpy((char *) newname, (char *) vp->name, |
| 94 |
(int) vp->namelen * sizeof(oid)); |
| 95 |
newname[*length] = 0; |
| 96 |
result = |
| 97 |
snmp_oid_compare(name, *length, newname, (int) vp->namelen + 1); |
| 98 |
if ((exact && (result != 0)) || (!exact && (result >= 0))) |
| 99 |
return NULL; |
| 100 |
memcpy((char *) name, (char *) newname, |
| 101 |
((int) vp->namelen + 1) * sizeof(oid)); |
| 102 |
*length = *length + 1; |
| 103 |
*var_len = sizeof(long); /* default length */ |
| 104 |
switch (vp->magic) { |
| 105 |
case HPFLAG: |
| 106 |
case HPCONF: |
| 107 |
case HPSTATUS: |
| 108 |
case HPRECONFIG: |
| 109 |
long_ret = 1; |
| 110 |
return (u_char *) & long_ret; /* remove trap */ |
| 111 |
case HPLOGMASK: |
| 112 |
long_ret = 3; |
| 113 |
return (u_char *) & long_ret; |
| 114 |
case HPTRAP: |
| 115 |
newname[*length - 1] = 128; |
| 116 |
newname[*length] = 120; |
| 117 |
newname[*length + 1] = 57; |
| 118 |
newname[*length + 2] = 92; |
| 119 |
*length = *length + 3; |
| 120 |
memcpy((char *) name, (char *) newname, *length * sizeof(oid)); |
| 121 |
long_ret = ((((((128 << 8) + 120) << 8) + 57) << 8) + 92); |
| 122 |
return (u_char *) & long_ret; |
| 123 |
} |
| 124 |
return NULL; |
| 125 |
} |