slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1 | /** |
Dimitrios Mavrommatis | 96b255a | 2017-12-06 13:09:25 -0800 | [diff] [blame] | 2 | * This class file was automatically generated by jASN1 v1.8.2 (http://www.openmuc.org) |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 3 | */ |
| 4 | |
Dimitrios Mavrommatis | 96b255a | 2017-12-06 13:09:25 -0800 | [diff] [blame] | 5 | package org.onosproject.xran.asn1lib.pdu; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 6 | |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 7 | import com.fasterxml.jackson.annotation.JsonIgnore; |
| 8 | import com.fasterxml.jackson.annotation.JsonValue; |
Dimitrios Mavrommatis | 96b255a | 2017-12-06 13:09:25 -0800 | [diff] [blame] | 9 | import org.onosproject.xran.asn1lib.api.CRNTI; |
| 10 | import org.onosproject.xran.asn1lib.api.ECGI; |
| 11 | import org.onosproject.xran.asn1lib.api.PCIARFCN; |
| 12 | import org.onosproject.xran.asn1lib.ber.BerByteArrayOutputStream; |
| 13 | import org.onosproject.xran.asn1lib.ber.BerLength; |
| 14 | import org.onosproject.xran.asn1lib.ber.BerTag; |
| 15 | import org.onosproject.xran.asn1lib.ber.types.string.BerUTF8String; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 16 | |
| 17 | import java.io.IOException; |
| 18 | import java.io.InputStream; |
| 19 | import java.io.Serializable; |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 20 | import java.io.UnsupportedEncodingException; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 21 | import java.util.ArrayList; |
| 22 | import java.util.Iterator; |
| 23 | import java.util.List; |
| 24 | |
| 25 | public class ScellDelete implements Serializable { |
| 26 | |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 27 | public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); |
| 28 | private static final long serialVersionUID = 1L; |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 29 | @JsonIgnore |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 30 | public byte[] code = null; |
| 31 | private CRNTI crnti = null; |
| 32 | private ECGI ecgi = null; |
| 33 | private ScellsInd scellsInd = null; |
Dimitrios Mavrommatis | 96b255a | 2017-12-06 13:09:25 -0800 | [diff] [blame] | 34 | |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 35 | public ScellDelete() { |
| 36 | } |
Dimitrios Mavrommatis | 96b255a | 2017-12-06 13:09:25 -0800 | [diff] [blame] | 37 | |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 38 | public ScellDelete(byte[] code) { |
| 39 | this.code = code; |
| 40 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 41 | |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 42 | public static XrancPdu constructPacket(ECGI ecgi, CRNTI crnti, PCIARFCN pciarfcn) { |
| 43 | ScellDelete scellDelete = new ScellDelete(); |
| 44 | scellDelete.setEcgi(ecgi); |
| 45 | scellDelete.setCrnti(crnti); |
| 46 | ScellsInd scellsInd = new ScellsInd(); |
Dimitrios Mavrommatis | 96b255a | 2017-12-06 13:09:25 -0800 | [diff] [blame] | 47 | scellsInd.getPCIARFCN().add(pciarfcn); |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 48 | scellDelete.setScellsInd(scellsInd); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 49 | |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 50 | BerUTF8String ver = null; |
| 51 | try { |
Dimitrios Mavrommatis | 96b255a | 2017-12-06 13:09:25 -0800 | [diff] [blame] | 52 | ver = new BerUTF8String("5"); |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 53 | } catch (UnsupportedEncodingException e) { |
| 54 | e.printStackTrace(); |
| 55 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 56 | |
Dimitrios Mavrommatis | 96b255a | 2017-12-06 13:09:25 -0800 | [diff] [blame] | 57 | XrancApiID apiID = new XrancApiID(26); |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 58 | XrancPduBody body = new XrancPduBody(); |
| 59 | body.setScellDelete(scellDelete); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 60 | |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 61 | XrancPduHdr hdr = new XrancPduHdr(); |
| 62 | hdr.setVer(ver); |
| 63 | hdr.setApiId(apiID); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 64 | |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 65 | XrancPdu pdu = new XrancPdu(); |
| 66 | pdu.setBody(body); |
| 67 | pdu.setHdr(hdr); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 68 | |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 69 | return pdu; |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 70 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 71 | |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 72 | public CRNTI getCrnti() { |
| 73 | return crnti; |
| 74 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 75 | |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 76 | public void setCrnti(CRNTI crnti) { |
| 77 | this.crnti = crnti; |
| 78 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 79 | |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 80 | public ECGI getEcgi() { |
| 81 | return ecgi; |
| 82 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 83 | |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 84 | public void setEcgi(ECGI ecgi) { |
| 85 | this.ecgi = ecgi; |
| 86 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 87 | |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 88 | public ScellsInd getScellsInd() { |
| 89 | return scellsInd; |
| 90 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 91 | |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 92 | public void setScellsInd(ScellsInd scellsInd) { |
| 93 | this.scellsInd = scellsInd; |
| 94 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 95 | |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 96 | public int encode(BerByteArrayOutputStream os) throws IOException { |
| 97 | return encode(os, true); |
| 98 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 99 | |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 100 | public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException { |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 101 | |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 102 | if (code != null) { |
| 103 | for (int i = code.length - 1; i >= 0; i--) { |
| 104 | os.write(code[i]); |
| 105 | } |
| 106 | if (withTag) { |
| 107 | return tag.encode(os) + code.length; |
| 108 | } |
| 109 | return code.length; |
| 110 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 111 | |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 112 | int codeLength = 0; |
| 113 | codeLength += scellsInd.encode(os, false); |
| 114 | // write tag: CONTEXT_CLASS, CONSTRUCTED, 2 |
| 115 | os.write(0xA2); |
| 116 | codeLength += 1; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 117 | |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 118 | codeLength += ecgi.encode(os, false); |
| 119 | // write tag: CONTEXT_CLASS, CONSTRUCTED, 1 |
| 120 | os.write(0xA1); |
| 121 | codeLength += 1; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 122 | |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 123 | codeLength += crnti.encode(os, false); |
| 124 | // write tag: CONTEXT_CLASS, PRIMITIVE, 0 |
| 125 | os.write(0x80); |
| 126 | codeLength += 1; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 127 | |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 128 | codeLength += BerLength.encodeLength(os, codeLength); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 129 | |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 130 | if (withTag) { |
| 131 | codeLength += tag.encode(os); |
| 132 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 133 | |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 134 | return codeLength; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 135 | |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 136 | } |
| 137 | |
| 138 | public int decode(InputStream is) throws IOException { |
| 139 | return decode(is, true); |
| 140 | } |
| 141 | |
| 142 | public int decode(InputStream is, boolean withTag) throws IOException { |
| 143 | int codeLength = 0; |
| 144 | int subCodeLength = 0; |
| 145 | BerTag berTag = new BerTag(); |
| 146 | |
| 147 | if (withTag) { |
| 148 | codeLength += tag.decodeAndCheck(is); |
| 149 | } |
| 150 | |
| 151 | BerLength length = new BerLength(); |
| 152 | codeLength += length.decode(is); |
| 153 | |
| 154 | int totalLength = length.val; |
| 155 | codeLength += totalLength; |
| 156 | |
| 157 | subCodeLength += berTag.decode(is); |
| 158 | if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) { |
| 159 | crnti = new CRNTI(); |
| 160 | subCodeLength += crnti.decode(is, false); |
| 161 | subCodeLength += berTag.decode(is); |
| 162 | } else { |
| 163 | throw new IOException("Tag does not match the mandatory sequence element tag."); |
| 164 | } |
| 165 | |
| 166 | if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) { |
| 167 | ecgi = new ECGI(); |
| 168 | subCodeLength += ecgi.decode(is, false); |
| 169 | subCodeLength += berTag.decode(is); |
| 170 | } else { |
| 171 | throw new IOException("Tag does not match the mandatory sequence element tag."); |
| 172 | } |
| 173 | |
| 174 | if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) { |
| 175 | scellsInd = new ScellsInd(); |
| 176 | subCodeLength += scellsInd.decode(is, false); |
| 177 | if (subCodeLength == totalLength) { |
| 178 | return codeLength; |
| 179 | } |
| 180 | } |
| 181 | throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength); |
| 182 | |
| 183 | |
| 184 | } |
| 185 | |
| 186 | public void encodeAndSave(int encodingSizeGuess) throws IOException { |
| 187 | BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess); |
| 188 | encode(os, false); |
| 189 | code = os.getArray(); |
| 190 | } |
| 191 | |
| 192 | public String toString() { |
| 193 | StringBuilder sb = new StringBuilder(); |
| 194 | appendAsString(sb, 0); |
| 195 | return sb.toString(); |
| 196 | } |
| 197 | |
| 198 | public void appendAsString(StringBuilder sb, int indentLevel) { |
| 199 | |
| 200 | sb.append("{"); |
| 201 | sb.append("\n"); |
| 202 | for (int i = 0; i < indentLevel + 1; i++) { |
| 203 | sb.append("\t"); |
| 204 | } |
| 205 | if (crnti != null) { |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 206 | sb.append("crnti: ").append(crnti); |
Dimitrios Mavrommatis | 96b255a | 2017-12-06 13:09:25 -0800 | [diff] [blame] | 207 | } else { |
| 208 | sb.append("crnti: <empty-required-field>"); |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 209 | } |
| 210 | |
| 211 | sb.append(",\n"); |
| 212 | for (int i = 0; i < indentLevel + 1; i++) { |
| 213 | sb.append("\t"); |
| 214 | } |
| 215 | if (ecgi != null) { |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 216 | sb.append("ecgi: "); |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 217 | ecgi.appendAsString(sb, indentLevel + 1); |
Dimitrios Mavrommatis | 96b255a | 2017-12-06 13:09:25 -0800 | [diff] [blame] | 218 | } else { |
| 219 | sb.append("ecgi: <empty-required-field>"); |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 220 | } |
| 221 | |
| 222 | sb.append(",\n"); |
| 223 | for (int i = 0; i < indentLevel + 1; i++) { |
| 224 | sb.append("\t"); |
| 225 | } |
| 226 | if (scellsInd != null) { |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 227 | sb.append("scellsInd: "); |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 228 | scellsInd.appendAsString(sb, indentLevel + 1); |
Dimitrios Mavrommatis | 96b255a | 2017-12-06 13:09:25 -0800 | [diff] [blame] | 229 | } else { |
| 230 | sb.append("scellsInd: <empty-required-field>"); |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 231 | } |
| 232 | |
| 233 | sb.append("\n"); |
| 234 | for (int i = 0; i < indentLevel; i++) { |
| 235 | sb.append("\t"); |
| 236 | } |
| 237 | sb.append("}"); |
| 238 | } |
| 239 | |
| 240 | public static class ScellsInd implements Serializable { |
| 241 | |
| 242 | public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); |
| 243 | private static final long serialVersionUID = 1L; |
Dimitrios Mavrommatis | 96b255a | 2017-12-06 13:09:25 -0800 | [diff] [blame] | 244 | @JsonIgnore |
| 245 | public byte[] code = null; |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 246 | private List<PCIARFCN> seqOf = null; |
| 247 | |
| 248 | public ScellsInd() { |
| 249 | seqOf = new ArrayList<PCIARFCN>(); |
| 250 | } |
| 251 | |
| 252 | public ScellsInd(byte[] code) { |
| 253 | this.code = code; |
| 254 | } |
| 255 | |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 256 | @JsonValue |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 257 | public List<PCIARFCN> getPCIARFCN() { |
| 258 | if (seqOf == null) { |
| 259 | seqOf = new ArrayList<PCIARFCN>(); |
| 260 | } |
| 261 | return seqOf; |
| 262 | } |
| 263 | |
| 264 | public int encode(BerByteArrayOutputStream os) throws IOException { |
| 265 | return encode(os, true); |
| 266 | } |
| 267 | |
| 268 | public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException { |
| 269 | |
| 270 | if (code != null) { |
| 271 | for (int i = code.length - 1; i >= 0; i--) { |
| 272 | os.write(code[i]); |
| 273 | } |
| 274 | if (withTag) { |
| 275 | return tag.encode(os) + code.length; |
| 276 | } |
| 277 | return code.length; |
| 278 | } |
| 279 | |
| 280 | int codeLength = 0; |
| 281 | for (int i = (seqOf.size() - 1); i >= 0; i--) { |
| 282 | codeLength += seqOf.get(i).encode(os, true); |
| 283 | } |
| 284 | |
| 285 | codeLength += BerLength.encodeLength(os, codeLength); |
| 286 | |
| 287 | if (withTag) { |
| 288 | codeLength += tag.encode(os); |
| 289 | } |
| 290 | |
| 291 | return codeLength; |
| 292 | } |
| 293 | |
| 294 | public int decode(InputStream is) throws IOException { |
| 295 | return decode(is, true); |
| 296 | } |
| 297 | |
| 298 | public int decode(InputStream is, boolean withTag) throws IOException { |
| 299 | int codeLength = 0; |
| 300 | int subCodeLength = 0; |
| 301 | if (withTag) { |
| 302 | codeLength += tag.decodeAndCheck(is); |
| 303 | } |
| 304 | |
| 305 | BerLength length = new BerLength(); |
| 306 | codeLength += length.decode(is); |
| 307 | int totalLength = length.val; |
| 308 | |
| 309 | while (subCodeLength < totalLength) { |
| 310 | PCIARFCN element = new PCIARFCN(); |
| 311 | subCodeLength += element.decode(is, true); |
| 312 | seqOf.add(element); |
| 313 | } |
| 314 | if (subCodeLength != totalLength) { |
| 315 | throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength); |
| 316 | |
| 317 | } |
| 318 | codeLength += subCodeLength; |
| 319 | |
| 320 | return codeLength; |
| 321 | } |
| 322 | |
| 323 | public void encodeAndSave(int encodingSizeGuess) throws IOException { |
| 324 | BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess); |
| 325 | encode(os, false); |
| 326 | code = os.getArray(); |
| 327 | } |
| 328 | |
| 329 | public String toString() { |
| 330 | StringBuilder sb = new StringBuilder(); |
| 331 | appendAsString(sb, 0); |
| 332 | return sb.toString(); |
| 333 | } |
| 334 | |
| 335 | public void appendAsString(StringBuilder sb, int indentLevel) { |
| 336 | |
Dimitrios Mavrommatis | 96b255a | 2017-12-06 13:09:25 -0800 | [diff] [blame] | 337 | sb.append("{\n"); |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 338 | for (int i = 0; i < indentLevel + 1; i++) { |
| 339 | sb.append("\t"); |
| 340 | } |
| 341 | if (seqOf == null) { |
Dimitrios Mavrommatis | 96b255a | 2017-12-06 13:09:25 -0800 | [diff] [blame] | 342 | sb.append("null"); |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 343 | } else { |
| 344 | Iterator<PCIARFCN> it = seqOf.iterator(); |
| 345 | if (it.hasNext()) { |
| 346 | it.next().appendAsString(sb, indentLevel + 1); |
| 347 | while (it.hasNext()) { |
| 348 | sb.append(",\n"); |
| 349 | for (int i = 0; i < indentLevel + 1; i++) { |
| 350 | sb.append("\t"); |
| 351 | } |
| 352 | it.next().appendAsString(sb, indentLevel + 1); |
| 353 | } |
| 354 | } |
| 355 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 356 | |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 357 | sb.append("\n"); |
| 358 | for (int i = 0; i < indentLevel; i++) { |
| 359 | sb.append("\t"); |
| 360 | } |
Dimitrios Mavrommatis | 96b255a | 2017-12-06 13:09:25 -0800 | [diff] [blame] | 361 | sb.append("}"); |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 362 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 363 | |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 364 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 365 | |
| 366 | } |
| 367 | |