LibItsFntp_Functions.ttcn3 39.5 KB
Newer Older
/**
 *  @author     ETSI / STF422_EETS
 *  @version    $URL:$
 *              $Id:$
 *  @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 
            a_mgtMnSapPortDefault, a_mgtSapAwaitFWTupdate 
    };
    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 {
        modulepar PICS_ITS_S_INW, PICS_ROLE_RH;
    // FIXME To be removed
//    import from LibItsCommon_TypesAndValues {
//        type UtCommandConfirm
//    };
reinaortega's avatar
reinaortega committed
    import from LibItsCalm_Interface all; 
    
    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
        function f_cf01Up() runs on ItsCalm {
            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 ***");
                stop;
            }
            
            // Map
            map(self:acPort, system:acPort);
            map(self:utPort, system:utPort);
            map(self:mgtMnSapPort, system:mgtMnSapPort);
            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
            
            // 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
        function f_cf02Up() runs on ItsCalm {
            
            // Sanity check
            if (not(PICS_ITS_S_INW)) {
                log("*** f_cf02Up: ERROR: PICS_ITS_S_INW required for setting uo CF02 ***");
                stop;
            }
            
            vc_commandRef := 0;
            vc_pduCounter := 0;
            
            // Map
            map(self:acPort, system:acPort);
            map(self:utPort, system:utPort);
            map(self:mgtMnSapPort, system:mgtMnSapPort);
            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
        function f_cf01Down() runs on ItsCalm {
            
            deactivate;
            
            // Unmap
            unmap(self:acPort, system:acPort);
            unmap(self:utPort, system:utPort);
            unmap(self:mgtMnSapPort, system:mgtMnSapPort);
            unmap(self:fntpPort, system:fntpPort);
            
            // Disconnect
            f_disconnect4SelfOrClientSync();
            
        } // end f_cf01Down
reinaortega's avatar
reinaortega committed
        function f_cf02Down() runs on ItsCalm {
            
            deactivate;
            
            // Unmap
            unmap(self:acPort, system:acPort);
            unmap(self:utPort, system:utPort);
            unmap(self:fntpPort, system:fntpPort);
            
            // Disconnect
            f_disconnect4SelfOrClientSync();
            
        } // End of f_cf02Down
        
        /**
         * @desc    Behavior function for initializing component's variables and tables
         * @param   p_componentName Name of the component
         */
reinaortega's avatar
reinaortega committed
        function f_initialiseComponent(in charstring p_componentName) runs on ItsCalm {
            
            // Initialize variables
            vc_componentName := p_componentName;
            vc_portNumber := { portLong := c_portNon };
            
            // Set defaults
            activate(a_fntpDefault()); // Default for Fntp module
            activate(a_mgtMnSapPortDefault()); // Default for MGT module / MF-SAP port
        } // End of f_initialiseComponent
        
    } // End of group fntpConfigurationFunctions
    
    group preambles {
        
        /**
         * @desc Brings the IUT into an initial state.
         */
reinaortega's avatar
reinaortega committed
        function f_initialState() runs on ItsCalm {
            
            f_utInitializeIut(m_fntpInitialize);
            f_sleepIgnoreDef(PX_WAIT_FOR_IUT_READY); // Wait until the IUT is in a stable situation (beaconing...)
        } // 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
        function f_initializeFntpForwardingTable(in PortNumber p_port) runs on ItsCalm {
            // Request allocation of a port number associated with the ITS-SP
            // TODO Consider case of c_portDyn, and use f_utCommandRequestConfirm
            f_utCommandRequestWithoutConfirm(
                m_generateNfFntpPortCreationRequest(
                    f_getIutServiceRef(), 
            // Store the allocated port number
            vc_portNumber := p_port;
            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
            f_mnSapAwaitFWTupdate();
            
        } // 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
        function f_unInitializeFntpForwardingTable() runs on ItsCalm {
            // check c_portDyn
            // Send for FTN-SOCKET.request & Wait for FTN-SOCKET.confirm
            f_utCommandRequestConfirm(
                m_generateNfFntpPortDeletionRequest(f_getIutServiceRef(), vc_portNumber),
                mw_fntpPortConfirm(f_getIutServiceRef(), ?),
                false,
                vc_utCommandConf);
        } // End of function f_unInitializeFntpForwardingTable
        
        /**
         * @desc Trigger a basic FNTPNPDU to create an entry in forwarding table for a known peer station 
         */
reinaortega's avatar
reinaortega committed
        function f_setupKnownPeerStation() runs on ItsCalm { 
            f_acGenerateFntpNpdu( 
                f_getIutRemotePortNumberValue(), 
                vc_portNumber, 
                m_llServiceAddr(m_linkId(f_getIutWlRemoteCiidBc(), f_getIutWlLocalCiid())), 
                m_llServiceAddr(m_linkId(f_getIutRemoteDestCiidBc(), f_getIutDestLocalCiid())), 
              f_getIutShopValue() 
            );
            // TODO Do we ignore management and NF-COMM.indication messages?
        } // End of function f_setupKnownPeerStation
        
    } // End of group preambles
    
    group postambles {
        
        /**
         * @desc The default postamble.
         */
reinaortega's avatar
reinaortega committed
        function f_poDefault() runs on ItsCalm {
        }
        
    } // 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
        function f_mnSapAwaitFWTupdate() runs on ItsCalm {
            
            tc_ac.start;
            alt {
                [] a_mgtSapAwaitFWTupdate() {
                    tc_ac.stop;
                    log("*** f_mnSapAwaitFWTupdate: INFO: Expected message not received ***");
                }
                [] tc_ac.timeout {
                    log("*** f_mnSapAwaitFWTupdate: ERROR: MN-SAP FWTupdate service primitive not received ***");
                }
            } // End of 'alt' statement
        } // End of function f_mnSapAwaitFWTupdate()
        
    } // 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
        function f_acTriggerEvent(template (value) AcFntpPrimitive p_event) runs on ItsCalm {
            acPort.send(p_event);
        }
        
        /**
         * @desc    Triggers test adapter to send FNTP NDPU
         * @param   p_sourcePort TODO
         * @param   p_destinationPort TODO
         * @param   p_sourcePort IN-SAP source port
         * @param   p_destinationPort IN-SAP destination port
         * @param   p_hops N-hops value
         */
        function f_acGenerateFntpNpdu(
            in template (value) PortNumber p_sourcePort, 
            in template (value) PortNumber p_destinationPort, 
            in template (value) LLserviceAddr p_insapSourceAddress, 
            in template (value) LLserviceAddr p_insapDestAddress, 
            in FNTPhopCount p_hops 
reinaortega's avatar
reinaortega committed
        ) runs on ItsCalm { 
                m_generateFntpNpdu( 
                    p_insapSourceAddress, 
                    p_insapDestAddress, 
                            m_fntpBasicNPDU( 
                                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
         * @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 
         */
        function f_acGenerateFntpNpduInvalidCtrlField( 
            in template (value) PortNumber p_sourcePort, 
            in template (value) PortNumber p_destinationPort, 
            in template (value) LLserviceAddr p_insapSourceAddress, // TODO Rename in p_insapSourceAddress
            in template (value) LLserviceAddr p_insapDestAddress,  // TODO Rename in p_insapDestAddress
            in template (value) FNTPhopCount p_hops 
reinaortega's avatar
reinaortega committed
        ) runs on ItsCalm { 
                m_generateFntpNpdu( 
                    p_insapSourceAddress, 
                    p_insapDestAddress, 
                            md_fntpExtendedNPDU_InvalidCtrlField( 
        } // End of function f_acGenerateFntpNpduInvalidCtrlField
        
        /**
         * @desc    Triggers lower tester to send FNTP station-internal NDPU with bit5 set 
         * @param   p_sourcePort        Source port 
         * @param   p_destinationPort   Destination port 
         * @param   p_insapSourceAddress     IN-SAP source port 
         * @param   p_insapDestAddress       IN-SAP destination port 
        function f_acGenerateFntpNpduInvalidBitSet( 
            in template (value) PortNumber p_sourcePort, 
            in template (value) PortNumber p_destinationPort, 
            in template (value) LLserviceAddr p_insapSourceAddress, // TODO Rename in p_insapSourceAddress
            in template (value) LLserviceAddr p_insapDestAddress  // TODO Rename in p_insapDestAddress
reinaortega's avatar
reinaortega committed
        ) runs on ItsCalm { 
                m_generateFntpNpdu( 
                    p_insapSourceAddress, 
                    p_insapDestAddress, 
                            md_fntpExtendedNPDU_InvalidBitSet( 
                                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 
         * @param   p_insapSourceAddress     IN-SAP source port 
         * @param   p_insapDestAddress       IN-SAP destination port 
         * @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 
         */
        function f_acGenerateFntpNpduCip(
            in template (value) PortNumber p_sourcePort, 
            in template (value) PortNumber p_destinationPort, 
            in template (value) LLserviceAddr p_insapSourceAddress, // TODO Rename in p_insapSourceAddress
            in template (value) LLserviceAddr p_insapDestAddress,  // TODO Rename in p_insapDestAddress
            in template (value) FNTPhopCount p_hops, 
            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
            in template (value) AccessParameters p_accessParams 
reinaortega's avatar
reinaortega committed
        ) runs on ItsCalm { 
                m_generateFntpNpduCip( 
                    p_insapSourceAddress, 
                    p_insapDestAddress, 
                            md_fntpExtendedNPDU_CIP( 
                                p_sourcePort, 
                                p_destinationPort, 
                                p_hops, 
                                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
                            ) 
                        ) 
                    ), 
                    p_accessParams 
                ) 
            ); 
        } // End of function f_acGenerateFntpNpduCip
        
        /**
         * @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
         */
        function f_acGenerateFntpForwardingNpdu(
            in template (value) PortNumber p_sourcePort, 
            in template (value) PortNumber p_destinationPort, 
            in template (value) PortNumber p_fromPort, 
            in template (value) PortNumber p_toPort, 
            in template (value) LLserviceAddr p_insapSourceAddress, 
            in template (value) LLserviceAddr p_insapDestAddress, 
            in template (value) FNTPpacketCounter p_counter, 
            in template (value) FNTPhopCount p_hops 
reinaortega's avatar
reinaortega committed
        ) runs on ItsCalm { 
                m_generateFntpNpdu( 
                    p_insapSourceAddress, 
                    p_insapDestAddress, 
                            md_fntpForwardingNpdu( 
                                p_sourcePort, 
                                p_destinationPort, 
                                p_hops,
                                p_fromPort,
                                p_toPort,
                                p_counter 
                            ) // End of field 'md_fntpForwardingNpdu'
                        ) // End of function encvalue
                    ) // End of function bit2oct
                ) // End of field 'm_generateFntpNpdu'
        } // End of function f_acGenerateFntpForwardingNpdu
        
        /**
         * @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
         */
        function f_acGenerateFntpForwardingNpduWithUnknownItsSciId(
            in template (value) PortNumber p_sourcePort, 
            in template (value) PortNumber p_destinationPort, 
            in template (value) PortNumber p_fromPort, 
            in template (value) PortNumber p_toPort,
            in template (value) LLserviceAddr p_insapSourceAddress, 
            in template (value) LLserviceAddr p_insapDestAddress, 
            in template (value) FNTPpacketCounter p_counter, 
            in template (value) FNTPhopCount p_hops 
reinaortega's avatar
reinaortega committed
        ) runs on ItsCalm { 
                m_generateFntpNpdu( 
                    p_insapSourceAddress, 
                    p_insapDestAddress, 
                            md_fntpForwardingNpdu_UnknownITS_SCU_ID( 
                                p_sourcePort, 
                                p_destinationPort, 
                                p_hops,
                                p_fromPort,
                                p_toPort,
                                p_counter 
                            ) // End of field 'md_fntpForwardingNpdu_UnknownITS_SCU_ID'
                        ) // End of function encvalue
                    ) // End of function bit2oct
                ) // End of field 'm_generateFntpNPDU'
            ); 
        } // End of function f_acGenerateFntpForwardingNpduWithUnknownItsSciId
        
        /**
         * @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
         */
        function f_acGenerateFntpForwardingNpduCip(
            in template (value) PortNumber p_sourcePort, 
            in template (value) PortNumber p_destinationPort, 
            in template (value) PortNumber p_fromPort, 
            in template (value) PortNumber p_toPort,
            in template (value) LLserviceAddr p_insapSourceAddress, // TODO Rename in p_insapSourceAddress
            in template (value) LLserviceAddr p_insapDestAddress,  // TODO Rename in p_insapDestAddress
            in template (value) FNTPpacketCounter p_counter, 
            in template (value) FNTPhopCount p_hops, 
            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
            in template (value) AccessParameters p_accessParams 
reinaortega's avatar
reinaortega committed
        ) runs on ItsCalm { 
                m_generateFntpNpduCip( 
                    p_insapSourceAddress, 
                    p_insapDestAddress, 
                            md_fntpForwardingNpdu_CIP( 
                                p_sourcePort, 
                                p_destinationPort, 
                                p_hops, 
                                p_fromPort, 
                                p_toPort, 
                                p_counter, 
                                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
                            ) // End of field 'md_fntpForwardingNpdu_CIP'
                        ) // End of function 'encvalue'
                    ), // End of function 'bit2oct'
                    p_accessParams 
                ) 
            ); 
        } // End of function f_acGenerateFntpForwardingNpduCip
    } // 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
        function f_oct2npdu(in octetstring p_data, in charstring p_syncPoint, out FNTPNPDU p_decoded) runs on ItsCalm {
            var integer v_result;
            
            v_result := decvalue(oct2bit(p_data), p_decoded);
            if (v_result == 1) {
                f_selfOrClientSyncAndVerdictTestBody(p_syncPoint, e_error); 
                log("*** f_oct2npdu: FAIL: 'decvalue' operation failed ***");
            } else if (v_result == 2) {
                f_selfOrClientSyncAndVerdictTestBody(p_syncPoint, e_error); 
                log("*** f_oct2npdu: FAIL: 'decvalue' operation failed, not enougth bits ***");
            log("*** f_oct2npdu: INFO: Decoded message done ***");
        } // End of function f_oct2npdu
        
    } // End of group internalFunctions
    
    group iutFunctions {
        
        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;
            }
            
            /**
             * @desc   TODO
             * @return TODO
             * @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 
        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 remote CIID for unicast (peer to peer)
             * @return  The remote CIID for unicast 
             * @see     PX_WL_REMOTE_CIID_UC
             * @verdict Unchanged
             */
            function f_getIutLanRemoteCiidUc() return EUI64 {
                return PX_LAN_REMOTE_CIID_UC;
            }
            
            /**
             * @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 
        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
        /**
         * @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;
        }
        
        /**
         * @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
         */
        function f_getIutLocalPortNumberValue() return PortNumber {
            return PX_LOCAL_PORT_NUMBER;
        }
        
        /**
         * @desc   Unknown broadcast VCI
         * @return An unknown broadcast VCI
         * @see PX_LINK_ID_UNKWNON_BC
        function f_getIutLinkIdUnknownBc() return Link_ID {
            return PX_LINK_ID_UNKWNON_BC;
        }
        
        /**
         * @desc    Get the ITS-SP payload EPDU
         * @return  The ITS-SP payload EPDU
         * @see     PX_ITS_FPDU
        function f_getIutItsFpdu() return ITSfpdu { 
            return PX_ITS_FPDU;
        }
        
        /**
         * @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
         */
        function f_getIutShopValue() return FNTPhopCount {
            return PX_SHOP;
        }
        
        /**
         * @desc    Get the N-hops value
         * @return  The N-hops value
         * @verdict Unchanged
         */
        function f_getIutNhopsValue() return FNTPhopCount {
            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
         */
        function f_getIutRxCipValue() return RXcip {
            return PX_CIP_RX_SETTINGS;
        }
        
        /**
         * @desc   Get the transmission access parameter
         * @return The transmission access parameter
         * @see PX_CIP_TX_SETTINGS
         * @verdict Unchanged
         */
        function f_getIutTxCipValue() return TXcip {
         * @desc    Get the remote port number value
         * @return  The remote port number value
         * @see     PX_REMOTE_PORT_NUMBER
         * @verdict Unchanged
         */
        function f_getIutRemotePortNumberValue() return PortNumber {
            return PX_REMOTE_PORT_NUMBER;
        } // End of function f_getIutRemotePortNumberValue
        
        /**
         * @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
        
    } // End of group iutFunctions
    
    group fntpAltsteps {
        
        /**
         * @desc The base default.
         */
reinaortega's avatar
reinaortega committed
        altstep a_fntpDefault() runs on ItsCalm {
            // 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;
//            }
// FIXME Add support of response to NF-FNTP-PORT.confirm & NF-FNTP-COMM.confirm
            [] 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);
            }
            [] tc_ac.timeout { // For security because it should be done in main altsetp bloc
                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
        altstep a_cf01Down() runs on ItsCalm {
            [] 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
        altstep a_cf02Down() runs on ItsCalm {
            [] 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