/* * @author STF 276 * @version $Id$ * @desc This module specifies common neighborhood and router * discovery 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_Rfc2461NeighborDiscovery_Functions { //LibCommon import from LibCommon_BasicTypesAndValues all; import from LibCommon_DataStrings all; import from LibCommon_VerdictControl { type FncRetCode }; import from LibCommon_Time all; //LibIpv6 import from LibIpv6_Interface_TypesAndValues all ; import from LibIpv6_Interface_Functions all; import from LibIpv6_CommonRfcs_TypesAndValues all; import from LibIpv6_CommonRfcs_Templates all; import from LibIpv6_CommonRfcs_Functions all; import from LibIpv6_ExternalFunctions all; import from LibIpv6_ModuleParameters all ; import from LibIpv6_Rfc2461NeighborDiscovery_Templates all; import from LibIpv6_Rfc2461NeighborDiscovery_TypesAndValues all; group redirect { /* * @desc This sends an ICMPv6 redirect for a test component * acting as any IPv6 node to the NUT. * Prior it modifies IPv6 packet payload ength and ICMPv6 * checksum to their correct values * @remark The template passed in must NOT contain any matching expressions! * @param p_redirect Ipv6 packet template with neighborhood advertisement to be sent * @return execution status */ function f_sendRedirect(in template Redirect p_redirect) runs on LibIpv6Node return FncRetCode { var Redirect v_ipPkt; v_ipPkt := valueof(p_redirect); //set extensionHeaders if(f_setExtensionHeaders( v_ipPkt ) != e_success) { log(" **** f_sendRedirect: Error when calculating length of extension headers ****"); return e_error; } //send ipPort.send(v_ipPkt); return e_success; } // end f_sendRedirect } // end group redirect group routerDiscovery { /* * @desc This sends an ICMPv6 router advertisement from a router node * to any NUT. Prior it modifies IPv6 packet payload length * and ICMPv6 checksum to their correct values * @remark The template passed in must NOT contain any matching expressions! * @param p_rtAdv Ipv6 packet template with router advertisement to be sent * @return execution status */ function f_sendRtAdv (in template RouterAdvertisement p_rtAdv) runs on LibIpv6Node return FncRetCode { var RouterAdvertisement v_ipPkt; v_ipPkt := valueof(p_rtAdv); //set extensionHeaders if(f_setExtensionHeaders( v_ipPkt ) != e_success) { log(" **** f_sendRtAdv: Error when calculating length of extension headers ****"); return e_error; } //send ipPort.send(v_ipPkt); return e_success; } // end f_sendRtAdv /* * @desc This functions sends a router advertisement with the specified * prefix, so that NUT adds the test component as its RT to its * default router list * @param p_llaAddrTn Local link address of testing node which calls this function * @param p_dstAddr Local link address of node under test * @param p_prefixLength Router advertisement option prefix length value * @param p_glaAddrTn Global address of testing node which calls this function * @param p_macUcaTn Local link-layer address of testing node which calls this function */ function f_sendRtAdvWithPrefix( in template Ipv6Address p_llaAddrTn, in template Ipv6Address p_dstAddr, in template PrefixLength p_prefixLength, in template Ipv6Address p_glaAddrTn, in template Oct6to15 p_macUcaTn) runs on LibIpv6Node return FncRetCode { var FncRetCode v_ret; v_ret := f_sendRtAdv( m_rtAdv_noExtHdr( p_llaAddrTn, p_dstAddr, c_mFlag0, c_oFlag0, c_infiniteLifetime, c_unspecifiedReachTime, c_unspecifiedRetransTime, m_rtAdvOpt_sllaPrefixOpt ( p_macUcaTn, p_prefixLength, c_lFlag1, c_aFlag1, c_validLifetime30s, c_preferredLifetime10s, f_createPrefix ( p_glaAddrTn, p_prefixLength ) ) ) ) ; return v_ret ; } /* * @desc This functions sends a router advertisement with the specified * prefix, so that NUT adds the test component as its RT to its * default router list * @param p_llaAddrTn Local link address of testing node which calls this function * @param p_dstAddr Local link address of node under test * @param p_prefixLength Router advertisement option prefix length value * @param p_glaAddrTn Global address of testing node which calls this function * @param p_macUcaTn Local link-layer address of testing node which calls this function * @param p_validLifetime Valid Lifetime to be send in Router Advertisement * @param p_preferredLifetime Preferred Lifetime to be send in Router Advertisement */ function f_sendRtAdvWithPrefix_lifeTime( in template Ipv6Address p_llaAddrTn, in template Ipv6Address p_dstAddr, in template PrefixLength p_prefixLength, in template Ipv6Address p_glaAddrTn, in template Oct6to15 p_macUcaTn, in UInt32 p_validLifetime, in UInt32 p_preferredLifetime) runs on LibIpv6Node return FncRetCode { var FncRetCode v_ret; v_ret := f_sendRtAdv( m_rtAdv_noExtHdr( p_llaAddrTn, p_dstAddr, c_mFlag0, c_oFlag0, c_infiniteLifetime, c_unspecifiedReachTime, c_unspecifiedRetransTime, m_rtAdvOpt_sllaPrefixOpt ( p_macUcaTn, p_prefixLength, c_lFlag1, c_aFlag1, p_validLifetime, p_preferredLifetime, f_createPrefix ( p_glaAddrTn, p_prefixLength ) ) ) ) ; return v_ret ; } /* * @desc This functions sends a router advertisement with the specified * prefix, so that NUT adds the test component as its RT to its * default router list * @param p_llaAddrTn Local link address of testing node which calls this function * @param p_dstAddr Local link address of node under test * @param p_prefixLength Router advertisement option prefix length value * @param p_glaAddrTn Global address of testing node which calls this function * @param p_linkLayerAddr Router Link-Layer address */ function f_sendMipRtAdvWithPrefix( in template Ipv6Address p_llaAddrTn, in template Ipv6Address p_dstAddr, in template PrefixLength p_prefixLength, in template Ipv6Address p_glaAddrTn, in template Oct6to15 p_linkLayerAddr) runs on LibIpv6Node return FncRetCode { var FncRetCode v_ret; v_ret := f_sendRtAdv( m_mobileRtAdv_noExtHdr( p_llaAddrTn, p_dstAddr, c_mFlag0, c_oFlag0, c_haFlag1, c_infiniteLifetime, c_unspecifiedReachTime, c_unspecifiedRetransTime, m_mobileRtAdvOpt_sllaPrefixOpt ( p_linkLayerAddr, p_prefixLength, c_lFlag1, c_aFlag1, c_rtAddrFlag1, c_infinitePrefixLifetime, c_infinitePrefixLifetime, p_glaAddrTn, m_advInterval(c_rtrAdvInterval3000ms), m_homeAgentInfo(c_haPref10s, c_haLifetime600s) ) ) ) ; return v_ret ; }//end f_sendMipRtAdvWithPrefix } // end group routerDiscovery group neighborDiscovery { /* * @desc This sends an ICMPv6 neighborhood advertisement from any * Ipv6 node to the NUT. Prior it modifies IPv6 packet payload * length and ICMPv6 checksum to their correct values * @remark The template passed in must NOT contain any matching expressions! * @param p_nbrAdv Ipv6 packet template with neighborhood advertisement to be sent * @return execution status */ function f_sendNbrAdv(in template NeighborAdvertisement p_nbrAdv) runs on LibIpv6Node return FncRetCode { var NeighborAdvertisement v_ipPkt; v_ipPkt := valueof(p_nbrAdv); //set extensionHeaders if(f_setExtensionHeaders( v_ipPkt ) != e_success) { log(" **** f_sendNbrAdv: Error when calculating length of extension headers ****"); return e_error; } //send ipPort.send(v_ipPkt); return e_success; }// end f_sendNbrAdv /* * @desc This sends an ICMPv6 router advertisement from a router node * to any NUT and waits 1 sec (give IUT time tp process the packet). * Prior it modifies IPv6 packet payload length and ICMPv6 checksum * to their correct values. * @remark The template passed in must NOT contain any matching expressions! * @param p_rtAdv Ipv6 packet template with router advertisement to be sent * @return execution status */ function f_sendRtAdvAndWait (in template RouterAdvertisement p_rtAdv) runs on LibIpv6Node return FncRetCode { if (f_sendRtAdv(p_rtAdv) != e_success) { return e_error; } f_sleep ( PX_T_BUILD_GLA ); return e_success; } // end f_sendRtAdv /* * @desc This sends an ICMPv6 Neighbor Solicitation from any * Ipv6 node to the NUT. Prior it modifies IPv6 packet payload * length and ICMPv6 checksum to their correct values. * @remark The template passed in must NOT contain any matching expressions! * @param p_nbrSol Ipv6 packet template with Neighbor Solicitation to be sent * @return execution status */ function f_sendNbrSol(in template NeighborSolicitation p_nbrSol) runs on LibIpv6Node return FncRetCode { var NeighborSolicitation v_ipPkt; v_ipPkt := valueof(p_nbrSol); //set extensionHeaders if(f_setExtensionHeaders( v_ipPkt ) != e_success) { log(" **** f_sendNbrSol: Error when calculating length of extension headers ****"); return e_error; } //send ipPort.send(v_ipPkt); return e_success; }// end f_sendNbrSol /* * @desc This sends an ICMPv6 Router Solicitation from any * Ipv6 node to the NUT. Prior it modifies IPv6 packet payload * length and ICMPv6 checksum to their correct values * @remark The template passed in must NOT contain any matching expressions! * @param p_rtrSol Ipv6 packet template with Router Solicitation to be sent * @return execution status */ function f_sendRtSol(in template RouterSolicitation p_rtrSol) runs on LibIpv6Node return FncRetCode { var RouterSolicitation v_ipPkt; v_ipPkt := valueof(p_rtrSol); //set extensionHeaders if(f_setExtensionHeaders( v_ipPkt ) != e_success) { log(" **** f_sendRtSol: Error when calculating length of extension headers ****"); return e_error; } //send ipPort.send(v_ipPkt); return e_success; }// end f_sendRtSol /* * @desc This function initiates Neighbor detection. * Sent and received packets must be given as templates. * @remark Time limit is defined by module parameter PX_TAC (see comp type) * @param p_nbrSol Neighbor Solicitation to be sent * @param p_nbrAdv template of an NA that is sent by NUT * @return execution status */ function f_performNeighborDetection ( in template NeighborSolicitation p_nbrSol, in template NeighborAdvertisement p_nbrAdv ) runs on LibIpv6Node return FncRetCode { var FncRetCode v_ret; // Send a Neighbor Solicitation v_ret := f_sendNbrSol ( p_nbrSol ); if ( v_ret != e_success ) { return v_ret; } tc_ac.start; alt { [] ipPort.receive ( p_nbrAdv ) { tc_ac.stop; v_ret := e_success; } [] tc_ac.timeout{ v_ret := e_timeout; } } // end alt return v_ret; } // end f_performNeighborDetection }//end group neighborDiscovery } // end module LibIpv6_Rfc2461NeighborDiscovery_Functions