summaryrefslogtreecommitdiff
path: root/ot_accesslist.c
diff options
context:
space:
mode:
authorDirk Engling <erdgeist@erdgeist.org>2026-10-24 02:04:33 +0200
committerDirk Engling <erdgeist@erdgeist.org>2026-10-24 02:04:33 +0200
commit168285b4569f862443419a2bffe221e1a8ab8150 (patch)
tree27ef578cd4af2e6860bcbc9c0dcb7af16d80b4ec /ot_accesslist.c
parent0eb6054309f23b3cec7cb799485b859fcf61f794 (diff)
Replace all manual hex conversion with the new helper
Diffstat (limited to 'ot_accesslist.c')
-rw-r--r--ot_accesslist.c26
1 files changed, 4 insertions, 22 deletions
diff --git a/ot_accesslist.c b/ot_accesslist.c
index 2827494..ee6adb2 100644
--- a/ot_accesslist.c
+++ b/ot_accesslist.c
@@ -20,10 +20,10 @@
20#include "fmt.h" 20#include "fmt.h"
21#include "ip6.h" 21#include "ip6.h"
22#include "mmap.h" 22#include "mmap.h"
23#include "scan.h"
24 23
25/* Opentracker */ 24/* Opentracker */
26#include "ot_accesslist.h" 25#include "ot_accesslist.h"
26#include "ot_hex.h"
27#include "ot_vector.h" 27#include "ot_vector.h"
28#include "trackerlogic.h" 28#include "trackerlogic.h"
29 29
@@ -128,20 +128,11 @@ static void accesslist_readfile(void) {
128 128
129 /* 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:].*" */
130 while (read_offs <= map_end) { 130 while (read_offs <= map_end) {
131 size_t i; 131 if (hex_tohash(*info_hash, read_offs)) {
132 for (i = 0; i < sizeof(ot_hash); ++i) {
133 int eger1 = scan_fromhex((unsigned char)read_offs[2 * i]);
134 int eger2 = scan_fromhex((unsigned char)read_offs[1 + 2 * i]);
135 if (eger1 < 0 || eger2 < 0)
136 break;
137 (*info_hash)[i] = (uint8_t)(eger1 * 16 + eger2);
138 }
139
140 if (i == sizeof(ot_hash)) {
141 read_offs += 40; 132 read_offs += 40;
142 133
143 /* Append accesslist to accesslist vector */ 134 /* Append accesslist to accesslist vector */
144 if (read_offs == map_end || scan_fromhex((unsigned char)*read_offs) < 0) 135 if (read_offs == map_end || !hex_isdigit((unsigned char)*read_offs))
145 ++info_hash; 136 ++info_hash;
146 } 137 }
147 138
@@ -261,7 +252,6 @@ static void *accesslist_adddel_worker(char *fifoname, ot_accesslist *_Atomic
261 252
262 while ((linelen = getline(&line, &linecap, fifo)) > 0) { 253 while ((linelen = getline(&line, &linecap, fifo)) > 0) {
263 ot_hash info_hash; 254 ot_hash info_hash;
264 size_t i;
265 255
266 printf("Got line %*s", (int)linelen, line); 256 printf("Got line %*s", (int)linelen, line);
267 /* 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:].*"
@@ -269,15 +259,7 @@ static void *accesslist_adddel_worker(char *fifoname, ot_accesslist *_Atomic
269 if (linelen < 41) 259 if (linelen < 41)
270 continue; 260 continue;
271 261
272 for (i = 0; i < sizeof(ot_hash); ++i) { 262 if (!hex_tohash(info_hash, line))
273 int eger1 = scan_fromhex((unsigned char)line[2 * i]);
274 int eger2 = scan_fromhex((unsigned char)line[1 + 2 * i]);
275 if (eger1 < 0 || eger2 < 0)
276 break;
277 ((uint8_t *)info_hash)[i] = (uint8_t)(eger1 * 16 + eger2);
278 }
279 printf("parsed info_hash %20s\n", info_hash);
280 if (i != sizeof(ot_hash))
281 continue; 263 continue;
282 264
283 /* 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