blob: 02b7cf35d89c359778684b20c6d99e71b5440965 [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;
slowr13fa5b02017-08-08 16:32:31 -07009import org.onosproject.xran.codecs.api.*;
slowr60d4d102017-08-16 18:33:58 -070010import org.onosproject.xran.codecs.ber.BerByteArrayOutputStream;
11import org.onosproject.xran.codecs.ber.BerLength;
12import org.onosproject.xran.codecs.ber.BerTag;
13import org.onosproject.xran.codecs.ber.types.string.BerUTF8String;
slowr13fa5b02017-08-08 16:32:31 -070014
15import java.io.IOException;
16import java.io.InputStream;
17import java.io.Serializable;
slowr8ddc2b12017-08-14 14:13:38 -070018import java.io.UnsupportedEncodingException;
slowr13fa5b02017-08-08 16:32:31 -070019import java.util.ArrayList;
20import java.util.Iterator;
21import java.util.List;
22
23public class RXSigMeasConfig implements Serializable {
24
25 private static final long serialVersionUID = 1L;
26
27 public static class MeasCells implements Serializable {
28
29 private static final long serialVersionUID = 1L;
30
31 public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
slowr60d4d102017-08-16 18:33:58 -070032 @JsonIgnore public byte[] code = null;
slowr13fa5b02017-08-08 16:32:31 -070033 private List<PCIARFCN> seqOf = null;
34
35 public MeasCells() {
36 seqOf = new ArrayList<PCIARFCN>();
37 }
38
39 public MeasCells(byte[] code) {
40 this.code = code;
41 }
42
slowr60d4d102017-08-16 18:33:58 -070043 @JsonValue
slowr13fa5b02017-08-08 16:32:31 -070044 public List<PCIARFCN> getPCIARFCN() {
45 if (seqOf == null) {
46 seqOf = new ArrayList<PCIARFCN>();
47 }
48 return seqOf;
49 }
50
51 public int encode(BerByteArrayOutputStream os) throws IOException {
52 return encode(os, true);
53 }
54
55 public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
56
57 if (code != null) {
58 for (int i = code.length - 1; i >= 0; i--) {
59 os.write(code[i]);
60 }
61 if (withTag) {
62 return tag.encode(os) + code.length;
63 }
64 return code.length;
65 }
66
67 int codeLength = 0;
68 for (int i = (seqOf.size() - 1); i >= 0; i--) {
69 codeLength += seqOf.get(i).encode(os, true);
70 }
71
72 codeLength += BerLength.encodeLength(os, codeLength);
73
74 if (withTag) {
75 codeLength += tag.encode(os);
76 }
77
78 return codeLength;
79 }
80
81 public int decode(InputStream is) throws IOException {
82 return decode(is, true);
83 }
84
85 public int decode(InputStream is, boolean withTag) throws IOException {
86 int codeLength = 0;
87 int subCodeLength = 0;
88 if (withTag) {
89 codeLength += tag.decodeAndCheck(is);
90 }
91
92 BerLength length = new BerLength();
93 codeLength += length.decode(is);
94 int totalLength = length.val;
95
96 while (subCodeLength < totalLength) {
97 PCIARFCN element = new PCIARFCN();
98 subCodeLength += element.decode(is, true);
99 seqOf.add(element);
100 }
101 if (subCodeLength != totalLength) {
102 throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength);
103
104 }
105 codeLength += subCodeLength;
106
107 return codeLength;
108 }
109
110 public void encodeAndSave(int encodingSizeGuess) throws IOException {
111 BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
112 encode(os, false);
113 code = os.getArray();
114 }
115
116 public String toString() {
117 StringBuilder sb = new StringBuilder();
118 appendAsString(sb, 0);
119 return sb.toString();
120 }
121
122 public void appendAsString(StringBuilder sb, int indentLevel) {
123
124 sb.append("[\n");
125 for (int i = 0; i < indentLevel + 1; i++) {
126 sb.append("\t");
127 }
128 if (seqOf == null) {
129// sb.append("null");
130 }
131 else {
132 Iterator<PCIARFCN> it = seqOf.iterator();
133 if (it.hasNext()) {
134 it.next().appendAsString(sb, indentLevel + 1);
135 while (it.hasNext()) {
136 sb.append(",\n");
137 for (int i = 0; i < indentLevel + 1; i++) {
138 sb.append("\t");
139 }
140 it.next().appendAsString(sb, indentLevel + 1);
141 }
142 }
143 }
144
145 sb.append("\n");
146 for (int i = 0; i < indentLevel; i++) {
147 sb.append("\t");
148 }
149 sb.append("]");
150 }
151
152 public void setPCIARFCN(PCIARFCN pciarfcn) {
153 seqOf.add(pciarfcn);
154 }
155 }
156
157 public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
158
slowr60d4d102017-08-16 18:33:58 -0700159 @JsonIgnore
slowr13fa5b02017-08-08 16:32:31 -0700160 public byte[] code = null;
161 private ECGI ecgi = null;
162 private CRNTI crnti = null;
163 private RXSigRepQty reportQty = null;
164 private MeasCells measCells = null;
165 private RXSigMeasRepInterval reportInterval = null;
166
167 public RXSigMeasConfig() {
168 }
169
170 public RXSigMeasConfig(byte[] code) {
171 this.code = code;
172 }
173
174 public void setEcgi(ECGI ecgi) {
175 this.ecgi = ecgi;
176 }
177
178 public ECGI getEcgi() {
179 return ecgi;
180 }
181
182 public void setCrnti(CRNTI crnti) {
183 this.crnti = crnti;
184 }
185
186 public CRNTI getCrnti() {
187 return crnti;
188 }
189
190 public void setReportQty(RXSigRepQty reportQty) {
191 this.reportQty = reportQty;
192 }
193
194 public RXSigRepQty getReportQty() {
195 return reportQty;
196 }
197
198 public void setMeasCells(MeasCells measCells) {
199 this.measCells = measCells;
200 }
201
202 public MeasCells getMeasCells() {
203 return measCells;
204 }
205
206 public void setReportInterval(RXSigMeasRepInterval reportInterval) {
207 this.reportInterval = reportInterval;
208 }
209
210 public RXSigMeasRepInterval getReportInterval() {
211 return reportInterval;
212 }
213
214 public int encode(BerByteArrayOutputStream os) throws IOException {
215 return encode(os, true);
216 }
217
218 public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
219
220 if (code != null) {
221 for (int i = code.length - 1; i >= 0; i--) {
222 os.write(code[i]);
223 }
224 if (withTag) {
225 return tag.encode(os) + code.length;
226 }
227 return code.length;
228 }
229
230 int codeLength = 0;
231 codeLength += reportInterval.encode(os, false);
232 // write tag: CONTEXT_CLASS, PRIMITIVE, 4
233 os.write(0x84);
234 codeLength += 1;
235
236 codeLength += measCells.encode(os, false);
237 // write tag: CONTEXT_CLASS, CONSTRUCTED, 3
238 os.write(0xA3);
239 codeLength += 1;
240
241 codeLength += reportQty.encode(os, false);
242 // write tag: CONTEXT_CLASS, PRIMITIVE, 2
243 os.write(0x82);
244 codeLength += 1;
245
246 codeLength += crnti.encode(os, false);
247 // write tag: CONTEXT_CLASS, PRIMITIVE, 1
248 os.write(0x81);
249 codeLength += 1;
250
251 codeLength += ecgi.encode(os, false);
252 // write tag: CONTEXT_CLASS, CONSTRUCTED, 0
253 os.write(0xA0);
254 codeLength += 1;
255
256 codeLength += BerLength.encodeLength(os, codeLength);
257
258 if (withTag) {
259 codeLength += tag.encode(os);
260 }
261
262 return codeLength;
263
264 }
265
266 public int decode(InputStream is) throws IOException {
267 return decode(is, true);
268 }
269
270 public int decode(InputStream is, boolean withTag) throws IOException {
271 int codeLength = 0;
272 int subCodeLength = 0;
273 BerTag berTag = new BerTag();
274
275 if (withTag) {
276 codeLength += tag.decodeAndCheck(is);
277 }
278
279 BerLength length = new BerLength();
280 codeLength += length.decode(is);
281
282 int totalLength = length.val;
283 codeLength += totalLength;
284
285 subCodeLength += berTag.decode(is);
286 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) {
287 ecgi = new ECGI();
288 subCodeLength += ecgi.decode(is, false);
289 subCodeLength += berTag.decode(is);
290 }
291 else {
292 throw new IOException("Tag does not match the mandatory sequence element tag.");
293 }
294
295 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) {
296 crnti = new CRNTI();
297 subCodeLength += crnti.decode(is, false);
298 subCodeLength += berTag.decode(is);
299 }
300 else {
301 throw new IOException("Tag does not match the mandatory sequence element tag.");
302 }
303
304 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 2)) {
305 reportQty = new RXSigRepQty();
306 subCodeLength += reportQty.decode(is, false);
307 subCodeLength += berTag.decode(is);
308 }
309 else {
310 throw new IOException("Tag does not match the mandatory sequence element tag.");
311 }
312
313 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 3)) {
314 measCells = new MeasCells();
315 subCodeLength += measCells.decode(is, false);
316 subCodeLength += berTag.decode(is);
317 }
318 else {
319 throw new IOException("Tag does not match the mandatory sequence element tag.");
320 }
321
322 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 4)) {
323 reportInterval = new RXSigMeasRepInterval();
324 subCodeLength += reportInterval.decode(is, false);
325 if (subCodeLength == totalLength) {
326 return codeLength;
327 }
328 }
329 throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
330
331
332 }
333
334 public void encodeAndSave(int encodingSizeGuess) throws IOException {
335 BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
336 encode(os, false);
337 code = os.getArray();
338 }
339
340 public String toString() {
341 StringBuilder sb = new StringBuilder();
342 appendAsString(sb, 0);
343 return sb.toString();
344 }
345
346 public void appendAsString(StringBuilder sb, int indentLevel) {
347
348 sb.append("{");
349 sb.append("\n");
350 for (int i = 0; i < indentLevel + 1; i++) {
351 sb.append("\t");
352 }
353 if (ecgi != null) {
slowr60d4d102017-08-16 18:33:58 -0700354 sb.append("ecgi: ");
slowr13fa5b02017-08-08 16:32:31 -0700355 ecgi.appendAsString(sb, indentLevel + 1);
356 }
357
358 sb.append(",\n");
359 for (int i = 0; i < indentLevel + 1; i++) {
360 sb.append("\t");
361 }
362 if (crnti != null) {
slowr60d4d102017-08-16 18:33:58 -0700363 sb.append("crnti: ").append(crnti);
slowr13fa5b02017-08-08 16:32:31 -0700364 }
365
366 sb.append(",\n");
367 for (int i = 0; i < indentLevel + 1; i++) {
368 sb.append("\t");
369 }
370 if (reportQty != null) {
slowr60d4d102017-08-16 18:33:58 -0700371 sb.append("reportQty: ").append(reportQty);
slowr13fa5b02017-08-08 16:32:31 -0700372 }
373
374 sb.append(",\n");
375 for (int i = 0; i < indentLevel + 1; i++) {
376 sb.append("\t");
377 }
378 if (measCells != null) {
slowr60d4d102017-08-16 18:33:58 -0700379 sb.append("measCells: ");
slowr13fa5b02017-08-08 16:32:31 -0700380 measCells.appendAsString(sb, indentLevel + 1);
381 }
382
383 sb.append(",\n");
384 for (int i = 0; i < indentLevel + 1; i++) {
385 sb.append("\t");
386 }
387 if (reportInterval != null) {
slowr60d4d102017-08-16 18:33:58 -0700388 sb.append("reportInterval: ").append(reportInterval);
slowr13fa5b02017-08-08 16:32:31 -0700389 }
390
391 sb.append("\n");
392 for (int i = 0; i < indentLevel; i++) {
393 sb.append("\t");
394 }
395 sb.append("}");
396 }
397
slowr8ddc2b12017-08-14 14:13:38 -0700398 public static XrancPdu constructPacket(ECGI ecgi, CRNTI crnti, RXSigMeasConfig.MeasCells measCells, int interval) {
399 RXSigRepQty rxSigRepQty = new RXSigRepQty(2);
400 RXSigMeasRepInterval repInterval = new RXSigMeasRepInterval(interval);
401
402 RXSigMeasConfig sigMeasConfig = new RXSigMeasConfig();
403 sigMeasConfig.setCrnti(crnti);
404 sigMeasConfig.setEcgi(ecgi);
405 sigMeasConfig.setReportQty(rxSigRepQty);
406 sigMeasConfig.setMeasCells(measCells);
407 sigMeasConfig.setReportInterval(repInterval);
408
409 XrancPduBody body = new XrancPduBody();
410 body.setRXSigMeasConfig(sigMeasConfig);
411
412 BerUTF8String ver = null;
413 try {
414 ver = new BerUTF8String("3");
415 } catch (UnsupportedEncodingException e) {
416 e.printStackTrace();
417 }
418 XrancApiID apiID = new XrancApiID(15);
419 XrancPduHdr hdr = new XrancPduHdr();
420 hdr.setVer(ver);
421 hdr.setApiId(apiID);
422
423 XrancPdu pdu = new XrancPdu();
424 pdu.setHdr(hdr);
425 pdu.setBody(body);
426
427 return pdu;
428 }
429
slowr13fa5b02017-08-08 16:32:31 -0700430}
431