Back to index

natlog  0.91.0
natfork.h
Go to the documentation of this file.
00001 #ifndef INCLUDED_NATFORK_
00002 #define INCLUDED_NATFORK_
00003 
00004 #include <ostream>
00005 #include <memory>
00006 
00007 #include <bobcat/fork>
00008 #include <bobcat/multistreambuf>
00009 #include <bobcat/pipe>
00010 
00011 
00012 namespace FBB
00013 {
00014     class SyslogStream;
00015 }
00016 
00017 class Options;
00018 
00019 class NatFork: public FBB::Fork
00020 {
00021     enum Mode
00022     {
00023         CONNTRACK,
00024         PCAP
00025     };
00026 
00027     Options &d_options;
00028 
00029     std::unique_ptr<FBB::SyslogStream> d_syslog;
00030 
00031     FBB::MultiStreambuf d_multiStreambuf;
00032     std::ostream d_stdMsg;
00033 
00034     Mode d_mode;
00035     FBB::Pipe d_pipe;
00036 
00037     public:
00038         NatFork();
00039 
00040         void run();
00041 
00042     private:
00043         void setupStdMsg();
00044         void checkSyslogParam(char const *label, std::string const &actual, 
00045                                                  std::string const &err);
00046         void setupDaemonMsg();
00047         void setupNonDaemonMsg();
00048 
00049         void handleChildStatus();
00050         void conntrackMode();
00051 
00052         virtual void parentProcess() override;
00053         virtual void childProcess() override;
00054 };
00055         
00056 #endif