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