]>
Commit | Line | Data |
---|---|---|
ef9fab2e P |
1 | #include "trusts.h" |
2 | ||
3 | static trustblock_t *trustblocklist = NULL; | |
4 | ||
5 | trustblock_t *createtrustblock(unsigned long id, patricia_node_t* node, unsigned long ownerid, time_t expire, char *reason_private, char *reason_public) { | |
6 | trustblock_t *tb = newtrustblock(); | |
7 | memset(tb, 0, sizeof(trustblock_t)); | |
8 | ||
9 | tb->startdate = getnettime(); | |
10 | ||
11 | tb->id = id; | |
12 | tb->node = node; | |
13 | tb->ownerid = ownerid; | |
14 | tb->expire = expire; | |
15 | tb->reason_private = getsstring(reason_private,512); | |
16 | tb->reason_public = getsstring(reason_public,512); | |
17 | ||
18 | tb->next=trustblocklist; | |
19 | trustblocklist = tb; | |
20 | return tb; | |
21 | } | |
22 | ||
23 | trustblock_t *createtrustblockfromdb(unsigned long id, patricia_node_t* node, unsigned long ownerid, time_t expire, time_t startdate, char *reason_private, char *reason_public) { | |
24 | trustblock_t *tb = createtrustblock(id,node,ownerid, expire, reason_private, reason_public); | |
25 | ||
26 | tb->startdate = startdate; | |
27 | return tb; | |
28 | } | |
29 | ||
30 | void trustblock_free(trustblock_t* t) | |
31 | { | |
32 | trustblock_t *st, *pst=NULL; | |
33 | for (st = trustblocklist; st; st=st->next) { | |
34 | if (st == t ) { | |
35 | break; | |
36 | } | |
37 | pst = st; | |
38 | } | |
39 | ||
40 | if (st) { | |
41 | if (pst) { | |
42 | pst->next = st->next; | |
43 | } | |
44 | derefnode(iptree,st->node); | |
45 | if (st->reason_public ) { | |
46 | freesstring(st->reason_public); | |
47 | } | |
48 | if (st->reason_private) { | |
49 | freesstring(st->reason_private); | |
50 | } | |
51 | freetrustblock(st); | |
52 | } | |
53 | } | |
54 | ||
55 | void trustblock_expire( trustblock_t *tb) { | |
56 | controlwall(NO_OPER, NL_TRUSTS, "trustblock on %s/%d expired",IPtostr(tb->node->prefix->sin),irc_bitlen(&(tb->node->prefix->sin),tb->node->prefix->bitlen)); | |
57 | trustsdb_deletetrustblock(tb->node->exts[tgb_ext]); | |
58 | trustblock_free(tb->node->exts[tgb_ext]); | |
59 | tb->node->exts[tgb_ext] = NULL; | |
60 | } | |
61 | ||
62 | void trustblock_freeall() { | |
63 | trustblock_t *tb, *ptb=NULL; | |
64 | tb=trustblocklist; | |
65 | while(tb) { | |
66 | ptb=tb; | |
67 | tb=tb->next; | |
68 | derefnode(iptree,ptb->node); | |
69 | if (ptb->reason_public ) { | |
70 | freesstring(ptb->reason_public); | |
71 | } | |
72 | if (ptb->reason_private) { | |
73 | freesstring(ptb->reason_private); | |
74 | } | |
75 | } | |
76 | } |