slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1 | package org.onosproject.xran.samplemessages; |
| 2 | |
| 3 | import org.onosproject.xran.codecs.api.AdmEstResponse; |
| 4 | import org.onosproject.xran.codecs.api.CRNTI; |
| 5 | import org.onosproject.xran.codecs.api.ECGI; |
| 6 | import org.onosproject.xran.codecs.pdu.*; |
| 7 | import org.openmuc.jasn1.ber.BerByteArrayOutputStream; |
| 8 | import org.openmuc.jasn1.ber.types.string.BerUTF8String; |
| 9 | |
| 10 | import java.io.UnsupportedEncodingException; |
| 11 | |
| 12 | public class UEAdmEncoderDecoder { |
| 13 | |
| 14 | private int flag; |
| 15 | private BerByteArrayOutputStream os; |
| 16 | private XrancPdu pdu; |
| 17 | |
| 18 | public UEAdmEncoderDecoder() { |
| 19 | os = new BerByteArrayOutputStream(4096); |
| 20 | } |
| 21 | |
| 22 | public static XrancPdu constructPacket(ECGI ecgi, CRNTI crnti) { |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame^] | 23 | AdmEstResponse response = new AdmEstResponse(0); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 24 | |
| 25 | UEAdmissionResponse ueAdmissionResponse = new UEAdmissionResponse(); |
| 26 | ueAdmissionResponse.setCrnti(crnti); |
| 27 | ueAdmissionResponse.setEcgi(ecgi); |
| 28 | ueAdmissionResponse.setAdmEstResponse(response); |
| 29 | |
| 30 | XrancPduBody body = new XrancPduBody(); |
| 31 | body.setUEAdmissionResponse(ueAdmissionResponse); |
| 32 | |
| 33 | BerUTF8String ver = null; |
| 34 | try { |
| 35 | ver = new BerUTF8String("4"); |
| 36 | } catch (UnsupportedEncodingException e) { |
| 37 | e.printStackTrace(); |
| 38 | } |
| 39 | XrancApiID apiID = new XrancApiID(3); |
| 40 | XrancPduHdr hdr = new XrancPduHdr(); |
| 41 | hdr.setVer(ver); |
| 42 | hdr.setApiId(apiID); |
| 43 | |
| 44 | XrancPdu pdu = new XrancPdu(); |
| 45 | pdu.setHdr(hdr); |
| 46 | pdu.setBody(body); |
| 47 | return pdu; |
| 48 | } |
| 49 | |
| 50 | public XrancPdu setPacketProperties(UEAdmissionRequest pdu_decoded) { |
| 51 | /*XrancPdu pdu_decoded = new XrancPdu(); |
| 52 | byte[] bytearray = DatatypeConverter.parseHexBinary(decodedString); |
| 53 | InputStream inputStream = new ByteArrayInputStream(bytearray); |
| 54 | try { |
| 55 | pdu_decoded.decode(inputStream); |
| 56 | } catch (IOException e) { |
| 57 | e.printStackTrace(); |
| 58 | }*/ |
| 59 | CRNTI crnti = pdu_decoded.getCrnti(); |
| 60 | ECGI ecgi = pdu_decoded.getEcgi(); |
| 61 | |
| 62 | AdmEstResponse response = new AdmEstResponse(1); |
| 63 | /*if (flag == 1) { |
| 64 | response = new AdmEstResponse(0); |
| 65 | } else { |
| 66 | response = new AdmEstResponse(1); |
| 67 | }*/ |
| 68 | |
| 69 | UEAdmissionResponse ueAdmissionResponse = new UEAdmissionResponse(); |
| 70 | ueAdmissionResponse.setCrnti(crnti); |
| 71 | ueAdmissionResponse.setEcgi(ecgi); |
| 72 | ueAdmissionResponse.setAdmEstResponse(response); |
| 73 | |
| 74 | XrancPduBody body = new XrancPduBody(); |
| 75 | body.setUEAdmissionResponse(ueAdmissionResponse); |
| 76 | |
| 77 | BerUTF8String ver = null; |
| 78 | try { |
| 79 | ver = new BerUTF8String("4"); |
| 80 | } catch (UnsupportedEncodingException e) { |
| 81 | e.printStackTrace(); |
| 82 | } |
| 83 | XrancApiID apiID = new XrancApiID(3); |
| 84 | XrancPduHdr hdr = new XrancPduHdr(); |
| 85 | hdr.setVer(ver); |
| 86 | hdr.setApiId(apiID); |
| 87 | |
| 88 | XrancPdu pdu = new XrancPdu(); |
| 89 | pdu.setHdr(hdr); |
| 90 | pdu.setBody(body); |
| 91 | return pdu; |
| 92 | |
| 93 | } |
| 94 | |
| 95 | } |