Skip to content
LibItsFntp_Functions.ttcn3 45.9 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 CITSapplMgmtApplReg language "ASN.1:1997" { // TODO To be removed
//        type ITSaid
//    };
    import from CALMmanagement language "ASN.1:1997" { 
        type StationID, ITS_scuId; 
    }; 
    import from CALMiitsscu language "ASN.1:1997" { 
        type 
            IIC_Request, IIC_Response 
    }; 
    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 CALMfsap language "ASN.1:1997" {
        type 
            CTX, SAM 
    };
    import from LibItsFsap_Templates {
        template 
            m_sam, m_ctx
    };
    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;
    };
    import from LibItsCommon_TypesAndValues {
        type UtCommandConfirm
    };
    import from LibItsCommon_Functions {
        function
            f_utInitializeIut, 
            f_utCommandRequestConfirm, f_utCommandRequestWithoutConfirm
    };
    import from LibIts_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>
         */
        function f_cf01Up() runs on ItsNt {
            
            // 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>
         */
        function f_cf02Up() runs on ItsNt {
            
            // 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
         */
        function f_cf01Down() runs on ItsNt {
            
            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
        
        function f_cf02Down() runs on ItsNt {
            
            deactivate;
            
            // Unmap
            unmap(self:acPort, system:acPort);
            unmap(self:utPort, system:utPort);
            unmap(self:fntpPort, system:fntpPort);
            
            // Disconnect
            f_disconnect4SelfOrClientSync();
            
        } // end f_cf02Down
        
        /**
         * @desc    Behavior function for initializing component's variables and tables
         * @param   p_componentName Name of the component
         */
        function f_initialiseComponent(in charstring p_componentName) runs on ItsNt {
            
            // 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 f_initialiseComponent
        
    } // End of group fntpConfigurationFunctions
    
    group preambles {
        
        /**
         * @desc Brings the IUT into an initial state.
         */
        function f_initialState() runs on ItsNt {
            
            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
        
Loading full blame...