View Javadoc
1   // NAME
2   //      $RCSfile: SnmpConstants.java,v $
3   // DESCRIPTION
4   //      [given below in javadoc format]
5   // DELTA
6   //      $Revision: 3.10 $
7   // CREATED
8   //      $Date: 2006/03/23 14:54:10 $
9   // COPYRIGHT
10  //      Westhawk Ltd
11  // TO DO
12  //
13  package uk.co.westhawk.snmp.stack;
14  
15  /*-
16   * ╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲
17   * SNMP Java Client
18   * ჻჻჻჻჻჻
19   * Copyright 2023 MetricsHub, Westhawk
20   * ჻჻჻჻჻჻
21   * This program is free software: you can redistribute it and/or modify
22   * it under the terms of the GNU Lesser General Public License as
23   * published by the Free Software Foundation, either version 3 of the
24   * License, or (at your option) any later version.
25   *
26   * This program is distributed in the hope that it will be useful,
27   * but WITHOUT ANY WARRANTY; without even the implied warranty of
28   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
29   * GNU General Lesser Public License for more details.
30   *
31   * You should have received a copy of the GNU General Lesser Public
32   * License along with this program.  If not, see
33   * <http://www.gnu.org/licenses/lgpl-3.0.html>.
34   * ╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱
35   */
36  
37  /*
38   * Copyright (C) 2001 - 2006 by Westhawk Ltd
39   * <a href="www.westhawk.co.uk">www.westhawk.co.uk</a>
40   *
41   * Permission to use, copy, modify, and distribute this software
42   * for any purpose and without fee is hereby granted, provided
43   * that the above copyright notices appear in all copies and that
44   * both the copyright notice and this permission notice appear in
45   * supporting documentation.
46   * This software is provided "as is" without express or implied
47   * warranty.
48   * author <a href="mailto:snmp@westhawk.co.uk">Tim Panton</a>
49   */
50  
51  /**
52   * This interface contains most of the constants used in the stack.
53   *
54   * @author <a href="mailto:snmp@westhawk.co.uk">Birgit Arkesteijn</a>
55   * @version $Revision: 3.10 $ $Date: 2006/03/23 14:54:10 $
56   */
57  public interface SnmpConstants {
58      static final String version_id = "@(#)$Id: SnmpConstants.java,v 3.10 2006/03/23 14:54:10 birgit Exp $ Copyright Westhawk Ltd";
59  
60      public static final byte ASN_BOOLEAN = (byte) (0x01);
61      public static final byte ASN_INTEGER = (byte) (0x02);
62      public static final byte ASN_BIT_STR = (byte) (0x03);
63      public static final byte ASN_OCTET_STR = (byte) (0x04);
64      public static final byte ASN_NULL = (byte) (0x05);
65      public static final byte ASN_OBJECT_ID = (byte) (0x06);
66      public static final byte ASN_SEQUENCE = (byte) (0x10);
67      public static final byte ASN_SET = (byte) (0x11);
68  
69      public static final byte ASN_UNIVERSAL = (byte) (0x00);
70      public static final byte ASN_APPLICATION = (byte) (0x40);
71      public static final byte ASN_CONTEXT = (byte) (0x80);
72      public static final byte ASN_PRIVATE = (byte) (0xC0);
73  
74      public static final byte ASN_PRIMITIVE = (byte) (0x00);
75      public static final byte ASN_CONSTRUCTOR = (byte) (0x20);
76  
77      public static final byte ASN_LONG_LEN = (byte) (0x80);
78      public static final byte ASN_EXTENSION_ID = (byte) (0x1F);
79      public static final byte ASN_BIT8 = (byte) (0x80);
80  
81      public static final byte INTEGER = (byte) ASN_INTEGER;
82      public static final byte STRING = (byte) ASN_OCTET_STR;
83      public static final byte OBJID = (byte) ASN_OBJECT_ID;
84      public static final byte NULLOBJ = (byte) ASN_NULL;
85  
86      /** IPv4 address only */
87      // RFC 2578:
88      public static final byte IPADDRESS = (byte) (ASN_APPLICATION | 0);
89      public static final byte COUNTER = (byte) (ASN_APPLICATION | 1);
90      public static final byte GAUGE = (byte) (ASN_APPLICATION | 2);
91      public static final byte TIMETICKS = (byte) (ASN_APPLICATION | 3);
92      public static final byte OPAQUE = (byte) (ASN_APPLICATION | 4);
93      public static final byte COUNTER64 = (byte) (ASN_APPLICATION | 6);
94  
95      /**
96       * for OSI NSAP addresses (see
97       * <a href="http://www.ietf.org/rfc/rfc1442.txt">RFC 1442</a>,
98       * is obsoleted by
99       * <a href="http://www.ietf.org/rfc/rfc2578.txt">RFC 2578</a>).
100      */
101     public static final byte NSAP_ADDRESS = (byte) (ASN_APPLICATION | 5);
102 
103     /**
104      * an unsigned 32-bit quantity (see
105      * <a href="http://www.ietf.org/rfc/rfc1902.txt">RFC 1902</a>,
106      * is obsoleted by
107      * <a href="http://www.ietf.org/rfc/rfc2578.txt">SNMPv2-SMI</a>).
108      *
109      * <p>
110      * Was called UINTEGER32. Renamed it in version 4_13.
111      * </p>
112      */
113     public static final byte OBSOLETED_RFC1442_UINTEGER32 = (byte) (ASN_APPLICATION | 7);
114 
115     /**
116      * an unsigned 32-bit quantity. This equals GAUGE. (see
117      * <a href="http://www.ietf.org/rfc/rfc2578.txt">SNMPv2-SMI</a>).
118      */
119     public static final byte SMI_V2_UINTEGER32 = GAUGE;
120 
121     /**
122      * Value for the <code>GenericTrap</code> field in SNMPv1 Trap.
123      */
124     public static final byte SNMP_TRAP_COLDSTART = (byte) (0x0);
125     /**
126      * Value for the <code>GenericTrap</code> field in SNMPv1 Trap.
127      */
128     public static final byte SNMP_TRAP_WARMSTART = (byte) (0x1);
129     /**
130      * Value for the <code>GenericTrap</code> field in SNMPv1 Trap.
131      */
132     public static final byte SNMP_TRAP_LINKDOWN = (byte) (0x2);
133     /**
134      * Value for the <code>GenericTrap</code> field in SNMPv1 Trap.
135      */
136     public static final byte SNMP_TRAP_LINKUP = (byte) (0x3);
137     /**
138      * Value for the <code>GenericTrap</code> field in SNMPv1 Trap.
139      */
140     public static final byte SNMP_TRAP_AUTHFAIL = (byte) (0x4);
141     /**
142      * Value for the <code>GenericTrap</code> field in SNMPv1 Trap.
143      */
144     public static final byte SNMP_TRAP_EGPNEIGHBORLOSS = (byte) (0x5);
145     /**
146      * Value for the <code>GenericTrap</code> field in SNMPv1 Trap.
147      */
148     public static final byte SNMP_TRAP_ENTERPRISESPECIFIC = (byte) (0x6);
149 
150     /**
151      * Indicated the agent does not implement the object referred to by
152      * this object identifier.
153      * Used in varbind list in response to SNMPv2c, SNMPv3 getRequest.
154      */
155     public static final byte SNMP_VAR_NOSUCHOBJECT = (byte) (ASN_CONTEXT | ASN_PRIMITIVE | 0x0);
156     /**
157      * Indicated that this object does not exists for this operation.
158      * Used in varbind list in response to SNMPv2c, SNMPv3 getRequest.
159      */
160     public static final byte SNMP_VAR_NOSUCHINSTANCE = (byte) (ASN_CONTEXT | ASN_PRIMITIVE | 0x1);
161     /**
162      * Indicated an attempt to reference an object identifier that is
163      * beyond the end of the MIB at the agent.
164      * Used in varbind list in response to SNMPv2c, SNMPv3 getRequest or
165      * getBulkRequest.
166      */
167     public static final byte SNMP_VAR_ENDOFMIBVIEW = (byte) (ASN_CONTEXT | ASN_PRIMITIVE | 0x2);
168 
169     /**
170      * No error in the PDU response.
171      * Used in SNMPv1, SNMPv2c, SNMPv3.
172      */
173     public static final byte SNMP_ERR_NOERROR = (byte) (0x00);
174     /**
175      * The size of the generated response PDU would exceed a local
176      * limitation.
177      * Used in SNMPv1, SNMPv2c, SNMPv3.
178      */
179     public static final byte SNMP_ERR_TOOBIG = (byte) (0x01);
180     /**
181      * The object is not available or the object's name does not exactly
182      * match.
183      * Only used in SNMPv1.
184      */
185     public static final byte SNMP_ERR_NOSUCHNAME = (byte) (0x02);
186     /**
187      * The object does not manifest a type, length, and value
188      * that is consistent with that required for the variable.
189      * Only used in response to SNMPv1 SetRequest.
190      */
191     public static final byte SNMP_ERR_BADVALUE = (byte) (0x03);
192     /**
193      * The object can not be set, only read.
194      * Only used in response to SNMPv1 SetRequest.
195      */
196     public static final byte SNMP_ERR_READONLY = (byte) (0x04);
197     /**
198      * The value of an object cannot be retrieved for reasons
199      * not covered by any of other errors.
200      * Used in SNMPv1, SNMPv2c, SNMPv3.
201      */
202     public static final byte SNMP_ERR_GENERR = (byte) (0x05);
203 
204     /**
205      * The variable binding's name specifies an existing or
206      * non-existent variable to which this request is/would be denied
207      * access because it is/would not be in the appropriate MIB view.
208      * Used in response to SNMPv2c, SNMPv3 SetRequest.
209      */
210     public static final byte SNMP_ERR_NOACCESS = (byte) (0x06);
211     /**
212      * The variable binding's value field specifies a type which is
213      * inconsistent with that required for all variables which share the
214      * same OBJECT IDENTIFIER prefix as the variable binding's name.
215      * Used in response to SNMPv2c, SNMPv3 SetRequest.
216      */
217     public static final byte SNMP_ERR_WRONGTYPE = (byte) (0x07);
218     /**
219      * The variable binding's value field specifies a length which is
220      * inconsistent with that required for all variables which share the
221      * same OBJECT IDENTIFIER prefix as the variable binding's name.
222      * Used in response to SNMPv2c, SNMPv3 SetRequest.
223      */
224     public static final byte SNMP_ERR_WRONGLENGTH = (byte) (0x08);
225     /**
226      * Otherwise, if the variable binding's value field contains an ASN.1
227      * encoding which is inconsistent with that field's ASN.1 tag.
228      * Used in response to SNMPv2c, SNMPv3 SetRequest.
229      */
230     public static final byte SNMP_ERR_WRONGENCODING = (byte) (0x09);
231     /**
232      * The variable binding's value field specifies a value which could
233      * under no circumstances be assigned to the variable.
234      * Used in response to SNMPv2c, SNMPv3 SetRequest.
235      */
236     public static final byte SNMP_ERR_WRONGVALUE = (byte) (0x0A);
237     /**
238      * The variable binding's name specifies a variable which does not
239      * exist and could not ever be created (even though some variables
240      * sharing the same OBJECT IDENTIFIER prefix might under some
241      * circumstances be able to be created).
242      * Used in response to SNMPv2c, SNMPv3 SetRequest.
243      */
244     public static final byte SNMP_ERR_NOCREATION = (byte) (0x0B);
245     /**
246      * The variable binding's value field specifies a value that could
247      * under other circumstances be held by the variable, but is presently
248      * inconsistent or otherwise unable to be assigned to the variable.
249      * Used in response to SNMPv2c, SNMPv3 SetRequest.
250      */
251     public static final byte SNMP_ERR_INCONSISTENTVALUE = (byte) (0x0C);
252     /**
253      * The assignment of the value specified by the variable binding's
254      * value field to the specified variable requires the allocation of a
255      * resource which is presently unavailable.
256      * Used in response to SNMPv2c, SNMPv3 SetRequest.
257      */
258     public static final byte SNMP_ERR_RESOURCEUNAVAILABLE = (byte) (0x0D);
259     /**
260      * Any of the assignments failed and all other assignments were
261      * undone.
262      * Used in response to SNMPv2c, SNMPv3 SetRequest.
263      */
264     public static final byte SNMP_ERR_COMMITFAILED = (byte) (0x0E);
265     /**
266      * Any of the assignments failed and all other assignments were
267      * undone, but is was not possible to undo all the assignments.
268      * Used in response to SNMPv2c, SNMPv3 SetRequest.
269      */
270     public static final byte SNMP_ERR_UNDOFAILED = (byte) (0x0F);
271     /**
272      * Users is has no access privileges.
273      * Used in SNMPv2c, SNMPv3.
274      */
275     public static final byte SNMP_ERR_AUTHORIZATIONERR = (byte) (0x10);
276     /**
277      * <ul>
278      * <li>
279      * There are no variables which share the same OBJECT IDENTIFIER
280      * prefix as the variable binding's name, and which are able to be
281      * created or modified no matter what new value is specified.
282      * </li>
283      * <li>
284      * The variable binding's name specifies a variable which exists but
285      * can not be modified no matter what new value is specified.
286      * </li>
287      * </ul>
288      * Used in response to SNMPv2c, SNMPv3 SetRequest.
289      */
290     public static final byte SNMP_ERR_NOTWRITABLE = (byte) (0x11);
291     /**
292      * The variable binding's name specifies a variable which does not
293      * exist but can not be created under the present circumstances (even
294      * though it could be created under other circumstances).
295      * Used in response to SNMPv2c, SNMPv3 SetRequest.
296      */
297     public static final byte SNMP_ERR_INCONSISTENTNAME = (byte) (0x12);
298 
299     /**
300      * A general decoding exception occured whilst decoding the response.
301      */
302     public static final byte SNMP_ERR_DECODING_EXC = (byte) (0x13);
303     /**
304      * A specific decoding exception occured whilst decoding the response.
305      * The response PDU being decoded has a sub length wrong (not overall
306      * length necessarily), so the asn sequence can't get created.
307      */
308     public static final byte SNMP_ERR_DECODINGASN_EXC = (byte) (0x14);
309     /**
310      * A specific decoding exception occured whilst decoding the response.
311      * The received overall response PDU is shorter than the PDU header
312      * says it is.
313      */
314     public static final byte SNMP_ERR_DECODINGPKTLNGTH_EXC = (byte) (0x15);
315 
316     /**
317      * The version number for SNMPv1.
318      */
319     public static final byte SNMP_VERSION_1 = (byte) (0x0);
320     /**
321      * The version number for SNMPv2c.
322      */
323     public static final byte SNMP_VERSION_2c = (byte) (0x1);
324     /**
325      * The version number for SNMPv2u.
326      */
327     // public static final byte SNMP_VERSION_2u =(byte)(0x2);
328     /**
329      * The version number for SNMPv3.
330      */
331     public static final byte SNMP_VERSION_3 = (byte) (0x3);
332 
333     /**
334      * The GetRequest PDU type.
335      */
336     static final byte GET_REQ_MSG = (byte) (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x0);
337     /**
338      * The GetNextRequest PDU type.
339      */
340     static final byte GETNEXT_REQ_MSG = (byte) (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x1);
341     /**
342      * The Response PDU type.
343      */
344     static final byte GET_RSP_MSG = (byte) (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x2);
345     /**
346      * The SetRequest PDU type.
347      */
348     static final byte SET_REQ_MSG = (byte) (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x3);
349     /**
350      * The SNMPv1 Trap PDU type.
351      */
352     static final byte TRP_REQ_MSG = (byte) (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x4);
353 
354     /**
355      * The GetBulkRequest PDU type.
356      */
357     static final byte GETBULK_REQ_MSG = (byte) (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x5);
358     /**
359      * The InformRequest PDU type.
360      */
361     static final byte INFORM_REQ_MSG = (byte) (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x6);
362     /**
363      * The SNMPv2 (and SNMPv3) Trap PDU type.
364      */
365     static final byte TRPV2_REQ_MSG = (byte) (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x7);
366     /**
367      * The GetReport PDU type.
368      */
369     static final byte GET_RPRT_MSG = (byte) (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x8);
370 
371     static final byte CONS_SEQ = (byte) (ASN_SEQUENCE | ASN_CONSTRUCTOR);
372 
373 }