blob: e06c0fd650d6b972a6be91c52ddfb527cae88902 [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.AdmEstResponse;
9import org.onosproject.xran.asn1lib.api.CRNTI;
10import org.onosproject.xran.asn1lib.api.ECGI;
11import org.onosproject.xran.asn1lib.ber.BerByteArrayOutputStream;
12import org.onosproject.xran.asn1lib.ber.BerLength;
13import org.onosproject.xran.asn1lib.ber.BerTag;
14import org.onosproject.xran.asn1lib.ber.types.string.BerUTF8String;
15
16import java.io.IOException;
17import java.io.InputStream;
18import java.io.Serializable;
19import java.io.UnsupportedEncodingException;
20
21public class UEAdmissionResponse 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 AdmEstResponse admEstResponse = null;
30
31 public UEAdmissionResponse() {
32 }
33
34 public UEAdmissionResponse(byte[] code) {
35 this.code = code;
36 }
37
38 public static XrancPdu constructPacket(ECGI ecgi, CRNTI crnti, boolean b) {
39 AdmEstResponse response = new AdmEstResponse(b ? 0 : 1);
40
41 UEAdmissionResponse ueAdmissionResponse = new UEAdmissionResponse();
42 ueAdmissionResponse.setCrnti(crnti);
43 ueAdmissionResponse.setEcgi(ecgi);
44 ueAdmissionResponse.setAdmEstResponse(response);
45
46 XrancPduBody body = new XrancPduBody();
47 body.setUEAdmissionResponse(ueAdmissionResponse);
48
49 BerUTF8String ver = null;
50 try {
51 ver = new BerUTF8String("5");
52 } catch (UnsupportedEncodingException e) {
53 e.printStackTrace();
54 }
55 XrancApiID apiID = new XrancApiID(3);
56 XrancPduHdr hdr = new XrancPduHdr();
57 hdr.setVer(ver);
58 hdr.setApiId(apiID);
59
60 XrancPdu pdu = new XrancPdu();
61 pdu.setHdr(hdr);
62 pdu.setBody(body);
63 return pdu;
64 }
65
66 public CRNTI getCrnti() {
67 return crnti;
68 }
69
70 public void setCrnti(CRNTI crnti) {
71 this.crnti = crnti;
72 }
73
74 public ECGI getEcgi() {
75 return ecgi;
76 }
77
78 public void setEcgi(ECGI ecgi) {
79 this.ecgi = ecgi;
80 }
81
82 public AdmEstResponse getAdmEstResponse() {
83 return admEstResponse;
84 }
85
86 public void setAdmEstResponse(AdmEstResponse admEstResponse) {
87 this.admEstResponse = admEstResponse;
88 }
89
90 public int encode(BerByteArrayOutputStream os) throws IOException {
91 return encode(os, true);
92 }
93
94 public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
95
96 if (code != null) {
97 for (int i = code.length - 1; i >= 0; i--) {
98 os.write(code[i]);
99 }
100 if (withTag) {
101 return tag.encode(os) + code.length;
102 }
103 return code.length;
104 }
105
106 int codeLength = 0;
107 codeLength += admEstResponse.encode(os, false);
108 // write tag: CONTEXT_CLASS, PRIMITIVE, 2
109 os.write(0x82);
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.PRIMITIVE, 2)) {
169 admEstResponse = new AdmEstResponse();
170 subCodeLength += admEstResponse.decode(is, false);
171 if (subCodeLength == totalLength) {
172 return codeLength;
173 }
174 }
175 throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
176
177
178 }
179
180 public void encodeAndSave(int encodingSizeGuess) throws IOException {
181 BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
182 encode(os, false);
183 code = os.getArray();
184 }
185
186 public String toString() {
187 StringBuilder sb = new StringBuilder();
188 appendAsString(sb, 0);
189 return sb.toString();
190 }
191
192 public void appendAsString(StringBuilder sb, int indentLevel) {
193
194 sb.append("{");
195 sb.append("\n");
196 for (int i = 0; i < indentLevel + 1; i++) {
197 sb.append("\t");
198 }
199 if (crnti != null) {
200 sb.append("crnti: ").append(crnti);
201 } else {
202 sb.append("crnti: <empty-required-field>");
203 }
204
205 sb.append(",\n");
206 for (int i = 0; i < indentLevel + 1; i++) {
207 sb.append("\t");
208 }
209 if (ecgi != null) {
210 sb.append("ecgi: ");
211 ecgi.appendAsString(sb, indentLevel + 1);
212 } else {
213 sb.append("ecgi: <empty-required-field>");
214 }
215
216 sb.append(",\n");
217 for (int i = 0; i < indentLevel + 1; i++) {
218 sb.append("\t");
219 }
220 if (admEstResponse != null) {
221 sb.append("admEstResponse: ").append(admEstResponse);
222 } else {
223 sb.append("admEstResponse: <empty-required-field>");
224 }
225
226 sb.append("\n");
227 for (int i = 0; i < indentLevel; i++) {
228 sb.append("\t");
229 }
230 sb.append("}");
231 }
232
233}
234