mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-02 08:50:12 +01:00
core/setting-wpan: add page and channel properties
This commit is contained in:
parent
a745f0c952
commit
ae38d43e66
4 changed files with 137 additions and 3 deletions
|
|
@ -359,6 +359,8 @@
|
|||
#define DESCRIBE_DOC_NM_SETTING_VXLAN_TTL N_("Specifies the time-to-live value to use in outgoing packets.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_WIMAX_MAC_ADDRESS N_("If specified, this connection will only apply to the WiMAX device whose MAC address matches. This property does not change the MAC address of the device (known as MAC spoofing). Deprecated: 1")
|
||||
#define DESCRIBE_DOC_NM_SETTING_WIMAX_NETWORK_NAME N_("Network Service Provider (NSP) name of the WiMAX network this connection should use. Deprecated: 1")
|
||||
#define DESCRIBE_DOC_NM_SETTING_WPAN_CHANNEL N_("IEEE 802.15.4 channel. A positive integer or -1, meaning \"do not set, use whatever the device is already set to\".")
|
||||
#define DESCRIBE_DOC_NM_SETTING_WPAN_MAC_ADDRESS N_("If specified, this connection will only apply to the IEEE 802.15.4 (WPAN) MAC layer device whose permanent MAC address matches.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_WPAN_PAGE N_("IEEE 802.15.4 channel page. A positive integer or -1, meaning \"do not set, use whatever the device is already set to\".")
|
||||
#define DESCRIBE_DOC_NM_SETTING_WPAN_PAN_ID N_("IEEE 802.15.4 Personal Area Network (PAN) identifier.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_WPAN_SHORT_ADDRESS N_("Short IEEE 802.15.4 address to be used within a restricted environment.")
|
||||
|
|
|
|||
|
|
@ -26,22 +26,34 @@
|
|||
#include "nm-setting-private.h"
|
||||
#include "nm-utils-private.h"
|
||||
|
||||
/* Ideally we'll be able to get this from a public header. */
|
||||
/* Ideally we'll be able to get these from a public header. */
|
||||
#ifndef IEEE802154_ADDR_LEN
|
||||
#define IEEE802154_ADDR_LEN 8
|
||||
#endif
|
||||
|
||||
#ifndef IEEE802154_MAX_PAGE
|
||||
#define IEEE802154_MAX_PAGE 31
|
||||
#endif
|
||||
|
||||
#ifndef IEEE802154_MAX_CHANNEL
|
||||
#define IEEE802154_MAX_CHANNEL 26
|
||||
#endif
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_MAC_ADDRESS,
|
||||
PROP_PAN_ID,
|
||||
PROP_SHORT_ADDRESS,
|
||||
PROP_PAGE,
|
||||
PROP_CHANNEL,
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
char *mac_address;
|
||||
guint16 pan_id;
|
||||
guint16 short_address;
|
||||
gint16 page;
|
||||
gint16 channel;
|
||||
} NMSettingWpanPrivate;
|
||||
|
||||
/**
|
||||
|
|
@ -117,6 +129,38 @@ nm_setting_wpan_get_short_address (NMSettingWpan *setting)
|
|||
return NM_SETTING_WPAN_GET_PRIVATE (setting)->short_address;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_wpan_get_page:
|
||||
* @setting: the #NMSettingWpan
|
||||
*
|
||||
* Returns: the #NMSettingWpan:page property of the setting
|
||||
*
|
||||
* Since: 1.16
|
||||
**/
|
||||
gint16
|
||||
nm_setting_wpan_get_page (NMSettingWpan *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_WPAN (setting), NM_SETTING_WPAN_PAGE_DEFAULT);
|
||||
|
||||
return NM_SETTING_WPAN_GET_PRIVATE (setting)->page;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_wpan_get_channel:
|
||||
* @setting: the #NMSettingWpan
|
||||
*
|
||||
* Returns: the #NMSettingWpan:channel property of the setting
|
||||
*
|
||||
* Since: 1.16
|
||||
**/
|
||||
gint16
|
||||
nm_setting_wpan_get_channel (NMSettingWpan *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_WPAN (setting), NM_SETTING_WPAN_CHANNEL_DEFAULT);
|
||||
|
||||
return NM_SETTING_WPAN_GET_PRIVATE (setting)->channel;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
verify (NMSetting *setting, NMConnection *connection, GError **error)
|
||||
{
|
||||
|
|
@ -131,6 +175,37 @@ verify (NMSetting *setting, NMConnection *connection, GError **error)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if ((priv->page == NM_SETTING_WPAN_PAGE_DEFAULT) != (priv->channel == NM_SETTING_WPAN_CHANNEL_DEFAULT)) {
|
||||
g_set_error_literal (error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
||||
_("page must be defined along with a channel"));
|
||||
g_prefix_error (error, "%s.%s: ", NM_SETTING_WPAN_SETTING_NAME, NM_SETTING_WPAN_PAGE);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (priv->page < NM_SETTING_WPAN_PAGE_DEFAULT || priv->page > IEEE802154_MAX_PAGE) {
|
||||
g_set_error (error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
||||
_("page must be between %d and %d"),
|
||||
NM_SETTING_WPAN_PAGE_DEFAULT,
|
||||
IEEE802154_MAX_PAGE);
|
||||
g_prefix_error (error, "%s.%s: ", NM_SETTING_WPAN_SETTING_NAME, NM_SETTING_WPAN_PAGE);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (priv->channel < NM_SETTING_WPAN_CHANNEL_DEFAULT || priv->channel > IEEE802154_MAX_CHANNEL) {
|
||||
g_set_error (error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
||||
_("channel must not be between %d and %d"),
|
||||
NM_SETTING_WPAN_CHANNEL_DEFAULT,
|
||||
IEEE802154_MAX_CHANNEL);
|
||||
g_prefix_error (error, "%s.%s: ", NM_SETTING_WPAN_SETTING_NAME, NM_SETTING_WPAN_CHANNEL);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
@ -149,6 +224,12 @@ get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
|
|||
case PROP_SHORT_ADDRESS:
|
||||
g_value_set_uint (value, nm_setting_wpan_get_short_address (setting));
|
||||
break;
|
||||
case PROP_PAGE:
|
||||
g_value_set_int (value, nm_setting_wpan_get_page (setting));
|
||||
break;
|
||||
case PROP_CHANNEL:
|
||||
g_value_set_int (value, nm_setting_wpan_get_channel (setting));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
|
|
@ -172,6 +253,12 @@ set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *p
|
|||
case PROP_SHORT_ADDRESS:
|
||||
priv->short_address = g_value_get_uint (value);
|
||||
break;
|
||||
case PROP_PAGE:
|
||||
priv->page = g_value_get_int (value);
|
||||
break;
|
||||
case PROP_CHANNEL:
|
||||
priv->channel = g_value_get_int (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
|
|
@ -183,8 +270,10 @@ nm_setting_wpan_init (NMSettingWpan *setting)
|
|||
{
|
||||
NMSettingWpanPrivate *priv = NM_SETTING_WPAN_GET_PRIVATE (setting);
|
||||
|
||||
priv->short_address = G_MAXUINT16;
|
||||
priv->pan_id = G_MAXUINT16;
|
||||
priv->short_address = G_MAXUINT16;
|
||||
priv->page = NM_SETTING_WPAN_PAGE_DEFAULT;
|
||||
priv->channel = NM_SETTING_WPAN_CHANNEL_DEFAULT;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -270,5 +359,39 @@ nm_setting_wpan_class_init (NMSettingWpanClass *klass)
|
|||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
/**
|
||||
* NMSettingWpan:page:
|
||||
*
|
||||
* IEEE 802.15.4 channel page. A positive integer or -1, meaning "do not
|
||||
* set, use whatever the device is already set to".
|
||||
*
|
||||
* Since: 1.16
|
||||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_PAGE,
|
||||
g_param_spec_int (NM_SETTING_WPAN_PAGE, "", "",
|
||||
G_MININT16,
|
||||
G_MAXINT16,
|
||||
NM_SETTING_WPAN_PAGE_DEFAULT,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
/**
|
||||
* NMSettingWpan:channel:
|
||||
*
|
||||
* IEEE 802.15.4 channel. A positive integer or -1, meaning "do not
|
||||
* set, use whatever the device is already set to".
|
||||
*
|
||||
* Since: 1.16
|
||||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_CHANNEL,
|
||||
g_param_spec_int (NM_SETTING_WPAN_CHANNEL, "", "",
|
||||
G_MININT16,
|
||||
G_MAXINT16,
|
||||
NM_SETTING_WPAN_CHANNEL_DEFAULT,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
_nm_setting_class_commit (setting_class, NM_META_SETTING_TYPE_WPAN);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,6 +39,11 @@ G_BEGIN_DECLS
|
|||
#define NM_SETTING_WPAN_MAC_ADDRESS "mac-address"
|
||||
#define NM_SETTING_WPAN_PAN_ID "pan-id"
|
||||
#define NM_SETTING_WPAN_SHORT_ADDRESS "short-address"
|
||||
#define NM_SETTING_WPAN_PAGE "page"
|
||||
#define NM_SETTING_WPAN_CHANNEL "channel"
|
||||
|
||||
#define NM_SETTING_WPAN_PAGE_DEFAULT -1
|
||||
#define NM_SETTING_WPAN_CHANNEL_DEFAULT -1
|
||||
|
||||
typedef struct _NMSettingWpanClass NMSettingWpanClass;
|
||||
|
||||
|
|
@ -53,6 +58,10 @@ NM_AVAILABLE_IN_1_14
|
|||
guint16 nm_setting_wpan_get_pan_id (NMSettingWpan *setting);
|
||||
NM_AVAILABLE_IN_1_14
|
||||
guint16 nm_setting_wpan_get_short_address (NMSettingWpan *setting);
|
||||
NM_AVAILABLE_IN_1_16
|
||||
gint16 nm_setting_wpan_get_page (NMSettingWpan *setting);
|
||||
NM_AVAILABLE_IN_1_16
|
||||
gint16 nm_setting_wpan_get_channel (NMSettingWpan *setting);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
|||
|
|
@ -184,7 +184,7 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *out_failure_reason)
|
|||
|
||||
ret = NM_ACT_STAGE_RETURN_SUCCESS;
|
||||
out:
|
||||
nm_device_bring_up (device, TRUE, NULL);
|
||||
nm_device_bring_up (device, TRUE, NULL);
|
||||
|
||||
if (lowpan_device)
|
||||
nm_device_bring_up (lowpan_device, TRUE, NULL);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue