blob: 02dd7d2d7af1b746650e806bf2750d5ea39b843a [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
7import org.onosproject.xran.codecs.api.CRNTI;
8import org.onosproject.xran.codecs.api.ECGI;
9import org.onosproject.xran.codecs.api.PCIARFCN;
10import org.openmuc.jasn1.ber.BerByteArrayOutputStream;
11import org.openmuc.jasn1.ber.BerLength;
12import org.openmuc.jasn1.ber.BerTag;
slowr89c2ac12017-08-15 16:20:06 -070013import org.openmuc.jasn1.ber.types.string.BerUTF8String;
slowr13fa5b02017-08-08 16:32:31 -070014
15import java.io.IOException;
16import java.io.InputStream;
17import java.io.Serializable;
slowr89c2ac12017-08-15 16:20:06 -070018import java.io.UnsupportedEncodingException;
slowr13fa5b02017-08-08 16:32:31 -070019import java.util.ArrayList;
20import java.util.Iterator;
21import java.util.List;
22
23public class ScellDelete implements Serializable {
24
slowr89c2ac12017-08-15 16:20:06 -070025 public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
26 private static final long serialVersionUID = 1L;
27 public byte[] code = null;
28 private CRNTI crnti = null;
29 private ECGI ecgi = null;
30 private ScellsInd scellsInd = null;
31 public ScellDelete() {
32 }
33 public ScellDelete(byte[] code) {
34 this.code = code;
35 }
slowr13fa5b02017-08-08 16:32:31 -070036
slowr89c2ac12017-08-15 16:20:06 -070037 public static XrancPdu constructPacket(ECGI ecgi, CRNTI crnti, PCIARFCN pciarfcn) {
38 ScellDelete scellDelete = new ScellDelete();
39 scellDelete.setEcgi(ecgi);
40 scellDelete.setCrnti(crnti);
41 ScellsInd scellsInd = new ScellsInd();
42 scellsInd.addPCIARFCN(pciarfcn);
43 scellDelete.setScellsInd(scellsInd);
slowr13fa5b02017-08-08 16:32:31 -070044
slowr89c2ac12017-08-15 16:20:06 -070045 BerUTF8String ver = null;
46 try {
47 ver = new BerUTF8String("3");
48 } catch (UnsupportedEncodingException e) {
49 e.printStackTrace();
50 }
slowr13fa5b02017-08-08 16:32:31 -070051
slowr89c2ac12017-08-15 16:20:06 -070052 XrancApiID apiID = new XrancApiID(28);
53 XrancPduBody body = new XrancPduBody();
54 body.setScellDelete(scellDelete);
slowr13fa5b02017-08-08 16:32:31 -070055
slowr89c2ac12017-08-15 16:20:06 -070056 XrancPduHdr hdr = new XrancPduHdr();
57 hdr.setVer(ver);
58 hdr.setApiId(apiID);
slowr13fa5b02017-08-08 16:32:31 -070059
slowr89c2ac12017-08-15 16:20:06 -070060 XrancPdu pdu = new XrancPdu();
61 pdu.setBody(body);
62 pdu.setHdr(hdr);
slowr13fa5b02017-08-08 16:32:31 -070063
slowr89c2ac12017-08-15 16:20:06 -070064 return pdu;
slowr13fa5b02017-08-08 16:32:31 -070065
slowr89c2ac12017-08-15 16:20:06 -070066 }
slowr13fa5b02017-08-08 16:32:31 -070067
slowr89c2ac12017-08-15 16:20:06 -070068 public CRNTI getCrnti() {
69 return crnti;
70 }
slowr13fa5b02017-08-08 16:32:31 -070071
slowr89c2ac12017-08-15 16:20:06 -070072 public void setCrnti(CRNTI crnti) {
73 this.crnti = crnti;
74 }
slowr13fa5b02017-08-08 16:32:31 -070075
slowr89c2ac12017-08-15 16:20:06 -070076 public ECGI getEcgi() {
77 return ecgi;
78 }
slowr13fa5b02017-08-08 16:32:31 -070079
slowr89c2ac12017-08-15 16:20:06 -070080 public void setEcgi(ECGI ecgi) {
81 this.ecgi = ecgi;
82 }
slowr13fa5b02017-08-08 16:32:31 -070083
slowr89c2ac12017-08-15 16:20:06 -070084 public ScellsInd getScellsInd() {
85 return scellsInd;
86 }
slowr13fa5b02017-08-08 16:32:31 -070087
slowr89c2ac12017-08-15 16:20:06 -070088 public void setScellsInd(ScellsInd scellsInd) {
89 this.scellsInd = scellsInd;
90 }
slowr13fa5b02017-08-08 16:32:31 -070091
slowr89c2ac12017-08-15 16:20:06 -070092 public int encode(BerByteArrayOutputStream os) throws IOException {
93 return encode(os, true);
94 }
slowr13fa5b02017-08-08 16:32:31 -070095
slowr89c2ac12017-08-15 16:20:06 -070096 public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
slowr13fa5b02017-08-08 16:32:31 -070097
slowr89c2ac12017-08-15 16:20:06 -070098 if (code != null) {
99 for (int i = code.length - 1; i >= 0; i--) {
100 os.write(code[i]);
101 }
102 if (withTag) {
103 return tag.encode(os) + code.length;
104 }
105 return code.length;
106 }
slowr13fa5b02017-08-08 16:32:31 -0700107
slowr89c2ac12017-08-15 16:20:06 -0700108 int codeLength = 0;
109 codeLength += scellsInd.encode(os, false);
110 // write tag: CONTEXT_CLASS, CONSTRUCTED, 2
111 os.write(0xA2);
112 codeLength += 1;
slowr13fa5b02017-08-08 16:32:31 -0700113
slowr89c2ac12017-08-15 16:20:06 -0700114 codeLength += ecgi.encode(os, false);
115 // write tag: CONTEXT_CLASS, CONSTRUCTED, 1
116 os.write(0xA1);
117 codeLength += 1;
slowr13fa5b02017-08-08 16:32:31 -0700118
slowr89c2ac12017-08-15 16:20:06 -0700119 codeLength += crnti.encode(os, false);
120 // write tag: CONTEXT_CLASS, PRIMITIVE, 0
121 os.write(0x80);
122 codeLength += 1;
slowr13fa5b02017-08-08 16:32:31 -0700123
slowr89c2ac12017-08-15 16:20:06 -0700124 codeLength += BerLength.encodeLength(os, codeLength);
slowr13fa5b02017-08-08 16:32:31 -0700125
slowr89c2ac12017-08-15 16:20:06 -0700126 if (withTag) {
127 codeLength += tag.encode(os);
128 }
slowr13fa5b02017-08-08 16:32:31 -0700129
slowr89c2ac12017-08-15 16:20:06 -0700130 return codeLength;
slowr13fa5b02017-08-08 16:32:31 -0700131
slowr89c2ac12017-08-15 16:20:06 -0700132 }
133
134 public int decode(InputStream is) throws IOException {
135 return decode(is, true);
136 }
137
138 public int decode(InputStream is, boolean withTag) throws IOException {
139 int codeLength = 0;
140 int subCodeLength = 0;
141 BerTag berTag = new BerTag();
142
143 if (withTag) {
144 codeLength += tag.decodeAndCheck(is);
145 }
146
147 BerLength length = new BerLength();
148 codeLength += length.decode(is);
149
150 int totalLength = length.val;
151 codeLength += totalLength;
152
153 subCodeLength += berTag.decode(is);
154 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
155 crnti = new CRNTI();
156 subCodeLength += crnti.decode(is, false);
157 subCodeLength += berTag.decode(is);
158 } else {
159 throw new IOException("Tag does not match the mandatory sequence element tag.");
160 }
161
162 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
163 ecgi = new ECGI();
164 subCodeLength += ecgi.decode(is, false);
165 subCodeLength += berTag.decode(is);
166 } else {
167 throw new IOException("Tag does not match the mandatory sequence element tag.");
168 }
169
170 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) {
171 scellsInd = new ScellsInd();
172 subCodeLength += scellsInd.decode(is, false);
173 if (subCodeLength == totalLength) {
174 return codeLength;
175 }
176 }
177 throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
178
179
180 }
181
182 public void encodeAndSave(int encodingSizeGuess) throws IOException {
183 BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
184 encode(os, false);
185 code = os.getArray();
186 }
187
188 public String toString() {
189 StringBuilder sb = new StringBuilder();
190 appendAsString(sb, 0);
191 return sb.toString();
192 }
193
194 public void appendAsString(StringBuilder sb, int indentLevel) {
195
196 sb.append("{");
197 sb.append("\n");
198 for (int i = 0; i < indentLevel + 1; i++) {
199 sb.append("\t");
200 }
201 if (crnti != null) {
202 sb.append("\"crnti\": ").append(crnti);
203 }
204
205 sb.append(",\n");
206 for (int i = 0; i < indentLevel + 1; i++) {
207 sb.append("\t");
208 }
209 if (ecgi != null) {
210 sb.append("\"ecgi\": ");
211 ecgi.appendAsString(sb, indentLevel + 1);
212 }
213
214 sb.append(",\n");
215 for (int i = 0; i < indentLevel + 1; i++) {
216 sb.append("\t");
217 }
218 if (scellsInd != null) {
219 sb.append("\"scellsInd\": ");
220 scellsInd.appendAsString(sb, indentLevel + 1);
221 }
222
223 sb.append("\n");
224 for (int i = 0; i < indentLevel; i++) {
225 sb.append("\t");
226 }
227 sb.append("}");
228 }
229
230 public static class ScellsInd implements Serializable {
231
232 public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
233 private static final long serialVersionUID = 1L;
234 public byte[] code = null;
235 private List<PCIARFCN> seqOf = null;
236
237 public ScellsInd() {
238 seqOf = new ArrayList<PCIARFCN>();
239 }
240
241 public ScellsInd(byte[] code) {
242 this.code = code;
243 }
244
245 public List<PCIARFCN> getPCIARFCN() {
246 if (seqOf == null) {
247 seqOf = new ArrayList<PCIARFCN>();
248 }
249 return seqOf;
250 }
251
252 public int encode(BerByteArrayOutputStream os) throws IOException {
253 return encode(os, true);
254 }
255
256 public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
257
258 if (code != null) {
259 for (int i = code.length - 1; i >= 0; i--) {
260 os.write(code[i]);
261 }
262 if (withTag) {
263 return tag.encode(os) + code.length;
264 }
265 return code.length;
266 }
267
268 int codeLength = 0;
269 for (int i = (seqOf.size() - 1); i >= 0; i--) {
270 codeLength += seqOf.get(i).encode(os, true);
271 }
272
273 codeLength += BerLength.encodeLength(os, codeLength);
274
275 if (withTag) {
276 codeLength += tag.encode(os);
277 }
278
279 return codeLength;
280 }
281
282 public int decode(InputStream is) throws IOException {
283 return decode(is, true);
284 }
285
286 public int decode(InputStream is, boolean withTag) throws IOException {
287 int codeLength = 0;
288 int subCodeLength = 0;
289 if (withTag) {
290 codeLength += tag.decodeAndCheck(is);
291 }
292
293 BerLength length = new BerLength();
294 codeLength += length.decode(is);
295 int totalLength = length.val;
296
297 while (subCodeLength < totalLength) {
298 PCIARFCN element = new PCIARFCN();
299 subCodeLength += element.decode(is, true);
300 seqOf.add(element);
301 }
302 if (subCodeLength != totalLength) {
303 throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength);
304
305 }
306 codeLength += subCodeLength;
307
308 return codeLength;
309 }
310
311 public void encodeAndSave(int encodingSizeGuess) throws IOException {
312 BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
313 encode(os, false);
314 code = os.getArray();
315 }
316
317 public String toString() {
318 StringBuilder sb = new StringBuilder();
319 appendAsString(sb, 0);
320 return sb.toString();
321 }
322
323 public void appendAsString(StringBuilder sb, int indentLevel) {
324
325 sb.append("[\n");
326 for (int i = 0; i < indentLevel + 1; i++) {
327 sb.append("\t");
328 }
329 if (seqOf == null) {
slowr13fa5b02017-08-08 16:32:31 -0700330// sb.append("null");
slowr89c2ac12017-08-15 16:20:06 -0700331 } else {
332 Iterator<PCIARFCN> it = seqOf.iterator();
333 if (it.hasNext()) {
334 it.next().appendAsString(sb, indentLevel + 1);
335 while (it.hasNext()) {
336 sb.append(",\n");
337 for (int i = 0; i < indentLevel + 1; i++) {
338 sb.append("\t");
339 }
340 it.next().appendAsString(sb, indentLevel + 1);
341 }
342 }
343 }
slowr13fa5b02017-08-08 16:32:31 -0700344
slowr89c2ac12017-08-15 16:20:06 -0700345 sb.append("\n");
346 for (int i = 0; i < indentLevel; i++) {
347 sb.append("\t");
348 }
349 sb.append("]");
350 }
slowr13fa5b02017-08-08 16:32:31 -0700351
slowr89c2ac12017-08-15 16:20:06 -0700352 public void addPCIARFCN(PCIARFCN pciarfcn) {
353 seqOf.add(pciarfcn);
354 }
355 }
slowr13fa5b02017-08-08 16:32:31 -0700356
357}
358