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