///////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2000-2019 Ericsson Telecom AB
//
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v2.0
// which accompanies this distribution, and is available at
// https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
///////////////////////////////////////////////////////////////////////////////
//
//  File:               SNDCP_Types.ttcn
//  Rev:                R2A
//  Prodnr:             CNL 113 576
//  Updated:            2008-01-21
//  Contact:            http://ttcn.ericsson.se
//  Reference:          3GPP TS 44.065 7.0.0
 
module SNDCP_Types
{    

// This module contains the Subnetwork Dependent Convergence Protocol
//  44.065 v7.0.0 with attributes for RAW encoding/decoding.

// According to 3GPP 04.64 - the maximum(!) length of the PDU_SN_UNITDATA and PDU_SN_DATA
// is minimum 140 and maximum 520 octets.
// The actual length of the PDU_SN_UNITDATA and PDU_SN_DATA is given in LLC ASPs or set to a parameter value.
// The possible maximum length of dataSegmentSnUnitdataPdu or dataSegmentSnDataPdu is therefore variable and 
// will depend on this setting.
// The RAW decoder should have no problem decoding these fields when they are simply defined as octetstrings
// and stand at the end of the SNDPC PDUs.
//

//
 
import from General_Types all;

external function enc_PDU_SN(in PDU_SN pdu ) return octetstring
with { extension "prototype(convert)"
       extension "encode(RAW)"
     }
      
external function dec_PDU_SN(in octetstring stream) return PDU_SN
with { extension "prototype(convert)"
       extension "decode(RAW)"
     }
     
type union PDU_SN
{
PDU_SN_UNITDATA    pDU_SN_UNITDATA,
PDU_SN_DATA        pDU_SN_DATA       
} with { variant "TAG (              
		pDU_SN_UNITDATA,       			 snPduType ='1'B;	
		pDU_SN_DATA,      			 snPduType ='0'B		
              )"
};


type record PDU_SN_UNITDATA 
{
 BIT4			   nsapi,
 BIT1		  	   moreBit,
 BIT1             	   snPduType,         
 BIT1			   firstSegmentIndicator, 
 BIT1			   spareBit,                     // set to '0'B
 BIT4			   pcomp optional,
 BIT4			   dcomp optional,
 BIT4			   npduNumber,
 BIT4			   segmentNumber,
 OCT1			   npduNumberContinued,
 octetstring 		   dataSegmentSnUnitdataPdu      
}  with { variant (pcomp)  	  "PRESENCE(firstSegmentIndicator = '1'B)";
          variant (dcomp)  	  "PRESENCE(firstSegmentIndicator = '1'B)"
 };


type record PDU_SN_DATA 
{
 BIT4			   nsapi, 
 BIT1		  	   moreBit,
 BIT1             	   snPduType,         
 BIT1			   firstSegmentIndicator, 
 BIT1			   spareBit,                  // set to '0'B
 BIT4			   pcomp optional,
 BIT4			   dcomp optional,
 OCT1			   npduNumberAck optional,
 octetstring 		   dataSegmentSnDataPdu       

} with { variant (pcomp)  	 	  "PRESENCE(firstSegmentIndicator = '1'B)";
          variant (dcomp)  	 	  "PRESENCE(firstSegmentIndicator = '1'B)";
	  variant (npduNumberAck)  	  "PRESENCE(firstSegmentIndicator = '1'B)"
  };


}with{ encode "RAW"}  // end of module
