blob: 8600ba3cea837bf740cd4875af519456d4a699c6 [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;
slowr13fa5b02017-08-08 16:32:31 -070011import org.onosproject.xran.codecs.api.AdmEstResponse;
12import org.onosproject.xran.codecs.api.CRNTI;
13import org.onosproject.xran.codecs.api.ECGI;
slowr60d4d102017-08-16 18:33:58 -070014import org.onosproject.xran.codecs.ber.types.string.BerUTF8String;
slowr13fa5b02017-08-08 16:32:31 -070015
16import java.io.IOException;
17import java.io.InputStream;
18import java.io.Serializable;
slowr8ddc2b12017-08-14 14:13:38 -070019import java.io.UnsupportedEncodingException;
slowr13fa5b02017-08-08 16:32:31 -070020
21public class UEAdmissionResponse 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 AdmEstResponse admEstResponse = null;
32
33 public UEAdmissionResponse() {
34 }
35
36 public UEAdmissionResponse(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 setAdmEstResponse(AdmEstResponse admEstResponse) {
57 this.admEstResponse = admEstResponse;
58 }
59
60 public AdmEstResponse getAdmEstResponse() {
61 return admEstResponse;
62 }
63
64 public int encode(BerByteArrayOutputStream os) throws IOException {
65 return encode(os, true);
66 }
67
68 public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
69
70 if (code != null) {
71 for (int i = code.length - 1; i >= 0; i--) {
72 os.write(code[i]);
73 }
74 if (withTag) {
75 return tag.encode(os) + code.length;
76 }
77 return code.length;
78 }
79
80 int codeLength = 0;
81 codeLength += admEstResponse.encode(os, false);
82 // write tag: CONTEXT_CLASS, PRIMITIVE, 2
83 os.write(0x82);
84 codeLength += 1;
85
86 codeLength += ecgi.encode(os, false);
87 // write tag: CONTEXT_CLASS, CONSTRUCTED, 1
88 os.write(0xA1);
89 codeLength += 1;
90
91 codeLength += crnti.encode(os, false);
92 // write tag: CONTEXT_CLASS, PRIMITIVE, 0
93 os.write(0x80);
94 codeLength += 1;
95
96 codeLength += BerLength.encodeLength(os, codeLength);
97
98 if (withTag) {
99 codeLength += tag.encode(os);
100 }
101
102 return codeLength;
103
104 }
105
106 public int decode(InputStream is) throws IOException {
107 return decode(is, true);
108 }
109
110 public int decode(InputStream is, boolean withTag) throws IOException {
111 int codeLength = 0;
112 int subCodeLength = 0;
113 BerTag berTag = new BerTag();
114
115 if (withTag) {
116 codeLength += tag.decodeAndCheck(is);
117 }
118
119 BerLength length = new BerLength();
120 codeLength += length.decode(is);
121
122 int totalLength = length.val;
123 codeLength += totalLength;
124
125 subCodeLength += berTag.decode(is);
126 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
127 crnti = new CRNTI();
128 subCodeLength += crnti.decode(is, false);
129 subCodeLength += berTag.decode(is);
130 }
131 else {
132 throw new IOException("Tag does not match the mandatory sequence element tag.");
133 }
134
135 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
136 ecgi = new ECGI();
137 subCodeLength += ecgi.decode(is, false);
138 subCodeLength += berTag.decode(is);
139 }
140 else {
141 throw new IOException("Tag does not match the mandatory sequence element tag.");
142 }
143
144 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 2)) {
145 admEstResponse = new AdmEstResponse();
146 subCodeLength += admEstResponse.decode(is, false);
147 if (subCodeLength == totalLength) {
148 return codeLength;
149 }
150 }
151 throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
152
153
154 }
155
156 public void encodeAndSave(int encodingSizeGuess) throws IOException {
157 BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
158 encode(os, false);
159 code = os.getArray();
160 }
161
162 public String toString() {
163 StringBuilder sb = new StringBuilder();
164 appendAsString(sb, 0);
165 return sb.toString();
166 }
167
168 public void appendAsString(StringBuilder sb, int indentLevel) {
169
170 sb.append("{");
171 sb.append("\n");
172 for (int i = 0; i < indentLevel + 1; i++) {
173 sb.append("\t");
174 }
175 if (crnti != null) {
slowr60d4d102017-08-16 18:33:58 -0700176 sb.append("crnti: ").append(crnti);
slowr13fa5b02017-08-08 16:32:31 -0700177 }
178
179 sb.append(",\n");
180 for (int i = 0; i < indentLevel + 1; i++) {
181 sb.append("\t");
182 }
183 if (ecgi != null) {
slowr60d4d102017-08-16 18:33:58 -0700184 sb.append("ecgi: ");
slowr13fa5b02017-08-08 16:32:31 -0700185 ecgi.appendAsString(sb, indentLevel + 1);
186 }
187
188 sb.append(",\n");
189 for (int i = 0; i < indentLevel + 1; i++) {
190 sb.append("\t");
191 }
192 if (admEstResponse != null) {
slowr60d4d102017-08-16 18:33:58 -0700193 sb.append("admEstResponse: ").append(admEstResponse);
slowr13fa5b02017-08-08 16:32:31 -0700194 }
195
196 sb.append("\n");
197 for (int i = 0; i < indentLevel; i++) {
198 sb.append("\t");
199 }
200 sb.append("}");
201 }
202
slowr8ddc2b12017-08-14 14:13:38 -0700203 public static XrancPdu constructPacket(ECGI ecgi, CRNTI crnti, boolean b) {
204 AdmEstResponse response = new AdmEstResponse(b ? 0 : 1);
205
206 UEAdmissionResponse ueAdmissionResponse = new UEAdmissionResponse();
207 ueAdmissionResponse.setCrnti(crnti);
208 ueAdmissionResponse.setEcgi(ecgi);
209 ueAdmissionResponse.setAdmEstResponse(response);
210
211 XrancPduBody body = new XrancPduBody();
212 body.setUEAdmissionResponse(ueAdmissionResponse);
213
214 BerUTF8String ver = null;
215 try {
216 ver = new BerUTF8String("3");
217 } catch (UnsupportedEncodingException e) {
218 e.printStackTrace();
219 }
220 XrancApiID apiID = new XrancApiID(3);
221 XrancPduHdr hdr = new XrancPduHdr();
222 hdr.setVer(ver);
223 hdr.setApiId(apiID);
224
225 XrancPdu pdu = new XrancPdu();
226 pdu.setHdr(hdr);
227 pdu.setBody(body);
228 return pdu;
229 }
230
slowr13fa5b02017-08-08 16:32:31 -0700231}
232