Commit fa7e3426 authored by seb's avatar seb
Browse files

created branch

parent f15c3fdc
Loading
Loading
Loading
Loading
+62 −0
Original line number Diff line number Diff line
/*
 *	@author 	STF 276
 *  @version 	$Id$
 *	@desc		This module specifies functions definitions
 *              based on the IPv6 meta message type.  
 *  
 */
 module LibIpv6_Rfc2460Root_Functions {

	//LibCommon
	import from LibCommon_BasicTypesAndValues all;
	import from LibCommon_DataStrings all;
	import from LibCommon_VerdictControl { type FncRetCode };
	//LibIpv6
	import from LibIpv6_Rfc2460Root_Templates all;
	import from LibIpv6_Rfc2460Root_TypesAndValues all;
	import from LibIpv6_Interface all;
	import from LibIpv6_ExternalFunctions all;
	import from LibIpv6_MultiRfcs_Functions all;
	import from LibIpv6_MultiRfcs_TypesAndValues all;

	group ipv6Packets {	

	/*
	 * @desc 	This sends a General IPv6 packet
	 *			from an IPv6 node to any NUT.
	 *			A General IPv6 packet is used in the case where only Extension headers
	 *			need to be sent.
	 * @remark  Time limit is defined by module parameter PX_TAC (see comp type)
	 * @param 	p_msg MIPHeader to be sent	
	 * @return 	execution status
	*/
	function f_sendGeneralIpv6(template GeneralIpv6 p_msg)
	runs on LibIpv6Node
	return FncRetCode {
		//Variables
		var Ipv6Packet v_ipPkt;
		v_ipPkt.generalIpv6 := valueof(p_msg);
		//set extensionHeaders
		if (ispresent(v_ipPkt.generalIpv6.extHdrList)) {
			if(f_setExtensionHeaders(	v_ipPkt.generalIpv6.extHdrList,
										v_ipPkt.generalIpv6.ipv6Hdr.sourceAddress,
										v_ipPkt.generalIpv6.ipv6Hdr.destinationAddress,
										v_ipPkt) != e_success) {
				log(" **** f_sendGeneralIpv6: Error when calculating length of extension headers ****");
				return e_error;
			}
		}
		//calc payloadLen
		v_ipPkt.generalIpv6.ipv6Hdr.payloadLength := fx_payloadLength (v_ipPkt);
		//send
		ipPort.send(v_ipPkt.generalIpv6);

		return e_success;
	}//end f_sendGeneralIpv6



    } //end group ipv6Packets

	
} // end module LibIpv6_Rfc2460Root_Functions
+571 −0
Original line number Diff line number Diff line
/*
 *	@author 	STF 276
 *  @version 	$Id$
 *	@desc		This module specifies common template definitions
 *              for the IPv6 meta message type
 */
 module LibIpv6_Rfc2460Root_Templates {

	//LibCommon
	import from LibCommon_BasicTypesAndValues all;
	import from LibCommon_DataStrings all;
	//LibIpv6
	import from LibIpv6_ExternalFunctions all;
	import from LibIpv6_ModuleParameters all ;
	import from LibIpv6_MultiRfcs_Templates all;
	import from LibIpv6_MultiRfcs_TypesAndValues all;
	import from LibIpv6_Rfc2460Root_TypesAndValues all ;
	import from LibIpv6_Rfc2462StatelessAddressAutoconf_TypesAndValues all;

	group ipv6HeaderTemplates{

		/*
		 *	@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 Ipv6Header m_ipHdr_nextHdr_srcDst (	UInt8 p_nextHdr,
										template Ipv6Address p_src,
										template Ipv6Address p_dst) := {
			version 		:= c_ipv6Version ,
			trafficClass 	:= c_trafficClassZero ,
			flowLabel 		:= c_flowLabelZero ,
			payloadLength 	:= c_zeroPayloadLength, 
			nextHeader 		:= p_nextHdr,
			hopLimit 		:= c_hopLimit255,
			sourceAddress 	:= p_src,
			destinationAddress := p_dst
		}

		/*
		 *	@param  p_nextHdr Next header identifier value to be used.
		 *	@param  p_hopLimit Number of hops to be used.
		 *	@param  p_src Binary IPv6 address associated with the
		 *          test component.
		 *	@param  p_dst Binary IPv6 address associated with NUT.
	    */
		template Ipv6Header m_ipHdr_nextHdr_hop_srcDst (	UInt8 p_nextHdr,
											UInt8 p_hopLimit,
											template Ipv6Address p_src,
											template Ipv6Address p_dst ) := {
			version 		:= c_ipv6Version ,
			trafficClass 	:= c_trafficClassZero ,
			flowLabel 		:= c_flowLabelZero ,
			payloadLength 	:= c_zeroPayloadLength,
			nextHeader 		:= p_nextHdr,
			hopLimit 		:= p_hopLimit,
			sourceAddress 	:= p_src,
			destinationAddress := p_dst
		}

		/*
		 *	@param  p_nextHdr Next header identifier value to be used.
	    */
		template Ipv6Header mw_ipHdr := {
			version 		:= c_ipv6Version ,
			trafficClass 	:= ?, //c_trafficClassZero ,
			flowLabel 		:= c_flowLabelZero ,
			payloadLength 	:= ?,
			nextHeader 		:= ?,
			hopLimit 		:= ?,
			sourceAddress 	:= ?,
			destinationAddress := ?
		}

		/*
		 *	@param  p_nextHdr Next header identifier value to be used.
	    */
		template Ipv6Header mw_ipHdr_nextHdr ( UInt8 p_nextHdr ) := {
			version 		:= c_ipv6Version ,
			trafficClass 	:= ?, //c_trafficClassZero ,
			flowLabel 		:= c_flowLabelZero ,
			payloadLength 	:= ?,
			nextHeader 		:= p_nextHdr,
			hopLimit 		:= ?,
			sourceAddress 	:= ?,
			destinationAddress := ?
		}

		/*
		 *	@param  p_src Binary IPv6 address associated with the
		 *          test component.
		 *	@param  p_dst Binary IPv6 address associated with NUT.
	    */
		template Ipv6Header mw_ipHdr_srcDst ( template Ipv6Address p_src,
											template Ipv6Address p_dst):= {
			version 		:= c_ipv6Version,
			trafficClass 	:= ? ,
			flowLabel 		:= ? ,
			payloadLength 	:= ?,
			nextHeader 		:= ?,
			hopLimit 		:= ?,
			sourceAddress 	:= p_src,
			destinationAddress := p_dst
		}

		/*
		 *	@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 Ipv6Header mw_ipHdr_nextHdr_srcDst (	template UInt8 p_nextHdr,
												template Ipv6Address p_src,
												template Ipv6Address p_dst) := {
			version 		:= c_ipv6Version ,
			trafficClass 	:= ? ,
			flowLabel 		:= ? ,
			payloadLength 	:= ?,
			nextHeader 		:= p_nextHdr,
			hopLimit 		:= ?,
			sourceAddress 	:= p_src,
			destinationAddress := p_dst
		}

		/*
		 *	@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 Ipv6Header mw_ipHdr_nextHdr_dst (	template UInt8 p_nextHdr,
													template Ipv6Address p_dst) := {
			version 		:= c_ipv6Version ,
			trafficClass 	:= ? ,
			flowLabel 		:= ? ,
			payloadLength 	:= ?,
			nextHeader 		:= p_nextHdr,
			hopLimit 		:= ?,
			sourceAddress 	:= ?,
			destinationAddress := p_dst
		}

		/*
		 *	@param  p_nextHdr Next header identifier value to be used.
		 *	@param  p_hopLimit Number of hops to be used.
		 *	@param  p_src Binary IPv6 address associated with the
		 *          test component.
		 *	@param  p_dst Binary IPv6 address associated with NUT.
	    */
		template Ipv6Header mw_ipHdr_nextHdr_hop_srcDst (
			UInt8 p_nextHdr,
			UInt8 p_hopLimit,
			template Ipv6Address p_src,
			template Ipv6Address p_dst
		) := {
			version 		:= c_ipv6Version ,
			trafficClass 	:= ?,
			flowLabel 		:= ?,
			payloadLength 	:= ?,
			nextHeader 		:= p_nextHdr,
			hopLimit 		:= p_hopLimit,
			sourceAddress 	:= p_src,
			destinationAddress := p_dst
		}

		/*
		 *	@param  p_dst destination address for DAD.
		*/
		template Ipv6Header mw_ipHdr_dAD_unspecSrc_dst (template Ipv6Address p_dst) := {
			version 		:= c_ipv6Version ,
			trafficClass 	:= c_trafficClassZero ,
			flowLabel 		:= c_flowLabelZero ,
			payloadLength 	:= ?,
			nextHeader 		:= c_icmpHdr,
			hopLimit 		:= ?,
			sourceAddress 	:= c_unspecifiedAdd,
			destinationAddress := p_dst
		}

	} // end group ipv6HeaderTemplates

	group extensionHeaderTemplates {

		group extensionHeaderListTemplates {

		/*
		 *	@param  p_extHdr First element in extension header
	    */
		template ExtensionHeaderList m_extHdrList_1Elem ( template ExtensionHeader p_extHdr ) := {
			p_extHdr
		}

		/*
		 *	@param  p_extHdr1 First element in extension header
		 *	@param  p_extHdr2 Second element in extension header
	    */
		template ExtensionHeaderList m_extHdrList_2Elem ( template ExtensionHeader p_extHdr1,
			template ExtensionHeader p_extHdr2
		) := {
			p_extHdr1,
			p_extHdr2
		}

		/*
		 *	@param  p_extHdr1 First element in extension header
		 *	@param  p_extHdr2 Second element in extension header
		 *	@param  p_extHdr3 Second element in extension header		 
		*/
		template ExtensionHeaderList m_extHdrList_3Elem ( template ExtensionHeader p_extHdr1,
			template ExtensionHeader p_extHdr2,
			template ExtensionHeader p_extHdr3	
		) := {
			p_extHdr1,
			p_extHdr2,
			p_extHdr3
		}

		}//end group extensionHeaderListTemplates

		group dstOptHeaderTemplates {

		/*
		 *	@param  p_nextHeader Next header identifier value to be used
		 *	@param  p_hdrExtLen Length of this extension header
		 *	@param  p_optionList List of options that this extension header carries
	    */
		template ExtensionHeader m_extHdr_dstOptHeader (
			UInt8 p_nextHeader,
			UInt8 p_hdrExtLen,
			template DestOptionList p_optionList
		) := {
			destinationOptionHeader := {
				nextHeader := p_nextHeader,
				hdrExtLen := p_hdrExtLen,
				destOptionList := p_optionList
			}
		}

		}//end group dstOptHeaderTemplates

		group fragmentHeaderTemplates {

		/*
		 *	@param  p_nextHeader Next header identifier value to be used
		 *	@param  p_fragmentOffset The offset, in 8-octet units, of the
		 *				data following this header, relative to the start
		 *				of the Fragmentable Part of the original packet.
		 *	@param  p_moreFlag indicates whether there are more segment or not
		 *	@param  p_identification Id of the actual fragment
	    */
		template ExtensionHeader m_extHdr_fragmentHeader (
			UInt8 p_nextHeader,
			UInt13 p_fragmentOffset,
			UInt1 p_moreFlag,
			UInt32 p_identification
		) := {
			fragmentHeader := {
				nextHeader := p_nextHeader,
				reserved1 := c_uInt8Zero,
				fragmentOffset := p_fragmentOffset,
				reserved2 := c_uInt2Zero,
				moreFlag := p_moreFlag,
				identification := p_identification
			}
		}

		}//end group fragmentHeaderTemplates

		group hbhOptHeaderTemplates {

		/*
		 *	@param  p_nextHeader Next header identifier value to be used
		 *	@param  p_hdrExtLen Length of this extension header
		 *	@param  p_optionList List of options that this extension header carries
	    */
		template ExtensionHeader m_extHdr_hbhOptHeader (
			UInt8 p_nextHeader,
			UInt8 p_hdrExtLen,
			template HopByHopOptionList p_optionList
		) := {
			hopByHopHeader := {
				nextHeader := p_nextHeader,
				hdrExtLen := p_hdrExtLen,
				hopByHopOptionList := p_optionList
			}
		}

		}//end hbhOptHeaderTemplates

		group routingHeaderTemplates {

		/*
		 *	@param  p_nextHeader Next header identifier value to be used
		 *	@param  p_hdrExtLen Length of this extension header in 8-octet units
		 *	@param  p_routingType Type of the routing header
		 *	@param  p_segmentsLeft Number of route segments remaining
		 *	@param  p_routingHeaderData A list of IPv6 addresses
	    */
		template ExtensionHeader m_extHdr_routingHeader (
			UInt8 p_nextHeader,
			UInt8 p_hdrExtLen,
			UInt8 p_routingType,
			UInt8 p_segmentsLeft,
			template RoutingHeaderData p_routingHeaderData
		) := {
			routingHeader := {
				nextHeader := p_nextHeader,
				hdrExtLen := p_hdrExtLen,
				routingType := p_routingType,
				segmentsLeft := p_segmentsLeft,
				reserved := c_uInt32Zero,
				routingHeaderData := p_routingHeaderData
			}
		}

		/*
		 *	@param  p_nextHeader Next header identifier value to be used
		 *	@param  p_hdrExtLen Length of this extension header in 8-octet units
		 *	@param  p_routingType Type of the routing header
		 *	@param  p_segmentsLeft Number of route segments remaining
		 *	@param  p_routingHeaderData A list of IPv6 addresses
	    */
		template ExtensionHeader mw_extHdr_routingHeader (
			UInt8 p_nextHeader,
			UInt8 p_hdrExtLen,
			UInt8 p_routingType,
			UInt8 p_segmentsLeft,
			template RoutingHeaderData p_routingHeaderData
		) := {
			routingHeader := {
				nextHeader := p_nextHeader,
				hdrExtLen := p_hdrExtLen,
				routingType := p_routingType,
				segmentsLeft := p_segmentsLeft,
				reserved := ?,
				routingHeaderData := p_routingHeaderData
			}
		}


		/*
		 *	@param  p_ipv6Address First IPv6 address in the routing header
		*/
		template RoutingHeaderData m_routingHeaderData_ipv6AddressList_1Elem ( template Ipv6Address p_ipv6Address ) := {
			rtHdrDataIpv6AddressList := {
				p_ipv6Address
			}
		}

		/*
		 *	@param  p_ipv6Address First IPv6 address in the routing header
		*/
		template RoutingHeaderData m_routingHeaderData_homeAddress ( template Ipv6Address p_ipv6Address ) := {
			rtHdrDataHomeAddress := p_ipv6Address
		}


		}//end group routingHeaderTemplates
		
		group mipHeaderTemplates {

	
			template ExtensionHeader m_extHdr_mipHeader ( 	UInt8 p_payloadProtocol,
															UInt8 p_mobilityHeaderType,
															template MipMessage p_mipMessage) := {
				mipHeader := {
					payloadProtocol := p_payloadProtocol,
					headerLen := c_uInt8Zero,
					mobilityHeaderType := p_mobilityHeaderType,  
					reserved := c_uInt8Zero,           
					checksum := c_2ZeroBytes,     
					mipMessage := p_mipMessage
				}
			}

			template ExtensionHeader mw_extHdr_mipHeader ( 	UInt8 p_payloadProtocol,
															UInt8 p_mobilityHeaderType,
															template MipMessage p_mipMessage) := {
				mipHeader := {
					payloadProtocol := p_payloadProtocol,
					headerLen := ?,
					mobilityHeaderType := p_mobilityHeaderType,  
					reserved := ?,           
					checksum := ?,     
					mipMessage := p_mipMessage
				}
			}



		}//end group mipHeaderTemplates

		group tunnelHdrTemplates {
			
		/*	@desc	Tunnel Hdr can use copy of IPv6Header for all fields except nextHdr
		 *			However, here no copies are used, but Zero Values.
		 *	@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 ExtensionHeader m_extHdr_tunneledHeader(	UInt8 p_nextHdr,
										template Ipv6Address p_src,
										template Ipv6Address p_dst) := {
			tunneledIpv6 := {
				version 		:= c_ipv6Version ,
				trafficClass 	:= c_trafficClassZero ,
				flowLabel 		:= c_flowLabelZero ,
				payloadLength 	:= c_zeroPayloadLength, //16
				nextHeader 		:= p_nextHdr,
				hopLimit 		:= c_hopLimit255,
				sourceAddress 	:= p_src,
				destinationAddress := p_dst
			}
		}

		/*	@desc	Tunnel Hdr can use copy of IPv6Header for all fields except nextHdr
		 *			However, here no copies are used, but Zero Values.
		 *	@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 ExtensionHeader mw_extHdr_tunneledHeader(	UInt8 p_nextHdr,
										template Ipv6Address p_src,
										template Ipv6Address p_dst) := {
			tunneledIpv6 := {
				version 		:= c_ipv6Version ,
				trafficClass 	:= ? ,
				flowLabel 		:= ? ,
				payloadLength 	:= ?, 
				nextHeader 		:= p_nextHdr,
				hopLimit 		:= ?,
				sourceAddress 	:= p_src,
				destinationAddress := p_dst
			}
		}
			
		}//end group tunnelHdrTemplates

	} // end extensionHeader

	group generalIpv6MessageTemplates{

		/*
		 *	@param  p_nextHeader Next header identifier value to be used.
		 *	@param  p_extHdrList List of extension header in the packet.
		 *	@param  p_src Binary IPv6 address associated with the
		 *          test component.
		 *	@param  p_dst Binary IPv6 address associated with NUT.
		 *	@param  p_data Data sent in the Echo Request packet.
		*/
		template GeneralIpv6 m_generalIpv6_extHdr_srcDst_data (
			UInt8 p_nextHeader,
			template ExtensionHeaderList p_extHdrList,
			template Ipv6Address p_src,
			template Ipv6Address p_dst,
			octetstring p_data
		) := {
			ipv6Hdr := m_ipHdr_nextHdr_srcDst(p_nextHeader, p_src, p_dst),
			extHdrList := p_extHdrList,
			data:= p_data
		}

		/*
		 *	@param  p_nextHeader Next header identifier value to be used.
		 *	@param  p_extHdrList List of extension header in the packet.
		 *	@param  p_src Binary IPv6 address associated with the
		 *          test component.
		 *	@param  p_dst Binary IPv6 address associated with NUT.
		 *
		*/
//		template GeneralIpv6 mw_extHdr_srcDst(
//			UInt8 p_nextHeader,
//			template ExtensionHeaderList p_extHdrList,
//			template Ipv6Address p_src,
//			template Ipv6Address p_dst
//		) := {
//			ipv6Hdr := mw_ipHdr_nextHdr_srcDst(p_nextHeader, p_src, p_dst),
//			extHdrList := p_extHdrList,
//			data:= omit
//		}

		/*
		 *	@param  p_nextHeader Next header identifier value to be used.
		 *	@param  p_extHdrList List of extension header in the packet.
		 *	@param  p_src Binary IPv6 address associated with the
		 *          test component.
		 *	@param  p_dst Binary IPv6 address associated with NUT.
		*/
		template GeneralIpv6 mw_generalIpv6_extHdr_srcDst (
			UInt8 p_nextHeader,
			template ExtensionHeaderList p_extHdrList,
			template Ipv6Address p_src,
			template Ipv6Address p_dst
		) := {
			ipv6Hdr := mw_ipHdr_nextHdr_srcDst(p_nextHeader, p_src, p_dst),
			extHdrList := p_extHdrList,
			data:= *
		}

    } //end group generalIpv6MessageTemplates

	group ipPacketsWithOnlyExtensionHdrsTemplates {
		
		/*
		 *	@param  p_nextHeader Next header identifier value to be used.
		 *	@param  p_extHdrList List of extension header in the packet.
		 *	@param  p_src Binary IPv6 address associated with the
		 *          test component.
		 *	@param  p_dst Binary IPv6 address associated with NUT.
		 *
		*/
		template GeneralIpv6 m_generalIpv6_srcDst(
			UInt8 p_nextHeader,
			template Ipv6Address p_src,
			template Ipv6Address p_dst,
			template ExtensionHeaderList p_extHdrList
		) := {
			ipv6Hdr := m_ipHdr_nextHdr_srcDst(p_nextHeader, p_src, p_dst),
			extHdrList := p_extHdrList,
			data := omit
		}

		/*
		 *	@param  p_nextHeader Next header identifier value to be used.
		 *	@param  p_extHdrList List of extension header in the packet.
		 *	@param  p_src Binary IPv6 address associated with the
		 *          test component.
		 *	@param  p_dst Binary IPv6 address associated with NUT.
		 *
		*/
		template GeneralIpv6 mw_generalIpv6_srcDst(
			UInt8 p_nextHeader,
			template Ipv6Address p_src,
			template Ipv6Address p_dst,
			template ExtensionHeaderList p_extHdrList
		) := {
			ipv6Hdr := mw_ipHdr_nextHdr_srcDst(p_nextHeader, p_src, p_dst),
			extHdrList := p_extHdrList,
			data := *
		}

		/*
		 *	@param  p_nextHeader Next header identifier value to be used.
		 *	@param  p_extHdrList List of extension header in the packet.
		 *	@param  p_src Binary IPv6 address associated with the
		 *          test component.
		 *	@param  p_dst Binary IPv6 address associated with NUT.
		 *
		*/
		template GeneralIpv6 mw_generalIpv6_dst(
			UInt8 p_nextHeader,
			template Ipv6Address p_dst,
			template ExtensionHeaderList p_extHdrList
		) := {
			ipv6Hdr := mw_ipHdr_nextHdr_dst(p_nextHeader, p_dst),
			extHdrList := p_extHdrList,
			data := *
		}
		
	}//end group ipPacketsWithOnlyExtensionHdrsTemplates

    group ipv6AddressTemplates {

        template Ipv6Address mw_anyIpv6Address := ?

    } //end group ipv6AddressTemplates

} // end module LibIpv6_Rfc2460Root_Templates
+219 −0

File added.

Preview size limit exceeded, changes collapsed.

+410 −0

File added.

Preview size limit exceeded, changes collapsed.

+1504 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading