2014-07-24 08:53:33 -04:00
|
|
|
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
|
|
|
|
/*
|
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This library 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
|
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
|
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
|
* Boston, MA 02110-1301 USA.
|
|
|
|
|
*
|
|
|
|
|
* Copyright 2007 - 2011 Novell, Inc.
|
|
|
|
|
* Copyright 2008 Red Hat, Inc.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
|
|
#include <nm-setting-ip4-config.h>
|
|
|
|
|
#include "nm-ip4-config.h"
|
2014-07-05 16:23:30 -04:00
|
|
|
#include "nm-dbus-interface.h"
|
2014-07-24 08:53:33 -04:00
|
|
|
#include "nm-object-private.h"
|
|
|
|
|
#include "nm-utils.h"
|
2014-08-25 15:25:27 -04:00
|
|
|
#include "nm-core-internal.h"
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
G_DEFINE_TYPE (NMIP4Config, nm_ip4_config, NM_TYPE_OBJECT)
|
|
|
|
|
|
|
|
|
|
#define NM_IP4_CONFIG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_IP4_CONFIG, NMIP4ConfigPrivate))
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
char *gateway;
|
2014-09-10 13:51:53 -04:00
|
|
|
GPtrArray *addresses;
|
|
|
|
|
GPtrArray *routes;
|
2014-07-02 14:25:43 -04:00
|
|
|
char **nameservers;
|
2014-07-02 14:25:43 -04:00
|
|
|
char **domains;
|
|
|
|
|
char **searches;
|
2014-07-02 14:25:43 -04:00
|
|
|
char **wins;
|
libnm-core, libnm, core: add AddressData and RouteData properties
Add AddressData and RouteData properties to NMSettingIPConfig and
NMIP[46]Config. These are like the existing "addresses" and "routes"
properties, but using strings and containing additional attributes,
like NMIPAddress and NMIPRoute.
This only affects the D-Bus representations; there are no API changes
to NMSettingIP{,4,6}Config or NMIP{4,6}Config as a result of this; the
additional information is just added to the existing 'addresses' and
'routes' properties.
NMSettingIP4Config and NMSettingIP6Config now always generate both
old-style data ('addresses', 'address-labels', 'routes') and new-style
data ('address-data', 'gateway', 'route-data') when serializing to
D-Bus, for backward compatibility. When deserializing, they will fill
in the 'addresses' and 'routes' properties from the new-style data if
it is present (ignoring the old-style data), or from the old-style
data if the new-style isn't present.
The daemon-side NMIP4Config and NMIP6Config always emit changes for
both 'Addresses'/'Routes' and 'AddressData'/'RouteData'. The
libnm-side classes initially listen for changes on both properties,
but start ignoring the 'Addresses' and 'Routes' properties once they
know the daemon is also providing 'AddressData' and 'RouteData'.
2014-10-21 08:33:18 -04:00
|
|
|
|
|
|
|
|
gboolean new_style_data;
|
2014-07-24 08:53:33 -04:00
|
|
|
} NMIP4ConfigPrivate;
|
|
|
|
|
|
|
|
|
|
enum {
|
|
|
|
|
PROP_0,
|
|
|
|
|
PROP_GATEWAY,
|
|
|
|
|
PROP_ADDRESSES,
|
|
|
|
|
PROP_ROUTES,
|
|
|
|
|
PROP_NAMESERVERS,
|
|
|
|
|
PROP_DOMAINS,
|
|
|
|
|
PROP_SEARCHES,
|
|
|
|
|
PROP_WINS_SERVERS,
|
|
|
|
|
|
|
|
|
|
LAST_PROP
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
nm_ip4_config_init (NMIP4Config *config)
|
|
|
|
|
{
|
2014-07-02 14:25:43 -04:00
|
|
|
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
|
|
|
|
|
2014-09-10 13:51:53 -04:00
|
|
|
priv->addresses = g_ptr_array_new ();
|
|
|
|
|
priv->routes = g_ptr_array_new ();
|
2014-07-02 14:25:43 -04:00
|
|
|
priv->nameservers = g_new0 (char *, 1);
|
2014-07-02 14:25:43 -04:00
|
|
|
priv->domains = g_new0 (char *, 1);
|
|
|
|
|
priv->searches = g_new0 (char *, 1);
|
2014-07-02 14:25:43 -04:00
|
|
|
priv->wins = g_new0 (char *, 1);
|
2014-07-24 08:53:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
libnm-core, libnm, core: add AddressData and RouteData properties
Add AddressData and RouteData properties to NMSettingIPConfig and
NMIP[46]Config. These are like the existing "addresses" and "routes"
properties, but using strings and containing additional attributes,
like NMIPAddress and NMIPRoute.
This only affects the D-Bus representations; there are no API changes
to NMSettingIP{,4,6}Config or NMIP{4,6}Config as a result of this; the
additional information is just added to the existing 'addresses' and
'routes' properties.
NMSettingIP4Config and NMSettingIP6Config now always generate both
old-style data ('addresses', 'address-labels', 'routes') and new-style
data ('address-data', 'gateway', 'route-data') when serializing to
D-Bus, for backward compatibility. When deserializing, they will fill
in the 'addresses' and 'routes' properties from the new-style data if
it is present (ignoring the old-style data), or from the old-style
data if the new-style isn't present.
The daemon-side NMIP4Config and NMIP6Config always emit changes for
both 'Addresses'/'Routes' and 'AddressData'/'RouteData'. The
libnm-side classes initially listen for changes on both properties,
but start ignoring the 'Addresses' and 'Routes' properties once they
know the daemon is also providing 'AddressData' and 'RouteData'.
2014-10-21 08:33:18 -04:00
|
|
|
demarshal_ip4_addresses (NMObject *object, GParamSpec *pspec, GVariant *value, gpointer field)
|
2014-07-24 08:53:33 -04:00
|
|
|
{
|
|
|
|
|
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (object);
|
|
|
|
|
|
libnm-core, libnm, core: add AddressData and RouteData properties
Add AddressData and RouteData properties to NMSettingIPConfig and
NMIP[46]Config. These are like the existing "addresses" and "routes"
properties, but using strings and containing additional attributes,
like NMIPAddress and NMIPRoute.
This only affects the D-Bus representations; there are no API changes
to NMSettingIP{,4,6}Config or NMIP{4,6}Config as a result of this; the
additional information is just added to the existing 'addresses' and
'routes' properties.
NMSettingIP4Config and NMSettingIP6Config now always generate both
old-style data ('addresses', 'address-labels', 'routes') and new-style
data ('address-data', 'gateway', 'route-data') when serializing to
D-Bus, for backward compatibility. When deserializing, they will fill
in the 'addresses' and 'routes' properties from the new-style data if
it is present (ignoring the old-style data), or from the old-style
data if the new-style isn't present.
The daemon-side NMIP4Config and NMIP6Config always emit changes for
both 'Addresses'/'Routes' and 'AddressData'/'RouteData'. The
libnm-side classes initially listen for changes on both properties,
but start ignoring the 'Addresses' and 'Routes' properties once they
know the daemon is also providing 'AddressData' and 'RouteData'.
2014-10-21 08:33:18 -04:00
|
|
|
if (priv->new_style_data)
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
2014-09-10 13:51:53 -04:00
|
|
|
g_ptr_array_unref (priv->addresses);
|
2014-10-20 21:30:56 -04:00
|
|
|
priv->addresses = nm_utils_ip4_addresses_from_variant (value, NULL);
|
2014-07-24 08:53:33 -04:00
|
|
|
_nm_object_queue_notify (object, NM_IP4_CONFIG_ADDRESSES);
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
libnm-core, libnm, core: add AddressData and RouteData properties
Add AddressData and RouteData properties to NMSettingIPConfig and
NMIP[46]Config. These are like the existing "addresses" and "routes"
properties, but using strings and containing additional attributes,
like NMIPAddress and NMIPRoute.
This only affects the D-Bus representations; there are no API changes
to NMSettingIP{,4,6}Config or NMIP{4,6}Config as a result of this; the
additional information is just added to the existing 'addresses' and
'routes' properties.
NMSettingIP4Config and NMSettingIP6Config now always generate both
old-style data ('addresses', 'address-labels', 'routes') and new-style
data ('address-data', 'gateway', 'route-data') when serializing to
D-Bus, for backward compatibility. When deserializing, they will fill
in the 'addresses' and 'routes' properties from the new-style data if
it is present (ignoring the old-style data), or from the old-style
data if the new-style isn't present.
The daemon-side NMIP4Config and NMIP6Config always emit changes for
both 'Addresses'/'Routes' and 'AddressData'/'RouteData'. The
libnm-side classes initially listen for changes on both properties,
but start ignoring the 'Addresses' and 'Routes' properties once they
know the daemon is also providing 'AddressData' and 'RouteData'.
2014-10-21 08:33:18 -04:00
|
|
|
static gboolean
|
|
|
|
|
demarshal_ip4_address_data (NMObject *object, GParamSpec *pspec, GVariant *value, gpointer field)
|
|
|
|
|
{
|
|
|
|
|
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (object);
|
|
|
|
|
|
|
|
|
|
priv->new_style_data = TRUE;
|
|
|
|
|
|
|
|
|
|
g_ptr_array_unref (priv->addresses);
|
|
|
|
|
priv->addresses = nm_utils_ip_addresses_from_variant (value, AF_INET);
|
|
|
|
|
_nm_object_queue_notify (object, NM_IP4_CONFIG_ADDRESSES);
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-24 08:53:33 -04:00
|
|
|
static gboolean
|
2014-09-10 13:51:53 -04:00
|
|
|
demarshal_ip4_array (NMObject *object, GParamSpec *pspec, GVariant *value, gpointer field)
|
2014-07-24 08:53:33 -04:00
|
|
|
{
|
2014-07-02 14:25:43 -04:00
|
|
|
char ***obj_field;
|
|
|
|
|
|
|
|
|
|
obj_field = field;
|
|
|
|
|
if (*obj_field)
|
|
|
|
|
g_strfreev (*obj_field);
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2014-09-10 13:51:53 -04:00
|
|
|
*obj_field = nm_utils_ip4_dns_from_variant (value);
|
2014-07-02 14:25:43 -04:00
|
|
|
|
|
|
|
|
_nm_object_queue_notify (object, pspec->name);
|
2014-07-24 08:53:33 -04:00
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
libnm-core, libnm, core: add AddressData and RouteData properties
Add AddressData and RouteData properties to NMSettingIPConfig and
NMIP[46]Config. These are like the existing "addresses" and "routes"
properties, but using strings and containing additional attributes,
like NMIPAddress and NMIPRoute.
This only affects the D-Bus representations; there are no API changes
to NMSettingIP{,4,6}Config or NMIP{4,6}Config as a result of this; the
additional information is just added to the existing 'addresses' and
'routes' properties.
NMSettingIP4Config and NMSettingIP6Config now always generate both
old-style data ('addresses', 'address-labels', 'routes') and new-style
data ('address-data', 'gateway', 'route-data') when serializing to
D-Bus, for backward compatibility. When deserializing, they will fill
in the 'addresses' and 'routes' properties from the new-style data if
it is present (ignoring the old-style data), or from the old-style
data if the new-style isn't present.
The daemon-side NMIP4Config and NMIP6Config always emit changes for
both 'Addresses'/'Routes' and 'AddressData'/'RouteData'. The
libnm-side classes initially listen for changes on both properties,
but start ignoring the 'Addresses' and 'Routes' properties once they
know the daemon is also providing 'AddressData' and 'RouteData'.
2014-10-21 08:33:18 -04:00
|
|
|
demarshal_ip4_routes (NMObject *object, GParamSpec *pspec, GVariant *value, gpointer field)
|
2014-07-24 08:53:33 -04:00
|
|
|
{
|
|
|
|
|
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (object);
|
|
|
|
|
|
libnm-core, libnm, core: add AddressData and RouteData properties
Add AddressData and RouteData properties to NMSettingIPConfig and
NMIP[46]Config. These are like the existing "addresses" and "routes"
properties, but using strings and containing additional attributes,
like NMIPAddress and NMIPRoute.
This only affects the D-Bus representations; there are no API changes
to NMSettingIP{,4,6}Config or NMIP{4,6}Config as a result of this; the
additional information is just added to the existing 'addresses' and
'routes' properties.
NMSettingIP4Config and NMSettingIP6Config now always generate both
old-style data ('addresses', 'address-labels', 'routes') and new-style
data ('address-data', 'gateway', 'route-data') when serializing to
D-Bus, for backward compatibility. When deserializing, they will fill
in the 'addresses' and 'routes' properties from the new-style data if
it is present (ignoring the old-style data), or from the old-style
data if the new-style isn't present.
The daemon-side NMIP4Config and NMIP6Config always emit changes for
both 'Addresses'/'Routes' and 'AddressData'/'RouteData'. The
libnm-side classes initially listen for changes on both properties,
but start ignoring the 'Addresses' and 'Routes' properties once they
know the daemon is also providing 'AddressData' and 'RouteData'.
2014-10-21 08:33:18 -04:00
|
|
|
if (priv->new_style_data)
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
2014-09-10 13:51:53 -04:00
|
|
|
g_ptr_array_unref (priv->routes);
|
|
|
|
|
priv->routes = nm_utils_ip4_routes_from_variant (value);
|
2014-07-24 08:53:33 -04:00
|
|
|
_nm_object_queue_notify (object, NM_IP4_CONFIG_ROUTES);
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
libnm-core, libnm, core: add AddressData and RouteData properties
Add AddressData and RouteData properties to NMSettingIPConfig and
NMIP[46]Config. These are like the existing "addresses" and "routes"
properties, but using strings and containing additional attributes,
like NMIPAddress and NMIPRoute.
This only affects the D-Bus representations; there are no API changes
to NMSettingIP{,4,6}Config or NMIP{4,6}Config as a result of this; the
additional information is just added to the existing 'addresses' and
'routes' properties.
NMSettingIP4Config and NMSettingIP6Config now always generate both
old-style data ('addresses', 'address-labels', 'routes') and new-style
data ('address-data', 'gateway', 'route-data') when serializing to
D-Bus, for backward compatibility. When deserializing, they will fill
in the 'addresses' and 'routes' properties from the new-style data if
it is present (ignoring the old-style data), or from the old-style
data if the new-style isn't present.
The daemon-side NMIP4Config and NMIP6Config always emit changes for
both 'Addresses'/'Routes' and 'AddressData'/'RouteData'. The
libnm-side classes initially listen for changes on both properties,
but start ignoring the 'Addresses' and 'Routes' properties once they
know the daemon is also providing 'AddressData' and 'RouteData'.
2014-10-21 08:33:18 -04:00
|
|
|
static gboolean
|
|
|
|
|
demarshal_ip4_route_data (NMObject *object, GParamSpec *pspec, GVariant *value, gpointer field)
|
|
|
|
|
{
|
|
|
|
|
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (object);
|
|
|
|
|
|
|
|
|
|
priv->new_style_data = TRUE;
|
|
|
|
|
|
|
|
|
|
g_ptr_array_unref (priv->routes);
|
|
|
|
|
priv->routes = nm_utils_ip_routes_from_variant (value, AF_INET);
|
|
|
|
|
_nm_object_queue_notify (object, NM_IP4_CONFIG_ROUTES);
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-24 08:53:33 -04:00
|
|
|
static void
|
2014-05-15 14:24:56 -04:00
|
|
|
init_dbus (NMObject *object)
|
2014-07-24 08:53:33 -04:00
|
|
|
{
|
2014-05-15 14:24:56 -04:00
|
|
|
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (object);
|
2014-07-24 08:53:33 -04:00
|
|
|
const NMPropertiesInfo property_info[] = {
|
|
|
|
|
{ NM_IP4_CONFIG_GATEWAY, &priv->gateway, },
|
libnm-core, libnm, core: add AddressData and RouteData properties
Add AddressData and RouteData properties to NMSettingIPConfig and
NMIP[46]Config. These are like the existing "addresses" and "routes"
properties, but using strings and containing additional attributes,
like NMIPAddress and NMIPRoute.
This only affects the D-Bus representations; there are no API changes
to NMSettingIP{,4,6}Config or NMIP{4,6}Config as a result of this; the
additional information is just added to the existing 'addresses' and
'routes' properties.
NMSettingIP4Config and NMSettingIP6Config now always generate both
old-style data ('addresses', 'address-labels', 'routes') and new-style
data ('address-data', 'gateway', 'route-data') when serializing to
D-Bus, for backward compatibility. When deserializing, they will fill
in the 'addresses' and 'routes' properties from the new-style data if
it is present (ignoring the old-style data), or from the old-style
data if the new-style isn't present.
The daemon-side NMIP4Config and NMIP6Config always emit changes for
both 'Addresses'/'Routes' and 'AddressData'/'RouteData'. The
libnm-side classes initially listen for changes on both properties,
but start ignoring the 'Addresses' and 'Routes' properties once they
know the daemon is also providing 'AddressData' and 'RouteData'.
2014-10-21 08:33:18 -04:00
|
|
|
{ NM_IP4_CONFIG_ADDRESSES, &priv->addresses, demarshal_ip4_addresses },
|
|
|
|
|
{ "address-data", &priv->addresses, demarshal_ip4_address_data },
|
|
|
|
|
{ NM_IP4_CONFIG_ROUTES, &priv->routes, demarshal_ip4_routes },
|
|
|
|
|
{ "route-data", &priv->routes, demarshal_ip4_route_data },
|
2014-07-24 08:53:33 -04:00
|
|
|
{ NM_IP4_CONFIG_NAMESERVERS, &priv->nameservers, demarshal_ip4_array },
|
2014-07-02 14:25:43 -04:00
|
|
|
{ NM_IP4_CONFIG_DOMAINS, &priv->domains, },
|
|
|
|
|
{ NM_IP4_CONFIG_SEARCHES, &priv->searches, },
|
2014-07-24 08:53:33 -04:00
|
|
|
{ NM_IP4_CONFIG_WINS_SERVERS, &priv->wins, demarshal_ip4_array },
|
|
|
|
|
{ NULL },
|
|
|
|
|
};
|
|
|
|
|
|
2014-05-15 14:24:56 -04:00
|
|
|
NM_OBJECT_CLASS (nm_ip4_config_parent_class)->init_dbus (object);
|
|
|
|
|
|
|
|
|
|
_nm_object_register_properties (object,
|
2014-08-18 14:17:52 -04:00
|
|
|
NM_DBUS_INTERFACE_IP4_CONFIG,
|
2014-07-24 08:53:33 -04:00
|
|
|
property_info);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
finalize (GObject *object)
|
|
|
|
|
{
|
|
|
|
|
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (object);
|
|
|
|
|
|
|
|
|
|
g_free (priv->gateway);
|
|
|
|
|
|
2014-09-10 13:51:53 -04:00
|
|
|
g_ptr_array_unref (priv->addresses);
|
|
|
|
|
g_ptr_array_unref (priv->routes);
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2014-07-02 14:25:43 -04:00
|
|
|
g_strfreev (priv->nameservers);
|
2014-07-02 14:25:43 -04:00
|
|
|
g_strfreev (priv->domains);
|
|
|
|
|
g_strfreev (priv->searches);
|
2014-07-02 14:25:43 -04:00
|
|
|
g_strfreev (priv->wins);
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (nm_ip4_config_parent_class)->finalize (object);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
get_property (GObject *object,
|
|
|
|
|
guint prop_id,
|
|
|
|
|
GValue *value,
|
|
|
|
|
GParamSpec *pspec)
|
|
|
|
|
{
|
|
|
|
|
NMIP4Config *self = NM_IP4_CONFIG (object);
|
|
|
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
|
case PROP_GATEWAY:
|
|
|
|
|
g_value_set_string (value, nm_ip4_config_get_gateway (self));
|
|
|
|
|
break;
|
|
|
|
|
case PROP_ADDRESSES:
|
2014-09-10 13:51:53 -04:00
|
|
|
g_value_take_boxed (value, _nm_utils_copy_array (nm_ip4_config_get_addresses (self),
|
2014-09-16 16:42:46 -04:00
|
|
|
(NMUtilsCopyFunc) nm_ip_address_dup,
|
|
|
|
|
(GDestroyNotify) nm_ip_address_unref));
|
2014-07-24 08:53:33 -04:00
|
|
|
break;
|
|
|
|
|
case PROP_ROUTES:
|
2014-09-10 13:51:53 -04:00
|
|
|
g_value_take_boxed (value, _nm_utils_copy_array (nm_ip4_config_get_routes (self),
|
2014-09-16 16:42:46 -04:00
|
|
|
(NMUtilsCopyFunc) nm_ip_route_dup,
|
|
|
|
|
(GDestroyNotify) nm_ip_route_unref));
|
2014-07-24 08:53:33 -04:00
|
|
|
break;
|
|
|
|
|
case PROP_NAMESERVERS:
|
2014-07-02 14:25:43 -04:00
|
|
|
g_value_set_boxed (value, (char **) nm_ip4_config_get_nameservers (self));
|
2014-07-24 08:53:33 -04:00
|
|
|
break;
|
|
|
|
|
case PROP_DOMAINS:
|
2014-07-02 14:25:43 -04:00
|
|
|
g_value_set_boxed (value, (char **) nm_ip4_config_get_domains (self));
|
2014-07-24 08:53:33 -04:00
|
|
|
break;
|
|
|
|
|
case PROP_SEARCHES:
|
2014-07-02 14:25:43 -04:00
|
|
|
g_value_set_boxed (value, (char **) nm_ip4_config_get_searches (self));
|
2014-07-24 08:53:33 -04:00
|
|
|
break;
|
|
|
|
|
case PROP_WINS_SERVERS:
|
2014-07-02 14:25:43 -04:00
|
|
|
g_value_set_boxed (value, (char **) nm_ip4_config_get_wins_servers (self));
|
2014-07-24 08:53:33 -04:00
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
nm_ip4_config_class_init (NMIP4ConfigClass *config_class)
|
|
|
|
|
{
|
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (config_class);
|
2014-05-15 14:24:56 -04:00
|
|
|
NMObjectClass *nm_object_class = NM_OBJECT_CLASS (config_class);
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
g_type_class_add_private (config_class, sizeof (NMIP4ConfigPrivate));
|
|
|
|
|
|
2014-08-18 14:17:52 -04:00
|
|
|
_nm_object_class_add_interface (nm_object_class, NM_DBUS_INTERFACE_IP4_CONFIG);
|
|
|
|
|
|
2014-07-24 08:53:33 -04:00
|
|
|
/* virtual methods */
|
|
|
|
|
object_class->get_property = get_property;
|
|
|
|
|
object_class->finalize = finalize;
|
|
|
|
|
|
2014-05-15 14:24:56 -04:00
|
|
|
nm_object_class->init_dbus = init_dbus;
|
|
|
|
|
|
2014-07-24 08:53:33 -04:00
|
|
|
/* properties */
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* NMIP4Config:gateway:
|
|
|
|
|
*
|
|
|
|
|
* The IP4 gateway address of the configuration as string.
|
|
|
|
|
**/
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_GATEWAY,
|
|
|
|
|
g_param_spec_string (NM_IP4_CONFIG_GATEWAY, "", "",
|
|
|
|
|
NULL,
|
|
|
|
|
G_PARAM_READABLE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* NMIP4Config:addresses:
|
|
|
|
|
*
|
2014-09-16 16:42:46 -04:00
|
|
|
* A #GPtrArray containing the addresses (#NMIPAddress) of the configuration.
|
2014-07-24 08:53:33 -04:00
|
|
|
**/
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_ADDRESSES,
|
2014-08-25 15:25:27 -04:00
|
|
|
g_param_spec_boxed (NM_IP4_CONFIG_ADDRESSES, "", "",
|
|
|
|
|
G_TYPE_PTR_ARRAY,
|
|
|
|
|
G_PARAM_READABLE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* NMIP4Config:routes:
|
|
|
|
|
*
|
2014-09-16 16:42:46 -04:00
|
|
|
* A #GPtrArray containing the routes (#NMIPRoute) of the configuration.
|
2014-07-24 08:53:33 -04:00
|
|
|
**/
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_ROUTES,
|
2014-08-25 15:25:27 -04:00
|
|
|
g_param_spec_boxed (NM_IP4_CONFIG_ROUTES, "", "",
|
|
|
|
|
G_TYPE_PTR_ARRAY,
|
|
|
|
|
G_PARAM_READABLE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* NMIP4Config:nameservers:
|
|
|
|
|
*
|
2014-07-02 14:25:43 -04:00
|
|
|
* The array containing name server IP addresses of the configuration.
|
2014-07-24 08:53:33 -04:00
|
|
|
**/
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_NAMESERVERS,
|
|
|
|
|
g_param_spec_boxed (NM_IP4_CONFIG_NAMESERVERS, "", "",
|
2014-07-02 14:25:43 -04:00
|
|
|
G_TYPE_STRV,
|
2014-07-24 08:53:33 -04:00
|
|
|
G_PARAM_READABLE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* NMIP4Config:domains:
|
|
|
|
|
*
|
2014-07-02 14:25:43 -04:00
|
|
|
* The array containing domain strings of the configuration.
|
2014-07-24 08:53:33 -04:00
|
|
|
**/
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_DOMAINS,
|
|
|
|
|
g_param_spec_boxed (NM_IP4_CONFIG_DOMAINS, "", "",
|
2014-07-02 14:25:43 -04:00
|
|
|
G_TYPE_STRV,
|
2014-07-24 08:53:33 -04:00
|
|
|
G_PARAM_READABLE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* NMIP4Config:searches:
|
|
|
|
|
*
|
2014-07-02 14:25:43 -04:00
|
|
|
* The array containing DNS search strings of the configuration.
|
2014-07-24 08:53:33 -04:00
|
|
|
**/
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_SEARCHES,
|
|
|
|
|
g_param_spec_boxed (NM_IP4_CONFIG_SEARCHES, "", "",
|
2014-07-02 14:25:43 -04:00
|
|
|
G_TYPE_STRV,
|
2014-07-24 08:53:33 -04:00
|
|
|
G_PARAM_READABLE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* NMIP4Config:wins-servers:
|
|
|
|
|
*
|
2014-07-02 14:25:43 -04:00
|
|
|
* The array containing WINS server IP addresses of the configuration.
|
2014-07-24 08:53:33 -04:00
|
|
|
**/
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_WINS_SERVERS,
|
|
|
|
|
g_param_spec_boxed (NM_IP4_CONFIG_WINS_SERVERS, "", "",
|
2014-07-02 14:25:43 -04:00
|
|
|
G_TYPE_STRV,
|
2014-07-24 08:53:33 -04:00
|
|
|
G_PARAM_READABLE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_ip4_config_get_gateway:
|
|
|
|
|
* @config: a #NMIP4Config
|
|
|
|
|
*
|
|
|
|
|
* Gets the IP4 gateway address.
|
|
|
|
|
*
|
2014-09-05 13:46:00 +02:00
|
|
|
* Returns: (transfer none): the IP4 address of the gateway.
|
2014-07-24 08:53:33 -04:00
|
|
|
**/
|
|
|
|
|
const char *
|
|
|
|
|
nm_ip4_config_get_gateway (NMIP4Config *config)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_IP4_CONFIG (config), NULL);
|
|
|
|
|
|
|
|
|
|
return NM_IP4_CONFIG_GET_PRIVATE (config)->gateway;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_ip4_config_get_addresses:
|
|
|
|
|
* @config: a #NMIP4Config
|
|
|
|
|
*
|
|
|
|
|
* Gets the IP4 addresses (containing the address, prefix, and gateway).
|
|
|
|
|
*
|
2014-09-16 16:42:46 -04:00
|
|
|
* Returns: (element-type NMIPAddress) (transfer none): the #GPtrArray
|
|
|
|
|
* containing #NMIPAddress<!-- -->es. This is the internal copy used by the
|
2014-09-10 13:51:53 -04:00
|
|
|
* configuration and must not be modified.
|
2014-07-24 08:53:33 -04:00
|
|
|
**/
|
2014-09-10 13:51:53 -04:00
|
|
|
GPtrArray *
|
2014-07-24 08:53:33 -04:00
|
|
|
nm_ip4_config_get_addresses (NMIP4Config *config)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_IP4_CONFIG (config), NULL);
|
|
|
|
|
|
|
|
|
|
return NM_IP4_CONFIG_GET_PRIVATE (config)->addresses;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_ip4_config_get_nameservers:
|
|
|
|
|
* @config: a #NMIP4Config
|
|
|
|
|
*
|
|
|
|
|
* Gets the domain name servers (DNS).
|
|
|
|
|
*
|
2014-09-05 13:46:00 +02:00
|
|
|
* Returns: (transfer none): the array of nameserver IP addresses
|
2014-07-24 08:53:33 -04:00
|
|
|
**/
|
2014-07-02 14:25:43 -04:00
|
|
|
const char * const *
|
2014-07-24 08:53:33 -04:00
|
|
|
nm_ip4_config_get_nameservers (NMIP4Config *config)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_IP4_CONFIG (config), NULL);
|
|
|
|
|
|
2014-07-02 14:25:43 -04:00
|
|
|
return (const char * const *) NM_IP4_CONFIG_GET_PRIVATE (config)->nameservers;
|
2014-07-24 08:53:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_ip4_config_get_domains:
|
|
|
|
|
* @config: a #NMIP4Config
|
|
|
|
|
*
|
|
|
|
|
* Gets the domain names.
|
|
|
|
|
*
|
2014-09-05 13:46:00 +02:00
|
|
|
* Returns: (transfer none): the array of domains.
|
|
|
|
|
* (This is never %NULL, though it may be 0-length).
|
2014-07-24 08:53:33 -04:00
|
|
|
**/
|
2014-07-02 14:25:43 -04:00
|
|
|
const char * const *
|
2014-07-24 08:53:33 -04:00
|
|
|
nm_ip4_config_get_domains (NMIP4Config *config)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_IP4_CONFIG (config), NULL);
|
|
|
|
|
|
2014-07-02 14:25:43 -04:00
|
|
|
return (const char * const *) NM_IP4_CONFIG_GET_PRIVATE (config)->domains;
|
2014-07-24 08:53:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_ip4_config_get_searches:
|
|
|
|
|
* @config: a #NMIP4Config
|
|
|
|
|
*
|
2014-07-02 14:25:43 -04:00
|
|
|
* Gets the DNS searches.
|
2014-07-24 08:53:33 -04:00
|
|
|
*
|
2014-09-05 13:46:00 +02:00
|
|
|
* Returns: (transfer none): the array of DNS search strings.
|
|
|
|
|
* (This is never %NULL, though it may be 0-length).
|
2014-07-24 08:53:33 -04:00
|
|
|
**/
|
2014-07-02 14:25:43 -04:00
|
|
|
const char * const *
|
2014-07-24 08:53:33 -04:00
|
|
|
nm_ip4_config_get_searches (NMIP4Config *config)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_IP4_CONFIG (config), NULL);
|
|
|
|
|
|
2014-07-02 14:25:43 -04:00
|
|
|
return (const char * const *) NM_IP4_CONFIG_GET_PRIVATE (config)->searches;
|
2014-07-24 08:53:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_ip4_config_get_wins_servers:
|
|
|
|
|
* @config: a #NMIP4Config
|
|
|
|
|
*
|
|
|
|
|
* Gets the Windows Internet Name Service servers (WINS).
|
|
|
|
|
*
|
2014-09-05 13:46:00 +02:00
|
|
|
* Returns: (element-type guint32) (transfer none): the #GArray containing #guint32s.
|
2014-07-24 08:53:33 -04:00
|
|
|
* This is the internal copy used by the configuration and must not be
|
|
|
|
|
* modified.
|
|
|
|
|
**/
|
2014-07-02 14:25:43 -04:00
|
|
|
const char * const *
|
2014-07-24 08:53:33 -04:00
|
|
|
nm_ip4_config_get_wins_servers (NMIP4Config *config)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_IP4_CONFIG (config), NULL);
|
|
|
|
|
|
2014-07-02 14:25:43 -04:00
|
|
|
return (const char * const *) NM_IP4_CONFIG_GET_PRIVATE (config)->wins;
|
2014-07-24 08:53:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_ip4_config_get_routes:
|
|
|
|
|
* @config: a #NMIP4Config
|
|
|
|
|
*
|
|
|
|
|
* Gets the routes.
|
|
|
|
|
*
|
2014-09-16 16:42:46 -04:00
|
|
|
* Returns: (element-type NMIPRoute) (transfer none): the #GPtrArray containing
|
|
|
|
|
* #NMIPRoutes. This is the internal copy used by the configuration, and must
|
2014-09-10 13:51:53 -04:00
|
|
|
* not be modified.
|
2014-07-24 08:53:33 -04:00
|
|
|
**/
|
2014-09-10 13:51:53 -04:00
|
|
|
GPtrArray *
|
2014-07-24 08:53:33 -04:00
|
|
|
nm_ip4_config_get_routes (NMIP4Config *config)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_IP4_CONFIG (config), NULL);
|
|
|
|
|
|
|
|
|
|
return NM_IP4_CONFIG_GET_PRIVATE (config)->routes;
|
|
|
|
|
}
|