blob: 7f86f7ce64c110ac0cd48ac1fe0db51481f4baa2 [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.openmuc.jasn1.ber.BerByteArrayOutputStream;
8import org.openmuc.jasn1.ber.BerLength;
9import org.openmuc.jasn1.ber.BerTag;
10import org.openmuc.jasn1.ber.types.BerInteger;
11import org.onosproject.xran.codecs.api.CRNTI;
12import org.onosproject.xran.codecs.api.ECGI;
13import org.onosproject.xran.codecs.api.ERABParams;
14import org.onosproject.xran.codecs.api.UEAMBR;
15
16import java.io.IOException;
17import java.io.InputStream;
18import java.io.Serializable;
19
20public class BearerAdmissionRequest implements Serializable {
21
22 private static final long serialVersionUID = 1L;
23
24 public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
25
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 void setCrnti(CRNTI crnti) {
41 this.crnti = crnti;
42 }
43
44 public CRNTI getCrnti() {
45 return crnti;
46 }
47
48 public void setEcgi(ECGI ecgi) {
49 this.ecgi = ecgi;
50 }
51
52 public ECGI getEcgi() {
53 return ecgi;
54 }
55
56 public void setUeAmbr(UEAMBR ueAmbr) {
57 this.ueAmbr = ueAmbr;
58 }
59
60 public UEAMBR getUeAmbr() {
61 return ueAmbr;
62 }
63
64 public void setNumErabs(BerInteger numErabs) {
65 this.numErabs = numErabs;
66 }
67
68 public BerInteger getNumErabs() {
69 return numErabs;
70 }
71
72 public void setErabParams(ERABParams erabParams) {
73 this.erabParams = erabParams;
74 }
75
76 public ERABParams getErabParams() {
77 return 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 }
157 else {
158 throw new IOException("Tag does not match the mandatory sequence element tag.");
159 }
160
161 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
162 ecgi = new ECGI();
163 subCodeLength += ecgi.decode(is, false);
164 subCodeLength += berTag.decode(is);
165 }
166 else {
167 throw new IOException("Tag does not match the mandatory sequence element tag.");
168 }
169
170 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) {
171 ueAmbr = new UEAMBR();
172 subCodeLength += ueAmbr.decode(is, false);
173 subCodeLength += berTag.decode(is);
174 }
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.PRIMITIVE, 3)) {
180 numErabs = new BerInteger();
181 subCodeLength += numErabs.decode(is, false);
182 subCodeLength += berTag.decode(is);
183 }
184 else {
185 throw new IOException("Tag does not match the mandatory sequence element tag.");
186 }
187
188 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 4)) {
189 erabParams = new ERABParams();
190 subCodeLength += erabParams.decode(is, false);
191 if (subCodeLength == totalLength) {
192 return codeLength;
193 }
194 }
195 throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
196
197
198 }
199
200 public void encodeAndSave(int encodingSizeGuess) throws IOException {
201 BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
202 encode(os, false);
203 code = os.getArray();
204 }
205
206 public String toString() {
207 StringBuilder sb = new StringBuilder();
208 appendAsString(sb, 0);
209 return sb.toString();
210 }
211
212 public void appendAsString(StringBuilder sb, int indentLevel) {
213
214 sb.append("{");
215 sb.append("\n");
216 for (int i = 0; i < indentLevel + 1; i++) {
217 sb.append("\t");
218 }
219 if (crnti != null) {
220 sb.append("\"crnti\": ").append(crnti);
221 }
222
223 sb.append(",\n");
224 for (int i = 0; i < indentLevel + 1; i++) {
225 sb.append("\t");
226 }
227 if (ecgi != null) {
228 sb.append("\"ecgi\": ");
229 ecgi.appendAsString(sb, indentLevel + 1);
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 }
240
241 sb.append(",\n");
242 for (int i = 0; i < indentLevel + 1; i++) {
243 sb.append("\t");
244 }
245 if (numErabs != null) {
246 sb.append("\"numErabs\": ").append(numErabs);
247 }
248
249 sb.append(",\n");
250 for (int i = 0; i < indentLevel + 1; i++) {
251 sb.append("\t");
252 }
253 if (erabParams != null) {
254 sb.append("\"erabParams\": ");
255 erabParams.appendAsString(sb, indentLevel + 1);
256 }
257
258 sb.append("\n");
259 for (int i = 0; i < indentLevel; i++) {
260 sb.append("\t");
261 }
262 sb.append("}");
263 }
264
265}
266