blob: 5a06a8abc14c07d95a551f78e8276e2478f61df8 [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.AdmEstStatus;
12import org.onosproject.xran.codecs.api.CRNTI;
13import org.onosproject.xran.codecs.api.ECGI;
14
15import java.io.IOException;
16import java.io.InputStream;
17import java.io.Serializable;
18
19public class UEAdmissionStatus 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 AdmEstStatus admEstStatus = null;
30
31 public UEAdmissionStatus() {
32 }
33
34 public UEAdmissionStatus(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 setAdmEstStatus(AdmEstStatus admEstStatus) {
55 this.admEstStatus = admEstStatus;
56 }
57
58 public AdmEstStatus getAdmEstStatus() {
59 return admEstStatus;
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 += admEstStatus.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 admEstStatus = new AdmEstStatus();
144 subCodeLength += admEstStatus.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 }
176
177 sb.append(",\n");
178 for (int i = 0; i < indentLevel + 1; i++) {
179 sb.append("\t");
180 }
181 if (ecgi != null) {
slowr60d4d102017-08-16 18:33:58 -0700182 sb.append("ecgi: ");
slowr13fa5b02017-08-08 16:32:31 -0700183 ecgi.appendAsString(sb, indentLevel + 1);
184 }
185
186 sb.append(",\n");
187 for (int i = 0; i < indentLevel + 1; i++) {
188 sb.append("\t");
189 }
190 if (admEstStatus != null) {
slowr60d4d102017-08-16 18:33:58 -0700191 sb.append("admEstStatus: ").append(admEstStatus);
slowr13fa5b02017-08-08 16:32:31 -0700192 }
193
194 sb.append("\n");
195 for (int i = 0; i < indentLevel; i++) {
196 sb.append("\t");
197 }
198 sb.append("}");
199 }
200
201}
202