summaryrefslogtreecommitdiff
path: root/ot_accesslist.c
diff options
context:
space:
mode:
Diffstat (limited to 'ot_accesslist.c')
-rw-r--r--ot_accesslist.c27
1 files changed, 4 insertions, 23 deletions
diff --git a/ot_accesslist.c b/ot_accesslist.c
index 8e9afdc..ee6adb2 100644
--- a/ot_accesslist.c
+++ b/ot_accesslist.c
@@ -17,14 +17,13 @@
17#endif 17#endif
18 18
19/* Libowfat */ 19/* Libowfat */
20#include "byte.h"
21#include "fmt.h" 20#include "fmt.h"
22#include "ip6.h" 21#include "ip6.h"
23#include "mmap.h" 22#include "mmap.h"
24#include "scan.h"
25 23
26/* Opentracker */ 24/* Opentracker */
27#include "ot_accesslist.h" 25#include "ot_accesslist.h"
26#include "ot_hex.h"
28#include "ot_vector.h" 27#include "ot_vector.h"
29#include "trackerlogic.h" 28#include "trackerlogic.h"
30 29
@@ -129,20 +128,11 @@ static void accesslist_readfile(void) {
129 128
130 /* We do ignore anything that is not of the form "^[:xdigit:]{40}[^:xdigit:].*" */ 129 /* We do ignore anything that is not of the form "^[:xdigit:]{40}[^:xdigit:].*" */
131 while (read_offs <= map_end) { 130 while (read_offs <= map_end) {
132 size_t i; 131 if (hex_tohash(*info_hash, read_offs)) {
133 for (i = 0; i < sizeof(ot_hash); ++i) {
134 int eger1 = scan_fromhex((unsigned char)read_offs[2 * i]);
135 int eger2 = scan_fromhex((unsigned char)read_offs[1 + 2 * i]);
136 if (eger1 < 0 || eger2 < 0)
137 break;
138 (*info_hash)[i] = (uint8_t)(eger1 * 16 + eger2);
139 }
140
141 if (i == sizeof(ot_hash)) {
142 read_offs += 40; 132 read_offs += 40;
143 133
144 /* Append accesslist to accesslist vector */ 134 /* Append accesslist to accesslist vector */
145 if (read_offs == map_end || scan_fromhex((unsigned char)*read_offs) < 0) 135 if (read_offs == map_end || !hex_isdigit((unsigned char)*read_offs))
146 ++info_hash; 136 ++info_hash;
147 } 137 }
148 138
@@ -262,7 +252,6 @@ static void *accesslist_adddel_worker(char *fifoname, ot_accesslist *_Atomic
262 252
263 while ((linelen = getline(&line, &linecap, fifo)) > 0) { 253 while ((linelen = getline(&line, &linecap, fifo)) > 0) {
264 ot_hash info_hash; 254 ot_hash info_hash;
265 size_t i;
266 255
267 printf("Got line %*s", (int)linelen, line); 256 printf("Got line %*s", (int)linelen, line);
268 /* We do ignore anything that is not of the form "^[:xdigit:]{40}[^:xdigit:].*" 257 /* We do ignore anything that is not of the form "^[:xdigit:]{40}[^:xdigit:].*"
@@ -270,15 +259,7 @@ static void *accesslist_adddel_worker(char *fifoname, ot_accesslist *_Atomic
270 if (linelen < 41) 259 if (linelen < 41)
271 continue; 260 continue;
272 261
273 for (i = 0; i < sizeof(ot_hash); ++i) { 262 if (!hex_tohash(info_hash, line))
274 int eger1 = scan_fromhex((unsigned char)line[2 * i]);
275 int eger2 = scan_fromhex((unsigned char)line[1 + 2 * i]);
276 if (eger1 < 0 || eger2 < 0)
277 break;
278 ((uint8_t *)info_hash)[i] = (uint8_t)(eger1 * 16 + eger2);
279 }
280 printf("parsed info_hash %20s\n", info_hash);
281 if (i != sizeof(ot_hash))
282 continue; 263 continue;
283 264
284 /* From now on we modify g_accesslist_add and g_accesslist_delete, so prevent the 265 /* From now on we modify g_accesslist_add and g_accesslist_delete, so prevent the