23 #include "FwSmConstants.h"
24 #include "FwSmConfig.h"
26 #include "FwPrConfig.h"
28 #include "FwPrConstants.h"
44 #include <sys/types.h>
45 #include <sys/socket.h>
46 #include <netinet/in.h>
53 #define h_addr h_addr_list[0]
73 struct sockaddr_in serv_addr;
74 struct hostent* server;
80 sockfd = socket(AF_INET, SOCK_STREAM, 0);
82 perror(
"CrFwInStreamSocketInitAction, Socket Creation");
88 if ((flags = fcntl(
sockfd, F_GETFL, 0)) < 0) {
89 perror(
"CrFwInStreamSocketInitAction, Set socket attributes");
93 if (fcntl(
sockfd, F_SETFL, flags | O_NONBLOCK) < 0) {
94 perror(
"CrFwInStreamSocketInitAction, Set socket attributes");
99 fcntl(
sockfd, F_SETFL, O_NONBLOCK);
102 if (server == NULL) {
103 perror(
"CrFwInStreamSocketInitAction, Get host name");
108 bzero((
char*) &serv_addr,
sizeof(serv_addr));
109 serv_addr.sin_family = AF_INET;
110 bcopy((
char*)server->h_addr,
111 (
char*)&serv_addr.sin_addr.s_addr,
112 (
long unsigned int)server->h_length);
113 serv_addr.sin_port = (
unsigned short int)htons(
portno);
115 if (connect(
sockfd,(
struct sockaddr*) &serv_addr,
sizeof(serv_addr)) < 0) {
116 if (errno != EINPROGRESS) {
117 perror(
"CrFwInStreamSocketInitAction, Connect Socket");
173 printf(
"CrFwInStreamSocketConfigAction: ERROR reading from socket\n");
181 printf(
"CrFwInStreamSocketConfigAction: invalid packet received from socket\n");
216 printf(
"CrFwInStreamSocketConfigAction: ERROR reading from socket\n");
223 printf(
"CrFwInStreamSocketConfigAction: invalid packet received from socket\n");
Definition of Base Component.
Definition of the Framework Component Data (FCD) Type.
unsigned char * CrFwPckt_t
Type for packets (see CrFwPckt.h).
int CrFwBool_t
Type used for boolean values (1 represent "true" and 0 represents "false").
void CrFwInStreamDefInitAction(FwPrDesc_t prDesc)
Default initialization action for an InStream.
void CrFwInStreamDefConfigAction(FwPrDesc_t prDesc)
Default configuration action for an InStream.
static CrFwCmpData_t inStreamData[CR_FW_NOF_INSTREAM]
The data structures for the InStream State Machines and their Procedures.
void CrFwInStreamDefShutdownAction(FwSmDesc_t smDesc)
Default shutdown action for an InStream.
void CrFwInStreamPcktAvail(FwSmDesc_t smDesc)
Query the middleware for available packets and collect them if they are available.
Definition of the InStream component.
void CrFwInStreamSocketInitAction(FwPrDesc_t prDesc)
Initialization action for the socket-based InStream.
CrFwBool_t CrFwInStreamSocketIsPcktAvail(CrFwDestSrc_t nofSrc, CrFwDestSrc_t *srcs)
Function implementing the Packet Available Check Operation for the InStream.
static unsigned int pcktMaxLength
The maximum size of an incoming packet.
void CrFwInStreamSocketConfigAction(FwPrDesc_t prDesc)
Configuration action for the socket-based InStream.
static unsigned char * readBuffer
The Read Buffer.
void CrFwInStreamSocketSetHost(char *name)
Set the host name of the server.
CrFwPckt_t CrFwInStreamSocketPcktCollect(CrFwDestSrc_t nofSrc, CrFwDestSrc_t *srcs)
Function implementing the Packet Collect Operation for the socket-based InStream.
static char * hostName
The host name.
void CrFwInStreamSocketShutdownAction(FwSmDesc_t smDesc)
Shutdown action for the socket-based InStream.
void CrFwInStreamSocketPoll(FwSmDesc_t inStream)
Poll the socket to check whether a new packet has arrived.
void CrFwInStreamSocketInitCheck(FwPrDesc_t prDesc)
Initialization check for the socket-based InStream.
void CrFwInStreamSocketSetPort(unsigned short n)
Set the port number for the socket.
static int sockfd
The file descriptor for the socket.
static unsigned short portno
The port number.
Interface for the Socket-Based InStream.
User-modifiable parameters for the InStream components (see CrFwInStream.h).
Interface for creating and accessing a report or command packet.
CrFwPcktLength_t CrFwPcktGetMaxLength()
Return the maximum length of a packet in number of bytes.
CrFwPckt_t CrFwPcktMake(CrFwPcktLength_t pcktLength)
Make function for command or report packets.
Interface for reporting an error detected by a framework component.
The CORDET Framework defines an interface for generating error reports (see CrFwRepErr....
Interface through which framework components access the current time.
unsigned char CrFwDestSrc_t
Type used for the command or report destination and source.
unsigned short int CrFwPcktLength_t
Type for the packet length.
Definition of the utility functions for the CORDET Framework.
Type for the Framework Component Data (FCD).
CrFwOutcome_t outcome
The outcome of an action or check executed by a state machine or by one of its procedures.