2 * minor network-address manipulation utilities
3 * Copyright (C) 1998, 1999 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: subnetof.c,v 1.4 1999/04/10 23:24:22 henry Exp $
21 - subnetof - given address and mask, return subnet part
28 struct in_addr result;
30 result.s_addr = addr.s_addr & mask.s_addr;
35 - hostof - given address and mask, return host part
42 struct in_addr result;
44 result.s_addr = addr.s_addr & ~mask.s_addr;
49 - broadcastof - given (network) address and mask, return broadcast address
52 broadcastof(addr, mask)
56 struct in_addr result;
58 result.s_addr = addr.s_addr | ~mask.s_addr;