blob: 8f6ad01ad62b329ad05d4b5a37a5593d9e5534f7 [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.ERABResponse;
14
15import java.io.IOException;
16import java.io.InputStream;
17import java.io.Serializable;
18
19public class BearerAdmissionResponse implements Serializable {
20
21 private static final long serialVersionUID = 1L;
22
23 public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
24
25 public byte[] code = null;
26 private CRNTI crnti = null;
27 private ECGI ecgi = null;
28 private BerInteger numErabList = null;
29 private ERABResponse erabResponse = null;
30
31 public BearerAdmissionResponse() {
32 }
33
34 public BearerAdmissionResponse(byte[] code) {
35 this.code = code;
36 }
37
38 public void setCrnti(CRNTI crnti) {
39 this.crnti = crnti;
40 }
41
42 public CRNTI getCrnti() {
43 return crnti;
44 }
45
46 public void setEcgi(ECGI ecgi) {
47 this.ecgi = ecgi;
48 }
49
50 public ECGI getEcgi() {
51 return ecgi;
52 }
53
54 public void setNumErabList(BerInteger numErabList) {
55 this.numErabList = numErabList;
56 }
57
58 public BerInteger getNumErabList() {
59 return numErabList;
60 }
61
62 public void setErabResponse(ERABResponse erabResponse) {
63 this.erabResponse = erabResponse;
64 }
65
66 public ERABResponse getErabResponse() {
67 return erabResponse;
68 }
69
70 public int encode(BerByteArrayOutputStream os) throws IOException {
71 return encode(os, true);
72 }
73
74 public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
75
76 if (code != null) {
77 for (int i = code.length - 1; i >= 0; i--) {
78 os.write(code[i]);
79 }
80 if (withTag) {
81 return tag.encode(os) + code.length;
82 }
83 return code.length;
84 }
85
86 int codeLength = 0;
87 codeLength += erabResponse.encode(os, false);
88 // write tag: CONTEXT_CLASS, CONSTRUCTED, 3
89 os.write(0xA3);
90 codeLength += 1;
91
92 codeLength += numErabList.encode(os, false);
93 // write tag: CONTEXT_CLASS, PRIMITIVE, 2
94 os.write(0x82);
95 codeLength += 1;
96
97 codeLength += ecgi.encode(os, false);
98 // write tag: CONTEXT_CLASS, CONSTRUCTED, 1
99 os.write(0xA1);
100 codeLength += 1;
101
102 codeLength += crnti.encode(os, false);
103 // write tag: CONTEXT_CLASS, PRIMITIVE, 0
104 os.write(0x80);
105 codeLength += 1;
106
107 codeLength += BerLength.encodeLength(os, codeLength);
108
109 if (withTag) {
110 codeLength += tag.encode(os);
111 }
112
113 return codeLength;
114
115 }
116
117 public int decode(InputStream is) throws IOException {
118 return decode(is, true);
119 }
120
121 public int decode(InputStream is, boolean withTag) throws IOException {
122 int codeLength = 0;
123 int subCodeLength = 0;
124 BerTag berTag = new BerTag();
125
126 if (withTag) {
127 codeLength += tag.decodeAndCheck(is);
128 }
129
130 BerLength length = new BerLength();
131 codeLength += length.decode(is);
132
133 int totalLength = length.val;
134 codeLength += totalLength;
135
136 subCodeLength += berTag.decode(is);
137 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
138 crnti = new CRNTI();
139 subCodeLength += crnti.decode(is, false);
140 subCodeLength += berTag.decode(is);
141 }
142 else {
143 throw new IOException("Tag does not match the mandatory sequence element tag.");
144 }
145
146 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
147 ecgi = new ECGI();
148 subCodeLength += ecgi.decode(is, false);
149 subCodeLength += berTag.decode(is);
150 }
151 else {
152 throw new IOException("Tag does not match the mandatory sequence element tag.");
153 }
154
155 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 2)) {
156 numErabList = new BerInteger();
157 subCodeLength += numErabList.decode(is, false);
158 subCodeLength += berTag.decode(is);
159 }
160 else {
161 throw new IOException("Tag does not match the mandatory sequence element tag.");
162 }
163
164 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 3)) {
165 erabResponse = new ERABResponse();
166 subCodeLength += erabResponse.decode(is, false);
167 if (subCodeLength == totalLength) {
168 return codeLength;
169 }
170 }
171 throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
172
173
174 }
175
176 public void encodeAndSave(int encodingSizeGuess) throws IOException {
177 BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
178 encode(os, false);
179 code = os.getArray();
180 }
181
182 public String toString() {
183 StringBuilder sb = new StringBuilder();
184 appendAsString(sb, 0);
185 return sb.toString();
186 }
187
188 public void appendAsString(StringBuilder sb, int indentLevel) {
189
190 sb.append("{");
191 sb.append("\n");
192 for (int i = 0; i < indentLevel + 1; i++) {
193 sb.append("\t");
194 }
195 if (crnti != null) {
196 sb.append("\"crnti\": ").append(crnti);
197 }
198
199 sb.append(",\n");
200 for (int i = 0; i < indentLevel + 1; i++) {
201 sb.append("\t");
202 }
203 if (ecgi != null) {
204 sb.append("\"ecgi\": ");
205 ecgi.appendAsString(sb, indentLevel + 1);
206 }
207
208 sb.append(",\n");
209 for (int i = 0; i < indentLevel + 1; i++) {
210 sb.append("\t");
211 }
212 if (numErabList != null) {
213 sb.append("\"numErabList\": ").append(numErabList);
214 }
215
216 sb.append(",\n");
217 for (int i = 0; i < indentLevel + 1; i++) {
218 sb.append("\t");
219 }
220 if (erabResponse != null) {
221 sb.append("\"erabResponse\": ");
222 erabResponse.appendAsString(sb, indentLevel + 1);
223 }
224
225 sb.append("\n");
226 for (int i = 0; i < indentLevel; i++) {
227 sb.append("\t");
228 }
229 sb.append("}");
230 }
231
232}
233