3 * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
4 * Copyright (c) 1996,1999 by Internet Software Consortium.
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
10 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
16 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21 #include "ares_setup.h"
27 * compare bit masks l and r, for n bits.
29 * -1, 1, or 0 in the libc tradition.
31 * network byte order assumed. this means 192.5.5.240/28 has
32 * 0x11110000 in its fourth octet.
34 * Paul Vixie (ISC), June 1996
37 ares_bitncmp(const void *l, const void *r, int n) {
43 if (x || (n % 8) == 0)
46 lb = ((const unsigned char *)l)[b];
47 rb = ((const unsigned char *)r)[b];
48 for (b = n % 8; b > 0; b--) {
49 if ((lb & 0x80) != (rb & 0x80)) {