blob: 6080f6968d4926aa5b381ef7ec62dbea326be1a5 [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.CRNTI;
10import org.onosproject.xran.codecs.api.ECGI;
11import org.onosproject.xran.codecs.api.PCIARFCN;
slowr60d4d102017-08-16 18:33:58 -070012import org.onosproject.xran.codecs.ber.BerByteArrayOutputStream;
13import org.onosproject.xran.codecs.ber.BerLength;
14import org.onosproject.xran.codecs.ber.BerTag;
15import org.onosproject.xran.codecs.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;
34 public ScellDelete() {
35 }
36 public ScellDelete(byte[] code) {
37 this.code = code;
38 }
slowr13fa5b02017-08-08 16:32:31 -070039
slowr89c2ac12017-08-15 16:20:06 -070040 public static XrancPdu constructPacket(ECGI ecgi, CRNTI crnti, PCIARFCN pciarfcn) {
41 ScellDelete scellDelete = new ScellDelete();
42 scellDelete.setEcgi(ecgi);
43 scellDelete.setCrnti(crnti);
44 ScellsInd scellsInd = new ScellsInd();
45 scellsInd.addPCIARFCN(pciarfcn);
46 scellDelete.setScellsInd(scellsInd);
slowr13fa5b02017-08-08 16:32:31 -070047
slowr89c2ac12017-08-15 16:20:06 -070048 BerUTF8String ver = null;
49 try {
50 ver = new BerUTF8String("3");
51 } catch (UnsupportedEncodingException e) {
52 e.printStackTrace();
53 }
slowr13fa5b02017-08-08 16:32:31 -070054
slowr89c2ac12017-08-15 16:20:06 -070055 XrancApiID apiID = new XrancApiID(28);
56 XrancPduBody body = new XrancPduBody();
57 body.setScellDelete(scellDelete);
slowr13fa5b02017-08-08 16:32:31 -070058
slowr89c2ac12017-08-15 16:20:06 -070059 XrancPduHdr hdr = new XrancPduHdr();
60 hdr.setVer(ver);
61 hdr.setApiId(apiID);
slowr13fa5b02017-08-08 16:32:31 -070062
slowr89c2ac12017-08-15 16:20:06 -070063 XrancPdu pdu = new XrancPdu();
64 pdu.setBody(body);
65 pdu.setHdr(hdr);
slowr13fa5b02017-08-08 16:32:31 -070066
slowr89c2ac12017-08-15 16:20:06 -070067 return pdu;
slowr13fa5b02017-08-08 16:32:31 -070068
slowr89c2ac12017-08-15 16:20:06 -070069 }
slowr13fa5b02017-08-08 16:32:31 -070070
slowr89c2ac12017-08-15 16:20:06 -070071 public CRNTI getCrnti() {
72 return crnti;
73 }
slowr13fa5b02017-08-08 16:32:31 -070074
slowr89c2ac12017-08-15 16:20:06 -070075 public void setCrnti(CRNTI crnti) {
76 this.crnti = crnti;
77 }
slowr13fa5b02017-08-08 16:32:31 -070078
slowr89c2ac12017-08-15 16:20:06 -070079 public ECGI getEcgi() {
80 return ecgi;
81 }
slowr13fa5b02017-08-08 16:32:31 -070082
slowr89c2ac12017-08-15 16:20:06 -070083 public void setEcgi(ECGI ecgi) {
84 this.ecgi = ecgi;
85 }
slowr13fa5b02017-08-08 16:32:31 -070086
slowr89c2ac12017-08-15 16:20:06 -070087 public ScellsInd getScellsInd() {
88 return scellsInd;
89 }
slowr13fa5b02017-08-08 16:32:31 -070090
slowr89c2ac12017-08-15 16:20:06 -070091 public void setScellsInd(ScellsInd scellsInd) {
92 this.scellsInd = scellsInd;
93 }
slowr13fa5b02017-08-08 16:32:31 -070094
slowr89c2ac12017-08-15 16:20:06 -070095 public int encode(BerByteArrayOutputStream os) throws IOException {
96 return encode(os, true);
97 }
slowr13fa5b02017-08-08 16:32:31 -070098
slowr89c2ac12017-08-15 16:20:06 -070099 public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
slowr13fa5b02017-08-08 16:32:31 -0700100
slowr89c2ac12017-08-15 16:20:06 -0700101 if (code != null) {
102 for (int i = code.length - 1; i >= 0; i--) {
103 os.write(code[i]);
104 }
105 if (withTag) {
106 return tag.encode(os) + code.length;
107 }
108 return code.length;
109 }
slowr13fa5b02017-08-08 16:32:31 -0700110
slowr89c2ac12017-08-15 16:20:06 -0700111 int codeLength = 0;
112 codeLength += scellsInd.encode(os, false);
113 // write tag: CONTEXT_CLASS, CONSTRUCTED, 2
114 os.write(0xA2);
115 codeLength += 1;
slowr13fa5b02017-08-08 16:32:31 -0700116
slowr89c2ac12017-08-15 16:20:06 -0700117 codeLength += ecgi.encode(os, false);
118 // write tag: CONTEXT_CLASS, CONSTRUCTED, 1
119 os.write(0xA1);
120 codeLength += 1;
slowr13fa5b02017-08-08 16:32:31 -0700121
slowr89c2ac12017-08-15 16:20:06 -0700122 codeLength += crnti.encode(os, false);
123 // write tag: CONTEXT_CLASS, PRIMITIVE, 0
124 os.write(0x80);
125 codeLength += 1;
slowr13fa5b02017-08-08 16:32:31 -0700126
slowr89c2ac12017-08-15 16:20:06 -0700127 codeLength += BerLength.encodeLength(os, codeLength);
slowr13fa5b02017-08-08 16:32:31 -0700128
slowr89c2ac12017-08-15 16:20:06 -0700129 if (withTag) {
130 codeLength += tag.encode(os);
131 }
slowr13fa5b02017-08-08 16:32:31 -0700132
slowr89c2ac12017-08-15 16:20:06 -0700133 return codeLength;
slowr13fa5b02017-08-08 16:32:31 -0700134
slowr89c2ac12017-08-15 16:20:06 -0700135 }
136
137 public int decode(InputStream is) throws IOException {
138 return decode(is, true);
139 }
140
141 public int decode(InputStream is, boolean withTag) throws IOException {
142 int codeLength = 0;
143 int subCodeLength = 0;
144 BerTag berTag = new BerTag();
145
146 if (withTag) {
147 codeLength += tag.decodeAndCheck(is);
148 }
149
150 BerLength length = new BerLength();
151 codeLength += length.decode(is);
152
153 int totalLength = length.val;
154 codeLength += totalLength;
155
156 subCodeLength += berTag.decode(is);
157 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
158 crnti = new CRNTI();
159 subCodeLength += crnti.decode(is, false);
160 subCodeLength += berTag.decode(is);
161 } else {
162 throw new IOException("Tag does not match the mandatory sequence element tag.");
163 }
164
165 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
166 ecgi = new ECGI();
167 subCodeLength += ecgi.decode(is, false);
168 subCodeLength += berTag.decode(is);
169 } else {
170 throw new IOException("Tag does not match the mandatory sequence element tag.");
171 }
172
173 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) {
174 scellsInd = new ScellsInd();
175 subCodeLength += scellsInd.decode(is, false);
176 if (subCodeLength == totalLength) {
177 return codeLength;
178 }
179 }
180 throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
181
182
183 }
184
185 public void encodeAndSave(int encodingSizeGuess) throws IOException {
186 BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
187 encode(os, false);
188 code = os.getArray();
189 }
190
191 public String toString() {
192 StringBuilder sb = new StringBuilder();
193 appendAsString(sb, 0);
194 return sb.toString();
195 }
196
197 public void appendAsString(StringBuilder sb, int indentLevel) {
198
199 sb.append("{");
200 sb.append("\n");
201 for (int i = 0; i < indentLevel + 1; i++) {
202 sb.append("\t");
203 }
204 if (crnti != null) {
slowr60d4d102017-08-16 18:33:58 -0700205 sb.append("crnti: ").append(crnti);
slowr89c2ac12017-08-15 16:20:06 -0700206 }
207
208 sb.append(",\n");
209 for (int i = 0; i < indentLevel + 1; i++) {
210 sb.append("\t");
211 }
212 if (ecgi != null) {
slowr60d4d102017-08-16 18:33:58 -0700213 sb.append("ecgi: ");
slowr89c2ac12017-08-15 16:20:06 -0700214 ecgi.appendAsString(sb, indentLevel + 1);
215 }
216
217 sb.append(",\n");
218 for (int i = 0; i < indentLevel + 1; i++) {
219 sb.append("\t");
220 }
221 if (scellsInd != null) {
slowr60d4d102017-08-16 18:33:58 -0700222 sb.append("scellsInd: ");
slowr89c2ac12017-08-15 16:20:06 -0700223 scellsInd.appendAsString(sb, indentLevel + 1);
224 }
225
226 sb.append("\n");
227 for (int i = 0; i < indentLevel; i++) {
228 sb.append("\t");
229 }
230 sb.append("}");
231 }
232
233 public static class ScellsInd implements Serializable {
234
235 public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
236 private static final long serialVersionUID = 1L;
slowr60d4d102017-08-16 18:33:58 -0700237 @JsonIgnore public byte[] code = null;
slowr89c2ac12017-08-15 16:20:06 -0700238 private List<PCIARFCN> seqOf = null;
239
240 public ScellsInd() {
241 seqOf = new ArrayList<PCIARFCN>();
242 }
243
244 public ScellsInd(byte[] code) {
245 this.code = code;
246 }
247
slowr60d4d102017-08-16 18:33:58 -0700248 @JsonValue
slowr89c2ac12017-08-15 16:20:06 -0700249 public List<PCIARFCN> getPCIARFCN() {
250 if (seqOf == null) {
251 seqOf = new ArrayList<PCIARFCN>();
252 }
253 return seqOf;
254 }
255
256 public int encode(BerByteArrayOutputStream os) throws IOException {
257 return encode(os, true);
258 }
259
260 public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
261
262 if (code != null) {
263 for (int i = code.length - 1; i >= 0; i--) {
264 os.write(code[i]);
265 }
266 if (withTag) {
267 return tag.encode(os) + code.length;
268 }
269 return code.length;
270 }
271
272 int codeLength = 0;
273 for (int i = (seqOf.size() - 1); i >= 0; i--) {
274 codeLength += seqOf.get(i).encode(os, true);
275 }
276
277 codeLength += BerLength.encodeLength(os, codeLength);
278
279 if (withTag) {
280 codeLength += tag.encode(os);
281 }
282
283 return codeLength;
284 }
285
286 public int decode(InputStream is) throws IOException {
287 return decode(is, true);
288 }
289
290 public int decode(InputStream is, boolean withTag) throws IOException {
291 int codeLength = 0;
292 int subCodeLength = 0;
293 if (withTag) {
294 codeLength += tag.decodeAndCheck(is);
295 }
296
297 BerLength length = new BerLength();
298 codeLength += length.decode(is);
299 int totalLength = length.val;
300
301 while (subCodeLength < totalLength) {
302 PCIARFCN element = new PCIARFCN();
303 subCodeLength += element.decode(is, true);
304 seqOf.add(element);
305 }
306 if (subCodeLength != totalLength) {
307 throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength);
308
309 }
310 codeLength += subCodeLength;
311
312 return codeLength;
313 }
314
315 public void encodeAndSave(int encodingSizeGuess) throws IOException {
316 BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
317 encode(os, false);
318 code = os.getArray();
319 }
320
321 public String toString() {
322 StringBuilder sb = new StringBuilder();
323 appendAsString(sb, 0);
324 return sb.toString();
325 }
326
327 public void appendAsString(StringBuilder sb, int indentLevel) {
328
329 sb.append("[\n");
330 for (int i = 0; i < indentLevel + 1; i++) {
331 sb.append("\t");
332 }
333 if (seqOf == null) {
slowr13fa5b02017-08-08 16:32:31 -0700334// sb.append("null");
slowr89c2ac12017-08-15 16:20:06 -0700335 } else {
336 Iterator<PCIARFCN> it = seqOf.iterator();
337 if (it.hasNext()) {
338 it.next().appendAsString(sb, indentLevel + 1);
339 while (it.hasNext()) {
340 sb.append(",\n");
341 for (int i = 0; i < indentLevel + 1; i++) {
342 sb.append("\t");
343 }
344 it.next().appendAsString(sb, indentLevel + 1);
345 }
346 }
347 }
slowr13fa5b02017-08-08 16:32:31 -0700348
slowr89c2ac12017-08-15 16:20:06 -0700349 sb.append("\n");
350 for (int i = 0; i < indentLevel; i++) {
351 sb.append("\t");
352 }
353 sb.append("]");
354 }
slowr13fa5b02017-08-08 16:32:31 -0700355
slowr89c2ac12017-08-15 16:20:06 -0700356 public void addPCIARFCN(PCIARFCN pciarfcn) {
357 seqOf.add(pciarfcn);
358 }
359 }
slowr13fa5b02017-08-08 16:32:31 -0700360
361}
362