LibItsFntp_Functions.ttcn3 39 KB
Newer Older
1
2
/**
 *  @author     ETSI / STF422_EETS
filatov's avatar
filatov committed
3
4
 *  @version    $URL$
 *              $Id$
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
 *  @desc       FAST networking & transport layer protocol (ISO 29281-2) functions
 */
module LibItsFntp_Functions {
    
    // Libcommon
    import from LibCommon_Sync all;
    import from LibCommon_VerdictControl {
      type FncRetCode
    };
    import from LibCommon_Time {
      function f_sleepIgnoreDef
    };
    import from LibCommon_BasicTypesAndValues { 
        type UInt16 
    };
    
    // LibIts
    import from CALMmanagement language "ASN.1:1997" { 
        type StationID, ITS_scuId; 
    }; 
    import from CALMllsap language "ASN.1:1997" { 
        type 
            EUI64, IN_SAPaddress, LLserviceAddr, Link_ID, AccessParameters 
    }; 
    import from CALMfntp language "ASN.1:1997" all; 
    import from LibItsMgt_Functions { 
        altstep 
reinaortega's avatar
reinaortega committed
32
            a_mgtMnSapPortDefault, a_mgtSapAwaitFwtUpdate 
33
34
35
36
37
38
39
40
    };
    import from LibItsFntp_TypesAndValues {
        const c_portDyn, c_portNon;
        type AcFntpPrimitive
    };
    import from LibItsFntp_Templates all;
    import from LibItsFntp_Pixits all;
    import from LibItsFntp_Pics {
41
        modulepar PICS_ITS_S_INW, PICS_ROLE_RH;
42
    };
reinaortega's avatar
reinaortega committed
43
    import from LibItsCalm_Interface all; 
44
45
46
47
48
49
50
51
    
    group fntpConfigurationFunctions {
        
        /**
         * @desc This configuration features:
         * <li>Host and Router are combined (see ISO/WD 29281-2 - Figure 1 - Implementation architecture I)</li>
         * <li>MGT1 IISC Port (IISC/LAN) is not used</li>
         */
reinaortega's avatar
reinaortega committed
52
        function f_cf01Up() runs on ItsCalm {
53
54
            
            // Sanity check
55
56
            if (PICS_ITS_S_INW or not(PICS_ROLE_RH)) {
                log("*** f_cf01Up: ERROR: 'PICS_ITS_S_INW or not(PICS_ROLE_RH)' required for stting up CF01 ***");
57
58
59
60
61
62
                stop;
            }
            
            // Map
            map(self:acPort, system:acPort);
            map(self:utPort, system:utPort);
63
            map(self:cfPort, system:cfPort);
64
65
66
67
68
69
70
71
72
73
            map(self:fntpPort, system:fntpPort);
            
            // Connect
            f_connect4SelfOrClientSync();
            
            // Set processing on shutdown
            activate(a_cf01Down());
            
            // Initialize the component
            f_initialiseComponent("cf01Up");
garciay's avatar
garciay committed
74
            
75
76
77
78
79
80
81
82
83
84
            // Initialze the IUT
            f_initialState();
            
        } // End of function f_cf01Up
        
        /**
         * @desc This configuration features:
         * <li>Host and Router are separated (see ISO/WD 29281-2 - Figure 3 - Implementation architecture II & III)</li>
         * <li>MGT1 IISC Port (IISC/LAN) is not used</li>
         */
reinaortega's avatar
reinaortega committed
85
        function f_cf02Up() runs on ItsCalm {
86
87
88
            
            // Sanity check
            if (not(PICS_ITS_S_INW)) {
89
                log("*** f_cf02Up: ERROR: PICS_ITS_S_INW required for setting uo CF02 ***");
90
91
92
93
94
95
96
97
98
                stop;
            }
            
            vc_commandRef := 0;
            vc_pduCounter := 0;
            
            // Map
            map(self:acPort, system:acPort);
            map(self:utPort, system:utPort);
99
            map(self:cfPort, system:cfPort);
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
            map(self:fntpPort, system:fntpPort);
            
            // Connect
            f_connect4SelfOrClientSync();
            
            // Set processing on shutdown
            activate(a_cf02Down());
            
            // Initialize the component
            f_initialiseComponent("cf02Up");

            // Initialze the IUT
            f_initialState();
            
        } // End of function f_cf02Up
        
        /**
         * @desc Deletes configuration cf01
         */
reinaortega's avatar
reinaortega committed
119
        function f_cf01Down() runs on ItsCalm {
120
121
122
123
124
125
            
            deactivate;
            
            // Unmap
            unmap(self:acPort, system:acPort);
            unmap(self:utPort, system:utPort);
126
            unmap(self:cfPort, system:cfPort);
127
128
129
130
131
            unmap(self:fntpPort, system:fntpPort);
            
            // Disconnect
            f_disconnect4SelfOrClientSync();
            
garciay's avatar
garciay committed
132
        } // end f_cf01Down
133
        
134
        /**
garciay's avatar
garciay committed
135
         * @desc Deletes configuration cf02
136
         */
reinaortega's avatar
reinaortega committed
137
        function f_cf02Down() runs on ItsCalm {
138
139
140
141
142
143
144
145
146
147
148
            
            deactivate;
            
            // Unmap
            unmap(self:acPort, system:acPort);
            unmap(self:utPort, system:utPort);
            unmap(self:fntpPort, system:fntpPort);
            
            // Disconnect
            f_disconnect4SelfOrClientSync();
            
garciay's avatar
garciay committed
149
        } // End of f_cf02Down
150
151
152
153
154
        
        /**
         * @desc    Behavior function for initializing component's variables and tables
         * @param   p_componentName Name of the component
         */
reinaortega's avatar
reinaortega committed
155
        function f_initialiseComponent(in charstring p_componentName) runs on ItsCalm {
156
157
158
159
160
161
162
            
            // Initialize variables
            vc_componentName := p_componentName;
            vc_portNumber := { portLong := c_portNon };
            
            // Set defaults
            activate(a_fntpDefault()); // Default for Fntp module
163
            activate(a_mgtMnSapPortDefault()); // Default for MGT module / MF-SAP port
164
            
garciay's avatar
garciay committed
165
        } // End of f_initialiseComponent
166
167
168
169
170
171
172
173
        
    } // End of group fntpConfigurationFunctions
    
    group preambles {
        
        /**
         * @desc Brings the IUT into an initial state.
         */
reinaortega's avatar
reinaortega committed
174
        function f_initialState() runs on ItsCalm {
175
176
            
            f_utInitializeIut(m_fntpInitialize);
177
            f_sleepIgnoreDef(PX_WAIT_FOR_IUT_READY); // Wait until the IUT is in a stable situation (beaconing...)
178
179
180
181
182
183
184
185
186
187
188
189
        } // End of function f_initialState
        
        /**
         * @desc Implement the following Initial conditions:
         * <li>the IUT having set up properly the FNTP forwarding table, and the local port number of the ITS-S application</li>
         * <li>the IUT having an entry in the FNTP forwarding table for unicast communication with remote Link Port and Service Port</li>
         * <li>the IUT having an entry in the FNTP forwarding table for Service Port = port1, but not for Service Port = port2</li>
         * <li>the IUT having an entry in the FNTP forwarding table for a Service Port, but no entry for the peer station</li>
         * @param p_port Indicates the port number
         * @verdict Unchanged on success, set to fail on error (e_timeout)
         * @see ISO/WD 29281-2 Clause 8.2
         */
reinaortega's avatar
reinaortega committed
190
        function f_initializeFntpForwardingTable(in PortNumber p_port) runs on ItsCalm {
191
            // Request allocation of a port number associated with the ITS-SP
192
193
            // TODO Consider case of c_portDyn, and use f_utCommandRequestConfirm
            f_utCommandRequestWithoutConfirm(
194
195
                m_generateNfFntpPortCreationRequest(
                    f_getIutServiceRef(), 
196
197
                    p_port)
            );
198
            // Store the allocated port number
199
            vc_portNumber := p_port;
200
201
202
203
204
205
            if (ischosen(vc_portNumber.portShort)) {
                log("*** f_initializeFntpForwardingTable: INFO: portNumber value is: " & int2str(vc_portNumber.portShort) & " ***");
            } else {
                log("*** f_initializeFntpForwardingTable: INFO: portNumber value is: " & int2str(vc_portNumber.portLong) & " ***");
            }
            // And wait for a MN-SAP.MN-COMMAND/FWTupdate message sent by IST management entity to update the forwarding table
reinaortega's avatar
reinaortega committed
206
			f_mnSapAwaitFwtUpdate();
207
208
209
210
211
212
213
            
        } // End of function f_initializeFntpForwardingTable
        
        /**
         * @desc Call this method to remove entry created by f_initializeFntpForwardingTable() in FNTP Forwarding Table
         * @verdict Unchanged
         */
reinaortega's avatar
reinaortega committed
214
        function f_unInitializeFntpForwardingTable() runs on ItsCalm {
215
            // check c_portDyn
216
            // Send for FTN-SOCKET.request & Wait for FTN-SOCKET.confirm
217
            f_utCommandRequestConfirm(
218
219
220
221
222
223
                m_generateNfFntpPortDeletionRequest(f_getIutServiceRef(), vc_portNumber),
                mw_fntpPortConfirm(f_getIutServiceRef(), ?),
                false,
                vc_utCommandConf);
        } // End of function f_unInitializeFntpForwardingTable
        
224
225
226
        /**
         * @desc Trigger a basic FNTPNPDU to create an entry in forwarding table for a known peer station 
         */
reinaortega's avatar
reinaortega committed
227
        function f_setupKnownPeerStation() runs on ItsCalm { 
228
            f_acGenerateFntpNpdu( 
229
230
                f_getIutRemotePortNumberValue(), 
                vc_portNumber, 
231
232
233
                m_llServiceAddr(m_linkId(f_getIutWlRemoteCiidBc(), f_getIutWlLocalCiid())), 
                m_llServiceAddr(m_linkId(f_getIutRemoteDestCiidBc(), f_getIutDestLocalCiid())), 
              f_getIutShopValue() 
234
235
236
237
            );
            // TODO Do we ignore management and NF-COMM.indication messages?
        } // End of function f_setupKnownPeerStation
        
238
239
240
241
242
243
244
    } // End of group preambles
    
    group postambles {
        
        /**
         * @desc The default postamble.
         */
reinaortega's avatar
reinaortega committed
245
        function f_poDefault() runs on ItsCalm {
246
            // Nothing to do
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
        }
        
    } // End of group postambles
    
    /**
     * @desc    MN-SAP primitives
     * @see     ISO/CD 24102-3 - Clause 7. MN-SAP
     */
    group testerFunctions {
        
    } // End of group testerFunctions
    
    group mnSapFunctions {
        
        /**
         * @desc    Wait for MN-SAP.MN-COMMAND/FWTupdate message sent by IST management entity to update the forwarding table
         * @verdict Unchanged
         */
reinaortega's avatar
reinaortega committed
265
        function f_mnSapAwaitFwtUpdate() runs on ItsCalm {
266
267
268
            
            tc_ac.start;
            alt {
reinaortega's avatar
reinaortega committed
269
                [] a_mgtSapAwaitFwtUpdate() {
270
                    tc_ac.stop;
reinaortega's avatar
reinaortega committed
271
                    log("*** f_mnSapAwaitFwtUpdate: INFO: Expected message not received ***");
272
273
                }
                [] tc_ac.timeout {
reinaortega's avatar
reinaortega committed
274
                    log("*** f_mnSapAwaitFwtUpdate: ERROR: MN-SAP FWTupdate service primitive not received ***");
275
276
                }
            } // End of 'alt' statement
reinaortega's avatar
reinaortega committed
277
        } // End of function f_mnSapAwaitFwtUpdate()
278
279
280
281
282
283
284
285
286
        
    } // End of group testerFunctions
    
    group adapterControl {
        
        /**
         * @desc    Triggers event in the test system adaptation via IN-SAP interface.
         * @param   p_event The event to trigger
         */
reinaortega's avatar
reinaortega committed
287
        function f_acTriggerEvent(template (value) AcFntpPrimitive p_event) runs on ItsCalm {
288
289
290
291
292
            acPort.send(p_event);
        }
        
        /**
         * @desc    Triggers test adapter to send FNTP NDPU
293
294
295
296
297
         * @param   p_sourcePort        Source port number
         * @param   p_destinationPort   Destination port number
         * @param   p_sourcePort        IN-SAP source port
         * @param   p_destinationPort   IN-SAP destination port
         * @param   p_hops              N-hops value
298
         */
299
        function f_acGenerateFntpNpdu(
300
301
            in template (value) PortNumber p_sourcePort, 
            in template (value) PortNumber p_destinationPort, 
302
303
            in template (value) LLserviceAddr p_insapSourceAddress, 
            in template (value) LLserviceAddr p_insapDestAddress, 
304
            in FNTPhopCount p_hops 
reinaortega's avatar
reinaortega committed
305
        ) runs on ItsCalm { 
306
            f_acTriggerEvent( 
307
                m_generateFntpNpdu( 
308
309
                    p_insapSourceAddress, 
                    p_insapDestAddress, 
310
311
                    bit2oct( 
                        encvalue( 
reinaortega's avatar
reinaortega committed
312
                            m_fntpBasicNpdu( 
313
314
315
316
317
318
319
320
321
322
323
324
                                p_sourcePort, 
                                p_destinationPort, 
                                p_hops 
                            ) 
                        ) 
                    ) 
                ) 
            ); 
        } // End of function f_acGenerateFntpNPDU
        
        /**
         * @desc    Triggers lower tester to send FNTP station-internal NDPU with several hops and an invalid control field
325
326
327
328
329
         * @param   p_sourcePort            Source port 
         * @param   p_destinationPort       Destination port 
         * @param   p_insapSourceAddress    IN-SAP source port 
         * @param   p_insapDestAddress      IN-SAP destination port 
         * @param   p_hops                  N-hops value 
330
         */
331
        function f_acGenerateFntpNpduInvalidCtrlField( 
332
333
            in template (value) PortNumber p_sourcePort, 
            in template (value) PortNumber p_destinationPort, 
334
335
            in template (value) LLserviceAddr p_insapSourceAddress, // TODO Rename in p_insapSourceAddress
            in template (value) LLserviceAddr p_insapDestAddress,  // TODO Rename in p_insapDestAddress
336
            in template (value) FNTPhopCount p_hops 
reinaortega's avatar
reinaortega committed
337
        ) runs on ItsCalm { 
338
            f_acTriggerEvent(
339
                m_generateFntpNpdu( 
340
341
                    p_insapSourceAddress, 
                    p_insapDestAddress, 
342
343
                    bit2oct( 
                        encvalue( 
reinaortega's avatar
reinaortega committed
344
                            md_fntpExtendedNpdu_invalidCtrlField( 
345
346
347
348
349
350
351
352
                                p_sourcePort, 
                                p_destinationPort, 
                                p_hops 
                            ) 
                        ) 
                    ) 
                ) 
            ); 
353
        } // End of function f_acGenerateFntpNpduInvalidCtrlField
354
355
356
        
        /**
         * @desc    Triggers lower tester to send FNTP station-internal NDPU with bit5 set 
357
358
359
360
         * @param   p_sourcePort            Source port 
         * @param   p_destinationPort       Destination port 
         * @param   p_insapSourceAddress    IN-SAP source port 
         * @param   p_insapDestAddress      IN-SAP destination port 
361
         */
362
        function f_acGenerateFntpNpduInvalidBitSet( 
363
364
            in template (value) PortNumber p_sourcePort, 
            in template (value) PortNumber p_destinationPort, 
365
366
            in template (value) LLserviceAddr p_insapSourceAddress, 
            in template (value) LLserviceAddr p_insapDestAddress 
reinaortega's avatar
reinaortega committed
367
        ) runs on ItsCalm { 
368
            f_acTriggerEvent(
369
                m_generateFntpNpdu( 
370
371
                    p_insapSourceAddress, 
                    p_insapDestAddress, 
372
373
                    bit2oct( 
                        encvalue( 
reinaortega's avatar
reinaortega committed
374
                            md_fntpExtendedNpdu_invalidBitSet( 
375
376
377
378
379
380
381
382
383
384
385
386
387
388
                                p_sourcePort, 
                                p_destinationPort, 
                                omit
                            ) 
                        ) 
                    ) 
                ) 
            ); 
        } // End of function f_acGenerateFntpNPDU_With_Bit5
        
        /**
         * @desc    Triggers test adapter to send FNTP NDPU
         * @param   p_sourcePort        Source port 
         * @param   p_destinationPort   Destination port 
389
390
         * @param   p_insapSourceAddress     IN-SAP source port 
         * @param   p_insapDestAddress       IN-SAP destination port 
391
392
393
394
395
         * @param   p_hops              N-hops value 
         * @param   p_rxCIP             Receive (RX) parameter settings
         * @param   p_txCIP             Transmit (TX) parameters of a VCI
         * @param   p_accessParams        Access parameters 
         */
396
        function f_acGenerateFntpNpduCip(
397
398
            in template (value) PortNumber p_sourcePort, 
            in template (value) PortNumber p_destinationPort, 
399
400
            in template (value) LLserviceAddr p_insapSourceAddress, 
            in template (value) LLserviceAddr p_insapDestAddress, 
401
            in template (value) FNTPhopCount p_hops, 
reinaortega's avatar
reinaortega committed
402
403
            in template (value) RXcip p_rxCip, // TODO Perhaps this parameter is not required, p_accessParams would be enough
            in template (value) TXcip p_txCip, // TODO Perhaps this parameter is not required, p_accessParams would be enough
404
            in template (value) AccessParameters p_accessParams 
reinaortega's avatar
reinaortega committed
405
        ) runs on ItsCalm { 
406
            f_acTriggerEvent( 
reinaortega's avatar
reinaortega committed
407
                md_generateFntpNpduCip( 
408
409
                    p_insapSourceAddress, 
                    p_insapDestAddress, 
410
411
                    bit2oct( 
                        encvalue( 
reinaortega's avatar
reinaortega committed
412
                            md_fntpExtendedNpdu_cip( 
413
414
415
                                p_sourcePort, 
                                p_destinationPort, 
                                p_hops, 
reinaortega's avatar
reinaortega committed
416
417
                                p_rxCip, // TODO Perhaps this parameter is not required, p_accessParams would be enough
                                p_txCip // TODO Perhaps this parameter is not required, p_accessParams would be enough
418
419
420
421
422
423
                            ) 
                        ) 
                    ), 
                    p_accessParams 
                ) 
            ); 
424
        } // End of function f_acGenerateFntpNpduCip
425
426
427
428
429
430
431
432
433
434
435
436
        
        /**
         * @desc    Triggers test adapter to send FNTP forwarding NDPU
         * @param   p_sourcePort        Source port (c_portRtr or c_portHst)
         * @param   p_destinationPort   Destination port (c_portRtr or c_portHst)
         * @param   p_fromPort          Forwarding source port
         * @param   p_toPort            Forwarding destination port
         * @param   p_sourcePort        IN-SAP source port
         * @param   p_destinationPort   IN-SAP destination port
         * @param   p_counter           Expected value of FNTP packet counter counter field
         * @param   p_hops              N-hops value
         */
437
        function f_acGenerateFntpForwardingNpdu(
438
439
440
            in template (value) PortNumber p_sourcePort, 
            in template (value) PortNumber p_destinationPort, 
            in template (value) PortNumber p_fromPort, 
441
442
443
            in template (value) PortNumber p_toPort, 
            in template (value) LLserviceAddr p_insapSourceAddress, 
            in template (value) LLserviceAddr p_insapDestAddress, 
444
445
            in template (value) FNTPpacketCounter p_counter, 
            in template (value) FNTPhopCount p_hops 
reinaortega's avatar
reinaortega committed
446
        ) runs on ItsCalm { 
447
            f_acTriggerEvent( 
448
                m_generateFntpNpdu( 
449
450
                    p_insapSourceAddress, 
                    p_insapDestAddress, 
451
452
                    bit2oct( 
                        encvalue( 
453
                            md_fntpForwardingNpdu( 
454
455
456
457
458
459
                                p_sourcePort, 
                                p_destinationPort, 
                                p_hops,
                                p_fromPort,
                                p_toPort,
                                p_counter 
460
                            ) // End of field 'md_fntpForwardingNpdu'
461
462
                        ) // End of function encvalue
                    ) // End of function bit2oct
463
                ) // End of field 'm_generateFntpNpdu'
464
            ); 
465
        } // End of function f_acGenerateFntpForwardingNpdu
466
467
468
469
470
471
472
473
474
475
476
477
        
        /**
         * @desc    Triggers test adapter to send FNTP forwarding NDPU with an unknown ITS-SCU-ID
         * @param   p_sourcePort        Source port (c_portRtr or c_portHst)
         * @param   p_destinationPort   Destination port (c_portRtr or c_portHst)
         * @param   p_fromPort          Forwarding source port
         * @param   p_toPort            Forwarding destination port
         * @param   p_sourcePort        IN-SAP source port
         * @param   p_destinationPort   IN-SAP destination port
         * @param   p_counter           Expected value of FNTP packet counter counter field
         * @param   p_hops              N-hops value
         */
478
        function f_acGenerateFntpForwardingNpduWithUnknownItsSciId(
479
480
481
482
            in template (value) PortNumber p_sourcePort, 
            in template (value) PortNumber p_destinationPort, 
            in template (value) PortNumber p_fromPort, 
            in template (value) PortNumber p_toPort,
483
484
            in template (value) LLserviceAddr p_insapSourceAddress, 
            in template (value) LLserviceAddr p_insapDestAddress, 
485
486
            in template (value) FNTPpacketCounter p_counter, 
            in template (value) FNTPhopCount p_hops 
reinaortega's avatar
reinaortega committed
487
        ) runs on ItsCalm { 
488
            f_acTriggerEvent( 
489
                m_generateFntpNpdu( 
490
491
                    p_insapSourceAddress, 
                    p_insapDestAddress, 
492
493
                    bit2oct( 
                        encvalue( 
reinaortega's avatar
reinaortega committed
494
                            md_fntpForwardingNpdu_unknownItsScuId( 
495
496
497
498
499
500
                                p_sourcePort, 
                                p_destinationPort, 
                                p_hops,
                                p_fromPort,
                                p_toPort,
                                p_counter 
501
                            ) // End of field 'md_fntpForwardingNpdu_UnknownITS_SCU_ID'
502
503
504
505
                        ) // End of function encvalue
                    ) // End of function bit2oct
                ) // End of field 'm_generateFntpNPDU'
            ); 
506
        } // End of function f_acGenerateFntpForwardingNpduWithUnknownItsSciId
507
508
509
510
511
512
513
514
515
516
517
518
519
520
        
        /**
         * @desc    Triggers test adapter to send FNTP forwarding NDPU with CIP
         * @param   p_sourcePort        Source port (c_portRtr or c_portHst)
         * @param   p_destinationPort   Destination port (c_portRtr or c_portHst)
         * @param   p_fromPort          Forwarding source port
         * @param   p_toPort            Forwarding destination port
         * @param   p_sourcePort        IN-SAP source port
         * @param   p_destinationPort   IN-SAP destination port
         * @param   p_counter           Expected value of FNTP packet counter counter field
         * @param   p_hops              N-hops value
         * @param   p_rxCIP             Receive (RX) parameter settings
         * @param   p_txCIP             Transmit (TX) parameters of a VCI
         */
521
        function f_acGenerateFntpForwardingNpduCip(
522
523
524
525
            in template (value) PortNumber p_sourcePort, 
            in template (value) PortNumber p_destinationPort, 
            in template (value) PortNumber p_fromPort, 
            in template (value) PortNumber p_toPort,
526
527
            in template (value) LLserviceAddr p_insapSourceAddress, 
            in template (value) LLserviceAddr p_insapDestAddress, 
528
529
            in template (value) FNTPpacketCounter p_counter, 
            in template (value) FNTPhopCount p_hops, 
reinaortega's avatar
reinaortega committed
530
531
            in template (value) RXcip p_rxCip, // TODO Perhaps this parameter is not required, p_accessParams would be enough
            in template (value) TXcip p_txCip, // TODO Perhaps this parameter is not required, p_accessParams would be enough
532
            in template (value) AccessParameters p_accessParams 
reinaortega's avatar
reinaortega committed
533
        ) runs on ItsCalm { 
534
            f_acTriggerEvent( 
reinaortega's avatar
reinaortega committed
535
                md_generateFntpNpduCip( 
536
537
                    p_insapSourceAddress, 
                    p_insapDestAddress, 
538
539
                    bit2oct( 
                        encvalue( 
reinaortega's avatar
reinaortega committed
540
                            md_fntpForwardingNpdu_cip( 
541
542
543
544
545
546
                                p_sourcePort, 
                                p_destinationPort, 
                                p_hops, 
                                p_fromPort, 
                                p_toPort, 
                                p_counter, 
reinaortega's avatar
reinaortega committed
547
548
                                p_rxCip, // TODO Perhaps this parameter is not required, p_accessParams would be enough
                                p_txCip // TODO Perhaps this parameter is not required, p_accessParams would be enough
549
                            ) // End of field 'md_fntpForwardingNpdu_CIP'
550
551
552
553
554
                        ) // End of function 'encvalue'
                    ), // End of function 'bit2oct'
                    p_accessParams 
                ) 
            ); 
555
        } // End of function f_acGenerateFntpForwardingNpduCip
556
        
garciay's avatar
garciay committed
557

558
559
560
561
562
563
564
565
566
567
568
569
570
    } // End of group adapterControl
    
    group internalFunctions { // TODO Use parametrized function (ETSI ES 202 784) insetad of the three oct2xxx functions
        
        /**
         * @desc  This function convert the specified octetstring into a template (FNTPNPDU or FntpExtInd or FntpFwdInd)
         * This SHALL be done due to the ASN.1 description of IN-SAP service primitives DL_Unitdata_request/DL_Unitdata_indication
         * @param p_data        An octetstring to decode
         * @param p_syncPoint   Current synchronisation point, required to set verdict according to the LibCommon rules
         * @param p_decoded     The decoded message
         * @verdict Unchanged on success, set to fail otherwise
         * @see ISO/CD 21218 - Clause 8.2.2
         */
reinaortega's avatar
reinaortega committed
571
        function f_oct2npdu(in octetstring p_data, in charstring p_syncPoint, out FNTPNPDU p_decoded) runs on ItsCalm {
572
573
574
575
576
            var integer v_result;
            
            v_result := decvalue(oct2bit(p_data), p_decoded);
            if (v_result == 1) {
                f_selfOrClientSyncAndVerdictTestBody(p_syncPoint, e_error); 
577
                log("*** f_oct2npdu: FAIL: 'decvalue' operation failed ***");
578
579
            } else if (v_result == 2) {
                f_selfOrClientSyncAndVerdictTestBody(p_syncPoint, e_error); 
580
                log("*** f_oct2npdu: FAIL: 'decvalue' operation failed, not enougth bits ***");
581
            }
582
583
            log("*** f_oct2npdu: INFO: Decoded message done ***");
        } // End of function f_oct2npdu
584
585
586
587
588
        
    } // End of group internalFunctions
    
    group iutFunctions {
        
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
        group cf01 { 
            
            /**
             * @desc    Get the local identifier of the VCI
             * @return  The local identifier of the VCI
             * @see     PX_WL_LOCAL_CIID
             * @verdict Unchanged
             * @see ISO 21218 - Clause 6.2 Link Identifier
             */
            function f_getIutWlLocalCiid() return EUI64 {
                return PX_WL_LOCAL_CIID;
            }
            
            /**
             * @desc    Get the local identifier of the VCI for broadcast on ITS-S host
             * @return  The local identifier of the VCI for broadcast on ITS-S host
             * @see     PX_WL_REMOTE_CIID_BC
             * @verdict Unchanged
             */
            function f_getIutWlRemoteCiidBc() return EUI64 {
                return PX_WL_REMOTE_CIID_BC;
            }
            
            /**
             * @desc    Get the remote CIID for unicast (peer to peer)
             * @return  The remote CIID for unicast 
             * @see     PX_WL_REMOTE_CIID_UC
             * @verdict Unchanged
             */
            function f_getIutWlRemoteCiidUc() return EUI64 {
                return PX_WL_REMOTE_CIID_UC;
            }
            
            /**
             * @desc    Get the IUT Link-ID in broadcast transmission mode
             * @return  The IUT Link-ID in broadcast transmission mode
             * @see     PX_WL_LINK_ID_BC
             * @verdict Unchanged
             * @see ISO 21218 - Clause 6.2 Link Identifier
             */
            function f_getIutWlLinkIdBc() return Link_ID {
                return PX_WL_LINK_ID_BC;
            }
            
            /**
634
635
636
             * @desc    Get an unknown VCI to be used to transmit the packet, i.e. the peer station, for Unicast
             * @return  An unknown VCI to be used to transmit the packet
             * @see PX_WL_LINK_ID_UNKWNON_UC
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
             * @verdict Unchanged
             */
            function f_getIutWlLinkIdUnknownUc() return Link_ID {
                return PX_WL_LINK_ID_UNKWNON_UC;
            }
            
            /**
             * @desc   Get the VCI to be used to transmit the packet, i.e. the peer station, for Unicast
             * @return The VCI to be used to transmit the packet, i.e. the peer station, for Unicast
             * @see PX_WL_LINK_ID_UC
             * @verdict Unchanged
             */
            function f_getIutWlLinkIdUc() return Link_ID {
                return PX_WL_LINK_ID_UC;
            }
            
        } // End of group cf01 
654
        
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
        group cf02 { 
            
            /**
             * @desc    Get the local identifier of the VCI
             * @return  The local identifier of the VCI
             * @see     PX_LAN_LOCAL_CIID
             * @verdict Unchanged
             * @see ISO 21218 - Clause 6.2 Link Identifier
             */
            function f_getIutLanLocalCiid() return EUI64 {
                return PX_LAN_LOCAL_CIID;
            }
            
            /**
             * @desc    Get the local identifier of the VCI for broadcast on ITS-S host
             * @return  The local identifier of the VCI for broadcast on ITS-S host
             * @see     PX_LAN_REMOTE_CIID_BC
             * @verdict Unchanged
             */
            function f_getIutLanRemoteCiidBc() return EUI64 {
                return PX_LAN_REMOTE_CIID_BC;
            }
            
            /**
             * @desc    Get the IUT Link-ID in broadcast transmission mode
             * @return  The IUT Link-ID in broadcast transmission mode
             * @see     PX_LAN_LINK_ID_BC
             * @verdict Unchanged
             * @see ISO 21218 - Clause 6.2 Link Identifier
             */
            function f_getIutLanLinkIdBc() return Link_ID {
                return PX_LAN_LINK_ID_BC;
            }
            
            /**
             * @desc    Get the identifier of a different VCI on ITS-S host/router only 
             * @return  The identifier of a different VCI on ITS-S host/router only 
             * @see     PX_LAN_DIFFERENT_LOCAL_CIID
             * @verdict Unchanged
             */
            function f_getIutLanDifferentLocalCiid() return EUI64 {
                return PX_LAN_DIFFERENT_LOCAL_CIID;
            }
            
        } // End of group cf02 
700
        
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
        group peerStation {
            
            /**
             * @desc    Get the local identifier of the VCI
             * @return  The local identifier of the VCI
             * @see     PX_DEST_LOCAL_CIID
             * @verdict Unchanged
             * @see ISO 21218 - Clause 6.2 Link Identifier
             */
            function f_getIutDestLocalCiid() return EUI64 {
                return PX_DEST_LOCAL_CIID;
            }
            
            /**
             * @desc    Get the remote identifier of the VCI for broadcast on ITS-S host
             * @return  The remote identifier of the VCI for broadcast on ITS-S host
             * @see     PX_DEST_REMOTE_CIID_BC
             * @verdict Unchanged
             * @see ISO 21218 - Clause 6.2 Link Identifier
             */
            function f_getIutRemoteDestCiidBc() return EUI64 {
                return PX_DEST_REMOTE_CIID_BC;
            }
            
            /**
             * @desc    Get the remote identifier of a second VCI for unicast (peer to peer) on ITS-S host 
             * @return  The remote identifier of a a second VCI for unicast (peer to peer) on ITS-S host 
             * @see     PX_DEST_REMOTE_CIID_UC
             * @verdict Unchanged
             */
            function f_getIutRemoteDestCiidUc() return EUI64 {
                return PX_DEST_REMOTE_CIID_UC;
            }
            
            /**
             * @desc    Get the identifier of a second VCI for unicast (peer to peer) on ITS-S host 
             * @return  The identifier of a a second VCI for unicast (peer to peer) on ITS-S host 
             * @see     PX_WL_SECOND_REMOTE_CIID_BC
             * @verdict Unchanged
             */
            function f_getIutSecondRemoteDestCiidBc() return EUI64 {
                return PX_SECOND_REMOTE_CIID_BC;
            }
            
        } // End of group peerStation
746
        
747
748
749
750
751
752
753
754
755
756
        /**
         * @desc   Get the application port number, used instead of c_portDyn
         * @return The application port number, used instead of c_portDyn
         * @see PX_APP_PORT_NUMBER
         * @verdict Unchanged
         */
        function f_getIutAppPortValue() return PortNumber {
            return PX_APP_PORT_NUMBER;
        }
        
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
        /**
         * @desc    Get the source forwarding port
         * @return  The source forwarding port
         * @see     PX_FORWARDING_SRC_PORT
         * @verdict Unchanged
         */
        function f_getIutForwardingSrcPort() return PortNumber {
            return PX_FORWARDING_SRC_PORT;
        }
        
        /**
         * @desc    Get the destination forwarding port
         * @return  The destination forwarding port
         * @see     PX_FORWARDING_DST_PORT
         * @verdict Unchanged
         */
        function f_getIutForwardingDestPort() return PortNumber {
            return PX_FORWARDING_DST_PORT;
        }
        
        /**
         * @desc    Get the source port number, i.e. the local endpoint
         * @return  The source port number
         * @see     PX_LOCAL_PORT_NUMBER
         * @verdict Unchanged
         */
783
        function f_getIutLocalPortNumberValue() return PortNumber {
784
785
786
787
            return PX_LOCAL_PORT_NUMBER;
        }
        
        /**
788
789
         * @desc   Unknown broadcast VCI
         * @return An unknown broadcast VCI
garciay's avatar
garciay committed
790
         * @see PX_WL_LINK_ID_UNKWNON_BC
791
792
         * @verdict Unchanged
         */
garciay's avatar
garciay committed
793
794
        function f_getIutWlLinkIdUnknownBc() return Link_ID {
            return PX_WL_LINK_ID_UNKWNON_BC;
795
796
        }
        
797
798
799
        /**
         * @desc    Get the ITS-SP payload EPDU
         * @return  The ITS-SP payload EPDU
800
         * @see     PX_ITS_FPDU
801
802
         * @verdict Unchanged
         */
803
        function f_getIutItsFpdu() return ITSfpdu { 
804
            return PX_ITS_FPDU;
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
        }
        
        /**
         * @desc    Get the service reference defining a number uniquely identifying the endpoint at this host in an implementation specific way
         * @return  The service reference
         * @see     PX_SERVICE_REF
         * @verdict Unchanged
         */
        function f_getIutServiceRef() return integer {
            return PX_SERVICE_REF;
        }
        
        /**
         * @desc    Get the Single-hop value
         * @return  The Single-hop value
         * @verdict Unchanged
         */
822
        function f_getIutShopValue() return FNTPhopCount {
823
824
825
826
827
828
829
830
            return PX_SHOP;
        }
        
        /**
         * @desc    Get the N-hops value
         * @return  The N-hops value
         * @verdict Unchanged
         */
831
        function f_getIutNhopsValue() return FNTPhopCount {
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
            return PX_NHOPS;
        }
        
        /**
         * @desc    Get a service port number
         * @return  The service port number
         * @see     PX_SERVICE_PORT
         * @verdict Unchanged
         */
        function f_getIutServicePortValue() return PortNumber {
            return PX_SERVICE_PORT;
        }
        
        /**
         * @desc   Get the reception access parameter
         * @return The reception access parameter
         * @see PX_CIP_RX_SETTINGS
         * @verdict Unchanged
         */
851
        function f_getIutRxCipValue() return RXcip {
852
853
854
855
856
857
858
859
860
            return PX_CIP_RX_SETTINGS;
        }
        
        /**
         * @desc   Get the transmission access parameter
         * @return The transmission access parameter
         * @see PX_CIP_TX_SETTINGS
         * @verdict Unchanged
         */
861
        function f_getIutTxCipValue() return TXcip {
862
863
864
865
            return PX_CIP_TX_SETTINGS;
        }
        
        /**
866
867
         * @desc    Get the remote port number value
         * @return  The remote port number value
868
869
870
         * @see     PX_REMOTE_PORT_NUMBER
         * @verdict Unchanged
         */
871
872
        function f_getIutRemotePortNumberValue() return PortNumber {
            return PX_REMOTE_PORT_NUMBER;
873
874
        } // End of function f_getIutRemotePortNumberValue
        
875
876
877
878
879
880
881
882
883
884
        /**
         * @desc    Get the second remote port number value
         * @return  The second remote port number value
         * @see     PX_SECOND_REMOTE_PORT_NUMBER
         * @verdict Unchanged
         */
        function f_getIutSecondRemotePortNumberValue() return PortNumber {
            return PX_SECOND_REMOTE_PORT_NUMBER;
        } // End of function f_getIutSecondRemotePortNumberValue
        
885
886
887
888
889
890
891
    } // End of group iutFunctions
    
    group fntpAltsteps {
        
        /**
         * @desc The base default.
         */
reinaortega's avatar
reinaortega committed
892
        altstep a_fntpDefault() runs on ItsCalm {
893
894
895
896
897
            // FIXME Check why TTWB detect an error here?
//            [] fntpPort.receive(mw_fntpInSapPrimitiveReq(mw_inUnitDataReq_any)) {
//                log("*** a_fntpDefault: INFO: IN-UNITDATA.request received in default ***");
//                repeat;
//            }
898
// FIXME Add support of response to NF-FNTP-PORT.confirm & NF-FNTP-COMM.confirm
899
900
901
902
903
904
905
906
            [] fntpPort.receive {
                log("*** a_fntpDefault: INFO: Unkown FNTP NDPU received in default ***");
                repeat;
            }
            [] tc_wait.timeout {
                log("*** a_fntpDefault: ERROR: Timeout while awaiting reaction of the IUT prior to Upper Tester action ***");
                f_selfOrClientSyncAndVerdict("error", e_timeout);
            }
907
            [] tc_ac.timeout { // For security because it should be done in main altsetp bloc
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
                log("*** a_fntpDefault: ERROR: Timeout while awaiting the reception of a message ***");
                f_selfOrClientSyncAndVerdict("error", e_timeout);
            }
            [] any timer.timeout {
                log("*** a_fntpDefault: INCONC: An unknown timer has expired in default ***"); 
                f_selfOrClientSyncAndVerdict("error", e_timeout);
            }
            [] a_shutdown() {
                f_poDefault();
                log("*** a_fntpDefault: INFO: TEST COMPONENT NOW STOPPING ITSELF! ***");
                if(self == mtc) {
                    f_cf01Down();
                }
                stop;
            }
        } // End of altstep a_fntpDefault()
        
        /**
         * @desc Default handling cf01 de-initialisation.
         */
reinaortega's avatar
reinaortega committed
928
        altstep a_cf01Down() runs on ItsCalm {
929
930
931
932
933
934
935
936
937
938
939
            [] a_shutdown() {
                f_poDefault();
                f_cf01Down();
                log("*** a_cf01Down: INFO: TEST COMPONENT NOW STOPPING ITSELF! ***");
                stop;
            }
        } // End of altstep a_cf01Down()
        
        /**
         * @desc Default handling cf02 de-initialisation.
         */
reinaortega's avatar
reinaortega committed
940
        altstep a_cf02Down() runs on ItsCalm {
941
942
943
944
945
946
947
948
949
950
951
            [] a_shutdown() {
                f_poDefault();
                f_cf02Down();
                log("*** a_cf02Down: INFO: TEST COMPONENT NOW STOPPING ITSELF! ***");
                stop;
            }
        } // End of altstep a_cf02Down()
        
    } // End of group fntpAltsteps
    
} // End of module LibItsFntp_Functions