summaryrefslogtreecommitdiff
path: root/src/ot_accesslist.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/ot_accesslist.h')
-rw-r--r--src/ot_accesslist.h77
1 files changed, 77 insertions, 0 deletions
diff --git a/src/ot_accesslist.h b/src/ot_accesslist.h
new file mode 100644
index 0000000..68c88dc
--- /dev/null
+++ b/src/ot_accesslist.h
@@ -0,0 +1,77 @@
1/* This software was written by Dirk Engling <erdgeist@erdgeist.org>
2 It is considered beerware. Prost. Skol. Cheers or whatever. */
3
4#ifndef OT_ACCESSLIST_H__
5#define OT_ACCESSLIST_H__
6
7#include "trackerlogic.h"
8
9#if defined(WANT_ACCESSLIST_BLACK) && defined(WANT_ACCESSLIST_WHITE)
10#error WANT_ACCESSLIST_BLACK and WANT_ACCESSLIST_WHITE are exclusive.
11#endif
12
13#if defined(WANT_ACCESSLIST_BLACK) || defined(WANT_ACCESSLIST_WHITE)
14#define WANT_ACCESSLIST
15/* Starts a thread that rereads the list when sent SIGHUP, and is stopped by
16 being sent one, so the caller blocks SIGHUP process wide beforehand */
17void accesslist_init(void);
18void accesslist_deinit(void);
19int accesslist_hashisvalid(const ot_hash hash);
20void accesslist_cleanup(void);
21
22/* Scan buf for up to capacity info_hashes in hexadecimal notation, one per
23 line, and return how many were written to dest */
24size_t accesslist_parse_hashes(ot_hash *dest, size_t capacity, const char *buf, size_t len);
25
26extern const char *g_accesslist_filename;
27#ifdef WANT_DYNAMIC_ACCESSLIST
28extern const char *g_accesslist_pipe_add;
29extern const char *g_accesslist_pipe_delete;
30#endif
31
32#else
33#ifdef WANT_DYNAMIC_ACCESSLIST
34#error WANT_DYNAMIC_ACCESSLIST needs either WANT_ACCESSLIST_BLACK or WANT_ACCESSLIST_WHITE
35#endif
36
37#define accesslist_init(accesslist_filename)
38#define accesslist_deinit()
39#define accesslist_hashisvalid(hash) 1
40#endif
41
42/* Test if an address is subset of an ot_net, return value is considered a bool */
43int accesslist_address_in_net(const ot_ip6 address, const ot_net *net);
44
45/* Store a value into a vector of struct { ot_net net, uint8_t[x] value } member;
46 returns NULL
47 if member_size is too small, or
48 if one of the nets inside the vector are a subnet of _net_, or
49 if _net_ is a subnet of one of the nets inside the vector, or
50 if the vector could not be resized
51 returns pointer to new member in vector for success
52 member_size can be sizeof(ot_net) to reduce the lookup to a boolean mapping
53*/
54void *accesslist_set_value_for_net(const ot_net *net, ot_vector *vector, const void *value, const size_t member_size);
55
56/* Takes a vector filled with struct { ot_net net, uint8_t[x] value } member;
57 Returns pointer to _member_ associated with the net, or NULL if not found
58 member_size can be sizeof(ot_net) to reduce the lookup to a boolean mapping
59*/
60void *accesslist_get_value_for_net(const ot_ip6 address, const ot_vector *vector, const size_t member_size);
61
62#ifdef WANT_IP_FROM_PROXY
63int proxylist_add_network(const ot_net *proxy, const ot_net *net);
64int proxylist_check_network(const ot_ip6 *proxy, const ot_ip6 address /* can be NULL to only check proxy */);
65#endif
66
67typedef enum {
68 OT_PERMISSION_MAY_FULLSCRAPE = 0x1,
69 OT_PERMISSION_MAY_STAT = 0x2,
70 OT_PERMISSION_MAY_LIVESYNC = 0x4,
71 OT_PERMISSION_MAY_PROXY = 0x8
72} ot_permissions;
73
74int accesslist_bless_net(ot_net *net, ot_permissions permissions);
75int accesslist_is_blessed(ot_ip6 ip, ot_permissions permissions);
76
77#endif