blob: 7de2dd1afbd3f7dfeb0c6b15c3dc893972f95be1 [file] [log] [blame]
Dimitrios Mavrommatis96b255a2017-12-06 13:09:25 -08001/**
2 * This class file was automatically generated by jASN1 v1.8.2 (http://www.openmuc.org)
3 */
4
5package org.onosproject.xran.asn1lib.pdu;
6
7
8import com.fasterxml.jackson.annotation.JsonIgnore;
9import org.onosproject.xran.asn1lib.api.ECGI;
10import org.onosproject.xran.asn1lib.ber.BerByteArrayOutputStream;
11import org.onosproject.xran.asn1lib.ber.BerLength;
12import org.onosproject.xran.asn1lib.ber.BerTag;
13import org.onosproject.xran.asn1lib.ber.types.string.BerUTF8String;
14
15import java.io.IOException;
16import java.io.InputStream;
17import java.io.Serializable;
18
19public class CellConfigRequest implements Serializable {
20
21 public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
22 private static final long serialVersionUID = 1L;
23 @JsonIgnore
24 public byte[] code = null;
25 private ECGI ecgi = null;
26
27 public CellConfigRequest() {
28 }
29
30 public CellConfigRequest(byte[] code) {
31 this.code = code;
32 }
33
34 public static XrancPdu constructPacket(ECGI ecgi) {
35 CellConfigRequest cellConfigRequest = new CellConfigRequest();
36 cellConfigRequest.setEcgi(ecgi);
37 BerUTF8String ver = null;
38 try {
39 ver = new BerUTF8String("5");
40 } catch (Exception ignored) {
41 }
42
43 XrancApiID apiID = new XrancApiID(0);
44 XrancPduBody body = new XrancPduBody();
45 body.setCellConfigRequest(cellConfigRequest);
46
47 XrancPduHdr hdr = new XrancPduHdr();
48 hdr.setVer(ver);
49 hdr.setApiId(apiID);
50
51 XrancPdu pdu = new XrancPdu();
52 pdu.setBody(body);
53 pdu.setHdr(hdr);
54
55 return pdu;
56 }
57
58 public ECGI getEcgi() {
59 return ecgi;
60 }
61
62 public void setEcgi(ECGI ecgi) {
63 this.ecgi = ecgi;
64 }
65
66 public int encode(BerByteArrayOutputStream os) throws IOException {
67 return encode(os, true);
68 }
69
70 public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException {
71
72 if (code != null) {
73 for (int i = code.length - 1; i >= 0; i--) {
74 os.write(code[i]);
75 }
76 if (withTag) {
77 return tag.encode(os) + code.length;
78 }
79 return code.length;
80 }
81
82 int codeLength = 0;
83 codeLength += ecgi.encode(os, false);
84 // write tag: CONTEXT_CLASS, CONSTRUCTED, 0
85 os.write(0xA0);
86 codeLength += 1;
87
88 codeLength += BerLength.encodeLength(os, codeLength);
89
90 if (withTag) {
91 codeLength += tag.encode(os);
92 }
93
94 return codeLength;
95
96 }
97
98 public int decode(InputStream is) throws IOException {
99 return decode(is, true);
100 }
101
102 public int decode(InputStream is, boolean withTag) throws IOException {
103 int codeLength = 0;
104 int subCodeLength = 0;
105 BerTag berTag = new BerTag();
106
107 if (withTag) {
108 codeLength += tag.decodeAndCheck(is);
109 }
110
111 BerLength length = new BerLength();
112 codeLength += length.decode(is);
113
114 int totalLength = length.val;
115 codeLength += totalLength;
116
117 subCodeLength += berTag.decode(is);
118 if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) {
119 ecgi = new ECGI();
120 subCodeLength += ecgi.decode(is, false);
121 if (subCodeLength == totalLength) {
122 return codeLength;
123 }
124 }
125 throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
126
127
128 }
129
130 public void encodeAndSave(int encodingSizeGuess) throws IOException {
131 BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess);
132 encode(os, false);
133 code = os.getArray();
134 }
135
136 public String toString() {
137 StringBuilder sb = new StringBuilder();
138 appendAsString(sb, 0);
139 return sb.toString();
140 }
141
142 public void appendAsString(StringBuilder sb, int indentLevel) {
143
144 sb.append("{");
145 sb.append("\n");
146 for (int i = 0; i < indentLevel + 1; i++) {
147 sb.append("\t");
148 }
149 if (ecgi != null) {
150 sb.append("ecgi: ");
151 ecgi.appendAsString(sb, indentLevel + 1);
152 } else {
153 sb.append("ecgi: <empty-required-field>");
154 }
155
156 sb.append("\n");
157 for (int i = 0; i < indentLevel; i++) {
158 sb.append("\t");
159 }
160 sb.append("}");
161 }
162}
163