2N/A * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") 2N/A * Copyright (c) 1998,1999 by Internet Software Consortium. 2N/A * Permission to use, copy, modify, and distribute this software for any 2N/A * purpose with or without fee is hereby granted, provided that the above 2N/A * copyright notice and this permission notice appear in all copies. 2N/A * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES 2N/A * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 2N/A * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR 2N/A * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 2N/A * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 2N/A * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT 2N/A * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 2N/A * inet_cidr_pton(af, src, dst, *bits) 2N/A * convert network address from presentation to network format. 2N/A * accepts inet_pton()'s input for this "af" plus trailing "/CIDR". 2N/A * "dst" is assumed large enough for its "af". "bits" is set to the 2N/A * /CIDR prefix length, which can have defaults (like /32 for IPv4). 2N/A * -1 if an error occurred (inspect errno; ENOENT means bad format). 2N/A * 0 if successful conversion occurred. 2N/A * 192.5.5.1/28 has a nonzero host part, which means it isn't a network 2N/A * as called for by inet_net_pton() but it can be a host address with 2N/A * an included netmask. 2N/A * Paul Vixie (ISC), October 1998 2N/A /* Get the mantissa. */ 2N/A /* Get the prefix length if any. */ 2N/A /* Prefix length can default to /32 only if all four octets spec'd. */ 2N/A /* If nothing was written to the destination, we found no address. */ 2N/A /* If prefix length overspecifies mantissa, life is bad. */ 2N/A /* Extend address to four octets. */ 2N/A /* Leading :: requires some special handling. */ 2N/A break;
/*%< '\\0' was seen by inet_pton4(). */ 2N/A * Since some memmove()'s erroneously fail to handle 2N/A * overlapping regions, we'll do the shift by hand. 2N/A for (i =
1; i <= n; i++) {
2N/A if (*
src ==
'\0')
/*%< syntax */ 2N/A if (
bits == 0 && *
src !=
'\0')
/*%< no leading zeros */