blob: 5e524e9c587a2efbe567cff4497a6f40dd72df0b [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.PropScell;
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.BerBoolean;
16import org.onosproject.xran.asn1lib.ber.types.BerEnum;
17import org.onosproject.xran.asn1lib.ber.types.BerInteger;
18import org.onosproject.xran.asn1lib.ber.types.string.BerUTF8String;
slowr13fa5b02017-08-08 16:32:31 -070019
20import java.io.IOException;
21import java.io.InputStream;
22import java.io.Serializable;
slowr89c2ac12017-08-15 16:20:06 -070023import java.io.UnsupportedEncodingException;
24import java.math.BigInteger;
slowr13fa5b02017-08-08 16:32:31 -070025import java.util.ArrayList;
26import java.util.Iterator;
27import java.util.List;
28
29public class ScellAdd implements Serializable {
30
slowr89c2ac12017-08-15 16:20:06 -070031 public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
32 private static final long serialVersionUID = 1L;
slowr60d4d102017-08-16 18:33:58 -070033 @JsonIgnore
slowr89c2ac12017-08-15 16:20:06 -070034 public byte[] code = null;
35 private CRNTI crnti = null;
36 private ECGI ecgi = null;
37 private ScellsProp scellsProp = null;
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -080038
slowr89c2ac12017-08-15 16:20:06 -070039 public ScellAdd() {
40 }
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -080041
slowr89c2ac12017-08-15 16:20:06 -070042 public ScellAdd(byte[] code) {
43 this.code = code;
44 }
slowr13fa5b02017-08-08 16:32:31 -070045
slowr89c2ac12017-08-15 16:20:06 -070046 public static XrancPdu constructPacket(ECGI ecgi, CRNTI crnti, PropScell propScell) {
47 ScellAdd scellAdd = new ScellAdd();
48 scellAdd.setCrnti(crnti);
49 scellAdd.setEcgi(ecgi);
slowr13fa5b02017-08-08 16:32:31 -070050
slowr89c2ac12017-08-15 16:20:06 -070051 propScell.setCrossCarrierSchedEnable(new BerBoolean(true));
52 propScell.setCaDirection(new BerEnum(new BigInteger("dl")));
53 propScell.setDeactTimer(new BerInteger(1000));
54 ScellsProp scellsProp = new ScellsProp();
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -080055 scellsProp.getPropScell().add(propScell);
slowr89c2ac12017-08-15 16:20:06 -070056 scellAdd.setScellsProp(scellsProp);
slowr13fa5b02017-08-08 16:32:31 -070057
slowr89c2ac12017-08-15 16:20:06 -070058 XrancPduBody body = new XrancPduBody();
59 body.setScellAdd(scellAdd);
slowr13fa5b02017-08-08 16:32:31 -070060
slowr89c2ac12017-08-15 16:20:06 -070061 BerUTF8String ver = null;
62 try {
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -080063 ver = new BerUTF8String("5");
slowr89c2ac12017-08-15 16:20:06 -070064 } catch (UnsupportedEncodingException e) {
65 e.printStackTrace();
66 }
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -080067 XrancApiID apiID = new XrancApiID(24);
slowr89c2ac12017-08-15 16:20:06 -070068 XrancPduHdr hdr = new XrancPduHdr();
69 hdr.setVer(ver);
70 hdr.setApiId(apiID);
slowr13fa5b02017-08-08 16:32:31 -070071
slowr89c2ac12017-08-15 16:20:06 -070072 XrancPdu pdu = new XrancPdu();
73 pdu.setHdr(hdr);
74 pdu.setBody(body);
slowr13fa5b02017-08-08 16:32:31 -070075
slowr89c2ac12017-08-15 16:20:06 -070076 return pdu;
77 }
slowr13fa5b02017-08-08 16:32:31 -070078
slowr89c2ac12017-08-15 16:20:06 -070079 public CRNTI getCrnti() {
80 return crnti;
81 }
slowr13fa5b02017-08-08 16:32:31 -070082
slowr89c2ac12017-08-15 16:20:06 -070083 public void setCrnti(CRNTI crnti) {
84 this.crnti = crnti;
85 }
slowr13fa5b02017-08-08 16:32:31 -070086
slowr89c2ac12017-08-15 16:20:06 -070087 public ECGI getEcgi() {
88 return ecgi;
89 }
slowr13fa5b02017-08-08 16:32:31 -070090
slowr89c2ac12017-08-15 16:20:06 -070091 public void setEcgi(ECGI ecgi) {
92 this.ecgi = ecgi;
93 }
slowr13fa5b02017-08-08 16:32:31 -070094
slowr89c2ac12017-08-15 16:20:06 -070095 public ScellsProp getScellsProp() {
96 return scellsProp;
97 }
slowr13fa5b02017-08-08 16:32:31 -070098
slowr89c2ac12017-08-15 16:20:06 -070099 public void setScellsProp(ScellsProp scellsProp) {
100 this.scellsProp = scellsProp;
101 }
slowr13fa5b02017-08-08 16:32:31 -0700102
slowr89c2ac12017-08-15 16:20:06 -0700103 public int encode(BerByteArrayOutputStream os) throws IOException {
104 return encode(os, true);
105 }
slowr13fa5b02017-08-08 16:32:31 -0700106
slowr89c2ac12017-08-15 16:20:06 -0700107 public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
slowr13fa5b02017-08-08 16:32:31 -0700108
slowr89c2ac12017-08-15 16:20:06 -0700109 if (code != null) {
110 for (int i = code.length - 1; i >= 0; i--) {
111 os.write(code[i]);
112 }
113 if (withTag) {
114 return tag.encode(os) + code.length;
115 }
116 return code.length;
117 }
slowr13fa5b02017-08-08 16:32:31 -0700118
slowr89c2ac12017-08-15 16:20:06 -0700119 int codeLength = 0;
120 codeLength += scellsProp.encode(os, false);
121 // write tag: CONTEXT_CLASS, CONSTRUCTED, 2
122 os.write(0xA2);
123 codeLength += 1;
slowr13fa5b02017-08-08 16:32:31 -0700124
slowr89c2ac12017-08-15 16:20:06 -0700125 codeLength += ecgi.encode(os, false);
126 // write tag: CONTEXT_CLASS, CONSTRUCTED, 1
127 os.write(0xA1);
128 codeLength += 1;
slowr13fa5b02017-08-08 16:32:31 -0700129
slowr89c2ac12017-08-15 16:20:06 -0700130 codeLength += crnti.encode(os, false);
131 // write tag: CONTEXT_CLASS, PRIMITIVE, 0
132 os.write(0x80);
133 codeLength += 1;
slowr13fa5b02017-08-08 16:32:31 -0700134
slowr89c2ac12017-08-15 16:20:06 -0700135 codeLength += BerLength.encodeLength(os, codeLength);
slowr13fa5b02017-08-08 16:32:31 -0700136
slowr89c2ac12017-08-15 16:20:06 -0700137 if (withTag) {
138 codeLength += tag.encode(os);
139 }
slowr13fa5b02017-08-08 16:32:31 -0700140
slowr89c2ac12017-08-15 16:20:06 -0700141 return codeLength;
slowr13fa5b02017-08-08 16:32:31 -0700142
slowr89c2ac12017-08-15 16:20:06 -0700143 }
slowr13fa5b02017-08-08 16:32:31 -0700144
slowr89c2ac12017-08-15 16:20:06 -0700145 public int decode(InputStream is) throws IOException {
146 return decode(is, true);
147 }
148
149 public int decode(InputStream is, boolean withTag) throws IOException {
150 int codeLength = 0;
151 int subCodeLength = 0;
152 BerTag berTag = new BerTag();
153
154 if (withTag) {
155 codeLength += tag.decodeAndCheck(is);
156 }
157
158 BerLength length = new BerLength();
159 codeLength += length.decode(is);
160
161 int totalLength = length.val;
162 codeLength += totalLength;
163
164 subCodeLength += berTag.decode(is);
165 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
166 crnti = new CRNTI();
167 subCodeLength += crnti.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, 1)) {
174 ecgi = new ECGI();
175 subCodeLength += ecgi.decode(is, false);
176 subCodeLength += berTag.decode(is);
177 } else {
178 throw new IOException("Tag does not match the mandatory sequence element tag.");
179 }
180
181 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) {
182 scellsProp = new ScellsProp();
183 subCodeLength += scellsProp.decode(is, false);
184 if (subCodeLength == totalLength) {
185 return codeLength;
186 }
187 }
188 throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
189
190
191 }
192
193 public void encodeAndSave(int encodingSizeGuess) throws IOException {
194 BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
195 encode(os, false);
196 code = os.getArray();
197 }
198
199 public String toString() {
200 StringBuilder sb = new StringBuilder();
201 appendAsString(sb, 0);
202 return sb.toString();
203 }
204
205 public void appendAsString(StringBuilder sb, int indentLevel) {
206
207 sb.append("{");
208 sb.append("\n");
209 for (int i = 0; i < indentLevel + 1; i++) {
210 sb.append("\t");
211 }
212 if (crnti != null) {
slowr60d4d102017-08-16 18:33:58 -0700213 sb.append("crnti: ").append(crnti);
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -0800214 } else {
215 sb.append("crnti: <empty-required-field>");
slowr89c2ac12017-08-15 16:20:06 -0700216 }
217
218 sb.append(",\n");
219 for (int i = 0; i < indentLevel + 1; i++) {
220 sb.append("\t");
221 }
222 if (ecgi != null) {
slowr60d4d102017-08-16 18:33:58 -0700223 sb.append("ecgi: ");
slowr89c2ac12017-08-15 16:20:06 -0700224 ecgi.appendAsString(sb, indentLevel + 1);
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -0800225 } else {
226 sb.append("ecgi: <empty-required-field>");
slowr89c2ac12017-08-15 16:20:06 -0700227 }
228
229 sb.append(",\n");
230 for (int i = 0; i < indentLevel + 1; i++) {
231 sb.append("\t");
232 }
233 if (scellsProp != null) {
slowr60d4d102017-08-16 18:33:58 -0700234 sb.append("scellsProp: ");
slowr89c2ac12017-08-15 16:20:06 -0700235 scellsProp.appendAsString(sb, indentLevel + 1);
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -0800236 } else {
237 sb.append("scellsProp: <empty-required-field>");
slowr89c2ac12017-08-15 16:20:06 -0700238 }
239
240 sb.append("\n");
241 for (int i = 0; i < indentLevel; i++) {
242 sb.append("\t");
243 }
244 sb.append("}");
245 }
246
247 public static class ScellsProp implements Serializable {
248
249 public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
250 private static final long serialVersionUID = 1L;
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -0800251 @JsonIgnore
252 public byte[] code = null;
slowr89c2ac12017-08-15 16:20:06 -0700253 private List<PropScell> seqOf = null;
254
255 public ScellsProp() {
256 seqOf = new ArrayList<PropScell>();
257 }
258
259 public ScellsProp(byte[] code) {
260 this.code = code;
261 }
262
slowr60d4d102017-08-16 18:33:58 -0700263 @JsonValue
slowr89c2ac12017-08-15 16:20:06 -0700264 public List<PropScell> getPropScell() {
265 if (seqOf == null) {
266 seqOf = new ArrayList<PropScell>();
267 }
268 return seqOf;
269 }
270
271 public int encode(BerByteArrayOutputStream os) throws IOException {
272 return encode(os, true);
273 }
274
275 public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
276
277 if (code != null) {
278 for (int i = code.length - 1; i >= 0; i--) {
279 os.write(code[i]);
280 }
281 if (withTag) {
282 return tag.encode(os) + code.length;
283 }
284 return code.length;
285 }
286
287 int codeLength = 0;
288 for (int i = (seqOf.size() - 1); i >= 0; i--) {
289 codeLength += seqOf.get(i).encode(os, true);
290 }
291
292 codeLength += BerLength.encodeLength(os, codeLength);
293
294 if (withTag) {
295 codeLength += tag.encode(os);
296 }
297
298 return codeLength;
299 }
300
301 public int decode(InputStream is) throws IOException {
302 return decode(is, true);
303 }
304
305 public int decode(InputStream is, boolean withTag) throws IOException {
306 int codeLength = 0;
307 int subCodeLength = 0;
308 if (withTag) {
309 codeLength += tag.decodeAndCheck(is);
310 }
311
312 BerLength length = new BerLength();
313 codeLength += length.decode(is);
314 int totalLength = length.val;
315
316 while (subCodeLength < totalLength) {
317 PropScell element = new PropScell();
318 subCodeLength += element.decode(is, true);
319 seqOf.add(element);
320 }
321 if (subCodeLength != totalLength) {
322 throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength);
323
324 }
325 codeLength += subCodeLength;
326
327 return codeLength;
328 }
329
330 public void encodeAndSave(int encodingSizeGuess) throws IOException {
331 BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
332 encode(os, false);
333 code = os.getArray();
334 }
335
336 public String toString() {
337 StringBuilder sb = new StringBuilder();
338 appendAsString(sb, 0);
339 return sb.toString();
340 }
341
342 public void appendAsString(StringBuilder sb, int indentLevel) {
343
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -0800344 sb.append("{\n");
slowr89c2ac12017-08-15 16:20:06 -0700345 for (int i = 0; i < indentLevel + 1; i++) {
346 sb.append("\t");
347 }
348 if (seqOf == null) {
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -0800349 sb.append("null");
slowr89c2ac12017-08-15 16:20:06 -0700350 } else {
351 Iterator<PropScell> it = seqOf.iterator();
352 if (it.hasNext()) {
353 it.next().appendAsString(sb, indentLevel + 1);
354 while (it.hasNext()) {
355 sb.append(",\n");
356 for (int i = 0; i < indentLevel + 1; i++) {
357 sb.append("\t");
358 }
359 it.next().appendAsString(sb, indentLevel + 1);
360 }
361 }
362 }
slowr13fa5b02017-08-08 16:32:31 -0700363
slowr89c2ac12017-08-15 16:20:06 -0700364 sb.append("\n");
365 for (int i = 0; i < indentLevel; i++) {
366 sb.append("\t");
367 }
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -0800368 sb.append("}");
slowr89c2ac12017-08-15 16:20:06 -0700369 }
slowr13fa5b02017-08-08 16:32:31 -0700370
slowr89c2ac12017-08-15 16:20:06 -0700371 }
slowr13fa5b02017-08-08 16:32:31 -0700372
373}
374