View Javadoc
1   // NAME
2   //      $RCSfile: ReportPdu.java,v $
3   // DESCRIPTION
4   //      [given below in javadoc format]
5   // DELTA
6   //      $Revision: 3.3 $
7   // CREATED
8   //      $Date: 2006/01/17 17:59:34 $
9   // COPYRIGHT
10  //      Westhawk Ltd
11  // TO DO
12  //
13  
14  /*
15   * Copyright (C) 2005 - 2006 by Westhawk Ltd
16   * <a href="www.westhawk.co.uk">www.westhawk.co.uk</a>
17   *
18   * Permission to use, copy, modify, and distribute this software
19   * for any purpose and without fee is hereby granted, provided
20   * that the above copyright notices appear in all copies and that
21   * both the copyright notice and this permission notice appear in
22   * supporting documentation.
23   * This software is provided "as is" without express or implied
24   * warranty.
25   * author <a href="mailto:snmp@westhawk.co.uk">Tim Panton</a>
26   */
27  
28  package uk.co.westhawk.snmp.stack;
29  
30  /*-
31   * ╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲
32   * SNMP Java Client
33   * ჻჻჻჻჻჻
34   * Copyright 2023 MetricsHub, Westhawk
35   * ჻჻჻჻჻჻
36   * This program is free software: you can redistribute it and/or modify
37   * it under the terms of the GNU Lesser General Public License as
38   * published by the Free Software Foundation, either version 3 of the
39   * License, or (at your option) any later version.
40   *
41   * This program is distributed in the hope that it will be useful,
42   * but WITHOUT ANY WARRANTY; without even the implied warranty of
43   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
44   * GNU General Lesser Public License for more details.
45   *
46   * You should have received a copy of the GNU General Lesser Public
47   * License along with this program.  If not, see
48   * <http://www.gnu.org/licenses/lgpl-3.0.html>.
49   * ╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱
50   */
51  
52  /**
53   * This class represents the ASN SNMP Report PDU object.
54   * This class is used when requests are received that try to discover our
55   * SNMPv3 timeliness. This will only be the case then the stack acts as
56   * authoritative engine.
57   *
58   * <p>
59   * Reports are not used (as far as we know) in normal
60   * manager - agent (authoritative - non authoritative) communication.
61   * Hence the reason why this stack does not support them in any other
62   * way.
63   * </p>
64   *
65   * @since 4_14
66   * @author <a href="mailto:snmp@westhawk.co.uk">Birgit Arkesteijn</a>
67   * @version $Revision: 3.3 $ $Date: 2006/01/17 17:59:34 $
68   */
69  public class ReportPdu extends Pdu {
70      private static final String version_id = "@(#)$Id: ReportPdu.java,v 3.3 2006/01/17 17:59:34 birgit Exp $ Copyright Westhawk Ltd";
71  
72      /**
73       * Constructor.
74       * The requestPdu is used to copy the necessary IDs to this PDU.
75       *
76       * @param con        The context of the PDU
77       * @param requestPdu The original Request PDU
78       */
79      public ReportPdu(SnmpContextBasisFace con, Pdu requestPdu) {
80          super(con);
81          setMsgType(AsnObject.GET_RPRT_MSG);
82          req_id = requestPdu.req_id;
83          snmpv3MsgId = requestPdu.snmpv3MsgId;
84      }
85  
86      /**
87       * Sets the error status of this PDU. This indicates that an exception
88       * has occurred while processing the original request.
89       *
90       * @see SnmpConstants#SNMP_ERR_NOERROR
91       * @see SnmpConstants#SNMP_ERR_TOOBIG
92       * @see SnmpConstants#SNMP_ERR_NOSUCHNAME
93       * @see SnmpConstants#SNMP_ERR_BADVALUE
94       * @see SnmpConstants#SNMP_ERR_READONLY
95       * @see SnmpConstants#SNMP_ERR_GENERR
96       * @see SnmpConstants#SNMP_ERR_NOACCESS
97       * @see SnmpConstants#SNMP_ERR_WRONGTYPE
98       * @see SnmpConstants#SNMP_ERR_WRONGLENGTH
99       * @see SnmpConstants#SNMP_ERR_WRONGENCODING
100      * @see SnmpConstants#SNMP_ERR_WRONGVALUE
101      * @see SnmpConstants#SNMP_ERR_NOCREATION
102      * @see SnmpConstants#SNMP_ERR_INCONSISTENTVALUE
103      * @see SnmpConstants#SNMP_ERR_RESOURCEUNAVAILABLE
104      * @see SnmpConstants#SNMP_ERR_COMMITFAILED
105      * @see SnmpConstants#SNMP_ERR_UNDOFAILED
106      * @see SnmpConstants#SNMP_ERR_AUTHORIZATIONERR
107      * @see SnmpConstants#SNMP_ERR_NOTWRITABLE
108      * @see SnmpConstants#SNMP_ERR_INCONSISTENTNAME
109      */
110     public void getErrorStatus(int errorStatus) {
111         errstat = errorStatus;
112     }
113 
114     /**
115      * Sets the error index of this PDU. When the error status is not
116      * SNMP_ERR_NOERROR, it indicates the index of the variable in the
117      * varbind list that caused the exception.
118      */
119     public void getErrorIndex(int errorIndex) {
120         errind = errorIndex;
121     }
122 
123     /**
124      * The Report PDU does not get a response back. So it should be sent once.
125      */
126     void transmit() {
127         transmit(false);
128     }
129 
130     /**
131      * Returns the string representation of this object.
132      *
133      * @return The string of the PDU
134      */
135     public String toString() {
136         return super.toString(true);
137     }
138 
139     /**
140      * Has no meaning, since there is not response.
141      */
142     protected void new_value(int n, varbind res) {
143     }
144 
145     /**
146      * Has no meaning, since there is not response.
147      */
148     protected void tell_them() {
149     }
150 
151     /**
152      * Returns that this type of PDU is <em>not</em> expecting a response.
153      * This method is used in AbstractSnmpContext to help determine whether
154      * or not to start a thread that listens for a response when sending this
155      * PDU.
156      * The default is <em>false</em>.
157      *
158      * @return true if a response is expected, false if not.
159      */
160     protected boolean isExpectingResponse() {
161         return false;
162     }
163 
164 }