Branch data Line data Source code
1 : : // $Id: RuleCondition.h 80 2004-07-14 20:15:50Z jason $
2 : :
3 : : #ifndef rulecondition_h
4 : : #define rulecondition_h
5 : :
6 : : #include "BroString.h"
7 : : #include "Func.h"
8 : : #include "List.h"
9 : : #include "util.h"
10 : :
11 : : class Rule;
12 : : class RuleEndpointState;
13 : :
14 : : // Base class for all rule conditions except patterns and "header".
15 : : class RuleCondition {
16 : : public:
17 : 19 : RuleCondition() { }
18 [ # # ][ # # ]: 0 : virtual ~RuleCondition() { }
[ # # ]
19 : :
20 : : virtual bool DoMatch(Rule* rule, RuleEndpointState* state,
21 : : const u_char* data, int len) = 0;
22 : :
23 : : virtual void PrintDebug() = 0;
24 : : };
25 : :
26 : : // Implements the "tcp-state" keyword.
27 : : class RuleConditionTCPState : public RuleCondition {
28 : : public:
29 : : enum TCPState {
30 : : STATE_ESTABLISHED = 1,
31 : : STATE_ORIG = 2,
32 : : STATE_RESP = 4,
33 : : STATE_STATELESS = 8
34 : : };
35 : :
36 : 19 : RuleConditionTCPState(int arg_tcpstates)
37 : 19 : { tcpstates = arg_tcpstates; }
38 : :
39 [ # # ][ # # ]: 0 : virtual ~RuleConditionTCPState() { }
40 : :
41 : : virtual bool DoMatch(Rule* rule, RuleEndpointState* state,
42 : : const u_char* data, int len);
43 : :
44 : : virtual void PrintDebug();
45 : :
46 : : private:
47 : : int tcpstates;
48 : : };
49 : :
50 : :
51 : : // Implements "ip-options".
52 : : class RuleConditionIPOptions : public RuleCondition {
53 : : public:
54 : : enum Options {
55 : : OPT_LSRR = 1,
56 : : OPT_LSRRE = 2,
57 : : OPT_RR = 4,
58 : : OPT_SSRR = 8,
59 : : };
60 : :
61 : 0 : RuleConditionIPOptions(int arg_options) { options = arg_options; }
62 [ # # ][ # # ]: 0 : virtual ~RuleConditionIPOptions() { }
63 : :
64 : : virtual bool DoMatch(Rule* rule, RuleEndpointState* state,
65 : : const u_char* data, int len);
66 : :
67 : : virtual void PrintDebug();
68 : :
69 : : private:
70 : : int options;
71 : : };
72 : :
73 : : // Implements "same-ip".
74 : : class RuleConditionSameIP : public RuleCondition {
75 : : public:
76 : 0 : RuleConditionSameIP() { }
77 [ # # ][ # # ]: 0 : virtual ~RuleConditionSameIP() {}
78 : :
79 : : virtual bool DoMatch(Rule* rule, RuleEndpointState* state,
80 : : const u_char* data, int len);
81 : :
82 : : virtual void PrintDebug();
83 : : };
84 : :
85 : : // Implements "payload-size".
86 : : class RuleConditionPayloadSize : public RuleCondition {
87 : : public:
88 : : enum Comp { RULE_LE, RULE_GE, RULE_LT, RULE_GT, RULE_EQ, RULE_NE };
89 : :
90 : 0 : RuleConditionPayloadSize(uint32 arg_val, Comp arg_comp)
91 : 0 : { val = arg_val; comp = arg_comp; }
92 : :
93 [ # # ][ # # ]: 0 : virtual ~RuleConditionPayloadSize() {}
94 : :
95 : : virtual bool DoMatch(Rule* rule, RuleEndpointState* state,
96 : : const u_char* data, int len);
97 : :
98 : : virtual void PrintDebug();
99 : :
100 : : private:
101 : : uint32 val;
102 : : Comp comp;
103 : : };
104 : :
105 : : // Implements "eval" which evaluates the given Bro identifier.
106 : : class RuleConditionEval : public RuleCondition {
107 : : public:
108 : : RuleConditionEval(const char* func);
109 [ # # ][ # # ]: 0 : virtual ~RuleConditionEval() {}
110 : :
111 : : virtual bool DoMatch(Rule* rule, RuleEndpointState* state,
112 : : const u_char* data, int len);
113 : :
114 : : virtual void PrintDebug();
115 : : private:
116 : : ID* id;
117 : : };
118 : :
119 : :
120 : :
121 : : #endif
|