View Javadoc
1   // NAME
2   //      $RCSfile: OneGetBulkPdu.java,v $
3   // DESCRIPTION
4   //      [given below in javadoc format]
5   // DELTA
6   //      $Revision: 3.9 $
7   // CREATED
8   //      $Date: 2006/01/17 17:43:53 $
9   // COPYRIGHT
10  //      Westhawk Ltd
11  // TO DO
12  //
13  
14  
15  /*
16   * Copyright (C) 2001 - 2006 by Westhawk Ltd
17   * <a href="www.westhawk.co.uk">www.westhawk.co.uk</a>
18   *
19   * Permission to use, copy, modify, and distribute this software
20   * for any purpose and without fee is hereby granted, provided
21   * that the above copyright notices appear in all copies and that
22   * both the copyright notice and this permission notice appear in
23   * supporting documentation.
24   * This software is provided "as is" without express or implied
25   * warranty.
26   * author <a href="mailto:snmp@westhawk.co.uk">Tim Panton</a>
27   */
28   
29  package uk.co.westhawk.snmp.pdu;
30  
31  /*-
32   * ╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲
33   * SNMP Java Client
34   * ჻჻჻჻჻჻
35   * Copyright 2023 MetricsHub, Westhawk
36   * ჻჻჻჻჻჻
37   * This program is free software: you can redistribute it and/or modify
38   * it under the terms of the GNU Lesser General Public License as
39   * published by the Free Software Foundation, either version 3 of the
40   * License, or (at your option) any later version.
41   *
42   * This program is distributed in the hope that it will be useful,
43   * but WITHOUT ANY WARRANTY; without even the implied warranty of
44   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
45   * GNU General Lesser Public License for more details.
46   *
47   * You should have received a copy of the GNU General Lesser Public
48   * License along with this program.  If not, see
49   * <http://www.gnu.org/licenses/lgpl-3.0.html>.
50   * ╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱
51   */
52  import uk.co.westhawk.snmp.stack.*;
53  import java.util.*;
54  
55  /**
56   * <p>
57   * The OneGetBulkPdu class performs a getBulkRequest and collects 
58   * the response varbinds into a Vector.
59   * </p>
60   *
61   * <p>
62   * If no exception occurred whilst receiving the response, the Object to the 
63   * update() method of the Observer will be an Vector of
64   * varbinds, so they may contains any AsnObject type.
65   * If an exception occurred, that exception will be passed as the Object
66   * to the update() method.
67   * </p>
68   *
69   * <p>
70   * For SNMPv3: The receiver of a request PDU acts as the authoritative engine.
71   * </p>
72   *
73   * @see varbind
74   * @see Vector
75   *
76   * @author <a href="mailto:snmp@westhawk.co.uk">Birgit Arkesteijn</a>
77   * @version $Revision: 3.9 $ $Date: 2006/01/17 17:43:53 $
78   */
79  public class OneGetBulkPdu extends GetBulkPdu {
80      private static final String version_id = "@(#)$Id: OneGetBulkPdu.java,v 3.9 2006/01/17 17:43:53 birgit Exp $ Copyright Westhawk Ltd";
81  
82      /**
83       * The GetBulk request is the only request that will return more
84       * variables than you've sent.
85       */
86      Vector vars;
87  
88      /**
89       * Constructor.
90       *
91       * @param con The context (v2c or v3) of the PDU
92       */
93      public OneGetBulkPdu(SnmpContextBasisFace con) {
94          super(con);
95          vars = new Vector();
96      }
97  
98      /**
99       * Returns a vector with the response varbinds.
100      */
101     public Vector getVarbinds() {
102         return vars;
103     }
104 
105     /**
106      * The value of the request is set. This will be called by
107      * Pdu.fillin().
108      *
109      * @param n     the index of the value
110      * @param a_var the value
111      * @see Pdu#new_value
112      */
113     protected void new_value(int n, varbind a_var) {
114         if (n == 0) {
115             vars = new Vector();
116         }
117         vars.addElement(a_var);
118     }
119 
120     /**
121      * This method notifies all observers.
122      * This will be called by Pdu.fillin().
123      * 
124      * <p>
125      * If no exception occurred whilst receiving the response, the Object to the
126      * update() method of the Observer will be an Vector of
127      * varbinds, so they may contains any AsnObject type.
128      * If an exception occurred, that exception will be passed as the Object
129      * to the update() method.
130      * </p>
131      *
132      * @see Vector
133      */
134     protected void tell_them() {
135         notifyObservers(vars);
136     }
137 
138 }