Nut/OS  4.10.3
API Reference
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 
00052 
00053 #ifndef SNMP_PORT
00054 
00056 #define SNMP_PORT       161
00057 #endif
00058 
00059 #ifndef SNMP_TRAP_PORT
00060 
00062 #define SNMP_TRAP_PORT  162
00063 #endif
00064 
00065 #ifndef SNMP_MAX_LEN
00066 
00068 #define SNMP_MAX_LEN    500
00069 #endif
00070 
00075 #define SNMP_VERSION_1      0
00076 
00085 #define SNMP_VERSION_2C     1
00086 
00095 #define SNMP_VERSION_3      3
00096 
00097 /*
00098  * PDU types in SNMPv1, SNMPv2c and SNMPv3.
00099  */
00100 #define SNMP_MSG_GET        (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x0)
00101 #define SNMP_MSG_GETNEXT    (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x1)
00102 #define SNMP_MSG_RESPONSE   (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x2)
00103 #define SNMP_MSG_SET        (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x3)
00104 
00105 /*
00106  * PDU types in SNMPv1. 
00107  */
00108 #define SNMP_MSG_TRAP       (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x4)
00109 
00110 /*
00111  * PDU types in SNMPv2c and SNMPv3 
00112  */
00113 #define SNMP_MSG_GETBULK    (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x5)
00114 #define SNMP_MSG_INFORM     (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x6)
00115 #define SNMP_MSG_TRAP2      (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x7)
00116 
00117 /*
00118  * PDU types in SNMPv3 
00119  */
00120 #define SNMP_MSG_REPORT     (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x8)
00121 
00122 /*
00123  * Exception values for SNMPv2c and SNMPv3 
00124  */
00125 #define SNMP_NOSUCHOBJECT    (ASN_CONTEXT | ASN_PRIMITIVE | 0x0)
00126 #define SNMP_NOSUCHINSTANCE  (ASN_CONTEXT | ASN_PRIMITIVE | 0x1)
00127 #define SNMP_ENDOFMIBVIEW    (ASN_CONTEXT | ASN_PRIMITIVE | 0x2)
00128 
00129 /*
00130  * Error codes in SNMPv1, SNMPv2c and SNMPv3 PDUs.
00131  */
00132 #define SNMP_ERR_NOERROR                0
00133 #define SNMP_ERR_TOOBIG                 1
00134 #define SNMP_ERR_NOSUCHNAME             2
00135 #define SNMP_ERR_BADVALUE               3
00136 #define SNMP_ERR_READONLY               4
00137 #define SNMP_ERR_GENERR                 5
00138 
00139 /*
00140  * Error codes in SNMPv2c and SNMPv3 PDUs.
00141  */
00142 #define SNMP_ERR_NOACCESS               6
00143 #define SNMP_ERR_WRONGTYPE              7
00144 #define SNMP_ERR_WRONGLENGTH            8
00145 #define SNMP_ERR_WRONGENCODING          9
00146 #define SNMP_ERR_WRONGVALUE             10
00147 #define SNMP_ERR_NOCREATION             11
00148 #define SNMP_ERR_INCONSISTENTVALUE      12
00149 #define SNMP_ERR_RESOURCEUNAVAILABLE    13
00150 #define SNMP_ERR_COMMITFAILED           14
00151 #define SNMP_ERR_UNDOFAILED             15
00152 #define SNMP_ERR_AUTHORIZATIONERROR     16
00153 #define SNMP_ERR_NOTWRITABLE            17
00154 #define SNMP_ERR_INCONSISTENTNAME       18
00155 
00156 /*
00157  * Values of the generic-trap field in trap PDUs.
00158  */
00159 #define SNMP_TRAP_COLDSTART             0
00160 #define SNMP_TRAP_WARMSTART             1
00161 #define SNMP_TRAP_LINKDOWN              2
00162 #define SNMP_TRAP_LINKUP                3
00163 #define SNMP_TRAP_AUTHFAIL              4
00164 #define SNMP_TRAP_EGPNEIGHBORLOSS       5
00165 #define SNMP_TRAP_ENTERPRISESPECIFIC    6
00166 
00167 /*
00168  * Basic OID values 
00169  */
00170 #define SNMP_OID_INTERNET       1, 3, 6, 1
00171 #define SNMP_OID_ENTERPRISES    SNMP_OID_INTERNET, 4, 1
00172 #define SNMP_OID_MIB2           SNMP_OID_INTERNET, 2, 1
00173 #define SNMP_OID_SNMPV2         SNMP_OID_INTERNET, 6
00174 #define SNMP_OID_SNMPMODULES    SNMP_OID_SNMPV2, 3
00175 
00176 
00177 
00178 #define SNMP_PARSE_ERROR        -1
00179 #define SNMP_BUILD_ERROR        -2
00180 
00182 #define MAX_SID_LEN     32
00183 
00184 #define MAX_NAME_LEN    128
00185 
00186 #define SNMP_ACT_RESERVE1    0
00187 #define SNMP_ACT_RESERVE2    1
00188 #define SNMP_ACT_COMMIT      2
00189 #define SNMP_ACT_ACTION      3
00190 #define SNMP_ACT_FREE        4
00191 
00194 extern CONST uint8_t *SnmpVarParse(CONST uint8_t *, size_t *, OID *, size_t *, uint8_t *, uint8_t **, size_t *);
00195 extern uint8_t *SnmpVarBuild(uint8_t *, size_t *, CONST OID *, size_t, uint8_t , CONST uint8_t *, size_t);
00196 
00197 #endif