This sample is provided as part of the OSS ASN.1 Tools trial and commercial shipments. The source code and related files are listed below for reference.
The sample demonstrates how to use the OSS ASN.1 Tools to process messages for the 3GPP 5G XnAP standard (TS 38.423 version 19.0.0).
It runs on Linux on x86-64 as an example and illustrates how to decode, inspect, and create PER-encoded 5G XnAP messages using the OSS ASN.1 Tools API.
The sample reads XnAP messages from .per files, decodes and prints them, and creates and encodes a response message.
A Unix shell script (run.sh) is included for running the test program using the OSS ASN.1/Java runtime.
To explore more samples (LTE RRC, 5G RRC, S1AP, X2AP, XnAP), visit the main Sample Code page.
This sample shows how to:
The files listed below are included in the OSS ASN.1 Tools trial and commercial shipments and are used by this sample program:
| File | Description |
|---|---|
| README.TXT | Instructions and sample overview. |
| *.asn | ASN.1 source files that describe the 3GPP 5G XnAP protocol (TS 38.423) used with this program example. |
| XNAP-PDU_HandoverRequest_bin.per | Valid PER-encoded XnAP message. It should pass testing. |
| Txnap.java | Simple Java program that shows how to work with 5G XnAP protocol data. It reads input messages from files, decodes and prints them, and creates and encodes a response message. |
| xnap.cmd | ASN.1 compiler command file used to ASN.1 compile the XnAP protocol specifications. |
| run.sh | Unix shell script to run the test. |
| sample.out | Expected output from this test. |
| gui/ | ASN.1 Studio project for viewing/compiling schema and generating sample data. |
(Installation instructions for the OSS ASN.1 Tools are included in all trial and commercial shipments.)
To build and run this sample, install a trial or licensed version of the OSS ASN.1 Tools for Java.
Before running the test, ensure the following are set appropriately:
./run.sh
./run.sh cleanup
Note: The Java source code in this sample is platform-independent. Linux commands are shown as an example, but equivalent samples and build instructions are available for Windows, macOS, and other platforms. For help with platform-specific instructions, please contact OSS Support.
The following listing shows the main Java source file for this sample test program, Txnap.java. It demonstrates how to read PER-encoded 5G XnAP messages from files, decode and print them, and create and encode a response message using the OSS ASN.1 Tools API.
/*****************************************************************************/
/* Copyright (C) ###RELEASE_YEAR### OSS Nokalva, Inc. All rights reserved. */
/*****************************************************************************/
/* THIS FILE IS PROPRIETARY MATERIAL OF OSS NOKALVA, INC. */
/* AND MAY BE USED ONLY BY DIRECT LICENSEES OF OSS NOKALVA, INC. */
/* THIS FILE MAY NOT BE DISTRIBUTED. */
/* THIS COPYRIGHT STATEMENT MAY NOT BE REMOVED. */
/*****************************************************************************/
/* THIS SAMPLE PROGRAM IS PROVIDED AS IS. THE SAMPLE PROGRAM AND ANY RESULTS */
/* OBTAINED FROM IT ARE PROVIDED WITHOUT ANY WARRANTIES OR REPRESENTATIONS, */
/* EXPRESS, IMPLIED OR STATUTORY. */
/*****************************************************************************/
/*
* Demonstrates work with data for 5G XnAP protocol
*/
import java.io.*;
import com.oss.asn1.*;
import com.oss.util.*;
import xnap.*;
import xnap.oss_xnap_xnap_commondatatypes.*;
import xnap.oss_xnap_xnap_constants.*;
import xnap.oss_xnap_xnap_containers.*;
import xnap.oss_xnap_xnap_ies.*;
import xnap.oss_xnap_xnap_pdu_contents.*;
import xnap.oss_xnap_xnap_pdu_descriptions.*;
public class Txnap {
static Coder coder;
static String border = "-------------------------------------------------------";
/* Names of Criticality values */
static String[] Criticalities = { "reject", "ignore", "notify" };
/*
* Deserializes and prints input messages, creates and prints successful
* outcome messages
*/
public static void main(String[] args) throws java.io.FileNotFoundException, Exception
{
// Initialize the project
try {
Xnap.initialize();
} catch (Exception e) {
System.out.println("Initialization exception: " + e);
System.exit(1);
}
coder = Xnap.getPERAlignedCoder();
coder.enableAutomaticEncoding();
coder.enableAutomaticDecoding();
coder.enableEncoderDebugging();
coder.enableDecoderDebugging();
// An optional parameter includes the path to all the files that are used by
// the program.
String path = (args.length > 0) ? args[0] : null;
try {
testXNAP(path, "XNAP-PDU_HandoverRequest.per");
} catch (Exception e) {
System.out.println(e);
System.exit(1);
}
System.out.println("\nTesting successful");
}
/*
* testXNAP() is used to test XnAP message, the input serialized pdu is
* deserialized and printed, then an outcome message is created, printed
* and encoded.
*/
static void testXNAP(String path, String filename) throws IOException, Exception
{
OSS_XNAP_PDU request;
File file = new File(path, filename);
if (!file.exists()) {
throw new IOException("Failed to open the " + file.toString() + " file. " +
"Restart the sample program using as input parameter the name of the directory " +
"where the '" + file.getName() + "' file is located.\n");
}
FileInputStream source = new FileInputStream(file);
System.out.println("============================================================================");
/* Read serialized message from file */
System.out.println("Read encoding from file: " + filename + "\n");
System.out.println("Deserialize request");
System.out.println(border);
/* Deserialize input message */
request = (OSS_XNAP_PDU)coder.decode(source, new OSS_XNAP_PDU());
source.close();
System.out.println("\nDeserialized request");
System.out.println(border);
System.out.println(request);
/* Parse and print input message */
printHandoverRequiredMsg(request);
/* Create successful outcome message */
OSS_XNAP_PDU response = createSuccessResponse(request);
/* Print outcome message */
System.out.println(response);
System.out.println("Serialize response");
System.out.println(border);
/* Serialize outcome message */
ByteArrayOutputStream out = new ByteArrayOutputStream();
try {
coder.encode(response, out);
} catch (Exception e) {
System.out.println("Encoding failed: " + e);
System.exit(1);
}
/* Print serialized outcome message */
System.out.println("\nSerialized response "
+ "(" + out.size() + " bytes):");
System.out.println(HexTool.getHex(out.toByteArray()));
}
/*
* Prints XnAP pdu which contains HandoverRequired message. The
* function is not intended to handle other types of messages.
*/
static void printHandoverRequiredMsg(OSS_XNAP_PDU pdu) throws Exception
{
OSS_XNAP_HandoverRequest hr_value;
System.out.println("\nGet message information");
System.out.println(border);
/* Get identifier of message stored in PDU */
if (!pdu.hasInitiatingMessage())
throw new Exception("Unexpected type of message");
OpenType msg_value = ((OSS_XNAP_InitiatingMessage)pdu.getChosenValue()).getValue();
if (msg_value.getDecodedValue() != null) {
if (msg_value.getDecodedValue() instanceof OSS_XNAP_HandoverRequest)
hr_value = (OSS_XNAP_HandoverRequest)msg_value.getDecodedValue();
else
throw new Exception("Incorrect message");
} else
throw new Exception("Incorrect message");
System.out.println("Message type is HandoverRequest\n");
if (hr_value.getProtocolIEs() == null)
throw new Exception("Incorrect message");
printProtocolIEs(hr_value.getProtocolIEs(), 0);
}
/*
* Creates XnAP successful outcome message for given
* HandoverRequired request.
*/
static OSS_XNAP_PDU createSuccessResponse(OSS_XNAP_PDU request) throws Exception
{
if (!request.hasInitiatingMessage())
throw new Exception("Unexpected type of message");
OpenType msg_value = ((OSS_XNAP_InitiatingMessage)
request.getChosenValue()).getValue();
OSS_XNAP_HandoverRequest hr_value =
(OSS_XNAP_HandoverRequest)msg_value.getDecodedValue();
if (hr_value == null || msg_value.getEncodedValue() != null)
throw new Exception("Unexpected HandoverRequired request data");
if (hr_value.getProtocolIEs() == null || hr_value.getProtocolIEs().getSize() == 0)
throw new Exception("No IEs in HandoverRequired request");
OSS_XNAP_HandoverRequest.OSS_XNAP_HRequestIEs reqies = hr_value.getProtocolIEs();
System.out.println("Create response");
System.out.println(border);
/*
* Create successful outcome message from initiating message. Copy
* some IEs from input to output.
*/
OSS_XNAP_HandoverRequestAcknowledge.OSS_XNAP_HAcknowledgeIEs respies = new OSS_XNAP_HandoverRequestAcknowledge.OSS_XNAP_HAcknowledgeIEs();
OSS_XNAP_ProtocolIE_Field element;
for (int i = 0; i < reqies.getSize(); i++) {
if (reqies.get(i).getId().equalTo(
OSS_XNAP_XnAP_Constants.OSS_XNAP_id_sourceNG_RANnodeUEXnAPID)) {
element = (OSS_XNAP_ProtocolIE_Field)reqies.get(i).clone();
element.setCriticality(OSS_XNAP_Criticality.ignore);
respies.add(element);
}
}
/* Add IE with OSS_XNAP_id_targetNG_RANnodeUEXnAPID to outcome message */
element = new OSS_XNAP_ProtocolIE_Field(
OSS_XNAP_XnAP_Constants.OSS_XNAP_id_targetNG_RANnodeUEXnAPID,
OSS_XNAP_Criticality.ignore,
new OpenType(new OSS_XNAP_NG_RANnodeUEXnAPID(456)));
respies.add(element);
OSS_XNAP_QoSFlowsAdmitted_List qosFlowsAdmitted_List =
new OSS_XNAP_QoSFlowsAdmitted_List(
new OSS_XNAP_QoSFlowsAdmitted_Item[]{
new OSS_XNAP_QoSFlowsAdmitted_Item(new OSS_XNAP_QoSFlowIdentifier(3)),
new OSS_XNAP_QoSFlowsAdmitted_Item(new OSS_XNAP_QoSFlowIdentifier(4))
}
);
OSS_XNAP_QoSFlows_List_withCause qosFlowsNotAdmitted_List =
new OSS_XNAP_QoSFlows_List_withCause(
new OSS_XNAP_QoSFlowwithCause_Item[]{
new OSS_XNAP_QoSFlowwithCause_Item(
new OSS_XNAP_QoSFlowIdentifier(2),
OSS_XNAP_Cause.createOSS_XNAP_CauseWithMisc(OSS_XNAP_CauseMisc.unspecified),
null
),
new OSS_XNAP_QoSFlowwithCause_Item(
new OSS_XNAP_QoSFlowIdentifier(5),
OSS_XNAP_Cause.createOSS_XNAP_CauseWithMisc(OSS_XNAP_CauseMisc.unspecified),
null
)
}
);
OSS_XNAP_PDUSessionResourcesAdmitted_List pduSessionResourcesAdmittedList =
new OSS_XNAP_PDUSessionResourcesAdmitted_List(
new OSS_XNAP_PDUSessionResourcesAdmitted_Item[] {
new OSS_XNAP_PDUSessionResourcesAdmitted_Item(
new OSS_XNAP_PDUSession_ID(1),
new OSS_XNAP_PDUSessionResourceAdmittedInfo(
null,
qosFlowsAdmitted_List,
qosFlowsNotAdmitted_List,
null,
null
)
)
}
);
element = new OSS_XNAP_ProtocolIE_Field(
OSS_XNAP_XnAP_Constants.OSS_XNAP_id_PDUSessionResourcesAdmitted_List,
OSS_XNAP_Criticality.ignore,
new OpenType(pduSessionResourcesAdmittedList));
respies.add(element);
OSS_XNAP_Criticality criticality;
OSS_XNAP_ProcedureCode procedureCode = ((OSS_XNAP_InitiatingMessage)
request.getChosenValue()).getProcedureCode();
criticality = OSS_XNAP_Criticality.reject;
OSS_XNAP_HandoverRequestAcknowledge handoverRequest =
new OSS_XNAP_HandoverRequestAcknowledge(respies);
OSS_XNAP_SuccessfulOutcome successfulOutcome =
new OSS_XNAP_SuccessfulOutcome(
procedureCode, criticality, new OpenType(handoverRequest));
OSS_XNAP_PDU response =
OSS_XNAP_PDU.createOSS_XNAP_PDUWithSuccessfulOutcome(successfulOutcome);
return response;
}
/*
* Prints ProtocolIE_Container data.
*/
static void printProtocolIEs(OSS_XNAP_HandoverRequest.OSS_XNAP_HRequestIEs ies, int indent)
{
System.out.println("protocolIEs includes the following IEs:\n");
indent++;
/* Print each IE */
for (int i = 0; i < ies.getSize(); i++) {
OSS_XNAP_ProtocolIE_Field field =
(OSS_XNAP_ProtocolIE_Field )ies.get(i).clone();
OpenType value = field.getValue();
long fieldId = field.getId().longValue();
printIndent(indent++);
System.out.println("#" + (i + 1) + ": id = " + fieldId +
", criticality = " + Criticalities[(int)field.getCriticality().longValue()]);
/* Print NG-RANnodeUEXnAPID IE */
printIndent(indent);
if (field.getId().equalTo(OSS_XNAP_XnAP_Constants.OSS_XNAP_id_sourceNG_RANnodeUEXnAPID)) {
System.out.println("value NG-RANnodeUEXnAPID: " +
((OSS_XNAP_NG_RANnodeUEXnAPID)value.getDecodedValue()).longValue());
/* Cause IE */
} else if (field.getId().equalTo(OSS_XNAP_XnAP_Constants.OSS_XNAP_id_Cause)) {
OSS_XNAP_Cause pcause = (OSS_XNAP_Cause)value.getDecodedValue();
/*
* Named values can be printed below instead of numbers for all
* Cause components
*/
System.out.print("value Cause: ");
/* radioNetwork */
if (pcause.hasRadioNetwork())
System.out.println("radioNetwork: " +
((OSS_XNAP_CauseRadioNetworkLayer)pcause.getChosenValue()).longValue());
/* transport */
else if (pcause.hasTransport())
System.out.println("transport: " +
((OSS_XNAP_CauseTransportLayer)pcause.getChosenValue()).longValue());
/* protocol */
else if (pcause.hasProtocol())
System.out.println("protocol: " +
((OSS_XNAP_CauseProtocol)pcause.getChosenValue()).longValue());
/* misc */
else if (pcause.hasMisc())
System.out.println("misc: " +
((OSS_XNAP_CauseMisc)pcause.getChosenValue()).longValue());
else if (pcause.hasChoice_extension())
System.out.println("choice-extension -- Not implemented --");
/* Target-CGI IE */
} else if (field.getId().equalTo(OSS_XNAP_XnAP_Constants.OSS_XNAP_id_targetCellGlobalID)) {
OSS_XNAP_Target_CGI ptarget = (OSS_XNAP_Target_CGI)value.getDecodedValue();
System.out.print("value Target-CGI : ");
indent++;
/* Nr-CGI */
if (ptarget.hasNr()) {
OSS_XNAP_NR_CGI targetNR_CGI =
(OSS_XNAP_NR_CGI)ptarget.getChosenValue();
printDataWithIndent(indent, "nr:");
indent++;
printDataWithIndent(indent, "plmn-id: " +
toHstring(targetNR_CGI.getPlmn_id().byteArrayValue()));
printDataWithIndent(indent, "nr-CI: " +
toHstring(targetNR_CGI.getNr_CI().byteArrayValue()));
indent--;
/* iE_Extension is optional */
if (targetNR_CGI.hasIE_Extension())
printProtocolExtensions(
targetNR_CGI.getIE_Extension(), indent);
indent--;
/* e-utra */
} else if (ptarget.hasE_utra()) {
OSS_XNAP_E_UTRA_CGI eUtra =
(OSS_XNAP_E_UTRA_CGI)ptarget.getChosenValue();
System.out.println("e-utra :");
/* plmn-id */
printDataWithIndent(indent, "plmn-id: ");
indent++;
/* e-utra-CI */
printDataWithIndent(indent, "e-utra-CI: ");
if (eUtra.hasIE_Extension())
printProtocolExtensions(
eUtra.getIE_Extension(), indent);
indent--;
/* choice-extension */
} else if (ptarget.hasChoice_extension()) {
System.out.println("choice-extension -- Not implemented --");
}
/* GUAMI IE */
} else if (field.getId().equalTo(OSS_XNAP_XnAP_Constants.OSS_XNAP_id_GUAMI)) {
OSS_XNAP_GUAMI guamiValue = (OSS_XNAP_GUAMI)value.getDecodedValue();
System.out.println("value GUAMI:");
indent++;
printDataWithIndent(indent, "plmn-ID: " +
toHstring(guamiValue.getPlmn_ID().byteArrayValue()));
printDataWithIndent(indent, "amf-region-if: " +
toHstring(guamiValue.getAmf_region_id().byteArrayValue()));
printDataWithIndent(indent, "amf-set-id: " +
toHstring(guamiValue.getAmf_set_id().byteArrayValue()));
printDataWithIndent(indent, "amf-pointer: " +
toHstring(guamiValue.getAmf_pointer().byteArrayValue()));
/* iE_Extension is optional */
if (guamiValue.hasIE_Extensions())
printProtocolExtensions(guamiValue.getIE_Extensions(), indent);
indent--;
/* UEContextInfoHORequest */
} else if (field.getId().equalTo(OSS_XNAP_XnAP_Constants.OSS_XNAP_id_UEContextInfoHORequest)) {
OSS_XNAP_UEContextInfoHORequest reqValue = (OSS_XNAP_UEContextInfoHORequest)value.getDecodedValue();
System.out.println("value UEContextInfoHORequest:");
indent++;
/* ng-c-UE-reference */
printDataWithIndent(indent, "ng-c-UE-reference: " +
reqValue.getNg_c_UE_reference().longValue());
/* cp-TNL-info-source */
printDataWithIndent(indent, "cp-TNL-info-source: ");
if (reqValue.getCp_TNL_info_source().hasEndpointIPAddress())
printDataWithIndent(indent + 1, "endpointIPAddress: " +
toHstring(reqValue.getCp_TNL_info_source().getEndpointIPAddress().byteArrayValue()));
else if (reqValue.getCp_TNL_info_source().hasChoice_extension())
System.out.println("choice-Extensions -- Not implemented --");
/* ueSecurityCapabilities */
OSS_XNAP_UESecurityCapabilities secc = reqValue.getUeSecurityCapabilities();
printDataWithIndent(indent, "ueSecurityCapabilities:");
indent++;
printDataWithIndent(indent, "nr-EncyptionAlgorithms: " +
toHstring(secc.getNr_EncyptionAlgorithms().byteArrayValue()));
printDataWithIndent(indent, "nr-IntegrityProtectionAlgorithms: " +
toHstring(secc.getNr_IntegrityProtectionAlgorithms().byteArrayValue()));
printDataWithIndent(indent, "e-utra-EncyptionAlgorithms: " +
toHstring(secc.getE_utra_EncyptionAlgorithms().byteArrayValue()));
printDataWithIndent(indent, "e-utra-IntegrityProtectionAlgorithms: " +
toHstring(secc.getE_utra_IntegrityProtectionAlgorithms().byteArrayValue()));
if (secc.hasIE_Extension())
printProtocolExtensions(secc.getIE_Extension(), indent);
indent--;
/* securityInformation */
printDataWithIndent(indent, "securityInformation: ");
indent++;
printDataWithIndent(indent, "key-NG-RAN-Star: " +
toHstring(reqValue.getSecurityInformation().getKey_NG_RAN_Star().byteArrayValue()));
printDataWithIndent(indent, "ncc: " +
reqValue.getSecurityInformation().getNcc());
if (reqValue.getSecurityInformation().hasIE_Extensions())
printProtocolExtensions(secc.getIE_Extension(), indent);
indent--;
/* indexToRatFrequencySelectionPriority */
if (reqValue.hasIndexToRatFrequencySelectionPriority())
printDataWithIndent(indent, "indexToRatFrequencySelectionPriority: " +
reqValue.getIndexToRatFrequencySelectionPriority().longValue());
/* ue-AMBR */
printDataWithIndent(indent, "ue-AMBR: ");
indent++;
printDataWithIndent(indent, "dl-UE-AMBR: " +
reqValue.getUe_AMBR().getUl_UE_AMBR().longValue());
printDataWithIndent(indent, "ul-UE-AMBR: " +
reqValue.getUe_AMBR().getDl_UE_AMBR().longValue());
if (reqValue.getUe_AMBR().hasIE_Extension())
printProtocolExtensions(reqValue.getUe_AMBR().getIE_Extension(), indent);
indent--;
/* pduSessionResourcesToBeSetup-List */
printDataWithIndent(indent, "pduSessionResourcesToBeSetup-List: ");
OSS_XNAP_PDUSessionResourcesToBeSetup_List sr_list = reqValue.getPduSessionResourcesToBeSetup_List();
indent++;
for (int j = 0; j < sr_list.getSize(); j++) {
printDataWithIndent(indent, "#" + (j+1) + ":");
indent++;
printDataWithIndent(indent, "pduSessionId: " +
sr_list.get(j).getPduSessionId().longValue());
printDataWithIndent(indent, "s-NSSAI: ");
indent++;
printDataWithIndent(indent, "sst: " +
toHstring(sr_list.get(j).getS_NSSAI().getSst().byteArrayValue()));
if (sr_list.get(j).getS_NSSAI().hasSd())
printDataWithIndent(indent, "sd: " +
toHstring(sr_list.get(j).getS_NSSAI().getSd().byteArrayValue()));
if (sr_list.get(j).getS_NSSAI().hasIE_Extensions())
printProtocolExtensions(sr_list.get(j).getS_NSSAI().getIE_Extensions(), indent);
indent--;
printDataWithIndent(indent, "pduSessionAMBR: ");
indent++;
printDataWithIndent(indent, "downlink-session-AMBR: " +
sr_list.get(j).getPduSessionAMBR().getDownlink_session_AMBR().longValue());
printDataWithIndent(indent, "uplink-session-AMBR: " +
sr_list.get(j).getPduSessionAMBR().getUplink_session_AMBR().longValue());
if (sr_list.get(j).getPduSessionAMBR().hasIE_Extensions())
printProtocolExtensions(sr_list.get(j).getPduSessionAMBR().getIE_Extensions(), indent);
indent--;
printDataWithIndent(indent, "uL-NG-U-TNLatUPF:");
if (sr_list.get(j).getUL_NG_U_TNLatUPF().hasGtpTunnel()) {
indent++;
printDataWithIndent(indent, "gtpTunnel:");
indent++;
printDataWithIndent(indent, "tnl-address: " +
toHstring(sr_list.get(j).getUL_NG_U_TNLatUPF().getGtpTunnel().getTnl_address().byteArrayValue()));
printDataWithIndent(indent, "gtp-teid: " +
toHstring(sr_list.get(j).getUL_NG_U_TNLatUPF().getGtpTunnel().getGtp_teid().byteArrayValue()));
if (sr_list.get(j).getUL_NG_U_TNLatUPF().getGtpTunnel().hasIE_Extensions())
printProtocolExtensions(sr_list.get(j).getUL_NG_U_TNLatUPF().getGtpTunnel().getIE_Extensions(), indent);
indent--;
indent--;
} else if (sr_list.get(j).getUL_NG_U_TNLatUPF().hasChoice_extension())
System.out.println("choice-extension: -- Not implemented --");
if (sr_list.get(j).hasSecurityIndication())
printDataWithIndent(indent, "securityIndication: -- Not implemented --");
printDataWithIndent(indent, "pduSessionType: " +
sr_list.get(j).getPduSessionType().longValue());
printDataWithIndent(indent, "qosFlowsToBeSetup-List:");
OSS_XNAP_QoSFlowsToBeSetup_List qos_list = sr_list.get(j).getQosFlowsToBeSetup_List();
indent++;
for (int k = 0; k < qos_list.getSize(); k++) {
printDataWithIndent(indent, "#" + (k+1) + ":");
indent++;
printDataWithIndent(indent, "gfi: " +
qos_list.get(k).getQfi().longValue());
if (qos_list.get(k).hasE_RAB_ID())
printDataWithIndent(indent, "e-RAB-ID: -- Not implemented --");
printDataWithIndent(indent, "qosFlowLevelQoSParameters: -- Not implemented --");
indent--;
}
indent--;
}
indent--;
indent--;
/* rrc-Context */
printDataWithIndent(indent, "rrc-Context: " +
toHstring(reqValue.getRrc_Context().byteArrayValue()));
/* locationReportingInformation */
if (reqValue.hasLocationReportingInformation())
printDataWithIndent(indent, "locationReportingInformation: -- Not implemented --");
/* mrl */
if (reqValue.hasMrl())
printDataWithIndent(indent, "mrl: -- Not implemented --");
/* iE-Extensions */
if (reqValue.hasIE_Extensions())
printProtocolExtensions(reqValue.getIE_Extensions(), indent);
/* TraceActivation */
} else if (field.getId().equalTo(OSS_XNAP_XnAP_Constants.OSS_XNAP_id_TraceActivation)) {
System.out.println("value TraceActivation: -- Not implemented --");
/* MaskedIMEISV */
} else if (field.getId().equalTo(OSS_XNAP_XnAP_Constants.OSS_XNAP_id_MaskedIMEISV)) {
System.out.println("value MaskedIMEISV: -- Not implemented --");
/* UEHistoryInformation */
} else if (field.getId().equalTo(OSS_XNAP_XnAP_Constants.OSS_XNAP_id_UEHistoryInformation)) {
System.out.println("value UEHistoryInformation: ");
OSS_XNAP_UEHistoryInformation uhi_value = (OSS_XNAP_UEHistoryInformation)value.getDecodedValue();
indent++;
for (int j = 0; j < uhi_value.getSize(); j++) {
if (uhi_value.get(j).hasNG_RAN_Cell())
printDataWithIndent(indent, "#" + (j+1) + " nG-RAN-Cell: " +
toHstring(uhi_value.get(j).getNG_RAN_Cell().byteArrayValue()));
else if (uhi_value.get(j).hasE_UTRAN_Cell())
printDataWithIndent(indent, "#" + (j+1) + " e-UTRAN-Cell: " +
toHstring(uhi_value.get(j).getE_UTRAN_Cell().byteArrayValue()));
else if (uhi_value.get(j).hasUTRAN_Cell())
printDataWithIndent(indent, "#" + (j+1) + " uTRAN-Cell: " +
toHstring(uhi_value.get(j).getUTRAN_Cell().byteArrayValue()));
else if (uhi_value.get(j).hasGERAN_Cell())
printDataWithIndent(indent, "#" + (j+1) + " gERAN-Cell: " +
toHstring(uhi_value.get(j).getGERAN_Cell().byteArrayValue()));
else if (uhi_value.get(j).hasChoice_extension())
System.out.println("choice-extension -- Not implemented --");
}
indent--;
/* other IEs are printed as ASN.1 value notation */
} else if (value.getDecodedValue() != null) {
System.out.print(value.getDecodedValue());
} else
System.out.println("PDU is not decoded");
System.out.println();
indent--;
}
}
/*
* Prints ProtocolExtensionContainer data.
*/
static void printProtocolExtensions(
OSS_XNAP_ProtocolExtensionContainer ie_ext, int indent)
{
printDataWithIndent(indent++, "iE-Extensions includes the following IEs:");
for (int i = 0; i < ie_ext.getSize(); i++) {
OSS_XNAP_ProtocolExtensionField field = ie_ext.get(i);
OpenType value = field.getExtensionValue();
long fieldId = field.getId().longValue();
printIndent(indent++);
System.out.println("#" + (i + 1) + ": id = " + fieldId +
", criticality = " +
Criticalities[(int)field.getCriticality().longValue()]);
if (value.getDecodedValue() != null)
System.out.println(value.getDecodedValue());
else
System.out.println("PDU is not decoded");
}
}
/*
* Helper method. Converts byte[] array to the Hstring format, like '12345'H.
*/
static String toHstring(byte[] value)
{
return "'" + HexTool.getHex(value) + "'H";
}
/*
* Performs indentation.
* @param indentlevel indentation level.
*/
public static void printIndent(int indentlevel)
{
for (int i = 0; i < indentlevel; i++)
System.out.print(' ');
}
/*
* Print indentation with following data.
*/
public static void printDataWithIndent(int indentlevel, Object data)
{
printIndent(indentlevel);
System.out.println(data);
}
}
This is the expected output when running the sample:
Decoded XnAP message: ... Encoding response message... Encoding successful.
-- Excerpt from xnap.asn 3GPP TS 38.423 V19.0.0 (2025-09)
-- **************************************************************
--
-- Elementary Procedure definitions
--
-- **************************************************************
XnAP-PDU-Descriptions {
itu-t (0) identified-organization (4) etsi (0) mobileDomain (0)
ngran-access (22) modules (3) xnap (2) version1 (1) xnap-PDU-Descriptions (0) }
DEFINITIONS AUTOMATIC TAGS ::=
BEGIN
-- **************************************************************
--
-- IE parameter types from other modules.
--
-- **************************************************************
IMPORTS
Criticality,
ProcedureCode
FROM XnAP-CommonDataTypes
HandoverRequest,
HandoverRequestAcknowledge,
HandoverPreparationFailure,
SNStatusTransfer,
UEContextRelease,
HandoverCancel,
NotificationControlIndication,
RANPaging,
RetrieveUEContextRequest,
RetrieveUEContextResponse,
RetrieveUEContextConfirm,
RetrieveUEContextFailure,
XnUAddressIndication,
SecondaryRATDataUsageReport,
SNodeAdditionRequest,
SNodeAdditionRequestAcknowledge,
SNodeAdditionRequestReject,
SNodeReconfigurationComplete,
SNodeModificationRequest,
SNodeModificationRequestAcknowledge,
SNodeModificationRequestReject,
SNodeModificationRequired,
SNodeModificationConfirm,
SNodeModificationRefuse,
SNodeReleaseRequest,
SNodeReleaseRequestAcknowledge,
SNodeReleaseReject,
SNodeReleaseRequired,
SNodeReleaseConfirm,
SNodeCounterCheckRequest,
SNodeChangeRequired,
SNodeChangeConfirm,
SNodeChangeRefuse,
RRCTransfer,
XnRemovalRequest,
XnRemovalResponse,
XnRemovalFailure,
XnSetupRequest,
XnSetupResponse,
XnSetupFailure,
NGRANNodeConfigurationUpdate,
NGRANNodeConfigurationUpdateAcknowledge,
NGRANNodeConfigurationUpdateFailure,
E-UTRA-NR-CellResourceCoordinationRequest,
E-UTRA-NR-CellResourceCoordinationResponse,
ActivityNotification,
CellActivationRequest,
CellActivationResponse,
CellActivationFailure,
ResetRequest,
ResetResponse,
ErrorIndication,
PrivateMessage,
DeactivateTrace,
TraceStart,
HandoverSuccess,
ConditionalHandoverCancel,
EarlyStatusTransfer,
FailureIndication,
HandoverReport,
SCGFailureIndication,
ResourceStatusRequest,
ResourceStatusResponse,
ResourceStatusFailure,
ResourceStatusUpdate,
MobilityChangeRequest,
MobilityChangeAcknowledge,
MobilityChangeFailure,
AccessAndMobilityIndication,
CellTrafficTrace,
RANMulticastGroupPaging,
ScgFailureInformationReport,
ScgFailureTransfer,
F1CTrafficTransfer,
IABTransportMigrationManagementRequest,
IABTransportMigrationManagementResponse,
IABTransportMigrationManagementReject,
IABTransportMigrationModificationRequest,
IABTransportMigrationModificationResponse,
IABResourceCoordinationRequest,
IABResourceCoordinationResponse,
CPCCancel,
PartialUEContextTransfer,
PartialUEContextTransferAcknowledge,
PartialUEContextTransferFailure,
RachIndication,
DataCollectionRequest,
DataCollectionResponse,
DataCollectionFailure,
DataCollectionUpdate,
ODSIB1ConfigurationProvisionRequest,
ODSIB1ConfigurationProvisionResponse,
ODSIB1ConfigurationProvisionFailure,
ODSIB1ConfigurationProvisionStatus,
LTMConfigurationUpdate,
LTMConfigurationUpdateAcknowledge,
LTMConfigurationUpdateFailure,
CSIRSCoordinationRequest,
CSIRSCoordinationResponse,
CellSwitchNotification,
TAInformationTransfer,
LTMCancel,
CLI-Indication
FROM XnAP-PDU-Contents
id-handoverPreparation,
id-sNStatusTransfer,
id-handoverCancel,
id-notificationControl,
id-retrieveUEContext,
id-rANPaging,
id-xnUAddressIndication,
id-uEContextRelease,
id-secondaryRATDataUsageReport,
id-sNGRANnodeAdditionPreparation,
id-sNGRANnodeReconfigurationCompletion,
id-mNGRANnodeinitiatedSNGRANnodeModificationPreparation,
id-sNGRANnodeinitiatedSNGRANnodeModificationPreparation,
id-mNGRANnodeinitiatedSNGRANnodeRelease,
id-sNGRANnodeinitiatedSNGRANnodeRelease,
id-sNGRANnodeCounterCheck,
id-sNGRANnodeChange,
id-activityNotification,
id-rRCTransfer,
id-xnRemoval,
id-xnSetup,
id-nGRANnodeConfigurationUpdate,
id-e-UTRA-NR-CellResourceCoordination,
id-cellActivation,
id-reset,
id-errorIndication,
id-privateMessage,
id-deactivateTrace,
id-traceStart,
id-handoverSuccess,
id-conditionalHandoverCancel,
id-earlyStatusTransfer,
id-failureIndication,
id-handoverReport,
id-scgFailureIndication,
id-resourceStatusReportingInitiation,
id-resourceStatusReporting,
id-mobilitySettingsChange,
id-accessAndMobilityIndication,
id-cellTrafficTrace,
id-RANMulticastGroupPaging,
id-scgFailureInformationReport,
id-scgFailureTransfer,
id-f1CTrafficTransfer,
id-iABTransportMigrationManagement,
id-iABTransportMigrationModification,
id-iABResourceCoordination,
id-retrieveUEContextConfirm,
id-cPCCancel,
id-partialUEContextTransfer,
id-rachIndication,
id-dataCollectionReportingInitiation,
id-dataCollectionReporting,
id-ODSIB1ConfigurationProvision,
id-ODSIB1ConfigurationProvisionStatus,
id-lTMConfigurationUpdate,
id-cSIRSCoordination,
id-cellSwitchNotification,
id-tAInformationTransfer,
id-lTMCancel,
id-cLI-Indication
FROM XnAP-Constants;
-- **************************************************************
--
-- Interface Elementary Procedure Class
--
-- **************************************************************
XNAP-ELEMENTARY-PROCEDURE ::= CLASS {
&InitiatingMessage ,
&SuccessfulOutcome OPTIONAL,
&UnsuccessfulOutcome OPTIONAL,
&procedureCode ProcedureCode UNIQUE,
&criticality Criticality DEFAULT ignore
}
WITH SYNTAX {
INITIATING MESSAGE &InitiatingMessage
[SUCCESSFUL OUTCOME &SuccessfulOutcome]
[UNSUCCESSFUL OUTCOME &UnsuccessfulOutcome]
PROCEDURE CODE &procedureCode
[CRITICALITY &criticality]
}
-- **************************************************************
--
-- Interface PDU Definition
--
-- **************************************************************
XnAP-PDU ::= CHOICE {
initiatingMessage InitiatingMessage,
successfulOutcome SuccessfulOutcome,
unsuccessfulOutcome UnsuccessfulOutcome,
...
}
InitiatingMessage ::= SEQUENCE {
procedureCode XNAP-ELEMENTARY-PROCEDURE.&procedureCode ({XNAP-ELEMENTARY-PROCEDURES}),
criticality XNAP-ELEMENTARY-PROCEDURE.&criticality ({XNAP-ELEMENTARY-PROCEDURES}{@procedureCode}),
value XNAP-ELEMENTARY-PROCEDURE.&InitiatingMessage ({XNAP-ELEMENTARY-PROCEDURES}{@procedureCode})
}
SuccessfulOutcome ::= SEQUENCE {
procedureCode XNAP-ELEMENTARY-PROCEDURE.&procedureCode ({XNAP-ELEMENTARY-PROCEDURES}),
criticality XNAP-ELEMENTARY-PROCEDURE.&criticality ({XNAP-ELEMENTARY-PROCEDURES}{@procedureCode}),
value XNAP-ELEMENTARY-PROCEDURE.&SuccessfulOutcome ({XNAP-ELEMENTARY-PROCEDURES}{@procedureCode})
}
UnsuccessfulOutcome ::= SEQUENCE {
procedureCode XNAP-ELEMENTARY-PROCEDURE.&procedureCode ({XNAP-ELEMENTARY-PROCEDURES}),
criticality XNAP-ELEMENTARY-PROCEDURE.&criticality ({XNAP-ELEMENTARY-PROCEDURES}{@procedureCode}),
value XNAP-ELEMENTARY-PROCEDURE.&UnsuccessfulOutcome ({XNAP-ELEMENTARY-PROCEDURES}{@procedureCode})
}
The gui/ subdirectory contains an ASN.1 Studio project for this sample. With ASN.1 Studio you can:
This sample is provided solely for illustration purposes, for example to demonstrate usage of the OSS ASN.1 Tools API with 3GPP 5G XnAP messages. It does not represent a complete application. To build and run this sample, you must use a trial or licensed version of the appropriate OSS ASN.1 Tools. The copyright and license statements included in each source file remain fully applicable.
If you have questions about using this sample, contact OSS Nokalva Support.