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 6527 by michael, Fri Sep 11 16:33:29 2015 UTC vs.
Revision 6651 by michael, Sun Oct 25 15:27:31 2015 UTC

# Line 77 | 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 94 | 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 124 | 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 140 | 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      }

Diff Legend

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