]>
Commit | Line | Data |
---|---|---|
2b6e02e2 CP |
1 | #ifndef __TRUSTS_H |
2 | #define __TRUSTS_H | |
3 | ||
4 | #include <time.h> | |
65f34016 | 5 | #include <stdint.h> |
1bbe1ac3 | 6 | #include "../nick/nick.h" |
2b6e02e2 CP |
7 | #include "../lib/sstring.h" |
8 | ||
9 | #define MIGRATION_STOPPED -1 | |
83bccee3 | 10 | #define MIGRATION_LASTERROR -2 |
2b6e02e2 CP |
11 | |
12 | #define CONTACTLEN 100 | |
13 | #define COMMENTLEN 300 | |
be2823bc CP |
14 | #define TRUSTNAMELEN 100 |
15 | #define TRUSTHOSTLEN 100 | |
2129448c | 16 | #define MAXTGEXTS 5 |
2b6e02e2 CP |
17 | |
18 | struct trustmigration; | |
19 | ||
1bbe1ac3 CP |
20 | struct trusthost; |
21 | ||
be2823bc | 22 | typedef struct trusthost { |
9bf9e8a1 CP |
23 | unsigned int id; |
24 | ||
65f34016 | 25 | uint32_t ip, mask; |
4be1aaf2 | 26 | unsigned int maxusage; |
be2823bc CP |
27 | time_t lastseen; |
28 | ||
1bbe1ac3 CP |
29 | nick *users; |
30 | struct trustgroup *group; | |
31 | ||
32 | unsigned int count; | |
33 | ||
6ebeb438 | 34 | |
b76fd8e6 | 35 | struct trusthost *parent, *children; |
6ebeb438 | 36 | unsigned int marker; |
b76fd8e6 | 37 | |
6ebeb438 | 38 | struct trusthost *nextbychild; |
be2823bc CP |
39 | struct trusthost *next; |
40 | } trusthost; | |
41 | ||
2b6e02e2 CP |
42 | typedef struct trustgroup { |
43 | unsigned int id; | |
44 | ||
45 | sstring *name; | |
46 | unsigned int trustedfor; | |
47 | int mode; | |
48 | unsigned int maxperident; | |
4be1aaf2 | 49 | unsigned int maxusage; |
2b6e02e2 | 50 | time_t expires; |
be2823bc | 51 | time_t lastseen; |
2b6e02e2 | 52 | time_t lastmaxuserreset; |
2b6e02e2 CP |
53 | sstring *createdby, *contact, *comment; |
54 | ||
be2823bc | 55 | trusthost *hosts; |
1bbe1ac3 CP |
56 | unsigned int count; |
57 | ||
6ebeb438 CP |
58 | unsigned int marker; |
59 | ||
2b6e02e2 | 60 | struct trustgroup *next; |
2129448c CP |
61 | |
62 | void *exts[MAXTGEXTS]; | |
2b6e02e2 CP |
63 | } trustgroup; |
64 | ||
1bbe1ac3 CP |
65 | #define nextbytrust(x) (nick *)((x)->exts[trusts_nextuserext]) |
66 | #define gettrusthost(x) (trusthost *)((x)->exts[trusts_thext]) | |
67 | #define setnextbytrust(x, y) (x)->exts[trusts_nextuserext] = (y) | |
68 | #define settrusthost(x, y) (x)->exts[trusts_thext] = (y) | |
69 | ||
45e8ce62 CP |
70 | /* trusts.c */ |
71 | extern int trusts_thext, trusts_nextuserext; | |
2129448c CP |
72 | int findtgext(const char *); |
73 | int registertgext(const char *); | |
74 | void releasetgext(int); | |
45e8ce62 | 75 | |
5ada3782 | 76 | /* db.c */ |
be2823bc | 77 | extern int trustsdbloaded; |
83bccee3 CP |
78 | int trusts_loaddb(void); |
79 | void trusts_closedb(int); | |
d2c08930 CP |
80 | trustgroup *tg_new(char *name, unsigned int trustedfor, int mode, unsigned int maxperident, time_t expires, char *createdby, char *contact, char *comment); |
81 | trusthost *th_new(trustgroup *tg, char *host); | |
8a95d3e4 CP |
82 | |
83 | /* formats.c */ | |
84 | char *trusts_timetostr(time_t); | |
65f34016 CP |
85 | int trusts_parsecidr(const char *, uint32_t *, short *); |
86 | int trusts_str2cidr(const char *, uint32_t *, uint32_t *); | |
87 | char *trusts_cidr2str(uint32_t, uint32_t); | |
5ada3782 CP |
88 | |
89 | /* data.c */ | |
be2823bc | 90 | extern trustgroup *tglist; |
5ada3782 CP |
91 | trustgroup *tg_getbyid(unsigned int); |
92 | void th_free(trusthost *); | |
d2c08930 | 93 | trusthost *th_add(trustgroup *, unsigned int, char *, unsigned int, time_t); |
5ada3782 | 94 | void tg_free(trustgroup *); |
d2c08930 CP |
95 | trustgroup *tg_add(unsigned int, char *, unsigned int, int, unsigned int, unsigned int, time_t, time_t, time_t, char *, char *, char *); |
96 | trusthost *th_getbyhost(uint32_t); | |
9097ab05 CP |
97 | trusthost *th_getbyhostandmask(uint32_t, uint32_t); |
98 | trusthost *th_getsmallestsupersetbyhost(uint32_t, uint32_t); | |
99 | trustgroup *tg_strtotg(char *); | |
100 | void th_adjusthosts(trusthost *th, trusthost *, trusthost *); | |
101 | void th_getsuperandsubsets(uint32_t, uint32_t, trusthost **, trusthost **); | |
b76fd8e6 CP |
102 | trusthost *th_getsubsetbyhost(uint32_t ip, uint32_t mask); |
103 | trusthost *th_getnextsubsetbyhost(trusthost *th, uint32_t ip, uint32_t mask); | |
104 | void th_linktree(void); | |
6ebeb438 CP |
105 | unsigned int nexttgmarker(void); |
106 | unsigned int nextthmarker(void); | |
5ada3782 CP |
107 | |
108 | /* migration.c */ | |
109 | typedef void (*TrustMigrationGroup)(void *, unsigned int, char *, unsigned int, unsigned int, unsigned int, unsigned int, time_t, time_t, time_t, char *, char *, char *); | |
110 | typedef void (*TrustMigrationHost)(void *, unsigned int, char *, unsigned int, time_t); | |
111 | typedef void (*TrustMigrationFini)(void *, int); | |
2b6e02e2 | 112 | |
5ada3782 CP |
113 | typedef struct trustmigration { |
114 | int count, cur; | |
115 | void *schedule; | |
116 | void *tag; | |
117 | ||
118 | TrustMigrationGroup group; | |
119 | TrustMigrationHost host; | |
120 | TrustMigrationFini fini; | |
121 | } trustmigration; | |
122 | ||
123 | /* db-migration.c */ | |
5ada3782 | 124 | typedef void (*TrustDBMigrationCallback)(int, void *); |
2d4ba67d | 125 | |
9097ab05 CP |
126 | /* events.c */ |
127 | void trusts_newnick(nick *, int); | |
128 | void trusts_lostnick(nick *, int); | |
129 | ||
2b6e02e2 | 130 | #endif |