blob: 3f31a27182f0a9f6869bf7e47784f1360b6b1cb1 [file] [log] [blame]
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -08001/**
2 * This class file was automatically generated by jASN1 v1.8.2 (http://www.openmuc.org)
3 */
4
5package org.onosproject.xran.asn1lib.pdu;
6
7import com.fasterxml.jackson.annotation.JsonIgnore;
8import org.onosproject.xran.asn1lib.api.CRNTI;
9import org.onosproject.xran.asn1lib.api.ECGI;
10import org.onosproject.xran.asn1lib.api.ERABParams;
11import org.onosproject.xran.asn1lib.api.UEAMBR;
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.BerInteger;
16
17import java.io.IOException;
18import java.io.InputStream;
19import java.io.Serializable;
20
21public class BearerAdmissionRequest implements Serializable {
22
23 public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
24 private static final long serialVersionUID = 1L;
25 @JsonIgnore
26 public byte[] code = null;
27 private CRNTI crnti = null;
28 private ECGI ecgi = null;
29 private UEAMBR ueAmbr = null;
30 private BerInteger numErabs = null;
31 private ERABParams erabParams = null;
32
33 public BearerAdmissionRequest() {
34 }
35
36 public BearerAdmissionRequest(byte[] code) {
37 this.code = code;
38 }
39
40 public CRNTI getCrnti() {
41 return crnti;
42 }
43
44 public void setCrnti(CRNTI crnti) {
45 this.crnti = crnti;
46 }
47
48 public ECGI getEcgi() {
49 return ecgi;
50 }
51
52 public void setEcgi(ECGI ecgi) {
53 this.ecgi = ecgi;
54 }
55
56 public UEAMBR getUeAmbr() {
57 return ueAmbr;
58 }
59
60 public void setUeAmbr(UEAMBR ueAmbr) {
61 this.ueAmbr = ueAmbr;
62 }
63
64 public BerInteger getNumErabs() {
65 return numErabs;
66 }
67
68 public void setNumErabs(BerInteger numErabs) {
69 this.numErabs = numErabs;
70 }
71
72 public ERABParams getErabParams() {
73 return erabParams;
74 }
75
76 public void setErabParams(ERABParams erabParams) {
77 this.erabParams = erabParams;
78 }
79
80 public int encode(BerByteArrayOutputStream os) throws IOException {
81 return encode(os, true);
82 }
83
84 public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
85
86 if (code != null) {
87 for (int i = code.length - 1; i >= 0; i--) {
88 os.write(code[i]);
89 }
90 if (withTag) {
91 return tag.encode(os) + code.length;
92 }
93 return code.length;
94 }
95
96 int codeLength = 0;
97 codeLength += erabParams.encode(os, false);
98 // write tag: CONTEXT_CLASS, CONSTRUCTED, 4
99 os.write(0xA4);
100 codeLength += 1;
101
102 codeLength += numErabs.encode(os, false);
103 // write tag: CONTEXT_CLASS, PRIMITIVE, 3
104 os.write(0x83);
105 codeLength += 1;
106
107 codeLength += ueAmbr.encode(os, false);
108 // write tag: CONTEXT_CLASS, CONSTRUCTED, 2
109 os.write(0xA2);
110 codeLength += 1;
111
112 codeLength += ecgi.encode(os, false);
113 // write tag: CONTEXT_CLASS, CONSTRUCTED, 1
114 os.write(0xA1);
115 codeLength += 1;
116
117 codeLength += crnti.encode(os, false);
118 // write tag: CONTEXT_CLASS, PRIMITIVE, 0
119 os.write(0x80);
120 codeLength += 1;
121
122 codeLength += BerLength.encodeLength(os, codeLength);
123
124 if (withTag) {
125 codeLength += tag.encode(os);
126 }
127
128 return codeLength;
129
130 }
131
132 public int decode(InputStream is) throws IOException {
133 return decode(is, true);
134 }
135
136 public int decode(InputStream is, boolean withTag) throws IOException {
137 int codeLength = 0;
138 int subCodeLength = 0;
139 BerTag berTag = new BerTag();
140
141 if (withTag) {
142 codeLength += tag.decodeAndCheck(is);
143 }
144
145 BerLength length = new BerLength();
146 codeLength += length.decode(is);
147
148 int totalLength = length.val;
149 codeLength += totalLength;
150
151 subCodeLength += berTag.decode(is);
152 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
153 crnti = new CRNTI();
154 subCodeLength += crnti.decode(is, false);
155 subCodeLength += berTag.decode(is);
156 } else {
157 throw new IOException("Tag does not match the mandatory sequence element tag.");
158 }
159
160 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
161 ecgi = new ECGI();
162 subCodeLength += ecgi.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, 2)) {
169 ueAmbr = new UEAMBR();
170 subCodeLength += ueAmbr.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.PRIMITIVE, 3)) {
177 numErabs = new BerInteger();
178 subCodeLength += numErabs.decode(is, false);
179 subCodeLength += berTag.decode(is);
180 } else {
181 throw new IOException("Tag does not match the mandatory sequence element tag.");
182 }
183
184 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 4)) {
185 erabParams = new ERABParams();
186 subCodeLength += erabParams.decode(is, false);
187 if (subCodeLength == totalLength) {
188 return codeLength;
189 }
190 }
191 throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
192
193
194 }
195
196 public void encodeAndSave(int encodingSizeGuess) throws IOException {
197 BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
198 encode(os, false);
199 code = os.getArray();
200 }
201
202 public String toString() {
203 StringBuilder sb = new StringBuilder();
204 appendAsString(sb, 0);
205 return sb.toString();
206 }
207
208 public void appendAsString(StringBuilder sb, int indentLevel) {
209
210 sb.append("{");
211 sb.append("\n");
212 for (int i = 0; i < indentLevel + 1; i++) {
213 sb.append("\t");
214 }
215 if (crnti != null) {
216 sb.append("crnti: ").append(crnti);
217 } else {
218 sb.append("crnti: <empty-required-field>");
219 }
220
221 sb.append(",\n");
222 for (int i = 0; i < indentLevel + 1; i++) {
223 sb.append("\t");
224 }
225 if (ecgi != null) {
226 sb.append("ecgi: ");
227 ecgi.appendAsString(sb, indentLevel + 1);
228 } else {
229 sb.append("ecgi: <empty-required-field>");
230 }
231
232 sb.append(",\n");
233 for (int i = 0; i < indentLevel + 1; i++) {
234 sb.append("\t");
235 }
236 if (ueAmbr != null) {
237 sb.append("ueAmbr: ");
238 ueAmbr.appendAsString(sb, indentLevel + 1);
239 } else {
240 sb.append("ueAmbr: <empty-required-field>");
241 }
242
243 sb.append(",\n");
244 for (int i = 0; i < indentLevel + 1; i++) {
245 sb.append("\t");
246 }
247 if (numErabs != null) {
248 sb.append("numErabs: ").append(numErabs);
249 } else {
250 sb.append("numErabs: <empty-required-field>");
251 }
252
253 sb.append(",\n");
254 for (int i = 0; i < indentLevel + 1; i++) {
255 sb.append("\t");
256 }
257 if (erabParams != null) {
258 sb.append("erabParams: ");
259 erabParams.appendAsString(sb, indentLevel + 1);
260 } else {
261 sb.append("erabParams: <empty-required-field>");
262 }
263
264 sb.append("\n");
265 for (int i = 0; i < indentLevel; i++) {
266 sb.append("\t");
267 }
268 sb.append("}");
269 }
270
271}
272