CORDET Framework - C2 Implementation
|
Implementation of interface to server socket. More...
Go to the source code of this file.
Functions | |
static void * | acceptThreadEntry (void *ptr) |
Entry point for the thread which waits for the incoming connection from the client socket. More... | |
void | CrFwServerSocketInitAction (FwPrDesc_t prDesc) |
Initialization action for the server socket. More... | |
void | CrFwServerSocketShutdownAction (FwSmDesc_t smDesc) |
Shutdown action for the server socket. More... | |
void | CrFwServerSocketConfigAction (FwPrDesc_t prDesc) |
Configuration action for the server socket. More... | |
void | CrFwServerSocketPoll () |
Poll the server socket to check whether a new packet has arrived. More... | |
CrFwPckt_t | CrFwServerSocketPcktCollect (CrFwDestSrc_t src) |
Function implementing the Packet Collect Operation for the server socket. More... | |
CrFwBool_t | CrFwServerSocketIsPcktAvail (CrFwDestSrc_t src) |
Function implementing the Packet Available Check Operation for the server socket. More... | |
CrFwBool_t | CrFwServerSocketPcktHandover (CrFwPckt_t pckt) |
Function implementing the hand-over operation for the server socket. More... | |
void | CrFwServerSocketInitCheck (FwPrDesc_t prDesc) |
Initialization check for the server socket. More... | |
void | CrFwServerSocketConfigCheck (FwPrDesc_t prDesc) |
Configuration check for the server socket. More... | |
void | CrFwServerSocketSetPort (unsigned short n) |
Set the port number for the socket. More... | |
Variables | |
static unsigned short | portno = 0 |
Set the port number (must be same as the port number specified in CrFwServerSocket.c | |
static int | sockfd = 0 |
The file descriptors for the socket. | |
static int | newsockfd |
The file descriptors for the socket. | |
static struct sockaddr_in | cli_addr |
Socket variable. | |
static socklen_t | clilen |
Socket variable. | |
static unsigned int | pcktMaxLength |
The maximum size of an incoming packet. | |
static unsigned char * | readBuffer |
The Read Buffer. | |
Implementation of interface to server socket.
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 CrFwServerSocket.c.
|
static |
Entry point for the thread which waits for the incoming connection from the client socket.
ptr | unused argument (required with compatibility with pthread create function) |
Definition at line 277 of file CrFwServerSocket.c.
void CrFwServerSocketConfigAction | ( | FwPrDesc_t | prDesc | ) |
Configuration action for the server socket.
This action clears the Read Buffer and executes the Configuration Action of the base InStream/OutStream.
prDesc | the configuration procedure descriptor. |
Definition at line 160 of file CrFwServerSocket.c.
void CrFwServerSocketConfigCheck | ( | FwPrDesc_t | prDesc | ) |
Configuration check for the server socket.
The check is successful if the connection from the matching client socket has been successfully accepted.
prDesc | the initialization procedure descriptor. |
Definition at line 313 of file CrFwServerSocket.c.
void CrFwServerSocketInitAction | ( | FwPrDesc_t | prDesc | ) |
Initialization action for the server socket.
If the server socket has already been initialized, this function calls the Initialization Action of the base InStream/OutStream and then returns. If the server socket has not yet been initialized, this action:
The function sets the outcome to "success" if all these operations are successful.
prDesc | the initialization procedure descriptor. |
Definition at line 81 of file CrFwServerSocket.c.
void CrFwServerSocketInitCheck | ( | FwPrDesc_t | prDesc | ) |
Initialization check for the server socket.
The check is successful if the port number has been set to a value larger than 2000.
prDesc | the initialization procedure descriptor. |
Definition at line 301 of file CrFwServerSocket.c.
CrFwBool_t CrFwServerSocketIsPcktAvail | ( | CrFwDestSrc_t | pcktSrc | ) |
Function implementing the Packet Available Check Operation for the server socket.
This function implements the following logic:
packetSource
, the function returns 1.packetSource
, the function performs a non-blocking read on the socket.packetSource
, the function returns 0.packetSource
, the function stores it in the Read Buffer and then returns 1.pcktSrc | the source associated to the InStream |
Definition at line 225 of file CrFwServerSocket.c.
CrFwPckt_t CrFwServerSocketPcktCollect | ( | CrFwDestSrc_t | pcktSrc | ) |
Function implementing the Packet Collect Operation for the server socket.
If the packet in the Read Buffer has a source attribute equal to pcktSrc
, this function:
CrFwPcktMake
If the Read Buffer holds a packet from a source other then pcktSrc
, this function returns NULL. Note that the logic of the server socket module guarantees that the Read Buffer will always be full when this function is called.
pcktSrc | the source associated to the InStream |
Definition at line 207 of file CrFwServerSocket.c.
CrFwBool_t CrFwServerSocketPcktHandover | ( | CrFwPckt_t | pckt | ) |
Function implementing the hand-over operation for the server socket.
This function performs a non-blocking write on the socket and, if it succeeds, it returns 1; otherwise, it returns 0.
pckt | the packet to be written to the socket |
Definition at line 259 of file CrFwServerSocket.c.
void CrFwServerSocketPoll | ( | ) |
Poll the server socket to check whether a new packet has arrived.
This function should be called periodically by an external scheduler. If there is a pending packet (i.e. of the Read Buffer is full), its source is determined, and then function CrFwInStreamPcktAvail
is called on the InStream associated to that packet source. If there is no pending packet (i.e. if the Read Buffer is empty), a non-blocking read is performed 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, its source is determined, and then function CrFwInStreamPcktAvail
is called on the InStream associated to that packet source. In a realistic implementation, the source of the incoming packet would be determined from the packet itself (which holds its source in its header). This implementation is intended for use with the test cases of CrFwSocketTestCase.h
and the incoming packets are routed to the 7-th InStream.
Definition at line 173 of file CrFwServerSocket.c.
void CrFwServerSocketSetPort | ( | 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 325 of file CrFwServerSocket.c.
void CrFwServerSocketShutdownAction | ( | FwSmDesc_t | smDesc | ) |
Shutdown action for the server socket.
If the server socket has already been shut down, this function calls the Shutdown Action of the base InStream/OutStream and then returns. If the client socket has not yet been shut down, this action executes the Shutdown Action of the base OutStream/InStream and then closes the socket.
smDesc | the OutStream State Machine descriptor (this parameter is not used). |
Definition at line 140 of file CrFwServerSocket.c.