3 * IPv4 address class. They understand how to take netmasks into consideration
4 * during equivalence testing.
6 * Gilbert Ramirez <gramirez@tivoli.cm>
8 * $Id: ipv4.h,v 1.4 2000/01/07 22:05:28 guy Exp $
10 * Ethereal - Network traffic analyzer
11 * By Gerald Combs <gerald@zing.org>
12 * Copyright 1998 Gerald Combs
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version 2
18 * of the License, or (at your option) any later version.
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
34 guint32 addr; /* stored in host order */
35 guint32 nmask; /* stored in host order */
38 /* Allocate a new ipv4_addr struct, initialize it, and return pointer */
39 ipv4_addr* ipv4_addr_new(void);
41 /* Frees an ipv4 struct */
42 void ipv4_addr_free(ipv4_addr *ipv4);
44 void ipv4_addr_set_host_order_addr(ipv4_addr *ipv4, guint32 new_addr);
45 void ipv4_addr_set_net_order_addr(ipv4_addr *ipv4, guint32 new_addr);
46 void ipv4_addr_set_netmask_bits(ipv4_addr *ipv4, guint new_nmask_bits);
48 guint32 ipv4_get_net_order_addr(ipv4_addr *ipv4);
49 guint32 ipv4_get_host_order_addr(ipv4_addr *ipv4);
51 /* Returns a string pointer to a dotted-decimal notation representation of an IPv4
52 * address. The pointer points to a internal buffer, so don't try to g_free() it */
53 gchar* ipv4_addr_str(ipv4_addr *ipv4);
55 /* Compares two ipv4_addrs, taking into account the less restrictive of the
56 * two netmasks, applying that netmask to both addrs.
58 gboolean ipv4_addr_eq(ipv4_addr *a, ipv4_addr *b);
59 gboolean ipv4_addr_gt(ipv4_addr *a, ipv4_addr *b);
60 gboolean ipv4_addr_ge(ipv4_addr *a, ipv4_addr *b);
61 gboolean ipv4_addr_lt(ipv4_addr *a, ipv4_addr *b);
62 gboolean ipv4_addr_le(ipv4_addr *a, ipv4_addr *b);