blob: fef213f40b211c9be3ba64d9f2e8d9b213800e0f [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;
7import org.onosproject.xran.codecs.ber.BerByteArrayOutputStream;
8import org.onosproject.xran.codecs.ber.BerLength;
9import org.onosproject.xran.codecs.ber.BerTag;
slowr13fa5b02017-08-08 16:32:31 -070010import org.onosproject.xran.codecs.api.CRNTI;
11import org.onosproject.xran.codecs.api.ECGI;
12import org.onosproject.xran.codecs.api.RelCause;
13
14import java.io.IOException;
15import java.io.InputStream;
16import java.io.Serializable;
17
18public class UEReleaseInd implements Serializable {
19
20 private static final long serialVersionUID = 1L;
21
22 public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
23
slowr60d4d102017-08-16 18:33:58 -070024 @JsonIgnore
slowr13fa5b02017-08-08 16:32:31 -070025 public byte[] code = null;
26 private CRNTI crnti = null;
27 private ECGI ecgi = null;
28 private RelCause releaseCause = null;
29
30 public UEReleaseInd() {
31 }
32
33 public UEReleaseInd(byte[] code) {
34 this.code = code;
35 }
36
37 public void setCrnti(CRNTI crnti) {
38 this.crnti = crnti;
39 }
40
41 public CRNTI getCrnti() {
42 return crnti;
43 }
44
45 public void setEcgi(ECGI ecgi) {
46 this.ecgi = ecgi;
47 }
48
49 public ECGI getEcgi() {
50 return ecgi;
51 }
52
53 public void setReleaseCause(RelCause releaseCause) {
54 this.releaseCause = releaseCause;
55 }
56
57 public RelCause getReleaseCause() {
58 return releaseCause;
59 }
60
61 public int encode(BerByteArrayOutputStream os) throws IOException {
62 return encode(os, true);
63 }
64
65 public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
66
67 if (code != null) {
68 for (int i = code.length - 1; i >= 0; i--) {
69 os.write(code[i]);
70 }
71 if (withTag) {
72 return tag.encode(os) + code.length;
73 }
74 return code.length;
75 }
76
77 int codeLength = 0;
78 codeLength += releaseCause.encode(os, false);
79 // write tag: CONTEXT_CLASS, PRIMITIVE, 2
80 os.write(0x82);
81 codeLength += 1;
82
83 codeLength += ecgi.encode(os, false);
84 // write tag: CONTEXT_CLASS, CONSTRUCTED, 1
85 os.write(0xA1);
86 codeLength += 1;
87
88 codeLength += crnti.encode(os, false);
89 // write tag: CONTEXT_CLASS, PRIMITIVE, 0
90 os.write(0x80);
91 codeLength += 1;
92
93 codeLength += BerLength.encodeLength(os, codeLength);
94
95 if (withTag) {
96 codeLength += tag.encode(os);
97 }
98
99 return codeLength;
100
101 }
102
103 public int decode(InputStream is) throws IOException {
104 return decode(is, true);
105 }
106
107 public int decode(InputStream is, boolean withTag) throws IOException {
108 int codeLength = 0;
109 int subCodeLength = 0;
110 BerTag berTag = new BerTag();
111
112 if (withTag) {
113 codeLength += tag.decodeAndCheck(is);
114 }
115
116 BerLength length = new BerLength();
117 codeLength += length.decode(is);
118
119 int totalLength = length.val;
120 codeLength += totalLength;
121
122 subCodeLength += berTag.decode(is);
123 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
124 crnti = new CRNTI();
125 subCodeLength += crnti.decode(is, false);
126 subCodeLength += berTag.decode(is);
127 }
128 else {
129 throw new IOException("Tag does not match the mandatory sequence element tag.");
130 }
131
132 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
133 ecgi = new ECGI();
134 subCodeLength += ecgi.decode(is, false);
135 subCodeLength += berTag.decode(is);
136 }
137 else {
138 throw new IOException("Tag does not match the mandatory sequence element tag.");
139 }
140
141 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 2)) {
142 releaseCause = new RelCause();
143 subCodeLength += releaseCause.decode(is, false);
144 if (subCodeLength == totalLength) {
145 return codeLength;
146 }
147 }
148 throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
149
150
151 }
152
153 public void encodeAndSave(int encodingSizeGuess) throws IOException {
154 BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
155 encode(os, false);
156 code = os.getArray();
157 }
158
159 public String toString() {
160 StringBuilder sb = new StringBuilder();
161 appendAsString(sb, 0);
162 return sb.toString();
163 }
164
165 public void appendAsString(StringBuilder sb, int indentLevel) {
166
167 sb.append("{");
168 sb.append("\n");
169 for (int i = 0; i < indentLevel + 1; i++) {
170 sb.append("\t");
171 }
172 if (crnti != null) {
slowr60d4d102017-08-16 18:33:58 -0700173 sb.append("crnti: ").append(crnti);
slowr13fa5b02017-08-08 16:32:31 -0700174 }
175
176 sb.append(",\n");
177 for (int i = 0; i < indentLevel + 1; i++) {
178 sb.append("\t");
179 }
180 if (ecgi != null) {
slowr60d4d102017-08-16 18:33:58 -0700181 sb.append("ecgi: ");
slowr13fa5b02017-08-08 16:32:31 -0700182 ecgi.appendAsString(sb, indentLevel + 1);
183 }
184
185 sb.append(",\n");
186 for (int i = 0; i < indentLevel + 1; i++) {
187 sb.append("\t");
188 }
189 if (releaseCause != null) {
slowr60d4d102017-08-16 18:33:58 -0700190 sb.append("releaseCause: ").append(releaseCause);
slowr13fa5b02017-08-08 16:32:31 -0700191 }
192
193 sb.append("\n");
194 for (int i = 0; i < indentLevel; i++) {
195 sb.append("\t");
196 }
197 sb.append("}");
198 }
199
200}
201