slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1 | /** |
| 2 | * This class file was automatically generated by jASN1 v1.8.0 (http://www.openmuc.org) |
| 3 | */ |
| 4 | |
| 5 | package org.onosproject.xran.codecs.pdu; |
| 6 | |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 7 | import com.fasterxml.jackson.annotation.JsonIgnore; |
| 8 | import org.onosproject.xran.codecs.ber.BerByteArrayOutputStream; |
| 9 | import org.onosproject.xran.codecs.ber.BerLength; |
| 10 | import org.onosproject.xran.codecs.ber.BerTag; |
| 11 | import org.onosproject.xran.codecs.ber.types.BerInteger; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 12 | import org.onosproject.xran.codecs.api.CRNTI; |
| 13 | import org.onosproject.xran.codecs.api.ECGI; |
| 14 | import org.onosproject.xran.codecs.api.ERABParams; |
| 15 | import org.onosproject.xran.codecs.api.UEAMBR; |
| 16 | |
| 17 | import java.io.IOException; |
| 18 | import java.io.InputStream; |
| 19 | import java.io.Serializable; |
| 20 | |
| 21 | public class BearerAdmissionRequest implements Serializable { |
| 22 | |
| 23 | private static final long serialVersionUID = 1L; |
| 24 | |
| 25 | public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); |
| 26 | |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 27 | @JsonIgnore |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 28 | public byte[] code = null; |
| 29 | private CRNTI crnti = null; |
| 30 | private ECGI ecgi = null; |
| 31 | private UEAMBR ueAmbr = null; |
| 32 | private BerInteger numErabs = null; |
| 33 | private ERABParams erabParams = null; |
| 34 | |
| 35 | public BearerAdmissionRequest() { |
| 36 | } |
| 37 | |
| 38 | public BearerAdmissionRequest(byte[] code) { |
| 39 | this.code = code; |
| 40 | } |
| 41 | |
| 42 | public void setCrnti(CRNTI crnti) { |
| 43 | this.crnti = crnti; |
| 44 | } |
| 45 | |
| 46 | public CRNTI getCrnti() { |
| 47 | return crnti; |
| 48 | } |
| 49 | |
| 50 | public void setEcgi(ECGI ecgi) { |
| 51 | this.ecgi = ecgi; |
| 52 | } |
| 53 | |
| 54 | public ECGI getEcgi() { |
| 55 | return ecgi; |
| 56 | } |
| 57 | |
| 58 | public void setUeAmbr(UEAMBR ueAmbr) { |
| 59 | this.ueAmbr = ueAmbr; |
| 60 | } |
| 61 | |
| 62 | public UEAMBR getUeAmbr() { |
| 63 | return ueAmbr; |
| 64 | } |
| 65 | |
| 66 | public void setNumErabs(BerInteger numErabs) { |
| 67 | this.numErabs = numErabs; |
| 68 | } |
| 69 | |
| 70 | public BerInteger getNumErabs() { |
| 71 | return numErabs; |
| 72 | } |
| 73 | |
| 74 | public void setErabParams(ERABParams erabParams) { |
| 75 | this.erabParams = erabParams; |
| 76 | } |
| 77 | |
| 78 | public ERABParams getErabParams() { |
| 79 | return erabParams; |
| 80 | } |
| 81 | |
| 82 | public int encode(BerByteArrayOutputStream os) throws IOException { |
| 83 | return encode(os, true); |
| 84 | } |
| 85 | |
| 86 | public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException { |
| 87 | |
| 88 | if (code != null) { |
| 89 | for (int i = code.length - 1; i >= 0; i--) { |
| 90 | os.write(code[i]); |
| 91 | } |
| 92 | if (withTag) { |
| 93 | return tag.encode(os) + code.length; |
| 94 | } |
| 95 | return code.length; |
| 96 | } |
| 97 | |
| 98 | int codeLength = 0; |
| 99 | codeLength += erabParams.encode(os, false); |
| 100 | // write tag: CONTEXT_CLASS, CONSTRUCTED, 4 |
| 101 | os.write(0xA4); |
| 102 | codeLength += 1; |
| 103 | |
| 104 | codeLength += numErabs.encode(os, false); |
| 105 | // write tag: CONTEXT_CLASS, PRIMITIVE, 3 |
| 106 | os.write(0x83); |
| 107 | codeLength += 1; |
| 108 | |
| 109 | codeLength += ueAmbr.encode(os, false); |
| 110 | // write tag: CONTEXT_CLASS, CONSTRUCTED, 2 |
| 111 | os.write(0xA2); |
| 112 | codeLength += 1; |
| 113 | |
| 114 | codeLength += ecgi.encode(os, false); |
| 115 | // write tag: CONTEXT_CLASS, CONSTRUCTED, 1 |
| 116 | os.write(0xA1); |
| 117 | codeLength += 1; |
| 118 | |
| 119 | codeLength += crnti.encode(os, false); |
| 120 | // write tag: CONTEXT_CLASS, PRIMITIVE, 0 |
| 121 | os.write(0x80); |
| 122 | codeLength += 1; |
| 123 | |
| 124 | codeLength += BerLength.encodeLength(os, codeLength); |
| 125 | |
| 126 | if (withTag) { |
| 127 | codeLength += tag.encode(os); |
| 128 | } |
| 129 | |
| 130 | return codeLength; |
| 131 | |
| 132 | } |
| 133 | |
| 134 | public int decode(InputStream is) throws IOException { |
| 135 | return decode(is, true); |
| 136 | } |
| 137 | |
| 138 | public int decode(InputStream is, boolean withTag) throws IOException { |
| 139 | int codeLength = 0; |
| 140 | int subCodeLength = 0; |
| 141 | BerTag berTag = new BerTag(); |
| 142 | |
| 143 | if (withTag) { |
| 144 | codeLength += tag.decodeAndCheck(is); |
| 145 | } |
| 146 | |
| 147 | BerLength length = new BerLength(); |
| 148 | codeLength += length.decode(is); |
| 149 | |
| 150 | int totalLength = length.val; |
| 151 | codeLength += totalLength; |
| 152 | |
| 153 | subCodeLength += berTag.decode(is); |
| 154 | if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) { |
| 155 | crnti = new CRNTI(); |
| 156 | subCodeLength += crnti.decode(is, false); |
| 157 | subCodeLength += berTag.decode(is); |
| 158 | } |
| 159 | else { |
| 160 | throw new IOException("Tag does not match the mandatory sequence element tag."); |
| 161 | } |
| 162 | |
| 163 | if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) { |
| 164 | ecgi = new ECGI(); |
| 165 | subCodeLength += ecgi.decode(is, false); |
| 166 | subCodeLength += berTag.decode(is); |
| 167 | } |
| 168 | else { |
| 169 | throw new IOException("Tag does not match the mandatory sequence element tag."); |
| 170 | } |
| 171 | |
| 172 | if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) { |
| 173 | ueAmbr = new UEAMBR(); |
| 174 | subCodeLength += ueAmbr.decode(is, false); |
| 175 | subCodeLength += berTag.decode(is); |
| 176 | } |
| 177 | else { |
| 178 | throw new IOException("Tag does not match the mandatory sequence element tag."); |
| 179 | } |
| 180 | |
| 181 | if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 3)) { |
| 182 | numErabs = new BerInteger(); |
| 183 | subCodeLength += numErabs.decode(is, false); |
| 184 | subCodeLength += berTag.decode(is); |
| 185 | } |
| 186 | else { |
| 187 | throw new IOException("Tag does not match the mandatory sequence element tag."); |
| 188 | } |
| 189 | |
| 190 | if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 4)) { |
| 191 | erabParams = new ERABParams(); |
| 192 | subCodeLength += erabParams.decode(is, false); |
| 193 | if (subCodeLength == totalLength) { |
| 194 | return codeLength; |
| 195 | } |
| 196 | } |
| 197 | throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength); |
| 198 | |
| 199 | |
| 200 | } |
| 201 | |
| 202 | public void encodeAndSave(int encodingSizeGuess) throws IOException { |
| 203 | BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess); |
| 204 | encode(os, false); |
| 205 | code = os.getArray(); |
| 206 | } |
| 207 | |
| 208 | public String toString() { |
| 209 | StringBuilder sb = new StringBuilder(); |
| 210 | appendAsString(sb, 0); |
| 211 | return sb.toString(); |
| 212 | } |
| 213 | |
| 214 | public void appendAsString(StringBuilder sb, int indentLevel) { |
| 215 | |
| 216 | sb.append("{"); |
| 217 | sb.append("\n"); |
| 218 | for (int i = 0; i < indentLevel + 1; i++) { |
| 219 | sb.append("\t"); |
| 220 | } |
| 221 | if (crnti != null) { |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 222 | sb.append("crnti: ").append(crnti); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 223 | } |
| 224 | |
| 225 | sb.append(",\n"); |
| 226 | for (int i = 0; i < indentLevel + 1; i++) { |
| 227 | sb.append("\t"); |
| 228 | } |
| 229 | if (ecgi != null) { |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 230 | sb.append("ecgi: "); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 231 | ecgi.appendAsString(sb, indentLevel + 1); |
| 232 | } |
| 233 | |
| 234 | sb.append(",\n"); |
| 235 | for (int i = 0; i < indentLevel + 1; i++) { |
| 236 | sb.append("\t"); |
| 237 | } |
| 238 | if (ueAmbr != null) { |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 239 | sb.append("ueAmbr: "); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 240 | ueAmbr.appendAsString(sb, indentLevel + 1); |
| 241 | } |
| 242 | |
| 243 | sb.append(",\n"); |
| 244 | for (int i = 0; i < indentLevel + 1; i++) { |
| 245 | sb.append("\t"); |
| 246 | } |
| 247 | if (numErabs != null) { |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 248 | sb.append("numErabs: ").append(numErabs); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 249 | } |
| 250 | |
| 251 | sb.append(",\n"); |
| 252 | for (int i = 0; i < indentLevel + 1; i++) { |
| 253 | sb.append("\t"); |
| 254 | } |
| 255 | if (erabParams != null) { |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 256 | sb.append("erabParams: "); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 257 | erabParams.appendAsString(sb, indentLevel + 1); |
| 258 | } |
| 259 | |
| 260 | sb.append("\n"); |
| 261 | for (int i = 0; i < indentLevel; i++) { |
| 262 | sb.append("\t"); |
| 263 | } |
| 264 | sb.append("}"); |
| 265 | } |
| 266 | |
| 267 | } |
| 268 | |