File: specifications.cc

package info (click to toggle)
natlog 3.01.00-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,912 kB
  • sloc: cpp: 3,691; fortran: 201; sh: 133; ansic: 123; makefile: 110
file content (118 lines) | stat: -rw-r--r-- 4,765 bytes parent folder | download | duplicates (5)
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#include "natfork.ih"

#include <iomanip>

void NatFork::specifications()
{
    if (d_options.verbose() >= 2)
    {
        d_stdMsg << left;

        switch (d_mode)
        {
            case Options::CONNTRACK:
                d_stdMsg << "CONNTRACK mode" << endl;
                d_stdMsg << setw(25) << setw(25) << "command: `" << 
                            d_options.conntrackCommand() << '\'' << endl;
                d_stdMsg << setw(25) << "conntrack device: " << 
                            d_options.conntrackDevice() << endl;
                if (d_options.IPheaderSize() != 0)
                    d_stdMsg << setw(25) << 
                                "conntrack IP header size correction: " << 
                                d_options.IPheaderSize() << " bytes" << endl;
                else
                    d_stdMsg << setw(25) << 
                                "no conntrack IP header size correction" << 
                                                                        endl;
                d_stdMsg << setw(25) << "max # conntrack restarts: " << 
                                d_options.conntrackRestart() << endl;
            break;

            case Options::DEVICE:
                d_stdMsg << "DEVICE mode" << endl;
                d_stdMsg << setw(25) << "devices: " <<
                                d_options[0] << ' ' << d_options[1] << endl; 
            break;

            case Options::TCPDUMP:
                d_stdMsg << "TCPDUMP mode" << endl;
                d_stdMsg << setw(25) << "specifications: "  << 
                                d_options[0] << ' ' << 
                                d_options[1] << ' ' << d_options[2] << ' ' << 
                                d_options[3] << ' ' << 
                                d_options[4] << ' ' << d_options[5] << endl;
            break;
        }

        d_stdMsg << setw(25) << boolalpha;
        d_stdMsg << setw(25) << "config file: " << 
                                            d_options.configPath() << endl;

        if (string const &logData = d_options.logData(); not logData.empty())
            d_stdMsg << setw(25) << "log data: " << logData << endl;

        if (d_options.rotateFreq() != 0 and d_options.nRotations() != 0)
        {
            d_stdMsg << setw(25) << "rotating log files: " << "every";
            if (d_options.rotateFreq() != 1)
                d_stdMsg << ' ' << d_options.rotateFreq();
            d_stdMsg << d_options.rotateTimeSpec() << endl;

            d_stdMsg << setw(25) << "number of rotated files: " << 
                                        d_options.nRotations() << endl;
        }

        d_stdMsg << setw(25) << "daemon: " << d_options.daemon() << endl;

        if (d_options.daemon())
            d_stdMsg << setw(25) << "PID file: " << 
                                            d_options.pidFile() << endl;

        d_stdMsg << setw(25) << "protocol(s): " << 
                                            d_options.protocolNames() << endl;

        if (not d_options.log().empty())
        {
            d_stdMsg << setw(25) << "using log: " << d_options.log() << endl;

            if (d_options.log() == "syslog")
            {
                d_stdMsg << setw(25) << "   facility: " << 
                                                d_options.facility() << endl;
                d_stdMsg << setw(25) << "   priority: " << 
                                                d_options.priority() << endl;
                d_stdMsg << setw(25) << "   tag: " << 
                                                d_options.syslogTag() << endl;
            }
        }

        d_stdMsg << setw(25) << "using stdout: " << 
                                                d_options.stdout() << endl;

        d_stdMsg << setw(25) << "time type: " << d_options.timeTxt() << endl;

        if (d_mode != Options::CONNTRACK)
        {
            d_stdMsg << setw(25) << "ttl (udp, icmp): " << d_options.ttl() << 
                                                        " seconds" << endl;
            d_stdMsg << setw(25) << "ttl (tcp): " << d_options.ttlTCP() << 
                                                        " seconds" << endl;
        }

        d_stdMsg << setw(25) << "verbosity: " << d_options.verbose() << endl;
        d_stdMsg << setw(25) << noboolalpha;
    }

    if (d_options.timeSpecError().length() != 0)
        d_stdMsg << setw(25) << "Time specifcation `" << 
                d_options.timeSpecError() << "' not supported. Using `" << 
                d_options.timeTxt() << "' instead" << endl;
    else if (d_options.verbose() < 2)
        imsg << "Using time type `" << d_options.timeTxt() << '\'' << endl;

    if (d_options.verbose() == 2)
        throw 0;
}