blob: 2d1bc70f801f32039ec4aae18a9df20d40352e02 [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
6import org.onosproject.xran.codecs.api.CRNTI;
7import org.onosproject.xran.codecs.api.ECGI;
8import org.onosproject.xran.codecs.api.PCIARFCN;
9import org.onosproject.xran.codecs.api.XICICPA;
10import org.openmuc.jasn1.ber.BerByteArrayOutputStream;
11import org.openmuc.jasn1.ber.BerLength;
12import org.openmuc.jasn1.ber.BerTag;
13import org.openmuc.jasn1.ber.types.BerBitString;
14import org.openmuc.jasn1.ber.types.BerInteger;
slowr8ddc2b12017-08-14 14:13:38 -070015import org.openmuc.jasn1.ber.types.string.BerUTF8String;
16
slowr13fa5b02017-08-08 16:32:31 -070017import java.io.IOException;
18import java.io.InputStream;
19import java.io.Serializable;
slowr8ddc2b12017-08-14 14:13:38 -070020import java.io.UnsupportedEncodingException;
slowr13fa5b02017-08-08 16:32:31 -070021
22public class XICICConfig implements Serializable {
23
24 private static final long serialVersionUID = 1L;
25
26 public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
27
28 public byte[] code = null;
29 private ECGI ecgi = null;
30 private PCIARFCN pciArfcn = null;
31 private CRNTI crnti = null;
32 private XICICPA pa = null;
33 private BerInteger startPrbDl = null;
34 private BerInteger endPrbDl = null;
35 private BerBitString subframeBitmaskDl = null;
36 private BerInteger p0UePusch = null;
37 private BerInteger startPrbUl = null;
38 private BerInteger endPrbUl = null;
39 private BerBitString subframeBitmaskUl = null;
slowr89c2ac12017-08-15 16:20:06 -070040
slowr13fa5b02017-08-08 16:32:31 -070041 public XICICConfig() {
42 }
43
44 public XICICConfig(byte[] code) {
45 this.code = code;
46 }
47
48 public void setEcgi(ECGI ecgi) {
49 this.ecgi = ecgi;
50 }
51
52 public ECGI getEcgi() {
53 return ecgi;
54 }
55
56 public void setPciArfcn(PCIARFCN pciArfcn) {
57 this.pciArfcn = pciArfcn;
58 }
59
60 public PCIARFCN getPciArfcn() {
61 return pciArfcn;
62 }
63
64 public void setCrnti(CRNTI crnti) {
65 this.crnti = crnti;
66 }
67
68 public CRNTI getCrnti() {
69 return crnti;
70 }
71
72 public void setPa(XICICPA pa) {
73 this.pa = pa;
74 }
75
76 public XICICPA getPa() {
77 return pa;
78 }
79
80 public void setStartPrbDl(BerInteger startPrbDl) {
81 this.startPrbDl = startPrbDl;
82 }
83
84 public BerInteger getStartPrbDl() {
85 return startPrbDl;
86 }
87
88 public void setEndPrbDl(BerInteger endPrbDl) {
89 this.endPrbDl = endPrbDl;
90 }
91
92 public BerInteger getEndPrbDl() {
93 return endPrbDl;
94 }
95
96 public void setSubframeBitmaskDl(BerBitString subframeBitmaskDl) {
97 this.subframeBitmaskDl = subframeBitmaskDl;
98 }
99
100 public BerBitString getSubframeBitmaskDl() {
101 return subframeBitmaskDl;
102 }
103
104 public void setP0UePusch(BerInteger p0UePusch) {
105 this.p0UePusch = p0UePusch;
106 }
107
108 public BerInteger getP0UePusch() {
109 return p0UePusch;
110 }
111
112 public void setStartPrbUl(BerInteger startPrbUl) {
113 this.startPrbUl = startPrbUl;
114 }
115
116 public BerInteger getStartPrbUl() {
117 return startPrbUl;
118 }
119
120 public void setEndPrbUl(BerInteger endPrbUl) {
121 this.endPrbUl = endPrbUl;
122 }
123
124 public BerInteger getEndPrbUl() {
125 return endPrbUl;
126 }
127
128 public void setSubframeBitmaskUl(BerBitString subframeBitmaskUl) {
129 this.subframeBitmaskUl = subframeBitmaskUl;
130 }
131
132 public BerBitString getSubframeBitmaskUl() {
133 return subframeBitmaskUl;
134 }
135
136 public int encode(BerByteArrayOutputStream os) throws IOException {
137 return encode(os, true);
138 }
139
140 public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
141
142 if (code != null) {
143 for (int i = code.length - 1; i >= 0; i--) {
144 os.write(code[i]);
145 }
146 if (withTag) {
147 return tag.encode(os) + code.length;
148 }
149 return code.length;
150 }
151
152 int codeLength = 0;
slowr89c2ac12017-08-15 16:20:06 -0700153 if (subframeBitmaskUl != null) {
154 codeLength += subframeBitmaskUl.encode(os, false);
155 // write tag: CONTEXT_CLASS, PRIMITIVE, 10
156 os.write(0x8A);
157 codeLength += 1;
158 }
159
160 if (endPrbUl != null) {
161 codeLength += endPrbUl.encode(os, false);
162 // write tag: CONTEXT_CLASS, PRIMITIVE, 9
163 os.write(0x89);
164 codeLength += 1;
165 }
166
167 if (startPrbUl != null) {
168 codeLength += startPrbUl.encode(os, false);
169 // write tag: CONTEXT_CLASS, PRIMITIVE, 8
170 os.write(0x88);
171 codeLength += 1;
172 }
173
174 if (p0UePusch != null) {
175 codeLength += p0UePusch.encode(os, false);
176 // write tag: CONTEXT_CLASS, PRIMITIVE, 7
177 os.write(0x87);
178 codeLength += 1;
179 }
180
181 if (subframeBitmaskDl != null) {
182 codeLength += subframeBitmaskDl.encode(os, false);
183 // write tag: CONTEXT_CLASS, PRIMITIVE, 6
184 os.write(0x86);
185 codeLength += 1;
186 }
187
188 if (endPrbDl != null) {
189 codeLength += endPrbDl.encode(os, false);
190 // write tag: CONTEXT_CLASS, PRIMITIVE, 5
191 os.write(0x85);
192 codeLength += 1;
193 }
194
195 if (startPrbDl != null) {
196 codeLength += startPrbDl.encode(os, false);
197 // write tag: CONTEXT_CLASS, PRIMITIVE, 4
198 os.write(0x84);
199 codeLength += 1;
200 }
201
202 if (pa != null) {
203 codeLength += pa.encode(os, false);
204 // write tag: CONTEXT_CLASS, PRIMITIVE, 3
205 os.write(0x83);
206 codeLength += 1;
207 }
208
slowr13fa5b02017-08-08 16:32:31 -0700209 codeLength += crnti.encode(os, false);
210 // write tag: CONTEXT_CLASS, PRIMITIVE, 2
211 os.write(0x82);
212 codeLength += 1;
slowr89c2ac12017-08-15 16:20:06 -0700213
214 if (pciArfcn != null) {
215 codeLength += pciArfcn.encode(os, false);
216 // write tag: CONTEXT_CLASS, CONSTRUCTED, 1
217 os.write(0xA1);
218 codeLength += 1;
219 }
220
slowr13fa5b02017-08-08 16:32:31 -0700221 codeLength += ecgi.encode(os, false);
222 // write tag: CONTEXT_CLASS, CONSTRUCTED, 0
223 os.write(0xA0);
224 codeLength += 1;
slowr89c2ac12017-08-15 16:20:06 -0700225
slowr13fa5b02017-08-08 16:32:31 -0700226 codeLength += BerLength.encodeLength(os, codeLength);
227
228 if (withTag) {
229 codeLength += tag.encode(os);
230 }
231
232 return codeLength;
233
234 }
235
236 public int decode(InputStream is) throws IOException {
237 return decode(is, true);
238 }
239
240 public int decode(InputStream is, boolean withTag) throws IOException {
241 int codeLength = 0;
242 int subCodeLength = 0;
243 BerTag berTag = new BerTag();
244
245 if (withTag) {
246 codeLength += tag.decodeAndCheck(is);
247 }
248
249 BerLength length = new BerLength();
250 codeLength += length.decode(is);
251
252 int totalLength = length.val;
253 codeLength += totalLength;
254
255 subCodeLength += berTag.decode(is);
256 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) {
257 ecgi = new ECGI();
258 subCodeLength += ecgi.decode(is, false);
259 subCodeLength += berTag.decode(is);
260 }
261 else {
262 throw new IOException("Tag does not match the mandatory sequence element tag.");
263 }
slowr89c2ac12017-08-15 16:20:06 -0700264
slowr13fa5b02017-08-08 16:32:31 -0700265 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
266 pciArfcn = new PCIARFCN();
267 subCodeLength += pciArfcn.decode(is, false);
268 subCodeLength += berTag.decode(is);
269 }
slowr89c2ac12017-08-15 16:20:06 -0700270
slowr13fa5b02017-08-08 16:32:31 -0700271 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 2)) {
272 crnti = new CRNTI();
273 subCodeLength += crnti.decode(is, false);
slowr89c2ac12017-08-15 16:20:06 -0700274 if (subCodeLength == totalLength) {
275 return codeLength;
276 }
slowr13fa5b02017-08-08 16:32:31 -0700277 subCodeLength += berTag.decode(is);
278 }
279 else {
280 throw new IOException("Tag does not match the mandatory sequence element tag.");
281 }
slowr89c2ac12017-08-15 16:20:06 -0700282
slowr13fa5b02017-08-08 16:32:31 -0700283 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 3)) {
284 pa = new XICICPA();
285 subCodeLength += pa.decode(is, false);
slowr89c2ac12017-08-15 16:20:06 -0700286 if (subCodeLength == totalLength) {
287 return codeLength;
288 }
slowr13fa5b02017-08-08 16:32:31 -0700289 subCodeLength += berTag.decode(is);
290 }
slowr89c2ac12017-08-15 16:20:06 -0700291
slowr13fa5b02017-08-08 16:32:31 -0700292 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 4)) {
293 startPrbDl = new BerInteger();
294 subCodeLength += startPrbDl.decode(is, false);
slowr89c2ac12017-08-15 16:20:06 -0700295 if (subCodeLength == totalLength) {
296 return codeLength;
297 }
slowr13fa5b02017-08-08 16:32:31 -0700298 subCodeLength += berTag.decode(is);
299 }
slowr89c2ac12017-08-15 16:20:06 -0700300
slowr13fa5b02017-08-08 16:32:31 -0700301 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 5)) {
302 endPrbDl = new BerInteger();
303 subCodeLength += endPrbDl.decode(is, false);
slowr89c2ac12017-08-15 16:20:06 -0700304 if (subCodeLength == totalLength) {
305 return codeLength;
306 }
slowr13fa5b02017-08-08 16:32:31 -0700307 subCodeLength += berTag.decode(is);
308 }
slowr89c2ac12017-08-15 16:20:06 -0700309
slowr13fa5b02017-08-08 16:32:31 -0700310 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 6)) {
311 subframeBitmaskDl = new BerBitString();
312 subCodeLength += subframeBitmaskDl.decode(is, false);
slowr89c2ac12017-08-15 16:20:06 -0700313 if (subCodeLength == totalLength) {
314 return codeLength;
315 }
slowr13fa5b02017-08-08 16:32:31 -0700316 subCodeLength += berTag.decode(is);
317 }
slowr89c2ac12017-08-15 16:20:06 -0700318
slowr13fa5b02017-08-08 16:32:31 -0700319 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 7)) {
320 p0UePusch = new BerInteger();
321 subCodeLength += p0UePusch.decode(is, false);
slowr89c2ac12017-08-15 16:20:06 -0700322 if (subCodeLength == totalLength) {
323 return codeLength;
324 }
slowr13fa5b02017-08-08 16:32:31 -0700325 subCodeLength += berTag.decode(is);
326 }
slowr89c2ac12017-08-15 16:20:06 -0700327
slowr13fa5b02017-08-08 16:32:31 -0700328 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 8)) {
329 startPrbUl = new BerInteger();
330 subCodeLength += startPrbUl.decode(is, false);
slowr89c2ac12017-08-15 16:20:06 -0700331 if (subCodeLength == totalLength) {
332 return codeLength;
333 }
slowr13fa5b02017-08-08 16:32:31 -0700334 subCodeLength += berTag.decode(is);
335 }
slowr89c2ac12017-08-15 16:20:06 -0700336
slowr13fa5b02017-08-08 16:32:31 -0700337 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 9)) {
338 endPrbUl = new BerInteger();
339 subCodeLength += endPrbUl.decode(is, false);
slowr89c2ac12017-08-15 16:20:06 -0700340 if (subCodeLength == totalLength) {
341 return codeLength;
342 }
slowr13fa5b02017-08-08 16:32:31 -0700343 subCodeLength += berTag.decode(is);
344 }
slowr89c2ac12017-08-15 16:20:06 -0700345
slowr13fa5b02017-08-08 16:32:31 -0700346 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 10)) {
347 subframeBitmaskUl = new BerBitString();
348 subCodeLength += subframeBitmaskUl.decode(is, false);
349 if (subCodeLength == totalLength) {
350 return codeLength;
351 }
352 }
353 throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
354
slowr89c2ac12017-08-15 16:20:06 -0700355
slowr13fa5b02017-08-08 16:32:31 -0700356 }
357
358 public void encodeAndSave(int encodingSizeGuess) throws IOException {
359 BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
360 encode(os, false);
361 code = os.getArray();
362 }
363
364 public String toString() {
365 StringBuilder sb = new StringBuilder();
366 appendAsString(sb, 0);
367 return sb.toString();
368 }
369
370 public void appendAsString(StringBuilder sb, int indentLevel) {
slowr13fa5b02017-08-08 16:32:31 -0700371 sb.append("{");
372 sb.append("\n");
373 for (int i = 0; i < indentLevel + 1; i++) {
374 sb.append("\t");
375 }
376 if (ecgi != null) {
slowr8d9a4c42017-08-15 16:21:12 -0700377 sb.append("\"ecgi: \"");
slowr13fa5b02017-08-08 16:32:31 -0700378 ecgi.appendAsString(sb, indentLevel + 1);
379 }
slowr8d9a4c42017-08-15 16:21:12 -0700380
slowr13fa5b02017-08-08 16:32:31 -0700381 if (pciArfcn != null) {
slowr8d9a4c42017-08-15 16:21:12 -0700382 sb.append(",\n");
383 for (int i = 0; i < indentLevel + 1; i++) {
384 sb.append("\t");
385 }
386 sb.append("\"pciArfcn: \"");
slowr13fa5b02017-08-08 16:32:31 -0700387 pciArfcn.appendAsString(sb, indentLevel + 1);
388 }
slowr8d9a4c42017-08-15 16:21:12 -0700389
slowr13fa5b02017-08-08 16:32:31 -0700390 sb.append(",\n");
391 for (int i = 0; i < indentLevel + 1; i++) {
392 sb.append("\t");
393 }
394 if (crnti != null) {
slowr8d9a4c42017-08-15 16:21:12 -0700395 sb.append("\"crnti: \"").append(crnti);
slowr13fa5b02017-08-08 16:32:31 -0700396 }
slowr8d9a4c42017-08-15 16:21:12 -0700397
slowr13fa5b02017-08-08 16:32:31 -0700398 if (pa != null) {
slowr8d9a4c42017-08-15 16:21:12 -0700399 sb.append(",\n");
400 for (int i = 0; i < indentLevel + 1; i++) {
401 sb.append("\t");
402 }
403 sb.append("\"pa: \"").append(pa);
slowr13fa5b02017-08-08 16:32:31 -0700404 }
slowr8d9a4c42017-08-15 16:21:12 -0700405
slowr13fa5b02017-08-08 16:32:31 -0700406 if (startPrbDl != null) {
slowr8d9a4c42017-08-15 16:21:12 -0700407 sb.append(",\n");
408 for (int i = 0; i < indentLevel + 1; i++) {
409 sb.append("\t");
410 }
411 sb.append("\"startPrbDl: \"").append(startPrbDl);
slowr13fa5b02017-08-08 16:32:31 -0700412 }
slowr8d9a4c42017-08-15 16:21:12 -0700413
slowr13fa5b02017-08-08 16:32:31 -0700414 if (endPrbDl != null) {
slowr8d9a4c42017-08-15 16:21:12 -0700415 sb.append(",\n");
416 for (int i = 0; i < indentLevel + 1; i++) {
417 sb.append("\t");
418 }
419 sb.append("\"endPrbDl: \"").append(endPrbDl);
slowr13fa5b02017-08-08 16:32:31 -0700420 }
slowr8d9a4c42017-08-15 16:21:12 -0700421
slowr13fa5b02017-08-08 16:32:31 -0700422 if (subframeBitmaskDl != null) {
slowr8d9a4c42017-08-15 16:21:12 -0700423 sb.append(",\n");
424 for (int i = 0; i < indentLevel + 1; i++) {
425 sb.append("\t");
426 }
427 sb.append("\"subframeBitmaskDl: \"").append(subframeBitmaskDl);
slowr13fa5b02017-08-08 16:32:31 -0700428 }
slowr8d9a4c42017-08-15 16:21:12 -0700429
slowr13fa5b02017-08-08 16:32:31 -0700430 if (p0UePusch != null) {
slowr8d9a4c42017-08-15 16:21:12 -0700431 sb.append(",\n");
432 for (int i = 0; i < indentLevel + 1; i++) {
433 sb.append("\t");
434 }
435 sb.append("\"p0UePusch: \"").append(p0UePusch);
slowr13fa5b02017-08-08 16:32:31 -0700436 }
slowr8d9a4c42017-08-15 16:21:12 -0700437
slowr13fa5b02017-08-08 16:32:31 -0700438 if (startPrbUl != null) {
slowr8d9a4c42017-08-15 16:21:12 -0700439 sb.append(",\n");
440 for (int i = 0; i < indentLevel + 1; i++) {
441 sb.append("\t");
442 }
443 sb.append("\"startPrbUl: \"").append(startPrbUl);
slowr13fa5b02017-08-08 16:32:31 -0700444 }
slowr8d9a4c42017-08-15 16:21:12 -0700445
slowr13fa5b02017-08-08 16:32:31 -0700446 if (endPrbUl != null) {
slowr8d9a4c42017-08-15 16:21:12 -0700447 sb.append(",\n");
448 for (int i = 0; i < indentLevel + 1; i++) {
449 sb.append("\t");
450 }
451 sb.append("\"endPrbUl: \"").append(endPrbUl);
slowr13fa5b02017-08-08 16:32:31 -0700452 }
slowr8d9a4c42017-08-15 16:21:12 -0700453
slowr13fa5b02017-08-08 16:32:31 -0700454 if (subframeBitmaskUl != null) {
slowr8d9a4c42017-08-15 16:21:12 -0700455 sb.append(",\n");
456 for (int i = 0; i < indentLevel + 1; i++) {
457 sb.append("\t");
458 }
459 sb.append("\"subframeBitmaskUl: \"").append(subframeBitmaskUl);
slowr13fa5b02017-08-08 16:32:31 -0700460 }
slowr8d9a4c42017-08-15 16:21:12 -0700461
slowr13fa5b02017-08-08 16:32:31 -0700462 sb.append("\n");
463 for (int i = 0; i < indentLevel; i++) {
464 sb.append("\t");
465 }
466 sb.append("}");
467 }
468
slowr8ddc2b12017-08-14 14:13:38 -0700469 public static XrancPdu constructPacket(RRMConfig config) {
470 XrancPduBody body = new XrancPduBody();
slowr7c0e1672017-08-15 17:09:14 -0700471
472 XICICConfig xicicConfig = new XICICConfig();
473
474 xicicConfig.setCrnti(config.getCrnti().getCRNTI().get(0));
475 xicicConfig.setEcgi(config.getEcgi());
476
477 try {
478 xicicConfig.setEndPrbDl(config.getEndPrbDl().getSeqOf().get(0));
479 } catch (Exception ignored) {}
480
481 try {
482 xicicConfig.setEndPrbUl(config.getEndPrbUl().getSeqOf().get(0));
483 } catch (Exception ignored) {}
484
485 try {
486 xicicConfig.setStartPrbDl(config.getStartPrbDl().getSeqOf().get(0));
487 } catch (Exception ignored) {}
488
489 try {
490 xicicConfig.setEndPrbUl(config.getStartPrbUl().getSeqOf().get(0));
491 } catch (Exception ignored) {}
492
493 body.setXICICConfig(xicicConfig);
slowr8ddc2b12017-08-14 14:13:38 -0700494
495 BerUTF8String ver = null;
496 try {
497 ver = new BerUTF8String("3");
498 } catch (UnsupportedEncodingException e) {
499 e.printStackTrace();
500 }
501
502 XrancApiID apiID = new XrancApiID(23);
503 XrancPduHdr hdr = new XrancPduHdr();
504 hdr.setVer(ver);
505 hdr.setApiId(apiID);
506
507 XrancPdu pdu = new XrancPdu();
508 pdu.setHdr(hdr);
509 pdu.setBody(body);
510 return pdu;
511 }
slowr13fa5b02017-08-08 16:32:31 -0700512}
513