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 MAXTRUSTEDFOR 50000
19 #define MAXDURATION 365 * 86400 * 20
20 #define MAXPERIDENT 1000
22 #define TABLES_REGULAR 0
23 #define TABLES_MIGRATION 1
24 #define TABLES_REPLICATION 2
26 struct trustmigration
;
30 typedef struct trusthost
{
34 unsigned int maxusage
;
38 struct trustgroup
*group
;
43 struct trusthost
*parent
, *children
;
46 struct trusthost
*nextbychild
;
47 struct trusthost
*next
;
50 typedef struct trustgroup
{
54 unsigned int trustedfor
;
56 unsigned int maxperident
;
57 unsigned int maxusage
;
60 time_t lastmaxuserreset
;
61 sstring
*createdby
, *contact
, *comment
;
68 struct trustgroup
*next
;
70 void *exts
[MAXTGEXTS
];
73 #define nextbytrust(x) (nick *)((x)->exts[trusts_nextuserext])
74 #define gettrusthost(x) (trusthost *)((x)->exts[trusts_thext])
75 #define setnextbytrust(x, y) (x)->exts[trusts_nextuserext] = (y)
76 #define settrusthost(x, y) (x)->exts[trusts_thext] = (y)
79 extern int trusts_thext
, trusts_nextuserext
;
80 int findtgext(const char *);
81 int registertgext(const char *);
82 void releasetgext(int);
83 int trusts_fullyonline(void);
86 char *trusts_timetostr(time_t);
87 int trusts_parsecidr(const char *, uint32_t *, short *);
88 int trusts_str2cidr(const char *, uint32_t *, uint32_t *);
89 char *trusts_cidr2str(uint32_t, uint32_t);
90 char *dumpth(trusthost
*, int);
91 char *dumptg(trustgroup
*, int);
92 int parseth(char *, trusthost
*, unsigned int *, int);
93 int parsetg(char *, trustgroup
*, int);
97 extern trustgroup
*tglist
;
98 trustgroup
*tg_getbyid(unsigned int);
99 void th_free(trusthost
*);
100 trusthost
*th_add(trusthost
*);
101 void tg_free(trustgroup
*, int);
102 trustgroup
*tg_add(trustgroup
*);
103 trusthost
*th_getbyhost(uint32_t);
104 trusthost
*th_getbyhostandmask(uint32_t, uint32_t);
105 trusthost
*th_getsmallestsupersetbyhost(uint32_t, uint32_t);
106 trustgroup
*tg_strtotg(char *);
107 void th_adjusthosts(trusthost
*th
, trusthost
*, trusthost
*);
108 void th_getsuperandsubsets(uint32_t, uint32_t, trusthost
**, trusthost
**);
109 trusthost
*th_getsubsetbyhost(uint32_t ip
, uint32_t mask
);
110 trusthost
*th_getnextsubsetbyhost(trusthost
*th
, uint32_t ip
, uint32_t mask
);
111 void th_linktree(void);
112 unsigned int nexttgmarker(void);
113 unsigned int nextthmarker(void);
114 trusthost
*th_getbyid(unsigned int);
115 int tg_modify(trustgroup
*, trustgroup
*);
118 typedef void (*TrustMigrationGroup
)(void *, trustgroup
*);
119 typedef void (*TrustMigrationHost
)(void *, trusthost
*, unsigned int);
120 typedef void (*TrustMigrationFini
)(void *, int);
123 extern int trustsdbloaded
;
124 int trusts_loaddb(void);
125 void trusts_closedb(int);
126 trustgroup
*tg_new(trustgroup
*);
127 trusthost
*th_new(trustgroup
*, char *);
128 void trustsdb_insertth(char *, trusthost
*, unsigned int);
129 void trustsdb_inserttg(char *, trustgroup
*);
130 trustgroup
*tg_copy(trustgroup
*);
131 trusthost
*th_copy(trusthost
*);
132 void tg_update(trustgroup
*);
133 void tg_delete(trustgroup
*);
134 void th_delete(trusthost
*);
136 typedef struct trustmigration
{
141 TrustMigrationGroup group
;
142 TrustMigrationHost host
;
143 TrustMigrationFini fini
;
147 typedef void (*TrustDBMigrationCallback
)(int, void *);
150 void trusts_newnick(nick
*, int);
151 void trusts_lostnick(nick
*, int);