Some fixes to the man page
[opentracker.git] / ot_accesslist.h
blob0a7488ea6f34cab886ff341e70146d1429bbfad3
1 /* This software was written by Dirk Engling <erdgeist@erdgeist.org>
2 It is considered beerware. Prost. Skol. Cheers or whatever.
4 $id$ */
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.
13 #endif
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;
26 #endif
28 #else
29 #ifdef WANT_DYNAMIC_ACCESSLIST
30 #error WANT_DYNAMIC_ACCESSLIST needs either WANT_ACCESSLIST_BLACK or WANT_ACCESSLIST_WHITE
31 #endif
33 #define accesslist_init(accesslist_filename)
34 #define accesslist_deinit()
35 #define accesslist_hashisvalid(hash) 1
36 #endif
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;
42 returns NULL
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 */);
61 #endif
63 #ifdef WANT_FULLLOG_NETWORKS
64 typedef struct ot_log ot_log;
65 struct ot_log {
66 ot_ip6 ip;
67 uint8_t *data;
68 size_t size;
69 ot_time time;
70 ot_log *next;
72 extern ot_log *g_logchain_first, *g_logchain_last;
74 void loglist_add_network(const ot_net *net);
75 void loglist_reset();
76 int loglist_check_address(const ot_ip6 address);
77 #endif
79 typedef enum {
80 OT_PERMISSION_MAY_FULLSCRAPE = 0x1,
81 OT_PERMISSION_MAY_STAT = 0x2,
82 OT_PERMISSION_MAY_LIVESYNC = 0x4,
83 OT_PERMISSION_MAY_PROXY = 0x8
84 } ot_permissions;
86 int accesslist_bless_net(ot_net *net, ot_permissions permissions);
87 int accesslist_is_blessed(ot_ip6 ip, ot_permissions permissions);
89 #endif