blob: 7d841c921bff9c65959ca38ddda3b86b77d05b84 [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 */
4package org.onosproject.xran.codecs.pdu;
5
slowr60d4d102017-08-16 18:33:58 -07006import com.fasterxml.jackson.annotation.JsonIgnore;
slowr13fa5b02017-08-08 16:32:31 -07007import org.onosproject.xran.codecs.api.CRNTI;
8import org.onosproject.xran.codecs.api.ECGI;
9import org.onosproject.xran.codecs.api.PCIARFCN;
10import org.onosproject.xran.codecs.api.XICICPA;
slowr60d4d102017-08-16 18:33:58 -070011import org.onosproject.xran.codecs.ber.BerByteArrayOutputStream;
12import org.onosproject.xran.codecs.ber.BerLength;
13import org.onosproject.xran.codecs.ber.BerTag;
14import org.onosproject.xran.codecs.ber.types.BerBitString;
15import org.onosproject.xran.codecs.ber.types.BerInteger;
16import org.onosproject.xran.codecs.ber.types.string.BerUTF8String;
slowr8ddc2b12017-08-14 14:13:38 -070017
slowr13fa5b02017-08-08 16:32:31 -070018import java.io.IOException;
19import java.io.InputStream;
20import java.io.Serializable;
slowr8ddc2b12017-08-14 14:13:38 -070021import java.io.UnsupportedEncodingException;
slowr13fa5b02017-08-08 16:32:31 -070022
23public class XICICConfig implements Serializable {
24
25 private static final long serialVersionUID = 1L;
26
27 public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
28
slowr60d4d102017-08-16 18:33:58 -070029 @JsonIgnore
slowr13fa5b02017-08-08 16:32:31 -070030 public byte[] code = null;
31 private ECGI ecgi = null;
32 private PCIARFCN pciArfcn = null;
33 private CRNTI crnti = null;
34 private XICICPA pa = null;
35 private BerInteger startPrbDl = null;
36 private BerInteger endPrbDl = null;
37 private BerBitString subframeBitmaskDl = null;
38 private BerInteger p0UePusch = null;
39 private BerInteger startPrbUl = null;
40 private BerInteger endPrbUl = null;
41 private BerBitString subframeBitmaskUl = null;
slowr89c2ac12017-08-15 16:20:06 -070042
slowr13fa5b02017-08-08 16:32:31 -070043 public XICICConfig() {
44 }
45
46 public XICICConfig(byte[] code) {
47 this.code = code;
48 }
49
50 public void setEcgi(ECGI ecgi) {
51 this.ecgi = ecgi;
52 }
53
54 public ECGI getEcgi() {
55 return ecgi;
56 }
57
58 public void setPciArfcn(PCIARFCN pciArfcn) {
59 this.pciArfcn = pciArfcn;
60 }
61
62 public PCIARFCN getPciArfcn() {
63 return pciArfcn;
64 }
65
66 public void setCrnti(CRNTI crnti) {
67 this.crnti = crnti;
68 }
69
70 public CRNTI getCrnti() {
71 return crnti;
72 }
73
74 public void setPa(XICICPA pa) {
75 this.pa = pa;
76 }
77
78 public XICICPA getPa() {
79 return pa;
80 }
81
82 public void setStartPrbDl(BerInteger startPrbDl) {
83 this.startPrbDl = startPrbDl;
84 }
85
86 public BerInteger getStartPrbDl() {
87 return startPrbDl;
88 }
89
90 public void setEndPrbDl(BerInteger endPrbDl) {
91 this.endPrbDl = endPrbDl;
92 }
93
94 public BerInteger getEndPrbDl() {
95 return endPrbDl;
96 }
97
98 public void setSubframeBitmaskDl(BerBitString subframeBitmaskDl) {
99 this.subframeBitmaskDl = subframeBitmaskDl;
100 }
101
102 public BerBitString getSubframeBitmaskDl() {
103 return subframeBitmaskDl;
104 }
105
106 public void setP0UePusch(BerInteger p0UePusch) {
107 this.p0UePusch = p0UePusch;
108 }
109
110 public BerInteger getP0UePusch() {
111 return p0UePusch;
112 }
113
114 public void setStartPrbUl(BerInteger startPrbUl) {
115 this.startPrbUl = startPrbUl;
116 }
117
118 public BerInteger getStartPrbUl() {
119 return startPrbUl;
120 }
121
122 public void setEndPrbUl(BerInteger endPrbUl) {
123 this.endPrbUl = endPrbUl;
124 }
125
126 public BerInteger getEndPrbUl() {
127 return endPrbUl;
128 }
129
130 public void setSubframeBitmaskUl(BerBitString subframeBitmaskUl) {
131 this.subframeBitmaskUl = subframeBitmaskUl;
132 }
133
134 public BerBitString getSubframeBitmaskUl() {
135 return subframeBitmaskUl;
136 }
137
138 public int encode(BerByteArrayOutputStream os) throws IOException {
139 return encode(os, true);
140 }
141
142 public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
143
144 if (code != null) {
145 for (int i = code.length - 1; i >= 0; i--) {
146 os.write(code[i]);
147 }
148 if (withTag) {
149 return tag.encode(os) + code.length;
150 }
151 return code.length;
152 }
153
154 int codeLength = 0;
slowr89c2ac12017-08-15 16:20:06 -0700155 if (subframeBitmaskUl != null) {
156 codeLength += subframeBitmaskUl.encode(os, false);
157 // write tag: CONTEXT_CLASS, PRIMITIVE, 10
158 os.write(0x8A);
159 codeLength += 1;
160 }
161
162 if (endPrbUl != null) {
163 codeLength += endPrbUl.encode(os, false);
164 // write tag: CONTEXT_CLASS, PRIMITIVE, 9
165 os.write(0x89);
166 codeLength += 1;
167 }
168
169 if (startPrbUl != null) {
170 codeLength += startPrbUl.encode(os, false);
171 // write tag: CONTEXT_CLASS, PRIMITIVE, 8
172 os.write(0x88);
173 codeLength += 1;
174 }
175
176 if (p0UePusch != null) {
177 codeLength += p0UePusch.encode(os, false);
178 // write tag: CONTEXT_CLASS, PRIMITIVE, 7
179 os.write(0x87);
180 codeLength += 1;
181 }
182
183 if (subframeBitmaskDl != null) {
184 codeLength += subframeBitmaskDl.encode(os, false);
185 // write tag: CONTEXT_CLASS, PRIMITIVE, 6
186 os.write(0x86);
187 codeLength += 1;
188 }
189
190 if (endPrbDl != null) {
191 codeLength += endPrbDl.encode(os, false);
192 // write tag: CONTEXT_CLASS, PRIMITIVE, 5
193 os.write(0x85);
194 codeLength += 1;
195 }
196
197 if (startPrbDl != null) {
198 codeLength += startPrbDl.encode(os, false);
199 // write tag: CONTEXT_CLASS, PRIMITIVE, 4
200 os.write(0x84);
201 codeLength += 1;
202 }
203
204 if (pa != null) {
205 codeLength += pa.encode(os, false);
206 // write tag: CONTEXT_CLASS, PRIMITIVE, 3
207 os.write(0x83);
208 codeLength += 1;
209 }
210
slowr13fa5b02017-08-08 16:32:31 -0700211 codeLength += crnti.encode(os, false);
212 // write tag: CONTEXT_CLASS, PRIMITIVE, 2
213 os.write(0x82);
214 codeLength += 1;
slowr89c2ac12017-08-15 16:20:06 -0700215
216 if (pciArfcn != null) {
217 codeLength += pciArfcn.encode(os, false);
218 // write tag: CONTEXT_CLASS, CONSTRUCTED, 1
219 os.write(0xA1);
220 codeLength += 1;
221 }
222
slowr13fa5b02017-08-08 16:32:31 -0700223 codeLength += ecgi.encode(os, false);
224 // write tag: CONTEXT_CLASS, CONSTRUCTED, 0
225 os.write(0xA0);
226 codeLength += 1;
slowr89c2ac12017-08-15 16:20:06 -0700227
slowr13fa5b02017-08-08 16:32:31 -0700228 codeLength += BerLength.encodeLength(os, codeLength);
229
230 if (withTag) {
231 codeLength += tag.encode(os);
232 }
233
234 return codeLength;
235
236 }
237
238 public int decode(InputStream is) throws IOException {
239 return decode(is, true);
240 }
241
242 public int decode(InputStream is, boolean withTag) throws IOException {
243 int codeLength = 0;
244 int subCodeLength = 0;
245 BerTag berTag = new BerTag();
246
247 if (withTag) {
248 codeLength += tag.decodeAndCheck(is);
249 }
250
251 BerLength length = new BerLength();
252 codeLength += length.decode(is);
253
254 int totalLength = length.val;
255 codeLength += totalLength;
256
257 subCodeLength += berTag.decode(is);
258 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) {
259 ecgi = new ECGI();
260 subCodeLength += ecgi.decode(is, false);
261 subCodeLength += berTag.decode(is);
262 }
263 else {
264 throw new IOException("Tag does not match the mandatory sequence element tag.");
265 }
slowr89c2ac12017-08-15 16:20:06 -0700266
slowr13fa5b02017-08-08 16:32:31 -0700267 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
268 pciArfcn = new PCIARFCN();
269 subCodeLength += pciArfcn.decode(is, false);
270 subCodeLength += berTag.decode(is);
271 }
slowr89c2ac12017-08-15 16:20:06 -0700272
slowr13fa5b02017-08-08 16:32:31 -0700273 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 2)) {
274 crnti = new CRNTI();
275 subCodeLength += crnti.decode(is, false);
slowr89c2ac12017-08-15 16:20:06 -0700276 if (subCodeLength == totalLength) {
277 return codeLength;
278 }
slowr13fa5b02017-08-08 16:32:31 -0700279 subCodeLength += berTag.decode(is);
280 }
281 else {
282 throw new IOException("Tag does not match the mandatory sequence element tag.");
283 }
slowr89c2ac12017-08-15 16:20:06 -0700284
slowr13fa5b02017-08-08 16:32:31 -0700285 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 3)) {
286 pa = new XICICPA();
287 subCodeLength += pa.decode(is, false);
slowr89c2ac12017-08-15 16:20:06 -0700288 if (subCodeLength == totalLength) {
289 return codeLength;
290 }
slowr13fa5b02017-08-08 16:32:31 -0700291 subCodeLength += berTag.decode(is);
292 }
slowr89c2ac12017-08-15 16:20:06 -0700293
slowr13fa5b02017-08-08 16:32:31 -0700294 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 4)) {
295 startPrbDl = new BerInteger();
296 subCodeLength += startPrbDl.decode(is, false);
slowr89c2ac12017-08-15 16:20:06 -0700297 if (subCodeLength == totalLength) {
298 return codeLength;
299 }
slowr13fa5b02017-08-08 16:32:31 -0700300 subCodeLength += berTag.decode(is);
301 }
slowr89c2ac12017-08-15 16:20:06 -0700302
slowr13fa5b02017-08-08 16:32:31 -0700303 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 5)) {
304 endPrbDl = new BerInteger();
305 subCodeLength += endPrbDl.decode(is, false);
slowr89c2ac12017-08-15 16:20:06 -0700306 if (subCodeLength == totalLength) {
307 return codeLength;
308 }
slowr13fa5b02017-08-08 16:32:31 -0700309 subCodeLength += berTag.decode(is);
310 }
slowr89c2ac12017-08-15 16:20:06 -0700311
slowr13fa5b02017-08-08 16:32:31 -0700312 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 6)) {
313 subframeBitmaskDl = new BerBitString();
314 subCodeLength += subframeBitmaskDl.decode(is, false);
slowr89c2ac12017-08-15 16:20:06 -0700315 if (subCodeLength == totalLength) {
316 return codeLength;
317 }
slowr13fa5b02017-08-08 16:32:31 -0700318 subCodeLength += berTag.decode(is);
319 }
slowr89c2ac12017-08-15 16:20:06 -0700320
slowr13fa5b02017-08-08 16:32:31 -0700321 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 7)) {
322 p0UePusch = new BerInteger();
323 subCodeLength += p0UePusch.decode(is, false);
slowr89c2ac12017-08-15 16:20:06 -0700324 if (subCodeLength == totalLength) {
325 return codeLength;
326 }
slowr13fa5b02017-08-08 16:32:31 -0700327 subCodeLength += berTag.decode(is);
328 }
slowr89c2ac12017-08-15 16:20:06 -0700329
slowr13fa5b02017-08-08 16:32:31 -0700330 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 8)) {
331 startPrbUl = new BerInteger();
332 subCodeLength += startPrbUl.decode(is, false);
slowr89c2ac12017-08-15 16:20:06 -0700333 if (subCodeLength == totalLength) {
334 return codeLength;
335 }
slowr13fa5b02017-08-08 16:32:31 -0700336 subCodeLength += berTag.decode(is);
337 }
slowr89c2ac12017-08-15 16:20:06 -0700338
slowr13fa5b02017-08-08 16:32:31 -0700339 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 9)) {
340 endPrbUl = new BerInteger();
341 subCodeLength += endPrbUl.decode(is, false);
slowr89c2ac12017-08-15 16:20:06 -0700342 if (subCodeLength == totalLength) {
343 return codeLength;
344 }
slowr13fa5b02017-08-08 16:32:31 -0700345 subCodeLength += berTag.decode(is);
346 }
slowr89c2ac12017-08-15 16:20:06 -0700347
slowr13fa5b02017-08-08 16:32:31 -0700348 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 10)) {
349 subframeBitmaskUl = new BerBitString();
350 subCodeLength += subframeBitmaskUl.decode(is, false);
351 if (subCodeLength == totalLength) {
352 return codeLength;
353 }
354 }
355 throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
356
slowr89c2ac12017-08-15 16:20:06 -0700357
slowr13fa5b02017-08-08 16:32:31 -0700358 }
359
360 public void encodeAndSave(int encodingSizeGuess) throws IOException {
361 BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
362 encode(os, false);
363 code = os.getArray();
364 }
365
366 public String toString() {
367 StringBuilder sb = new StringBuilder();
368 appendAsString(sb, 0);
369 return sb.toString();
370 }
371
372 public void appendAsString(StringBuilder sb, int indentLevel) {
slowr13fa5b02017-08-08 16:32:31 -0700373 sb.append("{");
374 sb.append("\n");
375 for (int i = 0; i < indentLevel + 1; i++) {
376 sb.append("\t");
377 }
378 if (ecgi != null) {
slowr60d4d102017-08-16 18:33:58 -0700379 sb.append("ecgi: ");
slowr13fa5b02017-08-08 16:32:31 -0700380 ecgi.appendAsString(sb, indentLevel + 1);
381 }
slowr8d9a4c42017-08-15 16:21:12 -0700382
slowr13fa5b02017-08-08 16:32:31 -0700383 if (pciArfcn != null) {
slowr8d9a4c42017-08-15 16:21:12 -0700384 sb.append(",\n");
385 for (int i = 0; i < indentLevel + 1; i++) {
386 sb.append("\t");
387 }
slowr60d4d102017-08-16 18:33:58 -0700388 sb.append("pciArfcn: ");
slowr13fa5b02017-08-08 16:32:31 -0700389 pciArfcn.appendAsString(sb, indentLevel + 1);
390 }
slowr8d9a4c42017-08-15 16:21:12 -0700391
slowr13fa5b02017-08-08 16:32:31 -0700392 sb.append(",\n");
393 for (int i = 0; i < indentLevel + 1; i++) {
394 sb.append("\t");
395 }
396 if (crnti != null) {
slowr60d4d102017-08-16 18:33:58 -0700397 sb.append("crnti: ").append(crnti);
slowr13fa5b02017-08-08 16:32:31 -0700398 }
slowr8d9a4c42017-08-15 16:21:12 -0700399
slowr13fa5b02017-08-08 16:32:31 -0700400 if (pa != null) {
slowr8d9a4c42017-08-15 16:21:12 -0700401 sb.append(",\n");
402 for (int i = 0; i < indentLevel + 1; i++) {
403 sb.append("\t");
404 }
slowr60d4d102017-08-16 18:33:58 -0700405 sb.append("pa: ").append(pa);
slowr13fa5b02017-08-08 16:32:31 -0700406 }
slowr8d9a4c42017-08-15 16:21:12 -0700407
slowr13fa5b02017-08-08 16:32:31 -0700408 if (startPrbDl != null) {
slowr8d9a4c42017-08-15 16:21:12 -0700409 sb.append(",\n");
410 for (int i = 0; i < indentLevel + 1; i++) {
411 sb.append("\t");
412 }
slowr60d4d102017-08-16 18:33:58 -0700413 sb.append("startPrbDl: ").append(startPrbDl);
slowr13fa5b02017-08-08 16:32:31 -0700414 }
slowr8d9a4c42017-08-15 16:21:12 -0700415
slowr13fa5b02017-08-08 16:32:31 -0700416 if (endPrbDl != null) {
slowr8d9a4c42017-08-15 16:21:12 -0700417 sb.append(",\n");
418 for (int i = 0; i < indentLevel + 1; i++) {
419 sb.append("\t");
420 }
slowr60d4d102017-08-16 18:33:58 -0700421 sb.append("endPrbDl: ").append(endPrbDl);
slowr13fa5b02017-08-08 16:32:31 -0700422 }
slowr8d9a4c42017-08-15 16:21:12 -0700423
slowr13fa5b02017-08-08 16:32:31 -0700424 if (subframeBitmaskDl != null) {
slowr8d9a4c42017-08-15 16:21:12 -0700425 sb.append(",\n");
426 for (int i = 0; i < indentLevel + 1; i++) {
427 sb.append("\t");
428 }
slowr60d4d102017-08-16 18:33:58 -0700429 sb.append("subframeBitmaskDl: ").append(subframeBitmaskDl);
slowr13fa5b02017-08-08 16:32:31 -0700430 }
slowr8d9a4c42017-08-15 16:21:12 -0700431
slowr13fa5b02017-08-08 16:32:31 -0700432 if (p0UePusch != null) {
slowr8d9a4c42017-08-15 16:21:12 -0700433 sb.append(",\n");
434 for (int i = 0; i < indentLevel + 1; i++) {
435 sb.append("\t");
436 }
slowr60d4d102017-08-16 18:33:58 -0700437 sb.append("p0UePusch: ").append(p0UePusch);
slowr13fa5b02017-08-08 16:32:31 -0700438 }
slowr8d9a4c42017-08-15 16:21:12 -0700439
slowr13fa5b02017-08-08 16:32:31 -0700440 if (startPrbUl != null) {
slowr8d9a4c42017-08-15 16:21:12 -0700441 sb.append(",\n");
442 for (int i = 0; i < indentLevel + 1; i++) {
443 sb.append("\t");
444 }
slowr60d4d102017-08-16 18:33:58 -0700445 sb.append("startPrbUl: ").append(startPrbUl);
slowr13fa5b02017-08-08 16:32:31 -0700446 }
slowr8d9a4c42017-08-15 16:21:12 -0700447
slowr13fa5b02017-08-08 16:32:31 -0700448 if (endPrbUl != null) {
slowr8d9a4c42017-08-15 16:21:12 -0700449 sb.append(",\n");
450 for (int i = 0; i < indentLevel + 1; i++) {
451 sb.append("\t");
452 }
slowr60d4d102017-08-16 18:33:58 -0700453 sb.append("endPrbUl: ").append(endPrbUl);
slowr13fa5b02017-08-08 16:32:31 -0700454 }
slowr8d9a4c42017-08-15 16:21:12 -0700455
slowr13fa5b02017-08-08 16:32:31 -0700456 if (subframeBitmaskUl != null) {
slowr8d9a4c42017-08-15 16:21:12 -0700457 sb.append(",\n");
458 for (int i = 0; i < indentLevel + 1; i++) {
459 sb.append("\t");
460 }
slowr60d4d102017-08-16 18:33:58 -0700461 sb.append("subframeBitmaskUl: ").append(subframeBitmaskUl);
slowr13fa5b02017-08-08 16:32:31 -0700462 }
slowr8d9a4c42017-08-15 16:21:12 -0700463
slowr13fa5b02017-08-08 16:32:31 -0700464 sb.append("\n");
465 for (int i = 0; i < indentLevel; i++) {
466 sb.append("\t");
467 }
468 sb.append("}");
469 }
470
slowr8ddc2b12017-08-14 14:13:38 -0700471 public static XrancPdu constructPacket(RRMConfig config) {
472 XrancPduBody body = new XrancPduBody();
slowr7c0e1672017-08-15 17:09:14 -0700473
474 XICICConfig xicicConfig = new XICICConfig();
475
476 xicicConfig.setCrnti(config.getCrnti().getCRNTI().get(0));
477 xicicConfig.setEcgi(config.getEcgi());
478
479 try {
480 xicicConfig.setEndPrbDl(config.getEndPrbDl().getSeqOf().get(0));
481 } catch (Exception ignored) {}
482
483 try {
484 xicicConfig.setEndPrbUl(config.getEndPrbUl().getSeqOf().get(0));
485 } catch (Exception ignored) {}
486
487 try {
488 xicicConfig.setStartPrbDl(config.getStartPrbDl().getSeqOf().get(0));
489 } catch (Exception ignored) {}
490
491 try {
492 xicicConfig.setEndPrbUl(config.getStartPrbUl().getSeqOf().get(0));
493 } catch (Exception ignored) {}
494
495 body.setXICICConfig(xicicConfig);
slowr8ddc2b12017-08-14 14:13:38 -0700496
497 BerUTF8String ver = null;
498 try {
499 ver = new BerUTF8String("3");
500 } catch (UnsupportedEncodingException e) {
501 e.printStackTrace();
502 }
503
504 XrancApiID apiID = new XrancApiID(23);
505 XrancPduHdr hdr = new XrancPduHdr();
506 hdr.setVer(ver);
507 hdr.setApiId(apiID);
508
509 XrancPdu pdu = new XrancPdu();
510 pdu.setHdr(hdr);
511 pdu.setBody(body);
512 return pdu;
513 }
slowr13fa5b02017-08-08 16:32:31 -0700514}
515