//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // File : comm_msgdefs.h // Author : Su Li // Date : 09/00 // Description: Common message structures for main Server // // Copyright (C) All // Rights reserved. // // // Revision List: // YY-MM BY DESCRIPTION // //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #ifndef __COMM_MSGDEFS_H__ #define __COMM_MSGDEFS_H__ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define ERROR 0 #define INFO 1 #define ALARM 2 typedef enum { ACK = 0, /* message going from the gateway to client(real server) where attaches detected */ SVR /* message going from client to gateway */ } Msg_Type; typedef enum { ATTACK = 0, OK } Msg; /* common message header */ typedef struct { Msg_Type msg_type; /* unique message identifier */ Msg msg; /* ATTACK or OK */ } MsgHeader; typedef enum { SUCCESS = 0, FAILURE } AckNack_Status; typedef struct { AckNack_Status status; } AckNack_Msg; /* global variables */ int port_num = 2750; char hostname[50]; char *log_dir="/usr2/students/sli/CS526/log"; char *ip_address ="128.198.162.60"; /*blanca*/ char svr_ip[50]; int MaxLogRecPerFile=2000; char hdrStr[13]; int nfds; int inserted; /*****Data File***/ typedef struct { int num_of_rec; FILE *dataFp; char filename[100]; char path[150]; time_t Timer; int newfile; int seq; char datebase[9]; } DATA_FILE; /*DATA_FILE *dataFile;*/ /* data */ typedef struct { char rcvd_from[50]; char data_buf[1024]; int data_len; int msg_type; int seq_no; } RcvdData; RcvdData buf; /***LOG FILE****/ typedef struct { int num_of_rec; FILE *infoLogFp; char filename[100]; char path[150]; int newfile; int seq; char datebase[9]; } INFO_LOG; typedef struct { int num_of_rec; FILE *errLogFp; char filename[100]; char path[150]; int newfile; int seq; char datebase[9]; } ERR_LOG; INFO_LOG *infoLog; ERR_LOG *errLog; DATA_FILE *dataFile; /****global fun def ***/ void initialize(); int isMidNight(int); void getCurrTimeString(char *format, char *res, int len, int msec_flag); int fileSize(char *filename); int storeIt(char *str); void resetTimer(); int checkTimer(); char *getFileName(int); void logIt(char *str, int); int openFile(int); char *getTime(); void moveFile(char *SourceDirectory,char *SourceName,char *DestDirectory,char *DestName); void reload(); void createReloadFile(); void shutDown(); /**Socket fun*/ int Receive(int sockfd, void *buffer, int bytesToRead); int Read(int sockfd, void *buffer, int bytesToRead); int Send(int sockfd, void *buf, int bytesToSend); //**Sock fun ends**/ bool processData(void *data_in, int sockfd); void startProcesses(); void initialize(); void getCurrTimeString(char *format, char *res, int len, int msec_flag); int fileSize(char *filename); int Connect(int sockfd); #endif /* __COMM_MSGDEFS_H__ */