GInetAddressMask

## GInetAddressMask GInetAddressMask — An IPv4/IPv6 address mask |

## Functions

GInetAddressMask * | g_inet_address_mask_new ()
GInetAddressMask * | g_inet_address_mask_new_from_string ()
gchar * | g_inet_address_mask_to_string ()
GSocketFamily | g_inet_address_mask_get_family ()
GInetAddress * | g_inet_address_mask_get_address ()
guint | g_inet_address_mask_get_length ()
gboolean | g_inet_address_mask_matches ()
gboolean | g_inet_address_mask_equal ()

## Properties

GInetAddress * | address | Read / Write
GSocketFamily | family | Read
guint | length | Read / Write

## Types and Values

| GInetAddressMask

## Object Hierarchy

        GObject
        ╰── GInetAddressMask

## Implemented Interfaces

GInetAddressMask implements GInitable.

## Includes

    #include <gio/gio.h>

## Description

GInetAddressMask represents a range of IPv4 or IPv6 addresses described by a base address and a length indicating how many bits of the base address are relevant for matching purposes. These are often given in string form. Eg, "10.0.0.0/8", or "fe80::/10".

## Functions

### g_inet_address_mask_new ()

    GInetAddressMask *
    g_inet_address_mask_new (GInetAddress *addr,
                             guint length,
                             GError **error);

Creates a new GInetAddressMask representing all addresses whose first `length` bits match `addr` .

#### Parameters

addr | a GInetAddress |
length | number of bits of `addr` to use |
error | return location for GError, or `NULL` |

#### Returns

a new GInetAddressMask, or `NULL` on error

Since: 2.32

### g_inet_address_mask_new_from_string ()

    GInetAddressMask *
    g_inet_address_mask_new_from_string (const gchar *mask_string,
                                         GError **error);

Parses `mask_string` as an IP address and (optional) length, and creates a new GInetAddressMask. The length, if present, is delimited by a "/". If it is not present, then the length is assumed to be the full length of the address.

#### Parameters

mask_string | an IP address or address/length string |
error | return location for GError, or `NULL` |

#### Returns

a new GInetAddressMask corresponding to `string` , or `NULL` on error.

Since: 2.32

### g_inet_address_mask_to_string ()

    gchar *
    g_inet_address_mask_to_string (GInetAddressMask *mask);

Converts `mask` back to its corresponding string form.

#### Parameters

mask | a GInetAddressMask |

#### Returns

a string corresponding to `mask` .

Since: 2.32

### g_inet_address_mask_get_family ()

    GSocketFamily
    g_inet_address_mask_get_family (GInetAddressMask *mask);

Gets the GSocketFamily of `mask` 's address

#### Parameters

mask | a GInetAddressMask |

#### Returns

the GSocketFamily of `mask` 's address

Since: 2.32

### g_inet_address_mask_get_address ()

    GInetAddress *
    g_inet_address_mask_get_address (GInetAddressMask *mask);

Gets `mask` 's base address

#### Parameters

mask | a GInetAddressMask |

#### Returns

`mask` 's base address.

[transfer none]

Since: 2.32

### g_inet_address_mask_get_length ()

    guint
    g_inet_address_mask_get_length (GInetAddressMask *mask);

Gets `mask` 's length

#### Parameters

mask | a GInetAddressMask |

#### Returns

`mask` 's length

Since: 2.32

### g_inet_address_mask_matches ()

    gboolean
    g_inet_address_mask_matches (GInetAddressMask *mask,
                                 GInetAddress *address);

Tests if `address` falls within the range described by `mask` .

#### Parameters

mask | a GInetAddressMask |
address | a GInetAddress |

#### Returns

whether `address` falls within the range described by `mask` .

Since: 2.32

### g_inet_address_mask_equal ()

    gboolean
    g_inet_address_mask_equal (GInetAddressMask *mask,
                               GInetAddressMask *mask2);

Tests if `mask` and `mask2` are the same mask.

#### Parameters

mask | a GInetAddressMask |
mask2 | another GInetAddressMask |

#### Returns

whether `mask` and `mask2` are the same mask

Since: 2.32

## Types and Values

### GInetAddressMask

    typedef struct _GInetAddressMask GInetAddressMask;

A combination of an IPv4 or IPv6 base address and a length, representing a range of IP addresses.

Since: 2.32

## Property Details

### The `“address”` property

      “address”                  GInetAddress *

The base address.

Flags: Read / Write

### The `“family”` property

      “family”                   GSocketFamily

The address family (IPv4 or IPv6).

Flags: Read

Default value: G_SOCKET_FAMILY_INVALID

### The `“length”` property

      “length”                   guint

The prefix length.

Flags: Read / Write

Allowed values: <= 128

Default value: 0