25 #include "CrFwRepErrStub.h" 26 #include "CrFwOutStreamSocket.h" 28 #include "FwSmConstants.h" 29 #include "FwSmConfig.h" 31 #include "FwPrConfig.h" 33 #include "FwPrConstants.h" 35 #include "CrFwOutStreamUserPar.h" 36 #include "CrFwCmpData.h" 49 #include <sys/types.h> 50 #include <sys/socket.h> 51 #include <netinet/in.h> 59 static unsigned short portno = 0;
82 struct sockaddr_in serv_addr,
cli_addr;
83 pthread_t acceptThread;
87 sockfd = socket(AF_INET, SOCK_STREAM, 0);
89 perror(
"CrFwInStreamSocketInitAction, Socket creation");
94 bzero((
char*) &serv_addr,
sizeof(serv_addr));
95 serv_addr.sin_family = AF_INET;
96 serv_addr.sin_addr.s_addr = INADDR_ANY;
97 serv_addr.sin_port = htons(
portno);
98 if (bind(
sockfd, (
struct sockaddr*) &serv_addr,
sizeof(serv_addr)) < 0) {
99 perror(
"CrFwOutStreamSocketInitAction, Bind Socket");
107 pthread_attr_init(&attr);
108 if (pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED) != 0) {
109 perror(
"CrFwOutStreamSocketInitAction, set detached state");
140 printf(
"CrFwOutStreamSocketInitAction: error writing to socket\n");
154 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 int portno
The port number.
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 int newsockfd[2]
The file descriptors for the client sockets.
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 sockfd
The file descriptor for the socket.
static socklen_t clilen
Socket variable.
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.
char * CrFwPckt_t
Type for packets (see CrFwPckt.h).
static void * acceptThreadEntry(void *ptr)
Entry point for the thread which waits for the incoming connection from the client socket...
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.