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; |
| 11 | import org.onosproject.xran.codecs.api.XICICPA; |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 12 | import org.onosproject.xran.codecs.ber.BerByteArrayOutputStream; |
| 13 | import org.onosproject.xran.codecs.ber.BerLength; |
| 14 | import org.onosproject.xran.codecs.ber.BerTag; |
| 15 | import org.onosproject.xran.codecs.ber.types.BerBitString; |
| 16 | import org.onosproject.xran.codecs.ber.types.BerInteger; |
| 17 | import org.onosproject.xran.codecs.ber.types.string.BerUTF8String; |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 18 | |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 19 | import java.io.IOException; |
| 20 | import java.io.InputStream; |
| 21 | import java.io.Serializable; |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 22 | import java.io.UnsupportedEncodingException; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 23 | import java.util.ArrayList; |
| 24 | import java.util.Iterator; |
| 25 | import java.util.List; |
| 26 | |
| 27 | public class RRMConfig implements Serializable { |
| 28 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 29 | public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); |
| 30 | private static final long serialVersionUID = 1L; |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 31 | @JsonIgnore |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 32 | public byte[] code = null; |
| 33 | private ECGI ecgi = null; |
| 34 | private Crnti crnti = null; |
| 35 | private Pa pa = null; |
| 36 | private StartPrbDl startPrbDl = null; |
| 37 | private EndPrbDl endPrbDl = null; |
| 38 | private SubframeBitmaskDl subframeBitmaskDl = null; |
| 39 | private P0UePusch p0UePusch = null; |
| 40 | private StartPrbUl startPrbUl = null; |
| 41 | private EndPrbUl endPrbUl = null; |
| 42 | private SubframeBitmaskUl subframeBitmaskUl = null; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 43 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 44 | public RRMConfig() { |
| 45 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 46 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 47 | public RRMConfig(byte[] code) { |
| 48 | this.code = code; |
| 49 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 50 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 51 | public ECGI getEcgi() { |
| 52 | return ecgi; |
| 53 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 54 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 55 | public void setEcgi(ECGI ecgi) { |
| 56 | this.ecgi = ecgi; |
| 57 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 58 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 59 | public Crnti getCrnti() { |
| 60 | return crnti; |
| 61 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 62 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 63 | public void setCrnti(Crnti crnti) { |
| 64 | this.crnti = crnti; |
| 65 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 66 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 67 | public Pa getPa() { |
| 68 | return pa; |
| 69 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 70 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 71 | public void setPa(Pa pa) { |
| 72 | this.pa = pa; |
| 73 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 74 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 75 | public StartPrbDl getStartPrbDl() { |
| 76 | return startPrbDl; |
| 77 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 78 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 79 | public void setStartPrbDl(StartPrbDl startPrbDl) { |
| 80 | this.startPrbDl = startPrbDl; |
| 81 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 82 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 83 | public EndPrbDl getEndPrbDl() { |
| 84 | return endPrbDl; |
| 85 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 86 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 87 | public void setEndPrbDl(EndPrbDl endPrbDl) { |
| 88 | this.endPrbDl = endPrbDl; |
| 89 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 90 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 91 | public SubframeBitmaskDl getSubframeBitmaskDl() { |
| 92 | return subframeBitmaskDl; |
| 93 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 94 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 95 | public void setSubframeBitmaskDl(SubframeBitmaskDl subframeBitmaskDl) { |
| 96 | this.subframeBitmaskDl = subframeBitmaskDl; |
| 97 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 98 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 99 | public P0UePusch getP0UePusch() { |
| 100 | return p0UePusch; |
| 101 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 102 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 103 | public void setP0UePusch(P0UePusch p0UePusch) { |
| 104 | this.p0UePusch = p0UePusch; |
| 105 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 106 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 107 | public StartPrbUl getStartPrbUl() { |
| 108 | return startPrbUl; |
| 109 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 110 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 111 | public void setStartPrbUl(StartPrbUl startPrbUl) { |
| 112 | this.startPrbUl = startPrbUl; |
| 113 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 114 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 115 | public EndPrbUl getEndPrbUl() { |
| 116 | return endPrbUl; |
| 117 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 118 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 119 | public void setEndPrbUl(EndPrbUl endPrbUl) { |
| 120 | this.endPrbUl = endPrbUl; |
| 121 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 122 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 123 | public SubframeBitmaskUl getSubframeBitmaskUl() { |
| 124 | return subframeBitmaskUl; |
| 125 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 126 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 127 | public void setSubframeBitmaskUl(SubframeBitmaskUl subframeBitmaskUl) { |
| 128 | this.subframeBitmaskUl = subframeBitmaskUl; |
| 129 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 130 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 131 | public int encode(BerByteArrayOutputStream os) throws IOException { |
| 132 | return encode(os, true); |
| 133 | } |
| 134 | |
| 135 | public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException { |
| 136 | |
| 137 | if (code != null) { |
| 138 | for (int i = code.length - 1; i >= 0; i--) { |
| 139 | os.write(code[i]); |
| 140 | } |
| 141 | if (withTag) { |
| 142 | return tag.encode(os) + code.length; |
| 143 | } |
| 144 | return code.length; |
| 145 | } |
| 146 | |
| 147 | int codeLength = 0; |
| 148 | if (subframeBitmaskUl != null) { |
| 149 | codeLength += subframeBitmaskUl.encode(os, false); |
| 150 | // write tag: CONTEXT_CLASS, CONSTRUCTED, 9 |
| 151 | os.write(0xA9); |
| 152 | codeLength += 1; |
| 153 | } |
| 154 | |
| 155 | if (endPrbUl != null) { |
| 156 | codeLength += endPrbUl.encode(os, false); |
| 157 | // write tag: CONTEXT_CLASS, CONSTRUCTED, 8 |
| 158 | os.write(0xA8); |
| 159 | codeLength += 1; |
| 160 | } |
| 161 | |
| 162 | if (startPrbUl != null) { |
| 163 | codeLength += startPrbUl.encode(os, false); |
| 164 | // write tag: CONTEXT_CLASS, CONSTRUCTED, 7 |
| 165 | os.write(0xA7); |
| 166 | codeLength += 1; |
| 167 | } |
| 168 | |
| 169 | if (p0UePusch != null) { |
| 170 | codeLength += p0UePusch.encode(os, false); |
| 171 | // write tag: CONTEXT_CLASS, CONSTRUCTED, 6 |
| 172 | os.write(0xA6); |
| 173 | codeLength += 1; |
| 174 | } |
| 175 | |
| 176 | if (subframeBitmaskDl != null) { |
| 177 | codeLength += subframeBitmaskDl.encode(os, false); |
| 178 | // write tag: CONTEXT_CLASS, CONSTRUCTED, 5 |
| 179 | os.write(0xA5); |
| 180 | codeLength += 1; |
| 181 | } |
| 182 | |
| 183 | if (endPrbDl != null) { |
| 184 | codeLength += endPrbDl.encode(os, false); |
| 185 | // write tag: CONTEXT_CLASS, CONSTRUCTED, 4 |
| 186 | os.write(0xA4); |
| 187 | codeLength += 1; |
| 188 | } |
| 189 | |
| 190 | if (startPrbDl != null) { |
| 191 | codeLength += startPrbDl.encode(os, false); |
| 192 | // write tag: CONTEXT_CLASS, CONSTRUCTED, 3 |
| 193 | os.write(0xA3); |
| 194 | codeLength += 1; |
| 195 | } |
| 196 | |
| 197 | if (pa != null) { |
| 198 | codeLength += pa.encode(os, false); |
| 199 | // write tag: CONTEXT_CLASS, CONSTRUCTED, 2 |
| 200 | os.write(0xA2); |
| 201 | codeLength += 1; |
| 202 | } |
| 203 | |
| 204 | if (crnti != null) { |
| 205 | codeLength += crnti.encode(os, false); |
| 206 | // write tag: CONTEXT_CLASS, CONSTRUCTED, 1 |
| 207 | os.write(0xA1); |
| 208 | codeLength += 1; |
| 209 | } |
| 210 | |
| 211 | codeLength += ecgi.encode(os, false); |
| 212 | // write tag: CONTEXT_CLASS, CONSTRUCTED, 0 |
| 213 | os.write(0xA0); |
| 214 | codeLength += 1; |
| 215 | |
| 216 | codeLength += BerLength.encodeLength(os, codeLength); |
| 217 | |
| 218 | if (withTag) { |
| 219 | codeLength += tag.encode(os); |
| 220 | } |
| 221 | |
| 222 | return codeLength; |
| 223 | |
| 224 | } |
| 225 | |
| 226 | public int decode(InputStream is) throws IOException { |
| 227 | return decode(is, true); |
| 228 | } |
| 229 | |
| 230 | public int decode(InputStream is, boolean withTag) throws IOException { |
| 231 | int codeLength = 0; |
| 232 | int subCodeLength = 0; |
| 233 | BerTag berTag = new BerTag(); |
| 234 | |
| 235 | if (withTag) { |
| 236 | codeLength += tag.decodeAndCheck(is); |
| 237 | } |
| 238 | |
| 239 | BerLength length = new BerLength(); |
| 240 | codeLength += length.decode(is); |
| 241 | |
| 242 | int totalLength = length.val; |
| 243 | codeLength += totalLength; |
| 244 | |
| 245 | subCodeLength += berTag.decode(is); |
| 246 | if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) { |
| 247 | ecgi = new ECGI(); |
| 248 | subCodeLength += ecgi.decode(is, false); |
| 249 | if (subCodeLength == totalLength) { |
| 250 | return codeLength; |
| 251 | } |
| 252 | subCodeLength += berTag.decode(is); |
| 253 | } else { |
| 254 | throw new IOException("Tag does not match the mandatory sequence element tag."); |
| 255 | } |
| 256 | |
| 257 | if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) { |
| 258 | crnti = new Crnti(); |
| 259 | subCodeLength += crnti.decode(is, false); |
| 260 | if (subCodeLength == totalLength) { |
| 261 | return codeLength; |
| 262 | } |
| 263 | subCodeLength += berTag.decode(is); |
| 264 | } |
| 265 | |
| 266 | if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) { |
| 267 | pa = new Pa(); |
| 268 | subCodeLength += pa.decode(is, false); |
| 269 | if (subCodeLength == totalLength) { |
| 270 | return codeLength; |
| 271 | } |
| 272 | subCodeLength += berTag.decode(is); |
| 273 | } |
| 274 | |
| 275 | if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 3)) { |
| 276 | startPrbDl = new StartPrbDl(); |
| 277 | subCodeLength += startPrbDl.decode(is, false); |
| 278 | if (subCodeLength == totalLength) { |
| 279 | return codeLength; |
| 280 | } |
| 281 | subCodeLength += berTag.decode(is); |
| 282 | } |
| 283 | |
| 284 | if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 4)) { |
| 285 | endPrbDl = new EndPrbDl(); |
| 286 | subCodeLength += endPrbDl.decode(is, false); |
| 287 | if (subCodeLength == totalLength) { |
| 288 | return codeLength; |
| 289 | } |
| 290 | subCodeLength += berTag.decode(is); |
| 291 | } |
| 292 | |
| 293 | if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 5)) { |
| 294 | subframeBitmaskDl = new SubframeBitmaskDl(); |
| 295 | subCodeLength += subframeBitmaskDl.decode(is, false); |
| 296 | if (subCodeLength == totalLength) { |
| 297 | return codeLength; |
| 298 | } |
| 299 | subCodeLength += berTag.decode(is); |
| 300 | } |
| 301 | |
| 302 | if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 6)) { |
| 303 | p0UePusch = new P0UePusch(); |
| 304 | subCodeLength += p0UePusch.decode(is, false); |
| 305 | if (subCodeLength == totalLength) { |
| 306 | return codeLength; |
| 307 | } |
| 308 | subCodeLength += berTag.decode(is); |
| 309 | } |
| 310 | |
| 311 | if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 7)) { |
| 312 | startPrbUl = new StartPrbUl(); |
| 313 | subCodeLength += startPrbUl.decode(is, false); |
| 314 | if (subCodeLength == totalLength) { |
| 315 | return codeLength; |
| 316 | } |
| 317 | subCodeLength += berTag.decode(is); |
| 318 | } |
| 319 | |
| 320 | if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 8)) { |
| 321 | endPrbUl = new EndPrbUl(); |
| 322 | subCodeLength += endPrbUl.decode(is, false); |
| 323 | if (subCodeLength == totalLength) { |
| 324 | return codeLength; |
| 325 | } |
| 326 | subCodeLength += berTag.decode(is); |
| 327 | } |
| 328 | |
| 329 | if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 9)) { |
| 330 | subframeBitmaskUl = new SubframeBitmaskUl(); |
| 331 | subCodeLength += subframeBitmaskUl.decode(is, false); |
| 332 | if (subCodeLength == totalLength) { |
| 333 | return codeLength; |
| 334 | } |
| 335 | } |
| 336 | throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength); |
| 337 | |
| 338 | |
| 339 | } |
| 340 | |
| 341 | public void encodeAndSave(int encodingSizeGuess) throws IOException { |
| 342 | BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess); |
| 343 | encode(os, false); |
| 344 | code = os.getArray(); |
| 345 | } |
| 346 | |
| 347 | public String toString() { |
| 348 | StringBuilder sb = new StringBuilder(); |
| 349 | appendAsString(sb, 0); |
| 350 | return sb.toString(); |
| 351 | } |
| 352 | |
| 353 | public void appendAsString(StringBuilder sb, int indentLevel) { |
| 354 | |
| 355 | sb.append("{"); |
| 356 | sb.append("\n"); |
| 357 | for (int i = 0; i < indentLevel + 1; i++) { |
| 358 | sb.append("\t"); |
| 359 | } |
| 360 | if (ecgi != null) { |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 361 | sb.append("ecgi: "); |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 362 | ecgi.appendAsString(sb, indentLevel + 1); |
| 363 | } |
| 364 | |
| 365 | if (crnti != null) { |
| 366 | sb.append(",\n"); |
| 367 | for (int i = 0; i < indentLevel + 1; i++) { |
| 368 | sb.append("\t"); |
| 369 | } |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 370 | sb.append("crnti: "); |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 371 | crnti.appendAsString(sb, indentLevel + 1); |
| 372 | } |
| 373 | |
| 374 | if (pa != null) { |
| 375 | sb.append(",\n"); |
| 376 | for (int i = 0; i < indentLevel + 1; i++) { |
| 377 | sb.append("\t"); |
| 378 | } |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 379 | sb.append("pa: "); |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 380 | pa.appendAsString(sb, indentLevel + 1); |
| 381 | } |
| 382 | |
| 383 | if (startPrbDl != null) { |
| 384 | sb.append(",\n"); |
| 385 | for (int i = 0; i < indentLevel + 1; i++) { |
| 386 | sb.append("\t"); |
| 387 | } |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 388 | sb.append("startPrbDl: "); |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 389 | startPrbDl.appendAsString(sb, indentLevel + 1); |
| 390 | } |
| 391 | |
| 392 | if (endPrbDl != null) { |
| 393 | sb.append(",\n"); |
| 394 | for (int i = 0; i < indentLevel + 1; i++) { |
| 395 | sb.append("\t"); |
| 396 | } |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 397 | sb.append("endPrbDl: "); |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 398 | endPrbDl.appendAsString(sb, indentLevel + 1); |
| 399 | } |
| 400 | |
| 401 | if (subframeBitmaskDl != null) { |
| 402 | sb.append(",\n"); |
| 403 | for (int i = 0; i < indentLevel + 1; i++) { |
| 404 | sb.append("\t"); |
| 405 | } |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 406 | sb.append("subframeBitmaskDl: "); |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 407 | subframeBitmaskDl.appendAsString(sb, indentLevel + 1); |
| 408 | } |
| 409 | |
| 410 | if (p0UePusch != null) { |
| 411 | sb.append(",\n"); |
| 412 | for (int i = 0; i < indentLevel + 1; i++) { |
| 413 | sb.append("\t"); |
| 414 | } |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 415 | sb.append("p0UePusch: "); |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 416 | p0UePusch.appendAsString(sb, indentLevel + 1); |
| 417 | } |
| 418 | |
| 419 | if (startPrbUl != null) { |
| 420 | sb.append(",\n"); |
| 421 | for (int i = 0; i < indentLevel + 1; i++) { |
| 422 | sb.append("\t"); |
| 423 | } |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 424 | sb.append("startPrbUl: "); |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 425 | startPrbUl.appendAsString(sb, indentLevel + 1); |
| 426 | } |
| 427 | |
| 428 | if (endPrbUl != null) { |
| 429 | sb.append(",\n"); |
| 430 | for (int i = 0; i < indentLevel + 1; i++) { |
| 431 | sb.append("\t"); |
| 432 | } |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 433 | sb.append("endPrbUl: "); |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 434 | endPrbUl.appendAsString(sb, indentLevel + 1); |
| 435 | } |
| 436 | |
| 437 | if (subframeBitmaskUl != null) { |
| 438 | sb.append(",\n"); |
| 439 | for (int i = 0; i < indentLevel + 1; i++) { |
| 440 | sb.append("\t"); |
| 441 | } |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 442 | sb.append("subframeBitmaskUl: "); |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 443 | subframeBitmaskUl.appendAsString(sb, indentLevel + 1); |
| 444 | } |
| 445 | |
| 446 | sb.append("\n"); |
| 447 | for (int i = 0; i < indentLevel; i++) { |
| 448 | sb.append("\t"); |
| 449 | } |
| 450 | sb.append("}"); |
| 451 | } |
| 452 | |
| 453 | public static class Crnti implements Serializable { |
| 454 | |
| 455 | public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); |
| 456 | private static final long serialVersionUID = 1L; |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 457 | @JsonIgnore public byte[] code = null; |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 458 | private List<CRNTI> seqOf = null; |
| 459 | |
| 460 | public Crnti() { |
| 461 | seqOf = new ArrayList<CRNTI>(); |
| 462 | } |
| 463 | |
| 464 | public Crnti(byte[] code) { |
| 465 | this.code = code; |
| 466 | } |
| 467 | |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 468 | @JsonValue |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 469 | public List<CRNTI> getCRNTI() { |
| 470 | if (seqOf == null) { |
| 471 | seqOf = new ArrayList<CRNTI>(); |
| 472 | } |
| 473 | return seqOf; |
| 474 | } |
| 475 | |
| 476 | public void addCRNTI(CRNTI crnti) { |
| 477 | seqOf.add(crnti); |
| 478 | } |
| 479 | |
| 480 | public int encode(BerByteArrayOutputStream os) throws IOException { |
| 481 | return encode(os, true); |
| 482 | } |
| 483 | |
| 484 | public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException { |
| 485 | |
| 486 | if (code != null) { |
| 487 | for (int i = code.length - 1; i >= 0; i--) { |
| 488 | os.write(code[i]); |
| 489 | } |
| 490 | if (withTag) { |
| 491 | return tag.encode(os) + code.length; |
| 492 | } |
| 493 | return code.length; |
| 494 | } |
| 495 | |
| 496 | int codeLength = 0; |
| 497 | for (int i = (seqOf.size() - 1); i >= 0; i--) { |
| 498 | codeLength += seqOf.get(i).encode(os, true); |
| 499 | } |
| 500 | |
| 501 | codeLength += BerLength.encodeLength(os, codeLength); |
| 502 | |
| 503 | if (withTag) { |
| 504 | codeLength += tag.encode(os); |
| 505 | } |
| 506 | |
| 507 | return codeLength; |
| 508 | } |
| 509 | |
| 510 | public int decode(InputStream is) throws IOException { |
| 511 | return decode(is, true); |
| 512 | } |
| 513 | |
| 514 | public int decode(InputStream is, boolean withTag) throws IOException { |
| 515 | int codeLength = 0; |
| 516 | int subCodeLength = 0; |
| 517 | if (withTag) { |
| 518 | codeLength += tag.decodeAndCheck(is); |
| 519 | } |
| 520 | |
| 521 | BerLength length = new BerLength(); |
| 522 | codeLength += length.decode(is); |
| 523 | int totalLength = length.val; |
| 524 | |
| 525 | while (subCodeLength < totalLength) { |
| 526 | CRNTI element = new CRNTI(); |
| 527 | subCodeLength += element.decode(is, true); |
| 528 | seqOf.add(element); |
| 529 | } |
| 530 | if (subCodeLength != totalLength) { |
| 531 | throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength); |
| 532 | |
| 533 | } |
| 534 | codeLength += subCodeLength; |
| 535 | |
| 536 | return codeLength; |
| 537 | } |
| 538 | |
| 539 | public void encodeAndSave(int encodingSizeGuess) throws IOException { |
| 540 | BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess); |
| 541 | encode(os, false); |
| 542 | code = os.getArray(); |
| 543 | } |
| 544 | |
| 545 | public String toString() { |
| 546 | StringBuilder sb = new StringBuilder(); |
| 547 | appendAsString(sb, 0); |
| 548 | return sb.toString(); |
| 549 | } |
| 550 | |
| 551 | public void appendAsString(StringBuilder sb, int indentLevel) { |
| 552 | |
| 553 | sb.append("[\n"); |
| 554 | for (int i = 0; i < indentLevel + 1; i++) { |
| 555 | sb.append("\t"); |
| 556 | } |
| 557 | if (seqOf == null) { |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 558 | // sb.append("null"); |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 559 | } else { |
| 560 | Iterator<CRNTI> it = seqOf.iterator(); |
| 561 | if (it.hasNext()) { |
| 562 | sb.append(it.next()); |
| 563 | while (it.hasNext()) { |
| 564 | sb.append(",\n"); |
| 565 | for (int i = 0; i < indentLevel + 1; i++) { |
| 566 | sb.append("\t"); |
| 567 | } |
| 568 | sb.append(it.next()); |
| 569 | } |
| 570 | } |
| 571 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 572 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 573 | sb.append("\n"); |
| 574 | for (int i = 0; i < indentLevel; i++) { |
| 575 | sb.append("\t"); |
| 576 | } |
| 577 | sb.append("]"); |
| 578 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 579 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 580 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 581 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 582 | public static class Pa implements Serializable { |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 583 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 584 | public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); |
| 585 | private static final long serialVersionUID = 1L; |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 586 | @JsonIgnore public byte[] code = null; |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 587 | private List<XICICPA> seqOf = null; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 588 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 589 | public Pa() { |
| 590 | seqOf = new ArrayList<XICICPA>(); |
| 591 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 592 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 593 | public Pa(byte[] code) { |
| 594 | this.code = code; |
| 595 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 596 | |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 597 | @JsonValue |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 598 | public List<XICICPA> getXICICPA() { |
| 599 | if (seqOf == null) { |
| 600 | seqOf = new ArrayList<XICICPA>(); |
| 601 | } |
| 602 | return seqOf; |
| 603 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 604 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 605 | public int encode(BerByteArrayOutputStream os) throws IOException { |
| 606 | return encode(os, true); |
| 607 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 608 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 609 | public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException { |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 610 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 611 | if (code != null) { |
| 612 | for (int i = code.length - 1; i >= 0; i--) { |
| 613 | os.write(code[i]); |
| 614 | } |
| 615 | if (withTag) { |
| 616 | return tag.encode(os) + code.length; |
| 617 | } |
| 618 | return code.length; |
| 619 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 620 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 621 | int codeLength = 0; |
| 622 | for (int i = (seqOf.size() - 1); i >= 0; i--) { |
| 623 | codeLength += seqOf.get(i).encode(os, true); |
| 624 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 625 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 626 | codeLength += BerLength.encodeLength(os, codeLength); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 627 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 628 | if (withTag) { |
| 629 | codeLength += tag.encode(os); |
| 630 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 631 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 632 | return codeLength; |
| 633 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 634 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 635 | public int decode(InputStream is) throws IOException { |
| 636 | return decode(is, true); |
| 637 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 638 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 639 | public int decode(InputStream is, boolean withTag) throws IOException { |
| 640 | int codeLength = 0; |
| 641 | int subCodeLength = 0; |
| 642 | if (withTag) { |
| 643 | codeLength += tag.decodeAndCheck(is); |
| 644 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 645 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 646 | BerLength length = new BerLength(); |
| 647 | codeLength += length.decode(is); |
| 648 | int totalLength = length.val; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 649 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 650 | while (subCodeLength < totalLength) { |
| 651 | XICICPA element = new XICICPA(); |
| 652 | subCodeLength += element.decode(is, true); |
| 653 | seqOf.add(element); |
| 654 | } |
| 655 | if (subCodeLength != totalLength) { |
| 656 | throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 657 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 658 | } |
| 659 | codeLength += subCodeLength; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 660 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 661 | return codeLength; |
| 662 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 663 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 664 | public void encodeAndSave(int encodingSizeGuess) throws IOException { |
| 665 | BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess); |
| 666 | encode(os, false); |
| 667 | code = os.getArray(); |
| 668 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 669 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 670 | public String toString() { |
| 671 | StringBuilder sb = new StringBuilder(); |
| 672 | appendAsString(sb, 0); |
| 673 | return sb.toString(); |
| 674 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 675 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 676 | public void appendAsString(StringBuilder sb, int indentLevel) { |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 677 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 678 | sb.append("[\n"); |
| 679 | for (int i = 0; i < indentLevel + 1; i++) { |
| 680 | sb.append("\t"); |
| 681 | } |
| 682 | if (seqOf == null) { |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 683 | // sb.append("null"); |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 684 | } else { |
| 685 | Iterator<XICICPA> it = seqOf.iterator(); |
| 686 | if (it.hasNext()) { |
| 687 | sb.append(it.next()); |
| 688 | while (it.hasNext()) { |
| 689 | sb.append(",\n"); |
| 690 | for (int i = 0; i < indentLevel + 1; i++) { |
| 691 | sb.append("\t"); |
| 692 | } |
| 693 | sb.append(it.next()); |
| 694 | } |
| 695 | } |
| 696 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 697 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 698 | sb.append("\n"); |
| 699 | for (int i = 0; i < indentLevel; i++) { |
| 700 | sb.append("\t"); |
| 701 | } |
| 702 | sb.append("]"); |
| 703 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 704 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 705 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 706 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 707 | public static class StartPrbDl implements Serializable { |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 708 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 709 | public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); |
| 710 | private static final long serialVersionUID = 1L; |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 711 | @JsonIgnore public byte[] code = null; |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 712 | private List<BerInteger> seqOf = null; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 713 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 714 | public StartPrbDl() { |
| 715 | seqOf = new ArrayList<BerInteger>(); |
| 716 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 717 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 718 | public StartPrbDl(byte[] code) { |
| 719 | this.code = code; |
| 720 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 721 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 722 | public List<BerInteger> getSeqOf() { |
| 723 | return seqOf; |
| 724 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 725 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 726 | public void setSeqOf(List<BerInteger> seqOf) { |
| 727 | this.seqOf = seqOf; |
| 728 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 729 | |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 730 | @JsonValue public List<BerInteger> getBerInteger() { |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 731 | if (seqOf == null) { |
| 732 | seqOf = new ArrayList<BerInteger>(); |
| 733 | } |
| 734 | return seqOf; |
| 735 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 736 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 737 | public int encode(BerByteArrayOutputStream os) throws IOException { |
| 738 | return encode(os, true); |
| 739 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 740 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 741 | public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException { |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 742 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 743 | if (code != null) { |
| 744 | for (int i = code.length - 1; i >= 0; i--) { |
| 745 | os.write(code[i]); |
| 746 | } |
| 747 | if (withTag) { |
| 748 | return tag.encode(os) + code.length; |
| 749 | } |
| 750 | return code.length; |
| 751 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 752 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 753 | int codeLength = 0; |
| 754 | for (int i = (seqOf.size() - 1); i >= 0; i--) { |
| 755 | codeLength += seqOf.get(i).encode(os, true); |
| 756 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 757 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 758 | codeLength += BerLength.encodeLength(os, codeLength); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 759 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 760 | if (withTag) { |
| 761 | codeLength += tag.encode(os); |
| 762 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 763 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 764 | return codeLength; |
| 765 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 766 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 767 | public int decode(InputStream is) throws IOException { |
| 768 | return decode(is, true); |
| 769 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 770 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 771 | public int decode(InputStream is, boolean withTag) throws IOException { |
| 772 | int codeLength = 0; |
| 773 | int subCodeLength = 0; |
| 774 | if (withTag) { |
| 775 | codeLength += tag.decodeAndCheck(is); |
| 776 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 777 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 778 | BerLength length = new BerLength(); |
| 779 | codeLength += length.decode(is); |
| 780 | int totalLength = length.val; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 781 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 782 | while (subCodeLength < totalLength) { |
| 783 | BerInteger element = new BerInteger(); |
| 784 | subCodeLength += element.decode(is, true); |
| 785 | seqOf.add(element); |
| 786 | } |
| 787 | if (subCodeLength != totalLength) { |
| 788 | throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 789 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 790 | } |
| 791 | codeLength += subCodeLength; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 792 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 793 | return codeLength; |
| 794 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 795 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 796 | public void encodeAndSave(int encodingSizeGuess) throws IOException { |
| 797 | BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess); |
| 798 | encode(os, false); |
| 799 | code = os.getArray(); |
| 800 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 801 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 802 | public String toString() { |
| 803 | StringBuilder sb = new StringBuilder(); |
| 804 | appendAsString(sb, 0); |
| 805 | return sb.toString(); |
| 806 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 807 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 808 | public void appendAsString(StringBuilder sb, int indentLevel) { |
| 809 | |
| 810 | sb.append("[\n"); |
| 811 | for (int i = 0; i < indentLevel + 1; i++) { |
| 812 | sb.append("\t"); |
| 813 | } |
| 814 | if (seqOf == null) { |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 815 | // sb.append("null"); |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 816 | } else { |
| 817 | Iterator<BerInteger> it = seqOf.iterator(); |
| 818 | if (it.hasNext()) { |
| 819 | sb.append(it.next()); |
| 820 | while (it.hasNext()) { |
| 821 | sb.append(",\n"); |
| 822 | for (int i = 0; i < indentLevel + 1; i++) { |
| 823 | sb.append("\t"); |
| 824 | } |
| 825 | sb.append(it.next()); |
| 826 | } |
| 827 | } |
| 828 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 829 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 830 | sb.append("\n"); |
| 831 | for (int i = 0; i < indentLevel; i++) { |
| 832 | sb.append("\t"); |
| 833 | } |
| 834 | sb.append("]"); |
| 835 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 836 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 837 | public void addBerInteger(BerInteger berInteger) { |
| 838 | seqOf.add(berInteger); |
| 839 | } |
| 840 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 841 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 842 | public static class EndPrbDl implements Serializable { |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 843 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 844 | public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); |
| 845 | private static final long serialVersionUID = 1L; |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 846 | @JsonIgnore public byte[] code = null; |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 847 | private List<BerInteger> seqOf = null; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 848 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 849 | public EndPrbDl() { |
| 850 | seqOf = new ArrayList<BerInteger>(); |
| 851 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 852 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 853 | public EndPrbDl(byte[] code) { |
| 854 | this.code = code; |
| 855 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 856 | |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 857 | @JsonValue public List<BerInteger> getBerInteger() { |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 858 | if (seqOf == null) { |
| 859 | seqOf = new ArrayList<BerInteger>(); |
| 860 | } |
| 861 | return seqOf; |
| 862 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 863 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 864 | public int encode(BerByteArrayOutputStream os) throws IOException { |
| 865 | return encode(os, true); |
| 866 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 867 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 868 | public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException { |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 869 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 870 | if (code != null) { |
| 871 | for (int i = code.length - 1; i >= 0; i--) { |
| 872 | os.write(code[i]); |
| 873 | } |
| 874 | if (withTag) { |
| 875 | return tag.encode(os) + code.length; |
| 876 | } |
| 877 | return code.length; |
| 878 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 879 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 880 | int codeLength = 0; |
| 881 | for (int i = (seqOf.size() - 1); i >= 0; i--) { |
| 882 | codeLength += seqOf.get(i).encode(os, true); |
| 883 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 884 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 885 | codeLength += BerLength.encodeLength(os, codeLength); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 886 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 887 | if (withTag) { |
| 888 | codeLength += tag.encode(os); |
| 889 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 890 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 891 | return codeLength; |
| 892 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 893 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 894 | public int decode(InputStream is) throws IOException { |
| 895 | return decode(is, true); |
| 896 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 897 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 898 | public int decode(InputStream is, boolean withTag) throws IOException { |
| 899 | int codeLength = 0; |
| 900 | int subCodeLength = 0; |
| 901 | if (withTag) { |
| 902 | codeLength += tag.decodeAndCheck(is); |
| 903 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 904 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 905 | BerLength length = new BerLength(); |
| 906 | codeLength += length.decode(is); |
| 907 | int totalLength = length.val; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 908 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 909 | while (subCodeLength < totalLength) { |
| 910 | BerInteger element = new BerInteger(); |
| 911 | subCodeLength += element.decode(is, true); |
| 912 | seqOf.add(element); |
| 913 | } |
| 914 | if (subCodeLength != totalLength) { |
| 915 | throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 916 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 917 | } |
| 918 | codeLength += subCodeLength; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 919 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 920 | return codeLength; |
| 921 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 922 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 923 | public void encodeAndSave(int encodingSizeGuess) throws IOException { |
| 924 | BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess); |
| 925 | encode(os, false); |
| 926 | code = os.getArray(); |
| 927 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 928 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 929 | public String toString() { |
| 930 | StringBuilder sb = new StringBuilder(); |
| 931 | appendAsString(sb, 0); |
| 932 | return sb.toString(); |
| 933 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 934 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 935 | public void appendAsString(StringBuilder sb, int indentLevel) { |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 936 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 937 | sb.append("[\n"); |
| 938 | for (int i = 0; i < indentLevel + 1; i++) { |
| 939 | sb.append("\t"); |
| 940 | } |
| 941 | if (seqOf == null) { |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 942 | // sb.append("null"); |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 943 | } else { |
| 944 | Iterator<BerInteger> it = seqOf.iterator(); |
| 945 | if (it.hasNext()) { |
| 946 | sb.append(it.next()); |
| 947 | while (it.hasNext()) { |
| 948 | sb.append(",\n"); |
| 949 | for (int i = 0; i < indentLevel + 1; i++) { |
| 950 | sb.append("\t"); |
| 951 | } |
| 952 | sb.append(it.next()); |
| 953 | } |
| 954 | } |
| 955 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 956 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 957 | sb.append("\n"); |
| 958 | for (int i = 0; i < indentLevel; i++) { |
| 959 | sb.append("\t"); |
| 960 | } |
| 961 | sb.append("]"); |
| 962 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 963 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 964 | public void addBerInteger(BerInteger berInteger) { |
| 965 | seqOf.add(berInteger); |
| 966 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 967 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 968 | public List<BerInteger> getSeqOf() { |
| 969 | return seqOf; |
| 970 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 971 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 972 | public void setSeqOf(List<BerInteger> seqOf) { |
| 973 | this.seqOf = seqOf; |
| 974 | } |
| 975 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 976 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 977 | public static class SubframeBitmaskDl implements Serializable { |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 978 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 979 | public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); |
| 980 | private static final long serialVersionUID = 1L; |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 981 | @JsonIgnore public byte[] code = null; |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 982 | private List<BerBitString> seqOf = null; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 983 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 984 | public SubframeBitmaskDl() { |
| 985 | seqOf = new ArrayList<BerBitString>(); |
| 986 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 987 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 988 | public SubframeBitmaskDl(byte[] code) { |
| 989 | this.code = code; |
| 990 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 991 | |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 992 | @JsonValue |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 993 | public List<BerBitString> getBerBitString() { |
| 994 | if (seqOf == null) { |
| 995 | seqOf = new ArrayList<BerBitString>(); |
| 996 | } |
| 997 | return seqOf; |
| 998 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 999 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1000 | public void addBerBitString(BerBitString berBitString) { |
| 1001 | seqOf.add(berBitString); |
| 1002 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1003 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1004 | public int encode(BerByteArrayOutputStream os) throws IOException { |
| 1005 | return encode(os, true); |
| 1006 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1007 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1008 | public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException { |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1009 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1010 | if (code != null) { |
| 1011 | for (int i = code.length - 1; i >= 0; i--) { |
| 1012 | os.write(code[i]); |
| 1013 | } |
| 1014 | if (withTag) { |
| 1015 | return tag.encode(os) + code.length; |
| 1016 | } |
| 1017 | return code.length; |
| 1018 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1019 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1020 | int codeLength = 0; |
| 1021 | for (int i = (seqOf.size() - 1); i >= 0; i--) { |
| 1022 | codeLength += seqOf.get(i).encode(os, true); |
| 1023 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1024 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1025 | codeLength += BerLength.encodeLength(os, codeLength); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1026 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1027 | if (withTag) { |
| 1028 | codeLength += tag.encode(os); |
| 1029 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1030 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1031 | return codeLength; |
| 1032 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1033 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1034 | public int decode(InputStream is) throws IOException { |
| 1035 | return decode(is, true); |
| 1036 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1037 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1038 | public int decode(InputStream is, boolean withTag) throws IOException { |
| 1039 | int codeLength = 0; |
| 1040 | int subCodeLength = 0; |
| 1041 | if (withTag) { |
| 1042 | codeLength += tag.decodeAndCheck(is); |
| 1043 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1044 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1045 | BerLength length = new BerLength(); |
| 1046 | codeLength += length.decode(is); |
| 1047 | int totalLength = length.val; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1048 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1049 | while (subCodeLength < totalLength) { |
| 1050 | BerBitString element = new BerBitString(); |
| 1051 | subCodeLength += element.decode(is, true); |
| 1052 | seqOf.add(element); |
| 1053 | } |
| 1054 | if (subCodeLength != totalLength) { |
| 1055 | throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1056 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1057 | } |
| 1058 | codeLength += subCodeLength; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1059 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1060 | return codeLength; |
| 1061 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1062 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1063 | public void encodeAndSave(int encodingSizeGuess) throws IOException { |
| 1064 | BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess); |
| 1065 | encode(os, false); |
| 1066 | code = os.getArray(); |
| 1067 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1068 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1069 | public String toString() { |
| 1070 | StringBuilder sb = new StringBuilder(); |
| 1071 | appendAsString(sb, 0); |
| 1072 | return sb.toString(); |
| 1073 | } |
| 1074 | |
| 1075 | public void appendAsString(StringBuilder sb, int indentLevel) { |
| 1076 | |
| 1077 | sb.append("[\n"); |
| 1078 | for (int i = 0; i < indentLevel + 1; i++) { |
| 1079 | sb.append("\t"); |
| 1080 | } |
| 1081 | if (seqOf == null) { |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1082 | // sb.append("null"); |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1083 | } else { |
| 1084 | Iterator<BerBitString> it = seqOf.iterator(); |
| 1085 | if (it.hasNext()) { |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 1086 | sb.append("" + it.next() + ""); |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1087 | while (it.hasNext()) { |
| 1088 | sb.append(",\n"); |
| 1089 | for (int i = 0; i < indentLevel + 1; i++) { |
| 1090 | sb.append("\t"); |
| 1091 | } |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 1092 | sb.append("" + it.next() + ""); |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1093 | } |
| 1094 | } |
| 1095 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1096 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1097 | sb.append("\n"); |
| 1098 | for (int i = 0; i < indentLevel; i++) { |
| 1099 | sb.append("\t"); |
| 1100 | } |
| 1101 | sb.append("]"); |
| 1102 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1103 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1104 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1105 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1106 | public static class P0UePusch implements Serializable { |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1107 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1108 | public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); |
| 1109 | private static final long serialVersionUID = 1L; |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 1110 | @JsonIgnore public byte[] code = null; |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1111 | private List<BerInteger> seqOf = null; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1112 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1113 | public P0UePusch() { |
| 1114 | seqOf = new ArrayList<BerInteger>(); |
| 1115 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1116 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1117 | public P0UePusch(byte[] code) { |
| 1118 | this.code = code; |
| 1119 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1120 | |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 1121 | @JsonValue public List<BerInteger> getBerInteger() { |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1122 | if (seqOf == null) { |
| 1123 | seqOf = new ArrayList<BerInteger>(); |
| 1124 | } |
| 1125 | return seqOf; |
| 1126 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1127 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1128 | public int encode(BerByteArrayOutputStream os) throws IOException { |
| 1129 | return encode(os, true); |
| 1130 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1131 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1132 | public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException { |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1133 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1134 | if (code != null) { |
| 1135 | for (int i = code.length - 1; i >= 0; i--) { |
| 1136 | os.write(code[i]); |
| 1137 | } |
| 1138 | if (withTag) { |
| 1139 | return tag.encode(os) + code.length; |
| 1140 | } |
| 1141 | return code.length; |
| 1142 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1143 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1144 | int codeLength = 0; |
| 1145 | for (int i = (seqOf.size() - 1); i >= 0; i--) { |
| 1146 | codeLength += seqOf.get(i).encode(os, true); |
| 1147 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1148 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1149 | codeLength += BerLength.encodeLength(os, codeLength); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1150 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1151 | if (withTag) { |
| 1152 | codeLength += tag.encode(os); |
| 1153 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1154 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1155 | return codeLength; |
| 1156 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1157 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1158 | public int decode(InputStream is) throws IOException { |
| 1159 | return decode(is, true); |
| 1160 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1161 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1162 | public int decode(InputStream is, boolean withTag) throws IOException { |
| 1163 | int codeLength = 0; |
| 1164 | int subCodeLength = 0; |
| 1165 | if (withTag) { |
| 1166 | codeLength += tag.decodeAndCheck(is); |
| 1167 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1168 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1169 | BerLength length = new BerLength(); |
| 1170 | codeLength += length.decode(is); |
| 1171 | int totalLength = length.val; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1172 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1173 | while (subCodeLength < totalLength) { |
| 1174 | BerInteger element = new BerInteger(); |
| 1175 | subCodeLength += element.decode(is, true); |
| 1176 | seqOf.add(element); |
| 1177 | } |
| 1178 | if (subCodeLength != totalLength) { |
| 1179 | throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1180 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1181 | } |
| 1182 | codeLength += subCodeLength; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1183 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1184 | return codeLength; |
| 1185 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1186 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1187 | public void encodeAndSave(int encodingSizeGuess) throws IOException { |
| 1188 | BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess); |
| 1189 | encode(os, false); |
| 1190 | code = os.getArray(); |
| 1191 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1192 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1193 | public String toString() { |
| 1194 | StringBuilder sb = new StringBuilder(); |
| 1195 | appendAsString(sb, 0); |
| 1196 | return sb.toString(); |
| 1197 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1198 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1199 | public void appendAsString(StringBuilder sb, int indentLevel) { |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1200 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1201 | sb.append("[\n"); |
| 1202 | for (int i = 0; i < indentLevel + 1; i++) { |
| 1203 | sb.append("\t"); |
| 1204 | } |
| 1205 | if (seqOf == null) { |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1206 | // sb.append("null"); |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1207 | } else { |
| 1208 | Iterator<BerInteger> it = seqOf.iterator(); |
| 1209 | if (it.hasNext()) { |
| 1210 | sb.append(it.next()); |
| 1211 | while (it.hasNext()) { |
| 1212 | sb.append(",\n"); |
| 1213 | for (int i = 0; i < indentLevel + 1; i++) { |
| 1214 | sb.append("\t"); |
| 1215 | } |
| 1216 | sb.append(it.next()); |
| 1217 | } |
| 1218 | } |
| 1219 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1220 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1221 | sb.append("\n"); |
| 1222 | for (int i = 0; i < indentLevel; i++) { |
| 1223 | sb.append("\t"); |
| 1224 | } |
| 1225 | sb.append("]"); |
| 1226 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1227 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1228 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1229 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1230 | public static class StartPrbUl implements Serializable { |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1231 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1232 | public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); |
| 1233 | private static final long serialVersionUID = 1L; |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 1234 | @JsonIgnore public byte[] code = null; |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1235 | private List<BerInteger> seqOf = null; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1236 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1237 | public StartPrbUl() { |
| 1238 | seqOf = new ArrayList<BerInteger>(); |
| 1239 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1240 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1241 | public StartPrbUl(byte[] code) { |
| 1242 | this.code = code; |
| 1243 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1244 | |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 1245 | @JsonValue public List<BerInteger> getBerInteger() { |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1246 | if (seqOf == null) { |
| 1247 | seqOf = new ArrayList<BerInteger>(); |
| 1248 | } |
| 1249 | return seqOf; |
| 1250 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1251 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1252 | public int encode(BerByteArrayOutputStream os) throws IOException { |
| 1253 | return encode(os, true); |
| 1254 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1255 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1256 | public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException { |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1257 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1258 | if (code != null) { |
| 1259 | for (int i = code.length - 1; i >= 0; i--) { |
| 1260 | os.write(code[i]); |
| 1261 | } |
| 1262 | if (withTag) { |
| 1263 | return tag.encode(os) + code.length; |
| 1264 | } |
| 1265 | return code.length; |
| 1266 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1267 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1268 | int codeLength = 0; |
| 1269 | for (int i = (seqOf.size() - 1); i >= 0; i--) { |
| 1270 | codeLength += seqOf.get(i).encode(os, true); |
| 1271 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1272 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1273 | codeLength += BerLength.encodeLength(os, codeLength); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1274 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1275 | if (withTag) { |
| 1276 | codeLength += tag.encode(os); |
| 1277 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1278 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1279 | return codeLength; |
| 1280 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1281 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1282 | public int decode(InputStream is) throws IOException { |
| 1283 | return decode(is, true); |
| 1284 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1285 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1286 | public int decode(InputStream is, boolean withTag) throws IOException { |
| 1287 | int codeLength = 0; |
| 1288 | int subCodeLength = 0; |
| 1289 | if (withTag) { |
| 1290 | codeLength += tag.decodeAndCheck(is); |
| 1291 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1292 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1293 | BerLength length = new BerLength(); |
| 1294 | codeLength += length.decode(is); |
| 1295 | int totalLength = length.val; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1296 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1297 | while (subCodeLength < totalLength) { |
| 1298 | BerInteger element = new BerInteger(); |
| 1299 | subCodeLength += element.decode(is, true); |
| 1300 | seqOf.add(element); |
| 1301 | } |
| 1302 | if (subCodeLength != totalLength) { |
| 1303 | throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1304 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1305 | } |
| 1306 | codeLength += subCodeLength; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1307 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1308 | return codeLength; |
| 1309 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1310 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1311 | public void encodeAndSave(int encodingSizeGuess) throws IOException { |
| 1312 | BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess); |
| 1313 | encode(os, false); |
| 1314 | code = os.getArray(); |
| 1315 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1316 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1317 | public String toString() { |
| 1318 | StringBuilder sb = new StringBuilder(); |
| 1319 | appendAsString(sb, 0); |
| 1320 | return sb.toString(); |
| 1321 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1322 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1323 | public void appendAsString(StringBuilder sb, int indentLevel) { |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1324 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1325 | sb.append("[\n"); |
| 1326 | for (int i = 0; i < indentLevel + 1; i++) { |
| 1327 | sb.append("\t"); |
| 1328 | } |
| 1329 | if (seqOf == null) { |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1330 | // sb.append("null"); |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1331 | } else { |
| 1332 | Iterator<BerInteger> it = seqOf.iterator(); |
| 1333 | if (it.hasNext()) { |
| 1334 | sb.append(it.next()); |
| 1335 | while (it.hasNext()) { |
| 1336 | sb.append(",\n"); |
| 1337 | for (int i = 0; i < indentLevel + 1; i++) { |
| 1338 | sb.append("\t"); |
| 1339 | } |
| 1340 | sb.append(it.next()); |
| 1341 | } |
| 1342 | } |
| 1343 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1344 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1345 | sb.append("\n"); |
| 1346 | for (int i = 0; i < indentLevel; i++) { |
| 1347 | sb.append("\t"); |
| 1348 | } |
| 1349 | sb.append("]"); |
| 1350 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1351 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1352 | public void addBerInteger(BerInteger berInteger) { |
| 1353 | seqOf.add(berInteger); |
| 1354 | } |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame] | 1355 | |
| 1356 | public List<BerInteger> getSeqOf() { |
| 1357 | return seqOf; |
| 1358 | } |
| 1359 | |
| 1360 | public void setSeqOf(List<BerInteger> seqOf) { |
| 1361 | this.seqOf = seqOf; |
| 1362 | } |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1363 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1364 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1365 | public static class EndPrbUl implements Serializable { |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1366 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1367 | public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); |
| 1368 | private static final long serialVersionUID = 1L; |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 1369 | @JsonIgnore public byte[] code = null; |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1370 | private List<BerInteger> seqOf = null; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1371 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1372 | public EndPrbUl() { |
| 1373 | seqOf = new ArrayList<BerInteger>(); |
| 1374 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1375 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1376 | public EndPrbUl(byte[] code) { |
| 1377 | this.code = code; |
| 1378 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1379 | |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 1380 | @JsonValue |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1381 | public List<BerInteger> getBerInteger() { |
| 1382 | if (seqOf == null) { |
| 1383 | seqOf = new ArrayList<BerInteger>(); |
| 1384 | } |
| 1385 | return seqOf; |
| 1386 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1387 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1388 | public int encode(BerByteArrayOutputStream os) throws IOException { |
| 1389 | return encode(os, true); |
| 1390 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1391 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1392 | public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException { |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1393 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1394 | if (code != null) { |
| 1395 | for (int i = code.length - 1; i >= 0; i--) { |
| 1396 | os.write(code[i]); |
| 1397 | } |
| 1398 | if (withTag) { |
| 1399 | return tag.encode(os) + code.length; |
| 1400 | } |
| 1401 | return code.length; |
| 1402 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1403 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1404 | int codeLength = 0; |
| 1405 | for (int i = (seqOf.size() - 1); i >= 0; i--) { |
| 1406 | codeLength += seqOf.get(i).encode(os, true); |
| 1407 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1408 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1409 | codeLength += BerLength.encodeLength(os, codeLength); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1410 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1411 | if (withTag) { |
| 1412 | codeLength += tag.encode(os); |
| 1413 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1414 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1415 | return codeLength; |
| 1416 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1417 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1418 | public int decode(InputStream is) throws IOException { |
| 1419 | return decode(is, true); |
| 1420 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1421 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1422 | public int decode(InputStream is, boolean withTag) throws IOException { |
| 1423 | int codeLength = 0; |
| 1424 | int subCodeLength = 0; |
| 1425 | if (withTag) { |
| 1426 | codeLength += tag.decodeAndCheck(is); |
| 1427 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1428 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1429 | BerLength length = new BerLength(); |
| 1430 | codeLength += length.decode(is); |
| 1431 | int totalLength = length.val; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1432 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1433 | while (subCodeLength < totalLength) { |
| 1434 | BerInteger element = new BerInteger(); |
| 1435 | subCodeLength += element.decode(is, true); |
| 1436 | seqOf.add(element); |
| 1437 | } |
| 1438 | if (subCodeLength != totalLength) { |
| 1439 | throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1440 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1441 | } |
| 1442 | codeLength += subCodeLength; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1443 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1444 | return codeLength; |
| 1445 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1446 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1447 | public void encodeAndSave(int encodingSizeGuess) throws IOException { |
| 1448 | BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess); |
| 1449 | encode(os, false); |
| 1450 | code = os.getArray(); |
| 1451 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1452 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1453 | public String toString() { |
| 1454 | StringBuilder sb = new StringBuilder(); |
| 1455 | appendAsString(sb, 0); |
| 1456 | return sb.toString(); |
| 1457 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1458 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1459 | public void appendAsString(StringBuilder sb, int indentLevel) { |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1460 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1461 | sb.append("[\n"); |
| 1462 | for (int i = 0; i < indentLevel + 1; i++) { |
| 1463 | sb.append("\t"); |
| 1464 | } |
| 1465 | if (seqOf == null) { |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1466 | // sb.append("null"); |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1467 | } else { |
| 1468 | Iterator<BerInteger> it = seqOf.iterator(); |
| 1469 | if (it.hasNext()) { |
| 1470 | sb.append(it.next()); |
| 1471 | while (it.hasNext()) { |
| 1472 | sb.append(",\n"); |
| 1473 | for (int i = 0; i < indentLevel + 1; i++) { |
| 1474 | sb.append("\t"); |
| 1475 | } |
| 1476 | sb.append(it.next()); |
| 1477 | } |
| 1478 | } |
| 1479 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1480 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1481 | sb.append("\n"); |
| 1482 | for (int i = 0; i < indentLevel; i++) { |
| 1483 | sb.append("\t"); |
| 1484 | } |
| 1485 | sb.append("]"); |
| 1486 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1487 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1488 | public void addBerInteger(BerInteger berInteger) { |
| 1489 | seqOf.add(berInteger); |
| 1490 | } |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame] | 1491 | |
| 1492 | public List<BerInteger> getSeqOf() { |
| 1493 | return seqOf; |
| 1494 | } |
| 1495 | |
| 1496 | public void setSeqOf(List<BerInteger> seqOf) { |
| 1497 | this.seqOf = seqOf; |
| 1498 | } |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1499 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1500 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1501 | public static class SubframeBitmaskUl implements Serializable { |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1502 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1503 | public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); |
| 1504 | private static final long serialVersionUID = 1L; |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 1505 | @JsonIgnore public byte[] code = null; |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1506 | private List<BerBitString> seqOf = null; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1507 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1508 | public SubframeBitmaskUl() { |
| 1509 | seqOf = new ArrayList<BerBitString>(); |
| 1510 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1511 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1512 | public SubframeBitmaskUl(byte[] code) { |
| 1513 | this.code = code; |
| 1514 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1515 | |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 1516 | @JsonValue |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1517 | public List<BerBitString> getBerBitString() { |
| 1518 | if (seqOf == null) { |
| 1519 | seqOf = new ArrayList<BerBitString>(); |
| 1520 | } |
| 1521 | return seqOf; |
| 1522 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1523 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1524 | public int encode(BerByteArrayOutputStream os) throws IOException { |
| 1525 | return encode(os, true); |
| 1526 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1527 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1528 | public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException { |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1529 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1530 | if (code != null) { |
| 1531 | for (int i = code.length - 1; i >= 0; i--) { |
| 1532 | os.write(code[i]); |
| 1533 | } |
| 1534 | if (withTag) { |
| 1535 | return tag.encode(os) + code.length; |
| 1536 | } |
| 1537 | return code.length; |
| 1538 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1539 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1540 | int codeLength = 0; |
| 1541 | for (int i = (seqOf.size() - 1); i >= 0; i--) { |
| 1542 | codeLength += seqOf.get(i).encode(os, true); |
| 1543 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1544 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1545 | codeLength += BerLength.encodeLength(os, codeLength); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1546 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1547 | if (withTag) { |
| 1548 | codeLength += tag.encode(os); |
| 1549 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1550 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1551 | return codeLength; |
| 1552 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1553 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1554 | public int decode(InputStream is) throws IOException { |
| 1555 | return decode(is, true); |
| 1556 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1557 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1558 | public int decode(InputStream is, boolean withTag) throws IOException { |
| 1559 | int codeLength = 0; |
| 1560 | int subCodeLength = 0; |
| 1561 | if (withTag) { |
| 1562 | codeLength += tag.decodeAndCheck(is); |
| 1563 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1564 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1565 | BerLength length = new BerLength(); |
| 1566 | codeLength += length.decode(is); |
| 1567 | int totalLength = length.val; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1568 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1569 | while (subCodeLength < totalLength) { |
| 1570 | BerBitString element = new BerBitString(); |
| 1571 | subCodeLength += element.decode(is, true); |
| 1572 | seqOf.add(element); |
| 1573 | } |
| 1574 | if (subCodeLength != totalLength) { |
| 1575 | throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + totalLength + " but has " + subCodeLength); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1576 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1577 | } |
| 1578 | codeLength += subCodeLength; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1579 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1580 | return codeLength; |
| 1581 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1582 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1583 | public void encodeAndSave(int encodingSizeGuess) throws IOException { |
| 1584 | BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess); |
| 1585 | encode(os, false); |
| 1586 | code = os.getArray(); |
| 1587 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1588 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1589 | public String toString() { |
| 1590 | StringBuilder sb = new StringBuilder(); |
| 1591 | appendAsString(sb, 0); |
| 1592 | return sb.toString(); |
| 1593 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1594 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1595 | public void appendAsString(StringBuilder sb, int indentLevel) { |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1596 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1597 | sb.append("[\n"); |
| 1598 | for (int i = 0; i < indentLevel + 1; i++) { |
| 1599 | sb.append("\t"); |
| 1600 | } |
| 1601 | if (seqOf == null) { |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1602 | // sb.append("null"); |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1603 | } else { |
| 1604 | Iterator<BerBitString> it = seqOf.iterator(); |
| 1605 | if (it.hasNext()) { |
| 1606 | sb.append(it.next()); |
| 1607 | while (it.hasNext()) { |
| 1608 | sb.append(",\n"); |
| 1609 | for (int i = 0; i < indentLevel + 1; i++) { |
| 1610 | sb.append("\t"); |
| 1611 | } |
| 1612 | sb.append(it.next()); |
| 1613 | } |
| 1614 | } |
| 1615 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1616 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1617 | sb.append("\n"); |
| 1618 | for (int i = 0; i < indentLevel; i++) { |
| 1619 | sb.append("\t"); |
| 1620 | } |
| 1621 | sb.append("]"); |
| 1622 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1623 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1624 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1625 | |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame] | 1626 | public static XrancPdu constructPacket(RRMConfig config) { |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1627 | XrancPduBody body = new XrancPduBody(); |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame] | 1628 | body.setRRMConfig(config); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1629 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1630 | BerUTF8String ver = null; |
| 1631 | try { |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame] | 1632 | ver = new BerUTF8String("3"); |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1633 | } catch (UnsupportedEncodingException e) { |
| 1634 | e.printStackTrace(); |
| 1635 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1636 | |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame] | 1637 | XrancApiID apiID = new XrancApiID(29); |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1638 | XrancPduHdr hdr = new XrancPduHdr(); |
| 1639 | hdr.setVer(ver); |
| 1640 | hdr.setApiId(apiID); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1641 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 1642 | XrancPdu pdu = new XrancPdu(); |
| 1643 | pdu.setHdr(hdr); |
| 1644 | pdu.setBody(body); |
| 1645 | return pdu; |
| 1646 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1647 | |
| 1648 | } |
| 1649 | |