slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1 | /** |
| 2 | * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org) |
| 3 | */ |
| 4 | |
| 5 | package org.onosproject.xran.codecs.pdu; |
| 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; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 9 | import org.onosproject.xran.codecs.api.CRNTI; |
| 10 | import org.onosproject.xran.codecs.api.ECGI; |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 11 | import org.onosproject.xran.codecs.ber.BerByteArrayOutputStream; |
| 12 | import org.onosproject.xran.codecs.ber.BerLength; |
| 13 | import org.onosproject.xran.codecs.ber.BerTag; |
| 14 | import org.onosproject.xran.codecs.ber.types.BerEnum; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 15 | |
| 16 | import java.io.IOException; |
| 17 | import java.io.InputStream; |
| 18 | import java.io.Serializable; |
| 19 | import java.util.ArrayList; |
| 20 | import java.util.Iterator; |
| 21 | import java.util.List; |
| 22 | |
| 23 | |
| 24 | public class RRMConfigStatus implements Serializable { |
| 25 | |
| 26 | private static final long serialVersionUID = 1L; |
| 27 | |
| 28 | public static class Crnti implements Serializable { |
| 29 | |
| 30 | private static final long serialVersionUID = 1L; |
| 31 | |
| 32 | public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 33 | @JsonIgnore |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 34 | public byte[] code = null; |
| 35 | private List<CRNTI> seqOf = null; |
| 36 | |
| 37 | public Crnti() { |
| 38 | seqOf = new ArrayList<CRNTI>(); |
| 39 | } |
| 40 | |
| 41 | public Crnti(byte[] code) { |
| 42 | this.code = code; |
| 43 | } |
| 44 | |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 45 | @JsonValue |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 46 | public List<CRNTI> getCRNTI() { |
| 47 | if (seqOf == null) { |
| 48 | seqOf = new ArrayList<CRNTI>(); |
| 49 | } |
| 50 | return seqOf; |
| 51 | } |
| 52 | |
| 53 | public int encode(BerByteArrayOutputStream os) throws IOException { |
| 54 | return encode(os, true); |
| 55 | } |
| 56 | |
| 57 | public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException { |
| 58 | |
| 59 | if (code != null) { |
| 60 | for (int i = code.length - 1; i >= 0; i--) { |
| 61 | os.write(code[i]); |
| 62 | } |
| 63 | if (withTag) { |
| 64 | return tag.encode(os) + code.length; |
| 65 | } |
| 66 | return code.length; |
| 67 | } |
| 68 | |
| 69 | int codeLength = 0; |
| 70 | for (int i = (seqOf.size() - 1); i >= 0; i--) { |
| 71 | codeLength += seqOf.get(i).encode(os, true); |
| 72 | } |
| 73 | |
| 74 | codeLength += BerLength.encodeLength(os, codeLength); |
| 75 | |
| 76 | if (withTag) { |
| 77 | codeLength += tag.encode(os); |
| 78 | } |
| 79 | |
| 80 | return codeLength; |
| 81 | } |
| 82 | |
| 83 | public int decode(InputStream is) throws IOException { |
| 84 | return decode(is, true); |
| 85 | } |
| 86 | |
| 87 | public int decode(InputStream is, boolean withTag) throws IOException { |
| 88 | int codeLength = 0; |
| 89 | int subCodeLength = 0; |
| 90 | if (withTag) { |
| 91 | codeLength += tag.decodeAndCheck(is); |
| 92 | } |
| 93 | |
| 94 | BerLength length = new BerLength(); |
| 95 | codeLength += length.decode(is); |
| 96 | int totalLength = length.val; |
| 97 | |
| 98 | while (subCodeLength < totalLength) { |
| 99 | CRNTI element = new CRNTI(); |
| 100 | subCodeLength += element.decode(is, true); |
| 101 | seqOf.add(element); |
| 102 | } |
| 103 | if (subCodeLength != totalLength) { |
| 104 | throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength); |
| 105 | |
| 106 | } |
| 107 | codeLength += subCodeLength; |
| 108 | |
| 109 | return codeLength; |
| 110 | } |
| 111 | |
| 112 | public void encodeAndSave(int encodingSizeGuess) throws IOException { |
| 113 | BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess); |
| 114 | encode(os, false); |
| 115 | code = os.getArray(); |
| 116 | } |
| 117 | |
| 118 | public String toString() { |
| 119 | StringBuilder sb = new StringBuilder(); |
| 120 | appendAsString(sb, 0); |
| 121 | return sb.toString(); |
| 122 | } |
| 123 | |
| 124 | public void appendAsString(StringBuilder sb, int indentLevel) { |
| 125 | |
| 126 | sb.append("[\n"); |
| 127 | for (int i = 0; i < indentLevel + 1; i++) { |
| 128 | sb.append("\t"); |
| 129 | } |
| 130 | if (seqOf == null) { |
| 131 | // sb.append("null"); |
| 132 | } |
| 133 | else { |
| 134 | Iterator<CRNTI> it = seqOf.iterator(); |
| 135 | if (it.hasNext()) { |
| 136 | sb.append(it.next()); |
| 137 | while (it.hasNext()) { |
| 138 | sb.append(",\n"); |
| 139 | for (int i = 0; i < indentLevel + 1; i++) { |
| 140 | sb.append("\t"); |
| 141 | } |
| 142 | sb.append(it.next()); |
| 143 | } |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | sb.append("\n"); |
| 148 | for (int i = 0; i < indentLevel; i++) { |
| 149 | sb.append("\t"); |
| 150 | } |
| 151 | sb.append("]"); |
| 152 | } |
| 153 | |
| 154 | } |
| 155 | |
| 156 | public static class Status implements Serializable { |
| 157 | |
| 158 | private static final long serialVersionUID = 1L; |
| 159 | |
| 160 | public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 161 | @JsonIgnore public byte[] code = null; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 162 | private List<BerEnum> seqOf = null; |
| 163 | |
| 164 | public Status() { |
| 165 | seqOf = new ArrayList<BerEnum>(); |
| 166 | } |
| 167 | |
| 168 | public Status(byte[] code) { |
| 169 | this.code = code; |
| 170 | } |
| 171 | |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 172 | @JsonValue |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 173 | public List<BerEnum> getBerEnum() { |
| 174 | if (seqOf == null) { |
| 175 | seqOf = new ArrayList<BerEnum>(); |
| 176 | } |
| 177 | return seqOf; |
| 178 | } |
| 179 | |
| 180 | public int encode(BerByteArrayOutputStream os) throws IOException { |
| 181 | return encode(os, true); |
| 182 | } |
| 183 | |
| 184 | public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException { |
| 185 | |
| 186 | if (code != null) { |
| 187 | for (int i = code.length - 1; i >= 0; i--) { |
| 188 | os.write(code[i]); |
| 189 | } |
| 190 | if (withTag) { |
| 191 | return tag.encode(os) + code.length; |
| 192 | } |
| 193 | return code.length; |
| 194 | } |
| 195 | |
| 196 | int codeLength = 0; |
| 197 | for (int i = (seqOf.size() - 1); i >= 0; i--) { |
| 198 | codeLength += seqOf.get(i).encode(os, true); |
| 199 | } |
| 200 | |
| 201 | codeLength += BerLength.encodeLength(os, codeLength); |
| 202 | |
| 203 | if (withTag) { |
| 204 | codeLength += tag.encode(os); |
| 205 | } |
| 206 | |
| 207 | return codeLength; |
| 208 | } |
| 209 | |
| 210 | public int decode(InputStream is) throws IOException { |
| 211 | return decode(is, true); |
| 212 | } |
| 213 | |
| 214 | public int decode(InputStream is, boolean withTag) throws IOException { |
| 215 | int codeLength = 0; |
| 216 | int subCodeLength = 0; |
| 217 | if (withTag) { |
| 218 | codeLength += tag.decodeAndCheck(is); |
| 219 | } |
| 220 | |
| 221 | BerLength length = new BerLength(); |
| 222 | codeLength += length.decode(is); |
| 223 | int totalLength = length.val; |
| 224 | |
| 225 | while (subCodeLength < totalLength) { |
| 226 | BerEnum element = new BerEnum(); |
| 227 | subCodeLength += element.decode(is, true); |
| 228 | seqOf.add(element); |
| 229 | } |
| 230 | if (subCodeLength != totalLength) { |
| 231 | throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength); |
| 232 | |
| 233 | } |
| 234 | codeLength += subCodeLength; |
| 235 | |
| 236 | return codeLength; |
| 237 | } |
| 238 | |
| 239 | public void encodeAndSave(int encodingSizeGuess) throws IOException { |
| 240 | BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess); |
| 241 | encode(os, false); |
| 242 | code = os.getArray(); |
| 243 | } |
| 244 | |
| 245 | public String toString() { |
| 246 | StringBuilder sb = new StringBuilder(); |
| 247 | appendAsString(sb, 0); |
| 248 | return sb.toString(); |
| 249 | } |
| 250 | |
| 251 | public void appendAsString(StringBuilder sb, int indentLevel) { |
| 252 | |
| 253 | sb.append("[\n"); |
| 254 | for (int i = 0; i < indentLevel + 1; i++) { |
| 255 | sb.append("\t"); |
| 256 | } |
| 257 | if (seqOf == null) { |
| 258 | // sb.append("null"); |
| 259 | } |
| 260 | else { |
| 261 | Iterator<BerEnum> it = seqOf.iterator(); |
| 262 | if (it.hasNext()) { |
| 263 | sb.append(it.next()); |
| 264 | while (it.hasNext()) { |
| 265 | sb.append(",\n"); |
| 266 | for (int i = 0; i < indentLevel + 1; i++) { |
| 267 | sb.append("\t"); |
| 268 | } |
| 269 | sb.append(it.next()); |
| 270 | } |
| 271 | } |
| 272 | } |
| 273 | |
| 274 | sb.append("\n"); |
| 275 | for (int i = 0; i < indentLevel; i++) { |
| 276 | sb.append("\t"); |
| 277 | } |
| 278 | sb.append("]"); |
| 279 | } |
| 280 | |
| 281 | } |
| 282 | |
| 283 | public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); |
| 284 | |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 285 | @JsonIgnore public byte[] code = null; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 286 | private ECGI ecgi = null; |
| 287 | private Crnti crnti = null; |
| 288 | private Status status = null; |
| 289 | |
| 290 | public RRMConfigStatus() { |
| 291 | } |
| 292 | |
| 293 | public RRMConfigStatus(byte[] code) { |
| 294 | this.code = code; |
| 295 | } |
| 296 | |
| 297 | public void setEcgi(ECGI ecgi) { |
| 298 | this.ecgi = ecgi; |
| 299 | } |
| 300 | |
| 301 | public ECGI getEcgi() { |
| 302 | return ecgi; |
| 303 | } |
| 304 | |
| 305 | public void setCrnti(Crnti crnti) { |
| 306 | this.crnti = crnti; |
| 307 | } |
| 308 | |
| 309 | public Crnti getCrnti() { |
| 310 | return crnti; |
| 311 | } |
| 312 | |
| 313 | public void setStatus(Status status) { |
| 314 | this.status = status; |
| 315 | } |
| 316 | |
| 317 | public Status getStatus() { |
| 318 | return status; |
| 319 | } |
| 320 | |
| 321 | public int encode(BerByteArrayOutputStream os) throws IOException { |
| 322 | return encode(os, true); |
| 323 | } |
| 324 | |
| 325 | public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException { |
| 326 | |
| 327 | if (code != null) { |
| 328 | for (int i = code.length - 1; i >= 0; i--) { |
| 329 | os.write(code[i]); |
| 330 | } |
| 331 | if (withTag) { |
| 332 | return tag.encode(os) + code.length; |
| 333 | } |
| 334 | return code.length; |
| 335 | } |
| 336 | |
| 337 | int codeLength = 0; |
| 338 | codeLength += status.encode(os, false); |
| 339 | // write tag: CONTEXT_CLASS, CONSTRUCTED, 2 |
| 340 | os.write(0xA2); |
| 341 | codeLength += 1; |
| 342 | |
| 343 | if (crnti != null) { |
| 344 | codeLength += crnti.encode(os, false); |
| 345 | // write tag: CONTEXT_CLASS, CONSTRUCTED, 1 |
| 346 | os.write(0xA1); |
| 347 | codeLength += 1; |
| 348 | } |
| 349 | |
| 350 | codeLength += ecgi.encode(os, false); |
| 351 | // write tag: CONTEXT_CLASS, CONSTRUCTED, 0 |
| 352 | os.write(0xA0); |
| 353 | codeLength += 1; |
| 354 | |
| 355 | codeLength += BerLength.encodeLength(os, codeLength); |
| 356 | |
| 357 | if (withTag) { |
| 358 | codeLength += tag.encode(os); |
| 359 | } |
| 360 | |
| 361 | return codeLength; |
| 362 | |
| 363 | } |
| 364 | |
| 365 | public int decode(InputStream is) throws IOException { |
| 366 | return decode(is, true); |
| 367 | } |
| 368 | |
| 369 | public int decode(InputStream is, boolean withTag) throws IOException { |
| 370 | int codeLength = 0; |
| 371 | int subCodeLength = 0; |
| 372 | BerTag berTag = new BerTag(); |
| 373 | |
| 374 | if (withTag) { |
| 375 | codeLength += tag.decodeAndCheck(is); |
| 376 | } |
| 377 | |
| 378 | BerLength length = new BerLength(); |
| 379 | codeLength += length.decode(is); |
| 380 | |
| 381 | int totalLength = length.val; |
| 382 | codeLength += totalLength; |
| 383 | |
| 384 | subCodeLength += berTag.decode(is); |
| 385 | if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) { |
| 386 | ecgi = new ECGI(); |
| 387 | subCodeLength += ecgi.decode(is, false); |
| 388 | subCodeLength += berTag.decode(is); |
| 389 | } |
| 390 | else { |
| 391 | throw new IOException("Tag does not match the mandatory sequence element tag."); |
| 392 | } |
| 393 | |
| 394 | if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) { |
| 395 | crnti = new Crnti(); |
| 396 | subCodeLength += crnti.decode(is, false); |
| 397 | subCodeLength += berTag.decode(is); |
| 398 | } |
| 399 | |
| 400 | if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) { |
| 401 | status = new Status(); |
| 402 | subCodeLength += status.decode(is, false); |
| 403 | if (subCodeLength == totalLength) { |
| 404 | return codeLength; |
| 405 | } |
| 406 | } |
| 407 | throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength); |
| 408 | |
| 409 | |
| 410 | } |
| 411 | |
| 412 | public void encodeAndSave(int encodingSizeGuess) throws IOException { |
| 413 | BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess); |
| 414 | encode(os, false); |
| 415 | code = os.getArray(); |
| 416 | } |
| 417 | |
| 418 | public String toString() { |
| 419 | StringBuilder sb = new StringBuilder(); |
| 420 | appendAsString(sb, 0); |
| 421 | return sb.toString(); |
| 422 | } |
| 423 | |
| 424 | public void appendAsString(StringBuilder sb, int indentLevel) { |
| 425 | |
| 426 | sb.append("{"); |
| 427 | sb.append("\n"); |
| 428 | for (int i = 0; i < indentLevel + 1; i++) { |
| 429 | sb.append("\t"); |
| 430 | } |
| 431 | if (ecgi != null) { |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 432 | sb.append("ecgi: "); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 433 | ecgi.appendAsString(sb, indentLevel + 1); |
| 434 | } |
| 435 | |
| 436 | if (crnti != null) { |
| 437 | sb.append(",\n"); |
| 438 | for (int i = 0; i < indentLevel + 1; i++) { |
| 439 | sb.append("\t"); |
| 440 | } |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 441 | sb.append("crnti: "); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 442 | crnti.appendAsString(sb, indentLevel + 1); |
| 443 | } |
| 444 | |
| 445 | sb.append(",\n"); |
| 446 | for (int i = 0; i < indentLevel + 1; i++) { |
| 447 | sb.append("\t"); |
| 448 | } |
| 449 | if (status != null) { |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 450 | sb.append("status: "); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 451 | status.appendAsString(sb, indentLevel + 1); |
| 452 | } |
| 453 | |
| 454 | sb.append("\n"); |
| 455 | for (int i = 0; i < indentLevel; i++) { |
| 456 | sb.append("\t"); |
| 457 | } |
| 458 | sb.append("}"); |
| 459 | } |
| 460 | |
| 461 | } |
| 462 | |