blob: 055c8be7e7561ef3513dca124b8fd403d364f141 [file] [log] [blame]
slowr13fa5b02017-08-08 16:32:31 -07001/**
2 * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org)
3 */
4
5package org.onosproject.xran.codecs.pdu;
6
slowr60d4d102017-08-16 18:33:58 -07007import com.fasterxml.jackson.annotation.JsonIgnore;
8import com.fasterxml.jackson.annotation.JsonValue;
9import org.onosproject.xran.codecs.ber.BerByteArrayOutputStream;
10import org.onosproject.xran.codecs.ber.BerLength;
11import org.onosproject.xran.codecs.ber.BerTag;
12import org.onosproject.xran.codecs.ber.types.BerInteger;
slowr13fa5b02017-08-08 16:32:31 -070013import org.onosproject.xran.codecs.api.CRNTI;
14import org.onosproject.xran.codecs.api.ECGI;
15import org.onosproject.xran.codecs.api.ERABID;
16
17import java.io.IOException;
18import java.io.InputStream;
19import java.io.Serializable;
20import java.util.ArrayList;
21import java.util.Iterator;
22import java.util.List;
23
24public class BearerReleaseInd implements Serializable {
25
26 private static final long serialVersionUID = 1L;
27
28 public static class ErabIds implements Serializable {
29
30 private static final long serialVersionUID = 1L;
31
32 public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
slowr60d4d102017-08-16 18:33:58 -070033 @JsonIgnore
slowr13fa5b02017-08-08 16:32:31 -070034 public byte[] code = null;
35 private List<ERABID> seqOf = null;
36
37 public ErabIds() {
38 seqOf = new ArrayList<ERABID>();
39 }
40
41 public ErabIds(byte[] code) {
42 this.code = code;
43 }
44
slowr60d4d102017-08-16 18:33:58 -070045 @JsonValue
slowr13fa5b02017-08-08 16:32:31 -070046 public List<ERABID> getERABID() {
47 if (seqOf == null) {
48 seqOf = new ArrayList<ERABID>();
49 }
50 return seqOf;
51 }
52
53 public int encode(BerByteArrayOutputStream os) throws IOException {
54 return encode(os, true);
55 }
56
57 public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
58
59 if (code != null) {
60 for (int i = code.length - 1; i >= 0; i--) {
61 os.write(code[i]);
62 }
63 if (withTag) {
64 return tag.encode(os) + code.length;
65 }
66 return code.length;
67 }
68
69 int codeLength = 0;
70 for (int i = (seqOf.size() - 1); i >= 0; i--) {
71 codeLength += seqOf.get(i).encode(os, true);
72 }
73
74 codeLength += BerLength.encodeLength(os, codeLength);
75
76 if (withTag) {
77 codeLength += tag.encode(os);
78 }
79
80 return codeLength;
81 }
82
83 public int decode(InputStream is) throws IOException {
84 return decode(is, true);
85 }
86
87 public int decode(InputStream is, boolean withTag) throws IOException {
88 int codeLength = 0;
89 int subCodeLength = 0;
90 if (withTag) {
91 codeLength += tag.decodeAndCheck(is);
92 }
93
94 BerLength length = new BerLength();
95 codeLength += length.decode(is);
96 int totalLength = length.val;
97
98 while (subCodeLength < totalLength) {
99 ERABID element = new ERABID();
100 subCodeLength += element.decode(is, true);
101 seqOf.add(element);
102 }
103 if (subCodeLength != totalLength) {
104 throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength);
105
106 }
107 codeLength += subCodeLength;
108
109 return codeLength;
110 }
111
112 public void encodeAndSave(int encodingSizeGuess) throws IOException {
113 BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
114 encode(os, false);
115 code = os.getArray();
116 }
117
118 public String toString() {
119 StringBuilder sb = new StringBuilder();
120 appendAsString(sb, 0);
121 return sb.toString();
122 }
123
124 public void appendAsString(StringBuilder sb, int indentLevel) {
125
126 sb.append("[\n");
127 for (int i = 0; i < indentLevel + 1; i++) {
128 sb.append("\t");
129 }
130 if (seqOf == null) {
131// sb.append("null");
132 }
133 else {
134 Iterator<ERABID> it = seqOf.iterator();
135 if (it.hasNext()) {
136 sb.append(it.next());
137 while (it.hasNext()) {
138 sb.append(",\n");
139 for (int i = 0; i < indentLevel + 1; i++) {
140 sb.append("\t");
141 }
142 sb.append(it.next());
143 }
144 }
145 }
146
147 sb.append("\n");
148 for (int i = 0; i < indentLevel; i++) {
149 sb.append("\t");
150 }
151 sb.append("]");
152 }
153
154 }
155
156 public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
157
slowr60d4d102017-08-16 18:33:58 -0700158 @JsonIgnore public byte[] code = null;
slowr13fa5b02017-08-08 16:32:31 -0700159 private CRNTI crnti = null;
160 private ECGI ecgi = null;
161 private BerInteger numErabs = null;
162 private ErabIds erabIds = null;
163
164 public BearerReleaseInd() {
165 }
166
167 public BearerReleaseInd(byte[] code) {
168 this.code = code;
169 }
170
171 public void setCrnti(CRNTI crnti) {
172 this.crnti = crnti;
173 }
174
175 public CRNTI getCrnti() {
176 return crnti;
177 }
178
179 public void setEcgi(ECGI ecgi) {
180 this.ecgi = ecgi;
181 }
182
183 public ECGI getEcgi() {
184 return ecgi;
185 }
186
187 public void setNumErabs(BerInteger numErabs) {
188 this.numErabs = numErabs;
189 }
190
191 public BerInteger getNumErabs() {
192 return numErabs;
193 }
194
195 public void setErabIds(ErabIds erabIds) {
196 this.erabIds = erabIds;
197 }
198
199 public ErabIds getErabIds() {
200 return erabIds;
201 }
202
203 public int encode(BerByteArrayOutputStream os) throws IOException {
204 return encode(os, true);
205 }
206
207 public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
208
209 if (code != null) {
210 for (int i = code.length - 1; i >= 0; i--) {
211 os.write(code[i]);
212 }
213 if (withTag) {
214 return tag.encode(os) + code.length;
215 }
216 return code.length;
217 }
218
219 int codeLength = 0;
220 codeLength += erabIds.encode(os, false);
221 // write tag: CONTEXT_CLASS, CONSTRUCTED, 3
222 os.write(0xA3);
223 codeLength += 1;
224
225 codeLength += numErabs.encode(os, false);
226 // write tag: CONTEXT_CLASS, PRIMITIVE, 2
227 os.write(0x82);
228 codeLength += 1;
229
230 codeLength += ecgi.encode(os, false);
231 // write tag: CONTEXT_CLASS, CONSTRUCTED, 1
232 os.write(0xA1);
233 codeLength += 1;
234
235 codeLength += crnti.encode(os, false);
236 // write tag: CONTEXT_CLASS, PRIMITIVE, 0
237 os.write(0x80);
238 codeLength += 1;
239
240 codeLength += BerLength.encodeLength(os, codeLength);
241
242 if (withTag) {
243 codeLength += tag.encode(os);
244 }
245
246 return codeLength;
247
248 }
249
250 public int decode(InputStream is) throws IOException {
251 return decode(is, true);
252 }
253
254 public int decode(InputStream is, boolean withTag) throws IOException {
255 int codeLength = 0;
256 int subCodeLength = 0;
257 BerTag berTag = new BerTag();
258
259 if (withTag) {
260 codeLength += tag.decodeAndCheck(is);
261 }
262
263 BerLength length = new BerLength();
264 codeLength += length.decode(is);
265
266 int totalLength = length.val;
267 codeLength += totalLength;
268
269 subCodeLength += berTag.decode(is);
270 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
271 crnti = new CRNTI();
272 subCodeLength += crnti.decode(is, false);
273 subCodeLength += berTag.decode(is);
274 }
275 else {
276 throw new IOException("Tag does not match the mandatory sequence element tag.");
277 }
278
279 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
280 ecgi = new ECGI();
281 subCodeLength += ecgi.decode(is, false);
282 subCodeLength += berTag.decode(is);
283 }
284 else {
285 throw new IOException("Tag does not match the mandatory sequence element tag.");
286 }
287
288 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 2)) {
289 numErabs = new BerInteger();
290 subCodeLength += numErabs.decode(is, false);
291 subCodeLength += berTag.decode(is);
292 }
293 else {
294 throw new IOException("Tag does not match the mandatory sequence element tag.");
295 }
296
297 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 3)) {
298 erabIds = new ErabIds();
299 subCodeLength += erabIds.decode(is, false);
300 if (subCodeLength == totalLength) {
301 return codeLength;
302 }
303 }
304 throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
305
306
307 }
308
309 public void encodeAndSave(int encodingSizeGuess) throws IOException {
310 BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
311 encode(os, false);
312 code = os.getArray();
313 }
314
315 public String toString() {
316 StringBuilder sb = new StringBuilder();
317 appendAsString(sb, 0);
318 return sb.toString();
319 }
320
321 public void appendAsString(StringBuilder sb, int indentLevel) {
322
323 sb.append("{");
324 sb.append("\n");
325 for (int i = 0; i < indentLevel + 1; i++) {
326 sb.append("\t");
327 }
328 if (crnti != null) {
slowr60d4d102017-08-16 18:33:58 -0700329 sb.append("crnti: ").append(crnti);
slowr13fa5b02017-08-08 16:32:31 -0700330 }
331
332 sb.append(",\n");
333 for (int i = 0; i < indentLevel + 1; i++) {
334 sb.append("\t");
335 }
336 if (ecgi != null) {
slowr60d4d102017-08-16 18:33:58 -0700337 sb.append("ecgi: ");
slowr13fa5b02017-08-08 16:32:31 -0700338 ecgi.appendAsString(sb, indentLevel + 1);
339 }
340
341 sb.append(",\n");
342 for (int i = 0; i < indentLevel + 1; i++) {
343 sb.append("\t");
344 }
345 if (numErabs != null) {
slowr60d4d102017-08-16 18:33:58 -0700346 sb.append("numErabs: ").append(numErabs);
slowr13fa5b02017-08-08 16:32:31 -0700347 }
348
349 sb.append(",\n");
350 for (int i = 0; i < indentLevel + 1; i++) {
351 sb.append("\t");
352 }
353 if (erabIds != null) {
slowr60d4d102017-08-16 18:33:58 -0700354 sb.append("erabIds: ");
slowr13fa5b02017-08-08 16:32:31 -0700355 erabIds.appendAsString(sb, indentLevel + 1);
356 }
357
358 sb.append("\n");
359 for (int i = 0; i < indentLevel; i++) {
360 sb.append("\t");
361 }
362 sb.append("}");
363 }
364
365}
366