6 #include "../nick/nick.h"
7 #include "../lib/sstring.h"
9 #define MIGRATION_STOPPED -1
10 #define MIGRATION_LASTERROR -2
12 #define CONTACTLEN 100
13 #define COMMENTLEN 300
14 #define TRUSTNAMELEN 100
15 #define TRUSTHOSTLEN 100
18 #define TABLES_REGULAR 0
19 #define TABLES_MIGRATION 1
20 #define TABLES_REPLICATION 2
22 struct trustmigration
;
26 typedef struct trusthost
{
30 unsigned int maxusage
;
34 struct trustgroup
*group
;
39 struct trusthost
*parent
, *children
;
42 struct trusthost
*nextbychild
;
43 struct trusthost
*next
;
46 typedef struct trustgroup
{
50 unsigned int trustedfor
;
52 unsigned int maxperident
;
53 unsigned int maxusage
;
56 time_t lastmaxuserreset
;
57 sstring
*createdby
, *contact
, *comment
;
64 struct trustgroup
*next
;
66 void *exts
[MAXTGEXTS
];
69 #define nextbytrust(x) (nick *)((x)->exts[trusts_nextuserext])
70 #define gettrusthost(x) (trusthost *)((x)->exts[trusts_thext])
71 #define setnextbytrust(x, y) (x)->exts[trusts_nextuserext] = (y)
72 #define settrusthost(x, y) (x)->exts[trusts_thext] = (y)
75 extern int trusts_thext
, trusts_nextuserext
;
76 int findtgext(const char *);
77 int registertgext(const char *);
78 void releasetgext(int);
79 int trusts_fullyonline(void);
82 extern int trustsdbloaded
;
83 int trusts_loaddb(void);
84 void trusts_closedb(int);
85 trustgroup
*tg_new(trustgroup
*);
86 trusthost
*th_new(trustgroup
*, char *);
87 void trustsdb_insertth(char *, trusthost
*, unsigned int);
88 void trustsdb_inserttg(char *, trustgroup
*);
89 trustgroup
*tg_copy(trustgroup
*);
90 trusthost
*th_copy(trusthost
*);
93 char *trusts_timetostr(time_t);
94 int trusts_parsecidr(const char *, uint32_t *, short *);
95 int trusts_str2cidr(const char *, uint32_t *, uint32_t *);
96 char *trusts_cidr2str(uint32_t, uint32_t);
97 char *dumpth(trusthost
*, int);
98 char *dumptg(trustgroup
*, int);
99 int parseth(char *, trusthost
*, unsigned int *, int);
100 int parsetg(char *, trustgroup
*, int);
104 extern trustgroup
*tglist
;
105 trustgroup
*tg_getbyid(unsigned int);
106 void th_free(trusthost
*);
107 trusthost
*th_add(trusthost
*);
108 void tg_free(trustgroup
*);
109 trustgroup
*tg_add(trustgroup
*);
110 trusthost
*th_getbyhost(uint32_t);
111 trusthost
*th_getbyhostandmask(uint32_t, uint32_t);
112 trusthost
*th_getsmallestsupersetbyhost(uint32_t, uint32_t);
113 trustgroup
*tg_strtotg(char *);
114 void th_adjusthosts(trusthost
*th
, trusthost
*, trusthost
*);
115 void th_getsuperandsubsets(uint32_t, uint32_t, trusthost
**, trusthost
**);
116 trusthost
*th_getsubsetbyhost(uint32_t ip
, uint32_t mask
);
117 trusthost
*th_getnextsubsetbyhost(trusthost
*th
, uint32_t ip
, uint32_t mask
);
118 void th_linktree(void);
119 unsigned int nexttgmarker(void);
120 unsigned int nextthmarker(void);
121 trustgroup
*tg_inttotg(unsigned int);
124 typedef void (*TrustMigrationGroup
)(void *, trustgroup
*);
125 typedef void (*TrustMigrationHost
)(void *, trusthost
*, unsigned int);
126 typedef void (*TrustMigrationFini
)(void *, int);
128 typedef struct trustmigration
{
133 TrustMigrationGroup group
;
134 TrustMigrationHost host
;
135 TrustMigrationFini fini
;
139 typedef void (*TrustDBMigrationCallback
)(int, void *);
142 void trusts_newnick(nick
*, int);
143 void trusts_lostnick(nick
*, int);