blob: cd68d7f435c13c22368da51224e871cd0b0a8254 [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 */
4package org.onosproject.xran.codecs.pdu;
5
slowr60d4d102017-08-16 18:33:58 -07006import com.fasterxml.jackson.annotation.JsonIgnore;
7import com.fasterxml.jackson.annotation.JsonValue;
slowr13fa5b02017-08-08 16:32:31 -07008import org.onosproject.xran.codecs.api.CRNTI;
9import org.onosproject.xran.codecs.api.ECGI;
10import org.onosproject.xran.codecs.api.TrafficSplitPercentage;
slowr60d4d102017-08-16 18:33:58 -070011import org.onosproject.xran.codecs.ber.BerByteArrayOutputStream;
12import org.onosproject.xran.codecs.ber.BerLength;
13import org.onosproject.xran.codecs.ber.BerTag;
slowr13fa5b02017-08-08 16:32:31 -070014
15import java.io.IOException;
16import java.io.InputStream;
17import java.io.Serializable;
18import java.util.ArrayList;
19import java.util.Iterator;
20import java.util.List;
21
22public class TrafficSplitConfig implements Serializable {
23
24 private static final long serialVersionUID = 1L;
25
26 public static class TrafficSplitPercent implements Serializable {
27
28 private static final long serialVersionUID = 1L;
29
30 public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
slowr60d4d102017-08-16 18:33:58 -070031 @JsonIgnore
slowr13fa5b02017-08-08 16:32:31 -070032 public byte[] code = null;
33 private List<TrafficSplitPercentage> seqOf = null;
34
35 public TrafficSplitPercent() {
36 seqOf = new ArrayList<TrafficSplitPercentage>();
37 }
38
39 public TrafficSplitPercent(byte[] code) {
40 this.code = code;
41 }
42
slowr60d4d102017-08-16 18:33:58 -070043 @JsonValue
slowr13fa5b02017-08-08 16:32:31 -070044 public List<TrafficSplitPercentage> getTrafficSplitPercentage() {
45 if (seqOf == null) {
46 seqOf = new ArrayList<TrafficSplitPercentage>();
47 }
48 return seqOf;
49 }
50
51 public int encode(BerByteArrayOutputStream os) throws IOException {
52 return encode(os, true);
53 }
54
55 public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
56
57 if (code != null) {
58 for (int i = code.length - 1; i >= 0; i--) {
59 os.write(code[i]);
60 }
61 if (withTag) {
62 return tag.encode(os) + code.length;
63 }
64 return code.length;
65 }
66
67 int codeLength = 0;
68 for (int i = (seqOf.size() - 1); i >= 0; i--) {
69 codeLength += seqOf.get(i).encode(os, true);
70 }
71
72 codeLength += BerLength.encodeLength(os, codeLength);
73
74 if (withTag) {
75 codeLength += tag.encode(os);
76 }
77
78 return codeLength;
79 }
80
81 public int decode(InputStream is) throws IOException {
82 return decode(is, true);
83 }
84
85 public int decode(InputStream is, boolean withTag) throws IOException {
86 int codeLength = 0;
87 int subCodeLength = 0;
88 if (withTag) {
89 codeLength += tag.decodeAndCheck(is);
90 }
91
92 BerLength length = new BerLength();
93 codeLength += length.decode(is);
94 int totalLength = length.val;
95
96 while (subCodeLength < totalLength) {
97 TrafficSplitPercentage element = new TrafficSplitPercentage();
98 subCodeLength += element.decode(is, true);
99 seqOf.add(element);
100 }
101 if (subCodeLength != totalLength) {
102 throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength);
103
104 }
105 codeLength += subCodeLength;
106
107 return codeLength;
108 }
109
110 public void encodeAndSave(int encodingSizeGuess) throws IOException {
111 BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
112 encode(os, false);
113 code = os.getArray();
114 }
115
116 public String toString() {
117 StringBuilder sb = new StringBuilder();
118 appendAsString(sb, 0);
119 return sb.toString();
120 }
121
122 public void appendAsString(StringBuilder sb, int indentLevel) {
123
124 sb.append("[\n");
125 for (int i = 0; i < indentLevel + 1; i++) {
126 sb.append("\t");
127 }
128 if (seqOf == null) {
129// sb.append("null");
130 }
131 else {
132 Iterator<TrafficSplitPercentage> it = seqOf.iterator();
133 if (it.hasNext()) {
134 it.next().appendAsString(sb, indentLevel + 1);
135 while (it.hasNext()) {
136 sb.append(",\n");
137 for (int i = 0; i < indentLevel + 1; i++) {
138 sb.append("\t");
139 }
140 it.next().appendAsString(sb, indentLevel + 1);
141 }
142 }
143 }
144
145 sb.append("\n");
146 for (int i = 0; i < indentLevel; i++) {
147 sb.append("\t");
148 }
149 sb.append("]");
150 }
151
152 }
153
154 public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
155
slowr60d4d102017-08-16 18:33:58 -0700156 @JsonIgnore public byte[] code = null;
slowr13fa5b02017-08-08 16:32:31 -0700157 private CRNTI crnti = null;
158 private ECGI ecgi = null;
159 private TrafficSplitPercent trafficSplitPercent = null;
160
161 public TrafficSplitConfig() {
162 }
163
164 public TrafficSplitConfig(byte[] code) {
165 this.code = code;
166 }
167
168 public void setCrnti(CRNTI crnti) {
169 this.crnti = crnti;
170 }
171
172 public CRNTI getCrnti() {
173 return crnti;
174 }
175
176 public void setEcgi(ECGI ecgi) {
177 this.ecgi = ecgi;
178 }
179
180 public ECGI getEcgi() {
181 return ecgi;
182 }
183
184 public void setTrafficSplitPercent(TrafficSplitPercent trafficSplitPercent) {
185 this.trafficSplitPercent = trafficSplitPercent;
186 }
187
188 public TrafficSplitPercent getTrafficSplitPercent() {
189 return trafficSplitPercent;
190 }
191
192 public int encode(BerByteArrayOutputStream os) throws IOException {
193 return encode(os, true);
194 }
195
196 public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
197
198 if (code != null) {
199 for (int i = code.length - 1; i >= 0; i--) {
200 os.write(code[i]);
201 }
202 if (withTag) {
203 return tag.encode(os) + code.length;
204 }
205 return code.length;
206 }
207
208 int codeLength = 0;
209 codeLength += trafficSplitPercent.encode(os, false);
210 // write tag: CONTEXT_CLASS, CONSTRUCTED, 2
211 os.write(0xA2);
212 codeLength += 1;
213
214 codeLength += ecgi.encode(os, false);
215 // write tag: CONTEXT_CLASS, CONSTRUCTED, 1
216 os.write(0xA1);
217 codeLength += 1;
218
219 codeLength += crnti.encode(os, false);
220 // write tag: CONTEXT_CLASS, PRIMITIVE, 0
221 os.write(0x80);
222 codeLength += 1;
223
224 codeLength += BerLength.encodeLength(os, codeLength);
225
226 if (withTag) {
227 codeLength += tag.encode(os);
228 }
229
230 return codeLength;
231
232 }
233
234 public int decode(InputStream is) throws IOException {
235 return decode(is, true);
236 }
237
238 public int decode(InputStream is, boolean withTag) throws IOException {
239 int codeLength = 0;
240 int subCodeLength = 0;
241 BerTag berTag = new BerTag();
242
243 if (withTag) {
244 codeLength += tag.decodeAndCheck(is);
245 }
246
247 BerLength length = new BerLength();
248 codeLength += length.decode(is);
249
250 int totalLength = length.val;
251 codeLength += totalLength;
252
253 subCodeLength += berTag.decode(is);
254 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
255 crnti = new CRNTI();
256 subCodeLength += crnti.decode(is, false);
257 subCodeLength += berTag.decode(is);
258 }
259 else {
260 throw new IOException("Tag does not match the mandatory sequence element tag.");
261 }
262
263 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
264 ecgi = new ECGI();
265 subCodeLength += ecgi.decode(is, false);
266 subCodeLength += berTag.decode(is);
267 }
268 else {
269 throw new IOException("Tag does not match the mandatory sequence element tag.");
270 }
271
272 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) {
273 trafficSplitPercent = new TrafficSplitPercent();
274 subCodeLength += trafficSplitPercent.decode(is, false);
275 if (subCodeLength == totalLength) {
276 return codeLength;
277 }
278 }
279 throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
280
281
282 }
283
284 public void encodeAndSave(int encodingSizeGuess) throws IOException {
285 BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
286 encode(os, false);
287 code = os.getArray();
288 }
289
290 public String toString() {
291 StringBuilder sb = new StringBuilder();
292 appendAsString(sb, 0);
293 return sb.toString();
294 }
295
296 public void appendAsString(StringBuilder sb, int indentLevel) {
297
298 sb.append("{");
299 sb.append("\n");
300 for (int i = 0; i < indentLevel + 1; i++) {
301 sb.append("\t");
302 }
303 if (crnti != null) {
slowr60d4d102017-08-16 18:33:58 -0700304 sb.append("crnti: ").append(crnti);
slowr13fa5b02017-08-08 16:32:31 -0700305 }
306
307 sb.append(",\n");
308 for (int i = 0; i < indentLevel + 1; i++) {
309 sb.append("\t");
310 }
311 if (ecgi != null) {
slowr60d4d102017-08-16 18:33:58 -0700312 sb.append("ecgi: ");
slowr13fa5b02017-08-08 16:32:31 -0700313 ecgi.appendAsString(sb, indentLevel + 1);
314 }
315
316 sb.append(",\n");
317 for (int i = 0; i < indentLevel + 1; i++) {
318 sb.append("\t");
319 }
320 if (trafficSplitPercent != null) {
slowr60d4d102017-08-16 18:33:58 -0700321 sb.append("trafficSplitPercent: ");
slowr13fa5b02017-08-08 16:32:31 -0700322 trafficSplitPercent.appendAsString(sb, indentLevel + 1);
323 }
324
325 sb.append("\n");
326 for (int i = 0; i < indentLevel; i++) {
327 sb.append("\t");
328 }
329 sb.append("}");
330 }
331
332}
333