- if (bp->flags & CHANBAN_IP) {
- if (bp->flags & CHANBAN_HOSTEXACT) {
- /* If it's an exact IP ban we can compare it numerically */
- unsigned int cip;
- unsigned char *ch;
-
- /* Well, it won't match if it's not an IPv4 host */
- if (!irc_in_addr_is_ipv4(&(np->p_ipaddr)))
- return 0;
-
- /* Extract the client's IP address into a usable format */
- ch=(unsigned char *)&(np->p_ipaddr.in6_16[6]);
- cip=(ch[0]<<24) | (ch[1]<<16) | (ch[2]<<8) | (ch[3]);
-
- if (cip==bp->ipaddr)
- return 1;
- } else {
- /* It's not an exact IP ban so let's generate the string */
- ipstring=IPtostr(np->p_ipaddr);
-
- if (bp->flags & CHANBAN_HOSTMASK && match2strings(bp->host->content,ipstring))
- return 1;
- }
- } else {
- /* Hostname bans need to be checked against +x host, +h host (if set)
- * and actual host. Note that the +x host is only generated (and checked) if it's
- * possible for the ban to match a hidden host.. */
-
- if ((bp->flags & CHANBAN_HIDDENHOST) && IsAccount(np)) {
- sprintf(fakehost,"%s.%s",np->authname, HIS_HIDDENHOST);
-
- if ((bp->flags & CHANBAN_HOSTEXACT) &&
- !ircd_strcmp(fakehost, bp->host->content))
- return 1;
-
- if ((bp->flags & CHANBAN_HOSTMASK) &&
- match2strings(bp->host->content, fakehost))
- return 1;
- }
-
- if (IsSetHost(np)) {
- if ((bp->flags & CHANBAN_HOSTEXACT) &&
- !ircd_strcmp(np->sethost->content, bp->host->content))
- return 1;
-
- if ((bp->flags & CHANBAN_HOSTMASK) &&
- match2strings(bp->host->content, np->sethost->content))
- return 1;
- }
-
- if (bp->flags & CHANBAN_HOSTEXACT && !ircd_strcmp(np->host->name->content,bp->host->content))
- return 1;
-
- if (bp->flags & CHANBAN_HOSTMASK && match2strings(bp->host->content,np->host->name->content))
- return 1;
- }