blob: a17b221e9183d82f0b449e86f4e1b6c6215af888 [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;
slowr13fa5b02017-08-08 16:32:31 -07006
slowr60d4d102017-08-16 18:33:58 -07007import com.fasterxml.jackson.annotation.JsonIgnore;
8import com.fasterxml.jackson.annotation.JsonValue;
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -08009import org.onosproject.xran.asn1lib.api.CRNTI;
10import org.onosproject.xran.asn1lib.api.ECGI;
11import org.onosproject.xran.asn1lib.api.PCIARFCN;
12import org.onosproject.xran.asn1lib.ber.BerByteArrayOutputStream;
13import org.onosproject.xran.asn1lib.ber.BerLength;
14import org.onosproject.xran.asn1lib.ber.BerTag;
15import org.onosproject.xran.asn1lib.ber.types.string.BerUTF8String;
slowr13fa5b02017-08-08 16:32:31 -070016
17import java.io.IOException;
18import java.io.InputStream;
19import java.io.Serializable;
slowr89c2ac12017-08-15 16:20:06 -070020import java.io.UnsupportedEncodingException;
slowr13fa5b02017-08-08 16:32:31 -070021import java.util.ArrayList;
22import java.util.Iterator;
23import java.util.List;
24
25public class ScellDelete implements Serializable {
26
slowr89c2ac12017-08-15 16:20:06 -070027 public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
28 private static final long serialVersionUID = 1L;
slowr60d4d102017-08-16 18:33:58 -070029 @JsonIgnore
slowr89c2ac12017-08-15 16:20:06 -070030 public byte[] code = null;
31 private CRNTI crnti = null;
32 private ECGI ecgi = null;
33 private ScellsInd scellsInd = null;
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -080034
slowr89c2ac12017-08-15 16:20:06 -070035 public ScellDelete() {
36 }
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -080037
slowr89c2ac12017-08-15 16:20:06 -070038 public ScellDelete(byte[] code) {
39 this.code = code;
40 }
slowr13fa5b02017-08-08 16:32:31 -070041
slowr89c2ac12017-08-15 16:20:06 -070042 public static XrancPdu constructPacket(ECGI ecgi, CRNTI crnti, PCIARFCN pciarfcn) {
43 ScellDelete scellDelete = new ScellDelete();
44 scellDelete.setEcgi(ecgi);
45 scellDelete.setCrnti(crnti);
46 ScellsInd scellsInd = new ScellsInd();
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -080047 scellsInd.getPCIARFCN().add(pciarfcn);
slowr89c2ac12017-08-15 16:20:06 -070048 scellDelete.setScellsInd(scellsInd);
slowr13fa5b02017-08-08 16:32:31 -070049
slowr89c2ac12017-08-15 16:20:06 -070050 BerUTF8String ver = null;
51 try {
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -080052 ver = new BerUTF8String("5");
slowr89c2ac12017-08-15 16:20:06 -070053 } catch (UnsupportedEncodingException e) {
54 e.printStackTrace();
55 }
slowr13fa5b02017-08-08 16:32:31 -070056
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -080057 XrancApiID apiID = new XrancApiID(26);
slowr89c2ac12017-08-15 16:20:06 -070058 XrancPduBody body = new XrancPduBody();
59 body.setScellDelete(scellDelete);
slowr13fa5b02017-08-08 16:32:31 -070060
slowr89c2ac12017-08-15 16:20:06 -070061 XrancPduHdr hdr = new XrancPduHdr();
62 hdr.setVer(ver);
63 hdr.setApiId(apiID);
slowr13fa5b02017-08-08 16:32:31 -070064
slowr89c2ac12017-08-15 16:20:06 -070065 XrancPdu pdu = new XrancPdu();
66 pdu.setBody(body);
67 pdu.setHdr(hdr);
slowr13fa5b02017-08-08 16:32:31 -070068
slowr89c2ac12017-08-15 16:20:06 -070069 return pdu;
slowr89c2ac12017-08-15 16:20:06 -070070 }
slowr13fa5b02017-08-08 16:32:31 -070071
slowr89c2ac12017-08-15 16:20:06 -070072 public CRNTI getCrnti() {
73 return crnti;
74 }
slowr13fa5b02017-08-08 16:32:31 -070075
slowr89c2ac12017-08-15 16:20:06 -070076 public void setCrnti(CRNTI crnti) {
77 this.crnti = crnti;
78 }
slowr13fa5b02017-08-08 16:32:31 -070079
slowr89c2ac12017-08-15 16:20:06 -070080 public ECGI getEcgi() {
81 return ecgi;
82 }
slowr13fa5b02017-08-08 16:32:31 -070083
slowr89c2ac12017-08-15 16:20:06 -070084 public void setEcgi(ECGI ecgi) {
85 this.ecgi = ecgi;
86 }
slowr13fa5b02017-08-08 16:32:31 -070087
slowr89c2ac12017-08-15 16:20:06 -070088 public ScellsInd getScellsInd() {
89 return scellsInd;
90 }
slowr13fa5b02017-08-08 16:32:31 -070091
slowr89c2ac12017-08-15 16:20:06 -070092 public void setScellsInd(ScellsInd scellsInd) {
93 this.scellsInd = scellsInd;
94 }
slowr13fa5b02017-08-08 16:32:31 -070095
slowr89c2ac12017-08-15 16:20:06 -070096 public int encode(BerByteArrayOutputStream os) throws IOException {
97 return encode(os, true);
98 }
slowr13fa5b02017-08-08 16:32:31 -070099
slowr89c2ac12017-08-15 16:20:06 -0700100 public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
slowr13fa5b02017-08-08 16:32:31 -0700101
slowr89c2ac12017-08-15 16:20:06 -0700102 if (code != null) {
103 for (int i = code.length - 1; i >= 0; i--) {
104 os.write(code[i]);
105 }
106 if (withTag) {
107 return tag.encode(os) + code.length;
108 }
109 return code.length;
110 }
slowr13fa5b02017-08-08 16:32:31 -0700111
slowr89c2ac12017-08-15 16:20:06 -0700112 int codeLength = 0;
113 codeLength += scellsInd.encode(os, false);
114 // write tag: CONTEXT_CLASS, CONSTRUCTED, 2
115 os.write(0xA2);
116 codeLength += 1;
slowr13fa5b02017-08-08 16:32:31 -0700117
slowr89c2ac12017-08-15 16:20:06 -0700118 codeLength += ecgi.encode(os, false);
119 // write tag: CONTEXT_CLASS, CONSTRUCTED, 1
120 os.write(0xA1);
121 codeLength += 1;
slowr13fa5b02017-08-08 16:32:31 -0700122
slowr89c2ac12017-08-15 16:20:06 -0700123 codeLength += crnti.encode(os, false);
124 // write tag: CONTEXT_CLASS, PRIMITIVE, 0
125 os.write(0x80);
126 codeLength += 1;
slowr13fa5b02017-08-08 16:32:31 -0700127
slowr89c2ac12017-08-15 16:20:06 -0700128 codeLength += BerLength.encodeLength(os, codeLength);
slowr13fa5b02017-08-08 16:32:31 -0700129
slowr89c2ac12017-08-15 16:20:06 -0700130 if (withTag) {
131 codeLength += tag.encode(os);
132 }
slowr13fa5b02017-08-08 16:32:31 -0700133
slowr89c2ac12017-08-15 16:20:06 -0700134 return codeLength;
slowr13fa5b02017-08-08 16:32:31 -0700135
slowr89c2ac12017-08-15 16:20:06 -0700136 }
137
138 public int decode(InputStream is) throws IOException {
139 return decode(is, true);
140 }
141
142 public int decode(InputStream is, boolean withTag) throws IOException {
143 int codeLength = 0;
144 int subCodeLength = 0;
145 BerTag berTag = new BerTag();
146
147 if (withTag) {
148 codeLength += tag.decodeAndCheck(is);
149 }
150
151 BerLength length = new BerLength();
152 codeLength += length.decode(is);
153
154 int totalLength = length.val;
155 codeLength += totalLength;
156
157 subCodeLength += berTag.decode(is);
158 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
159 crnti = new CRNTI();
160 subCodeLength += crnti.decode(is, false);
161 subCodeLength += berTag.decode(is);
162 } else {
163 throw new IOException("Tag does not match the mandatory sequence element tag.");
164 }
165
166 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
167 ecgi = new ECGI();
168 subCodeLength += ecgi.decode(is, false);
169 subCodeLength += berTag.decode(is);
170 } else {
171 throw new IOException("Tag does not match the mandatory sequence element tag.");
172 }
173
174 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) {
175 scellsInd = new ScellsInd();
176 subCodeLength += scellsInd.decode(is, false);
177 if (subCodeLength == totalLength) {
178 return codeLength;
179 }
180 }
181 throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
182
183
184 }
185
186 public void encodeAndSave(int encodingSizeGuess) throws IOException {
187 BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
188 encode(os, false);
189 code = os.getArray();
190 }
191
192 public String toString() {
193 StringBuilder sb = new StringBuilder();
194 appendAsString(sb, 0);
195 return sb.toString();
196 }
197
198 public void appendAsString(StringBuilder sb, int indentLevel) {
199
200 sb.append("{");
201 sb.append("\n");
202 for (int i = 0; i < indentLevel + 1; i++) {
203 sb.append("\t");
204 }
205 if (crnti != null) {
slowr60d4d102017-08-16 18:33:58 -0700206 sb.append("crnti: ").append(crnti);
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -0800207 } else {
208 sb.append("crnti: <empty-required-field>");
slowr89c2ac12017-08-15 16:20:06 -0700209 }
210
211 sb.append(",\n");
212 for (int i = 0; i < indentLevel + 1; i++) {
213 sb.append("\t");
214 }
215 if (ecgi != null) {
slowr60d4d102017-08-16 18:33:58 -0700216 sb.append("ecgi: ");
slowr89c2ac12017-08-15 16:20:06 -0700217 ecgi.appendAsString(sb, indentLevel + 1);
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -0800218 } else {
219 sb.append("ecgi: <empty-required-field>");
slowr89c2ac12017-08-15 16:20:06 -0700220 }
221
222 sb.append(",\n");
223 for (int i = 0; i < indentLevel + 1; i++) {
224 sb.append("\t");
225 }
226 if (scellsInd != null) {
slowr60d4d102017-08-16 18:33:58 -0700227 sb.append("scellsInd: ");
slowr89c2ac12017-08-15 16:20:06 -0700228 scellsInd.appendAsString(sb, indentLevel + 1);
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -0800229 } else {
230 sb.append("scellsInd: <empty-required-field>");
slowr89c2ac12017-08-15 16:20:06 -0700231 }
232
233 sb.append("\n");
234 for (int i = 0; i < indentLevel; i++) {
235 sb.append("\t");
236 }
237 sb.append("}");
238 }
239
240 public static class ScellsInd implements Serializable {
241
242 public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
243 private static final long serialVersionUID = 1L;
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -0800244 @JsonIgnore
245 public byte[] code = null;
slowr89c2ac12017-08-15 16:20:06 -0700246 private List<PCIARFCN> seqOf = null;
247
248 public ScellsInd() {
249 seqOf = new ArrayList<PCIARFCN>();
250 }
251
252 public ScellsInd(byte[] code) {
253 this.code = code;
254 }
255
slowr60d4d102017-08-16 18:33:58 -0700256 @JsonValue
slowr89c2ac12017-08-15 16:20:06 -0700257 public List<PCIARFCN> getPCIARFCN() {
258 if (seqOf == null) {
259 seqOf = new ArrayList<PCIARFCN>();
260 }
261 return seqOf;
262 }
263
264 public int encode(BerByteArrayOutputStream os) throws IOException {
265 return encode(os, true);
266 }
267
268 public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
269
270 if (code != null) {
271 for (int i = code.length - 1; i >= 0; i--) {
272 os.write(code[i]);
273 }
274 if (withTag) {
275 return tag.encode(os) + code.length;
276 }
277 return code.length;
278 }
279
280 int codeLength = 0;
281 for (int i = (seqOf.size() - 1); i >= 0; i--) {
282 codeLength += seqOf.get(i).encode(os, true);
283 }
284
285 codeLength += BerLength.encodeLength(os, codeLength);
286
287 if (withTag) {
288 codeLength += tag.encode(os);
289 }
290
291 return codeLength;
292 }
293
294 public int decode(InputStream is) throws IOException {
295 return decode(is, true);
296 }
297
298 public int decode(InputStream is, boolean withTag) throws IOException {
299 int codeLength = 0;
300 int subCodeLength = 0;
301 if (withTag) {
302 codeLength += tag.decodeAndCheck(is);
303 }
304
305 BerLength length = new BerLength();
306 codeLength += length.decode(is);
307 int totalLength = length.val;
308
309 while (subCodeLength < totalLength) {
310 PCIARFCN element = new PCIARFCN();
311 subCodeLength += element.decode(is, true);
312 seqOf.add(element);
313 }
314 if (subCodeLength != totalLength) {
315 throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength);
316
317 }
318 codeLength += subCodeLength;
319
320 return codeLength;
321 }
322
323 public void encodeAndSave(int encodingSizeGuess) throws IOException {
324 BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
325 encode(os, false);
326 code = os.getArray();
327 }
328
329 public String toString() {
330 StringBuilder sb = new StringBuilder();
331 appendAsString(sb, 0);
332 return sb.toString();
333 }
334
335 public void appendAsString(StringBuilder sb, int indentLevel) {
336
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -0800337 sb.append("{\n");
slowr89c2ac12017-08-15 16:20:06 -0700338 for (int i = 0; i < indentLevel + 1; i++) {
339 sb.append("\t");
340 }
341 if (seqOf == null) {
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -0800342 sb.append("null");
slowr89c2ac12017-08-15 16:20:06 -0700343 } else {
344 Iterator<PCIARFCN> it = seqOf.iterator();
345 if (it.hasNext()) {
346 it.next().appendAsString(sb, indentLevel + 1);
347 while (it.hasNext()) {
348 sb.append(",\n");
349 for (int i = 0; i < indentLevel + 1; i++) {
350 sb.append("\t");
351 }
352 it.next().appendAsString(sb, indentLevel + 1);
353 }
354 }
355 }
slowr13fa5b02017-08-08 16:32:31 -0700356
slowr89c2ac12017-08-15 16:20:06 -0700357 sb.append("\n");
358 for (int i = 0; i < indentLevel; i++) {
359 sb.append("\t");
360 }
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -0800361 sb.append("}");
slowr89c2ac12017-08-15 16:20:06 -0700362 }
slowr13fa5b02017-08-08 16:32:31 -0700363
slowr89c2ac12017-08-15 16:20:06 -0700364 }
slowr13fa5b02017-08-08 16:32:31 -0700365
366}
367