1 /* $Id: xprobe_module_param.h,v 1.10 2005/02/08 20:00:36 mederchik Exp $ */
2 /*
3 ** Copyright (C) 2001 Fyodor Yarochkin <fygrave@tigerteam.net>,
4 **                    Ofir Arkin       <ofir@sys-security.com>
5 **
6 ** This program is free software; you can redistribute it and/or modify
7 ** it under the terms of the GNU General Public License as published by
8 ** the Free Software Foundation; either version 2 of the License, or
9 ** (at your option) any later version.
10 **
11 **
12 ** This program is distributed in the hope that it will be useful,
13 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 ** GNU General Public License for more details.
16 **
17 ** You should have received a copy of the GNU General Public License
18 ** along with this program; if not, write to the Free Software
19 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 */
21 
22 /*
23  * Changes:
24  *				-	Feb 12 14:34:04 2003 meder - added type XPROBE_MODULE_PARAM_ZNZORIG,
25  *					that required addition of an extra argument to the add_param() and
26  *					check_param() methods;
27  */
28 #ifndef XPROBE_MODULE_PARAM_H
29 #define XPROBE_MODULE_PARAM_H
30 
31 #include "xprobe.h"
32 #include "usi++/usi++.h"
33 #include "target.h"
34 #include "os_matrix.h"
35 #include <string>
36 
37 using namespace std;
38 
39 #define XPROBE_MODULE_PARAM_BOOL		1      /* y/n */
40 #define XPROBE_MODULE_PARAM_ZNZ			2      /* zero, not zero -- !0, 0 */
41 #define XPROBE_MODULE_PARAM_INT			3      /* int - 1234 */
42 #define XPROBE_MODULE_PARAM_RANGE		4      /* range - <1, >2, 20-40 */
43 #define XPROBE_MODULE_PARAM_ZNZORIG		5		/* zero, not zero, original value(SENT) */
44 #define XPROBE_MODULE_PARAM_ZNZVAL		6		/* zero, value, not zero */
45 #define XPROBE_MODULE_PARAM_INTLIST		7		/* list of integers (1,2,3,4,...) */
46 #define XPROBE_MODULE_PARAM_STRATEGY	8		/* (R)andom, (I)ncremental, 0 */
47 
48 #define XPROBE_MODULE_PARAM_FUZZY_DELTA     31
49 
50 
51 #define XMP_STRATEGY_RANDOM				2
52 #define XMP_STRATEGY_INCREMENTAL		1
53 #define XMP_STRATEGY_ZERO				0
54 #define XMP_STRATEGY_THRESHOLD			256
55 
56 typedef struct xprobe_module_param_val {
57     int high;
58     int low;
59 	vector <int> val_list;
60 } xprobe_module_param_t;
61 
62 
63 
64 class Xprobe_Module_Param {
65     private:
66         int id;
67         int type;
68         map <int, xprobe_module_param_t> osid_sig;
69         int sig_insert(int os_id, xprobe_module_param_t p);
70     public:
Xprobe_Module_Param(int t)71         Xprobe_Module_Param(int t) { type = t; }
~Xprobe_Module_Param(void)72         virtual ~Xprobe_Module_Param(void) { return; }
73 //        virtual int check_param(ICMP *ip_pkt, ICMP *orig_pkt, OS_Matrix *os) =0;
74         int parse_param(int os_id, const char *param);
75         int add_param(int param, int orig, OS_Matrix *os);
set_id(int i)76         void set_id(int i) { id = i; }
get_id(void)77         int get_id(void) { return id; }
78 		int gen_match(int cnt, OS_Matrix *os);
79 };
80 
81 class Xprobe_Module_Param_TCP: public Xprobe_Module_Param {
82 	public:
Xprobe_Module_Param_TCP(int t)83 		Xprobe_Module_Param_TCP(int t): Xprobe_Module_Param(t) { return; }
~Xprobe_Module_Param_TCP(void)84 		virtual ~Xprobe_Module_Param_TCP(void) { return; }
85 		virtual int check_param(TCP *ip_pkt, TCP *orig_pkt, OS_Matrix *os) =0;
86 };
87 class Xprobe_Module_Param_ICMP: public Xprobe_Module_Param {
88 	public:
Xprobe_Module_Param_ICMP(int t)89 		Xprobe_Module_Param_ICMP(int t): Xprobe_Module_Param(t) {return; }
~Xprobe_Module_Param_ICMP(void)90 		virtual ~Xprobe_Module_Param_ICMP(void) { return; }
91 		virtual int check_param(ICMP *ip_pkt, ICMP *orig_pkt, OS_Matrix *os) =0;
92 };
93 
94 
95 #endif /* XPROBE_MODULE_PARAM */
96