initial
[rrq/rrqmisc.git] / socket-sniff / ignores.i
1 static char *IGNORES[] = {
2     "10.0.99.",         // ganetinet
3     "127.",             // localhost
4     "152.228.204.144",  // VM via nardoo
5     "152.228.204.145",
6     "152.228.204.146",
7     "152.228.204.147",
8     "152.228.204.148",
9     "152.228.204.149",
10     "152.228.204.150",
11     "152.228.204.151",
12     "152.228.204.152",
13     "152.228.204.153",
14     "152.228.204.154",
15     "152.228.204.155",
16     "152.228.204.156",
17     "152.228.204.157",
18     "152.228.204.158",
19     "152.228.204.159",
20     "2001:41d0:2:1f68:" // (via) nash
21     "2001:41d0:2:d06e:" // (via) newtonia
22     "2001:41d0:8:732b:" // (via) napier
23     "2001:41d0:a:511b:" // (via) nardoo
24     "37.187.145.27",    // nardoo
25     "37.59.56.43",      // napier
26     "46.105.97.110",    // newtonia
27     "5.135.82.176",     // VM via napier
28     "5.135.82.177",
29     "5.135.82.178",
30     "5.135.82.179",
31     "5.135.82.180",
32     "5.135.82.181",
33     "5.135.82.182",
34     "5.135.82.183",
35     "5.135.82.184",
36     "5.135.82.185",
37     "5.135.82.186",
38     "5.135.82.187",
39     "5.135.82.188",
40     "5.135.82.189",
41     "5.135.82.190",
42     "5.135.82.191",
43     "5.196.38.16",      // VM via newtonia
44     "5.196.38.17",
45     "5.196.38.18",
46     "5.196.38.19",
47     "5.196.38.20",
48     "5.196.38.21",
49     "5.196.38.22",
50     "5.196.38.23",
51     "5.196.38.24",
52     "5.196.38.25",
53     "5.196.38.26",
54     "5.196.38.27",
55     "5.196.38.28",
56     "5.196.38.29",
57     "5.196.38.30",
58     "5.196.38.31",
59     "54.36.142.176",    // VM via nash
60     "54.36.142.177",
61     "54.36.142.178",
62     "54.36.142.179",
63     "54.36.142.180",
64     "54.36.142.181",
65     "54.36.142.182",
66     "54.36.142.183",
67     "54.36.142.184",
68     "54.36.142.185",
69     "54.36.142.186",
70     "54.36.142.187",
71     "54.36.142.188",
72     "54.36.142.189",
73     "54.36.142.190",
74     "54.36.142.191",
75     "94.23.30.104",     // nash
76     (char*)0
77 };
78
79 // Return the size of the IGN table
80 static int IGN_count() {
81     int i = 0;
82     while ( IGNORES[ i ] != 0 ) {
83         i++;
84     }
85     return i;
86 }
87
88 /**
89  * Compare an IP against an ignore entry of width w.
90  * return 0 if ip starts with ign, <0 if ip < ign, and >0 if ip > ign
91  */
92 static int IGN_cmp(const void *ipx, const void *ignx) {
93     char *ip = (char *) ipx;
94     char *ign = *(char**) ignx;
95     while ( *ign ) {
96         if ( *ip == 0 ) {
97             return -1;
98         }
99         int c = *(ip++) - *(ign++);
100         if ( c ) {
101             return c;
102         }
103     }
104     return 0;
105 }
106
107 static int ignored(char *ip) {
108     static int IGN_size = -1;
109     if ( IGN_size == -1 ) {
110         IGN_size = IGN_count();
111     }
112     return bsearch( ip, IGNORES, IGN_size, sizeof( char* ), IGN_cmp )? 1 : 0;
113 }