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 | package org.onosproject.xran.codecs.pdu; |
| 5 | |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 6 | import com.fasterxml.jackson.annotation.JsonIgnore; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 7 | import org.onosproject.xran.codecs.api.CRNTI; |
| 8 | import org.onosproject.xran.codecs.api.ECGI; |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 9 | import org.onosproject.xran.codecs.ber.BerByteArrayOutputStream; |
| 10 | import org.onosproject.xran.codecs.ber.BerLength; |
| 11 | import org.onosproject.xran.codecs.ber.BerTag; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 12 | |
| 13 | import java.io.IOException; |
| 14 | import java.io.InputStream; |
| 15 | import java.io.Serializable; |
| 16 | |
| 17 | |
| 18 | public class SeNBDelete 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 | |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 24 | @JsonIgnore |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 25 | public byte[] code = null; |
| 26 | private CRNTI crnti = null; |
| 27 | private ECGI mEcgi = null; |
| 28 | private ECGI sEcgi = null; |
| 29 | |
| 30 | public SeNBDelete() { |
| 31 | } |
| 32 | |
| 33 | public SeNBDelete(byte[] code) { |
| 34 | this.code = code; |
| 35 | } |
| 36 | |
| 37 | public void setCrnti(CRNTI crnti) { |
| 38 | this.crnti = crnti; |
| 39 | } |
| 40 | |
| 41 | public CRNTI getCrnti() { |
| 42 | return crnti; |
| 43 | } |
| 44 | |
| 45 | public void setMEcgi(ECGI mEcgi) { |
| 46 | this.mEcgi = mEcgi; |
| 47 | } |
| 48 | |
| 49 | public ECGI getMEcgi() { |
| 50 | return mEcgi; |
| 51 | } |
| 52 | |
| 53 | public void setSEcgi(ECGI sEcgi) { |
| 54 | this.sEcgi = sEcgi; |
| 55 | } |
| 56 | |
| 57 | public ECGI getSEcgi() { |
| 58 | return sEcgi; |
| 59 | } |
| 60 | |
| 61 | public int encode(BerByteArrayOutputStream os) throws IOException { |
| 62 | return encode(os, true); |
| 63 | } |
| 64 | |
| 65 | public int encode(BerByteArrayOutputStream os, boolean withTag) throws IOException { |
| 66 | |
| 67 | if (code != null) { |
| 68 | for (int i = code.length - 1; i >= 0; i--) { |
| 69 | os.write(code[i]); |
| 70 | } |
| 71 | if (withTag) { |
| 72 | return tag.encode(os) + code.length; |
| 73 | } |
| 74 | return code.length; |
| 75 | } |
| 76 | |
| 77 | int codeLength = 0; |
| 78 | codeLength += sEcgi.encode(os, false); |
| 79 | // write tag: CONTEXT_CLASS, CONSTRUCTED, 2 |
| 80 | os.write(0xA2); |
| 81 | codeLength += 1; |
| 82 | |
| 83 | codeLength += mEcgi.encode(os, false); |
| 84 | // write tag: CONTEXT_CLASS, CONSTRUCTED, 1 |
| 85 | os.write(0xA1); |
| 86 | codeLength += 1; |
| 87 | |
| 88 | codeLength += crnti.encode(os, false); |
| 89 | // write tag: CONTEXT_CLASS, PRIMITIVE, 0 |
| 90 | os.write(0x80); |
| 91 | codeLength += 1; |
| 92 | |
| 93 | codeLength += BerLength.encodeLength(os, codeLength); |
| 94 | |
| 95 | if (withTag) { |
| 96 | codeLength += tag.encode(os); |
| 97 | } |
| 98 | |
| 99 | return codeLength; |
| 100 | |
| 101 | } |
| 102 | |
| 103 | public int decode(InputStream is) throws IOException { |
| 104 | return decode(is, true); |
| 105 | } |
| 106 | |
| 107 | public int decode(InputStream is, boolean withTag) throws IOException { |
| 108 | int codeLength = 0; |
| 109 | int subCodeLength = 0; |
| 110 | BerTag berTag = new BerTag(); |
| 111 | |
| 112 | if (withTag) { |
| 113 | codeLength += tag.decodeAndCheck(is); |
| 114 | } |
| 115 | |
| 116 | BerLength length = new BerLength(); |
| 117 | codeLength += length.decode(is); |
| 118 | |
| 119 | int totalLength = length.val; |
| 120 | codeLength += totalLength; |
| 121 | |
| 122 | subCodeLength += berTag.decode(is); |
| 123 | if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) { |
| 124 | crnti = new CRNTI(); |
| 125 | subCodeLength += crnti.decode(is, false); |
| 126 | subCodeLength += berTag.decode(is); |
| 127 | } |
| 128 | else { |
| 129 | throw new IOException("Tag does not match the mandatory sequence element tag."); |
| 130 | } |
| 131 | |
| 132 | if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) { |
| 133 | mEcgi = new ECGI(); |
| 134 | subCodeLength += mEcgi.decode(is, false); |
| 135 | subCodeLength += berTag.decode(is); |
| 136 | } |
| 137 | else { |
| 138 | throw new IOException("Tag does not match the mandatory sequence element tag."); |
| 139 | } |
| 140 | |
| 141 | if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) { |
| 142 | sEcgi = new ECGI(); |
| 143 | subCodeLength += sEcgi.decode(is, false); |
| 144 | if (subCodeLength == totalLength) { |
| 145 | return codeLength; |
| 146 | } |
| 147 | } |
| 148 | throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength); |
| 149 | |
| 150 | |
| 151 | } |
| 152 | |
| 153 | public void encodeAndSave(int encodingSizeGuess) throws IOException { |
| 154 | BerByteArrayOutputStream os = new BerByteArrayOutputStream(encodingSizeGuess); |
| 155 | encode(os, false); |
| 156 | code = os.getArray(); |
| 157 | } |
| 158 | |
| 159 | public String toString() { |
| 160 | StringBuilder sb = new StringBuilder(); |
| 161 | appendAsString(sb, 0); |
| 162 | return sb.toString(); |
| 163 | } |
| 164 | |
| 165 | public void appendAsString(StringBuilder sb, int indentLevel) { |
| 166 | |
| 167 | sb.append("{"); |
| 168 | sb.append("\n"); |
| 169 | for (int i = 0; i < indentLevel + 1; i++) { |
| 170 | sb.append("\t"); |
| 171 | } |
| 172 | if (crnti != null) { |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 173 | sb.append("crnti: ").append(crnti); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 174 | } |
| 175 | |
| 176 | sb.append(",\n"); |
| 177 | for (int i = 0; i < indentLevel + 1; i++) { |
| 178 | sb.append("\t"); |
| 179 | } |
| 180 | if (mEcgi != null) { |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 181 | sb.append("mEcgi: "); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 182 | mEcgi.appendAsString(sb, indentLevel + 1); |
| 183 | } |
| 184 | |
| 185 | sb.append(",\n"); |
| 186 | for (int i = 0; i < indentLevel + 1; i++) { |
| 187 | sb.append("\t"); |
| 188 | } |
| 189 | if (sEcgi != null) { |
slowr | 60d4d10 | 2017-08-16 18:33:58 -0700 | [diff] [blame] | 190 | sb.append("sEcgi: "); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 191 | sEcgi.appendAsString(sb, indentLevel + 1); |
| 192 | } |
| 193 | |
| 194 | sb.append("\n"); |
| 195 | for (int i = 0; i < indentLevel; i++) { |
| 196 | sb.append("\t"); |
| 197 | } |
| 198 | sb.append("}"); |
| 199 | } |
| 200 | |
| 201 | } |
| 202 | |