Commit 924124af authored by seb's avatar seb
Browse files

LibCommon added

extHdr added
parent fa7e3426
Loading
Loading
Loading
Loading
+5 −42
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@
 *              based on the common IPv6 message types only.  
 *  
 */
 module LibIpv6_MultiRfcs_Functions {
 module LibIpv6_CommonRfcs_Functions {

	//LibCommon
	import from LibCommon_BasicTypesAndValues all;
@@ -15,10 +15,11 @@
	import from LibIpv6_ExternalFunctions all;
	import from LibIpv6_Interface all ;
	import from LibIpv6_ModuleParameters all ;
	import from LibIpv6_MultiRfcs_TypesAndValues all;
	import from LibIpv6_MultiRfcs_Templates all;
	import from LibIpv6_CommonRfcs_TypesAndValues all;
	import from LibIpv6_CommonRfcs_Templates all;
	import from LibIpv6_Rfc2460Root_TypesAndValues { type all; const all };
	import from LibIpv6_Rfc2460Root_Templates all;
	import from LibIpv6_Rfc3775Mipv6_ExtHdrFunctions all;

group extHdrFns {

@@ -172,45 +173,8 @@ group extHdrFns {
	}//end group calcPrefixFns

	
	group mipHdrFns {



	/*
	 * @desc 	This goes through the Mip header and calculates length, checksum
	 *			and other specific functions of the different messages
	 * @param 	p_msg ExtensionHeaderList to be treated	
	 * @return 	execution status 
	*/
	function f_setMipHeader(in Ipv6Address p_srcAddr,
							in Ipv6Address p_dstAddr,
							inout MipHeader p_mipHeader)
	runs on LibIpv6Node
	return FncRetCode {
		var MipHeader v_mipHeader := valueof(p_mipHeader);
		var Ipv6Address v_homeAddress := c_16ZeroBytes ;

		if (ischosen(p_mipHeader.mipMessage.homeTestInit)) {
			//calc homeNonceIndex TODO
			//calc homeInitCookie TODO
			//calc homeKeygenToken TODO	
		}
		else if (ischosen(p_mipHeader.mipMessage.homeTest)) {
			//calc homeNonceIndex TODO
			//calc homeInitCookie TODO
			//calc homeKeygenToken TODO	
		}
		//calc mipHeaderLen
		p_mipHeader.headerLen := fx_mipHeaderLength(p_mipHeader);
		//set mipChecksum to zero
		p_mipHeader.checksum := c_2ZeroBytes;  
		//calc mipChecksum
		p_mipHeader.checksum := fx_mipHeaderChecksum(	p_srcAddr,
														p_dstAddr,
														p_mipHeader);
		return e_success;
	}

	/*
	 * @desc 	This goes through the ExtensionHeaderList and
	 *			checks if a HomeAddressOption is present.
@@ -355,10 +319,9 @@ group extHdrFns {
		return v_spi;
	}//end f_createSecurityParametersIndex

}//end group mipHdrFns



	
} // end module LibIpv6_MultiRfcs_Functions
} // end module LibIpv6_CommonRfcs_Functions
	
+166 −0
Original line number Diff line number Diff line
@@ -6,13 +6,13 @@
 *              IPv6 header, or extension headers
 *  
 */
module LibIpv6_MultiRfcs_Templates {
module LibIpv6_CommonRfcs_Templates {
	
	//LibCommon
	import from LibCommon_BasicTypesAndValues all;
	import from LibCommon_DataStrings all;
	//LibIpv6
	import from LibIpv6_MultiRfcs_TypesAndValues all;
	import from LibIpv6_CommonRfcs_TypesAndValues all;
	import from LibIpv6_ModuleParameters all;

	group link_Layer_Address {
@@ -162,169 +162,5 @@ module LibIpv6_MultiRfcs_Templates {

	}//end group nbrDiscOptions

	group mobilityHdrMessageTemplates {

		
		template MipMessage m_bindingUpdate(	UInt16 p_seqNr,
												UInt1 p_aFlag,
												UInt1 p_hFlag,
												UInt1 p_lFlag,
												UInt1 p_kFlag,
												UInt16 p_lifeTime,
												template MipOptionList p_mipOptions) := {	
			bindingUpdate := {
				sequenceNumber := p_seqNr,
				aFlag := p_aFlag,
				hFlag := p_hFlag,
				lFlag := p_lFlag,
				kFlag := p_kFlag,
				reserved := c_uInt12Zero,
				lifeTime := p_lifeTime,		
				mipOptions := p_mipOptions
			}
		}

		template MipMessage mw_bindingUpdate(	UInt1 p_aFlag,
												UInt1 p_hFlag,
												UInt1 p_lFlag,
												UInt1 p_kFlag,
												template MipOptionList p_mipOptions) := {	
			bindingUpdate := {
				sequenceNumber := ?,
				aFlag := p_aFlag,
				hFlag := p_hFlag,
				lFlag := p_lFlag,
				kFlag := p_kFlag,
				reserved := c_uInt12Zero,
				lifeTime := ?,		
				mipOptions := p_mipOptions
			}
		}
		
		template MipMessage mw_bindingUpdate_lifeTime(	UInt1 p_aFlag,
												UInt1 p_hFlag,
												UInt1 p_lFlag,
												UInt1 p_kFlag,
												UInt16 p_lifetime,
												template MipOptionList p_mipOptions) := {	
			bindingUpdate := {
				sequenceNumber := ?,
				aFlag := p_aFlag,
				hFlag := p_hFlag,
				lFlag := p_lFlag,
				kFlag := p_kFlag,
				reserved := c_uInt12Zero,
				lifeTime := p_lifetime,		
				mipOptions := p_mipOptions
			}
				}

		template MipMessage m_bindingAck(UInt16 p_seqNr, UInt16 p_lifetime, template MipOptionList p_mipOptions) := {	
			bindingAck := {
				status := c_mipCodeBindingUpdateAccepted,
				kFlag := c_kFlag0,
				reserved := c_uInt7Zero,
				sequenceNumber := p_seqNr,
				lifeTime := p_lifetime,		
				mipOptions := p_mipOptions
			}
		}

		template MipMessage mw_bindingAck(UInt16 p_seqNr) := {	
			bindingAck := {
				status := c_mipCodeBindingUpdateAccepted,
				kFlag := ?,
				reserved := ?,
				sequenceNumber := p_seqNr,
				lifeTime := ?,		
				mipOptions := ?
			}
		}
		
		template MipMessage mw_bindingError := {	
			bindingError := {
				status := ?,
				reserved := ?,
				homeAddress := ?,		
				mipOptions := *
			}	
		}
		
		template MipMessage m_hot := {	
			homeTest := {
				homeNonceIndex := c_uInt16Zero,
				homeInitCookie := c_64ZeroBits,
				homeKeygenToken := c_64ZeroBits,
				mipOptions := omit
			}
		}

		template MipMessage mw_hot := {	
			homeTest := {
				homeNonceIndex := ?,
				homeInitCookie := ?,
				homeKeygenToken := ?,
				mipOptions := *
			}
		}

		template MipMessage m_hoti := {	
			homeTestInit := {
				reserved := c_uInt16Zero,
				homeInitCookie := c_64ZeroBits,
				mipOptions := omit
			}
		}


		template MipMessage mw_hoti := {	
			homeTestInit := {
				reserved := ?,
				homeInitCookie := ?,
				mipOptions := *
			}
		}


	}//end group mobilityHdrMessageTemplates


	group mobilityOptTemplates {

		/*
		 *	@param  p_dstOpt First element in the Destination option list
		*/
		template MipOptionList m_mipOptList_1Elem ( template MipOption p_mipOpt ) := {
			p_mipOpt
		}

		/*
		 *	@param  p_dstOpt First element in the Destination option list
		*/
		template MipOptionList m_mipOptList_2Elem ( template MipOption p_mipOpt1, template MipOption p_mipOpt2 ) := {
			p_mipOpt1, p_mipOpt2
		}

		template MipOption m_mipOpt_altCoa(template MipOptAltCoA p_mipOptAltCoA) := {
			mipOptAltCoA := p_mipOptAltCoA
		}

		template MipOption m_mipOpt_padN(template OptPadN p_optPadN) := {
			optPadN := p_optPadN
		}

		template MipOptAltCoA m_mipOptAltCoA(in template Ipv6Address p_addr) := {
			mipOptType :=3,
			mipOptLen := 16,
			alternateCoA := p_addr
		}

		template MipOptAltCoA mw_mipOptAltCoA := {
			mipOptType :=3,
			mipOptLen := 16,
			alternateCoA := ?
		}
		
	}//end group mobilityOptTemplates

} // end module LibIpv6_MultiRfcs_Templates
} // end module LibIpv6_CommonRfcs_Templates
+20 −324
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@
 *              addresses, and extension headers. 
 *              Types have been derived from various RFCs.
 */
module LibIpv6_MultiRfcs_TypesAndValues {
module LibIpv6_CommonRfcs_TypesAndValues {
	
	//LibCommon
	import from LibCommon_BasicTypesAndValues all;
@@ -158,10 +158,7 @@ module LibIpv6_MultiRfcs_TypesAndValues {
			*/
			const UInt8		c_optJumboPayload := 194; 

			/*
			 * @desc Derived from ietf-mobileip-ipv6-24
			*/
			const UInt8		c_optHomeAddress := 201; 
		
		}

		group ExtensionHeaderIds {
@@ -450,7 +447,6 @@ module LibIpv6_MultiRfcs_TypesAndValues {

		}//end group rfc2461Options


		group rfc3775Options {

		/*
@@ -495,10 +491,26 @@ module LibIpv6_MultiRfcs_TypesAndValues {
			encode "present=bytes(0,1,201);intTag='hdrExtIntLen',getIntTag('hdrExtIntLen')-18";
		}

		group optionValues {
			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;
		}

			/*
			 * @desc Derived from ietf-mobileip-ipv6-24
			*/
			const UInt8		c_optHomeAddress := 201; 


		}//end group rfc3775Options


	

	} // end ipv6Options

	group sharedExtensionHeaders {
@@ -523,327 +535,11 @@ module LibIpv6_MultiRfcs_TypesAndValues {
//			octetstring			integrityCheckValue
//		}

		type record EspHeader {
			// Header
			UInt32				securityParametersIndex,
			UInt32				sequenceNumber,		
			octetstring			iv optional
		}
		
	}//end group espHeader

	/*
	 * @desc Derived from RFC4302 clause 2. 
	 *       The payloadLen is specified in unit of 4 Octets minus 2
	*/
	group authHeader {
		type record AuthHeader {
			UInt8		nextHeader,
			UInt8		payloadLen,
			UInt16		reserved,
			UInt32		securityParametersIndex,
			UInt32		sequenceNumber,
			octetstring	icv			
		}
	}//end group authHeader
	
	type record OtherIpv6ExtHdr {
		UInt8		nextHeader,
		UInt8		hdrLen,
		octetstring data optional
	} 
		
	group mipHeader {

	/*
	 * @desc Derived from RFC3775 clause 6.1.1. NoNextHeader 
	 *       should be used as default value for payloadProtocol.
	 *       The headerLen is to specified in unit of 8 Octets excluding
	 *       zero.
	*/
	type record MipHeader {
		UInt8		payloadProtocol,
		UInt8		headerLen,
		UInt8		mobilityHeaderType,  
		UInt8		reserved,           
		Oct2		checksum,     
		MipMessage	mipMessage
	}
	with {
		encode "isPDU=used for external function only!";
		encode (headerLen) "tag='hdrIntLen'";
		encode (mobilityHeaderType) "tag='mobilityHeaderType'";
	}

	

	group mipRfc3775Messages {
		
		type union MipMessage {
			BindingRefreshRequest 	bindingRefreshRequest,
			HomeTestInit 			homeTestInit,
			CareOfTestInit 			careOfTestInit,
			HomeTest 				homeTest,
			CareOfTest 				careOfTest,
			BindingUpdate 			bindingUpdate,
			BindingAck 				bindingAck,
			BindingError 			bindingError
		} 

		/*
		 * @desc Derived from  RFC3775 clause 6.1.2
		*/
		type record 	BindingRefreshRequest {
	        UInt16   		reserved,
        	MipOptionList 	mipOptions optional
		}
		with {
			encode "present=isEOF()== false && (valueOf(getTag('mobilityHeaderType'))==0);";
		}
		
		/*
		 * @desc Derived from  RFC3775 clause 6.1.3
		*/
		type record 	HomeTestInit{
			UInt16 		reserved,
			Bit64 		homeInitCookie,
			MipOptionList 		mipOptions optional
		}
		with {
			encode "present=isEOF()== false && (valueOf(getTag('mobilityHeaderType'))==1);";
		}
		
		/*
		 * @desc Derived from  RFC3775 clause 6.1.4
		*/
		type record 	CareOfTestInit {
			UInt16 		reserved,
			Bit64 		careOfInitCookie,
			MipOptionList 		mipOptions optional
		}
		with {
			encode "present=isEOF()== false && (valueOf(getTag('mobilityHeaderType'))==2);";
		}


		/*
		 * @desc Derived from  RFC3775 clause 6.1.5
		*/
		type record 	HomeTest {
			UInt16 		homeNonceIndex,
			Bit64 		homeInitCookie,
			Bit64 		homeKeygenToken,
			MipOptionList 		mipOptions optional
		}
		with {
			encode "present=isEOF()== false && (valueOf(getTag('mobilityHeaderType'))==3);";
		}

		/*
		 * @desc Derived from  RFC3775 clause 6.1.6
		*/
		type record 	CareOfTest {
			UInt16 		careOfNonceIndex,
			Bit64 		careOfInitCookie,
			Bit64 		careOfKeygenToken,
			MipOptionList 		mipOptions optional
		}
		with {
			encode "present=isEOF()== false && (valueOf(getTag('mobilityHeaderType'))==4);";
		}

		/* 
		 * @desc Derived from RFC3775 clause 6.1.7
		 *       Valid mipOptions are only the Binding Authorization Data  
		 *       (mandatory in Binding Updates sent to a correspondent 
    	 *		 node), Nonce indicates option, and Alternate Care-of 
		 *	     Address options 
		*/
		type record 	BindingUpdate {
			UInt16 		sequenceNumber,
			UInt1		aFlag, // = acknowledge
			UInt1		hFlag, // = homeRegistration
			UInt1		lFlag, // = linkLocalAddressCompatiability
			UInt1		kFlag, // = keyManagementMobilityCapability,
			UInt12		reserved,
			UInt16		lifeTime,		
			MipOptionList mipOptions optional
		}
		with {
			encode "present=isEOF()== false && (valueOf(getTag('mobilityHeaderType'))==5);";
		}

		/*
		 * @desc Derived from  RFC3775 clause 6.1.8
		*/
		type record 	BindingAck{
			UInt8		status,
			UInt1		kFlag,//keyManagementMobilityCapability,
			UInt7		reserved,
			UInt16 		sequenceNumber,
			UInt16		lifeTime,		
			MipOptionList 	mipOptions
		}
		with {
			encode "present=isEOF()== false && (valueOf(getTag('mobilityHeaderType'))==6);";
		}

		/*
		 * @desc Derived from  RFC3775 clause 6.1.9
		*/
		type record 	BindingError {
			UInt8		status,
			UInt8		reserved,
			Oct16		homeAddress,		
			MipOptionList 	mipOptions optional
		}
		with {
			encode "present=isEOF()== false && (valueOf(getTag('mobilityHeaderType'))==7);";
		}
		
	} // end mipRFC3775Messages

	group mipOptions {
		
		type set length(1 .. c_maxMipOptions) of MipOption MipOptionList;

		type union MipOption {
			OptPad1							optPad1,
			OptPadN							optPadN,
			MipOptBindingRefreshAdvice		mipOptBindingRefreshAdvice,
			MipOptAltCoA					mipOptAltCoA,
			MipOptNonceIndices				mipOptNonceIndices,
			MipBindingAuthorizationData		mipBindingAuthorizationData
		}
		
		/*
		 * @desc Derived from RFC 3775 Section 6.2.2
		*/
	//	type record MipOptPad1 {
	//		UInt8		pad (0)
	//	}

		/* 
		 * @desc Derived from RFC3775 Section 6.2.3 For N octets of  
		 *       padding, the Option Length field should contain the value 
		 *       N-2 and a padding of N-2 zero-valued octets.
		*/
	//	type record MipOptPadN {
	//		UInt8	mipOptType (1),
	//		UInt8	mipOptLen,
	//		octetstring	padding 
	//	}

		/*
		 * @desc Derived from RFC3775 Section 6.2.4
		*/
		type record MipOptBindingRefreshAdvice {
			UInt8	mipOptType (2),
			UInt8	mipOptLen (2),
			UInt16	refreshInterval
		}
		with {
			encode "present=bytes(0,1,2);";
		}
		
		/*
		 * @desc Derived from RFC3775 Section 6.2.5
		*/
		type record MipOptAltCoA {
			UInt8	mipOptType (3),
			UInt8	mipOptLen (16),
			Oct16	alternateCoA
		}
		with {
			encode "present=bytes(0,1,3);";
		}

		/*
		 * @desc Derived from RFC3775 Section 6.2.6
		*/
		type record MipOptNonceIndices {
			UInt8	mipOptType (4),
			UInt8	mipOptLen (4),
			UInt16	homeNonceIndex,
			UInt16	careOfNonceIndex
		}
		with {
			encode "present=bytes(0,1,4);";
		}

		/*
		 * @desc Derived from RFC3775 Section 6.2.7. Note that the
		 *       authenticator value depends on the used author procedure.
		*/
		type record MipBindingAuthorizationData {
			UInt8	mipOptType (5),
			UInt8	mipOptLen,
			octetstring	authenticator 
		}
		with {
			encode "present=bytes(0,1,5);";
			encode (mipOptLen) "tag='mipOptLen';";
			encode (authenticator) "length=valueOf(getTag('mipOptLen'));";
		}
		
	} // end mipOptions

	group mipConstants {
	
		const UInt8 c_maxMipOptions:=10;
		
		group mipMessageValues {
			
			const UInt16 c_100TimeUnits := 100 ;
			const UInt16 c_zeroTimeUnits := 0 ;
	}//end group espHeader

		}//end group MipMessageValues

		group mipHeaderValues {		
			const UInt8	c_bindingRefreshRequest := 0;
			const UInt8	c_homeTestInit := 1;
			const UInt8	c_careOfTestInit := 2;
			const UInt8	c_homeTest := 3;
			const UInt8	c_careOfTest := 4;
			const UInt8	c_bindingUpdate := 5;
			const UInt8	c_bindingAck := 6;	
			const UInt8	c_bindingError := 7;
			//todo add alias headertype
		}

		group optionValues {
			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;
		}

		/*
		*  @desc This values should be used in BindingAcknowledgement 
		*        messages 
		*/
		group statusCodesValues { 
			const UInt8 c_mipCodeBindingUpdateAccepted := 0;
			const UInt8 c_mipCodeAcceptedButPrefixDiscoveryNecessary := 1;
			const UInt8 c_mipCodeReasonUnspecified := 128;
			const UInt8 c_mipCodeAdministrativelyProhibited := 129;
			const UInt8 c_mipCodeInsufficientResources := 130;
			const UInt8 c_mipCodeHomeRegistrationNotSupported := 131;
			const UInt8 c_mipCodeNotHomeSubnet := 132;
			const UInt8 c_mipCodeNotHomeAgentForThisMobileNode := 133;
			const UInt8 c_mipCodeDuplicateAddressDetectionFailed := 134;
			const UInt8 c_mipCodeSequenceNumberOutofWindow := 135;
			const UInt8 c_mipCodeExpiredHomeNonceIndex := 136;
			const UInt8 c_mipCodeExpiredCareofNonceIndex := 137;
			const UInt8 c_mipCodeExpiredNonces := 138;
			const UInt8 c_mipCodeRegistrationTypeChangeDisallowed := 139;
		}	//end group statusCodesValues
		
	}//end 	group mipConstants
	
	}//end group mipHeader
	
	} // end sharedExtensionHeaders
		
@@ -859,4 +555,4 @@ module LibIpv6_MultiRfcs_TypesAndValues {
	} // end security


}
} // end LibIpv6_CommonRfcs_TypesAndValues
+3 −1
Original line number Diff line number Diff line
@@ -13,10 +13,12 @@
	import from LibCommon_BasicTypesAndValues all;
	import from LibCommon_DataStrings all;
	//LibIpv6
	import from LibIpv6_MultiRfcs_TypesAndValues { type all };
	import from LibIpv6_CommonRfcs_TypesAndValues { type all };
	import from LibIpv6_Interface { type Ipv6Packet };
	import from LibIpv6_Rfc2460Root_TypesAndValues {type all};

	import from LibIpv6_Rfc3775Mipv6_ExtHdrTypesAndValues all;


	/* @desc    This external function calculates the payload length
	 *			of a IPv6 packet
Loading