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; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 11 | import org.onosproject.xran.codecs.api.CRNTI; |
| 12 | import org.onosproject.xran.codecs.api.ECGI; |
| 13 | import org.onosproject.xran.codecs.api.ReconfIndReason; |
| 14 | |
| 15 | import java.io.IOException; |
| 16 | import java.io.InputStream; |
| 17 | import java.io.Serializable; |
| 18 | |
| 19 | public class UEReconfigInd implements Serializable { |
| 20 | |
| 21 | private static final long serialVersionUID = 1L; |
| 22 | |
| 23 | public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16); |
| 24 | |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame^] | 25 | @JsonIgnore |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 26 | public byte[] code = null; |
| 27 | private CRNTI crntiOld = null; |
| 28 | private ECGI ecgi = null; |
| 29 | private CRNTI crntiNew = null; |
| 30 | private ReconfIndReason reconfigCause = null; |
| 31 | |
| 32 | public UEReconfigInd() { |
| 33 | } |
| 34 | |
| 35 | public UEReconfigInd(byte[] code) { |
| 36 | this.code = code; |
| 37 | } |
| 38 | |
| 39 | public void setCrntiOld(CRNTI crntiOld) { |
| 40 | this.crntiOld = crntiOld; |
| 41 | } |
| 42 | |
| 43 | public CRNTI getCrntiOld() { |
| 44 | return crntiOld; |
| 45 | } |
| 46 | |
| 47 | public void setEcgi(ECGI ecgi) { |
| 48 | this.ecgi = ecgi; |
| 49 | } |
| 50 | |
| 51 | public ECGI getEcgi() { |
| 52 | return ecgi; |
| 53 | } |
| 54 | |
| 55 | public void setCrntiNew(CRNTI crntiNew) { |
| 56 | this.crntiNew = crntiNew; |
| 57 | } |
| 58 | |
| 59 | public CRNTI getCrntiNew() { |
| 60 | return crntiNew; |
| 61 | } |
| 62 | |
| 63 | public void setReconfigCause(ReconfIndReason reconfigCause) { |
| 64 | this.reconfigCause = reconfigCause; |
| 65 | } |
| 66 | |
| 67 | public ReconfIndReason getReconfigCause() { |
| 68 | return reconfigCause; |
| 69 | } |
| 70 | |
| 71 | public int encode(BerByteArrayOutputStream os) throws IOException { |
| 72 | return encode(os, true); |
| 73 | } |
| 74 | |
| 75 | public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException { |
| 76 | |
| 77 | if (code != null) { |
| 78 | for (int i = code.length - 1; i >= 0; i--) { |
| 79 | os.write(code[i]); |
| 80 | } |
| 81 | if (withTag) { |
| 82 | return tag.encode(os) + code.length; |
| 83 | } |
| 84 | return code.length; |
| 85 | } |
| 86 | |
| 87 | int codeLength = 0; |
| 88 | codeLength += reconfigCause.encode(os, false); |
| 89 | // write tag: CONTEXT_CLASS, PRIMITIVE, 3 |
| 90 | os.write(0x83); |
| 91 | codeLength += 1; |
| 92 | |
| 93 | codeLength += crntiNew.encode(os, false); |
| 94 | // write tag: CONTEXT_CLASS, PRIMITIVE, 2 |
| 95 | os.write(0x82); |
| 96 | codeLength += 1; |
| 97 | |
| 98 | codeLength += ecgi.encode(os, false); |
| 99 | // write tag: CONTEXT_CLASS, CONSTRUCTED, 1 |
| 100 | os.write(0xA1); |
| 101 | codeLength += 1; |
| 102 | |
| 103 | codeLength += crntiOld.encode(os, false); |
| 104 | // write tag: CONTEXT_CLASS, PRIMITIVE, 0 |
| 105 | os.write(0x80); |
| 106 | codeLength += 1; |
| 107 | |
| 108 | codeLength += BerLength.encodeLength(os, codeLength); |
| 109 | |
| 110 | if (withTag) { |
| 111 | codeLength += tag.encode(os); |
| 112 | } |
| 113 | |
| 114 | return codeLength; |
| 115 | |
| 116 | } |
| 117 | |
| 118 | public int decode(InputStream is) throws IOException { |
| 119 | return decode(is, true); |
| 120 | } |
| 121 | |
| 122 | public int decode(InputStream is, boolean withTag) throws IOException { |
| 123 | int codeLength = 0; |
| 124 | int subCodeLength = 0; |
| 125 | BerTag berTag = new BerTag(); |
| 126 | |
| 127 | if (withTag) { |
| 128 | codeLength += tag.decodeAndCheck(is); |
| 129 | } |
| 130 | |
| 131 | BerLength length = new BerLength(); |
| 132 | codeLength += length.decode(is); |
| 133 | |
| 134 | int totalLength = length.val; |
| 135 | codeLength += totalLength; |
| 136 | |
| 137 | subCodeLength += berTag.decode(is); |
| 138 | if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) { |
| 139 | crntiOld = new CRNTI(); |
| 140 | subCodeLength += crntiOld.decode(is, false); |
| 141 | subCodeLength += berTag.decode(is); |
| 142 | } |
| 143 | else { |
| 144 | throw new IOException("Tag does not match the mandatory sequence element tag."); |
| 145 | } |
| 146 | |
| 147 | if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) { |
| 148 | ecgi = new ECGI(); |
| 149 | subCodeLength += ecgi.decode(is, false); |
| 150 | subCodeLength += berTag.decode(is); |
| 151 | } |
| 152 | else { |
| 153 | throw new IOException("Tag does not match the mandatory sequence element tag."); |
| 154 | } |
| 155 | |
| 156 | if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 2)) { |
| 157 | crntiNew = new CRNTI(); |
| 158 | subCodeLength += crntiNew.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 | } |
| 164 | |
| 165 | if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 3)) { |
| 166 | reconfigCause = new ReconfIndReason(); |
| 167 | subCodeLength += reconfigCause.decode(is, false); |
| 168 | if (subCodeLength == totalLength) { |
| 169 | return codeLength; |
| 170 | } |
| 171 | } |
| 172 | throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength); |
| 173 | |
| 174 | |
| 175 | } |
| 176 | |
| 177 | public void encodeAndSave(int encodingSizeGuess) throws IOException { |
| 178 | BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess); |
| 179 | encode(os, false); |
| 180 | code = os.getArray(); |
| 181 | } |
| 182 | |
| 183 | public String toString() { |
| 184 | StringBuilder sb = new StringBuilder(); |
| 185 | appendAsString(sb, 0); |
| 186 | return sb.toString(); |
| 187 | } |
| 188 | |
| 189 | public void appendAsString(StringBuilder sb, int indentLevel) { |
| 190 | |
| 191 | sb.append("{"); |
| 192 | sb.append("\n"); |
| 193 | for (int i = 0; i < indentLevel + 1; i++) { |
| 194 | sb.append("\t"); |
| 195 | } |
| 196 | if (crntiOld != null) { |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame^] | 197 | sb.append("crntiOld: ").append(crntiOld); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 198 | } |
| 199 | |
| 200 | sb.append(",\n"); |
| 201 | for (int i = 0; i < indentLevel + 1; i++) { |
| 202 | sb.append("\t"); |
| 203 | } |
| 204 | if (ecgi != null) { |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame^] | 205 | sb.append("ecgi: "); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 206 | ecgi.appendAsString(sb, indentLevel + 1); |
| 207 | } |
| 208 | |
| 209 | sb.append(",\n"); |
| 210 | for (int i = 0; i < indentLevel + 1; i++) { |
| 211 | sb.append("\t"); |
| 212 | } |
| 213 | if (crntiNew != null) { |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame^] | 214 | sb.append("crntiNew: ").append(crntiNew); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 215 | } |
| 216 | |
| 217 | sb.append(",\n"); |
| 218 | for (int i = 0; i < indentLevel + 1; i++) { |
| 219 | sb.append("\t"); |
| 220 | } |
| 221 | if (reconfigCause != null) { |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame^] | 222 | sb.append("reconfigCause: ").append(reconfigCause); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 223 | } |
| 224 | |
| 225 | sb.append("\n"); |
| 226 | for (int i = 0; i < indentLevel; i++) { |
| 227 | sb.append("\t"); |
| 228 | } |
| 229 | sb.append("}"); |
| 230 | } |
| 231 | |
| 232 | } |
| 233 | |