summaryrefslogtreecommitdiff
path: root/agent/mibgroup/examples/netSnmpHostsTable_checkfns.c
blob: 25a733035ee38405413843ab5c6fe48ac31242f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
/*
 * Note: this file originally auto-generated by mib2c using
 *        : mib2c.check_values.conf,v 1.5 2003/05/31 00:11:57 hardaker Exp $
 */

/********************************************************************
 *                       NOTE   NOTE   NOTE
 *   This file is auto-generated and SHOULD NOT BE EDITED by hand.
 *   Modify the netSnmpHostsTable_checkfns_local.[ch] files insead so that you
 *   can regenerate this one as mib2c improvements are made.
 ********************************************************************/

/*
 * standard headers 
 */
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-features.h>
#include <net-snmp/net-snmp-includes.h>
#include "netSnmpHostsTable_checkfns.h"
#include "netSnmpHostsTable_checkfns_local.h"
#include "netSnmpHostsTable_enums.h"

netsnmp_feature_require(check_storage_transition)

/** Decides if an incoming value for the netSnmpHostAddressType mib node is legal.
 *  @param type    The incoming data type.
 *  @param val     The value to be checked.
 *  @param val_len The length of data stored in val (in bytes).
 *  @param old_val
 *  @param old_val_len
 *  @return 0 if the incoming value is legal, an SNMP error code otherwise.
 */
int
check_netSnmpHostAddressType(int type, long *val, size_t val_len,
                             long *old_val, size_t old_val_len)
{
    /** Check to see that we were called legally */
    if (!val)
        return SNMP_ERR_GENERR;

    /** Check the incoming type for correctness */
    if (type != ASN_INTEGER)
        return SNMP_ERR_WRONGTYPE;

    /** Check the enums.  Legal values will continue, others return error. */
    switch (*val) {
    case NETSNMPHOSTADDRESSTYPE_UNKNOWN:
    case NETSNMPHOSTADDRESSTYPE_IPV4:
    case NETSNMPHOSTADDRESSTYPE_IPV6:
    case NETSNMPHOSTADDRESSTYPE_IPV4Z:
    case NETSNMPHOSTADDRESSTYPE_IPV6Z:
    case NETSNMPHOSTADDRESSTYPE_DNS:
        break;

    /** not a legal enum value.  return an error */
    default:
        return SNMP_ERR_INCONSISTENTVALUE;
    }

    /** looks ok, call the local version of the same function. */
    return check_netSnmpHostAddressType_local(type, val, val_len, old_val,
                                              old_val_len);
}

/** Decides if an incoming value for the netSnmpHostAddress mib node is legal.
 *  @param type    The incoming data type.
 *  @param val     The value to be checked.
 *  @param val_len The length of data stored in val (in bytes).
 *  @param old_val
 *  @param old_val_len
 *  @return 0 if the incoming value is legal, an SNMP error code otherwise.
 */
int
check_netSnmpHostAddress(int type, char *val, size_t val_len,
                         char *old_val, size_t old_val_len)
{
    /** Check to see that we were called legally */
    if (!val)
        return SNMP_ERR_GENERR;

    /** Check the incoming type for correctness */
    if (type != ASN_OCTET_STR)
        return SNMP_ERR_WRONGTYPE;

    /** Check the ranges of the passed value for legality */
    if (!(val_len >= 0 && val_len <= 255))
        return SNMP_ERR_WRONGVALUE;

    /** looks ok, call the local version of the same function. */
    return check_netSnmpHostAddress_local(type, val, val_len, old_val,
                                          old_val_len);
}

/** Decides if an incoming value for the netSnmpHostStorage mib node is legal.
 *  @param type    The incoming data type.
 *  @param val     The value to be checked.
 *  @param val_len The length of data stored in val (in bytes).
 *  @param old_val
 *  @param old_val_len
 *  @return 0 if the incoming value is legal, an SNMP error code otherwise.
 */
int
check_netSnmpHostStorage(int type, long *val, size_t val_len,
                         long *old_val, size_t old_val_len)
{

    int             ret;

    /** Check to see that we were called legally */
    if (!val)
        return SNMP_ERR_GENERR;

    /** Check the incoming type for correctness */
    if (type != ASN_INTEGER)
        return SNMP_ERR_WRONGTYPE;

    /** Check the enums.  Legal values will continue, others return error. */
    switch (*val) {
    case NETSNMPHOSTSTORAGE_OTHER:
    case NETSNMPHOSTSTORAGE_VOLATILE:
    case NETSNMPHOSTSTORAGE_NONVOLATILE:
    case NETSNMPHOSTSTORAGE_PERMANENT:
    case NETSNMPHOSTSTORAGE_READONLY:
        break;

    /** not a legal enum value.  return an error */
    default:
        return SNMP_ERR_INCONSISTENTVALUE;
    }

    ret = check_storage_transition((old_val) ? *old_val : SNMP_STORAGE_NONE,
                                   *val);
    if (ret)
        return ret;

    /** looks ok, call the local version of the same function. */
    return check_netSnmpHostStorage_local(type, val, val_len, old_val,
                                          old_val_len);
}

/** Decides if an incoming value for the netSnmpHostRowStatus mib node is legal.
 *  @param type    The incoming data type.
 *  @param val     The value to be checked.
 *  @param val_len The length of data stored in val (in bytes).
 *  @param old_val
 *  @param old_val_len
 *  @return 0 if the incoming value is legal, an SNMP error code otherwise.
 */
int
check_netSnmpHostRowStatus(int type, long *val, size_t val_len,
                           long *old_val, size_t old_val_len)
{

    int             ret;

    /** Check to see that we were called legally */
    if (!val)
        return SNMP_ERR_GENERR;

    /** Check the incoming type for correctness */
    if (type != ASN_INTEGER)
        return SNMP_ERR_WRONGTYPE;

    /** Check the enums.  Legal values will continue, others return error. */
    switch (*val) {
    case NETSNMPHOSTROWSTATUS_ACTIVE:
    case NETSNMPHOSTROWSTATUS_NOTINSERVICE:
    case NETSNMPHOSTROWSTATUS_NOTREADY:
    case NETSNMPHOSTROWSTATUS_CREATEANDGO:
    case NETSNMPHOSTROWSTATUS_CREATEANDWAIT:
    case NETSNMPHOSTROWSTATUS_DESTROY:
        break;

    /** not a legal enum value.  return an error */
    default:
        return SNMP_ERR_INCONSISTENTVALUE;
    }

    ret = check_rowstatus_transition((old_val) ? *old_val : RS_NONEXISTENT,
                                     *val);
    if (ret)
        return ret;

    /** looks ok, call the local version of the same function. */
    return check_netSnmpHostRowStatus_local(type, val, val_len, old_val,
                                            old_val_len);
}