00001 #ifndef SNMP_H
00002 #define SNMP_H
00003
00004 #ifdef __cplusplus
00005 extern "C" {
00006 #endif
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #define SNMP_PORT 161
00036
00037 #define SNMP_TRAP_PORT 162
00038
00039
00040
00041 #define SNMP_MAX_LEN 1500
00042 #define SNMP_MIN_MAX_LEN 484
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099 #ifndef DISABLE_SNMPV1
00100 #define SNMP_VERSION_1 0
00101 #endif
00102 #ifndef DISABLE_SNMPV2C
00103 #define SNMP_VERSION_2c 1
00104 #endif
00105 #define SNMP_VERSION_2u 2
00106 #define SNMP_VERSION_3 3
00107
00108
00109
00110
00111 #define SNMP_VERSION_sec 128
00112 #define SNMP_VERSION_2p 129
00113 #define SNMP_VERSION_2star 130
00114
00115
00116
00117
00118 #define SNMP_MSG_GET (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x0)
00119 #define SNMP_MSG_GETNEXT (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x1)
00120 #define SNMP_MSG_RESPONSE (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x2)
00121 #define SNMP_MSG_SET (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x3)
00122
00123
00124
00125
00126 #define SNMP_MSG_TRAP (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x4)
00127
00128
00129
00130
00131 #define SNMP_MSG_GETBULK (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x5)
00132 #define SNMP_MSG_INFORM (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x6)
00133 #define SNMP_MSG_TRAP2 (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x7)
00134
00135
00136
00137
00138 #define SNMP_MSG_REPORT (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x8)
00139
00140
00141
00142
00143
00144
00145
00146 #define SNMP_MSG_INTERNAL_SET_BEGIN -1
00147 #define SNMP_MSG_INTERNAL_SET_RESERVE1 0
00148 #define SNMP_MSG_INTERNAL_SET_RESERVE2 1
00149 #define SNMP_MSG_INTERNAL_SET_ACTION 2
00150 #define SNMP_MSG_INTERNAL_SET_COMMIT 3
00151 #define SNMP_MSG_INTERNAL_SET_FREE 4
00152 #define SNMP_MSG_INTERNAL_SET_UNDO 5
00153 #define SNMP_MSG_INTERNAL_SET_MAX 6
00154
00155 #define SNMP_MSG_INTERNAL_CHECK_VALUE 17
00156 #define SNMP_MSG_INTERNAL_ROW_CREATE 18
00157 #define SNMP_MSG_INTERNAL_UNDO_SETUP 19
00158 #define SNMP_MSG_INTERNAL_SET_VALUE 20
00159 #define SNMP_MSG_INTERNAL_CHECK_CONSISTENCY 21
00160 #define SNMP_MSG_INTERNAL_UNDO_SET 22
00161 #define SNMP_MSG_INTERNAL_COMMIT 23
00162 #define SNMP_MSG_INTERNAL_UNDO_COMMIT 24
00163 #define SNMP_MSG_INTERNAL_IRREVERSIBLE_COMMIT 25
00164 #define SNMP_MSG_INTERNAL_UNDO_CLEANUP 26
00165
00166
00167
00168
00169
00170 #define SNMP_MSG_INTERNAL_PRE_REQUEST 128
00171 #define SNMP_MSG_INTERNAL_OBJECT_LOOKUP 129
00172 #define SNMP_MSG_INTERNAL_POST_REQUEST 130
00173 #define SNMP_MSG_INTERNAL_GET_STASH 131
00174
00175
00176
00177
00178 #define SNMP_CMD_CONFIRMED(c) (c == SNMP_MSG_INFORM || c == SNMP_MSG_GETBULK ||\
00179 c == SNMP_MSG_GETNEXT || c == SNMP_MSG_GET || \
00180 c == SNMP_MSG_SET)
00181
00182
00183
00184
00185 #define SNMP_NOSUCHOBJECT (ASN_CONTEXT | ASN_PRIMITIVE | 0x0)
00186 #define SNMP_NOSUCHINSTANCE (ASN_CONTEXT | ASN_PRIMITIVE | 0x1)
00187 #define SNMP_ENDOFMIBVIEW (ASN_CONTEXT | ASN_PRIMITIVE | 0x2)
00188
00189
00190
00191
00192
00193
00194
00195
00196 #define SNMP_ERR_NOERROR (0)
00197 #define SNMP_ERR_TOOBIG (1)
00198 #define SNMP_ERR_NOSUCHNAME (2)
00199 #define SNMP_ERR_BADVALUE (3)
00200 #define SNMP_ERR_READONLY (4)
00201 #define SNMP_ERR_GENERR (5)
00202
00203
00204
00205
00206 #define SNMP_ERR_NOACCESS (6)
00207 #define SNMP_ERR_WRONGTYPE (7)
00208 #define SNMP_ERR_WRONGLENGTH (8)
00209 #define SNMP_ERR_WRONGENCODING (9)
00210 #define SNMP_ERR_WRONGVALUE (10)
00211 #define SNMP_ERR_NOCREATION (11)
00212 #define SNMP_ERR_INCONSISTENTVALUE (12)
00213 #define SNMP_ERR_RESOURCEUNAVAILABLE (13)
00214 #define SNMP_ERR_COMMITFAILED (14)
00215 #define SNMP_ERR_UNDOFAILED (15)
00216 #define SNMP_ERR_AUTHORIZATIONERROR (16)
00217 #define SNMP_ERR_NOTWRITABLE (17)
00218
00219
00220
00221
00222 #define SNMP_ERR_INCONSISTENTNAME (18)
00223
00224 #define MAX_SNMP_ERR 18
00225
00226 #define SNMP_VALIDATE_ERR(x) ( (x > MAX_SNMP_ERR) ? \
00227 SNMP_ERR_GENERR : \
00228 (x < SNMP_ERR_NOERROR) ? \
00229 SNMP_ERR_GENERR : \
00230 x )
00231
00232
00233
00234
00235 #define SNMP_TRAP_COLDSTART (0)
00236 #define SNMP_TRAP_WARMSTART (1)
00237 #define SNMP_TRAP_LINKDOWN (2)
00238 #define SNMP_TRAP_LINKUP (3)
00239 #define SNMP_TRAP_AUTHFAIL (4)
00240 #define SNMP_TRAP_EGPNEIGHBORLOSS (5)
00241 #define SNMP_TRAP_ENTERPRISESPECIFIC (6)
00242
00243
00244
00245
00246 #define SNMP_ROW_NONEXISTENT 0
00247 #define SNMP_ROW_ACTIVE 1
00248 #define SNMP_ROW_NOTINSERVICE 2
00249 #define SNMP_ROW_NOTREADY 3
00250 #define SNMP_ROW_CREATEANDGO 4
00251 #define SNMP_ROW_CREATEANDWAIT 5
00252 #define SNMP_ROW_DESTROY 6
00253
00254
00255
00256
00257 #define SNMP_STORAGE_NONE 0
00258 #define SNMP_STORAGE_OTHER 1
00259 #define SNMP_STORAGE_VOLATILE 2
00260 #define SNMP_STORAGE_NONVOLATILE 3
00261 #define SNMP_STORAGE_PERMANENT 4
00262 #define SNMP_STORAGE_READONLY 5
00263
00264
00265
00266
00267 #define SNMP_MP_MODEL_SNMPv1 0
00268 #define SNMP_MP_MODEL_SNMPv2c 1
00269 #define SNMP_MP_MODEL_SNMPv2u 2
00270 #define SNMP_MP_MODEL_SNMPv3 3
00271 #define SNMP_MP_MODEL_SNMPv2p 256
00272
00273
00274
00275
00276 #define SNMP_SEC_MODEL_ANY 0
00277 #define SNMP_SEC_MODEL_SNMPv1 1
00278 #define SNMP_SEC_MODEL_SNMPv2c 2
00279 #define SNMP_SEC_MODEL_USM 3
00280 #define SNMP_SEC_MODEL_SNMPv2p 256
00281
00282 #define SNMP_SEC_LEVEL_NOAUTH 1
00283 #define SNMP_SEC_LEVEL_AUTHNOPRIV 2
00284 #define SNMP_SEC_LEVEL_AUTHPRIV 3
00285
00286 #define SNMP_MSG_FLAG_AUTH_BIT 0x01
00287 #define SNMP_MSG_FLAG_PRIV_BIT 0x02
00288 #define SNMP_MSG_FLAG_RPRT_BIT 0x04
00289
00290
00291
00292
00293 #define UCD_MSG_FLAG_RESPONSE_PDU 0x100
00294 #define UCD_MSG_FLAG_EXPECT_RESPONSE 0x200
00295 #define UCD_MSG_FLAG_FORCE_PDU_COPY 0x400
00296 #define UCD_MSG_FLAG_ALWAYS_IN_VIEW 0x800
00297 #define UCD_MSG_FLAG_PDU_TIMEOUT 0x1000
00298 #define UCD_MSG_FLAG_ONE_PASS_ONLY 0x2000
00299 #define UCD_MSG_FLAG_TUNNELED 0x4000
00300
00301
00302
00303
00304 #define SNMP_VIEW_INCLUDED 1
00305 #define SNMP_VIEW_EXCLUDED 2
00306
00307
00308
00309
00310 #define SNMP_OID_INTERNET 1, 3, 6, 1
00311 #define SNMP_OID_ENTERPRISES SNMP_OID_INTERNET, 4, 1
00312 #define SNMP_OID_MIB2 SNMP_OID_INTERNET, 2, 1
00313 #define SNMP_OID_SNMPV2 SNMP_OID_INTERNET, 6
00314 #define SNMP_OID_SNMPMODULES SNMP_OID_SNMPV2, 3
00315
00316
00317
00318
00319 #define SNMPADMINLENGTH 255
00320
00321
00322 char *uptime_string(u_long, char *);
00323 char *uptime_string_n(u_long, char *, size_t);
00324 void xdump(const u_char *, size_t, const char *);
00325 u_char *snmp_parse_var_op(u_char *, oid *, size_t *, u_char *,
00326 size_t *, u_char **, size_t *);
00327 u_char *snmp_build_var_op(u_char *, oid *, size_t *, u_char,
00328 size_t, u_char *, size_t *);
00329
00330
00331 #ifdef USE_REVERSE_ASNENCODING
00332 int snmp_realloc_rbuild_var_op(u_char ** pkt,
00333 size_t * pkt_len,
00334 size_t * offset,
00335 int allow_realloc,
00336 const oid * name,
00337 size_t * name_len,
00338 u_char value_type,
00339 u_char * value,
00340 size_t value_length);
00341 #endif
00342
00343 #ifdef __cplusplus
00344 }
00345 #endif
00346 #endif