/* File: proxy_structs.h Description: structure definitions and typedefs for proxy program. */ #ifndef __PROXY_STRUCTS_H__ #define __PROXY_STRUCTS_H__ #include #include #include #include #define FD_CLOSE 0 #define FD_OPEN 1 #define CLIENT 0 #define SERVER 1 #define QUEUE_BUFFER 4096 #define CONNECT_TIMEOUT 5.0 /* we'll have one of these for each available file descriptor */ struct rdata { int status; char ip[INET_ADDRSTRLEN]; /* client IP */ int relay; /* fd to which we relay data */ GSList *queue; int bytes_read; int bytes_written; int type; /* CLIENT or SERVER */ struct timeval ti_read; /* started reading data */ struct timeval ti_write; /* started writing data */ struct timeval tf_read; /* finished reading data */ struct timeval tf_write; /* finished writing data */ struct timeval ti_connect; /* started connect N/B */ struct timeval tf_connect; /* finished connect N/B */ }; /* these structures get stuffed into the mem chunks */ struct qdata { int l; /* number of bytes in this buffer */ int p; /* placeholder for repeat writes */ char s[QUEUE_BUFFER]; /* space for the data */ }; typedef struct qdata qdata; /* this struct will be filled out as needed. it will contain any data which needs to be globally accessible. */ struct mdata { GMemChunk *m; struct rdata *r; /* status/ip list */ struct sockaddr_in sa; struct sockaddr_in la; unsigned short local_port; char local_name[MAXPATHLEN]; unsigned short server_port; char server_name[MAXPATHLEN]; char log_file[MAXPATHLEN]; FILE *log_fp; int nofile; int server_sock; int kq; int iterations; int events; int accepts; int bytes_read[2]; int bytes_written[2]; int kevent_errors; int num_clients; int max_clients; float time_reading[2]; float time_writing[2]; int verbose; int out_of_memory; }; #endif /* __PROXY_STRUCTS_H__ */