]>
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 | ||
b76fd8e6 CP |
34 | struct trusthost *parent, *children; |
35 | struct trusthost *nextbychild; | |
36 | ||
be2823bc CP |
37 | struct trusthost *next; |
38 | } trusthost; | |
39 | ||
2b6e02e2 CP |
40 | typedef struct trustgroup { |
41 | unsigned int id; | |
42 | ||
43 | sstring *name; | |
44 | unsigned int trustedfor; | |
45 | int mode; | |
46 | unsigned int maxperident; | |
4be1aaf2 | 47 | unsigned int maxusage; |
2b6e02e2 | 48 | time_t expires; |
be2823bc | 49 | time_t lastseen; |
2b6e02e2 | 50 | time_t lastmaxuserreset; |
2b6e02e2 CP |
51 | sstring *createdby, *contact, *comment; |
52 | ||
be2823bc | 53 | trusthost *hosts; |
1bbe1ac3 CP |
54 | unsigned int count; |
55 | ||
2b6e02e2 | 56 | struct trustgroup *next; |
2129448c CP |
57 | |
58 | void *exts[MAXTGEXTS]; | |
2b6e02e2 CP |
59 | } trustgroup; |
60 | ||
1bbe1ac3 CP |
61 | #define nextbytrust(x) (nick *)((x)->exts[trusts_nextuserext]) |
62 | #define gettrusthost(x) (trusthost *)((x)->exts[trusts_thext]) | |
63 | #define setnextbytrust(x, y) (x)->exts[trusts_nextuserext] = (y) | |
64 | #define settrusthost(x, y) (x)->exts[trusts_thext] = (y) | |
65 | ||
45e8ce62 CP |
66 | /* trusts.c */ |
67 | extern int trusts_thext, trusts_nextuserext; | |
2129448c CP |
68 | int findtgext(const char *); |
69 | int registertgext(const char *); | |
70 | void releasetgext(int); | |
45e8ce62 | 71 | |
5ada3782 | 72 | /* db.c */ |
be2823bc | 73 | extern int trustsdbloaded; |
83bccee3 CP |
74 | int trusts_loaddb(void); |
75 | void trusts_closedb(int); | |
d2c08930 CP |
76 | trustgroup *tg_new(char *name, unsigned int trustedfor, int mode, unsigned int maxperident, time_t expires, char *createdby, char *contact, char *comment); |
77 | trusthost *th_new(trustgroup *tg, char *host); | |
8a95d3e4 CP |
78 | |
79 | /* formats.c */ | |
80 | char *trusts_timetostr(time_t); | |
65f34016 CP |
81 | int trusts_parsecidr(const char *, uint32_t *, short *); |
82 | int trusts_str2cidr(const char *, uint32_t *, uint32_t *); | |
83 | char *trusts_cidr2str(uint32_t, uint32_t); | |
5ada3782 CP |
84 | |
85 | /* data.c */ | |
be2823bc | 86 | extern trustgroup *tglist; |
5ada3782 CP |
87 | trustgroup *tg_getbyid(unsigned int); |
88 | void th_free(trusthost *); | |
d2c08930 | 89 | trusthost *th_add(trustgroup *, unsigned int, char *, unsigned int, time_t); |
5ada3782 | 90 | void tg_free(trustgroup *); |
d2c08930 CP |
91 | trustgroup *tg_add(unsigned int, char *, unsigned int, int, unsigned int, unsigned int, time_t, time_t, time_t, char *, char *, char *); |
92 | trusthost *th_getbyhost(uint32_t); | |
9097ab05 CP |
93 | trusthost *th_getbyhostandmask(uint32_t, uint32_t); |
94 | trusthost *th_getsmallestsupersetbyhost(uint32_t, uint32_t); | |
95 | trustgroup *tg_strtotg(char *); | |
96 | void th_adjusthosts(trusthost *th, trusthost *, trusthost *); | |
97 | void th_getsuperandsubsets(uint32_t, uint32_t, trusthost **, trusthost **); | |
b76fd8e6 CP |
98 | trusthost *th_getsubsetbyhost(uint32_t ip, uint32_t mask); |
99 | trusthost *th_getnextsubsetbyhost(trusthost *th, uint32_t ip, uint32_t mask); | |
100 | void th_linktree(void); | |
5ada3782 CP |
101 | |
102 | /* migration.c */ | |
103 | typedef void (*TrustMigrationGroup)(void *, unsigned int, char *, unsigned int, unsigned int, unsigned int, unsigned int, time_t, time_t, time_t, char *, char *, char *); | |
104 | typedef void (*TrustMigrationHost)(void *, unsigned int, char *, unsigned int, time_t); | |
105 | typedef void (*TrustMigrationFini)(void *, int); | |
2b6e02e2 | 106 | |
5ada3782 CP |
107 | typedef struct trustmigration { |
108 | int count, cur; | |
109 | void *schedule; | |
110 | void *tag; | |
111 | ||
112 | TrustMigrationGroup group; | |
113 | TrustMigrationHost host; | |
114 | TrustMigrationFini fini; | |
115 | } trustmigration; | |
116 | ||
117 | /* db-migration.c */ | |
5ada3782 | 118 | typedef void (*TrustDBMigrationCallback)(int, void *); |
2d4ba67d | 119 | |
9097ab05 CP |
120 | /* events.c */ |
121 | void trusts_newnick(nick *, int); | |
122 | void trusts_lostnick(nick *, int); | |
123 | ||
2b6e02e2 | 124 | #endif |