blob: 68ae5c113a9c8a2030984159242b4cbee1a738b7 [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;
slowr13fa5b02017-08-08 16:32:31 -07008import org.onosproject.xran.codecs.api.CRNTI;
9import org.onosproject.xran.codecs.api.ECGI;
slowr60d4d102017-08-16 18:33:58 -070010import org.onosproject.xran.codecs.ber.BerByteArrayOutputStream;
11import org.onosproject.xran.codecs.ber.BerLength;
12import org.onosproject.xran.codecs.ber.BerTag;
slowr13fa5b02017-08-08 16:32:31 -070013
14import java.io.IOException;
15import java.io.InputStream;
16import java.io.Serializable;
17
18
19public class HOComplete 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 ECGI ecgiT = null;
28 private ECGI ecgiS = null;
29 private CRNTI crntiNew = null;
30
31 public HOComplete() {
32 }
33
34 public HOComplete(byte[] code) {
35 this.code = code;
36 }
37
38 public void setEcgiT(ECGI ecgiT) {
39 this.ecgiT = ecgiT;
40 }
41
42 public ECGI getEcgiT() {
43 return ecgiT;
44 }
45
46 public void setEcgiS(ECGI ecgiS) {
47 this.ecgiS = ecgiS;
48 }
49
50 public ECGI getEcgiS() {
51 return ecgiS;
52 }
53
54 public void setCrntiNew(CRNTI crntiNew) {
55 this.crntiNew = crntiNew;
56 }
57
58 public CRNTI getCrntiNew() {
59 return crntiNew;
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 += crntiNew.encode(os, false);
80 // write tag: CONTEXT_CLASS, PRIMITIVE, 2
81 os.write(0x82);
82 codeLength += 1;
83
84 codeLength += ecgiS.encode(os, false);
85 // write tag: CONTEXT_CLASS, CONSTRUCTED, 1
86 os.write(0xA1);
87 codeLength += 1;
88
89 codeLength += ecgiT.encode(os, false);
90 // write tag: CONTEXT_CLASS, CONSTRUCTED, 0
91 os.write(0xA0);
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.CONSTRUCTED, 0)) {
125 ecgiT = new ECGI();
126 subCodeLength += ecgiT.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 ecgiS = new ECGI();
135 subCodeLength += ecgiS.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 crntiNew = new CRNTI();
144 subCodeLength += crntiNew.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 (ecgiT != null) {
slowr60d4d102017-08-16 18:33:58 -0700174 sb.append("ecgiT: ");
slowr13fa5b02017-08-08 16:32:31 -0700175 ecgiT.appendAsString(sb, indentLevel + 1);
176 }
177
178 sb.append(",\n");
179 for (int i = 0; i < indentLevel + 1; i++) {
180 sb.append("\t");
181 }
182 if (ecgiS != null) {
slowr60d4d102017-08-16 18:33:58 -0700183 sb.append("ecgiS: ");
slowr13fa5b02017-08-08 16:32:31 -0700184 ecgiS.appendAsString(sb, indentLevel + 1);
185 }
186
187 sb.append(",\n");
188 for (int i = 0; i < indentLevel + 1; i++) {
189 sb.append("\t");
190 }
191 if (crntiNew != null) {
slowr60d4d102017-08-16 18:33:58 -0700192 sb.append("crntiNew: ").append(crntiNew);
slowr13fa5b02017-08-08 16:32:31 -0700193 }
194
195 sb.append("\n");
196 for (int i = 0; i < indentLevel; i++) {
197 sb.append("\t");
198 }
199 sb.append("}");
200 }
201
202}
203