Decoding Messages

Decoding begins with a PDU ("Protocol Definition Unit") type which encompasses the messages for the corresponding standard.

The following are the basic steps to decode with a PDU decode function:

  1. Prepare a buffer for decoding

  2. Create the instance of the PDU to receive the decoded data

  3. Call the desired PDU decode function to decode the message

An example with some comments follows. This example is based on the AuthRequest sample.

   /* Create a decode buffer on a file stream.
      The decode buffer could also be created on any InputStream or on a byte
      array.
   */
   FileInputStream in = new FileInputStream (filename);

   Asn1NasDecodeBuffer decodeBuffer = new Asn1NasDecodeBuffer (in);

   /* Create PDU object to decode into.
   For 24.301:
   com.objsys.nas.TS24301Msgs.PDU pdu = new com.objsys.nas.TS24301Msgs.PDU();
   */
   com.objsys.nas.TS24501Msgs.PDU pdu = new com.objsys.nas.TS24501Msgs.PDU();
   
   
   /* Decode the data */
   pdu.decode (decodeBuffer);
   
   /* Do whatever you need to with pdu and the message it contains.
      Use pdu.msgType to determine the message type.
   */

   /* For example, print the content */
   pdu.print (System.out, "pdu", 0);

   /* Or, cast to the correct message type */
   AuthRequest msg = (AuthRequest)pdu.data;