1 /* This software was written by Dirk Engling <erdgeist@erdgeist.org>
2 It is considered beerware. Prost. Skol. Cheers or whatever.
6 #ifndef OT_ACCESSLIST_H__
7 #define OT_ACCESSLIST_H__
9 #include "trackerlogic.h"
11 #if defined(WANT_ACCESSLIST_BLACK) && defined(WANT_ACCESSLIST_WHITE)
12 #error WANT_ACCESSLIST_BLACK and WANT_ACCESSLIST_WHITE are exclusive.
15 #if defined(WANT_ACCESSLIST_BLACK) || defined(WANT_ACCESSLIST_WHITE)
16 #define WANT_ACCESSLIST
17 void accesslist_init(void);
18 void accesslist_deinit(void);
19 int accesslist_hashisvalid(ot_hash hash
);
20 void accesslist_cleanup(void);
22 extern char *g_accesslist_filename
;
23 #ifdef WANT_DYNAMIC_ACCESSLIST
24 extern char *g_accesslist_pipe_add
;
25 extern char *g_accesslist_pipe_delete
;
29 #ifdef WANT_DYNAMIC_ACCESSLIST
30 #error WANT_DYNAMIC_ACCESSLIST needs either WANT_ACCESSLIST_BLACK or WANT_ACCESSLIST_WHITE
33 #define accesslist_init(accesslist_filename)
34 #define accesslist_deinit()
35 #define accesslist_hashisvalid(hash) 1
38 /* Test if an address is subset of an ot_net, return value is considered a bool */
39 int address_in_net(const ot_ip6 address
, const ot_net
*net
);
41 /* Store a value into a vector of struct { ot_net net, uint8_t[x] value } member;
43 if member_size is too small, or
44 if one of the nets inside the vector are a subnet of _net_, or
45 if _net_ is a subnet of one of the nets inside the vector, or
46 if the vector could not be resized
47 returns pointer to new member in vector for success
48 member_size can be sizeof(ot_net) to reduce the lookup to a boolean mapping
50 void *set_value_for_net(const ot_net
*net
, ot_vector
*vector
, const void *value
, const size_t member_size
);
52 /* Takes a vector filled with struct { ot_net net, uint8_t[x] value } member;
53 Returns pointer to _member_ associated with the net, or NULL if not found
54 member_size can be sizeof(ot_net) to reduce the lookup to a boolean mapping
56 void *get_value_for_net(const ot_ip6 address
, const ot_vector
*vector
, const size_t member_size
);
58 #ifdef WANT_IP_FROM_PROXY
59 int proxylist_add_network(const ot_net
*proxy
, const ot_net
*net
);
60 int proxylist_check_network(const ot_ip6
*proxy
, const ot_ip6 address
/* can be NULL to only check proxy */);
63 #ifdef WANT_FULLLOG_NETWORKS
64 typedef struct ot_log ot_log
;
72 extern ot_log
*g_logchain_first
, *g_logchain_last
;
74 void loglist_add_network(const ot_net
*net
);
76 int loglist_check_address(const ot_ip6 address
);
80 OT_PERMISSION_MAY_FULLSCRAPE
= 0x1,
81 OT_PERMISSION_MAY_STAT
= 0x2,
82 OT_PERMISSION_MAY_LIVESYNC
= 0x4,
83 OT_PERMISSION_MAY_PROXY
= 0x8
86 int accesslist_bless_net(ot_net
*net
, ot_permissions permissions
);
87 int accesslist_is_blessed(ot_ip6 ip
, ot_permissions permissions
);