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>
27 #include <dbus/dbus-glib.h>
29 #include "nm-setting-wimax.h"
30 #include "nm-param-spec-specialized.h"
31 #include "nm-setting-private.h"
34 * SECTION:nm-setting-wimax
35 * @short_description: Describes 802.16e Mobile WiMAX connection properties
36 * @include: nm-setting-wimax.h
38 * The #NMSettingWimax object is a #NMSetting subclass that describes properties
39 * necessary for connection to 802.16e Mobile WiMAX networks.
41 * NetworkManager no longer supports WiMAX; while this API remains available for
42 * backward-compatibility reasons, it serves no real purpose, since WiMAX
43 * connections cannot be activated.
47 * nm_setting_wimax_error_quark:
49 * Registers an error quark for #NMSettingWimax if necessary.
51 * Returns: the error quark used for #NMSettingWimax errors.
53 * Deprecated: 1.2: WiMAX is no longer supported.
56 nm_setting_wimax_error_quark (void)
60 if (G_UNLIKELY (!quark))
61 quark = g_quark_from_static_string ("nm-setting-wimax-error-quark");
66 G_DEFINE_TYPE_WITH_CODE (NMSettingWimax, nm_setting_wimax, NM_TYPE_SETTING,
67 _nm_register_setting (NM_SETTING_WIMAX_SETTING_NAME,
70 NM_SETTING_WIMAX_ERROR))
71 NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_WIMAX)
73 #define NM_SETTING_WIMAX_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_WIMAX, NMSettingWimaxPrivate))
77 GByteArray *mac_address;
78 } NMSettingWimaxPrivate;
89 * nm_setting_wimax_new:
91 * Creates a new #NMSettingWimax object with default values.
93 * Returns: the new empty #NMSettingWimax object
95 * Deprecated: 1.2: WiMAX is no longer supported.
98 nm_setting_wimax_new (void)
100 return (NMSetting *) g_object_new (NM_TYPE_SETTING_WIMAX, NULL);
104 * nm_setting_wimax_get_network_name:
105 * @setting: the #NMSettingWimax
107 * Returns the WiMAX NSP name (ex "Sprint" or "CLEAR") which identifies the
108 * specific WiMAX network this setting describes a connection to.
110 * Returns: the WiMAX NSP name
112 * Deprecated: 1.2: WiMAX is no longer supported.
115 nm_setting_wimax_get_network_name (NMSettingWimax *setting)
117 g_return_val_if_fail (NM_IS_SETTING_WIMAX (setting), NULL);
119 return NM_SETTING_WIMAX_GET_PRIVATE (setting)->network_name;
123 * nm_setting_wimax_get_mac_address:
124 * @setting: the #NMSettingWimax
126 * Returns the MAC address of a WiMAX device which this connection is locked
129 * Returns: the MAC address
131 * Deprecated: 1.2: WiMAX is no longer supported.
134 nm_setting_wimax_get_mac_address (NMSettingWimax *setting)
136 g_return_val_if_fail (NM_IS_SETTING_WIMAX (setting), NULL);
138 return NM_SETTING_WIMAX_GET_PRIVATE (setting)->mac_address;
142 verify (NMSetting *setting, GSList *all_settings, GError **error)
144 NMSettingWimaxPrivate *priv = NM_SETTING_WIMAX_GET_PRIVATE (setting);
146 if (!priv->network_name) {
147 g_set_error_literal (error,
148 NM_SETTING_WIMAX_ERROR,
149 NM_SETTING_WIMAX_ERROR_MISSING_PROPERTY,
150 _("property is missing"));
151 g_prefix_error (error, "%s.%s: ", NM_SETTING_WIMAX_SETTING_NAME, NM_SETTING_WIMAX_NETWORK_NAME);
155 if (!strlen (priv->network_name)) {
156 g_set_error_literal (error,
157 NM_SETTING_WIMAX_ERROR,
158 NM_SETTING_WIMAX_ERROR_INVALID_PROPERTY,
159 _("property is empty"));
160 g_prefix_error (error, "%s.%s: ", NM_SETTING_WIMAX_SETTING_NAME, NM_SETTING_WIMAX_NETWORK_NAME);
164 if (priv->mac_address && priv->mac_address->len != ETH_ALEN) {
165 g_set_error_literal (error,
166 NM_SETTING_WIMAX_ERROR,
167 NM_SETTING_WIMAX_ERROR_INVALID_PROPERTY,
168 _("property is invalid"));
169 g_prefix_error (error, "%s.%s: ", NM_SETTING_WIMAX_SETTING_NAME, NM_SETTING_WIMAX_MAC_ADDRESS);
177 nm_setting_wimax_init (NMSettingWimax *setting)
182 finalize (GObject *object)
184 NMSettingWimaxPrivate *priv = NM_SETTING_WIMAX_GET_PRIVATE (object);
186 g_free (priv->network_name);
187 if (priv->mac_address)
188 g_byte_array_free (priv->mac_address, TRUE);
190 G_OBJECT_CLASS (nm_setting_wimax_parent_class)->finalize (object);
194 set_property (GObject *object, guint prop_id,
195 const GValue *value, GParamSpec *pspec)
197 NMSettingWimaxPrivate *priv = NM_SETTING_WIMAX_GET_PRIVATE (object);
200 case PROP_NETWORK_NAME:
201 g_free (priv->network_name);
202 priv->network_name = g_value_dup_string (value);
204 case PROP_MAC_ADDRESS:
205 if (priv->mac_address)
206 g_byte_array_free (priv->mac_address, TRUE);
207 priv->mac_address = g_value_dup_boxed (value);
210 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
216 get_property (GObject *object, guint prop_id,
217 GValue *value, GParamSpec *pspec)
219 NMSettingWimax *setting = NM_SETTING_WIMAX (object);
222 case PROP_NETWORK_NAME:
223 g_value_set_string (value, nm_setting_wimax_get_network_name (setting));
225 case PROP_MAC_ADDRESS:
226 g_value_set_boxed (value, nm_setting_wimax_get_mac_address (setting));
229 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
235 nm_setting_wimax_class_init (NMSettingWimaxClass *setting_class)
237 GObjectClass *object_class = G_OBJECT_CLASS (setting_class);
238 NMSettingClass *parent_class = NM_SETTING_CLASS (setting_class);
240 g_type_class_add_private (setting_class, sizeof (NMSettingWimaxPrivate));
242 /* virtual methods */
243 object_class->set_property = set_property;
244 object_class->get_property = get_property;
245 object_class->finalize = finalize;
246 parent_class->verify = verify;
250 * NMSettingWimax:network-name:
252 * Network Service Provider (NSP) name of the WiMAX network this connection
255 * Deprecated: 1.2: WiMAX is no longer supported.
257 g_object_class_install_property
258 (object_class, PROP_NETWORK_NAME,
259 g_param_spec_string (NM_SETTING_WIMAX_NETWORK_NAME, "", "",
262 G_PARAM_STATIC_STRINGS));
265 * NMSettingWimax:mac-address:
267 * If specified, this connection will only apply to the WiMAX device whose
268 * MAC address matches. This property does not change the MAC address of the
269 * device (known as MAC spoofing).
271 * Deprecated: 1.2: WiMAX is no longer supported.
273 g_object_class_install_property
274 (object_class, PROP_MAC_ADDRESS,
275 _nm_param_spec_specialized (NM_SETTING_WIMAX_MAC_ADDRESS, "", "",
276 DBUS_TYPE_G_UCHAR_ARRAY,
278 G_PARAM_STATIC_STRINGS));