#define CHFL_DEOPPED 0x0004 /**< Is de-opped by a server */
#define CHFL_SERVOPOK 0x0008 /**< Server op allowed */
#define CHFL_ZOMBIE 0x0010 /**< Kicked from channel */
-#define CHFL_BAN 0x0020 /**< ban channel flag */
-#define CHFL_BAN_IPMASK 0x0040 /**< ban mask is an IP-number mask */
-#define CHFL_BAN_OVERLAPPED 0x0080 /**< ban overlapped, need bounce */
#define CHFL_BURST_JOINED 0x0100 /**< Just joined by net.junction */
-#define CHFL_BURST_BAN 0x0200 /**< Ban part of last BURST */
-#define CHFL_BURST_BAN_WIPEOUT 0x0400 /**< Ban will be wiped at EOB */
#define CHFL_BANVALID 0x0800 /**< CHFL_BANNED bit is valid */
#define CHFL_BANNED 0x1000 /**< Channel member is banned */
#define CHFL_SILENCE_IPMASK 0x2000 /**< silence mask is a CIDR */
char apass[PASSLEN + 1];
};
+#define BAN_IPMASK 0x0001 /**< ban mask is an IP-number mask */
+#define BAN_OVERLAPPED 0x0002 /**< ban overlapped, need bounce */
+#define BAN_BURSTED 0x0004 /**< Ban part of last BURST */
+#define BAN_BURST_WIPEOUT 0x0008 /**< Ban will be wiped at EOB */
+#define BAN_DEL 0x4000 /**< Ban is being removed */
+#define BAN_ADD 0x8000 /**< Ban is being added */
+
/** A single ban for a channel. */
struct Ban {
struct Ban* next; /**< next ban in the channel */
time_t when; /**< timestamp when ban was added */
- unsigned int flags; /**< modifier flags for the ban
- * Zero or more of CHFL_BURST_BAN_WIPEOUT,
- * CHFL_BAN_OVERLAPPED
- */
+ unsigned int flags; /**< modifier flags for the ban */
char *who; /**< name of client that set the ban */
char *banstr; /**< hostmask that the ban matches */
};
*
* If `change' is true then add `banid' to channel `chptr'.
* Returns 0 if the ban was added.
- * Returns -2 if the ban already existed and was marked CHFL_BURST_BAN_WIPEOUT.
+ * Returns -2 if the ban already existed and was marked BAN_BURST_WIPEOUT.
* Return -1 otherwise.
*
- * Those bans that overlapped with `banid' are flagged with CHFL_BAN_OVERLAPPED
+ * Those bans that overlapped with `banid' are flagged with BAN_OVERLAPPED
* when `change' is false, otherwise they will be removed from the banlist.
* Subsequently calls to next_overlapped_ban() or next_removed_overlapped_ban()
* respectively will return these bans until NULL is returned.
*
* If `firsttime' is true, the ban list as returned by next_overlapped_ban()
* is reset (unless a non-zero value is returned, in which case the
- * CHFL_BAN_OVERLAPPED flag might not have been reset!).
+ * BAN_OVERLAPPED flag might not have been reset!).
*
* @author Run
* @param cptr Client adding the ban
* @param firsttime Reset the next_overlapped_ban() iteration.
* @returns
* 0 if the ban was added
- * -2 if the ban already existed and was marked CHFL_BURST_BAN_WIPEOUT
+ * -2 if the ban already existed and was marked BAN_BURST_WIPEOUT
* -1 otherwise
*/
int add_banid(struct Client *cptr, struct Channel *chptr, char *banid,
{
len += strlen((*banp)->banstr);
++cnt;
- if (((*banp)->flags & CHFL_BURST_BAN_WIPEOUT))
+ if (((*banp)->flags & BAN_BURST_WIPEOUT))
{
if (!strcmp((*banp)->banstr, banid))
{
- (*banp)->flags &= ~CHFL_BURST_BAN_WIPEOUT;
+ (*banp)->flags &= ~BAN_BURST_WIPEOUT;
return -2;
}
}
removed_bans_list = tmp;
removed_bans = 1;
}
- else if (!(tmp->flags & CHFL_BURST_BAN_WIPEOUT))
+ else if (!(tmp->flags & BAN_BURST_WIPEOUT))
{
- tmp->flags |= CHFL_BAN_OVERLAPPED;
+ tmp->flags |= BAN_OVERLAPPED;
if (!next_ban)
next_ban = tmp;
banp = &tmp->next;
else
{
if (firsttime)
- (*banp)->flags &= ~CHFL_BAN_OVERLAPPED;
+ (*banp)->flags &= ~BAN_OVERLAPPED;
banp = &(*banp)->next;
}
}
assert(0 != ban->who);
ban->when = TStime();
- ban->flags = CHFL_BAN; /* This bit is never used I think... */
if ((ip_start = strrchr(banid, '@')) && check_if_ipmask(ip_start + 1))
- ban->flags |= CHFL_BAN_IPMASK;
+ ban->flags |= BAN_IPMASK;
chptr->banlist = ban;
/*
}
for (tmp = chptr->banlist; tmp; tmp = tmp->next) {
- if ((tmp->flags & CHFL_BAN_IPMASK)) {
+ if ((tmp->flags & BAN_IPMASK)) {
if (!ip_s)
ip_s = make_nick_user_ip(nu_ip, cli_name(cptr),
(cli_user(cptr))->username, &cli_ip(cptr));
newban->who = cli_name(state->sptr);
newban->when = TStime();
- newban->flags = CHFL_BAN | MODE_ADD;
+ newban->flags = BAN_ADD;
if ((s = strrchr(t_str, '@')) && check_if_ipmask(s + 1))
- newban->flags |= CHFL_BAN_IPMASK;
+ newban->flags |= BAN_IPMASK;
}
if (!state->chptr->banlist) {
/* first, clean the ban flags up a bit */
if (!(state->done & DONE_BANCLEAN))
/* Note: We're overloading *lots* of bits here; be careful! */
- ban->flags &= ~(MODE_ADD | MODE_DEL | CHFL_BAN_OVERLAPPED);
+ ban->flags &= ~(BAN_ADD | BAN_DEL | BAN_OVERLAPPED);
/* Bit meanings:
*
- * MODE_ADD - Ban was added; if we're bouncing modes,
+ * BAN_ADD - Ban was added; if we're bouncing modes,
* then we'll remove it below; otherwise,
* we'll have to allocate a real ban
*
- * MODE_DEL - Ban was marked for deletion; if we're
+ * BAN_DEL - Ban was marked for deletion; if we're
* bouncing modes, we'll have to re-add it,
* otherwise, we'll have to remove it
*
- * CHFL_BAN_OVERLAPPED - The ban we added turns out to overlap
+ * BAN_OVERLAPPED - The ban we added turns out to overlap
* with a ban already set; if we're
* bouncing modes, we'll have to bounce
* this one; otherwise, we'll just ignore
*/
if (state->dir == MODE_DEL && !ircd_strcmp(ban->banstr, t_str)) {
- ban->flags |= MODE_DEL; /* delete one ban */
+ ban->flags |= BAN_DEL; /* delete one ban */
if (state->done & DONE_BANCLEAN) /* If we're cleaning, finish */
break;
} else if (state->dir == MODE_ADD) {
/* if the ban already exists, don't worry about it */
if (!ircd_strcmp(ban->banstr, t_str)) {
- newban->flags &= ~MODE_ADD; /* don't add ban at all */
+ newban->flags &= ~BAN_ADD; /* don't add ban at all */
MyFree(newban->banstr); /* stopper a leak */
state->numbans--; /* deallocate last ban */
if (state->done & DONE_BANCLEAN) /* If we're cleaning, finish */
break;
} else if (!mmatch(ban->banstr, t_str)) {
- if (!(ban->flags & MODE_DEL))
- newban->flags |= CHFL_BAN_OVERLAPPED; /* our ban overlaps */
+ if (!(ban->flags & BAN_DEL))
+ newban->flags |= BAN_OVERLAPPED; /* our ban overlaps */
} else if (!mmatch(t_str, ban->banstr))
- ban->flags |= MODE_DEL; /* mark ban for deletion: overlapping */
+ ban->flags |= BAN_DEL; /* mark ban for deletion: overlapping */
- if (!ban->next && (newban->flags & MODE_ADD))
+ if (!ban->next && (newban->flags & BAN_ADD))
{
ban->next = newban; /* add our ban with its flags */
break; /* get out of loop */
len += banlen;
nextban = ban->next;
- if ((ban->flags & (MODE_DEL | MODE_ADD)) == (MODE_DEL | MODE_ADD)) {
+ if ((ban->flags & (BAN_DEL | BAN_ADD)) == (BAN_DEL | BAN_ADD)) {
if (prevban)
prevban->next = 0; /* Break the list; ban isn't a real ban */
else
MyFree(ban->banstr);
continue;
- } else if (ban->flags & MODE_DEL) { /* Deleted a ban? */
+ } else if (ban->flags & BAN_DEL) { /* Deleted a ban? */
modebuf_mode_string(state->mbuf, MODE_DEL | MODE_BAN,
ban->banstr,
state->flags & MODE_PARSE_SET);
changed++;
continue; /* next ban; keep prevban like it is */
} else
- ban->flags &= (CHFL_BAN | CHFL_BAN_IPMASK); /* unset other flags */
- } else if (ban->flags & MODE_ADD) { /* adding a ban? */
+ ban->flags &= BAN_IPMASK; /* unset other flags */
+ } else if (ban->flags & BAN_ADD) { /* adding a ban? */
if (prevban)
prevban->next = 0; /* Break the list; ban isn't a real ban */
else
state->chptr->banlist = 0;
/* If we're supposed to ignore it, do so. */
- if (ban->flags & CHFL_BAN_OVERLAPPED &&
+ if (ban->flags & BAN_OVERLAPPED &&
!(state->flags & MODE_PARSE_BOUNCE)) {
count--;
len -= banlen;
newban = make_ban(ban->banstr);
DupString(newban->who, ban->who);
newban->when = ban->when;
- newban->flags = ban->flags & (CHFL_BAN | CHFL_BAN_IPMASK);
+ newban->flags = ban->flags & BAN_IPMASK;
newban->next = state->chptr->banlist; /* and link it in */
state->chptr->banlist = newban;
/* mark bans for wipeout */
for (lp = chptr->banlist; lp; lp = lp->next)
- lp->flags |= CHFL_BURST_BAN_WIPEOUT;
+ lp->flags |= BAN_BURST_WIPEOUT;
/* clear topic set by netrider (if set) */
if (*chptr->topic) {
for (lp = chptr->banlist; lp; lp = lp->next) {
if (!ircd_strcmp(lp->banstr, ban)) {
ban = 0; /* don't add ban */
- lp->flags &= ~CHFL_BURST_BAN_WIPEOUT; /* not wiping out */
+ lp->flags &= ~BAN_BURST_WIPEOUT; /* not wiping out */
break; /* new ban already existed; don't even repropagate */
- } else if (!(lp->flags & CHFL_BURST_BAN_WIPEOUT) &&
+ } else if (!(lp->flags & BAN_BURST_WIPEOUT) &&
!mmatch(lp->banstr, ban)) {
ban = 0; /* don't add ban unless wiping out bans */
break; /* new ban is encompassed by an existing one; drop */
} else if (!mmatch(ban, lp->banstr))
- lp->flags |= CHFL_BAN_OVERLAPPED; /* remove overlapping ban */
+ lp->flags |= BAN_OVERLAPPED; /* remove overlapping ban */
if (!lp->next)
break;
cli_name(feature_bool(FEAT_HIS_BANWHO) ? &me : sptr));
newban->when = TStime();
- newban->flags = CHFL_BAN | CHFL_BURST_BAN; /* set flags */
+ newban->flags = BAN_BURSTED; /* set flags */
if ((ptr = strrchr(ban, '@')) && check_if_ipmask(ptr + 1))
- newban->flags |= CHFL_BAN_IPMASK;
+ newban->flags |= BAN_IPMASK;
newban->next = 0;
if (lp)
lp = *lp_p;
/* remove ban from channel */
- if (lp->flags & (CHFL_BAN_OVERLAPPED | CHFL_BURST_BAN_WIPEOUT)) {
+ if (lp->flags & (BAN_OVERLAPPED | BAN_BURST_WIPEOUT)) {
modebuf_mode_string(mbuf, MODE_DEL | MODE_BAN,
lp->banstr, 1); /* let it free banstr */
lp->banstr = NULL; /* do not free this string */
*lp_p = lp->next; /* clip out of list */
free_ban(lp);
continue;
- } else if (lp->flags & CHFL_BURST_BAN) /* add ban to channel */
+ } else if (lp->flags & BAN_BURSTED) /* add ban to channel */
modebuf_mode_string(mbuf, MODE_ADD | MODE_BAN,
lp->banstr, 0); /* don't free banstr */
- lp->flags &= (CHFL_BAN | CHFL_BAN_IPMASK); /* reset the flag */
+ lp->flags &= BAN_IPMASK; /* reset the flag */
lp_p = &(*lp_p)->next;
}
}