source: fact/Evidence/Evidence.h@ 17227

Last change on this file since 17227 was 14189, checked in by ogrimm, 12 years ago
If DIM_DNS_NODE not set, EvidenceServer tries to run in local mode, starting a dns as separate process on localhost
  • Property svn:keywords set to Revision
File size: 2.5 KB
Line 
1#ifndef EVIDENCE_H_SEEN
2#define EVIDENCE_H_SEEN
3
4#include <stdio.h>
5#include <stdarg.h>
6#include <string>
7#include <sstream>
8#include <iomanip>
9#include <errno.h>
10#include <vector>
11#include <map>
12#include <set>
13#include <limits>
14
15#include <exception>
16#include <cxxabi.h>
17
18#include "dis.hxx"
19#include "dic.hxx"
20
21#define NO_LINK (char *) "__&DIM&NOLINK&__" // Data if no link available
22#define EVIDENCE_REVISION "$Revision: 14189 $"
23
24void ConfigChanged();
25
26// Class declation of Evidence server
27class EvidenceServer: public DimServer {
28
29 // Internal class for configuration requests
30 class Config: public DimInfo, public DimCommand, public DimRpcInfo {
31
32 DimInfo *Service;
33
34 void rpcInfoHandler();
35 void commandHandler();
36 void infoHandler();
37
38 public:
39 Config();
40 ~Config();
41
42 int ConfigTimeStamp;
43 std::string CurrentItem;
44 };
45
46 struct Item {
47 std::string Value;
48 int Time;
49 };
50 std::map<std::string, struct Item> List;
51
52 struct Message {
53 int Severity;
54 char Text[];
55 };
56
57 std::string Name;
58 DimService *MessageService;
59 struct Message *MessageData;
60 class Config *ConfClass;
61 static pthread_mutex_t Mutex;
62 static EvidenceServer *This;
63 bool LocalMode;
64 pid_t ChildPID;
65
66 static void SignalHandler(int); // static for signal()
67 static void Terminate(); // static for set_terminate()
68 virtual void errorHandler(int, int, char *);
69 virtual void exitHandler(int);
70 static void CallConfigChanged(); // static for phread_create()
71
72 public:
73 EvidenceServer(std::string);
74 ~EvidenceServer();
75
76 enum {INFO=0, WARN=10, ERROR=20, FATAL=30};
77
78 void Message(int, const char *, ...);
79 static void SendToLog(const char *, ...);
80 std::string GetConfig(std::string, std::string = std::string());
81 virtual void ConfigChanged() {};
82 static void Lock();
83 static void Unlock();
84 static std::string ToString(char *, const void *, int);
85 static bool ServiceOK(DimInfo *);
86 static bool ServiceOK(DimRpcInfo *);
87 static bool ServiceOK(DimCurrentInfo *);
88 static std::vector<std::string> Tokenize(const std::string &, const std::string & = " ");
89
90 bool ExitRequest;
91};
92
93// Class declaration of EvidenceHistory
94class EvidenceHistory {
95
96 public:
97 struct Item {
98 int Time;
99 int Size;
100 char Data[]; // Size bytes follow
101 } __attribute__((packed));
102
103 static const struct Item WrapMark;
104 static const struct Item EndMark;
105
106 private:
107 std::string Name;
108 char *Buffer;
109 int BufferSize;
110 char *DataStart;
111 struct Item *Pointer;
112
113 public:
114 EvidenceHistory(std::string);
115 ~EvidenceHistory();
116
117 bool GetHistory();
118 char *GetFormat();
119 const struct Item *Next();
120 void Rewind();
121};
122#endif
Note: See TracBrowser for help on using the repository browser.