-
Notifications
You must be signed in to change notification settings - Fork 1
/
lists.h
154 lines (116 loc) · 3.12 KB
/
lists.h
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/* $Id: lists.h,v 1.2 2005/08/19 07:31:06 chris Exp $ */
/*
Squirm - A Redirector for Squid
Maintained by Chris Foote, [email protected]
Copyright (C) 1998-2005 Chris Foote
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Please see the file GPL in this directory for full copyright
information.
*/
#ifndef LISTS_H
#define LISTS_H
#include<sys/types.h>
#include "regex.h"
#include "ip.h"
#define NORMAL 1
#define EXTENDED 2
#define ABORT 3
#define ABORT_ON_MATCH 4
#define ABORT_NORMAL 5
#define ABORT_EXTENDED 6
#define ACCEL_NORMAL 1
#define ACCEL_START 2
#define ACCEL_END 3
/* the two chief lists */
struct subnet_block *subnet_head;
struct pattern_file *pattern_head;
struct IP_item {
struct cidr subnet;
struct IP_item *next;
};
struct REGEX_pattern {
char *pattern;
char *replacement;
int case_sensitive;
int type;
int has_accel;
int accel_type;
char *accel;
regex_t cpattern;
};
struct pattern_item {
struct REGEX_pattern patterns;
struct pattern_item *next;
};
struct pattern_file {
struct pattern_item *head;
char *filename;
struct pattern_file *next;
};
struct pattern_block {
struct pattern_file *p_head;
int methods;
struct pattern_block *next;
};
struct subnet_block {
struct IP_item *sub_list;
struct pattern_block *pattern_list;
char *abort_log_name;
char *log_name;
struct subnet_block *next;
};
/* What all this actually means:
*subnet_head ----> cidr ----> cidr ----> cidr ...
|\
| \______> *pattern_file ----> *pattern_file ----> *pattern_file...
|
\/
subnet_block ----> cidr...
|\
| \______> *pattern_file ----> *pattern_file
|
\/
subnet_block ----> cidr ----> cidr ----> cidr ----> cidr...
|\
| \_______> *pattern_file...
|
\/
subnet_block ----> cidr ----> cidr ----> cidr...
.\
. \_______> *pattern_file...
.
.
Now the various *pattern_files above point into the primary list below
*pattern_head ----> pattern_item ----> pattern_item ...
|
|
\/
pattern_file ----> pattern_item...
|
|
\/
pattern_file ----> pattern_item....
.
.
.
*/
void init_subnet_blocks(void);
void init_pattern_blocks(void);
struct subnet_block *add_subnet_block();
int add_to_ip_list(struct cidr, struct subnet_block *block);
int add_pattern_file(char *conf_filename, struct subnet_block *block, int methods);
void add_to_plist(struct REGEX_pattern, struct pattern_item **list);
void add_to_patterns(char *pattern, struct pattern_item **list);
void init_lists(void);
void free_lists(void);
#endif