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

Comparing ircd-hybrid/trunk/src/ipcache.c (file contents):
Revision 5347 by michael, Sun Jan 11 12:42:20 2015 UTC vs.
Revision 8279 by michael, Tue Feb 20 19:30:13 2018 UTC

# Line 1 | Line 1
1   /*
2   *  ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3   *
4 < *  Copyright (c) 1997-2015 ircd-hybrid development team
4 > *  Copyright (c) 1997-2018 ircd-hybrid development team
5   *
6   *  This program is free software; you can redistribute it and/or modify
7   *  it under the terms of the GNU General Public License as published by
# Line 37 | Line 37 | static dlink_list ip_hash_table[IP_HASH_
37   static mp_pool_t *ip_entry_pool;
38  
39  
40
40   /* ipcache_hash_address()
41   *
42   * input        - pointer to an irc_inaddr
# Line 78 | Line 77 | ipcache_hash_address(const struct irc_ss
77   * count set to 0.
78   */
79   struct ip_entry *
80 < ipcache_find_or_add_address(struct irc_ssaddr *addr)
80 > ipcache_find_or_add_address(const struct irc_ssaddr *addr)
81   {
82    dlink_node *node = NULL;
83    struct ip_entry *iptr = NULL;
84    const uint32_t hash_index = ipcache_hash_address(addr);
85 <  struct sockaddr_in *v4 = (struct sockaddr_in *)addr, *ptr_v4;
86 <  struct sockaddr_in6 *v6 = (struct sockaddr_in6 *)addr, *ptr_v6;
85 >  const struct sockaddr_in *v4 = (const struct sockaddr_in *)addr, *ptr_v4;
86 >  const struct sockaddr_in6 *v6 = (const struct sockaddr_in6 *)addr, *ptr_v6;
87  
88    DLINK_FOREACH(node, ip_hash_table[hash_index].head)
89    {
# Line 95 | Line 94 | ipcache_find_or_add_address(struct irc_s
94  
95      if (addr->ss.ss_family == AF_INET6)
96      {
97 <      ptr_v6 = (struct sockaddr_in6 *)&iptr->ip;
97 >      ptr_v6 = (const struct sockaddr_in6 *)&iptr->ip;
98        if (!memcmp(&v6->sin6_addr, &ptr_v6->sin6_addr, sizeof(struct in6_addr)))
99          return iptr;  /* Found entry already in hash, return it. */
100      }
101      else
102      {
103 <      ptr_v4 = (struct sockaddr_in *)&iptr->ip;
103 >      ptr_v4 = (const struct sockaddr_in *)&iptr->ip;
104        if (!memcmp(&v4->sin_addr, &ptr_v4->sin_addr, sizeof(struct in_addr)))
105          return iptr;  /* Found entry already in hash, return it. */
106      }
# Line 125 | Line 124 | ipcache_find_or_add_address(struct irc_s
124   *                 the struct ip_entry is returned to the ip_entry_heap
125   */
126   void
127 < ipcache_remove_address(struct irc_ssaddr *addr)
127 > ipcache_remove_address(const struct irc_ssaddr *addr)
128   {
129    dlink_node *node = NULL;
130    const uint32_t hash_index = ipcache_hash_address(addr);
131 <  struct sockaddr_in *v4 = (struct sockaddr_in *)addr, *ptr_v4;
132 <  struct sockaddr_in6 *v6 = (struct sockaddr_in6 *)addr, *ptr_v6;
131 >  const struct sockaddr_in *v4 = (const struct sockaddr_in *)addr, *ptr_v4;
132 >  const struct sockaddr_in6 *v6 = (const struct sockaddr_in6 *)addr, *ptr_v6;
133  
134    DLINK_FOREACH(node, ip_hash_table[hash_index].head)
135    {
# Line 141 | Line 140 | ipcache_remove_address(struct irc_ssaddr
140  
141      if (addr->ss.ss_family == AF_INET6)
142      {
143 <      ptr_v6 = (struct sockaddr_in6 *)&iptr->ip;
143 >      ptr_v6 = (const struct sockaddr_in6 *)&iptr->ip;
144        if (memcmp(&v6->sin6_addr, &ptr_v6->sin6_addr, sizeof(struct in6_addr)))
145          continue;
146      }
147      else
148      {
149 <      ptr_v4 = (struct sockaddr_in *)&iptr->ip;
149 >      ptr_v4 = (const struct sockaddr_in *)&iptr->ip;
150        if (memcmp(&v4->sin_addr, &ptr_v4->sin_addr, sizeof(struct in_addr)))
151          continue;
152      }
# Line 202 | Line 201 | ipcache_remove_expired_entries(void *unu
201   * used in the hash.
202   */
203   void
204 < ipcache_get_stats(unsigned int *const number_ips_stored, uint64_t *const mem_ips_stored)
204 > ipcache_get_stats(unsigned int *const number_ips_stored, size_t *const mem_ips_stored)
205   {
206    for (unsigned int i = 0; i < IP_HASH_SIZE; ++i)
207      *number_ips_stored += dlink_list_length(&ip_hash_table[i]);

Comparing ircd-hybrid/trunk/src/ipcache.c (property svn:eol-style):
Revision 5347 by michael, Sun Jan 11 12:42:20 2015 UTC vs.
Revision 8279 by michael, Tue Feb 20 19:30:13 2018 UTC

# Line 0 | Line 1
1 + native

Comparing ircd-hybrid/trunk/src/ipcache.c (property svn:keywords):
Revision 5347 by michael, Sun Jan 11 12:42:20 2015 UTC vs.
Revision 8279 by michael, Tue Feb 20 19:30:13 2018 UTC

# Line 1 | Line 1
1 < Id Revision
1 > Id

Diff Legend

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