///////////////////////////////////////////////////////////////////////////////
//
// 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:               GRE_Types.ttcn
//  Rev:                R1B
//  Prodnr:             CNL 113 789
//  Updated:            2013-08-27
//  Contact:            http://ttcn.ericsson.se
//  Reference:			RFC 1701

module GRE_Types{
	
	import from General_Types all;
    
    external function enc_GRE_PDU(in GRE_PDU pdu) return octetstring
	with { extension "prototype(convert) encode(RAW)" }
	
	external function dec_GRE_PDU(in octetstring stream) return GRE_PDU
	with { extension "prototype(convert) decode(RAW)" }
    
	type record Source_Route_Entry{
	  OCT2	address_family,
	  OCT1	sre_offset,
	  INT1	sre_length,
	  octetstring	routing_information
	} with {
  		variant (sre_length) "LENGTHTO(routing_information)"
	}

	type set of Source_Route_Entry SRE_List

	type record GRE_Header{
	  BIT1	checksum_present,
	  BIT1	routing_present,
	  BIT1	key_present,
	  BIT1	sequence_nubmer_present,
	  BIT1	strict_source_route,
	  BIT3	recursion_control,
	  BIT5	reserved,
	  BIT3	version_number,
	  OCT2	protcol_type,
	  OCT2	checksum optional,
	  OCT2	offset optional,
	  OCT4	key optional,
	  OCT4	sequence_number optional,
	  SRE_List	routing optional
	} with {
	  variant (checksum) 	"PRESENCE(checksum_present='1'B,routing_present='1'B)"
	  variant (offset) 		"PRESENCE(checksum_present='1'B,routing_present='1'B)"
	  variant (routing) 	"PRESENCE(routing_present='1'B)"
	  variant (key) 		"PRESENCE(key_present='1'B)"
	  variant (sequence_number)	"PRESENCE(sequence_nubmer_present='1'B)"
	}

	type record GRE_PDU{
  		GRE_Header	header,
  		octetstring	payload
	} with { variant ""}

} with {encode "RAW"
		extension "version R1B"
}