blob: b807e5062c91739bdd17f73eea75fea507bd9c25 [file] [log] [blame]
slowr13fa5b02017-08-08 16:32:31 -07001/**
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -08002 * This class file was automatically generated by jASN1 v1.8.2 (http://www.openmuc.org)
slowr13fa5b02017-08-08 16:32:31 -07003 */
4
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -08005package org.onosproject.xran.asn1lib.pdu;
slowr13fa5b02017-08-08 16:32:31 -07006
slowr60d4d102017-08-16 18:33:58 -07007import com.fasterxml.jackson.annotation.JsonIgnore;
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -08008import org.onosproject.xran.asn1lib.api.AdmEstCause;
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;
slowr13fa5b02017-08-08 16:32:31 -070014
15import java.io.IOException;
16import java.io.InputStream;
17import java.io.Serializable;
18
19public class UEAdmissionRequest 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
slowr60d4d102017-08-16 18:33:58 -070025 @JsonIgnore
slowr13fa5b02017-08-08 16:32:31 -070026 public byte[] code = null;
27 private CRNTI crnti = null;
28 private ECGI ecgi = null;
29 private AdmEstCause admEstCause = null;
30
31 public UEAdmissionRequest() {
32 }
33
34 public UEAdmissionRequest(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 setAdmEstCause(AdmEstCause admEstCause) {
55 this.admEstCause = admEstCause;
56 }
57
58 public AdmEstCause getAdmEstCause() {
59 return admEstCause;
60 }
61
62 public int encode(BerByteArrayOutputStream os) throws IOException {
63 return encode(os, true);
64 }
65
66 public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
67
68 if (code != null) {
69 for (int i = code.length - 1; i >= 0; i--) {
70 os.write(code[i]);
71 }
72 if (withTag) {
73 return tag.encode(os) + code.length;
74 }
75 return code.length;
76 }
77
78 int codeLength = 0;
79 codeLength += admEstCause.encode(os, false);
80 // write tag: CONTEXT_CLASS, PRIMITIVE, 2
81 os.write(0x82);
82 codeLength += 1;
83
84 codeLength += ecgi.encode(os, false);
85 // write tag: CONTEXT_CLASS, CONSTRUCTED, 1
86 os.write(0xA1);
87 codeLength += 1;
88
89 codeLength += crnti.encode(os, false);
90 // write tag: CONTEXT_CLASS, PRIMITIVE, 0
91 os.write(0x80);
92 codeLength += 1;
93
94 codeLength += BerLength.encodeLength(os, codeLength);
95
96 if (withTag) {
97 codeLength += tag.encode(os);
98 }
99
100 return codeLength;
101
102 }
103
104 public int decode(InputStream is) throws IOException {
105 return decode(is, true);
106 }
107
108 public int decode(InputStream is, boolean withTag) throws IOException {
109 int codeLength = 0;
110 int subCodeLength = 0;
111 BerTag berTag = new BerTag();
112
113 if (withTag) {
114 codeLength += tag.decodeAndCheck(is);
115 }
116
117 BerLength length = new BerLength();
118 codeLength += length.decode(is);
119
120 int totalLength = length.val;
121 codeLength += totalLength;
122
123 subCodeLength += berTag.decode(is);
124 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
125 crnti = new CRNTI();
126 subCodeLength += crnti.decode(is, false);
127 subCodeLength += berTag.decode(is);
128 }
129 else {
130 throw new IOException("Tag does not match the mandatory sequence element tag.");
131 }
132
133 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
134 ecgi = new ECGI();
135 subCodeLength += ecgi.decode(is, false);
136 subCodeLength += berTag.decode(is);
137 }
138 else {
139 throw new IOException("Tag does not match the mandatory sequence element tag.");
140 }
141
142 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 2)) {
143 admEstCause = new AdmEstCause();
144 subCodeLength += admEstCause.decode(is, false);
145 if (subCodeLength == totalLength) {
146 return codeLength;
147 }
148 }
149 throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
150
151
152 }
153
154 public void encodeAndSave(int encodingSizeGuess) throws IOException {
155 BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
156 encode(os, false);
157 code = os.getArray();
158 }
159
160 public String toString() {
161 StringBuilder sb = new StringBuilder();
162 appendAsString(sb, 0);
163 return sb.toString();
164 }
165
166 public void appendAsString(StringBuilder sb, int indentLevel) {
167
168 sb.append("{");
169 sb.append("\n");
170 for (int i = 0; i < indentLevel + 1; i++) {
171 sb.append("\t");
172 }
173 if (crnti != null) {
slowr60d4d102017-08-16 18:33:58 -0700174 sb.append("crnti: ").append(crnti);
slowr13fa5b02017-08-08 16:32:31 -0700175 }
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -0800176 else {
177 sb.append("crnti: <empty-required-field>");
178 }
slowr13fa5b02017-08-08 16:32:31 -0700179
180 sb.append(",\n");
181 for (int i = 0; i < indentLevel + 1; i++) {
182 sb.append("\t");
183 }
184 if (ecgi != null) {
slowr60d4d102017-08-16 18:33:58 -0700185 sb.append("ecgi: ");
slowr13fa5b02017-08-08 16:32:31 -0700186 ecgi.appendAsString(sb, indentLevel + 1);
187 }
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -0800188 else {
189 sb.append("ecgi: <empty-required-field>");
190 }
slowr13fa5b02017-08-08 16:32:31 -0700191
192 sb.append(",\n");
193 for (int i = 0; i < indentLevel + 1; i++) {
194 sb.append("\t");
195 }
196 if (admEstCause != null) {
slowr60d4d102017-08-16 18:33:58 -0700197 sb.append("admEstCause: ").append(admEstCause);
slowr13fa5b02017-08-08 16:32:31 -0700198 }
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -0800199 else {
200 sb.append("admEstCause: <empty-required-field>");
201 }
slowr13fa5b02017-08-08 16:32:31 -0700202
203 sb.append("\n");
204 for (int i = 0; i < indentLevel; i++) {
205 sb.append("\t");
206 }
207 sb.append("}");
208 }
209
210}
211