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