Main Page | Class Hierarchy | Class List | Directories | File List | Class Members

ddtcd.h

00001 /* -*- Mode: C++; c-file-style: "stroustrup"; indent-tabs-mode: nil -*- */
00002 /*
00003  * ddtcd.h
00004  *   header file for client daemon.
00005  *
00006  * $Id: ddtcd.h,v 1.29 2001/11/24 21:11:50 benoit Exp $
00007  *
00008  * Copyright (c) 2000 Remi Lefebvre <remi@dhis.net>
00009  *                and Luca Filipozzi <lfilipoz@dhis.net>
00010  *
00011  * DDT comes with ABSOLUTELY NO WARRANTY and is licenced under the
00012  * GNU General Public License (version 2 or later). This license
00013  * can be retrieved from http://www.gnu.org/copyleft/gnu.html.
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> // for dropping priviledges
00047 #include <grp.h> //    idem 
00048 #include <sys/ioctl.h>
00049 #include <sys/stat.h>
00050 #include <sys/types.h>
00051 #include <sys/socket.h> // for NetBSD
00052 #include <time.h>
00053 #include <opt.h> // opt parser lib
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     // IP address that matched interface last time we checked
00097     unsigned long lastIP;
00098     unsigned long forceIP;
00099     
00100     time_t serverStamp;  // last time we heard from server
00101     int retryCount;      // how many times did we try without reply ?
00102     time_t retryStamp; 
00103     int retryIn;         // in how long do we reconsider our status ? 
00104     int currentStatus;   // our status
00105     int changeStatus;    // what we want
00106     char *md5_password;  // our md5 hashed password
00107 };
00108 
00109 #endif // DDTCD_H

Generated on Tue Sep 13 01:32:46 2005 for DDT Project by  doxygen 1.4.4