25 #include "CrFwRepErrStub.h" 26 #include "CrFwInStreamSocket.h" 28 #include "FwSmConstants.h" 29 #include "FwSmConfig.h" 31 #include "FwPrConfig.h" 33 #include "FwPrConstants.h" 35 #include "CrFwInStreamUserPar.h" 36 #include "CrFwCmpData.h" 49 #include <sys/types.h> 50 #include <sys/socket.h> 51 #include <netinet/in.h> 57 #define h_addr h_addr_list[0] 60 static unsigned short portno = 0;
77 struct sockaddr_in serv_addr;
78 struct hostent* server;
84 sockfd = socket(AF_INET, SOCK_STREAM, 0);
86 perror(
"CrFwInStreamSocketInitAction, Socket Creation");
92 if ((flags = fcntl(
sockfd, F_GETFL, 0)) < 0) {
93 perror(
"CrFwInStreamSocketInitAction, Set socket attributes");
97 if (fcntl(
sockfd, F_SETFL, flags | O_NONBLOCK) < 0) {
98 perror(
"CrFwInStreamSocketInitAction, Set socket attributes");
103 fcntl(
sockfd, F_SETFL, O_NONBLOCK);
106 if (server == NULL) {
107 perror(
"CrFwInStreamSocketInitAction, Get host name");
112 bzero((
char*) &serv_addr,
sizeof(serv_addr));
113 serv_addr.sin_family = AF_INET;
114 bcopy((
char*)server->h_addr,
115 (
char*)&serv_addr.sin_addr.s_addr,
116 (
long unsigned int)server->h_length);
117 serv_addr.sin_port = (
unsigned short int)htons(
portno);
119 if (connect(
sockfd,(
struct sockaddr*) &serv_addr,
sizeof(serv_addr)) < 0) {
120 if (errno != EINPROGRESS) {
121 perror(
"CrFwInStreamSocketInitAction, Connect Socket");
177 printf(
"CrFwInStreamSocketConfigAction: ERROR reading from socket\n");
185 printf(
"CrFwInStreamSocketConfigAction: invalid packet received from socket\n");
218 printf(
"CrFwInStreamSocketConfigAction: ERROR reading from socket\n");
225 printf(
"CrFwInStreamSocketConfigAction: invalid packet received from socket\n");
Type for the Framework Component Data (FCD).
Interface through which framework components access the current time.
void CrFwInStreamSocketPoll(FwSmDesc_t inStream)
Poll the socket to check whether a new packet has arrived.
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.
static CrFwCmpData_t inStreamData[CR_FW_NOF_INSTREAM]
The data structures for the InStream State Machines and their Procedures.
void CrFwInStreamSocketSetPort(unsigned short n)
Set the port number for the socket.
static unsigned char * readBuffer
The Read Buffer.
unsigned char CrFwDestSrc_t
Type used for the command or report destination and source.
CrFwPckt_t CrFwPcktMake(CrFwPcktLength_t pcktLength)
Make function for command or report packets.
CrFwPckt_t CrFwInStreamSocketPcktCollect(CrFwDestSrc_t src)
Function implementing the Packet Collect Operation for the socket-based InStream. ...
Interface for creating and accessing a report or command packet.
Definition of the InStream component.
int CrFwBool_t
Type used for boolean values (1 represent "true" and 0 represents "false").
void CrFwInStreamSocketConfigAction(FwPrDesc_t prDesc)
Configuration action for the socket-based InStream.
Interface for reporting an error detected by a framework component.
void CrFwInStreamDefInitAction(FwPrDesc_t prDesc)
Default initialization action for an InStream.
static int pcktMaxLength
The maximum size of an incoming packet.
unsigned short int CrFwPcktLength_t
Type for the packet length.
CrFwPcktLength_t CrFwPcktGetMaxLength()
Return the maximum length of a packet in number of bytes.
void CrFwInStreamSocketInitCheck(FwPrDesc_t prDesc)
Initialization check for the socket-based InStream.
static char * hostName
The host name.
Definition of the utility functions for the CORDET Framework.
void CrFwInStreamSocketInitAction(FwPrDesc_t prDesc)
Initialization action for the socket-based InStream.
static int sockfd
The file descriptor for the socket.
void CrFwInStreamDefShutdownAction(FwSmDesc_t smDesc)
Default shutdown action for an InStream.
Definition of Base Component.
void CrFwInStreamSocketSetHost(char *name)
Set the host name of the server.
char * CrFwPckt_t
Type for packets (see CrFwPckt.h).
void CrFwInStreamDefConfigAction(FwPrDesc_t prDesc)
Default configuration action for an InStream.
void CrFwInStreamPcktAvail(FwSmDesc_t smDesc)
Query the middleware for available packets and collect them if they are available.
CrFwBool_t CrFwInStreamSocketIsPcktAvail(CrFwDestSrc_t src)
Function implementing the Packet Available Check Operation for the InStream.
void CrFwInStreamSocketShutdownAction(FwSmDesc_t smDesc)
Shutdown action for the socket-based InStream.