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