View Javadoc
1   // NAME
2   //      $RCSfile: InformPdu_vec.java,v $
3   // DESCRIPTION
4   //      [given below in javadoc format]
5   // DELTA
6   //      $Revision: 3.5 $
7   // CREATED
8   //      $Date: 2006/11/29 16:12:50 $
9   // COPYRIGHT
10  //      Westhawk Ltd
11  // TO DO
12  //
13  
14  /*
15   * Copyright (C) 2002 - 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.pdu;
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  import uk.co.westhawk.snmp.stack.*;
52  import java.lang.*;
53  
54  /**
55   * <p>
56   * The InformPdu_vec class will inform a manager about a number of 
57   * objects (OIDs), based on the Inform request.
58   * </p>
59   *
60   * <p>
61   * Specify with <code>addOid()</code> the OIDs that should be informed with this
62   * InformPdu request. No more than <code>count</code> (see constructor) 
63   * should be added.
64   * Add an Observer to the InformPdu with <code>addObserver()</code>, and 
65   * send the InformPdu with <code>send()</code>.
66   * </p>
67   *
68   * <p>
69   * Note, this PDU should be sent to port 162 (the default trap port) by
70   * default. You will have to create a SnmpContext with the
71   * ListeningContextFace.DEFAULT_TRAP_PORT as parameter!
72   * </p>
73   *
74   * <p>
75   * Inform Requests
76   * are sent between managers. It is a kind of 'acknowlegded' trap since
77   * the receiving end should send a Response Pdu as reply.
78   * The varbind list has the same elements as the TrapPduv2.
79   * </p>
80   *
81   * @see Pdu#addOid
82   * @see Pdu#send
83   * @see varbind
84   * @see ListeningContextFace#DEFAULT_TRAP_PORT
85   * @since 4_12
86   *
87   * @author <a href="mailto:snmp@westhawk.co.uk">Birgit Arkesteijn</a>
88   * @version $Revision: 3.5 $ $Date: 2006/11/29 16:12:50 $
89   */
90  public class InformPdu_vec extends InformPdu {
91      private static final String version_id = "@(#)$Id: InformPdu_vec.java,v 3.5 2006/11/29 16:12:50 birgit Exp $ Copyright Westhawk Ltd";
92  
93      varbind[] value;
94  
95      /**
96       * Constructor.
97       *
98       * @param con   The context of the request
99       * @param count The number of OIDs to be get
100      */
101     public InformPdu_vec(SnmpContextBasisFace con, int count) {
102         super(con);
103         value = new varbind[count];
104     }
105 
106     /**
107      * The value of the request is set. This will be called by
108      * InformPdu.fillin().
109      *
110      * @param n   the index of the value
111      * @param var the value
112      * @see Pdu#new_value
113      */
114     protected void new_value(int n, varbind var) {
115         if (n < value.length) {
116             value[n] = var;
117         }
118     }
119 
120     /**
121      * This method notifies all observers.
122      * This will be called by InformPdu.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 array 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     protected void tell_them() {
133         notifyObservers(value);
134     }
135 
136 }