00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifdef HAVE_CONFIG_H
00018 #include "config.h"
00019 #endif
00020 #include "global.h"
00021
00022 #define PID_FILE PID_DIR "/ddt/ddtcd.pid"
00023 #define LOG_FILE LOG_DIR "/ddtcd.log"
00024 #define CONF_FILE CONF_DIR "/ddtcd.conf"
00025 #define INFIFO VAR_DIR "/ddt-client/fifo.in"
00026 #define OUTFIFO VAR_DIR "/ddt-client/fifo.out"
00027
00028 #define TIMEOUT (5*60)
00029 #define MAX_RETRIES 10
00030 #define MAX_PATH 256
00031
00032 #include <iostream>
00033 #include <fstream>
00034
00035 #include <stdlib.h>
00036 #include <string.h>
00037 #include <unistd.h>
00038 #include <errno.h>
00039 #include <signal.h>
00040 #include <fcntl.h>
00041 #include <netinet/in.h>
00042 #include <arpa/inet.h>
00043 #include <sys/socket.h>
00044 #include <net/if.h>
00045
00046 #include <pwd.h>
00047 #include <grp.h>
00048 #include <sys/ioctl.h>
00049 #include <sys/stat.h>
00050 #include <sys/types.h>
00051 #include <sys/socket.h>
00052 #include <time.h>
00053 #include <opt.h>
00054
00055 #include "Exception.h"
00056 #include "Logger.h"
00057 #include "Options.h"
00058 #include "UDP.h"
00059 #include "Packet.h"
00060
00061 #ifndef DDTCD_H
00062 #define DDTCD_H
00063
00064 class Client
00065 {
00066 public:
00067 Client();
00068 ~Client();
00069
00070 int alreadyRunning();
00071 int parseArgs(int *argc, char ***argv);
00072 int becomeDaemon();
00073 int receiver();
00074
00075 int readSocket();
00076 int readFifo();
00077
00078 private:
00079 void processUserRequest();
00080 int processReceivedPacket(DdtpPacket *pkt);
00081
00082 static void atexit_handler();
00083 static void signal_handler(int signum);
00084
00085 unsigned long getIfaceAddr(char *iface);
00086
00087 static Options *opts;
00088 static Logger *log;
00089 static UDP *udp;
00090 static DdtpPacket *pkt;
00091
00092 char msgbuf[256];
00093 int infifofd;
00094 int outfifofd;
00095
00096
00097 unsigned long lastIP;
00098 unsigned long forceIP;
00099
00100 time_t serverStamp;
00101 int retryCount;
00102 time_t retryStamp;
00103 int retryIn;
00104 int currentStatus;
00105 int changeStatus;
00106 char *md5_password;
00107 };
00108
00109 #endif // DDTCD_H