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(), 
Loading full blame...