penalty
penalty_addr_cmp(struct penalty *a, struct penalty *b)
penalty_expiry_cmp(struct penalty *a, struct penalty *b)
struct penalty *penalty, *tmp;
RB_FOREACH_SAFE(penalty, penalties_by_expiry, by_expiry, tmp) {
if (penalty->expiry >= now)
penalty) != penalty ||
penalty) != penalty)
free(penalty);
struct penalty find, *penalty;
if ((penalty = RB_FIND(penalties_by_addr, by_addr, &find)) == NULL)
if (penalty->expiry < now) {
if (!penalty->active)
*reason = penalty->reason;
struct penalty *p = NULL;
struct penalty *penalty = NULL, *existing = NULL;
penalty = xcalloc(1, sizeof(*penalty));
penalty->addr = masked;
penalty->expiry = now + penalty_secs;
penalty->reason = reason;
penalty)) == NULL) {
penalty->active = 1;
if (RB_INSERT(penalties_by_expiry, by_expiry, penalty) != NULL)
addrnetmask, penalty->active ? "active" : "deferred",
existing->reason = penalty->reason;
free(penalty);
penalty = NULL;
struct penalty *p = NULL;
RB_ENTRY(penalty) by_addr;
RB_ENTRY(penalty) by_expiry;
static int penalty_addr_cmp(struct penalty *a, struct penalty *b);
static int penalty_expiry_cmp(struct penalty *a, struct penalty *b);
RB_HEAD(penalties_by_addr, penalty) penalties_by_addr4, penalties_by_addr6;
RB_HEAD(penalties_by_expiry, penalty) penalties_by_expiry4, penalties_by_expiry6;
RB_GENERATE_STATIC(penalties_by_addr, penalty, by_addr, penalty_addr_cmp)
RB_GENERATE_STATIC(penalties_by_expiry, penalty, by_expiry, penalty_expiry_cmp)