Newer
Older
/*
* @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;
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 {
tepelmann
committed
var Redirect v_ipPkt;
v_ipPkt.ipv6Hdr.destinationAddress) != e_success) {
log(" **** f_sendRedirect: Error when calculating length of extension headers ****");
return e_error;
}
}
//calc payloadLen
v_ipPkt.ipv6Hdr.payloadLength := fx_payloadLength (v_ipPkt);
//set checksum to zero
v_ipPkt.ipv6Payload.redirectMsg.checksum := c_2ZeroBytes;
//calc checksum
v_ipPkt.ipv6Payload.redirectMsg.checksum := fx_icmpv6Checksum(v_ipPkt);
return e_success;
} // end f_sendRedirect
} // end group redirect
* @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 {
tepelmann
committed
var RouterAdvertisement v_ipPkt;
v_ipPkt.ipv6Hdr.destinationAddress) != e_success) {
log(" **** f_sendRtAdv: Error when calculating length of extension headers ****");
return e_error;
}
}
v_ipPkt.ipv6Hdr.payloadLength := fx_payloadLength (v_ipPkt);
v_ipPkt.ipv6Payload.routerAdvMsg.checksum := c_2ZeroBytes;
v_ipPkt.ipv6Payload.routerAdvMsg.checksum := fx_icmpv6Checksum(v_ipPkt);
* @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
function f_sendRtAdvWithPrefix( in template Ipv6Address p_llaAddrTn,
in template Ipv6Address p_dstAddr,
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,
f_createPrefix ( p_glaAddrTn, p_prefixLength ) ) ) ) ;
return v_ret ;
}
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
/*
* @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
*/
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 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_prefixOpt ( 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
*/
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;
tepelmann
committed
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
* @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 {
tepelmann
committed
var NeighborAdvertisement v_ipPkt;
v_ipPkt.ipv6Hdr.destinationAddress) != e_success) {
log(" **** f_sendNbrAdv: Error when calculating length of extension headers ****");
return e_error;
}
}
v_ipPkt.ipv6Hdr.payloadLength := fx_payloadLength (v_ipPkt);
v_ipPkt.ipv6Payload.nbrAdvMsg.checksum := c_2ZeroBytes;
v_ipPkt.ipv6Payload.nbrAdvMsg.checksum := fx_icmpv6Checksum(v_ipPkt);
* @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 {
tepelmann
committed
var NeighborSolicitation v_ipPkt;
v_ipPkt.ipv6Hdr.destinationAddress) != e_success) {
log(" **** f_sendNbrSol: Error when calculating length of extension headers ****");
return e_error;
}
}
v_ipPkt.ipv6Hdr.payloadLength := fx_payloadLength (v_ipPkt);
v_ipPkt.ipv6Payload.nbrSolMsg.checksum := c_2ZeroBytes;
v_ipPkt.ipv6Payload.nbrSolMsg.checksum := fx_icmpv6Checksum(v_ipPkt);
* @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 {
tepelmann
committed
var RouterSolicitation v_ipPkt;
v_ipPkt.ipv6Hdr.destinationAddress) != e_success) {
log(" **** f_sendRtSol: Error when calculating length of extension headers ****");
return e_error;
}
}
v_ipPkt.ipv6Hdr.payloadLength := fx_payloadLength (v_ipPkt);
v_ipPkt.ipv6Payload.routerSolMsg.checksum := c_2ZeroBytes;
v_ipPkt.ipv6Payload.routerSolMsg.checksum := fx_icmpv6Checksum(v_ipPkt);
* @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_echoRequest Echo Request to be sent
* @param p_nbrSol Neighbor Solicitation to be sent
* @param p_nbrAdv template of an NA that is sent by NUT
* @return execution status
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
*/
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