mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-24 14:36:13 +01:00
GInetAddress: add equal() method
This is needed in the fix for https://bugzilla.gnome.org/show_bug.cgi?id=631379 Signed-off-by: David Zeuthen <davidz@redhat.com>
This commit is contained in:
parent
8b03077a44
commit
33515d4eb4
@ -1486,6 +1486,7 @@ g_inet_address_new_from_string
|
||||
g_inet_address_new_from_bytes
|
||||
g_inet_address_new_any
|
||||
g_inet_address_new_loopback
|
||||
g_inet_address_equal
|
||||
g_inet_address_to_bytes
|
||||
g_inet_address_get_native_size
|
||||
g_inet_address_to_string
|
||||
|
@ -866,3 +866,32 @@ g_inet_address_get_is_mc_site_local (GInetAddress *address)
|
||||
else
|
||||
return IN6_IS_ADDR_MC_SITELOCAL (&address->priv->addr.ipv6);
|
||||
}
|
||||
|
||||
/**
|
||||
* g_inet_address_equal:
|
||||
* @address: A #GInetAddress.
|
||||
* @other_address: Another #GInetAddress.
|
||||
*
|
||||
* Checks if two #GInetAddress instances are equal, e.g. the same address.
|
||||
*
|
||||
* Returns: %TRUE if @address and @other_address are equal, %FALSE otherwise.
|
||||
*
|
||||
* Since: 2.30
|
||||
*/
|
||||
gboolean
|
||||
g_inet_address_equal (GInetAddress *address,
|
||||
GInetAddress *other_address)
|
||||
{
|
||||
g_return_val_if_fail (G_IS_INET_ADDRESS (address), FALSE);
|
||||
g_return_val_if_fail (G_IS_INET_ADDRESS (other_address), FALSE);
|
||||
|
||||
if (g_inet_address_get_family (address) != g_inet_address_get_family (other_address))
|
||||
return FALSE;
|
||||
|
||||
if (memcmp (g_inet_address_to_bytes (address),
|
||||
g_inet_address_to_bytes (other_address),
|
||||
g_inet_address_get_native_size (address)) != 0)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -69,6 +69,9 @@ GInetAddress * g_inet_address_new_loopback (GSocketFamily
|
||||
|
||||
GInetAddress * g_inet_address_new_any (GSocketFamily family);
|
||||
|
||||
gboolean g_inet_address_equal (GInetAddress *address,
|
||||
GInetAddress *other_address);
|
||||
|
||||
gchar * g_inet_address_to_string (GInetAddress *address);
|
||||
|
||||
const guint8 * g_inet_address_to_bytes (GInetAddress *address);
|
||||
|
@ -1123,6 +1123,7 @@ g_inet_address_get_is_site_local
|
||||
g_inet_address_to_bytes
|
||||
g_inet_address_get_native_size
|
||||
g_inet_address_to_string
|
||||
g_inet_address_equal
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user