blob: 674b79d1efc6ed11531efda9d47ea613f44b9a46 [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.PropScell;
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.BerBoolean;
16import org.onosproject.xran.codecs.ber.types.BerEnum;
17import org.onosproject.xran.codecs.ber.types.BerInteger;
18import org.onosproject.xran.codecs.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;
38 public ScellAdd() {
39 }
40 public ScellAdd(byte[] code) {
41 this.code = code;
42 }
slowr13fa5b02017-08-08 16:32:31 -070043
slowr89c2ac12017-08-15 16:20:06 -070044 public static XrancPdu constructPacket(ECGI ecgi, CRNTI crnti, PropScell propScell) {
45 ScellAdd scellAdd = new ScellAdd();
46 scellAdd.setCrnti(crnti);
47 scellAdd.setEcgi(ecgi);
slowr13fa5b02017-08-08 16:32:31 -070048
slowr89c2ac12017-08-15 16:20:06 -070049 propScell.setCrossCarrierSchedEnable(new BerBoolean(true));
50 propScell.setCaDirection(new BerEnum(new BigInteger("dl")));
51 propScell.setDeactTimer(new BerInteger(1000));
52 ScellsProp scellsProp = new ScellsProp();
53 scellsProp.addPropScell(propScell);
54 scellAdd.setScellsProp(scellsProp);
slowr13fa5b02017-08-08 16:32:31 -070055
slowr89c2ac12017-08-15 16:20:06 -070056 XrancPduBody body = new XrancPduBody();
57 body.setScellAdd(scellAdd);
slowr13fa5b02017-08-08 16:32:31 -070058
slowr89c2ac12017-08-15 16:20:06 -070059 BerUTF8String ver = null;
60 try {
61 ver = new BerUTF8String("3");
62 } catch (UnsupportedEncodingException e) {
63 e.printStackTrace();
64 }
65 XrancApiID apiID = new XrancApiID(26);
66 XrancPduHdr hdr = new XrancPduHdr();
67 hdr.setVer(ver);
68 hdr.setApiId(apiID);
slowr13fa5b02017-08-08 16:32:31 -070069
slowr89c2ac12017-08-15 16:20:06 -070070 XrancPdu pdu = new XrancPdu();
71 pdu.setHdr(hdr);
72 pdu.setBody(body);
slowr13fa5b02017-08-08 16:32:31 -070073
slowr89c2ac12017-08-15 16:20:06 -070074 return pdu;
75 }
slowr13fa5b02017-08-08 16:32:31 -070076
slowr89c2ac12017-08-15 16:20:06 -070077 public CRNTI getCrnti() {
78 return crnti;
79 }
slowr13fa5b02017-08-08 16:32:31 -070080
slowr89c2ac12017-08-15 16:20:06 -070081 public void setCrnti(CRNTI crnti) {
82 this.crnti = crnti;
83 }
slowr13fa5b02017-08-08 16:32:31 -070084
slowr89c2ac12017-08-15 16:20:06 -070085 public ECGI getEcgi() {
86 return ecgi;
87 }
slowr13fa5b02017-08-08 16:32:31 -070088
slowr89c2ac12017-08-15 16:20:06 -070089 public void setEcgi(ECGI ecgi) {
90 this.ecgi = ecgi;
91 }
slowr13fa5b02017-08-08 16:32:31 -070092
slowr89c2ac12017-08-15 16:20:06 -070093 public ScellsProp getScellsProp() {
94 return scellsProp;
95 }
slowr13fa5b02017-08-08 16:32:31 -070096
slowr89c2ac12017-08-15 16:20:06 -070097 public void setScellsProp(ScellsProp scellsProp) {
98 this.scellsProp = scellsProp;
99 }
slowr13fa5b02017-08-08 16:32:31 -0700100
slowr89c2ac12017-08-15 16:20:06 -0700101 public int encode(BerByteArrayOutputStream os) throws IOException {
102 return encode(os, true);
103 }
slowr13fa5b02017-08-08 16:32:31 -0700104
slowr89c2ac12017-08-15 16:20:06 -0700105 public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
slowr13fa5b02017-08-08 16:32:31 -0700106
slowr89c2ac12017-08-15 16:20:06 -0700107 if (code != null) {
108 for (int i = code.length - 1; i >= 0; i--) {
109 os.write(code[i]);
110 }
111 if (withTag) {
112 return tag.encode(os) + code.length;
113 }
114 return code.length;
115 }
slowr13fa5b02017-08-08 16:32:31 -0700116
slowr89c2ac12017-08-15 16:20:06 -0700117 int codeLength = 0;
118 codeLength += scellsProp.encode(os, false);
119 // write tag: CONTEXT_CLASS, CONSTRUCTED, 2
120 os.write(0xA2);
121 codeLength += 1;
slowr13fa5b02017-08-08 16:32:31 -0700122
slowr89c2ac12017-08-15 16:20:06 -0700123 codeLength += ecgi.encode(os, false);
124 // write tag: CONTEXT_CLASS, CONSTRUCTED, 1
125 os.write(0xA1);
126 codeLength += 1;
slowr13fa5b02017-08-08 16:32:31 -0700127
slowr89c2ac12017-08-15 16:20:06 -0700128 codeLength += crnti.encode(os, false);
129 // write tag: CONTEXT_CLASS, PRIMITIVE, 0
130 os.write(0x80);
131 codeLength += 1;
slowr13fa5b02017-08-08 16:32:31 -0700132
slowr89c2ac12017-08-15 16:20:06 -0700133 codeLength += BerLength.encodeLength(os, codeLength);
slowr13fa5b02017-08-08 16:32:31 -0700134
slowr89c2ac12017-08-15 16:20:06 -0700135 if (withTag) {
136 codeLength += tag.encode(os);
137 }
slowr13fa5b02017-08-08 16:32:31 -0700138
slowr89c2ac12017-08-15 16:20:06 -0700139 return codeLength;
slowr13fa5b02017-08-08 16:32:31 -0700140
slowr89c2ac12017-08-15 16:20:06 -0700141 }
slowr13fa5b02017-08-08 16:32:31 -0700142
slowr89c2ac12017-08-15 16:20:06 -0700143 public int decode(InputStream is) throws IOException {
144 return decode(is, true);
145 }
146
147 public int decode(InputStream is, boolean withTag) throws IOException {
148 int codeLength = 0;
149 int subCodeLength = 0;
150 BerTag berTag = new BerTag();
151
152 if (withTag) {
153 codeLength += tag.decodeAndCheck(is);
154 }
155
156 BerLength length = new BerLength();
157 codeLength += length.decode(is);
158
159 int totalLength = length.val;
160 codeLength += totalLength;
161
162 subCodeLength += berTag.decode(is);
163 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
164 crnti = new CRNTI();
165 subCodeLength += crnti.decode(is, false);
166 subCodeLength += berTag.decode(is);
167 } else {
168 throw new IOException("Tag does not match the mandatory sequence element tag.");
169 }
170
171 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
172 ecgi = new ECGI();
173 subCodeLength += ecgi.decode(is, false);
174 subCodeLength += berTag.decode(is);
175 } else {
176 throw new IOException("Tag does not match the mandatory sequence element tag.");
177 }
178
179 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) {
180 scellsProp = new ScellsProp();
181 subCodeLength += scellsProp.decode(is, false);
182 if (subCodeLength == totalLength) {
183 return codeLength;
184 }
185 }
186 throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
187
188
189 }
190
191 public void encodeAndSave(int encodingSizeGuess) throws IOException {
192 BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
193 encode(os, false);
194 code = os.getArray();
195 }
196
197 public String toString() {
198 StringBuilder sb = new StringBuilder();
199 appendAsString(sb, 0);
200 return sb.toString();
201 }
202
203 public void appendAsString(StringBuilder sb, int indentLevel) {
204
205 sb.append("{");
206 sb.append("\n");
207 for (int i = 0; i < indentLevel + 1; i++) {
208 sb.append("\t");
209 }
210 if (crnti != null) {
slowr60d4d102017-08-16 18:33:58 -0700211 sb.append("crnti: ").append(crnti);
slowr89c2ac12017-08-15 16:20:06 -0700212 }
213
214 sb.append(",\n");
215 for (int i = 0; i < indentLevel + 1; i++) {
216 sb.append("\t");
217 }
218 if (ecgi != null) {
slowr60d4d102017-08-16 18:33:58 -0700219 sb.append("ecgi: ");
slowr89c2ac12017-08-15 16:20:06 -0700220 ecgi.appendAsString(sb, indentLevel + 1);
221 }
222
223 sb.append(",\n");
224 for (int i = 0; i < indentLevel + 1; i++) {
225 sb.append("\t");
226 }
227 if (scellsProp != null) {
slowr60d4d102017-08-16 18:33:58 -0700228 sb.append("scellsProp: ");
slowr89c2ac12017-08-15 16:20:06 -0700229 scellsProp.appendAsString(sb, indentLevel + 1);
230 }
231
232 sb.append("\n");
233 for (int i = 0; i < indentLevel; i++) {
234 sb.append("\t");
235 }
236 sb.append("}");
237 }
238
239 public static class ScellsProp implements Serializable {
240
241 public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
242 private static final long serialVersionUID = 1L;
slowr60d4d102017-08-16 18:33:58 -0700243 @JsonIgnore public byte[] code = null;
slowr89c2ac12017-08-15 16:20:06 -0700244 private List<PropScell> seqOf = null;
245
246 public ScellsProp() {
247 seqOf = new ArrayList<PropScell>();
248 }
249
250 public ScellsProp(byte[] code) {
251 this.code = code;
252 }
253
slowr60d4d102017-08-16 18:33:58 -0700254 @JsonValue
slowr89c2ac12017-08-15 16:20:06 -0700255 public List<PropScell> getPropScell() {
256 if (seqOf == null) {
257 seqOf = new ArrayList<PropScell>();
258 }
259 return seqOf;
260 }
261
262 public int encode(BerByteArrayOutputStream os) throws IOException {
263 return encode(os, true);
264 }
265
266 public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
267
268 if (code != null) {
269 for (int i = code.length - 1; i >= 0; i--) {
270 os.write(code[i]);
271 }
272 if (withTag) {
273 return tag.encode(os) + code.length;
274 }
275 return code.length;
276 }
277
278 int codeLength = 0;
279 for (int i = (seqOf.size() - 1); i >= 0; i--) {
280 codeLength += seqOf.get(i).encode(os, true);
281 }
282
283 codeLength += BerLength.encodeLength(os, codeLength);
284
285 if (withTag) {
286 codeLength += tag.encode(os);
287 }
288
289 return codeLength;
290 }
291
292 public int decode(InputStream is) throws IOException {
293 return decode(is, true);
294 }
295
296 public int decode(InputStream is, boolean withTag) throws IOException {
297 int codeLength = 0;
298 int subCodeLength = 0;
299 if (withTag) {
300 codeLength += tag.decodeAndCheck(is);
301 }
302
303 BerLength length = new BerLength();
304 codeLength += length.decode(is);
305 int totalLength = length.val;
306
307 while (subCodeLength < totalLength) {
308 PropScell element = new PropScell();
309 subCodeLength += element.decode(is, true);
310 seqOf.add(element);
311 }
312 if (subCodeLength != totalLength) {
313 throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength);
314
315 }
316 codeLength += subCodeLength;
317
318 return codeLength;
319 }
320
321 public void encodeAndSave(int encodingSizeGuess) throws IOException {
322 BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
323 encode(os, false);
324 code = os.getArray();
325 }
326
327 public String toString() {
328 StringBuilder sb = new StringBuilder();
329 appendAsString(sb, 0);
330 return sb.toString();
331 }
332
333 public void appendAsString(StringBuilder sb, int indentLevel) {
334
335 sb.append("[\n");
336 for (int i = 0; i < indentLevel + 1; i++) {
337 sb.append("\t");
338 }
339 if (seqOf == null) {
slowr13fa5b02017-08-08 16:32:31 -0700340// sb.append("null");
slowr89c2ac12017-08-15 16:20:06 -0700341 } else {
342 Iterator<PropScell> it = seqOf.iterator();
343 if (it.hasNext()) {
344 it.next().appendAsString(sb, indentLevel + 1);
345 while (it.hasNext()) {
346 sb.append(",\n");
347 for (int i = 0; i < indentLevel + 1; i++) {
348 sb.append("\t");
349 }
350 it.next().appendAsString(sb, indentLevel + 1);
351 }
352 }
353 }
slowr13fa5b02017-08-08 16:32:31 -0700354
slowr89c2ac12017-08-15 16:20:06 -0700355 sb.append("\n");
356 for (int i = 0; i < indentLevel; i++) {
357 sb.append("\t");
358 }
359 sb.append("]");
360 }
slowr13fa5b02017-08-08 16:32:31 -0700361
slowr89c2ac12017-08-15 16:20:06 -0700362 public void addPropScell(PropScell propScell) {
363 seqOf.add(propScell);
364 }
365 }
slowr13fa5b02017-08-08 16:32:31 -0700366
367}
368