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 Sentry Software, 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 {
92 private static final String version_id =
93 "@(#)$Id: InformPdu_vec.java,v 3.5 2006/11/29 16:12:50 birgit Exp $ Copyright Westhawk Ltd";
94
95 varbind[] value;
96
97 /**
98 * Constructor.
99 *
100 * @param con The context of the request
101 * @param count The number of OIDs to be get
102 */
103 public InformPdu_vec(SnmpContextBasisFace con, int count)
104 {
105 super(con);
106 value = new varbind[count];
107 }
108
109 /**
110 * The value of the request is set. This will be called by
111 * InformPdu.fillin().
112 *
113 * @param n the index of the value
114 * @param var the value
115 * @see Pdu#new_value
116 */
117 protected void new_value(int n, varbind var)
118 {
119 if (n <value.length)
120 {
121 value[n] = var;
122 }
123 }
124
125 /**
126 * This method notifies all observers.
127 * This will be called by InformPdu.fillin().
128 *
129 * <p>
130 * If no exception occurred whilst receiving the response, the Object to the
131 * update() method of the Observer will be an array of
132 * varbinds, so they may contains any AsnObject type.
133 * If an exception occurred, that exception will be passed as the Object
134 * to the update() method.
135 * </p>
136 */
137 protected void tell_them()
138 {
139 notifyObservers(value);
140 }
141
142 }