3 * IPv4 address class. They understand how to take netmasks into consideration
4 * during equivalence testing.
6 * Gilbert Ramirez <gram@alumni.rice.edu>
10 * Wireshark - Network traffic analyzer
11 * By Gerald Combs <gerald@wireshark.org>
12 * Copyright 1998 Gerald Combs
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
33 #include "ws_symbol_export.h"
37 guint32 addr
; /* stored in host order */
38 guint32 nmask
; /* stored in host order */
41 /* Allocate a new ipv4_addr struct, initialize it, and return pointer */
42 ipv4_addr
* ipv4_addr_new(void);
44 /* Frees an ipv4 struct */
45 void ipv4_addr_free(ipv4_addr
*ipv4
);
47 void ipv4_addr_set_host_order_addr(ipv4_addr
*ipv4
, const guint32 new_addr
);
48 void ipv4_addr_set_net_order_addr(ipv4_addr
*ipv4
, const guint32 new_addr
);
49 void ipv4_addr_set_netmask_bits(ipv4_addr
*ipv4
, const guint new_nmask_bits
);
52 guint32
ipv4_get_net_order_addr(ipv4_addr
*ipv4
);
53 guint32
ipv4_get_host_order_addr(ipv4_addr
*ipv4
);
55 /* Fills in a buffer with a dotted-decimal notation representation of an IPv4
57 void ipv4_addr_str_buf(const ipv4_addr
*ipv4
, gchar
*buf
);
59 /* Compares two ipv4_addrs, taking into account the less restrictive of the
60 * two netmasks, applying that netmask to both addrs.
62 gboolean
ipv4_addr_eq(const ipv4_addr
*a
, const ipv4_addr
*b
);
63 gboolean
ipv4_addr_gt(const ipv4_addr
*a
, const ipv4_addr
*b
);
64 gboolean
ipv4_addr_ge(const ipv4_addr
*a
, const ipv4_addr
*b
);
65 gboolean
ipv4_addr_lt(const ipv4_addr
*a
, const ipv4_addr
*b
);
66 gboolean
ipv4_addr_le(const ipv4_addr
*a
, const ipv4_addr
*b
);
68 #define ipv4_addr_ne(a,b) !ipv4_addr_eq((a),(b))