blob: 3ee1f02b2a023fc3d5d35dd07213c85d0549bd89 [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.PropScell;
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.BerBoolean;
14import org.openmuc.jasn1.ber.types.BerEnum;
15import org.openmuc.jasn1.ber.types.BerInteger;
16import org.openmuc.jasn1.ber.types.string.BerUTF8String;
slowr13fa5b02017-08-08 16:32:31 -070017
18import java.io.IOException;
19import java.io.InputStream;
20import java.io.Serializable;
slowr89c2ac12017-08-15 16:20:06 -070021import java.io.UnsupportedEncodingException;
22import java.math.BigInteger;
slowr13fa5b02017-08-08 16:32:31 -070023import java.util.ArrayList;
24import java.util.Iterator;
25import java.util.List;
26
27public class ScellAdd implements Serializable {
28
slowr89c2ac12017-08-15 16:20:06 -070029 public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
30 private static final long serialVersionUID = 1L;
31 public byte[] code = null;
32 private CRNTI crnti = null;
33 private ECGI ecgi = null;
34 private ScellsProp scellsProp = null;
35 public ScellAdd() {
36 }
37 public ScellAdd(byte[] code) {
38 this.code = code;
39 }
slowr13fa5b02017-08-08 16:32:31 -070040
slowr89c2ac12017-08-15 16:20:06 -070041 public static XrancPdu constructPacket(ECGI ecgi, CRNTI crnti, PropScell propScell) {
42 ScellAdd scellAdd = new ScellAdd();
43 scellAdd.setCrnti(crnti);
44 scellAdd.setEcgi(ecgi);
slowr13fa5b02017-08-08 16:32:31 -070045
slowr89c2ac12017-08-15 16:20:06 -070046 propScell.setCrossCarrierSchedEnable(new BerBoolean(true));
47 propScell.setCaDirection(new BerEnum(new BigInteger("dl")));
48 propScell.setDeactTimer(new BerInteger(1000));
49 ScellsProp scellsProp = new ScellsProp();
50 scellsProp.addPropScell(propScell);
51 scellAdd.setScellsProp(scellsProp);
slowr13fa5b02017-08-08 16:32:31 -070052
slowr89c2ac12017-08-15 16:20:06 -070053 XrancPduBody body = new XrancPduBody();
54 body.setScellAdd(scellAdd);
slowr13fa5b02017-08-08 16:32:31 -070055
slowr89c2ac12017-08-15 16:20:06 -070056 BerUTF8String ver = null;
57 try {
58 ver = new BerUTF8String("3");
59 } catch (UnsupportedEncodingException e) {
60 e.printStackTrace();
61 }
62 XrancApiID apiID = new XrancApiID(26);
63 XrancPduHdr hdr = new XrancPduHdr();
64 hdr.setVer(ver);
65 hdr.setApiId(apiID);
slowr13fa5b02017-08-08 16:32:31 -070066
slowr89c2ac12017-08-15 16:20:06 -070067 XrancPdu pdu = new XrancPdu();
68 pdu.setHdr(hdr);
69 pdu.setBody(body);
slowr13fa5b02017-08-08 16:32:31 -070070
slowr89c2ac12017-08-15 16:20:06 -070071 return pdu;
72 }
slowr13fa5b02017-08-08 16:32:31 -070073
slowr89c2ac12017-08-15 16:20:06 -070074 public CRNTI getCrnti() {
75 return crnti;
76 }
slowr13fa5b02017-08-08 16:32:31 -070077
slowr89c2ac12017-08-15 16:20:06 -070078 public void setCrnti(CRNTI crnti) {
79 this.crnti = crnti;
80 }
slowr13fa5b02017-08-08 16:32:31 -070081
slowr89c2ac12017-08-15 16:20:06 -070082 public ECGI getEcgi() {
83 return ecgi;
84 }
slowr13fa5b02017-08-08 16:32:31 -070085
slowr89c2ac12017-08-15 16:20:06 -070086 public void setEcgi(ECGI ecgi) {
87 this.ecgi = ecgi;
88 }
slowr13fa5b02017-08-08 16:32:31 -070089
slowr89c2ac12017-08-15 16:20:06 -070090 public ScellsProp getScellsProp() {
91 return scellsProp;
92 }
slowr13fa5b02017-08-08 16:32:31 -070093
slowr89c2ac12017-08-15 16:20:06 -070094 public void setScellsProp(ScellsProp scellsProp) {
95 this.scellsProp = scellsProp;
96 }
slowr13fa5b02017-08-08 16:32:31 -070097
slowr89c2ac12017-08-15 16:20:06 -070098 public int encode(BerByteArrayOutputStream os) throws IOException {
99 return encode(os, true);
100 }
slowr13fa5b02017-08-08 16:32:31 -0700101
slowr89c2ac12017-08-15 16:20:06 -0700102 public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
slowr13fa5b02017-08-08 16:32:31 -0700103
slowr89c2ac12017-08-15 16:20:06 -0700104 if (code != null) {
105 for (int i = code.length - 1; i >= 0; i--) {
106 os.write(code[i]);
107 }
108 if (withTag) {
109 return tag.encode(os) + code.length;
110 }
111 return code.length;
112 }
slowr13fa5b02017-08-08 16:32:31 -0700113
slowr89c2ac12017-08-15 16:20:06 -0700114 int codeLength = 0;
115 codeLength += scellsProp.encode(os, false);
116 // write tag: CONTEXT_CLASS, CONSTRUCTED, 2
117 os.write(0xA2);
118 codeLength += 1;
slowr13fa5b02017-08-08 16:32:31 -0700119
slowr89c2ac12017-08-15 16:20:06 -0700120 codeLength += ecgi.encode(os, false);
121 // write tag: CONTEXT_CLASS, CONSTRUCTED, 1
122 os.write(0xA1);
123 codeLength += 1;
slowr13fa5b02017-08-08 16:32:31 -0700124
slowr89c2ac12017-08-15 16:20:06 -0700125 codeLength += crnti.encode(os, false);
126 // write tag: CONTEXT_CLASS, PRIMITIVE, 0
127 os.write(0x80);
128 codeLength += 1;
slowr13fa5b02017-08-08 16:32:31 -0700129
slowr89c2ac12017-08-15 16:20:06 -0700130 codeLength += BerLength.encodeLength(os, codeLength);
slowr13fa5b02017-08-08 16:32:31 -0700131
slowr89c2ac12017-08-15 16:20:06 -0700132 if (withTag) {
133 codeLength += tag.encode(os);
134 }
slowr13fa5b02017-08-08 16:32:31 -0700135
slowr89c2ac12017-08-15 16:20:06 -0700136 return codeLength;
slowr13fa5b02017-08-08 16:32:31 -0700137
slowr89c2ac12017-08-15 16:20:06 -0700138 }
slowr13fa5b02017-08-08 16:32:31 -0700139
slowr89c2ac12017-08-15 16:20:06 -0700140 public int decode(InputStream is) throws IOException {
141 return decode(is, true);
142 }
143
144 public int decode(InputStream is, boolean withTag) throws IOException {
145 int codeLength = 0;
146 int subCodeLength = 0;
147 BerTag berTag = new BerTag();
148
149 if (withTag) {
150 codeLength += tag.decodeAndCheck(is);
151 }
152
153 BerLength length = new BerLength();
154 codeLength += length.decode(is);
155
156 int totalLength = length.val;
157 codeLength += totalLength;
158
159 subCodeLength += berTag.decode(is);
160 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
161 crnti = new CRNTI();
162 subCodeLength += crnti.decode(is, false);
163 subCodeLength += berTag.decode(is);
164 } else {
165 throw new IOException("Tag does not match the mandatory sequence element tag.");
166 }
167
168 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
169 ecgi = new ECGI();
170 subCodeLength += ecgi.decode(is, false);
171 subCodeLength += berTag.decode(is);
172 } else {
173 throw new IOException("Tag does not match the mandatory sequence element tag.");
174 }
175
176 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) {
177 scellsProp = new ScellsProp();
178 subCodeLength += scellsProp.decode(is, false);
179 if (subCodeLength == totalLength) {
180 return codeLength;
181 }
182 }
183 throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
184
185
186 }
187
188 public void encodeAndSave(int encodingSizeGuess) throws IOException {
189 BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
190 encode(os, false);
191 code = os.getArray();
192 }
193
194 public String toString() {
195 StringBuilder sb = new StringBuilder();
196 appendAsString(sb, 0);
197 return sb.toString();
198 }
199
200 public void appendAsString(StringBuilder sb, int indentLevel) {
201
202 sb.append("{");
203 sb.append("\n");
204 for (int i = 0; i < indentLevel + 1; i++) {
205 sb.append("\t");
206 }
207 if (crnti != null) {
208 sb.append("\"crnti\": ").append(crnti);
209 }
210
211 sb.append(",\n");
212 for (int i = 0; i < indentLevel + 1; i++) {
213 sb.append("\t");
214 }
215 if (ecgi != null) {
216 sb.append("\"ecgi\": ");
217 ecgi.appendAsString(sb, indentLevel + 1);
218 }
219
220 sb.append(",\n");
221 for (int i = 0; i < indentLevel + 1; i++) {
222 sb.append("\t");
223 }
224 if (scellsProp != null) {
225 sb.append("\"scellsProp\": ");
226 scellsProp.appendAsString(sb, indentLevel + 1);
227 }
228
229 sb.append("\n");
230 for (int i = 0; i < indentLevel; i++) {
231 sb.append("\t");
232 }
233 sb.append("}");
234 }
235
236 public static class ScellsProp implements Serializable {
237
238 public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
239 private static final long serialVersionUID = 1L;
240 public byte[] code = null;
241 private List<PropScell> seqOf = null;
242
243 public ScellsProp() {
244 seqOf = new ArrayList<PropScell>();
245 }
246
247 public ScellsProp(byte[] code) {
248 this.code = code;
249 }
250
251 public List<PropScell> getPropScell() {
252 if (seqOf == null) {
253 seqOf = new ArrayList<PropScell>();
254 }
255 return seqOf;
256 }
257
258 public int encode(BerByteArrayOutputStream os) throws IOException {
259 return encode(os, true);
260 }
261
262 public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
263
264 if (code != null) {
265 for (int i = code.length - 1; i >= 0; i--) {
266 os.write(code[i]);
267 }
268 if (withTag) {
269 return tag.encode(os) + code.length;
270 }
271 return code.length;
272 }
273
274 int codeLength = 0;
275 for (int i = (seqOf.size() - 1); i >= 0; i--) {
276 codeLength += seqOf.get(i).encode(os, true);
277 }
278
279 codeLength += BerLength.encodeLength(os, codeLength);
280
281 if (withTag) {
282 codeLength += tag.encode(os);
283 }
284
285 return codeLength;
286 }
287
288 public int decode(InputStream is) throws IOException {
289 return decode(is, true);
290 }
291
292 public int decode(InputStream is, boolean withTag) throws IOException {
293 int codeLength = 0;
294 int subCodeLength = 0;
295 if (withTag) {
296 codeLength += tag.decodeAndCheck(is);
297 }
298
299 BerLength length = new BerLength();
300 codeLength += length.decode(is);
301 int totalLength = length.val;
302
303 while (subCodeLength < totalLength) {
304 PropScell element = new PropScell();
305 subCodeLength += element.decode(is, true);
306 seqOf.add(element);
307 }
308 if (subCodeLength != totalLength) {
309 throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength);
310
311 }
312 codeLength += subCodeLength;
313
314 return codeLength;
315 }
316
317 public void encodeAndSave(int encodingSizeGuess) throws IOException {
318 BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
319 encode(os, false);
320 code = os.getArray();
321 }
322
323 public String toString() {
324 StringBuilder sb = new StringBuilder();
325 appendAsString(sb, 0);
326 return sb.toString();
327 }
328
329 public void appendAsString(StringBuilder sb, int indentLevel) {
330
331 sb.append("[\n");
332 for (int i = 0; i < indentLevel + 1; i++) {
333 sb.append("\t");
334 }
335 if (seqOf == null) {
slowr13fa5b02017-08-08 16:32:31 -0700336// sb.append("null");
slowr89c2ac12017-08-15 16:20:06 -0700337 } else {
338 Iterator<PropScell> it = seqOf.iterator();
339 if (it.hasNext()) {
340 it.next().appendAsString(sb, indentLevel + 1);
341 while (it.hasNext()) {
342 sb.append(",\n");
343 for (int i = 0; i < indentLevel + 1; i++) {
344 sb.append("\t");
345 }
346 it.next().appendAsString(sb, indentLevel + 1);
347 }
348 }
349 }
slowr13fa5b02017-08-08 16:32:31 -0700350
slowr89c2ac12017-08-15 16:20:06 -0700351 sb.append("\n");
352 for (int i = 0; i < indentLevel; i++) {
353 sb.append("\t");
354 }
355 sb.append("]");
356 }
slowr13fa5b02017-08-08 16:32:31 -0700357
slowr89c2ac12017-08-15 16:20:06 -0700358 public void addPropScell(PropScell propScell) {
359 seqOf.add(propScell);
360 }
361 }
slowr13fa5b02017-08-08 16:32:31 -0700362
363}
364