CORDET Framework - C2 Implementation

Definition of the InLoader component. More...

Go to the source code of this file.

Typedefs

typedef CrFwDestSrc_t(* CrFwInLoaderGetReroutingDest_t) (CrFwDestSrc_t)
 Type for a pointer to the function which determines the re-routing destination of a packet. More...
 
typedef CrFwInstanceId_t(* CrFwInLoaderGetInManager_t) (CrFwServType_t, CrFwServSubType_t, CrFwDiscriminant_t, CrFwCmdRepType_t)
 Type for a pointer to the function which selects the InManager where the InCommand or InReport must be loaded. More...
 

Functions

FwSmDesc_t CrFwInLoaderMake ()
 Factory function to retrieve the state machine implementing the InLoader singleton component. More...
 
CrFwDestSrc_t CrFwInLoaderDefGetReroutingDestination (CrFwDestSrc_t pcktDest)
 Default implementation of the function which checks the legality of a destination and returns the re-routing destination. More...
 
CrFwDestSrc_t CrFwInLoaderDefNoRerouting (CrFwDestSrc_t pcktDest)
 Default implementation of the function which checks the legality of a destination and returns the re-routing destination. More...
 
CrFwInstanceId_t CrFwInLoaderDefGetInManager (CrFwServType_t servType, CrFwServSubType_t servSubType, CrFwDiscriminant_t discriminant, CrFwCmdRepType_t cmdRepFlag)
 Default implementation of the function which selects the InManager to which an incoming InReport or InCommand must be loaded. More...
 
void CrFwInLoaderSetInStream (FwSmDesc_t inStream)
 Set the InStream from which the packets will be retrieved the next time the InLoader is executed. More...
 

Detailed Description

Definition of the InLoader component.

The InLoader component is responsible for retrieving incoming packets which become available at an InStream (see CrFwInStream.h).

The InLoader component is a singleton component. It is defined as an extension of the Base Component (see CrFwBaseCmp.h). It overrides its execution procedure with the InLoader Execution Procedure shown in the figure:

InLoaderExecution.png

The Load/Command Report Procedure is shown in the next figure:

InLoaderLoadCommandReport.png

Execution of the InLoader causes a query to be made on InStream to check whether a packet is available at that InStream. If a packet is available, it is collected and if it passes its acceptance check, it is loaded in an InManager. The selection of the InManager is an adaptation point implemented through a function pointer defined in CrFwInLoaderUserPar.h.

The acceptance check is split into four sub-checks:

  1. The type/sub-type/discriminant of the incoming command or report is valid (i.e. it is defined in CrFwInFactoryUserPar.h and is therefore known to the application);
  2. The InFactory has sufficient resources to provide an InCommand or InReport component to hold the command or report encapsulated in the packet;
  3. The InCommand or InReport is successfully configured (i.e. it enters state CONFIGURED);
  4. The InCommand or InReport is successfully loaded in the InManager.

Sub-checks 1, 2 and 4 are fully implemented at framework level. Sub-check 3 is application-specific. It is called the Validity Check because it verifies the validity of the parameters of the incoming report or command and is implemented by a user-provided function which must conform to the prototype of function pointers CrFwInRepValidityCheck_t for incoming reports or CrFwInCmdValidityCheck_t for incoming commands. The functions implementing the validity checks are defined in CrFwInFactoryUserPar.h.

Function InLoaderLoadCmdRep in the InLoader is responsible for checking whether the sub-checks are passed. For incoming commands, failure to pass a sub-check is handled as follows:

If all sub-checks is passed, the incoming command is declared "accepted" and, if acknowledgement of successful acceptance for the command was required, function CrFwRepInCmdOutcome is called with the outcome set to crCmdAckAccSucc.

For incoming reports, failure to pass a sub-check is treated as an error and is handled as follows:

Mode of Use of an InLoader Component

The configuration of the InLoader components is defined statically in CrFwInLoaderUserPar.h.

The InLoader singleton component is created with function CrFwInLoaderMake. After being created, the InLoader must be initialized and reset. This is done with functions CrFwCmpInit and CrFwCmpReset. Nominally, after being initialized and reset the InManager State Machine should be in state CONFIGURED (this can be checked by verifying that function FwSmGetCurState returns CR_FW_BASE_STATE_CONFIGURED).

After an InLoader has been configured, it can be executed by means of function FwSmExecute. Execution of an InLoader causes its Execution Procedure (see figure above) to be executed.

The InLoader should be executed either when it is known that a packet has arrived at an InStream or periodically to check whether a packet is available and, if it is, to process it. During one execution cycle, the InLoader processes one single packet from one single InStream. The target InStream is conceptually an argument of the execution command; in practice, the target InStream is passed to the InLoader through function CrFwInLoaderSetInStream.

Author
Vaclav Cechticky vacla.nosp@m.v.ce.nosp@m.chtic.nosp@m.ky@p.nosp@m.np-so.nosp@m.ftwa.nosp@m.re.co.nosp@m.m
Alessandro Pasetti paset.nosp@m.ti@p.nosp@m.np-so.nosp@m.ftwa.nosp@m.re.co.nosp@m.m

This file is part of the CORDET Framework.

This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.

For information on alternative licensing, please contact P&P Software GmbH.

Definition in file CrFwInLoader.h.

Typedef Documentation

Type for a pointer to the function which selects the InManager where the InCommand or InReport must be loaded.

The function to determine the re-routing destination of a packet is one of the adaptation points of the framework. A function which implements this operation takes as input the service type, service sub-type, and discriminant of the InReport/InCommand and a flag which indicates whether the item to be loaded in the InManaher encapsulates an InCommand or an InReport. The function returns the identifier of the selected InManager (see CrFwInManagerMake).

Definition at line 131 of file CrFwInLoader.h.

typedef CrFwDestSrc_t(* CrFwInLoaderGetReroutingDest_t) (CrFwDestSrc_t)

Type for a pointer to the function which determines the re-routing destination of a packet.

The function to determine the re-routing destination of a packet is one of the adaptation points of the framework. A function which implements this operation takes the packet destination as an argument and returns either zero (if the argument destination is invalid) or else it returns the destination to which the packet should be re-routed (if the argument destination is valid).

Definition at line 119 of file CrFwInLoader.h.

Function Documentation

CrFwInstanceId_t CrFwInLoaderDefGetInManager ( CrFwServType_t  servType,
CrFwServSubType_t  servSubType,
CrFwDiscriminant_t  discriminant,
CrFwCmdRepType_t  cmdRepFlag 
)

Default implementation of the function which selects the InManager to which an incoming InReport or InCommand must be loaded.

This default implementation returns 0 if the component to be loaded is an InCommand (namely if argument cmdRepFlag is equal to crCmdType) and it returns 1 if the component to be loaded is an InReport (namely if argument cmdRepFlag is equal to crRepType). This function must conform to the prototype defined by CrFwInLoaderGetInManager_t.

Parameters
servTypethe service type of the incoming InCommand or InReport.
servSubTypethe service sub-type of the incoming InCommand or InReport.
discriminantthe discriminant of the incoming InCommand or InReport.
cmdRepFlaga flag indicating whether the item to be loaded is an InCommand or an InReport.
Returns
the identifier of the InManager into which the incoming InCommand or InReport must be loaded.

Definition at line 241 of file CrFwInLoader.c.

CrFwDestSrc_t CrFwInLoaderDefGetReroutingDestination ( CrFwDestSrc_t  pcktDest)

Default implementation of the function which checks the legality of a destination and returns the re-routing destination.

This default implementation always assumes that the argument destination is valid and it returns it unchanged. This default implementation is suitable for applications which are acting as gateways with one level of indirection (i.e. a situation where a packet is generated by application A for application B as its final destination, but the packet is sent to application C as a re-routing destination so that the packet travels from A to B and then from B to C). This function must conform to the prototype defined by CrFwInLoaderGetReroutingDest_t.

Parameters
pcktDestthe packet destination.
Returns
the value of pcktDest.

Definition at line 230 of file CrFwInLoader.c.

CrFwDestSrc_t CrFwInLoaderDefNoRerouting ( CrFwDestSrc_t  pcktDest)

Default implementation of the function which checks the legality of a destination and returns the re-routing destination.

This default implementation always assumes that the argument destination is invalid and therefore it always returns zero. This default implementation is suitable for applications which do not perform any packet re-routing (i.e. applications where a packet is always sent to its final destination). This function must conform to the prototype defined by CrFwInLoaderGetReroutingDest_t.

Parameters
pcktDestthe packet destination.
Returns
the value of pcktDest.

Definition at line 235 of file CrFwInLoader.c.

FwSmDesc_t CrFwInLoaderMake ( )

Factory function to retrieve the state machine implementing the InLoader singleton component.

The first time this function is called, it creates the InLoader State Machine singleton instance. Subsequent calls returns the same instance.

The first time this function is called, it returns the InLoader State Machine after it has been started but before it has been initialized and configured.

Returns
the descriptor of the InLoader State Machine or NULL if the state machine could not be created.

Definition at line 86 of file CrFwInLoader.c.

void CrFwInLoaderSetInStream ( FwSmDesc_t  inStream)

Set the InStream from which the packets will be retrieved the next time the InLoader is executed.

Parameters
inStreamthe InStream from which the packets will be retrieved the next time the InLoader is executed.

Definition at line 128 of file CrFwInLoader.c.

P&P Software GmbH, Copyright 2012-2013, All Rights Reserved