LibIpv6_CommonRfcs_TypesAndValues.ttcn 7.84 KB
Newer Older
/*
 *	@author 	STF 276
 *  @version 	$Id$
 *	@desc		This module defines types and constants for  
 *              information elements that are shared by more
 *              than one RFC TTCN-3 module including IPv6 options,
 *              addresses, and extension headers. 
 *              Types have been derived from various RFCs.
 */
module LibIpv6_CommonRfcs_TypesAndValues {
	
	//LibCommon
	import from LibCommon_BasicTypesAndValues all;
	import from LibCommon_DataStrings all;
	import from LibCommon_TextStrings all;
	import from LibCommon_Time all ;

	group DefaultConstants {
		const UInt16 c_defId 	:= 10; // for ICMP echo proc
		const UInt16 c_defSeqNo	:= 20; // for ICMP echo proc
	}

	group rfc4291AddressingArchitecture {

		type Oct16 Ipv6Address;
		type UInt8 PrefixLength ;//indicates nr of bits to be used as Prefix
		//Unspecified address
        const Ipv6Address c_unspecifiedAdd := c_16ZeroBytes;
		const UInt8	c_maxNrIpv6Address := 10;
		
		type record length(1 .. c_maxNrIpv6Address) of Ipv6Address Ipv6AddressList
		with {
			encode "present=isEOF()== false ;elements=valueOf(getTag('hdrExtLen'));"
		}
		
		
	}//end group rfc4291AddressingArchitecture
	

	group ipv6Options {

		const UInt8	c_optLen0 := 0;
		const UInt8 c_optLen1 := 1;
		const UInt8 c_optLen2 := 2;
		const UInt8 c_optLen3 := 3;
		const UInt8 c_optLen4 := 4;
		const UInt8 c_optLen6 := 6;
		const UInt8	c_optLen16 := 16;

		group rfc2460Options {

			group paddingOptions {

				const UInt8		c_optPad1 := 0;
				const UInt8		c_optPadN := 1;
				const UInt8 	c_optPadNLen0 := 0 ;
				const UInt8 	c_optPadNLen2 := 2;
				const UInt8 	c_optPadNLen4 := 4 ;
		
				type record OptPad1 {
					UInt8 			optType(c_optPad1)
				}
				with {
					encode "present=bytes(0,1,0);intTag='hdrExtIntLen',getIntTag('hdrExtIntLen')-1";
				}
		
				type record OptPadN {
					UInt8 			optType(c_optPadN),
					UInt8 			optLen,
					octetstring		padding optional
				}
				with {
					encode "present=bytes(0,1,1);";
					encode (optLen) "tag='optLen';intTag='hdrExtIntLen',getIntTag('hdrExtIntLen')-value-2";
					encode (padding) "length=valueOf(getTag('optLen'));fieldPresent=(valueOf(getTag('optLen'))>0)";
				}

			}//end group paddingOptions

			group DestOptions { //2460 + MIPv6

				const UInt8	c_maxNrDestOption := 10;

				/* @remark In a DestOptionList value either the pad1 or padN 
				 *         option can appear only once!
		        */
				type set length (1..c_maxNrDestOption) of DestOption   DestOptionList
				with {
					encode "elements=valueOf(getTag('hdrExtLen'));"
				}

				type union DestOption {
					OptPad1					pad1 ,
					OptPadN					padN ,
					OptTunnelEncapLimit 	tunnelEncapLimit , 
					OptHomeAddress			homeAddressOption,
					octetstring				generalOptionString
				}
				with {
					encode (generalOptionString) "length=valueOf(getTag('hdrExtLen'))-2;";
				}

			}//end group DestOptions

	
		}//end group rfc2460Options

		group rfc2461Options {

			group slla {
		
				const UInt8 c_srcLinkLayerAddress := 1;
		
	

				/*
				 * @desc Derived from RFC2461 clause4.6.1 + MIPv6
				 * @url http://www.ietf.org/rfc/rfc2461.txt
				*/
				type record SrcLinkLayerAddress {
					UInt8 				icmpType(c_srcLinkLayerAddress),
					UInt8 				optionLength,
					Oct6to15			linkLayerAddr
				}
				with {
					encode "present=bytes(0,1,1);";
					encode (optionLength) "tag='SLA_optionLength';";
					encode (linkLayerAddr) "length=valueOf(getTag('SLA_optionLength'))*8-2;";
				}
	
			}//end group slla

			group tlla {

				const UInt8 c_tgtLinkLayerAddress := 2;

				/*
				 * @desc Derived from RFC 2461 clause 4.6.1 + MIPv6
				 * @url http://www.ietf.org/rfc/rfc2461.txt
				*/
				type record TgtLinkLayerAddress {
					UInt8 				icmpType(c_tgtLinkLayerAddress),
					UInt8 				optionLength,
					Oct6to15			linkLayerAddr
				}
				with {
					encode "present=bytes(0,1,2);";
					encode (optionLength) "tag='TLA_optionLength';";
					encode (linkLayerAddr) "length=valueOf(getTag('TLA_optionLength'))*8-2;";
				}
		
		
			}//end group tlla

			group mtu {
		
				const UInt8 c_mtuOption := 5;

				/*
				 * @desc Derived from RFC 2461 clause 4.6.4 + MIPv6
				 * @url http://www.ietf.org/rfc/rfc2461.txt
				*/
				type record MtuOption {
					UInt8 	icmpType(c_mtuOption),
					UInt8 	optionLength,
					UInt16	reserved,
					UInt32	mtu
				}
				with {
					encode "present=bytes(0,1,5);"
				}
		
			}//end group mtu

		}//end group rfc2461Options

		group rfc2473Options {

			const UInt8		c_optTunnelEncapLimit := 4;

			/*
			 * @desc Derived from RFC 2473 Section 4.1.1
			 * @url http://www.ietf.org/rfc/rfc2473.txt
			*/
			type record OptTunnelEncapLimit {
				UInt8			optType(c_optTunnelEncapLimit),
				UInt8			optLen (1),
				UInt8			optTunnelEncapLimitValue
			}
			with {
				encode "present=bytes(0,1,4);intTag='hdrExtIntLen',getIntTag('hdrExtIntLen')-3";
			}
	
		}//end group rfc2473Options

		group rfc2675Options {

			const UInt8 c_optJumboPayload := 194;
			const UInt32 c_jumboLen8 := 8;
			const UInt32 c_jumboLen128K := 131072;

			/*
			 * @desc Derived from RFC 2675 Section 2
			 * @url http://www.ietf.org/rfc/rfc2675.txt
			*/
			type record OptJumboPayload {
				UInt8			optType(c_optJumboPayload),
				UInt8			optLen(4),
				UInt32			optJumboPayloadLength
			}
			with {
				encode "present=bytes(0,1,194);intTag='hdrExtIntLen',getIntTag('hdrExtIntLen')-6";
			}

		}//end group rfc2675Options

		group rfc2711Options {
	
			const UInt8		c_optRouterAlert := 5; 	

			/*
			 * @desc Derived from RFC 2711 Section 2.1
			 * @url http://www.ietf.org/rfc/rfc2711.txt
			*/
			type record OptRouterAlert {
				UInt8			optType(c_optRouterAlert),
				UInt8			optLen(2),
				UInt16			optValue
			}
			with {
				encode "present=bytes(0,1,5);intTag='hdrExtIntLen',getIntTag('hdrExtIntLen')-4";
			}

		}//end group rfc2711Options
	
		group rfc3775Options {

			const octetstring		c_preDefAIOption := '0101000000001000'O;
			const octetstring		c_preDefHAIOption := '0801000000000040'O;

			/*
			 * @desc  Extra ICMP option introduced by RFC3775, clause 7.3
			*/
			type record AdvertisementInterval { //ND + MIPv6
				UInt8 		icmpType (c_advertisementInterval),
				UInt8 		optionLength (1),
				UInt16		reserved,
				UInt32		advInterval
			}
			with {
				encode "present=bytes(1, 0x07)"
			}
		
			/*
			 * @desc Extra ICMP option introduced by RFC3775, clause 7.4
			*/
			type record HomeAgentInfo { //ND + MIPv6
				UInt8 		icmpType (c_homeAgentInfo),
				UInt8 		optionLength (1),
				UInt16		reserved,
				UInt16		homeAgentPreference,
				UInt16		homeAgentLifetime
			}
			with {
				encode "present=bytes(1, 0x08)"
			}

			/* @desc Derived from RFCxxxx MIpv6, clause 6.2 
			 * @remark This extension shall be inserted:  
			 *       1) After the routing header, if that header is present, 
			 *		 2) Before the Fragment Header, if that header is present
			 *		 3) Before the AH Header or ESP Header, if either one of those headers is present 
			*/
			type record OptHomeAddress { // as destination option
				UInt8	ipv6OptType(c_optHomeAddress),
				UInt8	ipv6OptLen(0..16),
				Oct16	homeAddress
			}
			with {
				encode "present=bytes(0,1,201);intTag='hdrExtIntLen',getIntTag('hdrExtIntLen')-18";
			}

			group mipOptionValues {
				const UInt8	c_bindingRefreshAdvice := 2;
				const UInt8	c_alternateCareofAddress := 3;
				const UInt8	c_nonceIndices := 4;
				const UInt8	c_authorizationData := 5;
				const UInt8 c_advertisementInterval := 7;
				const UInt8 c_homeAgentInfo := 8;
			
			}//end group mipOptionValues

			const UInt8	c_optHomeAddress := 201; 
			
		}//end group rfc3775Options

	} // end ipv6Options


} // end LibIpv6_CommonRfcs_TypesAndValues