20 #include "CrFwRepErrStub.h" 21 #include "CrFwInStreamSocket.h" 23 #include "FwSmConstants.h" 24 #include "FwSmConfig.h" 26 #include "FwPrConfig.h" 28 #include "FwPrConstants.h" 30 #include "CrFwInStreamUserPar.h" 31 #include "CrFwCmpData.h" 44 #include <sys/types.h> 45 #include <sys/socket.h> 46 #include <netinet/in.h> 52 #define h_addr h_addr_list[0] 72 struct sockaddr_in serv_addr;
73 struct hostent* server;
79 sockfd = socket(AF_INET, SOCK_STREAM, 0);
81 perror(
"CrFwInStreamSocketInitAction, Socket Creation");
87 if ((flags = fcntl(
sockfd, F_GETFL, 0)) < 0) {
88 perror(
"CrFwInStreamSocketInitAction, Set socket attributes");
92 if (fcntl(
sockfd, F_SETFL, flags | O_NONBLOCK) < 0) {
93 perror(
"CrFwInStreamSocketInitAction, Set socket attributes");
98 fcntl(
sockfd, F_SETFL, O_NONBLOCK);
101 if (server == NULL) {
102 perror(
"CrFwInStreamSocketInitAction, Get host name");
107 bzero((
char*) &serv_addr,
sizeof(serv_addr));
108 serv_addr.sin_family = AF_INET;
109 bcopy((
char*)server->h_addr,
110 (
char*)&serv_addr.sin_addr.s_addr,
111 (
long unsigned int)server->h_length);
112 serv_addr.sin_port = (
unsigned short int)htons(
portno);
114 if (connect(
sockfd,(
struct sockaddr*) &serv_addr,
sizeof(serv_addr)) < 0) {
115 if (errno != EINPROGRESS) {
116 perror(
"CrFwInStreamSocketInitAction, Connect Socket");
172 printf(
"CrFwInStreamSocketConfigAction: ERROR reading from socket\n");
180 printf(
"CrFwInStreamSocketConfigAction: invalid packet received from socket\n");
192 memcpy(pckt, readBuffer, readBuffer[0]);
213 printf(
"CrFwInStreamSocketConfigAction: ERROR reading from socket\n");
220 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 char * hostName
The host name.
static unsigned int pcktMaxLength
The maximum size of an incoming packet.
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.
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 sockfd
The file descriptor for the socket.
unsigned short int CrFwPcktLength_t
Type for the packet length.
static unsigned short portno
The port number.
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.
Definition of the utility functions for the CORDET Framework.
void CrFwInStreamSocketInitAction(FwPrDesc_t prDesc)
Initialization action for the socket-based InStream.
static unsigned char * readBuffer
The Read Buffer.
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.