Commit 6d6fde26 authored by berge's avatar berge
Browse files

misc bugs fixed

parent 4e3992d3
Loading
Loading
Loading
Loading
+83 −25
Original line number Diff line number Diff line
@@ -76,38 +76,45 @@ group rfc2460Root_Functions {
		var UInt8 i;
		var Ipv6Address v_homeAddress := c_16ZeroBytes;
		var UInt8 v_nrOfTunnelHdr := 0;
		var Ipv6Address v_pseudoSrcAddr := c_16ZeroBytes;
		var Ipv6Address v_pseudoDstAddr := c_16ZeroBytes;

		for (i:=0; i<sizeof(p_extHdrList);i:=i+1) {
			if (ischosen(p_extHdrList[i].mobileHeader)) {
				if (f_isPresentHomeAddressOption(p_extHdrList, v_homeAddress) == e_success) {
					v_ret := f_setMobileHeader(	v_homeAddress,
									p_dstAddr,
									p_extHdrList[i].mobileHeader,
									p_ipv6Packet);	
				if (f_isPresentHomeAddressOption(p_extHdrList, v_homeAddress) == e_success) {//used in all packets that are sent to registered CN
					v_pseudoSrcAddr := v_homeAddress;
					v_pseudoDstAddr := p_dstAddr;
				}
				else if (f_isPresentRoutingHeaderType2(p_extHdrList, v_homeAddress) == e_success) {
					v_ret := f_setMobileHeader(	p_srcAddr,
									v_homeAddress,									
									p_extHdrList[i].mobileHeader,
									p_ipv6Packet);	
					v_pseudoSrcAddr := p_srcAddr;					
					v_pseudoDstAddr := v_homeAddress;
				}
				else {
					v_pseudoSrcAddr := p_srcAddr;					
					v_pseudoDstAddr := p_dstAddr;
				}
				
				v_ret := f_setMobileHeader(	p_srcAddr,
											p_dstAddr,
									p_extHdrList[i].mobileHeader,
									p_ipv6Packet);
				}
											v_pseudoSrcAddr,					
											v_pseudoDstAddr,
											p_extHdrList[i].mobileHeader);
			}
			else if (ischosen(p_extHdrList[i].tunneledIpv6)) {
				v_nrOfTunnelHdr := v_nrOfTunnelHdr + 1;
				p_extHdrList[i].tunneledIpv6.payloadLength := fx_tunnelledPayloadLength(p_ipv6Packet, v_nrOfTunnelHdr);
				
				// Tunneled header is the active packet
				p_srcAddr := p_extHdrList[i].tunneledIpv6.sourceAddress;
				p_dstAddr := p_extHdrList[i].tunneledIpv6.destinationAddress;

			}
		/*	else if (ischosen(p_extHdrList[i].)) {
				f_setSecurityHdr();
			}  */
		}//end for

		return e_success;
		return v_ret;
	}//end f_setExtensionHeaders
		
	}//end group extHdrFns
@@ -128,8 +135,9 @@ group rfc3775Mipv6_ExtHdrFunctions {
	*/
	function f_setMobileHeader(	in Ipv6Address p_srcAddr,
								in Ipv6Address p_dstAddr,
							inout MobileHeader p_mobileHeader,
							in Ipv6Packet p_ipv6Packet)
								in Ipv6Address p_pseudoSrcAddr, 
								in Ipv6Address p_pseudoDstAddr, 	
								inout MobileHeader p_mobileHeader)
	runs on LibIpv6Node
	return FncRetCode {
		var MobileHeader v_mobileHeader := valueof(p_mobileHeader);
@@ -184,7 +192,7 @@ group rfc3775Mipv6_ExtHdrFunctions {
							vc_mobileSec.mnSimuParams.kbm := fx_mac(		e_sha1, c_1ZeroByte,
																			bit2oct(vc_mobileSec.mnSimuParams.receivedHomeKeygenToken));	
						}
						// ok 'til here												
											
						//set Authenticator option with dummy Authenticator
						p_mobileHeader.mobileMessage.bindingUpdateMsg.mobileOptions[v_position].mobileBindingAuthorizationData := {
														mobileOptType := 5,
@@ -199,7 +207,7 @@ group rfc3775Mipv6_ExtHdrFunctions {
				
						p_mobileHeader.mobileMessage.bindingUpdateMsg.mobileOptions[v_position].mobileBindingAuthorizationData.authenticator 
								 := fx_mac(	e_hmac_sha1_96, vc_mobileSec.mnSimuParams.kbm,
																		p_ipv6Packet.ipv6Hdr.sourceAddress // p_srcAddr //careOfaddr 
																		p_srcAddr //careOfaddr 
																		& p_dstAddr //cnAddr
																		& fx_mipHdrToOct(p_mobileHeader) );
				}
@@ -222,8 +230,8 @@ group rfc3775Mipv6_ExtHdrFunctions {
		//calc mipChecksum only when its set to c_2ZeroBytes
		// do no calc mipChecksum , but use the checksum from the template
		if (p_mobileHeader.checksum == c_2ZeroBytes) {
			p_mobileHeader.checksum := fx_mipHeaderChecksum ( p_srcAddr,
															p_dstAddr,
			p_mobileHeader.checksum := fx_mipHeaderChecksum ( 	p_pseudoSrcAddr, 
																p_pseudoDstAddr, 
																p_mobileHeader);
		}

@@ -231,6 +239,56 @@ group rfc3775Mipv6_ExtHdrFunctions {
	}
		

	function f_checkAuthenticator (	in Ipv6Address p_srcAddr,
									in Ipv6Address p_dstAddr,
									in MobileHeader p_mobileHeader,
									in octetstring p_receivedAuthenticator)
	runs on LibIpv6Node 
	return FncRetCode {
		var UInt8 v_position := 0;
		var octetstring v_computedAuthenticator;
		
		if (f_isPresentBindingAuthorizationDataOption(p_mobileHeader.mobileMessage.bindingUpdateMsg, v_position) == e_success) {
				
			if (p_mobileHeader.mobileMessage.bindingUpdateMsg.lifeTime != 0) {
				vc_mobileSec.cnSimuParams.kbm := fx_mac(		e_sha1, c_1ZeroByte,
																bit2oct(vc_mobileSec.cnSimuParams.homeKeygenToken)
																& bit2oct(vc_mobileSec.cnSimuParams.careOfKeygenToken));
			}
			else {
				vc_mobileSec.cnSimuParams.kbm := fx_mac(		e_sha1, c_1ZeroByte,
																bit2oct(vc_mobileSec.cnSimuParams.homeKeygenToken));	
			}
									
			//set Authenticator option with dummy Authenticator
			p_mobileHeader.mobileMessage.bindingUpdateMsg.mobileOptions[v_position].mobileBindingAuthorizationData := {
											mobileOptType := 5,
											mobileOptLen := 12,
											authenticator := c_12ZeroBytes}
																
			//calculate the mipHeaderLength over the dummy Authenticator
			p_mobileHeader.headerLen := fx_mipHeaderLength(p_mobileHeader) ;
				
			//set Authenticator to omit in order to calc the authenticator
			p_mobileHeader.mobileMessage.bindingUpdateMsg.mobileOptions[v_position].mobileBindingAuthorizationData.authenticator := omit;
		
			v_computedAuthenticator := fx_mac(	e_hmac_sha1_96, vc_mobileSec.cnSimuParams.kbm,
												p_srcAddr //careOfaddr 
												& p_dstAddr //cnAddr
												& fx_mipHdrToOct(p_mobileHeader) );
												
			if (p_receivedAuthenticator != v_computedAuthenticator) {
				return e_error;
			}
			
			return e_success;	
		}
		else {
			log("f_checkAuthenticator: Error: This packet does not contain any Binding Update");
			return e_error;
		}
	} //end function f_checkAuthenticator


		/*
	 * @desc 	This goes through the BindingUpdate and
+2 −2
Original line number Diff line number Diff line
@@ -1038,8 +1038,8 @@ module LibIpv6_Interface_TypesAndValues {
		 * @desc High level switch to select/deselect Security TCs/Fns
		*/
		type enumerated IpSecSwitch {
			e_securityOn,	
			e_securityOff
			e_securityOn(0),	
			e_securityOff(1)
		}
		with {
			variant "use=com.testingtech.ttcn.tci.LibIpv6_Interface_TypesAndValues.*;";
+11 −4
Original line number Diff line number Diff line
@@ -527,7 +527,7 @@ module LibIpv6_Rfc3775Mipv6_Functions {
																								m_mobileOptList_5Elem(
																									m_mobileOpt_padN(m_optPad2),
																									m_mobileOpt_altCoa(m_altCoA(p_mnCoaTn)),
																									m_mobileOpt_nonceIndices(m_mobileOptNonceIndices_dummy), //TODO SMU+AB validate byte boundary. padding should not be needed here
																									m_mobileOpt_nonceIndices(m_mobileOptNonceIndices_dummy), 
																									m_mobileOpt_padN(m_optPad4),
																									m_mobileOpt_bindingAuth(m_bindingAuthData_dummy)))))));
		if ( v_ret != e_success ) {return v_ret;}
@@ -683,6 +683,7 @@ module LibIpv6_Rfc3775Mipv6_Functions {
		var UInt16 v_lifetime := 0;					
		var Ipv6Address v_mnCareOfAddr := c_16ZeroBytes;
		var Ipv6Address v_mnHomeAddr := c_16ZeroBytes;
		var HomeAgentAddressDiscoveryRequest v_dhaadReq;

		// Send an RtAdv message to have the MN create an address
		f_sendRtAdvWithPrefix_lifeTime (
@@ -695,6 +696,12 @@ module LibIpv6_Rfc3775Mipv6_Functions {

		tc_loop.start;
		alt {
			[]	ipPort.receive(mw_dhaadReq(?, ?)) -> value v_dhaadReq {
				f_sendHaAddrDrep(
					m_dhaadRep(p_paramsHa.gla, p_paramsIut.mnCoa, v_dhaadReq.ipv6Payload.homeAgentAddrDiscRequestMsg.identifier));
				repeat;
				}
			
			//1st alternative: m_optPad2 + Coa
			[]	ipPort.receive (
					mw_bindingUpdate_dst (
@@ -713,7 +720,7 @@ module LibIpv6_Rfc3775Mipv6_Functions {
								mw_bindingUpdateMsg (
									c_aFlag1,
									c_hFlag1,
									c_lFlag0,
									?, //c_lFlag0,
									c_kFlag0,
									m_mobileOptList_2Elem (
										m_mobileOpt_padN(m_optPad2),
@@ -767,7 +774,7 @@ module LibIpv6_Rfc3775Mipv6_Functions {
									mw_bindingUpdateMsg(
										c_aFlag1,
										c_hFlag1,
										c_lFlag0,
										?, //c_lFlag0,
										c_kFlag0,
										m_mobileOptList_1Elem(
											m_mobileOpt_padN(m_optPad4))))))) -> value v_ipv6Packet {