Commit e19ac8c8 authored by mullers's avatar mullers
Browse files

transitioning added

parent 446ce08e
Loading
Loading
Loading
Loading
+73 −0
Original line number Original line Diff line number Diff line
/*
 *	@author 	STF 276
 *  @version 	$Id$
 *	@desc		This module specifies common IPv4 ICMP messages 
 *              interchanges (= operations) for an Ipv6 test component
 *              Functions do not set a test component verdict but instead
 *              use the function return value instead to notify the function
 *              caller about the success of the operation.
 *  
 */
 module LibIpv6_Rfc792Icmpv6_Functions {

	//LibCommon
	import from LibCommon_BasicTypesAndValues all;
	import from LibCommon_DataStrings all;
	import from LibCommon_VerdictControl { type FncRetCode };
	//LibIpv6
	import from LibIpv6_Interface_TypesAndValues all ;
	import from LibIpv6_Interface_Functions all;
	import from LibIpv6_Interface_Templates all;
	import from LibIpv6_CommonRfcs_TypesAndValues all;
	import from LibIpv6_CommonRfcs_Functions all;
	import from LibIpv6_ModuleParameters all ;
	import from LibIpv6_ExternalFunctions all;
//	import from LibIpv6_Rfc792Icmpv4_Templates all;
	import from LibIpv6_Rfc792Icmpv4_TypesAndValues all;
	
	/*
	 * @desc  	This sends an ICMPv4 echo request 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_sendIpv4EchoRequest (in template Ipv4EchoRequest p_ipv4EchoRequest) 
	runs on LibIpv6Node
	return FncRetCode {
		var Ipv4EchoRequest v_ipPkt;
		v_ipPkt := valueof(p_ipv4EchoRequest);

		//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_sendIpv4EchoRequest: 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_sendIpv4EchoRequest


} // end module LibIpv6_Rfc2463Icmpv6_Functions
+77 −0
Original line number Original line Diff line number Diff line
/*
 *	@author 	STF 276
 *  @version 	$Id$
 *	@desc		This module specifies common template definitions
 *              to specify ICMPv6 packets
 *
 */
module LibIpv6_Rfc792Icmpv4_Templates {
	//LibCommon
	import from LibCommon_BasicTypesAndValues all;
	import from LibCommon_DataStrings all;
	//LibIpv6
	import from LibIpv6_Interface_TypesAndValues all;
	import from LibIpv6_Interface_Templates all;
	import from LibIpv6_CommonRfcs_TypesAndValues all;
	import from LibIpv6_ExternalFunctions all;
	import from LibIpv6_ModuleParameters all;
	//import from LibIpv6_Rfc2463Icmpv6_TypesAndValues all;
	//import from LibIpv6_Rfc2461NeighborDiscovery_TypesAndValues all;
	import from LibIpv6_Rfc792Icmpv4_TypesAndValues all;
	
	group ICMPv4_Echo_Request {
		
		/*
		 *	@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 Ipv4EchoRequest m_ipv4EchoRequest_noData(
			template Ipv4Address p_src,
			template Ipv4Address p_dst
		) := {
			ipv4Hdr := m_ipv4Hdr_protocol_srcDst(c_protocol_icmp, p_src, p_dst),
			ipv4Payload := {
				ipv4EchoRequestMsg := {
					icmpType := c_icmpType_ipv4EReq,
					icmpCode := c_ipv4IcmpCode0,
					checksum := c_2ZeroBytes,
					identifier := c_defId,
					sequenceNumber := c_defSeqNo,
					data := omit
				}
			}
		}

	}// end ICMPv4_Echo_Request

	group ICMPv4_Echo_Reply {
		
		/*
		 *	@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 Ipv4EchoRequest mw_ipv4EchoReply_noData(
			template Ipv4Address p_src,
			template Ipv4Address p_dst
		) := {
			ipv4Hdr := mw_ipv4Hdr_protocol_srcDst(c_protocol_icmp, p_src, p_dst),
			ipv4Payload := {
				ipv4EchoRequestMsg := {
					icmpType := c_icmpType_ipv4EReq,
					icmpCode := c_ipv4IcmpCode0,
					checksum := ?,
					identifier := c_defId,
					sequenceNumber := c_defSeqNo,
					data := omit
				}
			}
		}

	}// end ICMPv4_Echo_Reply

	
} // end module LibIpv6_Rfc792Icmpv4_Templates
+60 −0
Original line number Original line Diff line number Diff line
/*
 *	@author 	STF 276
 *  @version 	$Id$
 *	@desc		This module defines the ICMPv4 message types and 
 *              their information elements using types from the 
 *              Common and Ipv6 library. Also it provides some useful  
 *              constant definitions.
 *              All types have been defined on the basis of RFC 792
 *  @url        http://www.ietf.org/rfc/rfc2463.txt
 *  
 */
 module LibIpv6_Rfc792Icmpv4_TypesAndValues {
	
	//LibCommon
	import from LibCommon_BasicTypesAndValues all;
	import from LibCommon_DataStrings all;
	//LibIpv6
	import from LibIpv6_CommonRfcs_TypesAndValues all ;

	group constants {
		const UInt8 	c_ipv4IcmpCode0 := 0 ;
		const UInt8 	c_icmpType_ipv4EReq := 0;
		const UInt8 	c_icmpType_ipv4ERep := 8;
	}

 	group icmpMsgs {
		
		/*
		 * @desc PDU type derived from RFC 792
		*/
		type record Ipv4EchoRequestMsg {
			UInt8 		icmpType(c_icmpType_ipv4EReq),
			UInt8 		icmpCode,
			Oct2 		checksum,
			UInt16		identifier,
			UInt16 		sequenceNumber,
			octetstring	data optional
		}
		with {
			variant"";//TODO DT MAY 2007
		}
	
		/*
		 * @desc PDU type derived from RFC 792
		*/
		type record Ipv4EchoReplyMsg {
			UInt8 		icmpType(c_icmpType_ipv4ERep),
			UInt8 		icmpCode,
			Oct2 		checksum,
			UInt16		identifier,
			UInt16 		sequenceNumber,
			octetstring	data optional
		}
		with {
			variant"";//TODO DT MAY 2007
		}

	} // end icmpMsgs
	
} // end module LibIpv6_Rfc792Icmpv4_TypesAndValues
 No newline at end of file