File: pcapfilter.h

package info (click to toggle)
natlog 1.01.0-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 956 kB
  • ctags: 343
  • sloc: cpp: 1,737; makefile: 140; sh: 123
file content (49 lines) | stat: -rw-r--r-- 1,038 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#ifndef INCLUDED_PCAPFILTER_
#define INCLUDED_PCAPFILTER_

#include <string>
#include <mutex>

#include <bobcat/signal>

#include "../pcap/pcap.h"
#include "../pcaprecord/pcaprecord.h"

struct PcapFilter: public FBB::SignalHandler
{
    typedef PcapRecord::Type Type;

    private:
        std::string d_device;
        PcapRecord &d_record;
        Type d_type;
        Pcap d_pcap;

        static char s_filterExpr[];
        static std::mutex s_recordMutex;

    public:
        PcapFilter(char const *device, PcapRecord &record, Type type);
        void operator()();
        
    private:
        void inDevice(PcapPacket const &packet);
        void outDevice(PcapPacket const &packet);

        void saveAdd(PcapPacket const &packet);
        void saveRemove(PcapPacket const &packet);


        static void callback(PcapFilter *pf, struct pcap_pkthdr const *hdr,
                             u_char const *bytes);
        int shiftPacketBegin() const;

        virtual void signalHandler(size_t signum) override;
};

#endif