1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301 USA.
19 * Copyright 2011 - 2013 Red Hat, Inc.
20 * Copyright 2009 Novell, Inc.
23 #include "nm-default.h"
26 #include <net/ethernet.h>
28 #include "nm-setting-wimax.h"
29 #include "nm-setting-private.h"
31 #include "nm-utils-private.h"
34 * SECTION:nm-setting-wimax
35 * @short_description: Describes 802.16e Mobile WiMAX connection properties
37 * The #NMSettingWimax object is a #NMSetting subclass that describes properties
38 * necessary for connection to 802.16e Mobile WiMAX networks.
40 * NetworkManager no longer supports WiMAX; while this API remains available for
41 * backward-compatibility reasons, it serves no real purpose, since WiMAX
42 * connections cannot be activated.
45 G_DEFINE_TYPE_WITH_CODE (NMSettingWimax, nm_setting_wimax, NM_TYPE_SETTING,
46 _nm_register_setting (WIMAX, 1))
47 NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_WIMAX)
49 #define NM_SETTING_WIMAX_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_WIMAX, NMSettingWimaxPrivate))
54 } NMSettingWimaxPrivate;
65 * nm_setting_wimax_new:
67 * Creates a new #NMSettingWimax object with default values.
69 * Returns: the new empty #NMSettingWimax object
71 * Deprecated: 1.2: WiMAX is no longer supported.
74 nm_setting_wimax_new (void)
76 return (NMSetting *) g_object_new (NM_TYPE_SETTING_WIMAX, NULL);
80 * nm_setting_wimax_get_network_name:
81 * @setting: the #NMSettingWimax
83 * Returns the WiMAX NSP name (ex "Sprint" or "CLEAR") which identifies the
84 * specific WiMAX network this setting describes a connection to.
86 * Returns: the WiMAX NSP name
88 * Deprecated: 1.2: WiMAX is no longer supported.
91 nm_setting_wimax_get_network_name (NMSettingWimax *setting)
93 g_return_val_if_fail (NM_IS_SETTING_WIMAX (setting), NULL);
95 return NM_SETTING_WIMAX_GET_PRIVATE (setting)->network_name;
99 * nm_setting_wimax_get_mac_address:
100 * @setting: the #NMSettingWimax
102 * Returns the MAC address of a WiMAX device which this connection is locked
105 * Returns: the MAC address
107 * Deprecated: 1.2: WiMAX is no longer supported.
110 nm_setting_wimax_get_mac_address (NMSettingWimax *setting)
112 g_return_val_if_fail (NM_IS_SETTING_WIMAX (setting), NULL);
114 return NM_SETTING_WIMAX_GET_PRIVATE (setting)->mac_address;
118 verify (NMSetting *setting, NMConnection *connection, GError **error)
120 NMSettingWimaxPrivate *priv = NM_SETTING_WIMAX_GET_PRIVATE (setting);
122 if (!priv->network_name) {
123 g_set_error_literal (error,
125 NM_CONNECTION_ERROR_MISSING_PROPERTY,
126 _("property is missing"));
127 g_prefix_error (error, "%s.%s: ", NM_SETTING_WIMAX_SETTING_NAME, NM_SETTING_WIMAX_NETWORK_NAME);
131 if (!strlen (priv->network_name)) {
132 g_set_error_literal (error,
134 NM_CONNECTION_ERROR_INVALID_PROPERTY,
135 _("property is empty"));
136 g_prefix_error (error, "%s.%s: ", NM_SETTING_WIMAX_SETTING_NAME, NM_SETTING_WIMAX_NETWORK_NAME);
140 if (priv->mac_address && !nm_utils_hwaddr_valid (priv->mac_address, ETH_ALEN)) {
141 g_set_error_literal (error,
143 NM_CONNECTION_ERROR_INVALID_PROPERTY,
144 _("property is invalid"));
145 g_prefix_error (error, "%s.%s: ", NM_SETTING_WIMAX_SETTING_NAME, NM_SETTING_WIMAX_MAC_ADDRESS);
153 nm_setting_wimax_init (NMSettingWimax *setting)
158 finalize (GObject *object)
160 NMSettingWimaxPrivate *priv = NM_SETTING_WIMAX_GET_PRIVATE (object);
162 g_free (priv->network_name);
163 g_free (priv->mac_address);
165 G_OBJECT_CLASS (nm_setting_wimax_parent_class)->finalize (object);
169 set_property (GObject *object, guint prop_id,
170 const GValue *value, GParamSpec *pspec)
172 NMSettingWimaxPrivate *priv = NM_SETTING_WIMAX_GET_PRIVATE (object);
175 case PROP_NETWORK_NAME:
176 g_free (priv->network_name);
177 priv->network_name = g_value_dup_string (value);
179 case PROP_MAC_ADDRESS:
180 g_free (priv->mac_address);
181 priv->mac_address = _nm_utils_hwaddr_canonical_or_invalid (g_value_get_string (value),
185 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
191 get_property (GObject *object, guint prop_id,
192 GValue *value, GParamSpec *pspec)
194 NMSettingWimax *setting = NM_SETTING_WIMAX (object);
197 case PROP_NETWORK_NAME:
198 g_value_set_string (value, nm_setting_wimax_get_network_name (setting));
200 case PROP_MAC_ADDRESS:
201 g_value_set_string (value, nm_setting_wimax_get_mac_address (setting));
204 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
210 nm_setting_wimax_class_init (NMSettingWimaxClass *setting_class)
212 GObjectClass *object_class = G_OBJECT_CLASS (setting_class);
213 NMSettingClass *parent_class = NM_SETTING_CLASS (setting_class);
215 g_type_class_add_private (setting_class, sizeof (NMSettingWimaxPrivate));
217 /* virtual methods */
218 object_class->set_property = set_property;
219 object_class->get_property = get_property;
220 object_class->finalize = finalize;
221 parent_class->verify = verify;
225 * NMSettingWimax:network-name:
227 * Network Service Provider (NSP) name of the WiMAX network this connection
230 * Deprecated: 1.2: WiMAX is no longer supported.
232 g_object_class_install_property
233 (object_class, PROP_NETWORK_NAME,
234 g_param_spec_string (NM_SETTING_WIMAX_NETWORK_NAME, "", "",
237 G_PARAM_STATIC_STRINGS));
240 * NMSettingWimax:mac-address:
242 * If specified, this connection will only apply to the WiMAX device whose
243 * MAC address matches. This property does not change the MAC address of the
244 * device (known as MAC spoofing).
246 * Deprecated: 1.2: WiMAX is no longer supported.
248 g_object_class_install_property
249 (object_class, PROP_MAC_ADDRESS,
250 g_param_spec_string (NM_SETTING_WIMAX_MAC_ADDRESS, "", "",
253 G_PARAM_STATIC_STRINGS));
254 _nm_setting_class_transform_property (parent_class, NM_SETTING_WIMAX_MAC_ADDRESS,
255 G_VARIANT_TYPE_BYTESTRING,
256 _nm_utils_hwaddr_to_dbus,
257 _nm_utils_hwaddr_from_dbus);