diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-05-22 13:27:02 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-05-22 13:27:02 +0000 |
commit | 37d9ce1d4544050396b44a1a1ba94429cb86267a (patch) | |
tree | 0bd7899469182f78d6d7255722484958597b446a /src/tun/test_regex.c | |
parent | bad29fd9a1cc3b1c7df7b992212568918c961b52 (diff) | |
download | gnunet-37d9ce1d4544050396b44a1a1ba94429cb86267a.tar.gz gnunet-37d9ce1d4544050396b44a1a1ba94429cb86267a.zip |
do not generate wildcard '.' transitions in policy regex, be precise
Diffstat (limited to 'src/tun/test_regex.c')
-rw-r--r-- | src/tun/test_regex.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/src/tun/test_regex.c b/src/tun/test_regex.c index 162a73b4b..f3cf7f7e1 100644 --- a/src/tun/test_regex.c +++ b/src/tun/test_regex.c | |||
@@ -25,6 +25,11 @@ | |||
25 | #include "platform.h" | 25 | #include "platform.h" |
26 | #include "gnunet_tun_lib.h" | 26 | #include "gnunet_tun_lib.h" |
27 | 27 | ||
28 | /** | ||
29 | * 'wildcard', matches all possible values (for HEX encoding). | ||
30 | */ | ||
31 | #define DOT "(0|1|2|3|4|5|6|7|8|9|A|B|C|D|E|F)" | ||
32 | |||
28 | 33 | ||
29 | static int | 34 | static int |
30 | test_iptoregex (const char *ipv4, | 35 | test_iptoregex (const char *ipv4, |
@@ -144,31 +149,31 @@ main (int argc, char *argv[]) | |||
144 | "6-0031-E1E173F951BE00000000000000000000"); | 149 | "6-0031-E1E173F951BE00000000000000000000"); |
145 | error += | 150 | error += |
146 | test_policy4toregex ("192.1.2.0/24:80;", | 151 | test_policy4toregex ("192.1.2.0/24:80;", |
147 | "4-0050-C00102.."); | 152 | "4-0050-C00102" DOT DOT); |
148 | error += | 153 | error += |
149 | test_policy4toregex ("192.1.0.0/16;", | 154 | test_policy4toregex ("192.1.0.0/16;", |
150 | "4-....-C001...."); | 155 | "4-" DOT DOT DOT DOT "-C001" DOT DOT DOT DOT); |
151 | error += | 156 | error += |
152 | test_policy4toregex ("192.1.0.0/16:80-81;", | 157 | test_policy4toregex ("192.1.0.0/16:80-81;", |
153 | "4-(0050|0051)-C001...."); | 158 | "4-(0050|0051)-C001" DOT DOT DOT DOT); |
154 | error += | 159 | error += |
155 | test_policy4toregex ("192.1.0.0/8:!3-65535;", | 160 | test_policy4toregex ("192.1.0.0/8:!3-65535;", |
156 | "4-000(0|1|2)-C0......"); | 161 | "4-000(0|1|2)-C0" DOT DOT DOT DOT DOT DOT); |
157 | error += | 162 | error += |
158 | test_policy4toregex ("192.1.0.0/8:!25-56;", | 163 | test_policy4toregex ("192.1.0.0/8:!25-56;", |
159 | "4-(0(0(0.|1(0|1|2|3|4|5|6|7|8)|3(9|A|B|C|D|E|F)|(4|5|6|7|8|9|A|B|C|D|E|F).)|(1|2|3|4|5|6|7|8|9|A|B|C|D|E|F)..)|(1|2|3|4|5|6|7|8|9|A|B|C|D|E|F)...)-C0......"); | 164 | "4-(0(0(0"DOT"|1(0|1|2|3|4|5|6|7|8)|3(9|A|B|C|D|E|F)|(4|5|6|7|8|9|A|B|C|D|E|F)"DOT")|(1|2|3|4|5|6|7|8|9|A|B|C|D|E|F)"DOT DOT")|(1|2|3|4|5|6|7|8|9|A|B|C|D|E|F)"DOT DOT DOT")-C0"DOT DOT DOT DOT DOT DOT); |
160 | error += | 165 | error += |
161 | test_policy6toregex ("E1E1::1;", | 166 | test_policy6toregex ("E1E1::1;", |
162 | "6-....-E1E10000000000000000000000000001"); | 167 | "6-"DOT DOT DOT DOT"-E1E10000000000000000000000000001"); |
163 | error += | 168 | error += |
164 | test_policy6toregex ("E1E1:ABCD::1/120;", | 169 | test_policy6toregex ("E1E1:ABCD::1/120;", |
165 | "6-....-E1E1ABCD0000000000000000000000.."); | 170 | "6-"DOT DOT DOT DOT"-E1E1ABCD0000000000000000000000" DOT DOT); |
166 | error += | 171 | error += |
167 | test_policy6toregex ("E1E1:ABCD::ABCD/126;", | 172 | test_policy6toregex ("E1E1:ABCD::ABCD/126;", |
168 | "6-....-E1E1ABCD00000000000000000000ABC(C|D|E|F)"); | 173 | "6-"DOT DOT DOT DOT"-E1E1ABCD00000000000000000000ABC(C|D|E|F)"); |
169 | error += | 174 | error += |
170 | test_policy6toregex ("E1E1:ABCD::ABCD/127;", | 175 | test_policy6toregex ("E1E1:ABCD::ABCD/127;", |
171 | "6-....-E1E1ABCD00000000000000000000ABC(C|D)"); | 176 | "6-"DOT DOT DOT DOT"-E1E1ABCD00000000000000000000ABC(C|D)"); |
172 | error += | 177 | error += |
173 | test_policy6toregex ("E1E1:ABCD::ABCD/128:80;", | 178 | test_policy6toregex ("E1E1:ABCD::ABCD/128:80;", |
174 | "6-0050-E1E1ABCD00000000000000000000ABCD"); | 179 | "6-0050-E1E1ABCD00000000000000000000ABCD"); |