2003-07-31 04:18:01 +00:00
|
|
|
/* ipv4.h
|
1999-11-15 06:32:38 +00:00
|
|
|
*
|
|
|
|
* IPv4 address class. They understand how to take netmasks into consideration
|
|
|
|
* during equivalence testing.
|
|
|
|
*
|
2001-11-13 23:55:44 +00:00
|
|
|
* Gilbert Ramirez <gram@alumni.rice.edu>
|
1999-11-15 06:32:38 +00:00
|
|
|
*
|
2004-07-18 00:24:25 +00:00
|
|
|
* $Id$
|
1999-11-15 06:32:38 +00:00
|
|
|
*
|
2006-05-21 05:12:17 +00:00
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
1999-11-15 06:32:38 +00:00
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2002-08-28 20:41:00 +00:00
|
|
|
*
|
1999-11-15 06:32:38 +00:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2002-08-28 20:41:00 +00:00
|
|
|
*
|
1999-11-15 06:32:38 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2012-06-28 22:56:06 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
1999-11-15 06:32:38 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __IPV4_H__
|
|
|
|
#define __IPV4_H__
|
|
|
|
|
2001-02-01 20:21:25 +00:00
|
|
|
#include <glib.h>
|
|
|
|
|
1999-11-15 06:32:38 +00:00
|
|
|
typedef struct {
|
|
|
|
guint32 addr; /* stored in host order */
|
|
|
|
guint32 nmask; /* stored in host order */
|
|
|
|
} ipv4_addr;
|
|
|
|
|
|
|
|
/* Allocate a new ipv4_addr struct, initialize it, and return pointer */
|
|
|
|
ipv4_addr* ipv4_addr_new(void);
|
|
|
|
|
|
|
|
/* Frees an ipv4 struct */
|
|
|
|
void ipv4_addr_free(ipv4_addr *ipv4);
|
|
|
|
|
2010-04-03 18:18:50 +00:00
|
|
|
void ipv4_addr_set_host_order_addr(ipv4_addr *ipv4, const guint32 new_addr);
|
|
|
|
void ipv4_addr_set_net_order_addr(ipv4_addr *ipv4, const guint32 new_addr);
|
|
|
|
void ipv4_addr_set_netmask_bits(ipv4_addr *ipv4, const guint new_nmask_bits);
|
1999-11-15 06:32:38 +00:00
|
|
|
|
|
|
|
guint32 ipv4_get_net_order_addr(ipv4_addr *ipv4);
|
|
|
|
guint32 ipv4_get_host_order_addr(ipv4_addr *ipv4);
|
|
|
|
|
2003-07-31 04:18:01 +00:00
|
|
|
/* Fills in a buffer with a dotted-decimal notation representation of an IPv4
|
|
|
|
* address. */
|
|
|
|
void ipv4_addr_str_buf(const ipv4_addr *ipv4, gchar *buf);
|
1999-11-19 22:32:00 +00:00
|
|
|
|
1999-11-15 06:32:38 +00:00
|
|
|
/* Compares two ipv4_addrs, taking into account the less restrictive of the
|
|
|
|
* two netmasks, applying that netmask to both addrs.
|
|
|
|
*/
|
2012-11-06 13:28:59 +00:00
|
|
|
gboolean ipv4_addr_eq(const ipv4_addr *a, const ipv4_addr *b);
|
|
|
|
gboolean ipv4_addr_gt(const ipv4_addr *a, const ipv4_addr *b);
|
|
|
|
gboolean ipv4_addr_ge(const ipv4_addr *a, const ipv4_addr *b);
|
|
|
|
gboolean ipv4_addr_lt(const ipv4_addr *a, const ipv4_addr *b);
|
|
|
|
gboolean ipv4_addr_le(const ipv4_addr *a, const ipv4_addr *b);
|
1999-11-15 06:32:38 +00:00
|
|
|
|
2000-04-14 05:39:43 +00:00
|
|
|
#define ipv4_addr_ne(a,b) !ipv4_addr_eq((a),(b))
|
|
|
|
|
1999-11-15 06:32:38 +00:00
|
|
|
#endif
|