blob: 9c41d27dc0895ab18a568bfc615463c7510d51a4 (
plain) (
blame)
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
|
#include "checker.h"
namespace NIPREG {
void TChecker::CheckNextFatal(const TAddress& first, const TAddress& last) {
if (!CheckNext(first, last))
ythrow yexception() << "IPREG format error: " << first.AsIPv6() << " - " << last.AsIPv6();
}
TFlatChecker::TFlatChecker() : HasState(false) {
}
bool TFlatChecker::CheckNext(const TAddress& first, const TAddress& last) {
bool result = true;
if (first > last)
result = false;
if (HasState && first <= PrevLast)
result = false;
PrevLast = last;
HasState = true;
return result;
}
TIntersectingChecker::TIntersectingChecker() : HasState(false) {
}
bool TIntersectingChecker::CheckNext(const TAddress& first, const TAddress& last) {
bool result = true;
if (first > last)
result = false;
if (HasState && (first < PrevFirst || (first == PrevFirst && last < PrevLast)))
result = false;
PrevFirst = first;
PrevLast = last;
HasState = true;
return result;
}
}
|