/[svn]/ircd-hybrid/trunk/src/misc.c
ViewVC logotype

Diff of /ircd-hybrid/trunk/src/misc.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 8880 by michael, Tue Jan 1 11:07:01 2019 UTC revision 8881 by michael, Sun Apr 14 16:03:29 2019 UTC
# Line 140  binary_to_hex(const unsigned char *bin, Line 140  binary_to_hex(const unsigned char *bin,
140    
141    *hex = '\0';    *hex = '\0';
142  }  }
143    
144    bool
145    address_compare(const void *p1,
146                    const void *p2, bool port)
147    {
148      const struct irc_ssaddr *const addr1 = p1;
149      const struct irc_ssaddr *const addr2 = p2;
150    
151      if (addr1->ss.ss_family != addr2->ss.ss_family)
152        return false;
153    
154      if (addr1->ss.ss_family == AF_INET)
155      {
156        const struct sockaddr_in *const sin1 = (const struct sockaddr_in *)addr1;
157        const struct sockaddr_in *const sin2 = (const struct sockaddr_in *)addr2;
158    
159        if (port == true && (sin1->sin_port != sin2->sin_port))
160          return false;
161        if (sin1->sin_addr.s_addr != sin2->sin_addr.s_addr)
162          return false;
163        return true;
164      }
165      else if (addr1->ss.ss_family == AF_INET6)
166      {
167        const struct sockaddr_in6 *const sin1 = (const struct sockaddr_in6 *)addr1;
168        const struct sockaddr_in6 *const sin2 = (const struct sockaddr_in6 *)addr2;
169    
170        if (port == true && (sin1->sin6_port != sin2->sin6_port))
171          return false;
172        if (memcmp(sin1->sin6_addr.s6_addr,
173                   sin2->sin6_addr.s6_addr, sizeof(struct in6_addr)))
174          return false;
175        return true;
176      }
177    
178      return false;
179    }

Legend:
Removed from v.8880  
changed lines
  Added in v.8881

svnadmin@ircd-hybrid.org
ViewVC Help
Powered by ViewVC 1.1.28