1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 package uk.co.westhawk.snmp.stack;
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52 import java.io.*;
53 import java.util.*;
54
55
56
57
58
59
60
61
62 class AsnTrapPduv1Sequence extends AsnSequence {
63 private static final String version_id = "@(#)$Id: AsnTrapPduv1Sequence.java,v 3.6 2006/01/17 17:43:54 birgit Exp $ Copyright Westhawk Ltd";
64
65 AsnTrapPduv1Sequence(InputStream in, int len, int pos) throws IOException {
66 super(in, len, pos);
67 }
68
69 String getEnterprise() throws DecodingException {
70 String ent = "";
71 AsnObject obj = getObj(0);
72 if (obj instanceof AsnObjectId) {
73 AsnObjectId rid = (AsnObjectId) obj;
74 ent = rid.getValue();
75 } else {
76 String msg = "TrapPduv1.Enterprise should be AsnObjectId"
77 + " instead of " + obj.getRespTypeString();
78 throw new DecodingException(msg);
79 }
80 return ent;
81 }
82
83 byte[] getIPAddress() throws DecodingException {
84 byte[] ip = null;
85 AsnObject obj = getObj(1);
86 if (obj instanceof AsnOctets) {
87 AsnOctets estat = (AsnOctets) obj;
88 ip = estat.getBytes();
89 } else {
90 String msg = "TrapPduv1.IPAddress should be of type AsnOctets"
91 + " instead of " + obj.getRespTypeString();
92 throw new DecodingException(msg);
93 }
94 return ip;
95 }
96
97 int getGenericTrap() throws DecodingException {
98 int genTrap = -1;
99 AsnObject obj = getObj(2);
100 if (obj instanceof AsnInteger) {
101 AsnInteger estat = (AsnInteger) obj;
102 genTrap = estat.getValue();
103 } else {
104 String msg = "TrapPduv1.GenericTrap should be of type AsnInteger"
105 + " instead of " + obj.getRespTypeString();
106 throw new DecodingException(msg);
107 }
108 return genTrap;
109 }
110
111 int getSpecificTrap() throws DecodingException {
112 int specTrap = -1;
113 AsnObject obj = getObj(3);
114 if (obj instanceof AsnInteger) {
115 AsnInteger estat = (AsnInteger) obj;
116 specTrap = estat.getValue();
117 } else {
118 String msg = "TrapPduv1.SpecificTrap should be of type AsnInteger"
119 + " instead of " + obj.getRespTypeString();
120 throw new DecodingException(msg);
121 }
122 return specTrap;
123
124 }
125
126 long getTimeTicks() throws DecodingException {
127 long ticks = -1;
128 AsnObject obj = getObj(4);
129 if (obj instanceof AsnUnsInteger) {
130 AsnUnsInteger estat = (AsnUnsInteger) obj;
131 ticks = estat.getValue();
132 } else {
133 String msg = "TrapPduv1.TimeTicks should be of type AsnUnsInteger"
134 + " instead of " + obj.getRespTypeString();
135 throw new DecodingException(msg);
136 }
137 return ticks;
138 }
139
140 AsnSequence getVarBind() throws DecodingException {
141 AsnSequence varb = null;
142 AsnObject obj = getObj(5);
143 if (obj instanceof AsnSequence) {
144 varb = (AsnSequence) obj;
145 } else {
146 String msg = "TrapPduv1.VarBind should be of type AsnSequence"
147 + " instead of " + obj.getRespTypeString();
148 throw new DecodingException(msg);
149 }
150 return varb;
151 }
152
153
154
155
156
157 AsnObject findTrapPduv1() {
158 return this;
159 }
160
161 }