1 // NAME
2 // $RCSfile: AsnPduSequence.java,v $
3 // DESCRIPTION
4 // [given below in javadoc format]
5 // DELTA
6 // $Revision: 3.10 $
7 // CREATED
8 // $Date: 2006/01/17 17:43:54 $
9 // COPYRIGHT
10 // Westhawk Ltd
11 // TO DO
12 //
13
14 /*
15 * Copyright (C) 1995, 1996 by West Consulting BV
16 *
17 * Permission to use, copy, modify, and distribute this software
18 * for any purpose and without fee is hereby granted, provided
19 * that the above copyright notices appear in all copies and that
20 * both the copyright notice and this permission notice appear in
21 * supporting documentation.
22 * This software is provided "as is" without express or implied
23 * warranty.
24 * author <a href="mailto:snmp@westhawk.co.uk">Tim Panton</a>
25 * original version by hargrave@dellgate.us.dell.com (Jordan Hargrave)
26 */
27
28 /*
29 * Copyright (C) 1996 - 2006 by Westhawk Ltd
30 * <a href="www.westhawk.co.uk">www.westhawk.co.uk</a>
31 *
32 * Permission to use, copy, modify, and distribute this software
33 * for any purpose and without fee is hereby granted, provided
34 * that the above copyright notices appear in all copies and that
35 * both the copyright notice and this permission notice appear in
36 * supporting documentation.
37 * This software is provided "as is" without express or implied
38 * warranty.
39 * author <a href="mailto:snmp@westhawk.co.uk">Tim Panton</a>
40 */
41
42 package uk.co.westhawk.snmp.stack;
43
44 /*-
45 * ╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲
46 * SNMP Java Client
47 * ჻჻჻჻჻჻
48 * Copyright 2023 MetricsHub, Westhawk
49 * ჻჻჻჻჻჻
50 * This program is free software: you can redistribute it and/or modify
51 * it under the terms of the GNU Lesser General Public License as
52 * published by the Free Software Foundation, either version 3 of the
53 * License, or (at your option) any later version.
54 *
55 * This program is distributed in the hope that it will be useful,
56 * but WITHOUT ANY WARRANTY; without even the implied warranty of
57 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
58 * GNU General Lesser Public License for more details.
59 *
60 * You should have received a copy of the GNU General Lesser Public
61 * License along with this program. If not, see
62 * <http://www.gnu.org/licenses/lgpl-3.0.html>.
63 * ╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱
64 */
65
66 import java.io.*;
67 import java.util.*;
68
69 /**
70 * The AsnPduSequence class know how a Pdu v1 and v2c is build, it knows its
71 * sequence.
72 *
73 * @author <a href="mailto:snmp@westhawk.co.uk">Tim Panton</a>
74 * @version $Revision: 3.10 $ $Date: 2006/01/17 17:43:54 $
75 */
76 class AsnPduSequence extends AsnSequence {
77 private static final String version_id = "@(#)$Id: AsnPduSequence.java,v 3.10 2006/01/17 17:43:54 birgit Exp $ Copyright Westhawk Ltd";
78
79 boolean snmpv3Discovery = false;
80
81 AsnPduSequence(InputStream in, int len, int pos) throws IOException {
82 super(in, len, pos);
83 }
84
85 int getReqId() {
86 AsnInteger rid = (AsnInteger) getObj(0);
87 return (rid.getValue());
88 }
89
90 int getWhatError() {
91 AsnInteger estat = (AsnInteger) getObj(1);
92 return (estat.getValue());
93 }
94
95 int getWhereError() {
96 AsnInteger estat = (AsnInteger) getObj(2);
97 return (estat.getValue());
98 }
99
100 AsnSequence getVarBind() {
101 return (AsnSequence) getObj(3);
102 }
103
104 /**
105 * recursively look for a pduSequence object
106 * - got one :-)
107 */
108 AsnObject findPdu() {
109 return this;
110 }
111
112 int getValue() {
113 AsnSequence varBind = (AsnSequence) getObj(3);
114 AsnSequence varPair = (AsnSequence) varBind.getObj(0);
115 AsnInteger val = (AsnInteger) varPair.getObj(1);
116 int value = val.getValue();
117
118 return value;
119 }
120
121 boolean hadError() {
122 return (SNMP_ERR_NOERROR != getWhatError());
123 }
124
125 boolean isSnmpv3Discovery() {
126 return snmpv3Discovery;
127 }
128
129 void setSnmpv3Discovery(boolean b) {
130 snmpv3Discovery = b;
131 }
132 }