20 #include "CrFwRepErrStub.h" 21 #include "CrFwOutStreamSocket.h" 23 #include "FwSmConstants.h" 24 #include "FwSmConfig.h" 26 #include "FwPrConfig.h" 28 #include "FwPrConstants.h" 30 #include "CrFwOutStreamUserPar.h" 31 #include "CrFwCmpData.h" 44 #include <sys/types.h> 45 #include <sys/socket.h> 46 #include <netinet/in.h> 77 struct sockaddr_in serv_addr, cli_addr;
78 pthread_t acceptThread;
82 sockfd = socket(AF_INET, SOCK_STREAM, 0);
84 perror(
"CrFwInStreamSocketInitAction, Socket creation");
89 bzero((
char*) &serv_addr,
sizeof(serv_addr));
90 serv_addr.sin_family = AF_INET;
91 serv_addr.sin_addr.s_addr = INADDR_ANY;
92 serv_addr.sin_port = htons(
portno);
93 if (bind(
sockfd, (
struct sockaddr*) &serv_addr,
sizeof(serv_addr)) < 0) {
94 perror(
"CrFwOutStreamSocketInitAction, Bind Socket");
102 pthread_attr_init(&attr);
103 if (pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED) != 0) {
104 perror(
"CrFwOutStreamSocketInitAction, set detached state");
135 printf(
"CrFwOutStreamSocketInitAction: error writing to socket\n");
149 perror(
"CrFwInStreamSocketInitAction, Socket Accept");
Type for the Framework Component Data (FCD).
Interface through which framework components access the current time.
CrFwOutcome_t outcome
The outcome of an action or check executed by a state machine or by one of its procedures.
static socklen_t clilen
Socket variable.
Definition of the OutStream component.
Interface for creating and accessing a report or command packet.
int CrFwBool_t
Type used for boolean values (1 represent "true" and 0 represents "false").
void CrFwOutStreamSocketInitAction(FwPrDesc_t prDesc)
Initialization action for the socket-based OutStream.
Interface for reporting an error detected by a framework component.
CrFwPcktLength_t CrFwPcktGetLength(CrFwPckt_t pckt)
Return the length (in number of bytes) of a packet.
static void * acceptThreadEntry(void *ptr)
Entry point for the thread which waits for the incoming connection from the InStream.
Definition of the utility functions for the CORDET Framework.
void CrFwOutStreamDefShutdownAction(FwSmDesc_t smDesc)
Default shutdown action for an OutStream.
CrFwBool_t CrFwOutStreamSocketPcktHandover(CrFwPckt_t pckt)
Function implementing the hand-over operation for the socket-based OutStream.
void CrFwOutStreamDefInitAction(FwPrDesc_t prDesc)
Default initialization action for an OutStream.
static int newsockfd
The file descriptors for the socket.
void CrFwOutStreamSocketSetPort(unsigned short n)
Set the port number for the socket.
Definition of Base Component.
void CrFwOutStreamSocketShutdownAction(FwSmDesc_t smDesc)
Shutdown action for the socket-based OutStream.
static CrFwCmpData_t outStreamData[CR_FW_NOF_OUTSTREAM]
The base data structures for the OutStream State Machines and their Procedures.
static int sockfd
The file descriptors for the socket.
char * CrFwPckt_t
Type for packets (see CrFwPckt.h).
static unsigned short portno
Set the port number (must be same as the port number specified in CrFwOutStreamSocket.c
static struct sockaddr_in cli_addr
Socket variable.
void CrFwOutStreamSocketInitCheck(FwPrDesc_t prDesc)
Initialization check for the socket-based OutStream.
void CrFwOutStreamSocketConfigCheck(FwPrDesc_t prDesc)
Configuration check for the socket-based OutStream.