CORDET Framework - C2 Implementation
|
Implementation of Socket-Based InStream. More...
Go to the source code of this file.
Macros | |
#define | h_addr h_addr_list[0] /* for backward compatibility */ |
Functions | |
void | CrFwInStreamSocketInitAction (FwPrDesc_t prDesc) |
Initialization action for the socket-based InStream. More... | |
void | CrFwInStreamSocketShutdownAction (FwSmDesc_t smDesc) |
Shutdown action for the socket-based InStream. More... | |
void | CrFwInStreamSocketInitCheck (FwPrDesc_t prDesc) |
Initialization check for the socket-based InStream. More... | |
void | CrFwInStreamSocketConfigAction (FwPrDesc_t prDesc) |
Configuration action for the socket-based InStream. More... | |
void | CrFwInStreamSocketPoll (FwSmDesc_t inStream) |
Poll the socket to check whether a new packet has arrived. More... | |
CrFwPckt_t | CrFwInStreamSocketPcktCollect (CrFwDestSrc_t src) |
Function implementing the Packet Collect Operation for the socket-based InStream. More... | |
CrFwBool_t | CrFwInStreamSocketIsPcktAvail (CrFwDestSrc_t src) |
Function implementing the Packet Available Check Operation for the InStream. More... | |
void | CrFwInStreamSocketSetPort (unsigned short n) |
Set the port number for the socket. More... | |
void | CrFwInStreamSocketSetHost (char *name) |
Set the host name of the server. More... | |
Variables | |
static unsigned short | portno = 0 |
The port number. | |
static char * | hostName = NULL |
The host name. | |
static int | sockfd |
The file descriptor for the socket. | |
static unsigned int | pcktMaxLength |
The maximum size of an incoming packet. | |
static unsigned char * | readBuffer |
The Read Buffer. | |
Implementation of Socket-Based InStream.
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 tests/CrFwInStreamSocket.c.
void CrFwInStreamSocketConfigAction | ( | FwPrDesc_t | prDesc | ) |
Configuration action for the socket-based InStream.
This action clears the Read Buffer and executes the the Configuration Action of the base InStream (function CrFwInStreamDefConfigAction
)
prDesc | the configuration procedure descriptor. |
Definition at line 156 of file tests/CrFwInStreamSocket.c.
void CrFwInStreamSocketInitAction | ( | FwPrDesc_t | prDesc | ) |
Initialization action for the socket-based InStream.
This action:
CrFwInStreamDefInitAction
)prDesc | the initialization procedure descriptor. |
Definition at line 70 of file tests/CrFwInStreamSocket.c.
void CrFwInStreamSocketInitCheck | ( | FwPrDesc_t | prDesc | ) |
Initialization check for the socket-based InStream.
The check is successful if: the maximum length of a packet (as retrieved from CrFwPcktGetMaxLength
) is smaller than 256; and the port number and server host name have been set.
prDesc | the initialization procedure descriptor. |
Definition at line 133 of file tests/CrFwInStreamSocket.c.
CrFwBool_t CrFwInStreamSocketIsPcktAvail | ( | CrFwDestSrc_t | src | ) |
Function implementing the Packet Available Check Operation for the InStream.
This function implements the following logic:
src | the source associated to the InStream (not used in this stub) |
Definition at line 200 of file tests/CrFwInStreamSocket.c.
CrFwPckt_t CrFwInStreamSocketPcktCollect | ( | CrFwDestSrc_t | src | ) |
Function implementing the Packet Collect Operation for the socket-based InStream.
If the Read Buffer is full, this function:
CrFwPcktMake
If the Read Buffer is empty, this function returns NULL. Note that the logic of the socket-based InStream guarantees that the Read Buffer will always be full when this function is called.
src | the source associated to the InStream (not used in this stub) |
Definition at line 186 of file tests/CrFwInStreamSocket.c.
void CrFwInStreamSocketPoll | ( | FwSmDesc_t | inStream | ) |
Poll the socket to check whether a new packet has arrived.
This function should be called periodically by an external scheduler. It performs a non-blocking read on the socket to check whether a packet is available at the socket. If a packet is available, it is placed into the Read Buffer and then function CrFwInStreamPcktAvail
is called to signal the arrival of a new packet.
inStream | the socket-based InStream |
Definition at line 165 of file tests/CrFwInStreamSocket.c.
void CrFwInStreamSocketSetHost | ( | char * | name | ) |
Set the host name of the server.
If a local socket is being created, the host name should be set to "localhost".
name | the host number. |
Definition at line 233 of file tests/CrFwInStreamSocket.c.
void CrFwInStreamSocketSetPort | ( | unsigned short | n | ) |
Set the port number for the socket.
The port number must be an integer greater than 2000.
n | the port number. |
Definition at line 228 of file tests/CrFwInStreamSocket.c.
void CrFwInStreamSocketShutdownAction | ( | FwSmDesc_t | smDesc | ) |
Shutdown action for the socket-based InStream.
This action executes the Shutdown Action of the base InStream (function CrFwInStreamDefShutdownAction
), releases the Read Buffer, and closes the socket.
smDesc | the InStream State Machine descriptor (this parameter is not used). |
Definition at line 126 of file tests/CrFwInStreamSocket.c.