Commit a0f8c352 authored by mullers's avatar mullers
Browse files

1.draft of transitioning prototype

parent e31ff6d5
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ module LibIpv6_CommonRfcs_TypesAndValues {
	group rfc4291AddressingArchitecture {

		type Oct16 Ipv6Address;
		type Oct4 Ipv4Address;
		type UInt8 PrefixLength ;//indicates nr of bits to be used as Prefix
		//Unspecified address
        const Ipv6Address c_unspecifiedAdd := c_16ZeroBytes;
+27 −3
Original line number Diff line number Diff line
@@ -35,6 +35,14 @@
	external function fx_payloadLength( in template Ipv6Packet p_msg ) 
	return UInt16;

	/* @desc    This external function calculates the total length
	 *			of a IPv4 packet.
	 * @param   p_msg Ipv4 packet
	 * @return  payload length in bytes
	*/
	external function fx_ipv4PacketTotalLength( in template Ipv4Packet p_msg ) 
	return UInt16;
	
	/* @desc    This external function calculates the payload length
	 *			of a IPv6 packet
	 * @param   p_msg Ipv6 packet
@@ -44,8 +52,11 @@
	external function fx_tunnelledPayloadLength( template Ipv6Packet p_msg, in UInt8 p_entry ) 
	return UInt16;
	
	/* @desc	TODO
	 * @param  TODO 
	/* @desc   Calculates the checksum over the IPv6 payload
	 * @param  p_srcAddress Source Address
	 * @param  p_dstAddress Destination Address
	 * @param  p_payload Checksum is calculated over this
	 * @param  p_nextHeader Needed for the checksum calculation
	 * @return checksum value
	*/
	external function fx_calcPayloadChecksum(in template Ipv6Address p_srcAddress,	
@@ -54,6 +65,19 @@
											 in UInt8 p_nextHeader) 
	return Oct2;

	/* @desc   Calculates the checksum over the IPv4 payload
	 * @param  p_srcAddress Source Address
	 * @param  p_dstAddress Destination Address
	 * @param  p_payload Checksum is calculated over this
	 * @param  p_nextHeader Needed for the checksum calculation
	 * @return checksum value
	*/
	external function fx_calcIpv4PayloadChecksum(in template Ipv4Address p_srcAddress,	
												 in template Ipv4Address p_dstAddress, 
												 in template Ipv4Payload p_payload,
												 in UInt8 p_nextHeader) 
	return Oct2;
	
	/* @desc 	This external function runs the Ipv6Packet through Codec and returns 
	 *			the octetstring representing the Ipv6Packet
	*/
+48 −0
Original line number Diff line number Diff line
@@ -1186,5 +1186,53 @@ group rfc4303Esp_ExtHdrFunctions {
	
}//end group rfc4303Esp_ExtHdrFunctions

group rfc791Fns {
	
	/*
	 * @desc  	This sends an ICMPv4 packet from an dual stack IPv4/IPv6 node to 
	 *          any NUT. Prior it modifies
	 *			IPv6 packet payload length and ICMPv6 checksum
	 *			IPv4 packet payload length (totalLength field in IPv4 header) and ICMPv4 checksum
	 *			to their correct values using external functions.
	 * @remark  The template passed in must NOT contain any matching expressions!
	 * @param 	p_echoRequest Ipv4 packet value or template with echo request to be sent
	 * @return 	execution status
	*/
	function f_sendIpv4Packet (in template Ipv4Packet p_ipv4Packet) 
	runs on LibIpv6Node
	return FncRetCode {
		var Ipv4Packet v_ipPkt;
		v_ipPkt := valueof(p_ipv4Packet);

		//Build IPv6 Packet
		if (ispresent(v_ipPkt.ipv4Payload) and ischosen(v_ipPkt.ipv4Payload.ipv6Packet)) {
			if(f_setExtensionHeaders(v_ipPkt.ipv4Payload.ipv6Packet) != e_success) {
				log(" **** f_sendIpv4Packet: Error when building IPv6Packet ****");
				return e_error;
			}
		}

		//Build IPv4 Packet
		//IHL is set in templates
		// Update the total length					
		v_ipPkt.ipv4Hdr.totalLength := fx_ipv4PacketTotalLength (v_ipPkt);

		// Compute payload checksum (Icmpv6, UDP, ...)
		v_ipPkt.ipv4Payload.ipv4EchoRequestMsg.checksum := fx_calcIpv4PayloadChecksum (
			v_ipPkt.ipv4Hdr.sourceAddress,
			v_ipPkt.ipv4Hdr.destinationAddress,
			v_ipPkt.ipv4Payload,
			c_icmpHdr //TODO verify if 58 is valid in IPv4
		);
		
		//send
		ipPort.send(v_ipPkt);
	
		return e_success;
	
	}//end f_sendIpv4Packet
	
}//end rfc791Fns

	
} // end module LibIpv6_Interface_Functions
+106 −2
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ module LibIpv6_Interface_Templates {
	import from LibIpv6_Rfc3775Mipv6_TypesAndValues all;
	import from LibIpv6_Rfc4068FastHandovers_TypesAndValues all;
	import from LibIpv6_Rfc2463Icmpv6_TypesAndValues all;
	import from LibIpv6_Rfc792Icmpv4_TypesAndValues all;

	group rfc2460Root_Templates {

@@ -1394,4 +1395,107 @@ module LibIpv6_Interface_Templates {

	} //end group rfc4303Esp_ExtHdrTemplates

	group rfc791Templates {
		
		group ipv4HeaderTemplates {

			/*
			 *	@param  p_nextHdr Next header identifier value to be used.
			 *	@param  p_src Binary IPv6 address associated with the
			 *          test component.
			 *	@param  p_dst Binary IPv6 address associated with NUT.
			*/
			template Ipv4Header m_ipv4Hdr_protocol_srcDst(
				UInt8 p_protocol,
				template Ipv4Address p_src,
				template Ipv4Address p_dst
			) := {
				version := c_ipv4Version,
				headerLength := c_defaultIhsLength,
				typeOfService := c_defaultTos,
				totalLength := c_uInt16Zero,
				identification := c_defaultIdentification,
				reserved := c_uInt1Zero,
				doNotFragFlag := c_doNotFragFlag1,
				moreFragsFlag := c_moreFragsFlag0,
				fragmentOffset := c_uInt13Zero,
				timeToLive := c_ttl255,
				protocol := p_protocol,
				hcs := c_2ZeroBytes,
				sourceAddress := p_src,
				destinationAddress := p_dst,
				ipv4HdrOptions := omit
			}

			/*
			 *	@param  p_nextHdr Next header identifier value to be used.
			 *	@param  p_src Binary IPv6 address associated with the
			 *          test component.
			 *	@param  p_dst Binary IPv6 address associated with NUT.
			*/
			template Ipv4Header mw_ipv4Hdr_protocol_srcDst(
				UInt8 p_protocol,
				template Ipv4Address p_src,
				template Ipv4Address p_dst
			) := {
				version := c_ipv4Version,
				headerLength := ?,
				typeOfService := ?,
				totalLength := ?,
				identification := ?,
				reserved := c_uInt1Zero,
				doNotFragFlag := ?,
				moreFragsFlag := ?,
				fragmentOffset := ?,
				timeToLive := ?,
				protocol := p_protocol,
				hcs := ?,
				sourceAddress := p_src,
				destinationAddress := p_dst,
				ipv4HdrOptions := *
			}

		}//end ipv4HeaderTemplates

		group ipv4PacketTemplates {
			
			
			/*
			 *	@param  p_src Binary IPv4 address associated with the
			 *          test component.
			 *	@param  p_dst Binary IPv6 address associated with NUT.
			 *	@param  p_ipv6Packet Tunneled IPv6 packet
			*/
			template Ipv4Packet m_ipv4Packet_tunneledIpv6(
				template Ipv4Address p_src,
				template Ipv4Address p_dst,
				template Ipv6Packet p_ipv6Packet
			) := {
				ipv4Hdr := m_ipv4Hdr_protocol_srcDst(c_protocol_tunneledIpv6, p_src, p_dst),
				ipv4Payload := {
					ipv6Packet := p_ipv6Packet
				}
			}

			/*
			 *	@param  p_src Binary IPv4 address associated with the
			 *          test component.
			 *	@param  p_dst Binary IPv6 address associated with NUT.
			 *	@param  p_ipv6Packet Tunneled IPv6 packet
			*/
			template Ipv4Packet mw_ipv4Packet_tunneledIpv6(
				template Ipv4Address p_src,
				template Ipv4Address p_dst,
				template Ipv6Packet p_ipv6Packet
			) := {
				ipv4Hdr := mw_ipv4Hdr_protocol_srcDst(c_protocol_tunneledIpv6, p_src, p_dst),
				ipv4Payload := {
					ipv6Packet := p_ipv6Packet
				}
			}
			
		}//end ipv4PacketTemplates	
		
	}//end rfc791Templates

} // end module LibIpv6_Interface_Templates
+100 −13
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ module LibIpv6_Interface_TypesAndValues {
	import from LibIpv6_Rfc0768Udp_TypesAndValues all ;
	import from LibIpv6_CommonRfcs_TypesAndValues all;
	import from LibIpv6_Rfc4306Ikev2_TypesAndValues all;
	import from LibIpv6_Rfc792Icmpv4_TypesAndValues all;

	group libTestSystem {
		/*
@@ -119,9 +120,11 @@ module LibIpv6_Interface_TypesAndValues {
			InformationalRequest,
			InformationalResponse,
			//MetaPdu
			Ipv6Packet
			//General IPv6 packet
			//GeneralIpv6
			Ipv6Packet,
			//Ipv4
			Ipv4EchoRequest,//TODO rename in test componennt from ipv6Port to ipPort
			Ipv4EchoReply,
			Ipv4Packet
		}//end type port Ipv6Port

	}//end group libTestSystem
@@ -359,15 +362,11 @@ module LibIpv6_Interface_TypesAndValues {
			variant "isPDU;use=com.testingtech.ttcn.tci.codec.helper.*;present=SupportFunctions.checkIKEmsg(dec, 37, 1)";
		}
		
	  	//General IPv6 packet
	//  	type octetstring Ipv6Packet;//TODO SMU+DTE check this


		/*
		 * @desc This meta packet type contains any Ipv6 packets.
		 *		 This type is used mainly for checksum calculation
		*/
	    type union Ipv6Payload  { //type union Ipv6Packet  {
	    type union Ipv6Payload  {
			//Imported from Rfc 2463
			DestinationUnreachableMsg 				destinationUnreachableMsg,
			PacketTooBigMsg							packetTooBigMsg,
@@ -404,11 +403,9 @@ module LibIpv6_Interface_TypesAndValues {
			//Udp
			UdpMsg									udpMsg,
		  	//General IPv6 packet
		  	//GeneralIpv6                         	generalIpv6
		  	octetstring								octetstringMsg
		}
		with {
			//DTE TODO
			variant "isPDU=LibIpv6_Interface_TypesAndValues;"
		}

@@ -1112,6 +1109,96 @@ module LibIpv6_Interface_TypesAndValues {

} // end extensionHeaders

group ipv4Definitions {

	group ipv4Constants {
		
		//const UInt32  	c_ipv4IcmpPointer4 := 4;
		const UInt4 	c_defaultIhsLength := 5;
		const UInt1 	c_doNotFragFlag0 := 0;
		const UInt1 	c_doNotFragFlag1 := 1;
		const UInt1 	c_moreFragsFlag0 := 0;
		const UInt1 	c_moreFragsFlag1 := 1;
		const UInt8 	c_ttl255 := c_uInt8Max;
		const Bit8 		c_defaultTos := int2bit(0,8);
		const Oct2		c_defaultIdentification := 'B444'O;
		const UInt8		c_protocol_icmp := 1;
		const UInt8		c_protocol_tunneledIpv6 := 41;
		
	}//end ipv4Constants

	group ipv4Packets {

		/*
		 * @desc PDU type derived from RFC791
		*/
		type record Ipv4Packet {
			Ipv4Header			ipv4Hdr,
			Ipv4Payload			ipv4Payload optional
		}
		with {
			variant"";//TODO DT MAY 2007
		}

		type Ipv4Packet Ipv4EchoRequest
		with {
			variant"";//TODO DT MAY 2007
		}

		type Ipv4Packet Ipv4EchoReply
		with {
			variant"";//TODO DT MAY 2007
		}

	}//end ipv4Packets


	group ipv4Header {
				
		const UInt4		c_ipv4Version := 4;

		/*
		 * @desc Derived from RFC 2460 Section 3
		 * @url http://www.ietf.org/rfc/rfc2460.txt
		*/
		type record Ipv4Header 	{
			UInt4 			version,
			UInt4			headerLength,//in 32 bit words
			Bit8			typeOfService,
			UInt16			totalLength,//length of the datagram, measured in octets,including internet header and data
			Oct2			identification,
			UInt1			reserved,
			UInt1			doNotFragFlag,
			UInt1			moreFragsFlag,
			UInt13			fragmentOffset,
			UInt8			timeToLive,
			UInt8			protocol,//in IPv6 it is nextHeader
			Oct2			hcs,//A checksum on the header only
			Ipv4Address		sourceAddress,
			Ipv4Address 	destinationAddress,
			octetstring		ipv4HdrOptions optional
		}
		with {
		 variant"";//TODO DT MAY 2007
		}

	} // end ipv4Header

	group ipv4Payload {
		
		type union Ipv4Payload  {
			//Imported from Rfc 792
			Ipv4EchoRequestMsg	ipv4EchoRequestMsg,
			Ipv4EchoReplyMsg	ipv4EchoReplyMsg,
			//Imported from RFC2463
			Ipv6Packet			ipv6Packet
		}

		
	}//end ipv4Payload
	
}//end ipv4Definitions



} // end module LibIpv6_Interface_TypesAndValues
Loading