2 * initialize subnet structure
3 * Copyright (C) 2000, 2002 Henry Spencer.
5 * This library is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU Library General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/lgpl.txt>.
10 * This library is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 * License for more details.
15 * RCSID $Id: initsubnet.c,v 1.6 2002/03/12 16:50:46 henry Exp $
21 - initsubnet - initialize ip_subnet from address and count
23 * The only hard part is checking for host-part bits turned on.
25 err_t /* NULL for success, else string literal */
26 initsubnet(addr, count, clash, dst)
27 const ip_address *addr;
29 int clash; /* '0' zero host-part bits, 'x' die on them */
39 n = addrbytesptr(&dst->addr, (const unsigned char **)&p);
41 return "unknown address family";
51 return "unknown clash-control value in initsubnet";
57 return "impossible mask count";
63 if (n > 0 && c != 0) /* partial byte */
68 return "improper subnet, host-part bits on";
75 dst->maskbits = count;
80 - addrtosubnet - initialize ip_subnet from a single address
82 err_t /* NULL for success, else string literal */
83 addrtosubnet(addr, dst)
84 const ip_address *addr;
90 n = addrbytesptr(&dst->addr, (const unsigned char **)NULL);
92 return "unknown address family";