blob: 16f00d0b5022c4ef919cb4b04bb825e65b98877f [file] [log] [blame]
slowr13fa5b02017-08-08 16:32:31 -07001/**
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -08002 * This class file was automatically generated by jASN1 v1.8.2 (http://www.openmuc.org)
slowr13fa5b02017-08-08 16:32:31 -07003 */
4
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -08005package org.onosproject.xran.asn1lib.pdu;
6
slowr13fa5b02017-08-08 16:32:31 -07007
slowr60d4d102017-08-16 18:33:58 -07008import com.fasterxml.jackson.annotation.JsonIgnore;
9import com.fasterxml.jackson.annotation.JsonValue;
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -080010import org.onosproject.xran.asn1lib.api.CRNTI;
11import org.onosproject.xran.asn1lib.api.ECGI;
12import org.onosproject.xran.asn1lib.api.L2MeasReportInterval;
13import org.onosproject.xran.asn1lib.api.L2ReportInterval;
14import org.onosproject.xran.asn1lib.ber.BerByteArrayOutputStream;
15import org.onosproject.xran.asn1lib.ber.BerLength;
16import org.onosproject.xran.asn1lib.ber.BerTag;
17import org.onosproject.xran.asn1lib.ber.types.string.BerUTF8String;
slowr13fa5b02017-08-08 16:32:31 -070018
19import java.io.IOException;
20import java.io.InputStream;
21import java.io.Serializable;
slowr89c2ac12017-08-15 16:20:06 -070022import java.io.UnsupportedEncodingException;
slowr13fa5b02017-08-08 16:32:31 -070023import java.util.ArrayList;
24import java.util.Iterator;
25import java.util.List;
26
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -080027public class L2MeasConfig implements Serializable {
slowr13fa5b02017-08-08 16:32:31 -070028
slowr89c2ac12017-08-15 16:20:06 -070029 public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
30 private static final long serialVersionUID = 1L;
slowr60d4d102017-08-16 18:33:58 -070031 @JsonIgnore
slowr89c2ac12017-08-15 16:20:06 -070032 public byte[] code = null;
slowr89c2ac12017-08-15 16:20:06 -070033 private ECGI ecgi = null;
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -080034 private Crnti crnti = null;
35 private L2ReportInterval reportIntervals = null;
36
37 public L2MeasConfig() {
slowr89c2ac12017-08-15 16:20:06 -070038 }
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -080039
40 public L2MeasConfig(byte[] code) {
slowr89c2ac12017-08-15 16:20:06 -070041 this.code = code;
42 }
slowr13fa5b02017-08-08 16:32:31 -070043
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -080044 public static XrancPdu constructPacket(ECGI ecgi, int l2MeasInterval) {
45 L2MeasConfig measConfig = new L2MeasConfig();
46 measConfig.setEcgi(ecgi);
47
48 L2ReportInterval l2ReportInterval = new L2ReportInterval();
49 L2MeasReportInterval l2MeasReportInterval = new L2MeasReportInterval(l2MeasInterval);
50 l2ReportInterval.setTPdcpMeasReportPerUe(l2MeasReportInterval);
51 l2ReportInterval.setTRadioMeasReportPerCell(l2MeasReportInterval);
52 l2ReportInterval.setTRadioMeasReportPerUe(l2MeasReportInterval);
53 l2ReportInterval.setTRadioSchedReportPerUe(l2MeasReportInterval);
54 l2ReportInterval.setTRadioSchedReportPerCell(l2MeasReportInterval);
55
56 measConfig.setReportIntervals(l2ReportInterval);
slowr13fa5b02017-08-08 16:32:31 -070057
slowr89c2ac12017-08-15 16:20:06 -070058 BerUTF8String ver = null;
59 try {
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -080060 ver = new BerUTF8String("5");
slowr89c2ac12017-08-15 16:20:06 -070061 } catch (UnsupportedEncodingException e) {
62 e.printStackTrace();
63 }
slowr13fa5b02017-08-08 16:32:31 -070064
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -080065 XrancApiID apiID = new XrancApiID(16);
slowr89c2ac12017-08-15 16:20:06 -070066 XrancPduBody body = new XrancPduBody();
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -080067 body.setL2MeasConfig(measConfig);
slowr13fa5b02017-08-08 16:32:31 -070068
slowr89c2ac12017-08-15 16:20:06 -070069 XrancPduHdr hdr = new XrancPduHdr();
70 hdr.setVer(ver);
71 hdr.setApiId(apiID);
slowr13fa5b02017-08-08 16:32:31 -070072
slowr89c2ac12017-08-15 16:20:06 -070073 XrancPdu pdu = new XrancPdu();
74 pdu.setBody(body);
75 pdu.setHdr(hdr);
slowr13fa5b02017-08-08 16:32:31 -070076
slowr89c2ac12017-08-15 16:20:06 -070077 return pdu;
slowr13fa5b02017-08-08 16:32:31 -070078
slowr89c2ac12017-08-15 16:20:06 -070079 }
slowr13fa5b02017-08-08 16:32:31 -070080
slowr89c2ac12017-08-15 16:20:06 -070081 public ECGI getEcgi() {
82 return ecgi;
83 }
slowr13fa5b02017-08-08 16:32:31 -070084
slowr89c2ac12017-08-15 16:20:06 -070085 public void setEcgi(ECGI ecgi) {
86 this.ecgi = ecgi;
87 }
slowr13fa5b02017-08-08 16:32:31 -070088
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -080089 public Crnti getCrnti() {
90 return crnti;
slowr89c2ac12017-08-15 16:20:06 -070091 }
slowr13fa5b02017-08-08 16:32:31 -070092
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -080093 public void setCrnti(Crnti crnti) {
94 this.crnti = crnti;
95 }
96
97 public L2ReportInterval getReportIntervals() {
98 return reportIntervals;
99 }
100
101 public void setReportIntervals(L2ReportInterval reportIntervals) {
102 this.reportIntervals = reportIntervals;
slowr89c2ac12017-08-15 16:20:06 -0700103 }
slowr13fa5b02017-08-08 16:32:31 -0700104
slowr89c2ac12017-08-15 16:20:06 -0700105 public int encode(BerByteArrayOutputStream os) throws IOException {
106 return encode(os, true);
107 }
slowr13fa5b02017-08-08 16:32:31 -0700108
slowr89c2ac12017-08-15 16:20:06 -0700109 public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
slowr13fa5b02017-08-08 16:32:31 -0700110
slowr89c2ac12017-08-15 16:20:06 -0700111 if (code != null) {
112 for (int i = code.length - 1; i >= 0; i--) {
113 os.write(code[i]);
114 }
115 if (withTag) {
116 return tag.encode(os) + code.length;
117 }
118 return code.length;
119 }
slowr13fa5b02017-08-08 16:32:31 -0700120
slowr89c2ac12017-08-15 16:20:06 -0700121 int codeLength = 0;
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -0800122 codeLength += reportIntervals.encode(os, false);
slowr89c2ac12017-08-15 16:20:06 -0700123 // write tag: CONTEXT_CLASS, CONSTRUCTED, 2
124 os.write(0xA2);
125 codeLength += 1;
slowr13fa5b02017-08-08 16:32:31 -0700126
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -0800127 if (crnti != null) {
128 codeLength += crnti.encode(os, false);
129 // write tag: CONTEXT_CLASS, CONSTRUCTED, 1
130 os.write(0xA1);
131 codeLength += 1;
132 }
slowr13fa5b02017-08-08 16:32:31 -0700133
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -0800134 codeLength += ecgi.encode(os, false);
135 // write tag: CONTEXT_CLASS, CONSTRUCTED, 0
136 os.write(0xA0);
slowr89c2ac12017-08-15 16:20:06 -0700137 codeLength += 1;
slowr13fa5b02017-08-08 16:32:31 -0700138
slowr89c2ac12017-08-15 16:20:06 -0700139 codeLength += BerLength.encodeLength(os, codeLength);
slowr13fa5b02017-08-08 16:32:31 -0700140
slowr89c2ac12017-08-15 16:20:06 -0700141 if (withTag) {
142 codeLength += tag.encode(os);
143 }
slowr13fa5b02017-08-08 16:32:31 -0700144
slowr89c2ac12017-08-15 16:20:06 -0700145 return codeLength;
slowr13fa5b02017-08-08 16:32:31 -0700146
slowr89c2ac12017-08-15 16:20:06 -0700147 }
148
149 public int decode(InputStream is) throws IOException {
150 return decode(is, true);
151 }
152
153 public int decode(InputStream is, boolean withTag) throws IOException {
154 int codeLength = 0;
155 int subCodeLength = 0;
156 BerTag berTag = new BerTag();
157
158 if (withTag) {
159 codeLength += tag.decodeAndCheck(is);
160 }
161
162 BerLength length = new BerLength();
163 codeLength += length.decode(is);
164
165 int totalLength = length.val;
166 codeLength += totalLength;
167
168 subCodeLength += berTag.decode(is);
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -0800169 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) {
slowr89c2ac12017-08-15 16:20:06 -0700170 ecgi = new ECGI();
171 subCodeLength += ecgi.decode(is, false);
172 subCodeLength += berTag.decode(is);
173 } else {
174 throw new IOException("Tag does not match the mandatory sequence element tag.");
175 }
176
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -0800177 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
178 crnti = new Crnti();
179 subCodeLength += crnti.decode(is, false);
180 subCodeLength += berTag.decode(is);
181 }
182
slowr89c2ac12017-08-15 16:20:06 -0700183 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) {
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -0800184 reportIntervals = new L2ReportInterval();
185 subCodeLength += reportIntervals.decode(is, false);
slowr89c2ac12017-08-15 16:20:06 -0700186 if (subCodeLength == totalLength) {
187 return codeLength;
188 }
189 }
190 throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
191
192
193 }
194
195 public void encodeAndSave(int encodingSizeGuess) throws IOException {
196 BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
197 encode(os, false);
198 code = os.getArray();
199 }
200
201 public String toString() {
202 StringBuilder sb = new StringBuilder();
203 appendAsString(sb, 0);
204 return sb.toString();
205 }
206
207 public void appendAsString(StringBuilder sb, int indentLevel) {
208
209 sb.append("{");
210 sb.append("\n");
211 for (int i = 0; i < indentLevel + 1; i++) {
212 sb.append("\t");
213 }
slowr89c2ac12017-08-15 16:20:06 -0700214 if (ecgi != null) {
slowr60d4d102017-08-16 18:33:58 -0700215 sb.append("ecgi: ");
slowr89c2ac12017-08-15 16:20:06 -0700216 ecgi.appendAsString(sb, indentLevel + 1);
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -0800217 } else {
218 sb.append("ecgi: <empty-required-field>");
219 }
220
221 if (crnti != null) {
222 sb.append(",\n");
223 for (int i = 0; i < indentLevel + 1; i++) {
224 sb.append("\t");
225 }
226 sb.append("crnti: ");
227 crnti.appendAsString(sb, indentLevel + 1);
slowr89c2ac12017-08-15 16:20:06 -0700228 }
229
230 sb.append(",\n");
231 for (int i = 0; i < indentLevel + 1; i++) {
232 sb.append("\t");
233 }
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -0800234 if (reportIntervals != null) {
235 sb.append("reportIntervals: ");
236 reportIntervals.appendAsString(sb, indentLevel + 1);
237 } else {
238 sb.append("reportIntervals: <empty-required-field>");
slowr89c2ac12017-08-15 16:20:06 -0700239 }
240
241 sb.append("\n");
242 for (int i = 0; i < indentLevel; i++) {
243 sb.append("\t");
244 }
245 sb.append("}");
246 }
247
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -0800248 public static class Crnti implements Serializable {
slowr89c2ac12017-08-15 16:20:06 -0700249
250 public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
251 private static final long serialVersionUID = 1L;
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -0800252 @JsonIgnore
253 public byte[] code = null;
254 private List<CRNTI> seqOf = null;
slowr89c2ac12017-08-15 16:20:06 -0700255
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -0800256 public Crnti() {
257 seqOf = new ArrayList<CRNTI>();
slowr89c2ac12017-08-15 16:20:06 -0700258 }
259
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -0800260 public Crnti(byte[] code) {
slowr89c2ac12017-08-15 16:20:06 -0700261 this.code = code;
262 }
263
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -0800264
slowr60d4d102017-08-16 18:33:58 -0700265 @JsonValue
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -0800266 public List<CRNTI> getCRNTI() {
slowr89c2ac12017-08-15 16:20:06 -0700267 if (seqOf == null) {
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -0800268 seqOf = new ArrayList<CRNTI>();
slowr89c2ac12017-08-15 16:20:06 -0700269 }
270 return seqOf;
271 }
272
273 public int encode(BerByteArrayOutputStream os) throws IOException {
274 return encode(os, true);
275 }
276
277 public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
278
279 if (code != null) {
280 for (int i = code.length - 1; i >= 0; i--) {
281 os.write(code[i]);
282 }
283 if (withTag) {
284 return tag.encode(os) + code.length;
285 }
286 return code.length;
287 }
288
289 int codeLength = 0;
290 for (int i = (seqOf.size() - 1); i >= 0; i--) {
291 codeLength += seqOf.get(i).encode(os, true);
292 }
293
294 codeLength += BerLength.encodeLength(os, codeLength);
295
296 if (withTag) {
297 codeLength += tag.encode(os);
298 }
299
300 return codeLength;
301 }
302
303 public int decode(InputStream is) throws IOException {
304 return decode(is, true);
305 }
306
307 public int decode(InputStream is, boolean withTag) throws IOException {
308 int codeLength = 0;
309 int subCodeLength = 0;
310 if (withTag) {
311 codeLength += tag.decodeAndCheck(is);
312 }
313
314 BerLength length = new BerLength();
315 codeLength += length.decode(is);
316 int totalLength = length.val;
317
318 while (subCodeLength < totalLength) {
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -0800319 CRNTI element = new CRNTI();
slowr89c2ac12017-08-15 16:20:06 -0700320 subCodeLength += element.decode(is, true);
321 seqOf.add(element);
322 }
323 if (subCodeLength != totalLength) {
324 throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength);
325
326 }
327 codeLength += subCodeLength;
328
329 return codeLength;
330 }
331
332 public void encodeAndSave(int encodingSizeGuess) throws IOException {
333 BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
334 encode(os, false);
335 code = os.getArray();
336 }
337
338 public String toString() {
339 StringBuilder sb = new StringBuilder();
340 appendAsString(sb, 0);
341 return sb.toString();
342 }
343
344 public void appendAsString(StringBuilder sb, int indentLevel) {
345
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -0800346 sb.append("{\n");
slowr89c2ac12017-08-15 16:20:06 -0700347 for (int i = 0; i < indentLevel + 1; i++) {
348 sb.append("\t");
349 }
350 if (seqOf == null) {
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -0800351 sb.append("null");
slowr89c2ac12017-08-15 16:20:06 -0700352 } else {
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -0800353 Iterator<CRNTI> it = seqOf.iterator();
slowr89c2ac12017-08-15 16:20:06 -0700354 if (it.hasNext()) {
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -0800355 sb.append(it.next());
slowr89c2ac12017-08-15 16:20:06 -0700356 while (it.hasNext()) {
357 sb.append(",\n");
358 for (int i = 0; i < indentLevel + 1; i++) {
359 sb.append("\t");
360 }
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -0800361 sb.append(it.next());
slowr89c2ac12017-08-15 16:20:06 -0700362 }
363 }
364 }
slowr13fa5b02017-08-08 16:32:31 -0700365
slowr89c2ac12017-08-15 16:20:06 -0700366 sb.append("\n");
367 for (int i = 0; i < indentLevel; i++) {
368 sb.append("\t");
369 }
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -0800370 sb.append("}");
slowr89c2ac12017-08-15 16:20:06 -0700371 }
slowr13fa5b02017-08-08 16:32:31 -0700372
slowr89c2ac12017-08-15 16:20:06 -0700373 }
slowr13fa5b02017-08-08 16:32:31 -0700374
375}
376