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