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;
//LibIpv6
import from LibIpv6_ExternalFunctions all;
import from LibIpv6_Interface all ;
import from LibIpv6_Rfc2460Root_TypesAndValues { type all };
import from LibIpv6_ModuleParameters all ;
import from LibIpv6_Rfc2461NeighborDiscovery_Templates all;
import from LibIpv6_Rfc2461NeighborDiscovery_TypesAndValues all;
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import from LibIpv6_Rfc2463Icmpv6_Functions all;
import from LibIpv6_MultiRfcs_TypesAndValues all;
import from LibIpv6_MultiRfcs_Templates all;
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
** @returns execution status
*/
function f_sendRtAdv (in template RouterAdvertisement p_rtAdv)
runs on LibIpv6Node
return FncRetCode {
var Ipv6Packet v_ipPkt;
v_ipPkt.routerAdvert := valueof(p_rtAdv);
//calc payloadLen
v_ipPkt.routerAdvert.ipv6Hdr.payloadLength := fx_payloadLength (v_ipPkt);
//set checksum to zero
v_ipPkt.routerAdvert.checksum := c_2ZeroBytes;
//calc checksum
v_ipPkt.routerAdvert.checksum := fx_icmpv6Checksum(v_ipPkt);
//send
ipPort.send(v_ipPkt.routerAdvert);
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_llaAddrNut Local link address of node under test
** @param p_prefix Router advertisement option prefix value
** @param p_glaAddrTn Global address of testing node which calls this function
*/
function f_sendRtAdvWithPrefix( in Ipv6Address p_llaAddrTn,
in Ipv6Address p_dstAddr,
in PrefixLength p_prefixLength,
in Ipv6Address p_glaAddrTn)
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_prefix ( p_prefixLength,
c_lFlag1,
c_aFlag1,
c_infiniteLifetime,
c_infiniteLifetime,
f_createPrefix ( p_glaAddrTn, p_prefixLength ) ) ) ) ;
return v_ret ;
}
} // end group routerDiscovery
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
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 Ipv6 packet template with neighborhood advertisement to be sent
** @returns execution status
*/
function f_sendNbrAdv(in template NeighborAdvertisement p_nbrAdv)
runs on LibIpv6Node
return FncRetCode {
var Ipv6Packet v_ipPkt;
v_ipPkt.nbrAdvert := valueof(p_nbrAdv);
//calc payloadLen
v_ipPkt.nbrAdvert.ipv6Hdr.payloadLength := fx_payloadLength (v_ipPkt);
//set checksum to zero
v_ipPkt.nbrAdvert.checksum := c_2ZeroBytes;
//calc checksum
v_ipPkt.nbrAdvert.checksum := fx_icmpv6Checksum(v_ipPkt);
//send
ipPort.send(v_ipPkt.nbrAdvert);
return e_success;
}// end f_sendNbrAdv
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
/*
** @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
** @returns execution status
*/
function f_sendRtAdvAndWait (in template RouterAdvertisement p_rtAdv)
runs on LibIpv6Node
return FncRetCode {
var Ipv6Packet v_ipPkt;
v_ipPkt.routerAdvert := valueof(p_rtAdv);
//calc payloadLen
v_ipPkt.routerAdvert.ipv6Hdr.payloadLength := fx_payloadLength (v_ipPkt);
//set checksum to zero
v_ipPkt.routerAdvert.checksum := c_2ZeroBytes;
//calc checksum
v_ipPkt.routerAdvert.checksum := fx_icmpv6Checksum(v_ipPkt);
//send
ipPort.send(v_ipPkt.routerAdvert);
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 Ipv6 packet template with Neighbor Solicitation to be sent
** @returns execution status
*/
function f_sendNbrSol(in template NeighborSolicitation p_nbrSol)
runs on LibIpv6Node
return FncRetCode {
var Ipv6Packet v_ipPkt;
v_ipPkt.nbrSolicitation := valueof(p_nbrSol);
//calc payloadLen
v_ipPkt.nbrSolicitation.ipv6Hdr.payloadLength := fx_payloadLength (v_ipPkt);
//set checksum to zero
v_ipPkt.nbrSolicitation.checksum := c_2ZeroBytes;
//calc checksum
v_ipPkt.nbrSolicitation.checksum := fx_icmpv6Checksum(v_ipPkt);
//send
ipPort.send(v_ipPkt.nbrSolicitation);
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 Ipv6 packet template with Router Solicitation to be sent
** @returns execution status
*/
function f_sendRtSol(in template RouterSolicitation p_rtrSol)
runs on LibIpv6Node
return FncRetCode {
var Ipv6Packet v_ipPkt;
v_ipPkt.routerSolicitation := valueof(p_rtrSol);
//calc payloadLen
v_ipPkt.routerSolicitation.ipv6Hdr.payloadLength := fx_payloadLength (v_ipPkt);
//set checksum to zero
v_ipPkt.routerSolicitation.checksum := c_2ZeroBytes;
//calc checksum
v_ipPkt.routerSolicitation.checksum := fx_icmpv6Checksum(v_ipPkt);
//send
ipPort.send(v_ipPkt.routerSolicitation);
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_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
*/
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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
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 Ipv6 packet template with neighborhood advertisement to be sent
** @returns execution status
*/
function f_sendRedirect(in template Redirect p_redirect)
runs on LibIpv6Node
return FncRetCode {
var Ipv6Packet v_ipPkt;
v_ipPkt.redirect := valueof(p_redirect);
//calc payloadLen
v_ipPkt.redirect.ipv6Hdr.payloadLength := fx_payloadLength (v_ipPkt);
//set checksum to zero
v_ipPkt.redirect.checksum := c_2ZeroBytes;
//calc checksum
v_ipPkt.redirect.checksum := fx_icmpv6Checksum(v_ipPkt);
//send
ipPort.send(v_ipPkt.redirect);
return e_success;
}// end f_sendRedirect
} // end group redirect
} // end module LibIpv6_Rfc2461NeighborDiscovery_Functions