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