blob: 732b71793f2a4f07f41b7fc04d8176ab12a4d329 [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 */
4package org.onosproject.xran.codecs.pdu;
5
slowr60d4d102017-08-16 18:33:58 -07006import com.fasterxml.jackson.annotation.JsonIgnore;
slowr13fa5b02017-08-08 16:32:31 -07007import org.onosproject.xran.codecs.api.CACap;
8import org.onosproject.xran.codecs.api.CRNTI;
9import org.onosproject.xran.codecs.api.DCCap;
10import org.onosproject.xran.codecs.api.ECGI;
slowr60d4d102017-08-16 18:33:58 -070011import org.onosproject.xran.codecs.ber.BerByteArrayOutputStream;
12import org.onosproject.xran.codecs.ber.BerLength;
13import org.onosproject.xran.codecs.ber.BerTag;
slowr13fa5b02017-08-08 16:32:31 -070014
15import java.io.IOException;
16import java.io.InputStream;
17import java.io.Serializable;
18
19
20public class UECapabilityInfo implements Serializable {
21
22 private static final long serialVersionUID = 1L;
23
24 public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
25
slowr60d4d102017-08-16 18:33:58 -070026 @JsonIgnore
slowr13fa5b02017-08-08 16:32:31 -070027 public byte[] code = null;
28 private CRNTI crnti = null;
29 private ECGI ecgi = null;
30 private CACap caCap = null;
31 private DCCap dcCap = null;
32
33 public UECapabilityInfo() {
34 }
35
36 public UECapabilityInfo(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 setCaCap(CACap caCap) {
57 this.caCap = caCap;
58 }
59
60 public CACap getCaCap() {
61 return caCap;
62 }
63
64 public void setDcCap(DCCap dcCap) {
65 this.dcCap = dcCap;
66 }
67
68 public DCCap getDcCap() {
69 return dcCap;
70 }
71
72 public int encode(BerByteArrayOutputStream os) throws IOException {
73 return encode(os, true);
74 }
75
76 public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
77
78 if (code != null) {
79 for (int i = code.length - 1; i >= 0; i--) {
80 os.write(code[i]);
81 }
82 if (withTag) {
83 return tag.encode(os) + code.length;
84 }
85 return code.length;
86 }
87
88 int codeLength = 0;
89 if (dcCap != null) {
90 codeLength += dcCap.encode(os, false);
91 // write tag: CONTEXT_CLASS, CONSTRUCTED, 3
92 os.write(0xA3);
93 codeLength += 1;
94 }
95
96 if (caCap != null) {
97 codeLength += caCap.encode(os, false);
98 // write tag: CONTEXT_CLASS, CONSTRUCTED, 2
99 os.write(0xA2);
100 codeLength += 1;
101 }
102
103 codeLength += ecgi.encode(os, false);
104 // write tag: CONTEXT_CLASS, CONSTRUCTED, 1
105 os.write(0xA1);
106 codeLength += 1;
107
108 codeLength += crnti.encode(os, false);
109 // write tag: CONTEXT_CLASS, PRIMITIVE, 0
110 os.write(0x80);
111 codeLength += 1;
112
113 codeLength += BerLength.encodeLength(os, codeLength);
114
115 if (withTag) {
116 codeLength += tag.encode(os);
117 }
118
119 return codeLength;
120
121 }
122
123 public int decode(InputStream is) throws IOException {
124 return decode(is, true);
125 }
126
127 public int decode(InputStream is, boolean withTag) throws IOException {
128 int codeLength = 0;
129 int subCodeLength = 0;
130 BerTag berTag = new BerTag();
131
132 if (withTag) {
133 codeLength += tag.decodeAndCheck(is);
134 }
135
136 BerLength length = new BerLength();
137 codeLength += length.decode(is);
138
139 int totalLength = length.val;
140 codeLength += totalLength;
141
142 subCodeLength += berTag.decode(is);
143 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
144 crnti = new CRNTI();
145 subCodeLength += crnti.decode(is, false);
146 subCodeLength += berTag.decode(is);
147 }
148 else {
149 throw new IOException("Tag does not match the mandatory sequence element tag.");
150 }
151
152 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
153 ecgi = new ECGI();
154 subCodeLength += ecgi.decode(is, false);
155 if (subCodeLength == totalLength) {
156 return codeLength;
157 }
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, 2)) {
165 caCap = new CACap();
166 subCodeLength += caCap.decode(is, false);
167 if (subCodeLength == totalLength) {
168 return codeLength;
169 }
170 subCodeLength += berTag.decode(is);
171 }
172
173 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 3)) {
174 dcCap = new DCCap();
175 subCodeLength += dcCap.decode(is, false);
176 if (subCodeLength == totalLength) {
177 return codeLength;
178 }
179 }
180 throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
181
182
183 }
184
185 public void encodeAndSave(int encodingSizeGuess) throws IOException {
186 BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
187 encode(os, false);
188 code = os.getArray();
189 }
190
191 public String toString() {
192 StringBuilder sb = new StringBuilder();
193 appendAsString(sb, 0);
194 return sb.toString();
195 }
196
197 public void appendAsString(StringBuilder sb, int indentLevel) {
198
199 sb.append("{");
200 sb.append("\n");
201 for (int i = 0; i < indentLevel + 1; i++) {
202 sb.append("\t");
203 }
204 if (crnti != null) {
slowr60d4d102017-08-16 18:33:58 -0700205 sb.append("crnti: ").append(crnti);
slowr13fa5b02017-08-08 16:32:31 -0700206 }
207
208 sb.append(",\n");
209 for (int i = 0; i < indentLevel + 1; i++) {
210 sb.append("\t");
211 }
212 if (ecgi != null) {
slowr60d4d102017-08-16 18:33:58 -0700213 sb.append("ecgi: ");
slowr13fa5b02017-08-08 16:32:31 -0700214 ecgi.appendAsString(sb, indentLevel + 1);
215 }
216
217 if (caCap != null) {
218 sb.append(",\n");
219 for (int i = 0; i < indentLevel + 1; i++) {
220 sb.append("\t");
221 }
slowr60d4d102017-08-16 18:33:58 -0700222 sb.append("caCap: ");
slowr13fa5b02017-08-08 16:32:31 -0700223 caCap.appendAsString(sb, indentLevel + 1);
224 }
225
226 if (dcCap != null) {
227 sb.append(",\n");
228 for (int i = 0; i < indentLevel + 1; i++) {
229 sb.append("\t");
230 }
slowr60d4d102017-08-16 18:33:58 -0700231 sb.append("dcCap: ");
slowr13fa5b02017-08-08 16:32:31 -0700232 dcCap.appendAsString(sb, indentLevel + 1);
233 }
234
235 sb.append("\n");
236 for (int i = 0; i < indentLevel; i++) {
237 sb.append("\t");
238 }
239 sb.append("}");
240 }
241
242}
243