snmp.h

Go to the documentation of this file.
00001 #ifndef PRO_SNMP_H
00002 #define PRO_SNMP_H
00003 
00004 /*
00005  * Copyright 1998-2007 by egnite Software GmbH
00006  * Copyright 1988, 1989, 1991, 1992 by Carnegie Mellon University
00007  *
00008  * Redistribution and use in source and binary forms, with or without
00009  * modification, are permitted provided that the following conditions
00010  * are met:
00011  *
00012  * 1. Redistributions of source code must retain the above copyright
00013  *    notice, this list of conditions and the following disclaimer.
00014  * 2. Redistributions in binary form must reproduce the above copyright
00015  *    notice, this list of conditions and the following disclaimer in the
00016  *    documentation and/or other materials provided with the distribution.
00017  * 3. Neither the name of the copyright holders nor the names of
00018  *    contributors may be used to endorse or promote products derived
00019  *    from this software without specific prior written permission.
00020  *
00021  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00022  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00023  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00024  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00025  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00026  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00027  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
00028  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
00029  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00030  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
00031  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00032  * SUCH DAMAGE.
00033  *
00034  * For additional information see http://www.ethernut.de/
00035  */
00036 
00046 #include <pro/asn1.h>
00047 
00048 #ifndef SNMP_PORT
00049 
00051 #define SNMP_PORT       161
00052 #endif
00053 
00054 #ifndef SNMP_TRAP_PORT
00055 
00057 #define SNMP_TRAP_PORT  162
00058 #endif
00059 
00060 #ifndef SNMP_MAX_LEN
00061 
00063 #define SNMP_MAX_LEN    500
00064 #endif
00065 
00070 #define SNMP_VERSION_1      0
00071 
00080 #define SNMP_VERSION_2C     1
00081 
00090 #define SNMP_VERSION_3      3
00091 
00092 /*
00093  * PDU types in SNMPv1, SNMPv2c and SNMPv3.
00094  */
00095 #define SNMP_MSG_GET        (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x0)
00096 #define SNMP_MSG_GETNEXT    (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x1)
00097 #define SNMP_MSG_RESPONSE   (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x2)
00098 #define SNMP_MSG_SET        (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x3)
00099 
00100 /*
00101  * PDU types in SNMPv1. 
00102  */
00103 #define SNMP_MSG_TRAP       (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x4)
00104 
00105 /*
00106  * PDU types in SNMPv2c and SNMPv3 
00107  */
00108 #define SNMP_MSG_GETBULK    (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x5)
00109 #define SNMP_MSG_INFORM     (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x6)
00110 #define SNMP_MSG_TRAP2      (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x7)
00111 
00112 /*
00113  * PDU types in SNMPv3 
00114  */
00115 #define SNMP_MSG_REPORT     (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x8)
00116 
00117 /*
00118  * Exception values for SNMPv2c and SNMPv3 
00119  */
00120 #define SNMP_NOSUCHOBJECT    (ASN_CONTEXT | ASN_PRIMITIVE | 0x0)
00121 #define SNMP_NOSUCHINSTANCE  (ASN_CONTEXT | ASN_PRIMITIVE | 0x1)
00122 #define SNMP_ENDOFMIBVIEW    (ASN_CONTEXT | ASN_PRIMITIVE | 0x2)
00123 
00124 /*
00125  * Error codes in SNMPv1, SNMPv2c and SNMPv3 PDUs.
00126  */
00127 #define SNMP_ERR_NOERROR            0
00128 #define SNMP_ERR_TOOBIG             1
00129 #define SNMP_ERR_NOSUCHNAME         2
00130 #define SNMP_ERR_BADVALUE           3
00131 #define SNMP_ERR_READONLY           4
00132 #define SNMP_ERR_GENERR             5
00133 
00134 /*
00135  * Error codes in SNMPv2c and SNMPv3 PDUs.
00136  */
00137 #define SNMP_ERR_NOACCESS               6
00138 #define SNMP_ERR_WRONGTYPE              7
00139 #define SNMP_ERR_WRONGLENGTH            8
00140 #define SNMP_ERR_WRONGENCODING          9
00141 #define SNMP_ERR_WRONGVALUE             10
00142 #define SNMP_ERR_NOCREATION             11
00143 #define SNMP_ERR_INCONSISTENTVALUE      12
00144 #define SNMP_ERR_RESOURCEUNAVAILABLE    13
00145 #define SNMP_ERR_COMMITFAILED           14
00146 #define SNMP_ERR_UNDOFAILED             15
00147 #define SNMP_ERR_AUTHORIZATIONERROR     16
00148 #define SNMP_ERR_NOTWRITABLE            17
00149 #define SNMP_ERR_INCONSISTENTNAME   18
00150 
00151 /*
00152  * Values of the generic-trap field in trap PDUs.
00153  */
00154 #define SNMP_TRAP_COLDSTART     0
00155 #define SNMP_TRAP_WARMSTART     1
00156 #define SNMP_TRAP_LINKDOWN      2
00157 #define SNMP_TRAP_LINKUP        3
00158 #define SNMP_TRAP_AUTHFAIL      4
00159 #define SNMP_TRAP_EGPNEIGHBORLOSS   5
00160 #define SNMP_TRAP_ENTERPRISESPECIFIC    6
00161 
00162 /*
00163  * Basic OID values 
00164  */
00165 #define SNMP_OID_INTERNET       1, 3, 6, 1
00166 #define SNMP_OID_ENTERPRISES    SNMP_OID_INTERNET, 4, 1
00167 #define SNMP_OID_MIB2           SNMP_OID_INTERNET, 2, 1
00168 #define SNMP_OID_SNMPV2         SNMP_OID_INTERNET, 6
00169 #define SNMP_OID_SNMPMODULES    SNMP_OID_SNMPV2, 3
00170 
00171 
00172 
00173 #define SNMP_PARSE_ERROR    -1
00174 #define SNMP_BUILD_ERROR    -2
00175 
00177 #define MAX_SID_LEN 32
00178 
00179 #define MAX_NAME_LEN    128
00180 
00181 #define SNMP_ACT_RESERVE1    0
00182 #define SNMP_ACT_RESERVE2    1
00183 #define SNMP_ACT_COMMIT      2
00184 #define SNMP_ACT_ACTION      3
00185 #define SNMP_ACT_FREE        4
00186 
00187 extern CONST uint8_t *SnmpVarParse(CONST uint8_t *, size_t *, OID *, size_t *, uint8_t *, uint8_t **, size_t *);
00188 extern uint8_t *SnmpVarBuild(uint8_t *, size_t *, CONST OID *, size_t, uint8_t , CONST uint8_t *, size_t);
00189 
00190 #endif

© 2000-2007 by egnite Software GmbH - visit http://www.ethernut.de/