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> 69 struct sockaddr_in serv_addr;
70 struct hostent* server;
85 sockfd = socket(AF_INET, SOCK_STREAM, 0);
87 perror(
"CrDaClientSocketInitAction, Socket Creation");
93 if ((flags = fcntl(
sockfd, F_GETFL, 0)) < 0) {
94 perror(
"CrDaClientSocketInitAction, Set socket attributes");
98 if (fcntl(
sockfd, F_SETFL, flags | O_NONBLOCK) < 0) {
99 perror(
"CrDaClientSocketInitAction, Set socket attributes");
105 if (server == NULL) {
106 perror(
"CrDaClientSocketInitAction, Get host name");
111 bzero((
char*) &serv_addr,
sizeof(serv_addr));
112 serv_addr.sin_family = AF_INET;
113 bcopy((
char*)server->h_addr,
114 (
char*)&serv_addr.sin_addr.s_addr,
116 serv_addr.sin_port = htons(
portno);
118 if (connect(
sockfd,(
struct sockaddr*) &serv_addr,
sizeof(serv_addr)) < 0) {
119 if (errno != EINPROGRESS) {
120 perror(
"CrDaClientSocketInitAction, Connect Socket");
184 perror(
"CrDaClientSocketConfigAction, Incorrect caller type");
206 printf(
"CrDaClientSocketPoll: ERROR reading from socket\n");
216 printf(
"CrDaClientSocketPoll: invalid packet received from socket\n");
229 if (src == pcktSrc) {
231 memcpy(pckt, readBuffer, readBuffer[0]);
254 printf(
"CrDaClientSocketIsPcktAvail: ERROR reading from socket\n");
266 printf(
"CrDaClientSocketIsPcktAvail: invalid packet received from socket\n");
279 n = write(
sockfd, pckt, len);
285 printf(
"CrDaClientSocketPcktHandover: error writing to socket\n");
void CrFwOutStreamDefConfigAction(FwPrDesc_t prDesc)
Default configuration action for an OutStream.
void CrDaClientSocketConfigAction(FwPrDesc_t prDesc)
Configuration action for the client socket.
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.
CrFwDestSrc_t CrFwPcktGetSrc(CrFwPckt_t pckt)
Return the source of the command or report encapsulated in a packet.
void CrDaClientSocketSetPort(int n)
Set the port number for the socket.
unsigned char * CrFwPckt_t
Type for packets (see CrFwPckt.h).
CrFwBool_t CrDaClientSocketIsPcktAvail(CrFwDestSrc_t src)
Function implementing the Packet Available Check Operation for the client 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.
#define CR_FW_INSTREAM_TYPE
Type identifier for the InStream components.
Interface for creating and accessing a report or command packet.
Definition of the InStream component.
void CrDaClientSocketInitAction(FwPrDesc_t prDesc)
Initialization action for the client socket.
int CrFwBool_t
Type used for boolean values (1 represent "true" and 0 represents "false").
Header file to define all invariant publicly available constants and types for the CORDET Framework...
static int pcktMaxLength
The maximum size of an incoming packet.
void CrDaClientSocketShutdownAction(FwSmDesc_t smDesc)
Shutdown action for the client socket.
Interface for reporting an error detected by a framework component.
static char * hostName
The host name.
void CrFwInStreamDefInitAction(FwPrDesc_t prDesc)
Default initialization action for an InStream.
CrFwPcktLength_t CrFwPcktGetLength(CrFwPckt_t pckt)
Return the length (in number of bytes) of a packet.
CrFwPckt_t CrDaClientSocketPcktCollect(CrFwDestSrc_t src)
Function implementing the Packet Collect Operation for the client socket.
static unsigned char * readBuffer
The Read Buffer.
Interface for the client socket used in the CORDET Demo.
CrFwBool_t CrDaClientSocketPcktHandover(CrFwPckt_t pckt)
Function implementing the hand-over operation for the client socket.
unsigned short int CrFwPcktLength_t
Type for the packet length.
CrFwPcktLength_t CrFwPcktGetMaxLength()
Return the maximum length of a packet in number of bytes.
Definition of the utility functions for the CORDET Framework.
void CrFwOutStreamDefShutdownAction(FwSmDesc_t smDesc)
Default shutdown action for an OutStream.
void CrFwOutStreamDefInitAction(FwPrDesc_t prDesc)
Default initialization action for an OutStream.
void CrFwInStreamDefShutdownAction(FwSmDesc_t smDesc)
Default shutdown action for an InStream.
static int sockfd
The file descriptor for the socket.
FwSmDesc_t CrFwInStreamGet(CrFwDestSrc_t src)
Getter function for the InStream corresponding to the argument source.
Definition of Base Component.
void CrDaClientSocketSetHost(char *name)
Set the host name of the server.
void CrDaClientSocketPoll()
Poll the client socket to check whether a new packet has arrived.
CrFwTypeId_t typeId
The type identifier of the framework component.
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.
#define CR_FW_OUTSTREAM_TYPE
Type identifier for the OutStream components.
static int portno
The port number.
void CrDaClientSocketInitCheck(FwPrDesc_t prDesc)
Initialization check for the client socket.