CORDET Framework - C2 Implementation
CrFwInStream.c File Reference

Implementation of InStream State Machine. More...

Go to the source code of this file.

Functions

static int IsPcktQueueEmpty (FwSmDesc_t smDesc)
 Function which checks if the packet queue is empty. More...
 
static int IsPcktAvail (FwSmDesc_t smDesc)
 Function which checks if a packet is available. More...
 
static void DoActionA (FwSmDesc_t smDesc)
 Function which performs Action A in the InStream State Machine. More...
 
static void DoActionB (FwSmDesc_t smDesc)
 Function which performs Action b in the InStream State Machine. More...
 
FwSmDesc_t CrFwInStreamMake (CrFwInstanceId_t i)
 Factory function to retrieve the i-th InStream State Machine instance. More...
 
FwSmDesc_t CrFwInStreamGet (CrFwDestSrc_t src)
 Getter function for the InStream corresponding to the argument source. More...
 
CrFwBool_t CrFwInStreamIsInWaiting (FwSmDesc_t smDesc)
 Return true if the argument InStream is in state WAITING. More...
 
CrFwBool_t CrFwInStreamIsInPcktAvail (FwSmDesc_t smDesc)
 Return true if the argument InStream is in state PCKT_AVAIL. More...
 
CrFwPckt_t CrFwInStreamGetPckt (FwSmDesc_t smDesc)
 Retrieve a packet from the InStream. More...
 
void CrFwInStreamPcktAvail (FwSmDesc_t smDesc)
 Query the middleware for available packets and collect them if they are available. More...
 
CrFwDestSrc_t CrFwInStreamGetSrc (FwSmDesc_t smDesc)
 Get the currently defined packet source of an InStream. More...
 
CrFwSeqCnt_t CrFwInStreamGetSeqCnt (FwSmDesc_t smDesc, CrFwGroup_t group)
 Return the value of the sequence counter of the last packet successfully collected by the InStream for a group. More...
 
void CrFwInStreamSetSeqCnt (FwSmDesc_t smDesc, CrFwGroup_t group, CrFwSeqCnt_t seqCnt)
 Overwrites the sequence counter value of the last packet for a group. More...
 
CrFwCounterU1_t CrFwInStreamGetNOfPendingPckts (FwSmDesc_t smDesc)
 Return the number of packets currently in the packet queue of an InStream. More...
 
CrFwGroup_t CrFwInStreamGetNOfGroups (FwSmDesc_t smDesc)
 Return the number of groups associated to the InStream. More...
 
CrFwCounterU1_t CrFwInStreamGetPcktQueueSize (FwSmDesc_t smDesc)
 Return the size of the packet queue of the InStream. More...
 
void CrFwInStreamDefConfigAction (FwPrDesc_t prDesc)
 Default configuration action for an InStream. More...
 
void CrFwInStreamDefShutdownAction (FwSmDesc_t smDesc)
 Default shutdown action for an InStream. More...
 
void CrFwInStreamDefInitAction (FwPrDesc_t prDesc)
 Default initialization action for an InStream. More...
 

Variables

static FwSmDesc_t baseInStreamSmDesc = NULL
 Base InStream from which all other InStreams are derived. More...
 
static CrFwCounterU1_t inStreamPcktQueueSize [CR_FW_NOF_INSTREAM] = CR_FW_INSTREAM_PQSIZE
 The sizes of the packet queues in the InStream components. More...
 
static CrFwGroup_t inStreamNOfGroups [CR_FW_NOF_INSTREAM] = CR_FW_INSTREAM_NOF_GROUPS
 The number of groups associated to the InStream components. More...
 
static CrFwPcktCollect_t inStreamPcktCollect [CR_FW_NOF_INSTREAM] = CR_FW_INSTREAM_PCKTCOLLECT
 The functions implementing the packet hand-over operations for the InStream components. More...
 
static CrFwPcktAvailCheck_t inStreamPcktAvailCheck [CR_FW_NOF_INSTREAM] = CR_FW_INSTREAM_PCKTAVAILCHECK
 The functions implementing the packet available check operations for the InStream components. More...
 
static FwPrAction_t inStreamInitCheck [CR_FW_NOF_INSTREAM] = CR_FW_INSTREAM_INITCHECK
 The functions implementing the initialization checks for the InStream components. More...
 
static FwPrAction_t inStreamInitAction [CR_FW_NOF_INSTREAM] = CR_FW_INSTREAM_INITACTION
 The functions implementing the initialization actions for the InStream components. More...
 
static FwPrAction_t inStreamConfigCheck [CR_FW_NOF_INSTREAM] = CR_FW_INSTREAM_CONFIGCHECK
 The functions implementing the configuration checks for the InStream components. More...
 
static FwPrAction_t inStreamConfigAction [CR_FW_NOF_INSTREAM] = CR_FW_INSTREAM_CONFIGACTION
 The functions implementing the configuration actions for the InStream components. More...
 
static FwSmAction_t inStreamShutdownAction [CR_FW_NOF_INSTREAM] = CR_FW_INSTREAM_SHUTDOWNACTION
 The functions implementing the shutdown actions for the InStream components. More...
 
static CrFwDestSrc_t inStreamSrc [CR_FW_NOF_INSTREAM] = CR_FW_INSTREAM_SRC
 The sources associated to the InStream components. More...
 
static FwSmDesc_t inStreamDesc [CR_FW_NOF_INSTREAM]
 The descriptors of the InStream State Machines. More...
 
static CrFwCmpData_t inStreamData [CR_FW_NOF_INSTREAM]
 The data structures for the InStream State Machines and their Procedures. More...
 
static CrFwInStreamData_t inStreamCmpSpecificData [CR_FW_NOF_INSTREAM]
 The component-specific data for the InStream State Machines and their Procedures. More...
 

Detailed Description

Implementation of InStream State Machine.

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 CrFwInStream.c.

Function Documentation

void CrFwInStreamDefConfigAction ( FwPrDesc_t  prDesc)

Default configuration action for an InStream.

This function resets the packet queue of the InStream. Configuration actions have an outcome (see CrFwResetProc.h). The outcome of this configuration action is always: "success".

This function should never be directly called by the end-application. It is declared as a public function so that it may be used in application-specific Configuration Actions.

Parameters
prDescthe descriptor of the Reset Procedure of the InStream

Definition at line 288 of file CrFwInStream.c.

void CrFwInStreamDefInitAction ( FwPrDesc_t  prDesc)

Default initialization action for an InStream.

This function: (a) allocates the memory for the packet queue of the InStream; (b) allocates the memory for the array holding the sequence counters for the destination/source groups associated to the Instream; and (c) initializes all data structures implementing the InStream. Initialization actions have an outcome (see CrFwResetProc.h). The situation of where the memory allocation fails is not handled and therefore the outcome of this configuration action is always "success".

This function should never be directly called by the end-application. It is declared as a public function so that it may be used in application-specific Initialization Actions.

Parameters
prDescthe descriptor of the Initialization Procedure of the InStream

Definition at line 312 of file CrFwInStream.c.

void CrFwInStreamDefShutdownAction ( FwSmDesc_t  smDesc)

Default shutdown action for an InStream.

This function releases the memory allocated to the packet queue of the InStream and releases the memory allocated to the array holding the sequence counters.

This function should never be directly called by the end-application. It is declared as a public function so that it may be used in application-specific Shutdown Actions.

Parameters
smDescthe descriptor of the InStream State Machine

Definition at line 301 of file CrFwInStream.c.

FwSmDesc_t CrFwInStreamGet ( CrFwDestSrc_t  src)

Getter function for the InStream corresponding to the argument source.

Nominally, each InStream is associated to a certain packet source. The binding between an InStream and its source is done statically in the configuration file CrFwInStreamUserPar.h.

If the value of the source argument is illegal (i.e. if no InStream has been bound to it), this function returns NULL and sets the application error code to: crInStreamUndefDest.

This function should only be called after all InStreams have been built through calls to function CrFwInStreamMake. If this pre-condition is not satisfied, execution of this function could result in an access to a NULL pointer.

Parameters
srcthe packet source associated to the InStream
Returns
the descriptor of the InStream State Machine or NULL if the argument source was illegal or no InStream had been bound to it.

Definition at line 211 of file CrFwInStream.c.

CrFwGroup_t CrFwInStreamGetNOfGroups ( FwSmDesc_t  smDesc)

Return the number of groups associated to the InStream.

Parameters
smDescthe descriptor of the Base State Machine of the InStream.
Returns
the number of groups associated to the InStream.

Definition at line 275 of file CrFwInStream.c.

CrFwCounterU1_t CrFwInStreamGetNOfPendingPckts ( FwSmDesc_t  smDesc)

Return the number of packets currently in the packet queue of an InStream.

Parameters
smDescthe descriptor of the InStream State Machine
Returns
the number of packets currently in the packet queue of the InStream.

Definition at line 268 of file CrFwInStream.c.

CrFwPckt_t CrFwInStreamGetPckt ( FwSmDesc_t  smDesc)

Retrieve a packet from the InStream.

This function sends the GetPacket command to the InStream State Machine. If, at the time the function is called, the InStream is in state PCKT_AVAIL (i.e. if the InStream is configured and its packet queue is not empty), the function returns the oldest packet currently in the Packet Queue of the InStream; otherwise, the function return NULL.

Parameters
smDescthe descriptor of the Base State Machine of the InStream.
Returns
pckt the oldest packet in the packet queue or NULL if there is no packet in the packet queue.

Definition at line 232 of file CrFwInStream.c.

CrFwCounterU1_t CrFwInStreamGetPcktQueueSize ( FwSmDesc_t  smDesc)

Return the size of the packet queue of the InStream.

Parameters
smDescthe descriptor of the InStream State Machine
Returns
the size of the packet queue of the InStream.

Definition at line 281 of file CrFwInStream.c.

CrFwSeqCnt_t CrFwInStreamGetSeqCnt ( FwSmDesc_t  smDesc,
CrFwGroup_t  group 
)

Return the value of the sequence counter of the last packet successfully collected by the InStream for a group.

If no packet has yet been collected for that group after the InStream was reset, the sequence counter is equal to zero.

Parameters
smDescthe descriptor of the InStream State Machine
groupthe identifier of the group
Returns
the InStream sequence counter

Definition at line 253 of file CrFwInStream.c.

CrFwDestSrc_t CrFwInStreamGetSrc ( FwSmDesc_t  smDesc)

Get the currently defined packet source of an InStream.

An InStream can receive packets from one (and only one) source. A source has an identifier of type CrFwDestSrc_t.

Parameters
smDescthe descriptor of the Base State Machine of the InStream.
Returns
src the source associated to the OutStream

Definition at line 246 of file CrFwInStream.c.

CrFwBool_t CrFwInStreamIsInPcktAvail ( FwSmDesc_t  smDesc)

Return true if the argument InStream is in state PCKT_AVAIL.

Parameters
smDescthe descriptor of the Base State Machine of the InStream.
Returns
1 if the argument InStream is in state CONFIGURED, sub-state PCKT_AVAIL; 0 otherwise.

Definition at line 227 of file CrFwInStream.c.

CrFwBool_t CrFwInStreamIsInWaiting ( FwSmDesc_t  smDesc)

Return true if the argument InStream is in state WAITING.

Parameters
smDescthe descriptor of the Base State Machine of the InStream.
Returns
1 if the argument InStream is in state CONFIGURED, sub-state WAITING; 0 otherwise.

Definition at line 222 of file CrFwInStream.c.

FwSmDesc_t CrFwInStreamMake ( CrFwInstanceId_t  inStreamId)

Factory function to retrieve the i-th InStream State Machine instance.

The first time this function is called with a certain value of the argument i, it creates the i-th InStream State Machine instance. Subsequent calls returns the same instance.

The InStream identifier i must be in the range: [0, CR_FW_NOF_INSTREAM-1]. If the identifier is out of range, the function returns NULL and sets the application error code to: crInStreamIllId.

The first time this function is called with a certain value of i, it returns an InStream State Machine which has been started but which must still be initialized and configured.

Parameters
inStreamIdthe identifier of the InStream
Returns
the descriptor of the Base State Machine of the InStream or NULL if the state machine could not be created or if the identifier i is out of range.

Definition at line 121 of file CrFwInStream.c.

void CrFwInStreamPcktAvail ( FwSmDesc_t  smDesc)

Query the middleware for available packets and collect them if they are available.

This function sends the PacketAvailable command to the InStream State Machine. This command may be sent to the InStream by the middleware to signal the arrival of a new packet at the connection controlled by the InStream or it may be sent to poll the middleware and check whether any packets are available. If packets are available at the middleware, they are collected and stored in the InStream's Packet Queue.

Parameters
smDescthe descriptor of the Base State Machine of the InStream.

Definition at line 241 of file CrFwInStream.c.

void CrFwInStreamSetSeqCnt ( FwSmDesc_t  smDesc,
CrFwGroup_t  group,
CrFwSeqCnt_t  seqCnt 
)

Overwrites the sequence counter value of the last packet for a group.

Can be used to update the expected sequence counter value for the next packet.

Parameters
smDescthe descriptor of the InStream State Machine
groupthe identifier of the group
seqCntthe InStream sequence counter

Definition at line 260 of file CrFwInStream.c.

static void DoActionA ( FwSmDesc_t  smDesc)
static

Function which performs Action A in the InStream State Machine.

This function is used as a transition action in the InStream State Machine.

Parameters
smDescthe state machine descriptor
Returns
1 if the packet queue is empty; zero otherwise.

Definition at line 322 of file CrFwInStream.c.

static void DoActionB ( FwSmDesc_t  smDesc)
static

Function which performs Action b in the InStream State Machine.

This function is used as a transition action in the InStream State Machine.

Parameters
smDescthe state machine descriptor
Returns
1 if the packet queue is empty; zero otherwise.

Definition at line 329 of file CrFwInStream.c.

static int IsPcktAvail ( FwSmDesc_t  smDesc)
static

Function which checks if a packet is available.

This function is used as guard for the transition into state WAITING.

Parameters
smDescthe state machine descriptor
Returns
1 if the packet queue is empty; zero otherwise.

Definition at line 363 of file CrFwInStream.c.

static int IsPcktQueueEmpty ( FwSmDesc_t  smDesc)
static

Function which checks if the packet queue is empty.

This function is used as guard for the transition into state WAITING.

Parameters
smDescthe state machine descriptor
Returns
1 if the packet queue is empty; zero otherwise.

Definition at line 371 of file CrFwInStream.c.

Variable Documentation

FwSmDesc_t baseInStreamSmDesc = NULL
static

Base InStream from which all other InStreams are derived.

Definition at line 46 of file CrFwInStream.c.

CrFwInStreamData_t inStreamCmpSpecificData[CR_FW_NOF_INSTREAM]
static

The component-specific data for the InStream State Machines and their Procedures.

Definition at line 85 of file CrFwInStream.c.

FwPrAction_t inStreamConfigAction[CR_FW_NOF_INSTREAM] = CR_FW_INSTREAM_CONFIGACTION
static

The functions implementing the configuration actions for the InStream components.

Definition at line 70 of file CrFwInStream.c.

FwPrAction_t inStreamConfigCheck[CR_FW_NOF_INSTREAM] = CR_FW_INSTREAM_CONFIGCHECK
static

The functions implementing the configuration checks for the InStream components.

Definition at line 67 of file CrFwInStream.c.

CrFwCmpData_t inStreamData[CR_FW_NOF_INSTREAM]
static

The data structures for the InStream State Machines and their Procedures.

Definition at line 82 of file CrFwInStream.c.

FwSmDesc_t inStreamDesc[CR_FW_NOF_INSTREAM]
static

The descriptors of the InStream State Machines.

Definition at line 79 of file CrFwInStream.c.

FwPrAction_t inStreamInitAction[CR_FW_NOF_INSTREAM] = CR_FW_INSTREAM_INITACTION
static

The functions implementing the initialization actions for the InStream components.

Definition at line 64 of file CrFwInStream.c.

FwPrAction_t inStreamInitCheck[CR_FW_NOF_INSTREAM] = CR_FW_INSTREAM_INITCHECK
static

The functions implementing the initialization checks for the InStream components.

Definition at line 61 of file CrFwInStream.c.

The number of groups associated to the InStream components.

Definition at line 52 of file CrFwInStream.c.

The functions implementing the packet available check operations for the InStream components.

Definition at line 58 of file CrFwInStream.c.

The functions implementing the packet hand-over operations for the InStream components.

Definition at line 55 of file CrFwInStream.c.

CrFwCounterU1_t inStreamPcktQueueSize[CR_FW_NOF_INSTREAM] = CR_FW_INSTREAM_PQSIZE
static

The sizes of the packet queues in the InStream components.

Definition at line 49 of file CrFwInStream.c.

FwSmAction_t inStreamShutdownAction[CR_FW_NOF_INSTREAM] = CR_FW_INSTREAM_SHUTDOWNACTION
static

The functions implementing the shutdown actions for the InStream components.

Definition at line 73 of file CrFwInStream.c.

The sources associated to the InStream components.

Definition at line 76 of file CrFwInStream.c.

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