Skip to content
LibItsFntp_Functions.ttcn3 40.8 KiB
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;
    };
    // 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 {
            
            // Sanity check
            if (PICS_ITS_S_INW) {
                log("*** f_cf01Up: ERROR: PICS_ITS_S_INW shall not be required for executing the TC ***");
                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");

            // 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 executing the TC ***");
                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 };
            vc_scuId := 255;
            
            // 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_getIutSrcRemoteCIID_BC(), f_getIutSrcLocalCIID())), 
                m_llServiceAddr(m_linkID(f_getIutRemoteDestCIID_BC(), 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()
        
        /**
         * @desc    Generate a correctly formatted GCctxTxCmd message via IN-SAP interface
         * @param   p_commandRef  Unique cyclic reference number of command. Same value as in related MN-REQUEST.request
         * @param   p_linkID      Link ID of the peer station
         * @param   p_clientID    TODO
         * @verdict Unchanged
         */
        // FIXME To be removed - Moved on NF-SAP
reinaortega's avatar
reinaortega committed
//        function f_mnSapGenerateGCctxTxCmd(in CommandRef p_commandRef, in Link_ID p_linkID, in ITSaid p_clientID) runs on ItsCalm {
//            f_mgtGenerateGCctxTxCmd(
//                p_commandRef, 
//                m_gCctxTxCmd(
//                    f_getIutINSapAddress(), 
//                    p_linkID, 
//                    p_clientID
//                )
//            );
//        }
        
        /**
         * @desc    Generate a correctly formatted SAM/CTXrxNot message from peer station via IN-SAP interface
         * @param   p_commandRef  Unique cyclic reference number of command. Same value as in related MN-REQUEST.request
         * @param   p_linkID      Link ID of the peer station
         * @param   p_clientID    
         * @verdict Unchanged
         */
        // FIXME To be removed - Moved on NF-SAP
reinaortega's avatar
reinaortega committed
//        function f_mnSapGenerateCTXrxNot(in CommandRef p_commandRef, in Link_ID p_linkID, in ITSaid p_clientID) runs on ItsCalm {
//            f_mgtGenerateCTXrxNot(
//                p_commandRef, 
//                m_cTXrxNot(
//                    f_getIutINSapAddress(), 
//                    p_linkID, 
//                    p_clientID
//                )
//            );
//        }
        
    } // 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 { 
            f_acTriggerEvent( 
                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_acGenerateFntpNPDU_InvalidCtrlField( 
            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 { 
            f_acTriggerEvent(
                m_generateFntpNPDU( 
                    p_insapSourceAddress, 
                    p_insapDestAddress, 
                            md_fntpExtendedNPDU_InvalidCtrlField( 
                                p_sourcePort, 
                                p_destinationPort, 
                                p_hops 
                            ) 
                        ) 
                    ) 
                ) 
            ); 
        } // End of function f_acGenerateFntpNPDU_InvalidCtrlField
        
        /**
         * @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_acGenerateFntpNPDU_InvalidBitSet( 
            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 { 
            f_acTriggerEvent(
                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_acGenerateFntpNPDU_CIP(
            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 { 
            f_acTriggerEvent( 
                m_generateFntpNPDU_CIP( 
                    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_acGenerateFntpNPDU_CIP
        
        /**
         * @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, // 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 
reinaortega's avatar
reinaortega committed
        ) runs on ItsCalm { 
            f_acTriggerEvent( 
                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_acGenerateFntpForwardingNPDU_UnknownITS_SCU_ID(
            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 
reinaortega's avatar
reinaortega committed
        ) runs on ItsCalm { 
            f_acTriggerEvent( 
                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_acGenerateFntpForwardingNPDU_UnknownITS_SCU_ID
        
        /**
         * @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_acGenerateFntpForwardingNPDU_CIP(
            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 { 
            f_acTriggerEvent( 
                m_generateFntpNPDU_CIP( 
                    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_acGenerateFntpForwardingNPDU_CIP
        
    } // 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 {
        
        /**
         * @desc    Get the local identifier of the VCI
         * @return  The local identifier of the VCI
         * @see     PX_SRC_LOCAL_CIID
         * @verdict Unchanged
         * @see ISO 21218 - Clause 6.2 Link Identifier
         */
        function f_getIutSrcLocalCIID() return EUI64 {
            return PX_SRC_LOCAL_CIID;
        }
        
        /**
         * @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 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_SRC_REMOTE_CIID_BC
         * @verdict Unchanged
         */
        function f_getIutSrcRemoteCIID_BC() return EUI64 {
            return PX_SRC_REMOTE_CIID_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_SRC_DIFFERENT_LOCAL_CIID
         * @verdict Unchanged
         */
        function f_getIutSrcDifferentLocalCIID() return EUI64 {
            return PX_SRC_DIFFERENT_LOCAL_CIID;
        }
        
        /**
         * @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_SRC_SECOND_REMOTE_CIID_UC
         * @verdict Unchanged
         */
        function f_getIutSrcSecondRemoteCIID() return EUI64 {
            return PX_SRC_SECOND_REMOTE_CIID_UC;
        }
        
        /**
         * @desc    Get the remote CIID for unicast (peer to peer)
         * @return  The remote CIID for unicast 
         * @see     PX_SRC_REMOTE_CIID_UC
         * @verdict Unchanged
         */
        function f_getIutSrcRemoteCIID_UC() return EUI64 {
            return PX_SRC_REMOTE_CIID_UC;
        }
        
        /**
         * @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_getIutDestRemoteCIID() return EUI64 {
            return PX_DEST_REMOTE_CIID_UC;
        }
        
        /**
         * @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    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_getIutRemoteDestCIID_BC() return EUI64 {
            return PX_DEST_REMOTE_CIID_BC;
        }
        
        /**
         * @desc    Get the IUT Link-ID in broadcast transmission mode
         * @return  The IUT Link-ID in broadcast transmission mode
         * @see     PX_LINK_ID_BC
         * @verdict Unchanged
         * @see ISO 21218 - Clause 6.2 Link Identifier
         */
        function f_getIutLinkId_BC() return Link_ID {
            return PX_LINK_ID_BC;
        }
        
        /**
         * @desc   TODO
         * @return TODO
         * @verdict Unchanged
         */
        function f_getIutLinkId_BC_Router() return Link_ID {
            return PX_LINK_ID_BC_WITH_SECOND_SCU_ID;
        }
        
//        /**
//         * @desc   TODO
//         * @return TODO
//         * @verdict Unchanged
//         */
//        function f_getIutLinkId_BC_WithThirdScuId() return Link_ID {
//            return PX_LINK_ID_BC_WITH_THIRD_SCU_ID;
//        }
//        
//        /**
//         * @desc   TODO
//         * @return TODO
//         * @verdict Unchanged
//         */
//        function f_getIutLinkId_BC_WithFourthScuId() return Link_ID {
//            return PX_LINK_ID_BC_WITH_FOURTH_SCU_ID;
//        }
//        
        /**
         * @desc    Get the IUT Link-ID in multicast transmission mode
         * @return  The IUT Link-ID in broadcast transmission mode
         * @see     PX_LINK_ID_BC
         * @verdict Unchanged
         */
        function f_getIutLinkId_MC() return Link_ID {
            return PX_LINK_ID_MC;
        }
        
        /**
         * @desc   TODO
         * @return TODO
         * @verdict Unchanged
         */
        function f_getIutLinkId_UNKWNON_BC() return Link_ID {
            return PX_LINK_ID_UNKWNON_BC;
        }
        
        /**
         * @desc   TODO
         * @return TODO
         * @verdict Unchanged
         */
        function f_getIutLinkId_UNKWNON_UC() return Link_ID {
            return PX_LINK_ID_UNKWNON_UC;
        }
        
        /**
         * @desc   TODO
         * @return TODO
         * @verdict Unchanged
         */
        function f_getIutLinkId_UC() return Link_ID {
            return PX_LINK_ID_UC;
        }
        
//        /**
//         * @desc    Get the IUT station identifier
//         * @return  The IUT station identifier
//         * @see     PX_STATION_ID
//         * @verdict Unchanged
//         */
//        function f_getIutStationId() return StationID {
//            return PX_STATION_ID;
//        }
//        
        /**
         * @desc    Get an unknown IUT station identifier
         * @return  An unknown IUT station identifier
         * @see     PX_STATION_ID_UNKNOWN
         * @verdict Unchanged
         */
        function f_getIutStationId_UNKWNON() return StationID { // FIXME Rename into f_getIutPeerStationId
            return PX_STATION_ID_UNKNOWN;
        }
        
        /**
         * @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 the  host scuID value
         * @return  The host scuID value
         * @see     PX_HOST_SCU_ID
         * @verdict Unchanged
         */
        function f_getIutHostScuIdValue() return ITS_scuId {
            return PX_HOST_SCU_ID;
        }
        
        /**
         * @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 {
            return PX_CIP_TX_SETTINGS;
        }
        
        /**
         * @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