ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/branches/8.2.x/src/hostmask.c
(Generate patch)

Comparing ircd-hybrid/branches/8.2.x/src/hostmask.c (file contents):
Revision 4413 by michael, Sat Aug 2 16:53:48 2014 UTC vs.
Revision 4414 by michael, Thu Aug 7 14:06:08 2014 UTC

# Line 57 | Line 57
57     Also a bug in DigitParse above.
58     -Gozem 2002-07-19 gozem@linux.nu
59   */
60 #ifdef IPV6
60   static int
61   try_parse_v6_netmask(const char *text, struct irc_ssaddr *addr, int *b)
62   {
# Line 161 | Line 160 | try_parse_v6_netmask(const char *text, s
160      *b = bits;
161    return HM_IPV6;
162   }
164 #endif
163  
164   /* int try_parse_v4_netmask(const char *, struct irc_ssaddr *, int *);
165   * Input: A possible IPV4 address as a string.
# Line 253 | Line 251 | parse_netmask(const char *text, struct i
251   {
252    if (strchr(text, '.'))
253      return try_parse_v4_netmask(text, addr, b);
256 #ifdef IPV6
254    if (strchr(text, ':'))
255      return try_parse_v6_netmask(text, addr, b);
256 < #endif
256 >
257    return HM_HOST;
258   }
259  
# Line 266 | Line 263 | parse_netmask(const char *text, struct i
263   * Output: if match, -1 else 0
264   * Side effects: None
265   */
269 #ifdef IPV6
266   int
267   match_ipv6(const struct irc_ssaddr *addr, const struct irc_ssaddr *mask, int bits)
268   {
# Line 285 | Line 281 | match_ipv6(const struct irc_ssaddr *addr
281      return -1;
282    return 0;
283   }
288 #endif
284  
285   /* int match_ipv4(struct irc_ssaddr *, struct irc_ssaddr *, int)
286   * Input: An IP address, an IP mask, the number of bits in the mask.
# Line 316 | Line 311 | void
311   mask_addr(struct irc_ssaddr *ip, int bits)
312   {
313    int mask;
319 #ifdef IPV6
314    struct sockaddr_in6 *v6_base_ip;
315    int i, m, n;
322 #endif
316    struct sockaddr_in *v4_base_ip;
317  
318 < #ifdef IPV6
326 <  if (ip->ss.ss_family != AF_INET6)
327 < #endif
318 >  if (ip->ss.ss_family == AF_INET)
319    {
320      uint32_t tmp = 0;
321      v4_base_ip = (struct sockaddr_in *)ip;
# Line 333 | Line 324 | mask_addr(struct irc_ssaddr *ip, int bit
324      tmp = ntohl(v4_base_ip->sin_addr.s_addr);
325      v4_base_ip->sin_addr.s_addr = htonl(tmp & mask);
326    }
336 #ifdef IPV6
327    else
328    {
329      n = bits / 8;
# Line 346 | Line 336 | mask_addr(struct irc_ssaddr *ip, int bit
336      for (i = n + 1; i < 16; i++)
337        v6_base_ip->sin6_addr.s6_addr[i] = 0;
338    }
349 #endif
339   }
340  
341   /* Hashtable stuff...now external as it's used in m_stats.c */
# Line 382 | Line 371 | hash_ipv4(const struct irc_ssaddr *addr,
371   * Output: A hash value of the IP address.
372   * Side effects: None
373   */
385 #ifdef IPV6
374   static uint32_t
375   hash_ipv6(const struct irc_ssaddr *addr, int bits)
376   {
# Line 404 | Line 392 | hash_ipv6(const struct irc_ssaddr *addr,
392      else
393        return v & (ATABLE_SIZE - 1);
394    }
395 +
396    return v & (ATABLE_SIZE - 1);
397   }
409 #endif
398  
399   /* int hash_text(const char *start)
400   * Input: The start of the text to hash.
# Line 467 | Line 455 | find_conf_by_address(const char *name, s
455    if (addr)
456    {
457      /* Check for IPV6 matches... */
470 #ifdef IPV6
458      if (fam == AF_INET6)
459      {
460        for (b = 128; b >= 0; b -= 16)
# Line 491 | Line 478 | find_conf_by_address(const char *name, s
478          }
479        }
480      }
481 <    else
495 < #endif
496 <    if (fam == AF_INET)
481 >    else if (fam == AF_INET)
482      {
483        for (b = 32; b >= 0; b -= 8)
484        {
# Line 656 | Line 641 | add_conf_by_address(const unsigned int t
641        bits -= bits % 8;
642        dlinkAdd(arec, &arec->node, &atable[hash_ipv4(&arec->Mask.ipa.addr, bits)]);
643        break;
659 #ifdef IPV6
644      case HM_IPV6:
645        /* We have to do this, since we do not re-hash for every bit -A1kmm. */
646        bits -= bits % 16;
647        dlinkAdd(arec, &arec->node, &atable[hash_ipv6(&arec->Mask.ipa.addr, bits)]);
648        break;
665 #endif
649      default: /* HM_HOST */
650        arec->Mask.hostname = hostname;
651        dlinkAdd(arec, &arec->node, &atable[get_mask_hash(hostname)]);
# Line 693 | Line 676 | delete_one_address_conf(const char *addr
676        bits -= bits % 8;
677        hv = hash_ipv4(&addr, bits);
678        break;
696 #ifdef IPV6
679      case HM_IPV6:
680        /* We have to do this, since we do not re-hash for every bit -A1kmm. */
681        bits -= bits % 16;
682        hv = hash_ipv6(&addr, bits);
683        break;
702 #endif
684      default: /* HM_HOST */
685        hv = get_mask_hash(address);
686        break;

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)