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);
81 extern int trustsdbloaded
;
82 int trusts_loaddb(void);
83 void trusts_closedb(int);
84 trustgroup
*tg_new(char *name
, unsigned int trustedfor
, int mode
, unsigned int maxperident
, time_t expires
, char *createdby
, char *contact
, char *comment
);
85 trusthost
*th_new(trustgroup
*tg
, char *host
);
88 char *trusts_timetostr(time_t);
89 int trusts_parsecidr(const char *, uint32_t *, short *);
90 int trusts_str2cidr(const char *, uint32_t *, uint32_t *);
91 char *trusts_cidr2str(uint32_t, uint32_t);
94 extern trustgroup
*tglist
;
95 trustgroup
*tg_getbyid(unsigned int);
96 void th_free(trusthost
*);
97 trusthost
*th_add(trustgroup
*, unsigned int, char *, unsigned int, time_t);
98 void tg_free(trustgroup
*);
99 trustgroup
*tg_add(unsigned int, char *, unsigned int, int, unsigned int, unsigned int, time_t, time_t, time_t, char *, char *, char *);
100 trusthost
*th_getbyhost(uint32_t);
101 trusthost
*th_getbyhostandmask(uint32_t, uint32_t);
102 trusthost
*th_getsmallestsupersetbyhost(uint32_t, uint32_t);
103 trustgroup
*tg_strtotg(char *);
104 void th_adjusthosts(trusthost
*th
, trusthost
*, trusthost
*);
105 void th_getsuperandsubsets(uint32_t, uint32_t, trusthost
**, trusthost
**);
106 trusthost
*th_getsubsetbyhost(uint32_t ip
, uint32_t mask
);
107 trusthost
*th_getnextsubsetbyhost(trusthost
*th
, uint32_t ip
, uint32_t mask
);
108 void th_linktree(void);
109 unsigned int nexttgmarker(void);
110 unsigned int nextthmarker(void);
113 typedef void (*TrustMigrationGroup
)(void *, unsigned int, char *, unsigned int, unsigned int, unsigned int, unsigned int, time_t, time_t, time_t, char *, char *, char *);
114 typedef void (*TrustMigrationHost
)(void *, unsigned int, char *, unsigned int, time_t);
115 typedef void (*TrustMigrationFini
)(void *, int);
117 typedef struct trustmigration
{
122 TrustMigrationGroup group
;
123 TrustMigrationHost host
;
124 TrustMigrationFini fini
;
128 typedef void (*TrustDBMigrationCallback
)(int, void *);
131 void trusts_newnick(nick
*, int);
132 void trusts_lostnick(nick
*, int);