mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-05 14:38:09 +02:00
merge: branch 'lr/6lowpan'
https://github.com/NetworkManager/NetworkManager/pull/120
This commit is contained in:
commit
191c9c7f0d
67 changed files with 3969 additions and 683 deletions
43
Makefile.am
43
Makefile.am
|
|
@ -204,6 +204,8 @@ introspection_sources = \
|
|||
introspection/org.freedesktop.NetworkManager.Device.Infiniband.h \
|
||||
introspection/org.freedesktop.NetworkManager.Device.IPTunnel.c \
|
||||
introspection/org.freedesktop.NetworkManager.Device.IPTunnel.h \
|
||||
introspection/org.freedesktop.NetworkManager.Device.Lowpan.c \
|
||||
introspection/org.freedesktop.NetworkManager.Device.Lowpan.h \
|
||||
introspection/org.freedesktop.NetworkManager.Device.Macsec.c \
|
||||
introspection/org.freedesktop.NetworkManager.Device.Macsec.h \
|
||||
introspection/org.freedesktop.NetworkManager.Device.Macvlan.c \
|
||||
|
|
@ -236,6 +238,8 @@ introspection_sources = \
|
|||
introspection/org.freedesktop.NetworkManager.Device.Wireless.h \
|
||||
introspection/org.freedesktop.NetworkManager.Device.WiMax.c \
|
||||
introspection/org.freedesktop.NetworkManager.Device.WiMax.h \
|
||||
introspection/org.freedesktop.NetworkManager.Device.Wpan.c \
|
||||
introspection/org.freedesktop.NetworkManager.Device.Wpan.h \
|
||||
introspection/org.freedesktop.NetworkManager.Device.c \
|
||||
introspection/org.freedesktop.NetworkManager.Device.h \
|
||||
introspection/org.freedesktop.NetworkManager.DHCP4Config.c \
|
||||
|
|
@ -289,6 +293,7 @@ DBUS_INTERFACE_DOCS = \
|
|||
docs/api/dbus-org.freedesktop.NetworkManager.Device.Adsl.xml \
|
||||
docs/api/dbus-org.freedesktop.NetworkManager.AgentManager.xml \
|
||||
docs/api/dbus-org.freedesktop.NetworkManager.Device.WiMax.xml \
|
||||
docs/api/dbus-org.freedesktop.NetworkManager.Device.Wpan.xml \
|
||||
docs/api/dbus-org.freedesktop.NetworkManager.Device.IPTunnel.xml \
|
||||
docs/api/dbus-org.freedesktop.NetworkManager.Device.Tun.xml \
|
||||
docs/api/dbus-org.freedesktop.NetworkManager.Device.Bridge.xml \
|
||||
|
|
@ -307,7 +312,8 @@ DBUS_INTERFACE_DOCS = \
|
|||
docs/api/dbus-org.freedesktop.NetworkManager.Device.Wired.xml \
|
||||
docs/api/dbus-org.freedesktop.NetworkManager.IP4Config.xml \
|
||||
docs/api/dbus-org.freedesktop.NetworkManager.Device.Statistics.xml \
|
||||
docs/api/dbus-org.freedesktop.NetworkManager.DnsManager.xml
|
||||
docs/api/dbus-org.freedesktop.NetworkManager.DnsManager.xml \
|
||||
docs/api/dbus-org.freedesktop.NetworkManager.Device.Lowpan.xml
|
||||
|
||||
introspection/%.c: introspection/%.xml
|
||||
@$(MKDIR_P) introspection/
|
||||
|
|
@ -340,6 +346,7 @@ dbusinterfaces_DATA = \
|
|||
introspection/org.freedesktop.NetworkManager.Device.Generic.xml \
|
||||
introspection/org.freedesktop.NetworkManager.Device.Infiniband.xml \
|
||||
introspection/org.freedesktop.NetworkManager.Device.IPTunnel.xml \
|
||||
introspection/org.freedesktop.NetworkManager.Device.Lowpan.xml \
|
||||
introspection/org.freedesktop.NetworkManager.Device.Macsec.xml \
|
||||
introspection/org.freedesktop.NetworkManager.Device.Macvlan.xml \
|
||||
introspection/org.freedesktop.NetworkManager.Device.Modem.xml \
|
||||
|
|
@ -356,6 +363,7 @@ dbusinterfaces_DATA = \
|
|||
introspection/org.freedesktop.NetworkManager.Device.Vxlan.xml \
|
||||
introspection/org.freedesktop.NetworkManager.Device.Wireless.xml \
|
||||
introspection/org.freedesktop.NetworkManager.Device.WiMax.xml \
|
||||
introspection/org.freedesktop.NetworkManager.Device.Wpan.xml \
|
||||
introspection/org.freedesktop.NetworkManager.Device.xml \
|
||||
introspection/org.freedesktop.NetworkManager.DHCP4Config.xml \
|
||||
introspection/org.freedesktop.NetworkManager.DHCP6Config.xml \
|
||||
|
|
@ -390,6 +398,7 @@ libnm_core_lib_h_pub_real = \
|
|||
libnm-core/nm-core-types.h \
|
||||
libnm-core/nm-dbus-interface.h \
|
||||
libnm-core/nm-errors.h \
|
||||
libnm-core/nm-setting-6lowpan.h \
|
||||
libnm-core/nm-setting-8021x.h \
|
||||
libnm-core/nm-setting-adsl.h \
|
||||
libnm-core/nm-setting-bluetooth.h \
|
||||
|
|
@ -430,6 +439,7 @@ libnm_core_lib_h_pub_real = \
|
|||
libnm-core/nm-setting-wired.h \
|
||||
libnm-core/nm-setting-wireless-security.h \
|
||||
libnm-core/nm-setting-wireless.h \
|
||||
libnm-core/nm-setting-wpan.h \
|
||||
libnm-core/nm-setting.h \
|
||||
libnm-core/nm-simple-connection.h \
|
||||
libnm-core/nm-utils.h \
|
||||
|
|
@ -458,6 +468,7 @@ libnm_core_lib_h_priv = \
|
|||
libnm-core/nm-setting-private.h \
|
||||
libnm-core/nm-utils-private.h
|
||||
libnm_core_lib_c_settings_real = \
|
||||
libnm-core/nm-setting-6lowpan.c \
|
||||
libnm-core/nm-setting-8021x.c \
|
||||
libnm-core/nm-setting-adsl.c \
|
||||
libnm-core/nm-setting-bluetooth.c \
|
||||
|
|
@ -497,7 +508,8 @@ libnm_core_lib_c_settings_real = \
|
|||
libnm-core/nm-setting-wimax.c \
|
||||
libnm-core/nm-setting-wired.c \
|
||||
libnm-core/nm-setting-wireless-security.c \
|
||||
libnm-core/nm-setting-wireless.c
|
||||
libnm-core/nm-setting-wireless.c \
|
||||
libnm-core/nm-setting-wpan.c
|
||||
libnm_core_lib_c_real = \
|
||||
$(libnm_core_lib_c_settings_real) \
|
||||
shared/nm-utils/c-list-util.c \
|
||||
|
|
@ -768,6 +780,7 @@ libnm_lib_h_pub_real = \
|
|||
libnm/nm-autoptr.h \
|
||||
libnm/nm-checkpoint.h \
|
||||
libnm/nm-client.h \
|
||||
libnm/nm-device-6lowpan.h \
|
||||
libnm/nm-device-adsl.h \
|
||||
libnm/nm-device-bond.h \
|
||||
libnm/nm-device-bridge.h \
|
||||
|
|
@ -791,6 +804,7 @@ libnm_lib_h_pub_real = \
|
|||
libnm/nm-device-vxlan.h \
|
||||
libnm/nm-device-wifi.h \
|
||||
libnm/nm-device-wimax.h \
|
||||
libnm/nm-device-wpan.h \
|
||||
libnm/nm-device.h \
|
||||
libnm/nm-dhcp-config.h \
|
||||
libnm/nm-ip-config.h \
|
||||
|
|
@ -824,6 +838,7 @@ libnm_lib_c_real = \
|
|||
libnm/nm-checkpoint.c \
|
||||
libnm/nm-client.c \
|
||||
libnm/nm-dbus-helpers.c \
|
||||
libnm/nm-device-6lowpan.c \
|
||||
libnm/nm-device-adsl.c \
|
||||
libnm/nm-device-bond.c \
|
||||
libnm/nm-device-bridge.c \
|
||||
|
|
@ -847,6 +862,7 @@ libnm_lib_c_real = \
|
|||
libnm/nm-device-vxlan.c \
|
||||
libnm/nm-device-wifi.c \
|
||||
libnm/nm-device-wimax.c \
|
||||
libnm/nm-device-wpan.c \
|
||||
libnm/nm-device.c \
|
||||
libnm/nm-dhcp-config.c \
|
||||
libnm/nm-dhcp4-config.c \
|
||||
|
|
@ -1477,11 +1493,13 @@ src_libNetworkManagerBase_la_SOURCES = \
|
|||
src/platform/nm-platform-private.h \
|
||||
src/platform/nm-linux-platform.c \
|
||||
src/platform/nm-linux-platform.h \
|
||||
src/platform/wifi/wifi-utils-nl80211.c \
|
||||
src/platform/wifi/wifi-utils-nl80211.h \
|
||||
src/platform/wifi/wifi-utils-private.h \
|
||||
src/platform/wifi/wifi-utils.c \
|
||||
src/platform/wifi/wifi-utils.h \
|
||||
src/platform/wifi/nm-wifi-utils-nl80211.c \
|
||||
src/platform/wifi/nm-wifi-utils-nl80211.h \
|
||||
src/platform/wifi/nm-wifi-utils-private.h \
|
||||
src/platform/wifi/nm-wifi-utils.c \
|
||||
src/platform/wifi/nm-wifi-utils.h \
|
||||
src/platform/wpan/nm-wpan-utils.c \
|
||||
src/platform/wpan/nm-wpan-utils.h \
|
||||
\
|
||||
src/ndisc/nm-lndp-ndisc.c \
|
||||
src/ndisc/nm-lndp-ndisc.h \
|
||||
|
|
@ -1514,8 +1532,8 @@ src_libNetworkManagerBase_la_SOURCES = \
|
|||
|
||||
if WITH_WEXT
|
||||
src_libNetworkManagerBase_la_SOURCES += \
|
||||
src/platform/wifi/wifi-utils-wext.c \
|
||||
src/platform/wifi/wifi-utils-wext.h
|
||||
src/platform/wifi/nm-wifi-utils-wext.c \
|
||||
src/platform/wifi/nm-wifi-utils-wext.h
|
||||
endif
|
||||
|
||||
src_libNetworkManagerBase_la_LIBADD = \
|
||||
|
|
@ -1527,6 +1545,9 @@ src_libNetworkManagerBase_la_LIBADD = \
|
|||
|
||||
$(src_libNetworkManagerBase_la_OBJECTS): $(libnm_core_lib_h_pub_mkenums)
|
||||
|
||||
EXTRA_DIST += \
|
||||
src/platform/linux/nl802154.h
|
||||
|
||||
###############################################################################
|
||||
|
||||
src_libNetworkManager_la_CPPFLAGS = $(src_cppflags)
|
||||
|
|
@ -1553,6 +1574,8 @@ src_libNetworkManager_la_SOURCES = \
|
|||
src/devices/nm-device-logging.h \
|
||||
src/devices/nm-device-private.h \
|
||||
\
|
||||
src/devices/nm-device-6lowpan.c \
|
||||
src/devices/nm-device-6lowpan.h \
|
||||
src/devices/nm-device-bond.c \
|
||||
src/devices/nm-device-bond.h \
|
||||
src/devices/nm-device-bridge.c \
|
||||
|
|
@ -1579,6 +1602,8 @@ src_libNetworkManager_la_SOURCES = \
|
|||
src/devices/nm-device-vlan.h \
|
||||
src/devices/nm-device-vxlan.c \
|
||||
src/devices/nm-device-vxlan.h \
|
||||
src/devices/nm-device-wpan.c \
|
||||
src/devices/nm-device-wpan.h \
|
||||
\
|
||||
src/dhcp/nm-dhcp-dhcpcanon.c \
|
||||
src/dhcp/nm-dhcp-dhclient.c \
|
||||
|
|
|
|||
7
NEWS
7
NEWS
|
|
@ -1,3 +1,10 @@
|
|||
=============================================
|
||||
NetworkManager-1.?? (not released yet)
|
||||
Overview of changes since NetworkManager-1.12
|
||||
=============================================
|
||||
|
||||
* Added support for IEEE 802.15.4 and 6LowPAN devices.
|
||||
|
||||
=============================================
|
||||
NetworkManager-1.11.90 (1.12-rc1)
|
||||
Overview of changes since NetworkManager-1.10
|
||||
|
|
|
|||
|
|
@ -660,6 +660,8 @@ const NmcMetaGenericInfo *const metagen_con_active_general[_NMC_GENERIC_INFO_TYP
|
|||
NM_SETTING_MACSEC_SETTING_NAME"," \
|
||||
NM_SETTING_MACVLAN_SETTING_NAME"," \
|
||||
NM_SETTING_VXLAN_SETTING_NAME"," \
|
||||
NM_SETTING_WPAN_SETTING_NAME","\
|
||||
NM_SETTING_6LOWPAN_SETTING_NAME","\
|
||||
NM_SETTING_PROXY_SETTING_NAME"," \
|
||||
NM_SETTING_TC_CONFIG_SETTING_NAME
|
||||
// NM_SETTING_DUMMY_SETTING_NAME
|
||||
|
|
@ -890,7 +892,11 @@ usage_connection_add (void)
|
|||
" [source-port-min <0-65535>]\n"
|
||||
" [source-port-max <0-65535>]\n"
|
||||
" [destination-port <0-65535>]\n\n"
|
||||
" dummy: \n\n"
|
||||
" wpan: [short-addr <0x0000-0xffff>]\n\n"
|
||||
" [pan-id <0x0000-0xffff>]\n\n"
|
||||
" [mac <MAC address>]\n\n"
|
||||
" 6lowpan: dev <parent device (connection UUID, ifname, or MAC)>\n"
|
||||
" dummy:\n\n"
|
||||
" SLAVE_OPTIONS:\n"
|
||||
" bridge: [priority <0-63>]\n"
|
||||
" [path-cost <1-65535>]\n"
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright 2010 - 2017 Red Hat, Inc.
|
||||
* Copyright 2010 - 2018 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#include "nm-default.h"
|
||||
|
|
@ -775,7 +775,9 @@ _get_fcn_gobject_int (ARGS_GET_FCN)
|
|||
GParamSpec *pspec;
|
||||
nm_auto_unset_gvalue GValue gval = G_VALUE_INIT;
|
||||
gint64 v;
|
||||
guint base = 10;
|
||||
const NMMetaUtilsIntValueInfo *value_infos;
|
||||
char *return_str;
|
||||
|
||||
RETURN_UNSUPPORTED_GET_TYPE ();
|
||||
|
||||
|
|
@ -801,19 +803,38 @@ _get_fcn_gobject_int (ARGS_GET_FCN)
|
|||
break;
|
||||
}
|
||||
|
||||
if ( property_info->property_typ_data
|
||||
&& property_info->property_typ_data->subtype.gobject_int.base > 0) {
|
||||
base = property_info->property_typ_data->subtype.gobject_int.base;
|
||||
}
|
||||
|
||||
switch (base) {
|
||||
case 10:
|
||||
return_str = g_strdup_printf ("%"G_GINT64_FORMAT, v);
|
||||
break;
|
||||
case 16:
|
||||
return_str = g_strdup_printf ("0x%"G_GINT64_MODIFIER"x", v);
|
||||
break;
|
||||
default:
|
||||
return_str = NULL;
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
if ( get_type == NM_META_ACCESSOR_GET_TYPE_PRETTY
|
||||
&& property_info->property_typ_data
|
||||
&& (value_infos = property_info->property_typ_data->subtype.gobject_int.value_infos)) {
|
||||
for (; value_infos->nick; value_infos++) {
|
||||
if (value_infos->value == v) {
|
||||
RETURN_STR_TO_FREE (g_strdup_printf ("%lli (%s)",
|
||||
(long long) v,
|
||||
value_infos->nick));
|
||||
char *old_str = return_str;
|
||||
|
||||
return_str = g_strdup_printf ("%s (%s)", old_str, value_infos->nick);
|
||||
g_free (old_str);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_STR_TO_FREE (g_strdup_printf ("%"G_GINT64_FORMAT, v));
|
||||
RETURN_STR_TO_FREE (return_str);
|
||||
}
|
||||
|
||||
static gconstpointer
|
||||
|
|
@ -1179,6 +1200,11 @@ _set_fcn_gobject_mtu (ARGS_SET_FCN)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
/* Ideally we'll be able to get this from a public header. */
|
||||
#ifndef IEEE802154_ADDR_LEN
|
||||
#define IEEE802154_ADDR_LEN 8
|
||||
#endif
|
||||
|
||||
static gboolean
|
||||
_set_fcn_gobject_mac (ARGS_SET_FCN)
|
||||
{
|
||||
|
|
@ -1190,9 +1216,11 @@ _set_fcn_gobject_mac (ARGS_SET_FCN)
|
|||
else
|
||||
mode = NM_META_PROPERTY_TYPE_MAC_MODE_DEFAULT;
|
||||
|
||||
if (mode == NM_META_PROPERTY_TYPE_MAC_MODE_INFINIBAND)
|
||||
if (mode == NM_META_PROPERTY_TYPE_MAC_MODE_INFINIBAND) {
|
||||
valid = nm_utils_hwaddr_valid (value, INFINIBAND_ALEN);
|
||||
else {
|
||||
} else if (mode == NM_META_PROPERTY_TYPE_MAC_MODE_WPAN) {
|
||||
valid = nm_utils_hwaddr_valid (value, IEEE802154_ADDR_LEN);
|
||||
} else {
|
||||
valid = nm_utils_hwaddr_valid (value, ETH_ALEN)
|
||||
|| ( mode == NM_META_PROPERTY_TYPE_MAC_MODE_CLONED
|
||||
&& NM_CLONED_MAC_IS_SPECIAL (value));
|
||||
|
|
@ -7414,6 +7442,65 @@ static const NMMetaPropertyInfo *const property_infos_WIRELESS_SECURITY[] = {
|
|||
NULL
|
||||
};
|
||||
|
||||
#undef _CURRENT_NM_META_SETTING_TYPE
|
||||
#define _CURRENT_NM_META_SETTING_TYPE NM_META_SETTING_TYPE_WPAN
|
||||
static const NMMetaPropertyInfo *const property_infos_WPAN[] = {
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_WPAN_MAC_ADDRESS,
|
||||
.property_type = &_pt_gobject_mac,
|
||||
.is_cli_option = TRUE,
|
||||
.property_alias = "mac",
|
||||
.prompt = N_("MAC [none]"),
|
||||
.property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (mac,
|
||||
.mode = NM_META_PROPERTY_TYPE_MAC_MODE_WPAN,
|
||||
),
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_WPAN_SHORT_ADDRESS,
|
||||
.is_cli_option = TRUE,
|
||||
.property_alias = "short-addr",
|
||||
.prompt = N_("Short address (<0x0000-0xffff>)"),
|
||||
.property_type = &_pt_gobject_int,
|
||||
.property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (gobject_int, \
|
||||
.base = 16,
|
||||
.value_infos = INT_VALUE_INFOS (
|
||||
{
|
||||
.value = G_MAXUINT16,
|
||||
.nick = "unset",
|
||||
}
|
||||
),
|
||||
),
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_WPAN_PAN_ID,
|
||||
.is_cli_option = TRUE,
|
||||
.inf_flags = NM_META_PROPERTY_INF_FLAG_REQD,
|
||||
.property_alias = "pan-id",
|
||||
.prompt = N_("PAN Identifier (<0x0000-0xffff>)"),
|
||||
.property_type = &_pt_gobject_int,
|
||||
.property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (gobject_int, \
|
||||
.base = 16,
|
||||
.value_infos = INT_VALUE_INFOS (
|
||||
{
|
||||
.value = G_MAXUINT16,
|
||||
.nick = "unset",
|
||||
}
|
||||
),
|
||||
),
|
||||
),
|
||||
NULL
|
||||
};
|
||||
|
||||
#undef _CURRENT_NM_META_SETTING_TYPE
|
||||
#define _CURRENT_NM_META_SETTING_TYPE NM_META_SETTING_TYPE_6LOWPAN
|
||||
static const NMMetaPropertyInfo *const property_infos_6LOWPAN[] = {
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_6LOWPAN_PARENT,
|
||||
.is_cli_option = TRUE,
|
||||
.property_alias = "dev",
|
||||
.inf_flags = NM_META_PROPERTY_INF_FLAG_REQD,
|
||||
.prompt = N_("IEEE 802.15.4 (WPAN) parent device or connection UUID"),
|
||||
.property_type = &_pt_gobject_string,
|
||||
),
|
||||
NULL
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
|
|
@ -7574,6 +7661,8 @@ _setting_init_fcn_wireless (ARGS_SETTING_INIT_FCN)
|
|||
#define SETTING_PRETTY_NAME_WIRED N_("Wired Ethernet")
|
||||
#define SETTING_PRETTY_NAME_WIRELESS N_("Wi-Fi connection")
|
||||
#define SETTING_PRETTY_NAME_WIRELESS_SECURITY N_("Wi-Fi security settings")
|
||||
#define SETTING_PRETTY_NAME_WPAN N_("WPAN settings")
|
||||
#define SETTING_PRETTY_NAME_6LOWPAN N_("6LOWPAN settings")
|
||||
|
||||
#define NM_META_SETTING_VALID_PARTS(...) \
|
||||
((const NMMetaSettingValidPartItem *const[]) { __VA_ARGS__ NULL })
|
||||
|
|
@ -7601,6 +7690,12 @@ const NMMetaSettingInfoEditor nm_meta_setting_infos_editor[] = {
|
|||
.pretty_name = SETTING_PRETTY_NAME_##type, \
|
||||
__VA_ARGS__ \
|
||||
}
|
||||
SETTING_INFO (6LOWPAN,
|
||||
.valid_parts = NM_META_SETTING_VALID_PARTS (
|
||||
NM_META_SETTING_VALID_PART_ITEM (CONNECTION, TRUE),
|
||||
NM_META_SETTING_VALID_PART_ITEM (6LOWPAN, TRUE),
|
||||
),
|
||||
),
|
||||
SETTING_INFO (802_1X),
|
||||
SETTING_INFO (ADSL,
|
||||
.valid_parts = NM_META_SETTING_VALID_PARTS (
|
||||
|
|
@ -7815,6 +7910,12 @@ const NMMetaSettingInfoEditor nm_meta_setting_infos_editor[] = {
|
|||
SETTING_INFO (WIRELESS_SECURITY,
|
||||
.alias = "wifi-sec",
|
||||
),
|
||||
SETTING_INFO (WPAN,
|
||||
.valid_parts = NM_META_SETTING_VALID_PARTS (
|
||||
NM_META_SETTING_VALID_PART_ITEM (CONNECTION, TRUE),
|
||||
NM_META_SETTING_VALID_PART_ITEM (WPAN, TRUE),
|
||||
),
|
||||
),
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
|||
|
|
@ -163,6 +163,7 @@ typedef enum {
|
|||
NM_META_PROPERTY_TYPE_MAC_MODE_DEFAULT,
|
||||
NM_META_PROPERTY_TYPE_MAC_MODE_CLONED,
|
||||
NM_META_PROPERTY_TYPE_MAC_MODE_INFINIBAND,
|
||||
NM_META_PROPERTY_TYPE_MAC_MODE_WPAN,
|
||||
} NMMetaPropertyTypeMacMode;
|
||||
|
||||
typedef struct _NMMetaEnvironment NMMetaEnvironment;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
/* Generated file. Do not edit. */
|
||||
|
||||
#define DESCRIBE_DOC_NM_SETTING_6LOWPAN_NAME N_("The setting's name, which uniquely identifies the setting within the connection. Each setting type has a name unique to that type, for example \"ppp\" or \"wireless\" or \"wired\".")
|
||||
#define DESCRIBE_DOC_NM_SETTING_6LOWPAN_PARENT N_("If given, specifies the parent interface name or parent connection UUID from which this 6LowPAN interface should be created.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_OLPC_MESH_CHANNEL N_("Channel on which the mesh network to join is located.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_OLPC_MESH_DHCP_ANYCAST_ADDRESS N_("Anycast DHCP MAC address used when requesting an IP address via DHCP. The specific anycast address used determines which DHCP server class answers the request.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_OLPC_MESH_NAME N_("The setting's name, which uniquely identifies the setting within the connection. Each setting type has a name unique to that type, for example \"ppp\" or \"wireless\" or \"wired\".")
|
||||
|
|
@ -391,3 +393,7 @@
|
|||
#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_NAME N_("The setting's name, which uniquely identifies the setting within the connection. Each setting type has a name unique to that type, for example \"ppp\" or \"wireless\" or \"wired\".")
|
||||
#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_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_NAME N_("The setting's name, which uniquely identifies the setting within the connection. Each setting type has a name unique to that type, for example \"ppp\" or \"wireless\" or \"wired\".")
|
||||
#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.")
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ ifaces = [
|
|||
'org.freedesktop.NetworkManager.Device.Generic',
|
||||
'org.freedesktop.NetworkManager.Device.Infiniband',
|
||||
'org.freedesktop.NetworkManager.Device.IPTunnel',
|
||||
'org.freedesktop.NetworkManager.Device.Lowpan',
|
||||
'org.freedesktop.NetworkManager.Device.Macsec',
|
||||
'org.freedesktop.NetworkManager.Device.Macvlan',
|
||||
'org.freedesktop.NetworkManager.Device.Modem',
|
||||
|
|
@ -30,6 +31,7 @@ ifaces = [
|
|||
'org.freedesktop.NetworkManager.Device.Vlan',
|
||||
'org.freedesktop.NetworkManager.Device.Vxlan',
|
||||
'org.freedesktop.NetworkManager.Device.WiMax',
|
||||
'org.freedesktop.NetworkManager.Device.Wpan',
|
||||
'org.freedesktop.NetworkManager.Device.Wired',
|
||||
'org.freedesktop.NetworkManager.Device.Wireless',
|
||||
'org.freedesktop.NetworkManager.Device',
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<node name="/">
|
||||
<!--
|
||||
org.freedesktop.NetworkManager.Device.Lowpan:
|
||||
@short_description: 6LoWPAN Device
|
||||
|
||||
-->
|
||||
<interface name="org.freedesktop.NetworkManager.Device.Lowpan">
|
||||
|
||||
<!--
|
||||
HwAddress:
|
||||
|
||||
The active hardware address of the device.
|
||||
-->
|
||||
<property name="HwAddress" type="s" access="read"/>
|
||||
|
||||
<!--
|
||||
Parent:
|
||||
|
||||
The object path of the parent device.
|
||||
-->
|
||||
<property name="Parent" type="o" access="read"/>
|
||||
</interface>
|
||||
</node>
|
||||
18
introspection/org.freedesktop.NetworkManager.Device.Wpan.xml
Normal file
18
introspection/org.freedesktop.NetworkManager.Device.Wpan.xml
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<node name="/">
|
||||
<!--
|
||||
org.freedesktop.NetworkManager.Device.Wpan:
|
||||
@short_description: IEEE 802.15.4 (WPAN) MAC Layer Device
|
||||
|
||||
-->
|
||||
<interface name="org.freedesktop.NetworkManager.Device.Wpan">
|
||||
|
||||
<!--
|
||||
HwAddress:
|
||||
|
||||
The active hardware address of the device.
|
||||
-->
|
||||
<property name="HwAddress" type="s" access="read"/>
|
||||
|
||||
</interface>
|
||||
</node>
|
||||
|
|
@ -5,6 +5,7 @@ libnm_core_headers = files(
|
|||
'nm-core-types.h',
|
||||
'nm-dbus-interface.h',
|
||||
'nm-errors.h',
|
||||
'nm-setting-6lowpan.h',
|
||||
'nm-setting-8021x.h',
|
||||
'nm-setting-adsl.h',
|
||||
'nm-setting-bluetooth.h',
|
||||
|
|
@ -45,6 +46,7 @@ libnm_core_headers = files(
|
|||
'nm-setting-wired.h',
|
||||
'nm-setting-wireless-security.h',
|
||||
'nm-setting-wireless.h',
|
||||
'nm-setting-wpan.h',
|
||||
'nm-setting.h',
|
||||
'nm-simple-connection.h',
|
||||
'nm-utils.h',
|
||||
|
|
@ -55,6 +57,7 @@ libnm_core_headers = files(
|
|||
)
|
||||
|
||||
libnm_core_settings_sources = files(
|
||||
'nm-setting-6lowpan.c',
|
||||
'nm-setting-8021x.c',
|
||||
'nm-setting-adsl.c',
|
||||
'nm-setting-bluetooth.c',
|
||||
|
|
@ -94,7 +97,8 @@ libnm_core_settings_sources = files(
|
|||
'nm-setting-wimax.c',
|
||||
'nm-setting-wired.c',
|
||||
'nm-setting-wireless-security.c',
|
||||
'nm-setting-wireless.c'
|
||||
'nm-setting-wireless.c',
|
||||
'nm-setting-wpan.c'
|
||||
)
|
||||
|
||||
libnm_core_sources = libnm_core_settings_sources + files(
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright 2007 - 2017 Red Hat, Inc.
|
||||
* Copyright 2007 - 2018 Red Hat, Inc.
|
||||
* Copyright 2007 - 2008 Novell, Inc.
|
||||
*/
|
||||
|
||||
|
|
@ -809,16 +809,34 @@ _normalize_ethernet_link_neg (NMConnection *self)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* _supports_addr_family:
|
||||
* @self: a #NMConnection
|
||||
* @family: AF_*
|
||||
*
|
||||
* Check whether the connection supports certain L3 address family,
|
||||
* in order to be able to tell whether is should have the corresponding
|
||||
* setting ("ipv4" for AF_INET and "ipv6" for AF_INET6).
|
||||
*
|
||||
* If AF_UNSPEC is given, then the function checks whether the connection
|
||||
* supports any L3 configuration at all.
|
||||
*
|
||||
* Returns: %TRUE if the AF is supported, %FALSE otherwise
|
||||
**/
|
||||
static gboolean
|
||||
_without_ip_config (NMConnection *self)
|
||||
_supports_addr_family (NMConnection *self, int family)
|
||||
{
|
||||
const char *connection_type = nm_connection_get_connection_type (self);
|
||||
|
||||
g_return_val_if_fail (connection_type, FALSE);
|
||||
g_return_val_if_fail (connection_type, TRUE);
|
||||
if (strcmp (connection_type, NM_SETTING_OVS_INTERFACE_SETTING_NAME) == 0)
|
||||
return TRUE;
|
||||
if (strcmp (connection_type, NM_SETTING_WPAN_SETTING_NAME) == 0)
|
||||
return FALSE;
|
||||
if (strcmp (connection_type, NM_SETTING_6LOWPAN_SETTING_NAME) == 0)
|
||||
return family == AF_INET6 || family == AF_UNSPEC;
|
||||
|
||||
return !!nm_setting_connection_get_master (nm_connection_get_setting_connection (self));
|
||||
return !nm_setting_connection_get_master (nm_connection_get_setting_connection (self));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
@ -841,32 +859,18 @@ _normalize_ip_config (NMConnection *self, GHashTable *parameters)
|
|||
s_ip6 = nm_connection_get_setting_ip6_config (self);
|
||||
s_proxy = nm_connection_get_setting_proxy (self);
|
||||
|
||||
if (_without_ip_config (self)) {
|
||||
/* Slave connections don't have IP configuration. */
|
||||
|
||||
if (s_ip4)
|
||||
nm_connection_remove_setting (self, NM_TYPE_SETTING_IP4_CONFIG);
|
||||
|
||||
if (s_ip6)
|
||||
nm_connection_remove_setting (self, NM_TYPE_SETTING_IP6_CONFIG);
|
||||
|
||||
if (s_proxy)
|
||||
nm_connection_remove_setting (self, NM_TYPE_SETTING_PROXY);
|
||||
|
||||
return s_ip4 || s_ip6 || s_proxy;
|
||||
} else {
|
||||
/* Ensure all non-slave connections have IP4 and IP6 settings objects. If no
|
||||
* IP6 setting was specified, then assume that means IP6 config is allowed
|
||||
* to fail. But if no IP4 setting was specified, assume the caller was just
|
||||
* being lazy.
|
||||
*/
|
||||
if (_supports_addr_family (self, AF_INET)) {
|
||||
if (!s_ip4) {
|
||||
/* But if no IP4 setting was specified, assume the caller was just
|
||||
* being lazy and use the default method.
|
||||
*/
|
||||
setting = nm_setting_ip4_config_new ();
|
||||
|
||||
g_object_set (setting,
|
||||
NM_SETTING_IP_CONFIG_METHOD, default_ip4_method,
|
||||
NULL);
|
||||
nm_connection_add_setting (self, setting);
|
||||
changed = TRUE;
|
||||
} else {
|
||||
if ( nm_setting_ip_config_get_gateway (s_ip4)
|
||||
&& nm_setting_ip_config_get_never_default (s_ip4)) {
|
||||
|
|
@ -890,7 +894,18 @@ _normalize_ip_config (NMConnection *self, GHashTable *parameters)
|
|||
changed = TRUE;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (s_ip4) {
|
||||
nm_connection_remove_setting (self, NM_TYPE_SETTING_IP4_CONFIG);
|
||||
changed = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (_supports_addr_family (self, AF_INET6)) {
|
||||
if (!s_ip6) {
|
||||
/* If no IP6 setting was specified, then assume that means IP6 config is
|
||||
* allowed to fail.
|
||||
*/
|
||||
setting = nm_setting_ip6_config_new ();
|
||||
|
||||
g_object_set (setting,
|
||||
|
|
@ -898,6 +913,7 @@ _normalize_ip_config (NMConnection *self, GHashTable *parameters)
|
|||
NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE,
|
||||
NULL);
|
||||
nm_connection_add_setting (self, setting);
|
||||
changed = TRUE;
|
||||
} else {
|
||||
const char *token;
|
||||
|
||||
|
|
@ -930,14 +946,27 @@ _normalize_ip_config (NMConnection *self, GHashTable *parameters)
|
|||
changed = TRUE;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (s_ip6) {
|
||||
nm_connection_remove_setting (self, NM_TYPE_SETTING_IP6_CONFIG);
|
||||
changed = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (_supports_addr_family (self, AF_UNSPEC)) {
|
||||
if (!s_proxy) {
|
||||
setting = nm_setting_proxy_new ();
|
||||
nm_connection_add_setting (self, setting);
|
||||
changed = TRUE;
|
||||
}
|
||||
} else {
|
||||
if (s_proxy) {
|
||||
nm_connection_remove_setting (self, NM_TYPE_SETTING_PROXY);
|
||||
changed = TRUE;
|
||||
}
|
||||
|
||||
return !s_ip4 || !s_ip6 || !s_proxy || changed;
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
@ -1288,39 +1317,79 @@ _nm_connection_verify (NMConnection *connection, GError **error)
|
|||
nm_assert (normalizable_error_type != NM_SETTING_VERIFY_ERROR);
|
||||
if (NM_IN_SET (normalizable_error_type, NM_SETTING_VERIFY_SUCCESS,
|
||||
NM_SETTING_VERIFY_NORMALIZABLE)) {
|
||||
if (_without_ip_config (connection)) {
|
||||
if (s_ip4 || s_ip6 || s_proxy) {
|
||||
if (_supports_addr_family (connection, AF_INET)) {
|
||||
if (!s_ip4 && normalizable_error_type == NM_SETTING_VERIFY_SUCCESS) {
|
||||
g_set_error_literal (&normalizable_error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_MISSING_SETTING,
|
||||
_("setting is required for non-slave connections"));
|
||||
g_prefix_error (&normalizable_error, "%s: ", NM_SETTING_IP4_CONFIG_SETTING_NAME);
|
||||
|
||||
/* having a master without IP config was not a verify() error, accept
|
||||
* it for backward compatibility. */
|
||||
normalizable_error_type = NM_SETTING_VERIFY_NORMALIZABLE;
|
||||
}
|
||||
} else {
|
||||
if (s_ip4) {
|
||||
g_clear_error (&normalizable_error);
|
||||
g_set_error_literal (&normalizable_error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_INVALID_SETTING,
|
||||
_("setting not allowed in slave connection"));
|
||||
g_prefix_error (&normalizable_error, "%s: ",
|
||||
s_ip4
|
||||
? NM_SETTING_IP4_CONFIG_SETTING_NAME
|
||||
: (s_ip6
|
||||
? NM_SETTING_IP6_CONFIG_SETTING_NAME
|
||||
: NM_SETTING_PROXY_SETTING_NAME));
|
||||
g_prefix_error (&normalizable_error, "%s: ", NM_SETTING_IP4_CONFIG_SETTING_NAME);
|
||||
/* having a slave with IP config *was* and is a verify() error. */
|
||||
normalizable_error_type = NM_SETTING_VERIFY_NORMALIZABLE_ERROR;
|
||||
}
|
||||
} else {
|
||||
if ( normalizable_error_type == NM_SETTING_VERIFY_SUCCESS
|
||||
&& (!s_ip4 || !s_ip6 || !s_proxy)) {
|
||||
}
|
||||
|
||||
if (_supports_addr_family (connection, AF_INET6)) {
|
||||
if (!s_ip6 && normalizable_error_type == NM_SETTING_VERIFY_SUCCESS) {
|
||||
g_set_error_literal (&normalizable_error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_MISSING_SETTING,
|
||||
_("setting is required for non-slave connections"));
|
||||
g_prefix_error (&normalizable_error, "%s: ",
|
||||
!s_ip4
|
||||
? NM_SETTING_IP4_CONFIG_SETTING_NAME
|
||||
: (!s_ip6
|
||||
? NM_SETTING_IP6_CONFIG_SETTING_NAME
|
||||
: NM_SETTING_PROXY_SETTING_NAME));
|
||||
g_prefix_error (&normalizable_error, "%s: ", NM_SETTING_IP6_CONFIG_SETTING_NAME);
|
||||
|
||||
/* having a master without IP config was not a verify() error, accept
|
||||
* it for backward compatibility. */
|
||||
normalizable_error_type = NM_SETTING_VERIFY_NORMALIZABLE;
|
||||
}
|
||||
} else {
|
||||
if (s_ip6) {
|
||||
g_clear_error (&normalizable_error);
|
||||
g_set_error_literal (&normalizable_error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_INVALID_SETTING,
|
||||
_("setting not allowed in slave connection"));
|
||||
g_prefix_error (&normalizable_error, "%s: ", NM_SETTING_IP6_CONFIG_SETTING_NAME);
|
||||
/* having a slave with IP config *was* and is a verify() error. */
|
||||
normalizable_error_type = NM_SETTING_VERIFY_NORMALIZABLE_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
if (_supports_addr_family (connection, AF_UNSPEC)) {
|
||||
if (!s_proxy && normalizable_error_type == NM_SETTING_VERIFY_SUCCESS) {
|
||||
g_set_error_literal (&normalizable_error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_MISSING_SETTING,
|
||||
_("setting is required for non-slave connections"));
|
||||
g_prefix_error (&normalizable_error, "%s: ", NM_SETTING_PROXY_SETTING_NAME);
|
||||
|
||||
/* having a master without proxy config was not a verify() error, accept
|
||||
* it for backward compatibility. */
|
||||
normalizable_error_type = NM_SETTING_VERIFY_NORMALIZABLE;
|
||||
}
|
||||
} else {
|
||||
if (s_proxy) {
|
||||
g_clear_error (&normalizable_error);
|
||||
g_set_error_literal (&normalizable_error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_INVALID_SETTING,
|
||||
_("setting not allowed in slave connection"));
|
||||
g_prefix_error (&normalizable_error, "%s: ", NM_SETTING_PROXY_SETTING_NAME);
|
||||
/* having a slave with proxy config *was* and is a verify() error. */
|
||||
normalizable_error_type = NM_SETTING_VERIFY_NORMALIZABLE_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2033,7 +2102,8 @@ nm_connection_is_virtual (NMConnection *connection)
|
|||
if (!type)
|
||||
return FALSE;
|
||||
|
||||
if ( !strcmp (type, NM_SETTING_BOND_SETTING_NAME)
|
||||
if ( !strcmp (type, NM_SETTING_6LOWPAN_SETTING_NAME)
|
||||
|| !strcmp (type, NM_SETTING_BOND_SETTING_NAME)
|
||||
|| !strcmp (type, NM_SETTING_DUMMY_SETTING_NAME)
|
||||
|| !strcmp (type, NM_SETTING_TEAM_SETTING_NAME)
|
||||
|| !strcmp (type, NM_SETTING_BRIDGE_SETTING_NAME)
|
||||
|
|
@ -2113,6 +2183,22 @@ nm_connection_get_virtual_device_description (NMConnection *connection)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
* nm_connection_get_setting_6lowpan:
|
||||
* @connection: the #NMConnection
|
||||
*
|
||||
* A shortcut to return any #NMSetting6Lowpan the connection might contain.
|
||||
*
|
||||
* Returns: (transfer none): an #NMSetting6Lowpan if the connection contains one, otherwise %NULL
|
||||
*
|
||||
* Since: 1.14
|
||||
**/
|
||||
NMSetting6Lowpan *
|
||||
nm_connection_get_setting_6lowpan (NMConnection *connection)
|
||||
{
|
||||
return _connection_get_setting_check (connection, NM_TYPE_SETTING_6LOWPAN);
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_connection_get_setting_802_1x:
|
||||
* @connection: the #NMConnection
|
||||
|
|
@ -2679,6 +2765,22 @@ nm_connection_get_setting_vlan (NMConnection *connection)
|
|||
return _connection_get_setting_check (connection, NM_TYPE_SETTING_VLAN);
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_connection_get_setting_wpan:
|
||||
* @connection: the #NMConnection
|
||||
*
|
||||
* A shortcut to return any #NMSettingWpan the connection might contain.
|
||||
*
|
||||
* Returns: (transfer none): an #NMSettingWpan if the connection contains one, otherwise %NULL
|
||||
*
|
||||
* Since: 1.14
|
||||
**/
|
||||
NMSettingWpan *
|
||||
nm_connection_get_setting_wpan (NMConnection *connection)
|
||||
{
|
||||
return _connection_get_setting_check (connection, NM_TYPE_SETTING_WPAN);
|
||||
}
|
||||
|
||||
NMSettingBluetooth *
|
||||
_nm_connection_get_setting_bluetooth_for_nap (NMConnection *connection)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright 2007 - 2017 Red Hat, Inc.
|
||||
* Copyright 2007 - 2018 Red Hat, Inc.
|
||||
* Copyright 2007 - 2008 Novell, Inc.
|
||||
*/
|
||||
|
||||
|
|
@ -193,6 +193,8 @@ const char * nm_connection_get_connection_type (NMConnection *connection);
|
|||
gboolean nm_connection_is_virtual (NMConnection *connection);
|
||||
char * nm_connection_get_virtual_device_description (NMConnection *connection);
|
||||
|
||||
NM_AVAILABLE_IN_1_14
|
||||
NMSetting6Lowpan * nm_connection_get_setting_6lowpan (NMConnection *connection);
|
||||
NMSetting8021x * nm_connection_get_setting_802_1x (NMConnection *connection);
|
||||
NMSettingBluetooth * nm_connection_get_setting_bluetooth (NMConnection *connection);
|
||||
NMSettingBond * nm_connection_get_setting_bond (NMConnection *connection);
|
||||
|
|
@ -241,6 +243,8 @@ NMSettingWirelessSecurity *nm_connection_get_setting_wireless_security (NMConnec
|
|||
NMSettingVlan * nm_connection_get_setting_vlan (NMConnection *connection);
|
||||
NM_AVAILABLE_IN_1_2
|
||||
NMSettingVxlan * nm_connection_get_setting_vxlan (NMConnection *connection);
|
||||
NM_AVAILABLE_IN_1_14
|
||||
NMSettingWpan * nm_connection_get_setting_wpan (NMConnection *connection);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@
|
|||
#include "nm-setting-wired.h"
|
||||
#include "nm-setting-wireless-security.h"
|
||||
#include "nm-setting-wireless.h"
|
||||
#include "nm-setting-wpan.h"
|
||||
#include "nm-setting.h"
|
||||
#include "nm-simple-connection.h"
|
||||
#include "nm-utils.h"
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* (C) Copyright 2014 - 2017 Red Hat, Inc.
|
||||
* (C) Copyright 2014 - 2018 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#ifndef NM_CORE_NM_INTERNAL_H
|
||||
|
|
@ -37,6 +37,7 @@
|
|||
|
||||
#include "nm-connection.h"
|
||||
#include "nm-core-enum-types.h"
|
||||
#include "nm-setting-6lowpan.h"
|
||||
#include "nm-setting-8021x.h"
|
||||
#include "nm-setting-adsl.h"
|
||||
#include "nm-setting-bluetooth.h"
|
||||
|
|
@ -75,6 +76,7 @@
|
|||
#include "nm-setting-wired.h"
|
||||
#include "nm-setting-wireless-security.h"
|
||||
#include "nm-setting-wireless.h"
|
||||
#include "nm-setting-wpan.h"
|
||||
#include "nm-setting.h"
|
||||
#include "nm-simple-connection.h"
|
||||
#include "nm-utils.h"
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright 2014 - 2017 Red Hat, Inc.
|
||||
* Copyright 2014 - 2018 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#ifndef __NM_CORE_TYPES_H__
|
||||
|
|
@ -29,6 +29,7 @@
|
|||
|
||||
typedef struct _NMConnection NMConnection;
|
||||
typedef struct _NMSetting NMSetting;
|
||||
typedef struct _NMSetting6Lowpan NMSetting6Lowpan;
|
||||
typedef struct _NMSetting8021x NMSetting8021x;
|
||||
typedef struct _NMSettingAdsl NMSettingAdsl;
|
||||
typedef struct _NMSettingBluetooth NMSettingBluetooth;
|
||||
|
|
@ -69,6 +70,7 @@ typedef struct _NMSettingWimax NMSettingWimax;
|
|||
typedef struct _NMSettingWired NMSettingWired;
|
||||
typedef struct _NMSettingWireless NMSettingWireless;
|
||||
typedef struct _NMSettingWirelessSecurity NMSettingWirelessSecurity;
|
||||
typedef struct _NMSettingWpan NMSettingWpan;
|
||||
typedef struct _NMSimpleConnection NMSimpleConnection;
|
||||
|
||||
#endif /* __NM_CORE_TYPES_H__ */
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright 2004 - 2017 Red Hat, Inc.
|
||||
* Copyright 2004 - 2018 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
/* Definitions related to NetworkManager's D-Bus interfaces.
|
||||
|
|
@ -75,6 +75,8 @@
|
|||
#define NM_DBUS_INTERFACE_DEVICE_VXLAN NM_DBUS_INTERFACE_DEVICE ".Vxlan"
|
||||
#define NM_DBUS_INTERFACE_DEVICE_GRE NM_DBUS_INTERFACE_DEVICE ".Gre"
|
||||
#define NM_DBUS_INTERFACE_DEVICE_IP_TUNNEL NM_DBUS_INTERFACE_DEVICE ".IPTunnel"
|
||||
#define NM_DBUS_INTERFACE_DEVICE_WPAN NM_DBUS_INTERFACE_DEVICE ".Wpan"
|
||||
#define NM_DBUS_INTERFACE_DEVICE_6LOWPAN NM_DBUS_INTERFACE_DEVICE ".Lowpan"
|
||||
#define NM_DBUS_INTERFACE_DEVICE_STATISTICS NM_DBUS_INTERFACE_DEVICE ".Statistics"
|
||||
#define NM_DBUS_INTERFACE_CHECKPOINT NM_DBUS_INTERFACE ".Checkpoint"
|
||||
|
||||
|
|
@ -212,6 +214,8 @@ typedef enum {
|
|||
* @NM_DEVICE_TYPE_OVS_INTERFACE: a OpenVSwitch interface
|
||||
* @NM_DEVICE_TYPE_OVS_PORT: a OpenVSwitch port
|
||||
* @NM_DEVICE_TYPE_OVS_BRIDGE: a OpenVSwitch bridge
|
||||
* @NM_DEVICE_TYPE_WPAN: a IEEE 802.15.4 (WPAN) MAC Layer Device
|
||||
* @NM_DEVICE_TYPE_6LOWPAN: 6LoWPAN interface
|
||||
*
|
||||
* #NMDeviceType values indicate the type of hardware represented by a
|
||||
* device object.
|
||||
|
|
@ -244,6 +248,8 @@ typedef enum {
|
|||
NM_DEVICE_TYPE_OVS_INTERFACE = 24,
|
||||
NM_DEVICE_TYPE_OVS_PORT = 25,
|
||||
NM_DEVICE_TYPE_OVS_BRIDGE = 26,
|
||||
NM_DEVICE_TYPE_WPAN = 27,
|
||||
NM_DEVICE_TYPE_6LOWPAN = 28,
|
||||
} NMDeviceType;
|
||||
|
||||
/**
|
||||
|
|
|
|||
229
libnm-core/nm-setting-6lowpan.c
Normal file
229
libnm-core/nm-setting-6lowpan.c
Normal file
|
|
@ -0,0 +1,229 @@
|
|||
/*
|
||||
* 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 2018 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#include "nm-default.h"
|
||||
|
||||
#include "nm-setting-private.h"
|
||||
#include "nm-setting-6lowpan.h"
|
||||
|
||||
NM_GOBJECT_PROPERTIES_DEFINE_BASE (
|
||||
PROP_PARENT,
|
||||
);
|
||||
|
||||
typedef struct {
|
||||
char *parent;
|
||||
} NMSetting6LowpanPrivate;
|
||||
|
||||
/**
|
||||
* NMSetting6Lowpan:
|
||||
*
|
||||
* 6LoWPAN Settings
|
||||
*/
|
||||
struct _NMSetting6Lowpan {
|
||||
NMSetting parent;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
NMSettingClass parent;
|
||||
} NMSetting6LowpanClass;
|
||||
|
||||
/**
|
||||
* SECTION:nm-setting-6lowpan
|
||||
* @short_description: Describes connection properties for 6LoWPAN interfaces
|
||||
*
|
||||
* The #NMSetting6Lowpan object is a #NMSetting subclass that describes properties
|
||||
* necessary for connection to 6LoWPAN interfaces.
|
||||
**/
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (NMSetting6Lowpan, nm_setting_6lowpan, NM_TYPE_SETTING,
|
||||
_nm_register_setting (6LOWPAN, NM_SETTING_PRIORITY_HW_BASE))
|
||||
NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_6LOWPAN)
|
||||
|
||||
#define NM_SETTING_6LOWPAN_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_6LOWPAN, NMSetting6LowpanPrivate))
|
||||
|
||||
|
||||
/**
|
||||
* nm_setting_6lowpan_new:
|
||||
*
|
||||
* Creates a new #NMSetting6Lowpan object with default values.
|
||||
*
|
||||
* Returns: (transfer full): the new empty #NMSetting6Lowpan object
|
||||
*
|
||||
* Since: 1.14
|
||||
**/
|
||||
NMSetting *
|
||||
nm_setting_6lowpan_new (void)
|
||||
{
|
||||
return (NMSetting *) g_object_new (NM_TYPE_SETTING_6LOWPAN, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_6lowpan_get_parent:
|
||||
* @setting: the #NMSetting6Lowpan
|
||||
*
|
||||
* Returns: the #NMSetting6Lowpan:parent property of the setting
|
||||
*
|
||||
* Since: 1.14
|
||||
**/
|
||||
const char *
|
||||
nm_setting_6lowpan_get_parent (NMSetting6Lowpan *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_6LOWPAN (setting), NULL);
|
||||
return NM_SETTING_6LOWPAN_GET_PRIVATE (setting)->parent;
|
||||
}
|
||||
|
||||
/*********************************************************************/
|
||||
|
||||
static gboolean
|
||||
verify (NMSetting *setting, NMConnection *connection, GError **error)
|
||||
{
|
||||
NMSetting6LowpanPrivate *priv = NM_SETTING_6LOWPAN_GET_PRIVATE (setting);
|
||||
NMSettingConnection *s_con = NULL;
|
||||
|
||||
if (connection)
|
||||
s_con = nm_connection_get_setting_connection (connection);
|
||||
|
||||
if (!priv->parent) {
|
||||
g_set_error (error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_MISSING_PROPERTY,
|
||||
_("property is not specified"));
|
||||
g_prefix_error (error, "%s.%s: ", NM_SETTING_6LOWPAN_SETTING_NAME, NM_SETTING_6LOWPAN_PARENT);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (nm_utils_is_uuid (priv->parent)) {
|
||||
/* If we have an NMSettingConnection:master with slave-type="6lowpan",
|
||||
* then it must be the same UUID.
|
||||
*/
|
||||
if (s_con) {
|
||||
const char *master = NULL, *slave_type = NULL;
|
||||
|
||||
slave_type = nm_setting_connection_get_slave_type (s_con);
|
||||
if (!g_strcmp0 (slave_type, NM_SETTING_6LOWPAN_SETTING_NAME))
|
||||
master = nm_setting_connection_get_master (s_con);
|
||||
|
||||
if (master && g_strcmp0 (priv->parent, master) != 0) {
|
||||
g_set_error (error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
||||
_("'%s' value doesn't match '%s=%s'"),
|
||||
priv->parent, NM_SETTING_CONNECTION_MASTER, master);
|
||||
g_prefix_error (error, "%s.%s: ", NM_SETTING_6LOWPAN_SETTING_NAME, NM_SETTING_6LOWPAN_PARENT);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
} else if (!nm_utils_iface_valid_name (priv->parent)) {
|
||||
/* parent must be either a UUID or an interface name */
|
||||
g_set_error (error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
||||
_("'%s' is neither an UUID nor an interface name"),
|
||||
priv->parent);
|
||||
g_prefix_error (error, "%s.%s: ", NM_SETTING_6LOWPAN_SETTING_NAME, NM_SETTING_6LOWPAN_PARENT);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
nm_setting_6lowpan_init (NMSetting6Lowpan *setting)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
set_property (GObject *object, guint prop_id,
|
||||
const GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
NMSetting6Lowpan *setting = NM_SETTING_6LOWPAN (object);
|
||||
NMSetting6LowpanPrivate *priv = NM_SETTING_6LOWPAN_GET_PRIVATE (setting);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_PARENT:
|
||||
g_free (priv->parent);
|
||||
priv->parent = g_value_dup_string (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
get_property (GObject *object, guint prop_id,
|
||||
GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
NMSetting6Lowpan *setting = NM_SETTING_6LOWPAN (object);
|
||||
NMSetting6LowpanPrivate *priv = NM_SETTING_6LOWPAN_GET_PRIVATE (setting);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_PARENT:
|
||||
g_value_set_string (value, priv->parent);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
finalize (GObject *object)
|
||||
{
|
||||
NMSetting6Lowpan *setting = NM_SETTING_6LOWPAN (object);
|
||||
NMSetting6LowpanPrivate *priv = NM_SETTING_6LOWPAN_GET_PRIVATE (setting);
|
||||
|
||||
g_free (priv->parent);
|
||||
|
||||
G_OBJECT_CLASS (nm_setting_6lowpan_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
nm_setting_6lowpan_class_init (NMSetting6LowpanClass *setting_class)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (setting_class);
|
||||
NMSettingClass *parent_class = NM_SETTING_CLASS (setting_class);
|
||||
|
||||
g_type_class_add_private (setting_class, sizeof (NMSetting6LowpanPrivate));
|
||||
|
||||
object_class->set_property = set_property;
|
||||
object_class->get_property = get_property;
|
||||
object_class->finalize = finalize;
|
||||
parent_class->verify = verify;
|
||||
|
||||
/**
|
||||
* NMSetting6Lowpan:parent:
|
||||
*
|
||||
* If given, specifies the parent interface name or parent connection UUID
|
||||
* from which this 6LowPAN interface should be created.
|
||||
*
|
||||
* Since: 1.14
|
||||
**/
|
||||
obj_properties[PROP_PARENT] =
|
||||
g_param_spec_string (NM_SETTING_6LOWPAN_PARENT, "", "",
|
||||
NULL,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties);
|
||||
}
|
||||
52
libnm-core/nm-setting-6lowpan.h
Normal file
52
libnm-core/nm-setting-6lowpan.h
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* 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 2018 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#ifndef __NM_SETTING_6LOWPAN_H__
|
||||
#define __NM_SETTING_6LOWPAN_H__
|
||||
|
||||
#if !defined (__NETWORKMANAGER_H_INSIDE__) && !defined (NETWORKMANAGER_COMPILATION)
|
||||
#error "Only <NetworkManager.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include "nm-setting.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define NM_TYPE_SETTING_6LOWPAN (nm_setting_6lowpan_get_type ())
|
||||
#define NM_SETTING_6LOWPAN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTING_6LOWPAN, NMSetting6Lowpan))
|
||||
#define NM_SETTING_6LOWPAN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SETTING_6LOWPANCONFIG, NMSetting6LowpanClass))
|
||||
#define NM_IS_SETTING_6LOWPAN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SETTING_6LOWPAN))
|
||||
#define NM_IS_SETTING_6LOWPAN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SETTING_6LOWPAN))
|
||||
#define NM_SETTING_6LOWPAN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SETTING_6LOWPAN, NMSetting6LowpanClass))
|
||||
|
||||
#define NM_SETTING_6LOWPAN_SETTING_NAME "6lowpan"
|
||||
|
||||
#define NM_SETTING_6LOWPAN_PARENT "parent"
|
||||
|
||||
NM_AVAILABLE_IN_1_14
|
||||
GType nm_setting_6lowpan_get_type (void);
|
||||
NM_AVAILABLE_IN_1_14
|
||||
NMSetting *nm_setting_6lowpan_new (void);
|
||||
|
||||
NM_AVAILABLE_IN_1_14
|
||||
const char *nm_setting_6lowpan_get_parent (NMSetting6Lowpan *setting);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __NM_SETTING_6LOWPAN_H__ */
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright 2007 - 2011 Red Hat, Inc.
|
||||
* Copyright 2007 - 2018 Red Hat, Inc.
|
||||
* Copyright 2007 - 2008 Novell, Inc.
|
||||
*/
|
||||
|
||||
|
|
@ -145,12 +145,6 @@ nm_setting_serial_get_send_delay (NMSettingSerial *setting)
|
|||
return NM_SETTING_SERIAL_GET_PRIVATE (setting)->send_delay;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
verify (NMSetting *setting, NMConnection *connection, GError **error)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
nm_setting_serial_init (NMSettingSerial *setting)
|
||||
{
|
||||
|
|
@ -254,7 +248,6 @@ nm_setting_serial_class_init (NMSettingSerialClass *setting_class)
|
|||
/* virtual methods */
|
||||
object_class->set_property = set_property;
|
||||
object_class->get_property = get_property;
|
||||
parent_class->verify = verify;
|
||||
|
||||
/* Properties */
|
||||
|
||||
|
|
|
|||
273
libnm-core/nm-setting-wpan.c
Normal file
273
libnm-core/nm-setting-wpan.c
Normal file
|
|
@ -0,0 +1,273 @@
|
|||
/*
|
||||
* 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 2018 Lubomir Rintel <lkundrak@v3.sk>
|
||||
*/
|
||||
|
||||
#include "nm-default.h"
|
||||
|
||||
#include "nm-setting-wpan.h"
|
||||
|
||||
#include "nm-connection-private.h"
|
||||
#include "nm-setting-connection.h"
|
||||
#include "nm-setting-private.h"
|
||||
#include "nm-utils-private.h"
|
||||
|
||||
/* Ideally we'll be able to get this from a public header. */
|
||||
#ifndef IEEE802154_ADDR_LEN
|
||||
#define IEEE802154_ADDR_LEN 8
|
||||
#endif
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_MAC_ADDRESS,
|
||||
PROP_PAN_ID,
|
||||
PROP_SHORT_ADDRESS,
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
char *mac_address;
|
||||
guint16 pan_id;
|
||||
guint16 short_address;
|
||||
} NMSettingWpanPrivate;
|
||||
|
||||
/**
|
||||
* NMSettingWpan:
|
||||
*
|
||||
* IEEE 802.15.4 (WPAN) MAC Settings
|
||||
*/
|
||||
struct _NMSettingWpan {
|
||||
NMSetting parent;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
NMSettingClass parent;
|
||||
} NMSettingWpanClass;
|
||||
|
||||
/**
|
||||
* SECTION:nm-setting-wpan
|
||||
* @short_description: Describes connection properties for IEEE 802.15.4 (WPAN) MAC
|
||||
*
|
||||
* The #NMSettingWpan object is a #NMSetting subclass that describes properties
|
||||
* necessary for configuring IEEE 802.15.4 (WPAN) MAC layer devices.
|
||||
**/
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (NMSettingWpan, nm_setting_wpan, NM_TYPE_SETTING,
|
||||
_nm_register_setting (WPAN, NM_SETTING_PRIORITY_HW_BASE))
|
||||
NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_WPAN)
|
||||
|
||||
#define NM_SETTING_WPAN_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_WPAN, NMSettingWpanPrivate))
|
||||
|
||||
/**
|
||||
* nm_setting_wpan_get_mac_address:
|
||||
* @setting: the #NMSettingWpan
|
||||
*
|
||||
* Returns: the #NMSettingWpan:mac-address property of the setting
|
||||
*
|
||||
* Since: 1.14
|
||||
**/
|
||||
const char *
|
||||
nm_setting_wpan_get_mac_address (NMSettingWpan *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_WPAN (setting), NULL);
|
||||
|
||||
return NM_SETTING_WPAN_GET_PRIVATE (setting)->mac_address;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_wpan_get_pan_id:
|
||||
* @setting: the #NMSettingWpan
|
||||
*
|
||||
* Returns: the #NMSettingWpan:pan-id property of the setting
|
||||
*
|
||||
* Since: 1.14
|
||||
**/
|
||||
guint16
|
||||
nm_setting_wpan_get_pan_id (NMSettingWpan *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_WPAN (setting), G_MAXUINT16);
|
||||
|
||||
return NM_SETTING_WPAN_GET_PRIVATE (setting)->pan_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_wpan_get_short_address:
|
||||
* @setting: the #NMSettingWpan
|
||||
*
|
||||
* Returns: the #NMSettingWpan:short-address property of the setting
|
||||
*
|
||||
* Since: 1.14
|
||||
**/
|
||||
guint16
|
||||
nm_setting_wpan_get_short_address (NMSettingWpan *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_WPAN (setting), G_MAXUINT16);
|
||||
|
||||
return NM_SETTING_WPAN_GET_PRIVATE (setting)->short_address;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
verify (NMSetting *setting, NMConnection *connection, GError **error)
|
||||
{
|
||||
NMSettingWpanPrivate *priv = NM_SETTING_WPAN_GET_PRIVATE (setting);
|
||||
|
||||
if (priv->mac_address && !nm_utils_hwaddr_valid (priv->mac_address, IEEE802154_ADDR_LEN)) {
|
||||
g_set_error_literal (error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
||||
_("property is invalid"));
|
||||
g_prefix_error (error, "%s.%s: ", NM_SETTING_WPAN_SETTING_NAME, NM_SETTING_WPAN_MAC_ADDRESS);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
NMSettingWpan *setting = NM_SETTING_WPAN (object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_MAC_ADDRESS:
|
||||
g_value_set_string (value, nm_setting_wpan_get_mac_address (setting));
|
||||
break;
|
||||
case PROP_PAN_ID:
|
||||
g_value_set_uint (value, nm_setting_wpan_get_pan_id (setting));
|
||||
break;
|
||||
case PROP_SHORT_ADDRESS:
|
||||
g_value_set_uint (value, nm_setting_wpan_get_short_address (setting));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
NMSettingWpanPrivate *priv = NM_SETTING_WPAN_GET_PRIVATE (object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_MAC_ADDRESS:
|
||||
g_free (priv->mac_address);
|
||||
priv->mac_address = _nm_utils_hwaddr_canonical_or_invalid (g_value_get_string (value),
|
||||
IEEE802154_ADDR_LEN);
|
||||
break;
|
||||
case PROP_PAN_ID:
|
||||
priv->pan_id = g_value_get_uint (value);
|
||||
break;
|
||||
case PROP_SHORT_ADDRESS:
|
||||
priv->short_address = g_value_get_uint (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
nm_setting_wpan_init (NMSettingWpan *setting)
|
||||
{
|
||||
NMSettingWpanPrivate *priv = NM_SETTING_WPAN_GET_PRIVATE (setting);
|
||||
|
||||
priv->short_address = G_MAXUINT16;
|
||||
priv->pan_id = G_MAXUINT16;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_wpan_new:
|
||||
*
|
||||
* Creates a new #NMSettingWpan object with default values.
|
||||
*
|
||||
* Returns: (transfer full): the new empty #NMSettingWpan object
|
||||
*
|
||||
* Since: 1.14
|
||||
**/
|
||||
NMSetting *
|
||||
nm_setting_wpan_new (void)
|
||||
{
|
||||
return (NMSetting *) g_object_new (NM_TYPE_SETTING_WPAN, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
finalize (GObject *object)
|
||||
{
|
||||
NMSettingWpanPrivate *priv = NM_SETTING_WPAN_GET_PRIVATE (object);
|
||||
|
||||
g_free (priv->mac_address);
|
||||
|
||||
G_OBJECT_CLASS (nm_setting_wpan_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
nm_setting_wpan_class_init (NMSettingWpanClass *setting_wpan_class)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (setting_wpan_class);
|
||||
NMSettingClass *setting_class = NM_SETTING_CLASS (setting_wpan_class);
|
||||
|
||||
g_type_class_add_private (setting_class, sizeof (NMSettingWpanPrivate));
|
||||
|
||||
object_class->set_property = set_property;
|
||||
object_class->get_property = get_property;
|
||||
object_class->finalize = finalize;
|
||||
setting_class->verify = verify;
|
||||
|
||||
/**
|
||||
* NMSettingWpan:mac-address:
|
||||
*
|
||||
* If specified, this connection will only apply to the IEEE 802.15.4 (WPAN)
|
||||
* MAC layer device whose permanent MAC address matches.
|
||||
**/
|
||||
/* ---keyfile---
|
||||
* property: mac-address
|
||||
* format: usual hex-digits-and-colons notation
|
||||
* description: MAC address in hex-digits-and-colons notation
|
||||
* (e.g. 76:d8:9b:87:66:60:84:ee).
|
||||
* ---end---
|
||||
*/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_MAC_ADDRESS,
|
||||
g_param_spec_string (NM_SETTING_WPAN_MAC_ADDRESS, "", "",
|
||||
NULL,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
/**
|
||||
* NMSettingWpan:pan-id:
|
||||
*
|
||||
* IEEE 802.15.4 Personal Area Network (PAN) identifier.
|
||||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_PAN_ID,
|
||||
g_param_spec_uint (NM_SETTING_WPAN_PAN_ID, "", "",
|
||||
0, G_MAXUINT16, G_MAXUINT16,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
/**
|
||||
* NMSettingWpan:short-address:
|
||||
*
|
||||
* Short IEEE 802.15.4 address to be used within a restricted environment.
|
||||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_SHORT_ADDRESS,
|
||||
g_param_spec_uint (NM_SETTING_WPAN_SHORT_ADDRESS, "", "",
|
||||
0, G_MAXUINT16, G_MAXUINT16,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
}
|
||||
57
libnm-core/nm-setting-wpan.h
Normal file
57
libnm-core/nm-setting-wpan.h
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* 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 2018 Lubomir Rintel <lkundrak@v3.sk>
|
||||
*/
|
||||
|
||||
#ifndef __NM_SETTING_WPAN_H__
|
||||
#define __NM_SETTING_WPAN_H__
|
||||
|
||||
#if !defined (__NETWORKMANAGER_H_INSIDE__) && !defined (NETWORKMANAGER_COMPILATION)
|
||||
#error "Only <NetworkManager.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include "nm-setting.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define NM_TYPE_SETTING_WPAN (nm_setting_wpan_get_type ())
|
||||
#define NM_SETTING_WPAN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTING_WPAN, NMSettingWpan))
|
||||
#define NM_SETTING_WPAN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SETTING_WPANCONFIG, NMSettingWpanClass))
|
||||
#define NM_IS_SETTING_WPAN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SETTING_WPAN))
|
||||
#define NM_IS_SETTING_WPAN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SETTING_WPAN))
|
||||
#define NM_SETTING_WPAN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SETTING_WPAN, NMSettingWpanClass))
|
||||
|
||||
#define NM_SETTING_WPAN_SETTING_NAME "wpan"
|
||||
#define NM_SETTING_WPAN_MAC_ADDRESS "mac-address"
|
||||
#define NM_SETTING_WPAN_PAN_ID "pan-id"
|
||||
#define NM_SETTING_WPAN_SHORT_ADDRESS "short-address"
|
||||
|
||||
NM_AVAILABLE_IN_1_14
|
||||
GType nm_setting_wpan_get_type (void);
|
||||
NM_AVAILABLE_IN_1_14
|
||||
NMSetting *nm_setting_wpan_new (void);
|
||||
|
||||
NM_AVAILABLE_IN_1_14
|
||||
const char *nm_setting_wpan_get_mac_address (NMSettingWpan *setting);
|
||||
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);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __NM_SETTING_WPAN_H__ */
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright 2008 - 2011 Red Hat, Inc.
|
||||
* Copyright 2008 - 2018 Red Hat, Inc.
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
@ -61,6 +61,7 @@
|
|||
#include "nm-setting-wired.h"
|
||||
#include "nm-setting-wireless.h"
|
||||
#include "nm-setting-wireless-security.h"
|
||||
#include "nm-setting-wpan.h"
|
||||
#include "nm-simple-connection.h"
|
||||
#include "nm-keyfile-internal.h"
|
||||
#include "nm-utils/nm-dedup-multi.h"
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright 2014 - 2017 Red Hat, Inc.
|
||||
* Copyright 2014 - 2018 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#ifndef __NETWORKMANAGER_H__
|
||||
|
|
@ -29,6 +29,7 @@
|
|||
#include "nm-connection.h"
|
||||
#include "nm-core-enum-types.h"
|
||||
#include "nm-dbus-interface.h"
|
||||
#include "nm-device-6lowpan.h"
|
||||
#include "nm-device-adsl.h"
|
||||
#include "nm-device-bond.h"
|
||||
#include "nm-device-bridge.h"
|
||||
|
|
@ -52,12 +53,14 @@
|
|||
#include "nm-device-vxlan.h"
|
||||
#include "nm-device-wifi.h"
|
||||
#include "nm-device-wimax.h"
|
||||
#include "nm-device-wpan.h"
|
||||
#include "nm-device.h"
|
||||
#include "nm-dhcp-config.h"
|
||||
#include "nm-enum-types.h"
|
||||
#include "nm-ip-config.h"
|
||||
#include "nm-object.h"
|
||||
#include "nm-remote-connection.h"
|
||||
#include "nm-setting-6lowpan.h"
|
||||
#include "nm-setting-8021x.h"
|
||||
#include "nm-setting-adsl.h"
|
||||
#include "nm-setting-bluetooth.h"
|
||||
|
|
@ -98,6 +101,7 @@
|
|||
#include "nm-setting-wired.h"
|
||||
#include "nm-setting-wireless.h"
|
||||
#include "nm-setting-wireless-security.h"
|
||||
#include "nm-setting-wpan.h"
|
||||
#include "nm-setting.h"
|
||||
#include "nm-simple-connection.h"
|
||||
#include "nm-utils.h"
|
||||
|
|
|
|||
|
|
@ -1349,11 +1349,14 @@ global:
|
|||
nm_client_checkpoint_rollback_finish;
|
||||
nm_client_get_checkpoints;
|
||||
nm_connection_get_setting_tc_config;
|
||||
nm_device_6lowpan_get_type;
|
||||
nm_device_ip_tunnel_get_flags;
|
||||
nm_device_wifi_get_last_scan;
|
||||
nm_device_wpan_get_type;
|
||||
nm_ip_tunnel_flags_get_type;
|
||||
nm_remote_connection_get_filename;
|
||||
nm_remote_connection_get_flags;
|
||||
nm_setting_6lowpan_get_type;
|
||||
nm_setting_connection_get_mdns;
|
||||
nm_setting_connection_mdns_get_type;
|
||||
nm_setting_ip_tunnel_get_flags;
|
||||
|
|
@ -1365,6 +1368,7 @@ global:
|
|||
nm_setting_wireless_security_fils_get_type;
|
||||
nm_setting_wireless_get_wake_on_wlan;
|
||||
nm_setting_wireless_wake_on_wlan_get_type;
|
||||
nm_setting_wpan_get_type;
|
||||
nm_settings_connection_flags_get_type;
|
||||
nm_utils_get_timestamp_msec;
|
||||
nm_vpn_service_plugin_shutdown;
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ libnm_headers = files(
|
|||
'nm-autoptr.h',
|
||||
'nm-checkpoint.h',
|
||||
'nm-client.h',
|
||||
'nm-device-6lowpan.h',
|
||||
'nm-device-adsl.h',
|
||||
'nm-device-bond.h',
|
||||
'nm-device-bridge.h',
|
||||
|
|
@ -56,6 +57,7 @@ libnm_headers = files(
|
|||
'nm-device-vxlan.h',
|
||||
'nm-device-wifi.h',
|
||||
'nm-device-wimax.h',
|
||||
'nm-device-wpan.h',
|
||||
'nm-dhcp-config.h',
|
||||
'nm-ip-config.h',
|
||||
'nm-object.h',
|
||||
|
|
@ -93,6 +95,7 @@ libnm_sources = files(
|
|||
'nm-checkpoint.c',
|
||||
'nm-client.c',
|
||||
'nm-dbus-helpers.c',
|
||||
'nm-device-6lowpan.c',
|
||||
'nm-device-adsl.c',
|
||||
'nm-device-bond.c',
|
||||
'nm-device-bridge.c',
|
||||
|
|
@ -117,6 +120,7 @@ libnm_sources = files(
|
|||
'nm-device-vxlan.c',
|
||||
'nm-device-wifi.c',
|
||||
'nm-device-wimax.c',
|
||||
'nm-device-wpan.c',
|
||||
'nm-dhcp-config.c',
|
||||
'nm-dhcp4-config.c',
|
||||
'nm-dhcp6-config.c',
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
* Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright 2007 - 2008 Novell, Inc.
|
||||
* Copyright 2007 - 2014 Red Hat, Inc.
|
||||
* Copyright 2007 - 2018 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#include "nm-default.h"
|
||||
|
|
@ -51,6 +51,7 @@
|
|||
#include "nm-access-point.h"
|
||||
#include "nm-active-connection.h"
|
||||
#include "nm-checkpoint.h"
|
||||
#include "nm-device-6lowpan.h"
|
||||
#include "nm-device-adsl.h"
|
||||
#include "nm-device-bond.h"
|
||||
#include "nm-device-bridge.h"
|
||||
|
|
@ -74,6 +75,7 @@
|
|||
#include "nm-device-vxlan.h"
|
||||
#include "nm-device-wifi.h"
|
||||
#include "nm-device-wimax.h"
|
||||
#include "nm-device-wpan.h"
|
||||
#include "nm-dhcp4-config.h"
|
||||
#include "nm-dhcp6-config.h"
|
||||
#include "nm-dhcp-config.h"
|
||||
|
|
@ -2523,6 +2525,8 @@ obj_nm_for_gdbus_object (NMClient *self, GDBusObject *object, GDBusObjectManager
|
|||
type = NM_TYPE_ACCESS_POINT;
|
||||
else if (strcmp (ifname, NM_DBUS_INTERFACE_ACTIVE_CONNECTION) == 0 && type != NM_TYPE_VPN_CONNECTION)
|
||||
type = NM_TYPE_ACTIVE_CONNECTION;
|
||||
else if (strcmp (ifname, NM_DBUS_INTERFACE_DEVICE_6LOWPAN) == 0)
|
||||
type = NM_TYPE_DEVICE_6LOWPAN;
|
||||
else if (strcmp (ifname, NM_DBUS_INTERFACE_DEVICE_ADSL) == 0)
|
||||
type = NM_TYPE_DEVICE_ADSL;
|
||||
else if (strcmp (ifname, NM_DBUS_INTERFACE_DEVICE_BOND) == 0)
|
||||
|
|
@ -2563,6 +2567,8 @@ obj_nm_for_gdbus_object (NMClient *self, GDBusObject *object, GDBusObjectManager
|
|||
type = NM_TYPE_DEVICE_TUN;
|
||||
else if (strcmp (ifname, NM_DBUS_INTERFACE_DEVICE_VLAN) == 0)
|
||||
type = NM_TYPE_DEVICE_VLAN;
|
||||
else if (strcmp (ifname, NM_DBUS_INTERFACE_DEVICE_WPAN) == 0)
|
||||
type = NM_TYPE_DEVICE_WPAN;
|
||||
else if (strcmp (ifname, NM_DBUS_INTERFACE_DEVICE_VXLAN) == 0)
|
||||
type = NM_TYPE_DEVICE_VXLAN;
|
||||
else if (strcmp (ifname, NM_DBUS_INTERFACE_DEVICE_WIRELESS) == 0)
|
||||
|
|
|
|||
193
libnm/nm-device-6lowpan.c
Normal file
193
libnm/nm-device-6lowpan.c
Normal file
|
|
@ -0,0 +1,193 @@
|
|||
/*
|
||||
* 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 2018 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#include "nm-default.h"
|
||||
|
||||
#include "nm-device-6lowpan.h"
|
||||
#include "nm-object-private.h"
|
||||
|
||||
typedef struct {
|
||||
NMDevice *parent;
|
||||
char *hw_address;
|
||||
} NMDevice6LowpanPrivate;
|
||||
|
||||
/**
|
||||
* NMDevice6Lowpan:
|
||||
*/
|
||||
struct _NMDevice6Lowpan {
|
||||
NMDevice parent;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
NMDeviceClass parent;
|
||||
|
||||
/*< private >*/
|
||||
gpointer padding[4];
|
||||
} NMDevice6LowpanClass;
|
||||
|
||||
G_DEFINE_TYPE (NMDevice6Lowpan, nm_device_6lowpan, NM_TYPE_DEVICE)
|
||||
|
||||
#define NM_DEVICE_6LOWPAN_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_6LOWPAN, NMDevice6LowpanPrivate))
|
||||
|
||||
NM_GOBJECT_PROPERTIES_DEFINE_BASE (
|
||||
PROP_PARENT,
|
||||
PROP_HW_ADDRESS,
|
||||
);
|
||||
|
||||
/**
|
||||
* nm_device_6lowpan_get_parent:
|
||||
* @device: a #NMDevice6Lowpan
|
||||
*
|
||||
* Returns: (transfer none): the device's parent device
|
||||
*
|
||||
* Since: 1.14
|
||||
**/
|
||||
NMDevice *
|
||||
nm_device_6lowpan_get_parent (NMDevice6Lowpan *device)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_DEVICE_6LOWPAN (device), NULL);
|
||||
|
||||
return NM_DEVICE_6LOWPAN_GET_PRIVATE (device)->parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_device_6lowpan_get_hw_address:
|
||||
* @device: a #NMDevice6Lowpan
|
||||
*
|
||||
* Gets the hardware (MAC) address of the #NMDevice6Lowpan
|
||||
*
|
||||
* Returns: the hardware address. This is the internal string used by the
|
||||
* device, and must not be modified.
|
||||
*
|
||||
* Since: 1.14
|
||||
**/
|
||||
const char *
|
||||
nm_device_6lowpan_get_hw_address (NMDevice6Lowpan *device)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_DEVICE_6LOWPAN (device), NULL);
|
||||
|
||||
return NM_DEVICE_6LOWPAN_GET_PRIVATE (device)->hw_address;
|
||||
}
|
||||
|
||||
static const char *
|
||||
get_hw_address (NMDevice *device)
|
||||
{
|
||||
return nm_device_6lowpan_get_hw_address (NM_DEVICE_6LOWPAN (device));
|
||||
}
|
||||
|
||||
/***********************************************************/
|
||||
|
||||
static void
|
||||
nm_device_6lowpan_init (NMDevice6Lowpan *device)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
init_dbus (NMObject *object)
|
||||
{
|
||||
NMDevice6LowpanPrivate *priv = NM_DEVICE_6LOWPAN_GET_PRIVATE (object);
|
||||
const NMPropertiesInfo property_info[] = {
|
||||
{ NM_DEVICE_6LOWPAN_PARENT, &priv->parent, NULL, NM_TYPE_DEVICE },
|
||||
{ NM_DEVICE_6LOWPAN_HW_ADDRESS, &priv->hw_address },
|
||||
{ NULL },
|
||||
};
|
||||
|
||||
NM_OBJECT_CLASS (nm_device_6lowpan_parent_class)->init_dbus (object);
|
||||
|
||||
_nm_object_register_properties (object,
|
||||
NM_DBUS_INTERFACE_DEVICE_6LOWPAN,
|
||||
property_info);
|
||||
}
|
||||
|
||||
static void
|
||||
finalize (GObject *object)
|
||||
{
|
||||
NMDevice6LowpanPrivate *priv = NM_DEVICE_6LOWPAN_GET_PRIVATE (object);
|
||||
|
||||
g_free (priv->hw_address);
|
||||
g_clear_object (&priv->parent);
|
||||
|
||||
G_OBJECT_CLASS (nm_device_6lowpan_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
NMDevice6Lowpan *device = NM_DEVICE_6LOWPAN (object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_PARENT:
|
||||
g_value_set_object (value, nm_device_6lowpan_get_parent (device));
|
||||
break;
|
||||
case PROP_HW_ADDRESS:
|
||||
g_value_set_string (value, nm_device_6lowpan_get_hw_address (device));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
nm_device_6lowpan_class_init (NMDevice6LowpanClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
NMObjectClass *nm_object_class = NM_OBJECT_CLASS (klass);
|
||||
NMDeviceClass *device_class = NM_DEVICE_CLASS (klass);
|
||||
|
||||
g_type_class_add_private (klass, sizeof (NMDevice6LowpanPrivate));
|
||||
|
||||
object_class->finalize = finalize;
|
||||
object_class->get_property = get_property;
|
||||
|
||||
nm_object_class->init_dbus = init_dbus;
|
||||
|
||||
device_class->get_hw_address = get_hw_address;
|
||||
|
||||
/**
|
||||
* NMDevice6Lowpan:parent:
|
||||
*
|
||||
* The devices's parent device.
|
||||
*
|
||||
* Since: 1.14
|
||||
**/
|
||||
obj_properties[PROP_PARENT] =
|
||||
g_param_spec_object (NM_DEVICE_6LOWPAN_PARENT, "", "",
|
||||
NM_TYPE_DEVICE,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
* NMDevice6Lowpan:hw-address:
|
||||
*
|
||||
* The hardware (MAC) address of the device.
|
||||
*
|
||||
* Since: 1.14
|
||||
**/
|
||||
obj_properties[PROP_HW_ADDRESS] =
|
||||
g_param_spec_string (NM_DEVICE_6LOWPAN_HW_ADDRESS, "", "",
|
||||
NULL,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties);
|
||||
}
|
||||
50
libnm/nm-device-6lowpan.h
Normal file
50
libnm/nm-device-6lowpan.h
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* 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 2018 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#ifndef __NM_DEVICE_6LOWPAN_H__
|
||||
#define __NM_DEVICE_6LOWPAN_H__
|
||||
|
||||
#if !defined (__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION)
|
||||
#error "Only <NetworkManager.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include "nm-device.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define NM_TYPE_DEVICE_6LOWPAN (nm_device_6lowpan_get_type ())
|
||||
#define NM_DEVICE_6LOWPAN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DEVICE_6LOWPAN, NMDevice6Lowpan))
|
||||
#define NM_DEVICE_6LOWPAN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DEVICE_6LOWPAN, NMDevice6LowpanClass))
|
||||
#define NM_IS_DEVICE_6LOWPAN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DEVICE_6LOWPAN))
|
||||
#define NM_IS_DEVICE_6LOWPAN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_6LOWPAN))
|
||||
#define NM_DEVICE_6LOWPAN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_6LOWPAN, NMDevice6LowpanClass))
|
||||
|
||||
#define NM_DEVICE_6LOWPAN_PARENT "parent"
|
||||
#define NM_DEVICE_6LOWPAN_HW_ADDRESS "hw-address"
|
||||
|
||||
NM_AVAILABLE_IN_1_14
|
||||
GType nm_device_6lowpan_get_type (void);
|
||||
|
||||
NM_AVAILABLE_IN_1_14
|
||||
NMDevice * nm_device_6lowpan_get_parent (NMDevice6Lowpan *device);
|
||||
NM_AVAILABLE_IN_1_14
|
||||
const char * nm_device_6lowpan_get_hw_address (NMDevice6Lowpan *device);
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __NM_DEVICE_6LOWPAN_H__ */
|
||||
179
libnm/nm-device-wpan.c
Normal file
179
libnm/nm-device-wpan.c
Normal file
|
|
@ -0,0 +1,179 @@
|
|||
/*
|
||||
* 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 2018 Lubomir Rintel <lkundrak@v3.sk>
|
||||
*/
|
||||
|
||||
#include "nm-default.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "nm-device-wpan.h"
|
||||
#include "nm-object-private.h"
|
||||
#include "nm-setting-wpan.h"
|
||||
#include "nm-setting-connection.h"
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_HW_ADDRESS,
|
||||
|
||||
LAST_PROP
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
char *hw_address;
|
||||
} NMDeviceWpanPrivate;
|
||||
|
||||
/**
|
||||
* NMDeviceWpan:
|
||||
*/
|
||||
struct _NMDeviceWpan {
|
||||
NMDevice parent;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
NMDeviceClass parent;
|
||||
} NMDeviceWpanClass;
|
||||
|
||||
G_DEFINE_TYPE (NMDeviceWpan, nm_device_wpan, NM_TYPE_DEVICE)
|
||||
|
||||
#define NM_DEVICE_WPAN_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_WPAN, NMDeviceWpanPrivate))
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
* nm_device_wpan_get_hw_address:
|
||||
* @device: a #NMDeviceWpan
|
||||
*
|
||||
* Gets the active hardware (MAC) address of the #NMDeviceWpan
|
||||
*
|
||||
* Returns: the active hardware address. This is the internal string used by the
|
||||
* device, and must not be modified.
|
||||
**/
|
||||
const char *
|
||||
nm_device_wpan_get_hw_address (NMDeviceWpan *device)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_DEVICE_WPAN (device), NULL);
|
||||
|
||||
return nm_str_not_empty (NM_DEVICE_WPAN_GET_PRIVATE (device)->hw_address);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
connection_compatible (NMDevice *device, NMConnection *connection, GError **error)
|
||||
{
|
||||
if (!NM_DEVICE_CLASS (nm_device_wpan_parent_class)->connection_compatible (device, connection, error))
|
||||
return FALSE;
|
||||
|
||||
if (!nm_connection_is_type (connection, NM_SETTING_WPAN_SETTING_NAME)) {
|
||||
g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION,
|
||||
_("The connection was not a wpan connection."));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static GType
|
||||
get_setting_type (NMDevice *device)
|
||||
{
|
||||
return NM_TYPE_SETTING_WPAN;
|
||||
}
|
||||
|
||||
static const char *
|
||||
get_hw_address (NMDevice *device)
|
||||
{
|
||||
return nm_device_wpan_get_hw_address (NM_DEVICE_WPAN (device));
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
switch (prop_id) {
|
||||
case PROP_HW_ADDRESS:
|
||||
g_value_set_string (value, nm_device_wpan_get_hw_address (NM_DEVICE_WPAN (object)));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
nm_device_wpan_init (NMDeviceWpan *device)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
init_dbus (NMObject *object)
|
||||
{
|
||||
NMDeviceWpanPrivate *priv = NM_DEVICE_WPAN_GET_PRIVATE (object);
|
||||
const NMPropertiesInfo property_info[] = {
|
||||
{ NM_DEVICE_WPAN_HW_ADDRESS, &priv->hw_address },
|
||||
{ NULL },
|
||||
};
|
||||
|
||||
NM_OBJECT_CLASS (nm_device_wpan_parent_class)->init_dbus (object);
|
||||
|
||||
_nm_object_register_properties (object,
|
||||
NM_DBUS_INTERFACE_DEVICE_WPAN,
|
||||
property_info);
|
||||
}
|
||||
|
||||
static void
|
||||
finalize (GObject *object)
|
||||
{
|
||||
NMDeviceWpanPrivate *priv = NM_DEVICE_WPAN_GET_PRIVATE (object);
|
||||
|
||||
g_free (priv->hw_address);
|
||||
|
||||
G_OBJECT_CLASS (nm_device_wpan_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
nm_device_wpan_class_init (NMDeviceWpanClass *wpan_class)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (wpan_class);
|
||||
NMObjectClass *nm_object_class = NM_OBJECT_CLASS (wpan_class);
|
||||
NMDeviceClass *device_class = NM_DEVICE_CLASS (wpan_class);
|
||||
|
||||
g_type_class_add_private (wpan_class, sizeof (NMDeviceWpanPrivate));
|
||||
|
||||
/* virtual methods */
|
||||
object_class->finalize = finalize;
|
||||
object_class->get_property = get_property;
|
||||
|
||||
nm_object_class->init_dbus = init_dbus;
|
||||
|
||||
device_class->connection_compatible = connection_compatible;
|
||||
device_class->get_setting_type = get_setting_type;
|
||||
device_class->get_hw_address = get_hw_address;
|
||||
|
||||
/* properties */
|
||||
|
||||
/**
|
||||
* NMDeviceWpan:hw-address:
|
||||
*
|
||||
* The active hardware (MAC) address of the device.
|
||||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_HW_ADDRESS,
|
||||
g_param_spec_string (NM_DEVICE_WPAN_HW_ADDRESS, "", "",
|
||||
NULL,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
}
|
||||
48
libnm/nm-device-wpan.h
Normal file
48
libnm/nm-device-wpan.h
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* 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 2018 Lubomir Rintel <lkundrak@v3.sk>
|
||||
*/
|
||||
|
||||
#ifndef __NM_DEVICE_WPAN_H__
|
||||
#define __NM_DEVICE_WPAN_H__
|
||||
|
||||
#if !defined (__NETWORKMANAGER_H_INSIDE__) && !defined (NETWORKMANAGER_COMPILATION)
|
||||
#error "Only <NetworkManager.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include "nm-device.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define NM_TYPE_DEVICE_WPAN (nm_device_wpan_get_type ())
|
||||
#define NM_DEVICE_WPAN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DEVICE_WPAN, NMDeviceWpan))
|
||||
#define NM_DEVICE_WPAN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DEVICE_WPAN, NMDeviceWpanClass))
|
||||
#define NM_IS_DEVICE_WPAN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DEVICE_WPAN))
|
||||
#define NM_IS_DEVICE_WPAN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_WPAN))
|
||||
#define NM_DEVICE_WPAN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_WPAN, NMDeviceWpanClass))
|
||||
|
||||
#define NM_DEVICE_WPAN_HW_ADDRESS "hw-address"
|
||||
|
||||
NM_AVAILABLE_IN_1_14
|
||||
GType nm_device_wpan_get_type (void);
|
||||
|
||||
NM_AVAILABLE_IN_1_14
|
||||
const char *nm_device_wpan_get_hw_address (NMDeviceWpan *device);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __NM_DEVICE_WPAN_H__ */
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
* Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright 2007 - 2008 Novell, Inc.
|
||||
* Copyright 2007 - 2012 Red Hat, Inc.
|
||||
* Copyright 2007 - 2018 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#include "nm-default.h"
|
||||
|
|
@ -284,6 +284,8 @@ coerce_type (NMDeviceType type)
|
|||
case NM_DEVICE_TYPE_UNKNOWN:
|
||||
case NM_DEVICE_TYPE_DUMMY:
|
||||
case NM_DEVICE_TYPE_PPP:
|
||||
case NM_DEVICE_TYPE_WPAN:
|
||||
case NM_DEVICE_TYPE_6LOWPAN:
|
||||
return type;
|
||||
}
|
||||
return NM_DEVICE_TYPE_UNKNOWN;
|
||||
|
|
@ -1345,6 +1347,10 @@ get_type_name (NMDevice *device)
|
|||
return _("Dummy");
|
||||
case NM_DEVICE_TYPE_PPP:
|
||||
return _("PPP");
|
||||
case NM_DEVICE_TYPE_WPAN:
|
||||
return _("IEEE 802.15.4");
|
||||
case NM_DEVICE_TYPE_6LOWPAN:
|
||||
return _("6LoWPAN");
|
||||
case NM_DEVICE_TYPE_GENERIC:
|
||||
case NM_DEVICE_TYPE_UNUSED1:
|
||||
case NM_DEVICE_TYPE_UNUSED2:
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright 2014 Red Hat, Inc.
|
||||
* Copyright 2014 - 2018 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#ifndef __NM_TYPES_H__
|
||||
|
|
@ -31,6 +31,7 @@ typedef struct _NMActiveConnection NMActiveConnection;
|
|||
typedef struct _NMCheckpoint NMCheckpoint;
|
||||
typedef struct _NMClient NMClient;
|
||||
typedef struct _NMDevice NMDevice;
|
||||
typedef struct _NMDevice6Lowpan NMDevice6Lowpan;
|
||||
typedef struct _NMDeviceAdsl NMDeviceAdsl;
|
||||
typedef struct _NMDeviceBond NMDeviceBond;
|
||||
typedef struct _NMDeviceBridge NMDeviceBridge;
|
||||
|
|
@ -54,6 +55,7 @@ typedef struct _NMDeviceVlan NMDeviceVlan;
|
|||
typedef struct _NMDeviceVxlan NMDeviceVxlan;
|
||||
typedef struct _NMDeviceWifi NMDeviceWifi;
|
||||
typedef struct _NMDeviceWimax NMDeviceWimax;
|
||||
typedef struct _NMDeviceWpan NMDeviceWpan;
|
||||
typedef struct _NMDhcpConfig NMDhcpConfig;
|
||||
typedef struct _NMIPConfig NMIPConfig;
|
||||
typedef struct _NMObject NMObject;
|
||||
|
|
|
|||
|
|
@ -2003,6 +2003,26 @@ It's equivalent to the <literal>+bond.options 'option=value'</literal> syntax.</
|
|||
</tbody>
|
||||
</tgroup></table>
|
||||
|
||||
<table><title>WPAN options</title><tgroup cols="2">
|
||||
<thead>
|
||||
<row><entry>Alias</entry><entry>Property</entry></row>
|
||||
</thead>
|
||||
<tbody>
|
||||
<row><entry align="left">mac</entry><entry align="left"><link linkend="nm-settings.property.wpan.mac">wpan.mac</link></entry></row>
|
||||
<row><entry align="left">short-addr</entry><entry align="left"><link linkend="nm-settings.property.wpan.short-addr">wpan.short-addr</link></entry></row>
|
||||
<row><entry align="left">pan-id</entry><entry align="left"><link linkend="nm-settings.property.wpan.pan-id">wpan.pan-id</link></entry></row>
|
||||
</tbody>
|
||||
</tgroup></table>
|
||||
|
||||
<table><title>6LoWPAN options</title><tgroup cols="2">
|
||||
<thead>
|
||||
<row><entry>Alias</entry><entry>Property</entry></row>
|
||||
</thead>
|
||||
<tbody>
|
||||
<row><entry align="left">dev</entry><entry align="left"><link linkend="nm-settings.property.6lowpan.dev">6lowpan.parent</link></entry></row>
|
||||
</tbody>
|
||||
</tgroup></table>
|
||||
|
||||
<table><title>IPv4 options</title><tgroup cols="3">
|
||||
<thead>
|
||||
<row><entry>Alias</entry><entry>Property</entry><entry>Note</entry></row>
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ libnm-core/crypto_nss.c
|
|||
libnm-core/nm-connection.c
|
||||
libnm-core/nm-dbus-utils.c
|
||||
libnm-core/nm-keyfile.c
|
||||
libnm-core/nm-setting-6lowpan.c
|
||||
libnm-core/nm-setting-8021x.c
|
||||
libnm-core/nm-setting-adsl.c
|
||||
libnm-core/nm-setting-bluetooth.c
|
||||
|
|
@ -94,6 +95,7 @@ libnm-core/nm-setting-wimax.c
|
|||
libnm-core/nm-setting-wired.c
|
||||
libnm-core/nm-setting-wireless-security.c
|
||||
libnm-core/nm-setting-wireless.c
|
||||
libnm-core/nm-setting-wpan.c
|
||||
libnm-core/nm-setting.c
|
||||
libnm-core/nm-utils.c
|
||||
libnm-core/nm-vpn-editor-plugin.c
|
||||
|
|
@ -129,6 +131,7 @@ libnm-util/nm-setting-wired.c
|
|||
libnm-util/nm-setting-wireless-security.c
|
||||
libnm-util/nm-setting-wireless.c
|
||||
libnm-util/nm-utils.c
|
||||
libnm/nm-device-6lowpan.c
|
||||
libnm/nm-device-adsl.c
|
||||
libnm/nm-device-bond.c
|
||||
libnm/nm-device-bridge.c
|
||||
|
|
@ -150,6 +153,7 @@ libnm/nm-device-vlan.c
|
|||
libnm/nm-device-vxlan.c
|
||||
libnm/nm-device-wifi.c
|
||||
libnm/nm-device-wimax.c
|
||||
libnm/nm-device-wpan.c
|
||||
libnm/nm-device.c
|
||||
libnm/nm-manager.c
|
||||
libnm/nm-object.c
|
||||
|
|
@ -169,6 +173,7 @@ src/dns/nm-dns-manager.c
|
|||
src/devices/adsl/nm-device-adsl.c
|
||||
src/devices/bluetooth/nm-bluez-device.c
|
||||
src/devices/bluetooth/nm-device-bt.c
|
||||
src/devices/nm-device-6lowpan.c
|
||||
src/devices/nm-device-bond.c
|
||||
src/devices/nm-device-bridge.c
|
||||
src/devices/nm-device-dummy.c
|
||||
|
|
@ -180,6 +185,7 @@ src/devices/nm-device-macvlan.c
|
|||
src/devices/nm-device-tun.c
|
||||
src/devices/nm-device-vlan.c
|
||||
src/devices/nm-device-vxlan.c
|
||||
src/devices/nm-device-wpan.c
|
||||
src/devices/team/nm-device-team.c
|
||||
src/devices/wifi/nm-device-olpc-mesh.c
|
||||
src/devices/wifi/nm-device-wifi.c
|
||||
|
|
|
|||
|
|
@ -16,13 +16,14 @@
|
|||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright 2017 Red Hat, Inc.
|
||||
* Copyright 2017 - 2018 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#include "nm-default.h"
|
||||
|
||||
#include "nm-meta-setting.h"
|
||||
|
||||
#include "nm-setting-6lowpan.h"
|
||||
#include "nm-setting-8021x.h"
|
||||
#include "nm-setting-adsl.h"
|
||||
#include "nm-setting-bluetooth.h"
|
||||
|
|
@ -63,6 +64,7 @@
|
|||
#include "nm-setting-wired.h"
|
||||
#include "nm-setting-wireless.h"
|
||||
#include "nm-setting-wireless-security.h"
|
||||
#include "nm-setting-wpan.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
|
|
@ -145,6 +147,11 @@ const NMSetting8021xSchemeVtable nm_setting_8021x_scheme_vtable[] = {
|
|||
/*****************************************************************************/
|
||||
|
||||
const NMMetaSettingInfo nm_meta_setting_infos[] = {
|
||||
[NM_META_SETTING_TYPE_6LOWPAN] = {
|
||||
.meta_type = NM_META_SETTING_TYPE_6LOWPAN,
|
||||
.setting_name = NM_SETTING_6LOWPAN_SETTING_NAME,
|
||||
.get_setting_gtype = nm_setting_6lowpan_get_type,
|
||||
},
|
||||
[NM_META_SETTING_TYPE_802_1X] = {
|
||||
.meta_type = NM_META_SETTING_TYPE_802_1X,
|
||||
.setting_name = NM_SETTING_802_1X_SETTING_NAME,
|
||||
|
|
@ -340,6 +347,11 @@ const NMMetaSettingInfo nm_meta_setting_infos[] = {
|
|||
.setting_name = NM_SETTING_WIRELESS_SECURITY_SETTING_NAME,
|
||||
.get_setting_gtype = nm_setting_wireless_security_get_type,
|
||||
},
|
||||
[NM_META_SETTING_TYPE_WPAN] = {
|
||||
.meta_type = NM_META_SETTING_TYPE_WPAN,
|
||||
.setting_name = NM_SETTING_WPAN_SETTING_NAME,
|
||||
.get_setting_gtype = nm_setting_wpan_get_type,
|
||||
},
|
||||
|
||||
[NM_META_SETTING_TYPE_UNKNOWN] = {
|
||||
.meta_type = NM_META_SETTING_TYPE_UNKNOWN,
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright 2017 Red Hat, Inc.
|
||||
* Copyright 2017 - 2018 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#ifndef __NM_META_SETTING_H__
|
||||
|
|
@ -56,6 +56,7 @@ extern const NMSetting8021xSchemeVtable nm_setting_8021x_scheme_vtable[_NM_SETTI
|
|||
/*****************************************************************************/
|
||||
|
||||
typedef enum {
|
||||
NM_META_SETTING_TYPE_6LOWPAN,
|
||||
NM_META_SETTING_TYPE_802_1X,
|
||||
NM_META_SETTING_TYPE_ADSL,
|
||||
NM_META_SETTING_TYPE_BLUETOOTH,
|
||||
|
|
@ -95,6 +96,7 @@ typedef enum {
|
|||
NM_META_SETTING_TYPE_WIRED,
|
||||
NM_META_SETTING_TYPE_WIRELESS,
|
||||
NM_META_SETTING_TYPE_WIRELESS_SECURITY,
|
||||
NM_META_SETTING_TYPE_WPAN,
|
||||
|
||||
NM_META_SETTING_TYPE_UNKNOWN,
|
||||
|
||||
|
|
|
|||
375
src/devices/nm-device-6lowpan.c
Normal file
375
src/devices/nm-device-6lowpan.c
Normal file
|
|
@ -0,0 +1,375 @@
|
|||
/* NetworkManager -- Network link manager
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright 2018 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#include "nm-default.h"
|
||||
|
||||
#include "nm-device-6lowpan.h"
|
||||
|
||||
#include "nm-device-private.h"
|
||||
#include "settings/nm-settings.h"
|
||||
#include "platform/nm-platform.h"
|
||||
#include "nm-device-factory.h"
|
||||
#include "nm-setting-6lowpan.h"
|
||||
#include "nm-utils.h"
|
||||
|
||||
#include "nm-device-logging.h"
|
||||
_LOG_DECLARE_SELF(NMDevice6Lowpan);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef struct {
|
||||
gulong parent_state_id;
|
||||
} NMDevice6LowpanPrivate;
|
||||
|
||||
struct _NMDevice6Lowpan {
|
||||
NMDevice parent;
|
||||
NMDevice6LowpanPrivate _priv;
|
||||
};
|
||||
|
||||
struct _NMDevice6LowpanClass {
|
||||
NMDeviceClass parent;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (NMDevice6Lowpan, nm_device_6lowpan, NM_TYPE_DEVICE)
|
||||
|
||||
#define NM_DEVICE_6LOWPAN_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMDevice6Lowpan, NM_IS_DEVICE_6LOWPAN)
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
parent_state_changed (NMDevice *parent,
|
||||
NMDeviceState new_state,
|
||||
NMDeviceState old_state,
|
||||
NMDeviceStateReason reason,
|
||||
gpointer user_data)
|
||||
{
|
||||
NMDevice6Lowpan *self = NM_DEVICE_6LOWPAN (user_data);
|
||||
|
||||
nm_device_set_unmanaged_by_flags (NM_DEVICE (self), NM_UNMANAGED_PARENT, !nm_device_get_managed (parent, FALSE), reason);
|
||||
}
|
||||
|
||||
static void
|
||||
parent_changed_notify (NMDevice *device,
|
||||
int old_ifindex,
|
||||
NMDevice *old_parent,
|
||||
int new_ifindex,
|
||||
NMDevice *new_parent)
|
||||
{
|
||||
NMDevice6Lowpan *self = NM_DEVICE_6LOWPAN (device);
|
||||
NMDevice6LowpanPrivate *priv = NM_DEVICE_6LOWPAN_GET_PRIVATE (self);
|
||||
|
||||
NM_DEVICE_CLASS (nm_device_6lowpan_parent_class)->parent_changed_notify (device, old_ifindex, old_parent, new_ifindex, new_parent);
|
||||
|
||||
/* note that @self doesn't have to clear @parent_state_id on dispose,
|
||||
* because NMDevice's dispose() will unset the parent, which in turn calls
|
||||
* parent_changed_notify(). */
|
||||
nm_clear_g_signal_handler (old_parent, &priv->parent_state_id);
|
||||
|
||||
if (new_parent) {
|
||||
priv->parent_state_id = g_signal_connect (new_parent,
|
||||
NM_DEVICE_STATE_CHANGED,
|
||||
G_CALLBACK (parent_state_changed),
|
||||
device);
|
||||
|
||||
/* Set parent-dependent unmanaged flag */
|
||||
nm_device_set_unmanaged_by_flags (device,
|
||||
NM_UNMANAGED_PARENT,
|
||||
!nm_device_get_managed (new_parent, FALSE),
|
||||
NM_DEVICE_STATE_REASON_PARENT_MANAGED_CHANGED);
|
||||
}
|
||||
|
||||
if (new_ifindex > 0) {
|
||||
/* Recheck availability now that the parent has changed */
|
||||
nm_device_queue_recheck_available (device,
|
||||
NM_DEVICE_STATE_REASON_PARENT_CHANGED,
|
||||
NM_DEVICE_STATE_REASON_PARENT_CHANGED);
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
create_and_realize (NMDevice *device,
|
||||
NMConnection *connection,
|
||||
NMDevice *parent,
|
||||
const NMPlatformLink **out_plink,
|
||||
GError **error)
|
||||
{
|
||||
const char *iface = nm_device_get_iface (device);
|
||||
NMPlatformError plerr;
|
||||
NMSetting6Lowpan *s_6lowpan;
|
||||
int parent_ifindex;
|
||||
|
||||
s_6lowpan = nm_connection_get_setting_6lowpan (connection);
|
||||
g_return_val_if_fail (s_6lowpan, FALSE);
|
||||
|
||||
parent_ifindex = parent ? nm_device_get_ifindex (parent) : 0;
|
||||
|
||||
if (parent_ifindex <= 0) {
|
||||
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_MISSING_DEPENDENCIES,
|
||||
"6LoWPAN devices can not be created without a parent interface");
|
||||
g_return_val_if_fail (!parent, FALSE);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
plerr = nm_platform_link_6lowpan_add (nm_device_get_platform (device), iface, parent_ifindex, out_plink);
|
||||
if (plerr != NM_PLATFORM_ERROR_SUCCESS) {
|
||||
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED,
|
||||
"Failed to create 6lowpan interface '%s' for '%s': %s",
|
||||
iface,
|
||||
nm_connection_get_id (connection),
|
||||
nm_platform_error_to_string_a (plerr));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
nm_device_parent_set_ifindex (device, parent_ifindex);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static NMDeviceCapabilities
|
||||
get_generic_capabilities (NMDevice *dev)
|
||||
{
|
||||
return NM_DEVICE_CAP_CARRIER_DETECT | NM_DEVICE_CAP_IS_SOFTWARE;
|
||||
}
|
||||
|
||||
static void
|
||||
link_changed (NMDevice *device,
|
||||
const NMPlatformLink *pllink)
|
||||
{
|
||||
NMDevice6Lowpan *self = NM_DEVICE_6LOWPAN (device);
|
||||
int parent = 0;
|
||||
int ifindex;
|
||||
|
||||
NM_DEVICE_CLASS (nm_device_6lowpan_parent_class)->link_changed (device, pllink);
|
||||
|
||||
ifindex = nm_device_get_ifindex (device);
|
||||
if (!nm_platform_link_6lowpan_get_properties (nm_device_get_platform (device), ifindex, &parent)) {
|
||||
_LOGW (LOGD_DEVICE, "could not get 6lowpan properties");
|
||||
return;
|
||||
}
|
||||
|
||||
nm_device_parent_set_ifindex (device, parent);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
is_available (NMDevice *device, NMDeviceCheckDevAvailableFlags flags)
|
||||
{
|
||||
if (!nm_device_parent_get_device (device))
|
||||
return FALSE;
|
||||
return NM_DEVICE_CLASS (nm_device_6lowpan_parent_class)->is_available (device, flags);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
check_connection_compatible (NMDevice *device, NMConnection *connection)
|
||||
{
|
||||
NMSetting6Lowpan *s_6lowpan;
|
||||
|
||||
if (!NM_DEVICE_CLASS (nm_device_6lowpan_parent_class)->check_connection_compatible (device, connection))
|
||||
return FALSE;
|
||||
|
||||
s_6lowpan = nm_connection_get_setting_6lowpan (connection);
|
||||
if (!s_6lowpan)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
complete_connection (NMDevice *device,
|
||||
NMConnection *connection,
|
||||
const char *specific_object,
|
||||
NMConnection *const*existing_connections,
|
||||
GError **error)
|
||||
{
|
||||
NMSetting6Lowpan *s_6lowpan;
|
||||
|
||||
nm_utils_complete_generic (nm_device_get_platform (device),
|
||||
connection,
|
||||
NM_SETTING_6LOWPAN_SETTING_NAME,
|
||||
existing_connections,
|
||||
NULL,
|
||||
_("6LOWPAN connection"),
|
||||
NULL,
|
||||
TRUE);
|
||||
|
||||
s_6lowpan = nm_connection_get_setting_6lowpan (connection);
|
||||
if (!s_6lowpan) {
|
||||
g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INVALID_CONNECTION,
|
||||
"A '6lowpan' setting is required.");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* If there's no 6LoWPAN interface, no parent, and no hardware address in the
|
||||
* settings, then there's not enough information to complete the setting.
|
||||
*/
|
||||
if ( !nm_setting_6lowpan_get_parent (s_6lowpan)
|
||||
&& !nm_device_match_hwaddr (device, connection, TRUE)) {
|
||||
g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INVALID_CONNECTION,
|
||||
"The '6lowpan' setting had no interface name, parent, or hardware address.");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
update_connection (NMDevice *device, NMConnection *connection)
|
||||
{
|
||||
NMSetting6Lowpan *s_6lowpan = nm_connection_get_setting_6lowpan (connection);
|
||||
NMDevice *parent_device;
|
||||
const char *setting_parent, *new_parent;
|
||||
|
||||
if (!s_6lowpan) {
|
||||
s_6lowpan = (NMSetting6Lowpan *) nm_setting_6lowpan_new ();
|
||||
nm_connection_add_setting (connection, (NMSetting *) s_6lowpan);
|
||||
}
|
||||
|
||||
/* Update parent in the connection; default to parent's interface name */
|
||||
parent_device = nm_device_parent_get_device (device);
|
||||
if (parent_device) {
|
||||
new_parent = nm_device_get_iface (parent_device);
|
||||
setting_parent = nm_setting_6lowpan_get_parent (s_6lowpan);
|
||||
if (setting_parent && nm_utils_is_uuid (setting_parent)) {
|
||||
NMConnection *parent_connection;
|
||||
|
||||
/* Don't change a parent specified by UUID if it's still valid */
|
||||
parent_connection = (NMConnection *) nm_settings_get_connection_by_uuid (nm_device_get_settings (device), setting_parent);
|
||||
if (parent_connection && nm_device_check_connection_compatible (parent_device, parent_connection))
|
||||
new_parent = NULL;
|
||||
}
|
||||
if (new_parent)
|
||||
g_object_set (s_6lowpan, NM_SETTING_6LOWPAN_PARENT, new_parent, NULL);
|
||||
} else
|
||||
g_object_set (s_6lowpan, NM_SETTING_6LOWPAN_PARENT, NULL, NULL);
|
||||
|
||||
}
|
||||
|
||||
static NMActStageReturn
|
||||
act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *out_failure_reason)
|
||||
{
|
||||
NMActStageReturn ret;
|
||||
|
||||
ret = NM_DEVICE_CLASS (nm_device_6lowpan_parent_class)->act_stage1_prepare (dev, out_failure_reason);
|
||||
if (ret != NM_ACT_STAGE_RETURN_SUCCESS)
|
||||
return ret;
|
||||
|
||||
if (!nm_device_hw_addr_set_cloned (dev, nm_device_get_applied_connection (dev), FALSE))
|
||||
return NM_ACT_STAGE_RETURN_FAILURE;
|
||||
return NM_ACT_STAGE_RETURN_SUCCESS;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
nm_device_6lowpan_init (NMDevice6Lowpan *self)
|
||||
{
|
||||
}
|
||||
|
||||
static const NMDBusInterfaceInfoExtended interface_info_device_6lowpan = {
|
||||
.parent = NM_DEFINE_GDBUS_INTERFACE_INFO_INIT (
|
||||
NM_DBUS_INTERFACE_DEVICE_6LOWPAN,
|
||||
.properties = NM_DEFINE_GDBUS_PROPERTY_INFOS (
|
||||
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE ("HwAddress", "s", NM_DEVICE_HW_ADDRESS),
|
||||
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE ("Parent", "o", NM_DEVICE_PARENT),
|
||||
),
|
||||
),
|
||||
};
|
||||
|
||||
static void
|
||||
nm_device_6lowpan_class_init (NMDevice6LowpanClass *klass)
|
||||
{
|
||||
NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS (klass);
|
||||
NMDeviceClass *device_class = NM_DEVICE_CLASS (klass);
|
||||
|
||||
NM_DEVICE_CLASS_DECLARE_TYPES (klass, NULL, NM_LINK_TYPE_6LOWPAN)
|
||||
|
||||
dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS (&interface_info_device_6lowpan);
|
||||
|
||||
device_class->act_stage1_prepare = act_stage1_prepare;
|
||||
device_class->check_connection_compatible = check_connection_compatible;
|
||||
device_class->complete_connection = complete_connection;
|
||||
device_class->connection_type = NM_SETTING_6LOWPAN_SETTING_NAME;
|
||||
device_class->create_and_realize = create_and_realize;
|
||||
device_class->get_generic_capabilities = get_generic_capabilities;
|
||||
device_class->get_configured_mtu = nm_device_get_configured_mtu_for_wired;
|
||||
device_class->link_changed = link_changed;
|
||||
device_class->is_available = is_available;
|
||||
device_class->parent_changed_notify = parent_changed_notify;
|
||||
device_class->update_connection = update_connection;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#define NM_TYPE_6LOWPAN_DEVICE_FACTORY (nm_6lowpan_device_factory_get_type ())
|
||||
#define NM_6LOWPAN_DEVICE_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_6LOWPAN_DEVICE_FACTORY, NM6LowpanDeviceFactory))
|
||||
|
||||
static NMDevice *
|
||||
create_device (NMDeviceFactory *factory,
|
||||
const char *iface,
|
||||
const NMPlatformLink *plink,
|
||||
NMConnection *connection,
|
||||
gboolean *out_ignore)
|
||||
{
|
||||
return (NMDevice *) g_object_new (NM_TYPE_DEVICE_6LOWPAN,
|
||||
NM_DEVICE_IFACE, iface,
|
||||
NM_DEVICE_TYPE_DESC, "6LoWPAN",
|
||||
NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_6LOWPAN,
|
||||
NM_DEVICE_LINK_TYPE, NM_LINK_TYPE_6LOWPAN,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static const char *
|
||||
get_connection_parent (NMDeviceFactory *factory, NMConnection *connection)
|
||||
{
|
||||
NMSetting6Lowpan *s_6lowpan;
|
||||
|
||||
g_return_val_if_fail (nm_connection_is_type (connection, NM_SETTING_6LOWPAN_SETTING_NAME), NULL);
|
||||
|
||||
s_6lowpan = nm_connection_get_setting_6lowpan (connection);
|
||||
g_assert (s_6lowpan);
|
||||
|
||||
return nm_setting_6lowpan_get_parent (s_6lowpan);
|
||||
}
|
||||
|
||||
static char *
|
||||
get_connection_iface (NMDeviceFactory *factory,
|
||||
NMConnection *connection,
|
||||
const char *parent_iface)
|
||||
{
|
||||
NMSetting6Lowpan *s_6lowpan;
|
||||
const char *ifname;
|
||||
|
||||
g_return_val_if_fail (nm_connection_is_type (connection, NM_SETTING_6LOWPAN_SETTING_NAME), NULL);
|
||||
|
||||
s_6lowpan = nm_connection_get_setting_6lowpan (connection);
|
||||
g_assert (s_6lowpan);
|
||||
|
||||
if (!parent_iface)
|
||||
return NULL;
|
||||
|
||||
ifname = nm_connection_get_interface_name (connection);
|
||||
return g_strdup (ifname);
|
||||
}
|
||||
|
||||
NM_DEVICE_FACTORY_DEFINE_INTERNAL (6LOWPAN, 6Lowpan, 6lowpan,
|
||||
NM_DEVICE_FACTORY_DECLARE_LINK_TYPES (NM_LINK_TYPE_6LOWPAN)
|
||||
NM_DEVICE_FACTORY_DECLARE_SETTING_TYPES (NM_SETTING_6LOWPAN_SETTING_NAME),
|
||||
factory_class->create_device = create_device;
|
||||
factory_class->get_connection_parent = get_connection_parent;
|
||||
factory_class->get_connection_iface = get_connection_iface;
|
||||
);
|
||||
37
src/devices/nm-device-6lowpan.h
Normal file
37
src/devices/nm-device-6lowpan.h
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
/* NetworkManager -- Network link manager
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright 2018 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#ifndef __NETWORKMANAGER_DEVICE_6LOWPAN_H__
|
||||
#define __NETWORKMANAGER_DEVICE_6LOWPAN_H__
|
||||
|
||||
#include "nm-device.h"
|
||||
|
||||
#define NM_TYPE_DEVICE_6LOWPAN (nm_device_6lowpan_get_type ())
|
||||
#define NM_DEVICE_6LOWPAN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DEVICE_6LOWPAN, NMDevice6Lowpan))
|
||||
#define NM_DEVICE_6LOWPAN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DEVICE_6LOWPAN, NMDevice6LowpanClass))
|
||||
#define NM_IS_DEVICE_6LOWPAN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DEVICE_6LOWPAN))
|
||||
#define NM_IS_DEVICE_6LOWPAN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_6LOWPAN))
|
||||
#define NM_DEVICE_6LOWPAN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_6LOWPAN, NMDevice6LowpanClass))
|
||||
|
||||
typedef struct _NMDevice6Lowpan NMDevice6Lowpan;
|
||||
typedef struct _NMDevice6LowpanClass NMDevice6LowpanClass;
|
||||
|
||||
GType nm_device_6lowpan_get_type (void);
|
||||
|
||||
#endif /* __NETWORKMANAGER_DEVICE_6LOWPAN_H__ */
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright 2011 - 2016 Red Hat, Inc.
|
||||
* Copyright 2011 - 2018 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#include "nm-default.h"
|
||||
|
|
@ -363,7 +363,6 @@ static NMActStageReturn
|
|||
act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *out_failure_reason)
|
||||
{
|
||||
NMActStageReturn ret = NM_ACT_STAGE_RETURN_SUCCESS;
|
||||
gboolean no_firmware = FALSE;
|
||||
|
||||
ret = NM_DEVICE_CLASS (nm_device_bond_parent_class)->act_stage1_prepare (dev, out_failure_reason);
|
||||
if (ret != NM_ACT_STAGE_RETURN_SUCCESS)
|
||||
|
|
@ -374,7 +373,7 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *out_failure_reason)
|
|||
ret = apply_bonding_config (dev);
|
||||
if (ret != NM_ACT_STAGE_RETURN_FAILURE)
|
||||
ret = nm_device_hw_addr_set_cloned (dev, nm_device_get_applied_connection (dev), FALSE);
|
||||
nm_device_bring_up (dev, TRUE, &no_firmware);
|
||||
nm_device_bring_up (dev, TRUE, NULL);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -386,7 +385,7 @@ enslave_slave (NMDevice *device,
|
|||
gboolean configure)
|
||||
{
|
||||
NMDeviceBond *self = NM_DEVICE_BOND (device);
|
||||
gboolean success = TRUE, no_firmware = FALSE;
|
||||
gboolean success = TRUE;
|
||||
const char *slave_iface = nm_device_get_ip_iface (slave);
|
||||
NMConnection *master_con;
|
||||
|
||||
|
|
@ -397,7 +396,7 @@ enslave_slave (NMDevice *device,
|
|||
success = nm_platform_link_enslave (nm_device_get_platform (device),
|
||||
nm_device_get_ip_ifindex (device),
|
||||
nm_device_get_ip_ifindex (slave));
|
||||
nm_device_bring_up (slave, TRUE, &no_firmware);
|
||||
nm_device_bring_up (slave, TRUE, NULL);
|
||||
|
||||
if (!success)
|
||||
return FALSE;
|
||||
|
|
@ -434,7 +433,7 @@ release_slave (NMDevice *device,
|
|||
gboolean configure)
|
||||
{
|
||||
NMDeviceBond *self = NM_DEVICE_BOND (device);
|
||||
gboolean success, no_firmware = FALSE;
|
||||
gboolean success;
|
||||
gs_free char *address = NULL;
|
||||
|
||||
if (configure) {
|
||||
|
|
@ -463,7 +462,7 @@ release_slave (NMDevice *device,
|
|||
* IFF_UP), so we must bring it back up here to ensure carrier changes and
|
||||
* other state is noticed by the now-released slave.
|
||||
*/
|
||||
if (!nm_device_bring_up (slave, TRUE, &no_firmware))
|
||||
if (!nm_device_bring_up (slave, TRUE, NULL))
|
||||
_LOGW (LOGD_BOND, "released bond slave could not be brought up.");
|
||||
} else {
|
||||
_LOGI (LOGD_BOND, "bond slave %s was released",
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright (C) 2014 Red Hat, Inc.
|
||||
* Copyright (C) 2014 - 2018 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#include "nm-default.h"
|
||||
|
|
@ -417,6 +417,7 @@ nm_device_factory_manager_load_factories (NMDeviceFactoryManagerFactoryFunc call
|
|||
callback, user_data); \
|
||||
} G_STMT_END
|
||||
|
||||
_ADD_INTERNAL (nm_6lowpan_device_factory_get_type);
|
||||
_ADD_INTERNAL (nm_bond_device_factory_get_type);
|
||||
_ADD_INTERNAL (nm_bridge_device_factory_get_type);
|
||||
_ADD_INTERNAL (nm_dummy_device_factory_get_type);
|
||||
|
|
@ -430,6 +431,7 @@ nm_device_factory_manager_load_factories (NMDeviceFactoryManagerFactoryFunc call
|
|||
_ADD_INTERNAL (nm_veth_device_factory_get_type);
|
||||
_ADD_INTERNAL (nm_vlan_device_factory_get_type);
|
||||
_ADD_INTERNAL (nm_vxlan_device_factory_get_type);
|
||||
_ADD_INTERNAL (nm_wpan_device_factory_get_type);
|
||||
|
||||
load_factories_from_dir (NMPLUGINDIR, callback, user_data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright 2011 Red Hat, Inc.
|
||||
* Copyright 2011 - 2018 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#include "nm-default.h"
|
||||
|
|
@ -80,7 +80,7 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *out_failure_reason)
|
|||
NMSettingInfiniband *s_infiniband;
|
||||
char ifname_verified[IFNAMSIZ];
|
||||
const char *transport_mode;
|
||||
gboolean ok, no_firmware = FALSE;
|
||||
gboolean ok;
|
||||
|
||||
ret = NM_DEVICE_CLASS (nm_device_infiniband_parent_class)->act_stage1_prepare (device, out_failure_reason);
|
||||
if (ret != NM_ACT_STAGE_RETURN_SUCCESS)
|
||||
|
|
@ -104,7 +104,7 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *out_failure_reason)
|
|||
/* With some drivers the interface must be down to set transport mode */
|
||||
nm_device_take_down (device, TRUE);
|
||||
ok = nm_platform_sysctl_set (nm_device_get_platform (device), NMP_SYSCTL_PATHID_NETDIR (dirfd, ifname_verified, "mode"), transport_mode);
|
||||
nm_device_bring_up (device, TRUE, &no_firmware);
|
||||
nm_device_bring_up (device, TRUE, NULL);
|
||||
|
||||
if (!ok) {
|
||||
NM_SET_OUT (out_failure_reason, NM_DEVICE_STATE_REASON_CONFIG_FAILED);
|
||||
|
|
|
|||
251
src/devices/nm-device-wpan.c
Normal file
251
src/devices/nm-device-wpan.c
Normal file
|
|
@ -0,0 +1,251 @@
|
|||
/* NetworkManager -- Network link manager
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright 2018 Lubomir Rintel <lkundrak@v3.sk>
|
||||
*/
|
||||
|
||||
#include "nm-default.h"
|
||||
|
||||
#include "nm-manager.h"
|
||||
#include "nm-device-wpan.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "nm-act-request.h"
|
||||
#include "nm-device-private.h"
|
||||
#include "nm-ip4-config.h"
|
||||
#include "platform/nm-platform.h"
|
||||
#include "nm-device-factory.h"
|
||||
#include "nm-setting-wpan.h"
|
||||
#include "nm-core-internal.h"
|
||||
|
||||
#include "nm-device-logging.h"
|
||||
_LOG_DECLARE_SELF(NMDeviceWpan);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
struct _NMDeviceWpan {
|
||||
NMDevice parent;
|
||||
};
|
||||
|
||||
struct _NMDeviceWpanClass {
|
||||
NMDeviceClass parent;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (NMDeviceWpan, nm_device_wpan, NM_TYPE_DEVICE)
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static gboolean
|
||||
complete_connection (NMDevice *device,
|
||||
NMConnection *connection,
|
||||
const char *specific_object,
|
||||
NMConnection *const*existing_connections,
|
||||
GError **error)
|
||||
{
|
||||
NMSettingWpan *s_wpan;
|
||||
|
||||
nm_utils_complete_generic (nm_device_get_platform (device),
|
||||
connection,
|
||||
NM_SETTING_WPAN_SETTING_NAME,
|
||||
existing_connections,
|
||||
NULL,
|
||||
_("WPAN connection"),
|
||||
NULL,
|
||||
TRUE);
|
||||
|
||||
s_wpan = nm_connection_get_setting_wpan (connection);
|
||||
if (!s_wpan) {
|
||||
g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INVALID_CONNECTION,
|
||||
"A 'wpan' setting is required.");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
update_connection (NMDevice *device, NMConnection *connection)
|
||||
{
|
||||
NMSettingWpan *s_wpan = nm_connection_get_setting_wpan (connection);
|
||||
|
||||
if (!s_wpan) {
|
||||
s_wpan = (NMSettingWpan *) nm_setting_wpan_new ();
|
||||
nm_connection_add_setting (connection, (NMSetting *) s_wpan);
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
check_connection_compatible (NMDevice *device, NMConnection *connection)
|
||||
{
|
||||
NMSettingWpan *s_wpan;
|
||||
const char *mac, *hw_addr;
|
||||
|
||||
if (!NM_DEVICE_CLASS (nm_device_wpan_parent_class)->check_connection_compatible (device, connection))
|
||||
return FALSE;
|
||||
|
||||
s_wpan = nm_connection_get_setting_wpan (connection);
|
||||
if (!s_wpan)
|
||||
return FALSE;
|
||||
|
||||
mac = nm_setting_wpan_get_mac_address (s_wpan);
|
||||
if (mac) {
|
||||
hw_addr = nm_device_get_hw_address (device);
|
||||
if (!nm_utils_hwaddr_matches (mac, -1, hw_addr, -1))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static NMActStageReturn
|
||||
act_stage1_prepare (NMDevice *device, NMDeviceStateReason *out_failure_reason)
|
||||
{
|
||||
NMDeviceWpan *self = NM_DEVICE_WPAN (device);
|
||||
NMConnection *connection;
|
||||
NMSettingWpan *s_wpan;
|
||||
NMPlatform *platform;
|
||||
guint16 pan_id;
|
||||
guint16 short_address;
|
||||
int ifindex;
|
||||
const guint8 *hwaddr;
|
||||
gsize hwaddr_len = 0;
|
||||
const NMPlatformLink *lowpan_plink;
|
||||
NMDevice *lowpan_device = NULL;
|
||||
NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE;
|
||||
|
||||
ret = NM_DEVICE_CLASS (nm_device_wpan_parent_class)->act_stage1_prepare (device, out_failure_reason);
|
||||
if (ret != NM_ACT_STAGE_RETURN_SUCCESS)
|
||||
return ret;
|
||||
|
||||
platform = nm_device_get_platform (device);
|
||||
g_return_val_if_fail (platform, NM_ACT_STAGE_RETURN_FAILURE);
|
||||
|
||||
ifindex = nm_device_get_ifindex (device);
|
||||
g_return_val_if_fail (ifindex > 0, NM_ACT_STAGE_RETURN_FAILURE);
|
||||
|
||||
connection = nm_device_get_applied_connection (device);
|
||||
g_return_val_if_fail (connection, NM_ACT_STAGE_RETURN_FAILURE);
|
||||
|
||||
s_wpan = nm_connection_get_setting_wpan (connection);
|
||||
g_return_val_if_fail (s_wpan, NM_ACT_STAGE_RETURN_FAILURE);
|
||||
|
||||
hwaddr = nm_platform_link_get_address (platform, ifindex, &hwaddr_len);
|
||||
g_return_val_if_fail (hwaddr, NM_ACT_STAGE_RETURN_FAILURE);
|
||||
|
||||
/* As of kernel 4.16, the 6LoWPAN devices layered on top of WPANs
|
||||
* need to be DOWN as well as the WPAN device itself in order to
|
||||
* modify the WPAN properties. */
|
||||
lowpan_plink = nm_platform_link_get_by_address (platform,
|
||||
NM_LINK_TYPE_6LOWPAN,
|
||||
hwaddr,
|
||||
hwaddr_len);
|
||||
if (lowpan_plink && NM_FLAGS_HAS (lowpan_plink->n_ifi_flags, IFF_UP)) {
|
||||
lowpan_device = nm_manager_get_device_by_ifindex (nm_manager_get (),
|
||||
lowpan_plink->ifindex);
|
||||
}
|
||||
|
||||
if (lowpan_device)
|
||||
nm_device_take_down (lowpan_device, TRUE);
|
||||
|
||||
nm_device_take_down (device, TRUE);
|
||||
|
||||
pan_id = nm_setting_wpan_get_pan_id (s_wpan);
|
||||
if (pan_id != G_MAXUINT16) {
|
||||
if (!nm_platform_wpan_set_pan_id (platform, ifindex, pan_id)) {
|
||||
_LOGW (LOGD_DEVICE, "unable to set the PAN ID");
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
short_address = nm_setting_wpan_get_short_address (s_wpan);
|
||||
if (short_address != G_MAXUINT16) {
|
||||
if (!nm_platform_wpan_set_short_addr (platform, ifindex, short_address)) {
|
||||
_LOGW (LOGD_DEVICE, "unable to set the short address");
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
ret = NM_ACT_STAGE_RETURN_SUCCESS;
|
||||
out:
|
||||
nm_device_bring_up (device, TRUE, NULL);
|
||||
|
||||
if (lowpan_device)
|
||||
nm_device_bring_up (lowpan_device, TRUE, NULL);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
nm_device_wpan_init (NMDeviceWpan *self)
|
||||
{
|
||||
}
|
||||
|
||||
static const NMDBusInterfaceInfoExtended interface_info_device_wpan = {
|
||||
.parent = NM_DEFINE_GDBUS_INTERFACE_INFO_INIT (
|
||||
NM_DBUS_INTERFACE_DEVICE_WPAN,
|
||||
.properties = NM_DEFINE_GDBUS_PROPERTY_INFOS (
|
||||
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE ("HwAddress", "s", NM_DEVICE_HW_ADDRESS),
|
||||
),
|
||||
),
|
||||
};
|
||||
|
||||
static void
|
||||
nm_device_wpan_class_init (NMDeviceWpanClass *klass)
|
||||
{
|
||||
NMDeviceClass *device_class = NM_DEVICE_CLASS (klass);
|
||||
NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS (klass);
|
||||
|
||||
NM_DEVICE_CLASS_DECLARE_TYPES (klass, NULL, NM_LINK_TYPE_WPAN)
|
||||
|
||||
dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS (&interface_info_device_wpan);
|
||||
|
||||
device_class->connection_type = NM_SETTING_WPAN_SETTING_NAME;
|
||||
device_class->complete_connection = complete_connection;
|
||||
device_class->check_connection_compatible = check_connection_compatible;
|
||||
device_class->update_connection = update_connection;
|
||||
device_class->act_stage1_prepare = act_stage1_prepare;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#define NM_TYPE_WPAN_DEVICE_FACTORY (nm_wpan_device_factory_get_type ())
|
||||
#define NM_WPAN_DEVICE_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_WPAN_DEVICE_FACTORY, NMWpanDeviceFactory))
|
||||
|
||||
static NMDevice *
|
||||
create_device (NMDeviceFactory *factory,
|
||||
const char *iface,
|
||||
const NMPlatformLink *plink,
|
||||
NMConnection *connection,
|
||||
gboolean *out_ignore)
|
||||
{
|
||||
return (NMDevice *) g_object_new (NM_TYPE_DEVICE_WPAN,
|
||||
NM_DEVICE_IFACE, iface,
|
||||
NM_DEVICE_TYPE_DESC, "WPAN",
|
||||
NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_WPAN,
|
||||
NM_DEVICE_LINK_TYPE, NM_LINK_TYPE_WPAN,
|
||||
NULL);
|
||||
}
|
||||
|
||||
NM_DEVICE_FACTORY_DEFINE_INTERNAL (WPAN, Wpan, wpan,
|
||||
NM_DEVICE_FACTORY_DECLARE_LINK_TYPES (NM_LINK_TYPE_WPAN)
|
||||
NM_DEVICE_FACTORY_DECLARE_SETTING_TYPES (NM_SETTING_WPAN_SETTING_NAME),
|
||||
factory_class->create_device = create_device;
|
||||
);
|
||||
35
src/devices/nm-device-wpan.h
Normal file
35
src/devices/nm-device-wpan.h
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
/* NetworkManager -- Network link manager
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright 2018 Lubomir Rintel <lkundrak@v3.sk>
|
||||
*/
|
||||
|
||||
#ifndef __NETWORKMANAGER_DEVICE_WPAN_H__
|
||||
#define __NETWORKMANAGER_DEVICE_WPAN_H__
|
||||
|
||||
#define NM_TYPE_DEVICE_WPAN (nm_device_wpan_get_type ())
|
||||
#define NM_DEVICE_WPAN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DEVICE_WPAN, NMDeviceWpan))
|
||||
#define NM_DEVICE_WPAN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DEVICE_WPAN, NMDeviceWpanClass))
|
||||
#define NM_IS_DEVICE_WPAN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DEVICE_WPAN))
|
||||
#define NM_IS_DEVICE_WPAN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_WPAN))
|
||||
#define NM_DEVICE_WPAN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_WPAN, NMDeviceWpanClass))
|
||||
|
||||
typedef struct _NMDeviceWpan NMDeviceWpan;
|
||||
typedef struct _NMDeviceWpanClass NMDeviceWpanClass;
|
||||
|
||||
GType nm_device_wpan_get_type (void);
|
||||
|
||||
#endif /* __NETWORKMANAGER_DEVICE_WPAN_H__ */
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright (C) 2005 - 2017 Red Hat, Inc.
|
||||
* Copyright (C) 2005 - 2018 Red Hat, Inc.
|
||||
* Copyright (C) 2006 - 2008 Novell, Inc.
|
||||
*/
|
||||
|
||||
|
|
@ -1736,7 +1736,11 @@ static gboolean
|
|||
get_ip_iface_identifier (NMDevice *self, NMUtilsIPv6IfaceId *out_iid)
|
||||
{
|
||||
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
||||
NMPlatform *platform = nm_device_get_platform (self);
|
||||
const NMPlatformLink *pllink;
|
||||
const guint8 *hwaddr;
|
||||
guint8 pseudo_hwaddr[ETH_ALEN];
|
||||
guint hwaddr_len;
|
||||
int ifindex;
|
||||
gboolean success;
|
||||
|
||||
|
|
@ -1744,7 +1748,7 @@ get_ip_iface_identifier (NMDevice *self, NMUtilsIPv6IfaceId *out_iid)
|
|||
ifindex = nm_device_get_ip_ifindex (self);
|
||||
g_return_val_if_fail (ifindex > 0, FALSE);
|
||||
|
||||
pllink = nm_platform_link_get (nm_device_get_platform (self), ifindex);
|
||||
pllink = nm_platform_link_get (platform, ifindex);
|
||||
if ( !pllink
|
||||
|| NM_IN_SET (pllink->type, NM_LINK_TYPE_NONE, NM_LINK_TYPE_UNKNOWN))
|
||||
return FALSE;
|
||||
|
|
@ -1754,9 +1758,35 @@ get_ip_iface_identifier (NMDevice *self, NMUtilsIPv6IfaceId *out_iid)
|
|||
if (pllink->addr.len > NM_UTILS_HWADDR_LEN_MAX)
|
||||
g_return_val_if_reached (FALSE);
|
||||
|
||||
hwaddr = pllink->addr.data;
|
||||
hwaddr_len = pllink->addr.len;
|
||||
|
||||
if (pllink->type == NM_LINK_TYPE_6LOWPAN) {
|
||||
/* If the underlying IEEE 802.15.4 device has a short address we generate
|
||||
* a "pseudo 48-bit address" that's to be used in the same fashion as a
|
||||
* wired Ethernet address. The mechanism is specified in Section 6. of
|
||||
* RFC 4944 */
|
||||
guint16 pan_id;
|
||||
guint16 short_addr;
|
||||
|
||||
short_addr = nm_platform_wpan_get_short_addr (platform, pllink->parent);
|
||||
if (short_addr != G_MAXUINT16) {
|
||||
pan_id = nm_platform_wpan_get_pan_id (platform, pllink->parent);
|
||||
pseudo_hwaddr[0] = short_addr & 0xff;
|
||||
pseudo_hwaddr[1] = (short_addr >> 8) & 0xff;
|
||||
pseudo_hwaddr[2] = 0;
|
||||
pseudo_hwaddr[3] = 0;
|
||||
pseudo_hwaddr[4] = pan_id & 0xff;
|
||||
pseudo_hwaddr[5] = (pan_id >> 8) & 0xff;
|
||||
|
||||
hwaddr = pseudo_hwaddr;
|
||||
hwaddr_len = G_N_ELEMENTS (pseudo_hwaddr);
|
||||
}
|
||||
}
|
||||
|
||||
success = nm_utils_get_ipv6_interface_identifier (pllink->type,
|
||||
pllink->addr.data,
|
||||
pllink->addr.len,
|
||||
hwaddr,
|
||||
hwaddr_len,
|
||||
priv->dev_id,
|
||||
out_iid);
|
||||
if (!success) {
|
||||
|
|
@ -1910,10 +1940,14 @@ nm_device_get_route_metric_default (NMDeviceType device_type)
|
|||
return 700;
|
||||
case NM_DEVICE_TYPE_BT:
|
||||
return 750;
|
||||
case NM_DEVICE_TYPE_6LOWPAN:
|
||||
return 775;
|
||||
case NM_DEVICE_TYPE_OVS_BRIDGE:
|
||||
case NM_DEVICE_TYPE_OVS_INTERFACE:
|
||||
case NM_DEVICE_TYPE_OVS_PORT:
|
||||
return 800;
|
||||
case NM_DEVICE_TYPE_WPAN:
|
||||
return 850;
|
||||
case NM_DEVICE_TYPE_GENERIC:
|
||||
return 950;
|
||||
case NM_DEVICE_TYPE_UNKNOWN:
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
||||
/* NetworkManager -- Network link manager
|
||||
*
|
||||
* Copyright (C) 2013 Jiri Pirko <jiri@resnulli.us>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -16,6 +14,9 @@
|
|||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright (C) 2013 Jiri Pirko <jiri@resnulli.us>
|
||||
* Copyright (C) 2018 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#include "nm-default.h"
|
||||
|
|
@ -703,7 +704,7 @@ enslave_slave (NMDevice *device,
|
|||
{
|
||||
NMDeviceTeam *self = NM_DEVICE_TEAM (device);
|
||||
NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE (self);
|
||||
gboolean success = TRUE, no_firmware = FALSE;
|
||||
gboolean success = TRUE;
|
||||
const char *slave_iface = nm_device_get_ip_iface (slave);
|
||||
NMSettingTeamPort *s_team_port;
|
||||
|
||||
|
|
@ -738,7 +739,7 @@ enslave_slave (NMDevice *device,
|
|||
success = nm_platform_link_enslave (nm_device_get_platform (device),
|
||||
nm_device_get_ip_ifindex (device),
|
||||
nm_device_get_ip_ifindex (slave));
|
||||
nm_device_bring_up (slave, TRUE, &no_firmware);
|
||||
nm_device_bring_up (slave, TRUE, NULL);
|
||||
|
||||
if (!success)
|
||||
return FALSE;
|
||||
|
|
@ -762,7 +763,7 @@ release_slave (NMDevice *device,
|
|||
{
|
||||
NMDeviceTeam *self = NM_DEVICE_TEAM (device);
|
||||
NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE (self);
|
||||
gboolean success, no_firmware = FALSE;
|
||||
gboolean success;
|
||||
|
||||
if (configure) {
|
||||
success = nm_platform_link_release (nm_device_get_platform (device),
|
||||
|
|
@ -778,7 +779,7 @@ release_slave (NMDevice *device,
|
|||
* IFF_UP), so we must bring it back up here to ensure carrier changes and
|
||||
* other state is noticed by the now-released port.
|
||||
*/
|
||||
if (!nm_device_bring_up (slave, TRUE, &no_firmware))
|
||||
if (!nm_device_bring_up (slave, TRUE, NULL))
|
||||
_LOGW (LOGD_TEAM, "released team port %s could not be brought up",
|
||||
nm_device_get_ip_iface (slave));
|
||||
|
||||
|
|
|
|||
|
|
@ -55,8 +55,9 @@ sources = files(
|
|||
'ndisc/nm-lndp-ndisc.c',
|
||||
'ndisc/nm-ndisc.c',
|
||||
'platform/nm-netlink.c',
|
||||
'platform/wifi/wifi-utils-nl80211.c',
|
||||
'platform/wifi/wifi-utils.c',
|
||||
'platform/wifi/nm-wifi-utils-nl80211.c',
|
||||
'platform/wifi/nm-wifi-utils.c',
|
||||
'platform/wpan/nm-wpan-utils.c',
|
||||
'platform/nm-linux-platform.c',
|
||||
'platform/nm-platform.c',
|
||||
'platform/nm-platform-utils.c',
|
||||
|
|
@ -79,7 +80,7 @@ deps = [
|
|||
]
|
||||
|
||||
if enable_wext
|
||||
sources += files('platform/wifi/wifi-utils-wext.c')
|
||||
sources += files('platform/wifi/nm-wifi-utils-wext.c')
|
||||
endif
|
||||
|
||||
libnetwork_manager_base = static_library(
|
||||
|
|
@ -92,6 +93,7 @@ libnetwork_manager_base = static_library(
|
|||
|
||||
sources = files(
|
||||
'devices/nm-acd-manager.c',
|
||||
'devices/nm-device-6lowpan.c',
|
||||
'devices/nm-device-bond.c',
|
||||
'devices/nm-device-bridge.c',
|
||||
'devices/nm-device.c',
|
||||
|
|
@ -109,6 +111,7 @@ sources = files(
|
|||
'devices/nm-device-veth.c',
|
||||
'devices/nm-device-vlan.c',
|
||||
'devices/nm-device-vxlan.c',
|
||||
'devices/nm-device-wpan.c',
|
||||
'devices/nm-lldp-listener.c',
|
||||
'dhcp/nm-dhcp-dhclient.c',
|
||||
'dhcp/nm-dhcp-dhclient-utils.c',
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright 2004 - 2014 Red Hat, Inc.
|
||||
* Copyright 2004 - 2018 Red Hat, Inc.
|
||||
* Copyright 2005 - 2008 Novell, Inc.
|
||||
*/
|
||||
|
||||
|
|
@ -3018,6 +3018,11 @@ nm_utils_get_ipv6_interface_identifier (NMLinkType link_type,
|
|||
out_iid->id_u8[3] = 0xFE;
|
||||
memcpy (out_iid->id_u8 + 4, &addr, 4);
|
||||
return TRUE;
|
||||
case NM_LINK_TYPE_6LOWPAN:
|
||||
/* The hardware address is already 64-bit. This is the case for
|
||||
* IEEE 802.15.4 networks. */
|
||||
memcpy (out_iid->id_u8, hwaddr, sizeof (out_iid->id_u8));
|
||||
return TRUE;
|
||||
default:
|
||||
if (hwaddr_len == ETH_ALEN) {
|
||||
/* Translate 48-bit MAC address to a 64-bit Modified EUI-64. See
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright (C) 2012 - 2017 Red Hat, Inc.
|
||||
* Copyright (C) 2012 - 2018 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#ifndef __NETWORKMANAGER_TYPES_H__
|
||||
|
|
@ -150,6 +150,8 @@ typedef enum {
|
|||
NM_LINK_TYPE_WIFI,
|
||||
NM_LINK_TYPE_WWAN_NET, /* WWAN kernel netdevice */
|
||||
NM_LINK_TYPE_WIMAX,
|
||||
NM_LINK_TYPE_WPAN,
|
||||
NM_LINK_TYPE_6LOWPAN,
|
||||
|
||||
/* Software types */
|
||||
NM_LINK_TYPE_BNEP = 0x10000, /* Bluetooth Ethernet emulation */
|
||||
|
|
|
|||
452
src/platform/linux/nl802154.h
Normal file
452
src/platform/linux/nl802154.h
Normal file
|
|
@ -0,0 +1,452 @@
|
|||
#ifndef __NL802154_H
|
||||
#define __NL802154_H
|
||||
/*
|
||||
* 802.15.4 netlink interface public header
|
||||
*
|
||||
* Copyright 2014 Alexander Aring <aar@pengutronix.de>
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#define NL802154_GENL_NAME "nl802154"
|
||||
|
||||
enum nl802154_commands {
|
||||
/* don't change the order or add anything between, this is ABI! */
|
||||
/* currently we don't shipping this file via uapi, ignore the above one */
|
||||
NL802154_CMD_UNSPEC,
|
||||
|
||||
NL802154_CMD_GET_WPAN_PHY, /* can dump */
|
||||
NL802154_CMD_SET_WPAN_PHY,
|
||||
NL802154_CMD_NEW_WPAN_PHY,
|
||||
NL802154_CMD_DEL_WPAN_PHY,
|
||||
|
||||
NL802154_CMD_GET_INTERFACE, /* can dump */
|
||||
NL802154_CMD_SET_INTERFACE,
|
||||
NL802154_CMD_NEW_INTERFACE,
|
||||
NL802154_CMD_DEL_INTERFACE,
|
||||
|
||||
NL802154_CMD_SET_CHANNEL,
|
||||
|
||||
NL802154_CMD_SET_PAN_ID,
|
||||
NL802154_CMD_SET_SHORT_ADDR,
|
||||
|
||||
NL802154_CMD_SET_TX_POWER,
|
||||
NL802154_CMD_SET_CCA_MODE,
|
||||
NL802154_CMD_SET_CCA_ED_LEVEL,
|
||||
|
||||
NL802154_CMD_SET_MAX_FRAME_RETRIES,
|
||||
|
||||
NL802154_CMD_SET_BACKOFF_EXPONENT,
|
||||
NL802154_CMD_SET_MAX_CSMA_BACKOFFS,
|
||||
|
||||
NL802154_CMD_SET_LBT_MODE,
|
||||
|
||||
NL802154_CMD_SET_ACKREQ_DEFAULT,
|
||||
|
||||
NL802154_CMD_SET_WPAN_PHY_NETNS,
|
||||
|
||||
/* add new commands above here */
|
||||
|
||||
#ifdef CONFIG_IEEE802154_NL802154_EXPERIMENTAL
|
||||
NL802154_CMD_SET_SEC_PARAMS,
|
||||
NL802154_CMD_GET_SEC_KEY, /* can dump */
|
||||
NL802154_CMD_NEW_SEC_KEY,
|
||||
NL802154_CMD_DEL_SEC_KEY,
|
||||
NL802154_CMD_GET_SEC_DEV, /* can dump */
|
||||
NL802154_CMD_NEW_SEC_DEV,
|
||||
NL802154_CMD_DEL_SEC_DEV,
|
||||
NL802154_CMD_GET_SEC_DEVKEY, /* can dump */
|
||||
NL802154_CMD_NEW_SEC_DEVKEY,
|
||||
NL802154_CMD_DEL_SEC_DEVKEY,
|
||||
NL802154_CMD_GET_SEC_LEVEL, /* can dump */
|
||||
NL802154_CMD_NEW_SEC_LEVEL,
|
||||
NL802154_CMD_DEL_SEC_LEVEL,
|
||||
#endif /* CONFIG_IEEE802154_NL802154_EXPERIMENTAL */
|
||||
|
||||
/* used to define NL802154_CMD_MAX below */
|
||||
__NL802154_CMD_AFTER_LAST,
|
||||
NL802154_CMD_MAX = __NL802154_CMD_AFTER_LAST - 1
|
||||
};
|
||||
|
||||
enum nl802154_attrs {
|
||||
/* don't change the order or add anything between, this is ABI! */
|
||||
/* currently we don't shipping this file via uapi, ignore the above one */
|
||||
NL802154_ATTR_UNSPEC,
|
||||
|
||||
NL802154_ATTR_WPAN_PHY,
|
||||
NL802154_ATTR_WPAN_PHY_NAME,
|
||||
|
||||
NL802154_ATTR_IFINDEX,
|
||||
NL802154_ATTR_IFNAME,
|
||||
NL802154_ATTR_IFTYPE,
|
||||
|
||||
NL802154_ATTR_WPAN_DEV,
|
||||
|
||||
NL802154_ATTR_PAGE,
|
||||
NL802154_ATTR_CHANNEL,
|
||||
|
||||
NL802154_ATTR_PAN_ID,
|
||||
NL802154_ATTR_SHORT_ADDR,
|
||||
|
||||
NL802154_ATTR_TX_POWER,
|
||||
|
||||
NL802154_ATTR_CCA_MODE,
|
||||
NL802154_ATTR_CCA_OPT,
|
||||
NL802154_ATTR_CCA_ED_LEVEL,
|
||||
|
||||
NL802154_ATTR_MAX_FRAME_RETRIES,
|
||||
|
||||
NL802154_ATTR_MAX_BE,
|
||||
NL802154_ATTR_MIN_BE,
|
||||
NL802154_ATTR_MAX_CSMA_BACKOFFS,
|
||||
|
||||
NL802154_ATTR_LBT_MODE,
|
||||
|
||||
NL802154_ATTR_GENERATION,
|
||||
|
||||
NL802154_ATTR_CHANNELS_SUPPORTED,
|
||||
NL802154_ATTR_SUPPORTED_CHANNEL,
|
||||
|
||||
NL802154_ATTR_EXTENDED_ADDR,
|
||||
|
||||
NL802154_ATTR_WPAN_PHY_CAPS,
|
||||
|
||||
NL802154_ATTR_SUPPORTED_COMMANDS,
|
||||
|
||||
NL802154_ATTR_ACKREQ_DEFAULT,
|
||||
|
||||
NL802154_ATTR_PAD,
|
||||
|
||||
NL802154_ATTR_PID,
|
||||
NL802154_ATTR_NETNS_FD,
|
||||
|
||||
/* add attributes here, update the policy in nl802154.c */
|
||||
|
||||
#ifdef CONFIG_IEEE802154_NL802154_EXPERIMENTAL
|
||||
NL802154_ATTR_SEC_ENABLED,
|
||||
NL802154_ATTR_SEC_OUT_LEVEL,
|
||||
NL802154_ATTR_SEC_OUT_KEY_ID,
|
||||
NL802154_ATTR_SEC_FRAME_COUNTER,
|
||||
|
||||
NL802154_ATTR_SEC_LEVEL,
|
||||
NL802154_ATTR_SEC_DEVICE,
|
||||
NL802154_ATTR_SEC_DEVKEY,
|
||||
NL802154_ATTR_SEC_KEY,
|
||||
#endif /* CONFIG_IEEE802154_NL802154_EXPERIMENTAL */
|
||||
|
||||
__NL802154_ATTR_AFTER_LAST,
|
||||
NL802154_ATTR_MAX = __NL802154_ATTR_AFTER_LAST - 1
|
||||
};
|
||||
|
||||
enum nl802154_iftype {
|
||||
/* for backwards compatibility TODO */
|
||||
NL802154_IFTYPE_UNSPEC = -1,
|
||||
|
||||
NL802154_IFTYPE_NODE,
|
||||
NL802154_IFTYPE_MONITOR,
|
||||
NL802154_IFTYPE_COORD,
|
||||
|
||||
/* keep last */
|
||||
NUM_NL802154_IFTYPES,
|
||||
NL802154_IFTYPE_MAX = NUM_NL802154_IFTYPES - 1
|
||||
};
|
||||
|
||||
/**
|
||||
* enum nl802154_wpan_phy_capability_attr - wpan phy capability attributes
|
||||
*
|
||||
* @__NL802154_CAP_ATTR_INVALID: attribute number 0 is reserved
|
||||
* @NL802154_CAP_ATTR_CHANNELS: a nested attribute for nl802154_channel_attr
|
||||
* @NL802154_CAP_ATTR_TX_POWERS: a nested attribute for
|
||||
* nl802154_wpan_phy_tx_power
|
||||
* @NL802154_CAP_ATTR_MIN_CCA_ED_LEVEL: minimum value for cca_ed_level
|
||||
* @NL802154_CAP_ATTR_MAX_CCA_ED_LEVEL: maxmimum value for cca_ed_level
|
||||
* @NL802154_CAP_ATTR_CCA_MODES: nl802154_cca_modes flags
|
||||
* @NL802154_CAP_ATTR_CCA_OPTS: nl802154_cca_opts flags
|
||||
* @NL802154_CAP_ATTR_MIN_MINBE: minimum of minbe value
|
||||
* @NL802154_CAP_ATTR_MAX_MINBE: maximum of minbe value
|
||||
* @NL802154_CAP_ATTR_MIN_MAXBE: minimum of maxbe value
|
||||
* @NL802154_CAP_ATTR_MAX_MINBE: maximum of maxbe value
|
||||
* @NL802154_CAP_ATTR_MIN_CSMA_BACKOFFS: minimum of csma backoff value
|
||||
* @NL802154_CAP_ATTR_MAX_CSMA_BACKOFFS: maximum of csma backoffs value
|
||||
* @NL802154_CAP_ATTR_MIN_FRAME_RETRIES: minimum of frame retries value
|
||||
* @NL802154_CAP_ATTR_MAX_FRAME_RETRIES: maximum of frame retries value
|
||||
* @NL802154_CAP_ATTR_IFTYPES: nl802154_iftype flags
|
||||
* @NL802154_CAP_ATTR_LBT: nl802154_supported_bool_states flags
|
||||
* @NL802154_CAP_ATTR_MAX: highest cap attribute currently defined
|
||||
* @__NL802154_CAP_ATTR_AFTER_LAST: internal use
|
||||
*/
|
||||
enum nl802154_wpan_phy_capability_attr {
|
||||
__NL802154_CAP_ATTR_INVALID,
|
||||
|
||||
NL802154_CAP_ATTR_IFTYPES,
|
||||
|
||||
NL802154_CAP_ATTR_CHANNELS,
|
||||
NL802154_CAP_ATTR_TX_POWERS,
|
||||
|
||||
NL802154_CAP_ATTR_CCA_ED_LEVELS,
|
||||
NL802154_CAP_ATTR_CCA_MODES,
|
||||
NL802154_CAP_ATTR_CCA_OPTS,
|
||||
|
||||
NL802154_CAP_ATTR_MIN_MINBE,
|
||||
NL802154_CAP_ATTR_MAX_MINBE,
|
||||
|
||||
NL802154_CAP_ATTR_MIN_MAXBE,
|
||||
NL802154_CAP_ATTR_MAX_MAXBE,
|
||||
|
||||
NL802154_CAP_ATTR_MIN_CSMA_BACKOFFS,
|
||||
NL802154_CAP_ATTR_MAX_CSMA_BACKOFFS,
|
||||
|
||||
NL802154_CAP_ATTR_MIN_FRAME_RETRIES,
|
||||
NL802154_CAP_ATTR_MAX_FRAME_RETRIES,
|
||||
|
||||
NL802154_CAP_ATTR_LBT,
|
||||
|
||||
/* keep last */
|
||||
__NL802154_CAP_ATTR_AFTER_LAST,
|
||||
NL802154_CAP_ATTR_MAX = __NL802154_CAP_ATTR_AFTER_LAST - 1
|
||||
};
|
||||
|
||||
/**
|
||||
* enum nl802154_cca_modes - cca modes
|
||||
*
|
||||
* @__NL802154_CCA_INVALID: cca mode number 0 is reserved
|
||||
* @NL802154_CCA_ENERGY: Energy above threshold
|
||||
* @NL802154_CCA_CARRIER: Carrier sense only
|
||||
* @NL802154_CCA_ENERGY_CARRIER: Carrier sense with energy above threshold
|
||||
* @NL802154_CCA_ALOHA: CCA shall always report an idle medium
|
||||
* @NL802154_CCA_UWB_SHR: UWB preamble sense based on the SHR of a frame
|
||||
* @NL802154_CCA_UWB_MULTIPLEXED: UWB preamble sense based on the packet with
|
||||
* the multiplexed preamble
|
||||
* @__NL802154_CCA_ATTR_AFTER_LAST: Internal
|
||||
* @NL802154_CCA_ATTR_MAX: Maximum CCA attribute number
|
||||
*/
|
||||
enum nl802154_cca_modes {
|
||||
__NL802154_CCA_INVALID,
|
||||
NL802154_CCA_ENERGY,
|
||||
NL802154_CCA_CARRIER,
|
||||
NL802154_CCA_ENERGY_CARRIER,
|
||||
NL802154_CCA_ALOHA,
|
||||
NL802154_CCA_UWB_SHR,
|
||||
NL802154_CCA_UWB_MULTIPLEXED,
|
||||
|
||||
/* keep last */
|
||||
__NL802154_CCA_ATTR_AFTER_LAST,
|
||||
NL802154_CCA_ATTR_MAX = __NL802154_CCA_ATTR_AFTER_LAST - 1
|
||||
};
|
||||
|
||||
/**
|
||||
* enum nl802154_cca_opts - additional options for cca modes
|
||||
*
|
||||
* @NL802154_CCA_OPT_ENERGY_CARRIER_OR: NL802154_CCA_ENERGY_CARRIER with OR
|
||||
* @NL802154_CCA_OPT_ENERGY_CARRIER_AND: NL802154_CCA_ENERGY_CARRIER with AND
|
||||
*/
|
||||
enum nl802154_cca_opts {
|
||||
NL802154_CCA_OPT_ENERGY_CARRIER_AND,
|
||||
NL802154_CCA_OPT_ENERGY_CARRIER_OR,
|
||||
|
||||
/* keep last */
|
||||
__NL802154_CCA_OPT_ATTR_AFTER_LAST,
|
||||
NL802154_CCA_OPT_ATTR_MAX = __NL802154_CCA_OPT_ATTR_AFTER_LAST - 1
|
||||
};
|
||||
|
||||
/**
|
||||
* enum nl802154_supported_bool_states - bool states for bool capability entry
|
||||
*
|
||||
* @NL802154_SUPPORTED_BOOL_FALSE: indicates to set false
|
||||
* @NL802154_SUPPORTED_BOOL_TRUE: indicates to set true
|
||||
* @__NL802154_SUPPORTED_BOOL_INVALD: reserved
|
||||
* @NL802154_SUPPORTED_BOOL_BOTH: indicates to set true and false
|
||||
* @__NL802154_SUPPORTED_BOOL_AFTER_LAST: Internal
|
||||
* @NL802154_SUPPORTED_BOOL_MAX: highest value for bool states
|
||||
*/
|
||||
enum nl802154_supported_bool_states {
|
||||
NL802154_SUPPORTED_BOOL_FALSE,
|
||||
NL802154_SUPPORTED_BOOL_TRUE,
|
||||
/* to handle them in a mask */
|
||||
__NL802154_SUPPORTED_BOOL_INVALD,
|
||||
NL802154_SUPPORTED_BOOL_BOTH,
|
||||
|
||||
/* keep last */
|
||||
__NL802154_SUPPORTED_BOOL_AFTER_LAST,
|
||||
NL802154_SUPPORTED_BOOL_MAX = __NL802154_SUPPORTED_BOOL_AFTER_LAST - 1
|
||||
};
|
||||
|
||||
#ifdef CONFIG_IEEE802154_NL802154_EXPERIMENTAL
|
||||
|
||||
enum nl802154_dev_addr_modes {
|
||||
NL802154_DEV_ADDR_NONE,
|
||||
__NL802154_DEV_ADDR_INVALID,
|
||||
NL802154_DEV_ADDR_SHORT,
|
||||
NL802154_DEV_ADDR_EXTENDED,
|
||||
|
||||
/* keep last */
|
||||
__NL802154_DEV_ADDR_AFTER_LAST,
|
||||
NL802154_DEV_ADDR_MAX = __NL802154_DEV_ADDR_AFTER_LAST - 1
|
||||
};
|
||||
|
||||
enum nl802154_dev_addr_attrs {
|
||||
NL802154_DEV_ADDR_ATTR_UNSPEC,
|
||||
|
||||
NL802154_DEV_ADDR_ATTR_PAN_ID,
|
||||
NL802154_DEV_ADDR_ATTR_MODE,
|
||||
NL802154_DEV_ADDR_ATTR_SHORT,
|
||||
NL802154_DEV_ADDR_ATTR_EXTENDED,
|
||||
NL802154_DEV_ADDR_ATTR_PAD,
|
||||
|
||||
/* keep last */
|
||||
__NL802154_DEV_ADDR_ATTR_AFTER_LAST,
|
||||
NL802154_DEV_ADDR_ATTR_MAX = __NL802154_DEV_ADDR_ATTR_AFTER_LAST - 1
|
||||
};
|
||||
|
||||
enum nl802154_key_id_modes {
|
||||
NL802154_KEY_ID_MODE_IMPLICIT,
|
||||
NL802154_KEY_ID_MODE_INDEX,
|
||||
NL802154_KEY_ID_MODE_INDEX_SHORT,
|
||||
NL802154_KEY_ID_MODE_INDEX_EXTENDED,
|
||||
|
||||
/* keep last */
|
||||
__NL802154_KEY_ID_MODE_AFTER_LAST,
|
||||
NL802154_KEY_ID_MODE_MAX = __NL802154_KEY_ID_MODE_AFTER_LAST - 1
|
||||
};
|
||||
|
||||
enum nl802154_key_id_attrs {
|
||||
NL802154_KEY_ID_ATTR_UNSPEC,
|
||||
|
||||
NL802154_KEY_ID_ATTR_MODE,
|
||||
NL802154_KEY_ID_ATTR_INDEX,
|
||||
NL802154_KEY_ID_ATTR_IMPLICIT,
|
||||
NL802154_KEY_ID_ATTR_SOURCE_SHORT,
|
||||
NL802154_KEY_ID_ATTR_SOURCE_EXTENDED,
|
||||
NL802154_KEY_ID_ATTR_PAD,
|
||||
|
||||
/* keep last */
|
||||
__NL802154_KEY_ID_ATTR_AFTER_LAST,
|
||||
NL802154_KEY_ID_ATTR_MAX = __NL802154_KEY_ID_ATTR_AFTER_LAST - 1
|
||||
};
|
||||
|
||||
enum nl802154_seclevels {
|
||||
NL802154_SECLEVEL_NONE,
|
||||
NL802154_SECLEVEL_MIC32,
|
||||
NL802154_SECLEVEL_MIC64,
|
||||
NL802154_SECLEVEL_MIC128,
|
||||
NL802154_SECLEVEL_ENC,
|
||||
NL802154_SECLEVEL_ENC_MIC32,
|
||||
NL802154_SECLEVEL_ENC_MIC64,
|
||||
NL802154_SECLEVEL_ENC_MIC128,
|
||||
|
||||
/* keep last */
|
||||
__NL802154_SECLEVEL_AFTER_LAST,
|
||||
NL802154_SECLEVEL_MAX = __NL802154_SECLEVEL_AFTER_LAST - 1
|
||||
};
|
||||
|
||||
enum nl802154_frames {
|
||||
NL802154_FRAME_BEACON,
|
||||
NL802154_FRAME_DATA,
|
||||
NL802154_FRAME_ACK,
|
||||
NL802154_FRAME_CMD,
|
||||
|
||||
/* keep last */
|
||||
__NL802154_FRAME_AFTER_LAST,
|
||||
NL802154_FRAME_MAX = __NL802154_FRAME_AFTER_LAST - 1
|
||||
};
|
||||
|
||||
enum nl802154_cmd_frames {
|
||||
__NL802154_CMD_FRAME_INVALID,
|
||||
NL802154_CMD_FRAME_ASSOC_REQUEST,
|
||||
NL802154_CMD_FRAME_ASSOC_RESPONSE,
|
||||
NL802154_CMD_FRAME_DISASSOC_NOTIFY,
|
||||
NL802154_CMD_FRAME_DATA_REQUEST,
|
||||
NL802154_CMD_FRAME_PAN_ID_CONFLICT_NOTIFY,
|
||||
NL802154_CMD_FRAME_ORPHAN_NOTIFY,
|
||||
NL802154_CMD_FRAME_BEACON_REQUEST,
|
||||
NL802154_CMD_FRAME_COORD_REALIGNMENT,
|
||||
NL802154_CMD_FRAME_GTS_REQUEST,
|
||||
|
||||
/* keep last */
|
||||
__NL802154_CMD_FRAME_AFTER_LAST,
|
||||
NL802154_CMD_FRAME_MAX = __NL802154_CMD_FRAME_AFTER_LAST - 1
|
||||
};
|
||||
|
||||
enum nl802154_seclevel_attrs {
|
||||
NL802154_SECLEVEL_ATTR_UNSPEC,
|
||||
|
||||
NL802154_SECLEVEL_ATTR_LEVELS,
|
||||
NL802154_SECLEVEL_ATTR_FRAME,
|
||||
NL802154_SECLEVEL_ATTR_CMD_FRAME,
|
||||
NL802154_SECLEVEL_ATTR_DEV_OVERRIDE,
|
||||
|
||||
/* keep last */
|
||||
__NL802154_SECLEVEL_ATTR_AFTER_LAST,
|
||||
NL802154_SECLEVEL_ATTR_MAX = __NL802154_SECLEVEL_ATTR_AFTER_LAST - 1
|
||||
};
|
||||
|
||||
/* TODO what is this? couldn't find in mib */
|
||||
enum {
|
||||
NL802154_DEVKEY_IGNORE,
|
||||
NL802154_DEVKEY_RESTRICT,
|
||||
NL802154_DEVKEY_RECORD,
|
||||
|
||||
/* keep last */
|
||||
__NL802154_DEVKEY_AFTER_LAST,
|
||||
NL802154_DEVKEY_MAX = __NL802154_DEVKEY_AFTER_LAST - 1
|
||||
};
|
||||
|
||||
enum nl802154_dev {
|
||||
NL802154_DEV_ATTR_UNSPEC,
|
||||
|
||||
NL802154_DEV_ATTR_FRAME_COUNTER,
|
||||
NL802154_DEV_ATTR_PAN_ID,
|
||||
NL802154_DEV_ATTR_SHORT_ADDR,
|
||||
NL802154_DEV_ATTR_EXTENDED_ADDR,
|
||||
NL802154_DEV_ATTR_SECLEVEL_EXEMPT,
|
||||
NL802154_DEV_ATTR_KEY_MODE,
|
||||
NL802154_DEV_ATTR_PAD,
|
||||
|
||||
/* keep last */
|
||||
__NL802154_DEV_ATTR_AFTER_LAST,
|
||||
NL802154_DEV_ATTR_MAX = __NL802154_DEV_ATTR_AFTER_LAST - 1
|
||||
};
|
||||
|
||||
enum nl802154_devkey {
|
||||
NL802154_DEVKEY_ATTR_UNSPEC,
|
||||
|
||||
NL802154_DEVKEY_ATTR_FRAME_COUNTER,
|
||||
NL802154_DEVKEY_ATTR_EXTENDED_ADDR,
|
||||
NL802154_DEVKEY_ATTR_ID,
|
||||
NL802154_DEVKEY_ATTR_PAD,
|
||||
|
||||
/* keep last */
|
||||
__NL802154_DEVKEY_ATTR_AFTER_LAST,
|
||||
NL802154_DEVKEY_ATTR_MAX = __NL802154_DEVKEY_ATTR_AFTER_LAST - 1
|
||||
};
|
||||
|
||||
enum nl802154_key {
|
||||
NL802154_KEY_ATTR_UNSPEC,
|
||||
|
||||
NL802154_KEY_ATTR_ID,
|
||||
NL802154_KEY_ATTR_USAGE_FRAMES,
|
||||
NL802154_KEY_ATTR_USAGE_CMDS,
|
||||
NL802154_KEY_ATTR_BYTES,
|
||||
|
||||
/* keep last */
|
||||
__NL802154_KEY_ATTR_AFTER_LAST,
|
||||
NL802154_KEY_ATTR_MAX = __NL802154_KEY_ATTR_AFTER_LAST - 1
|
||||
};
|
||||
|
||||
#define NL802154_KEY_SIZE 16
|
||||
#define NL802154_CMD_FRAME_NR_IDS 256
|
||||
|
||||
#endif /* CONFIG_IEEE802154_NL802154_EXPERIMENTAL */
|
||||
|
||||
#endif /* __NL802154_H */
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright (C) 2012 - 2017 Red Hat, Inc.
|
||||
* Copyright (C) 2012 - 2018 Red Hat, Inc.
|
||||
*/
|
||||
#include "nm-default.h"
|
||||
|
||||
|
|
@ -50,8 +50,9 @@
|
|||
#include "nmp-netns.h"
|
||||
#include "nm-platform-utils.h"
|
||||
#include "nm-platform-private.h"
|
||||
#include "wifi/wifi-utils.h"
|
||||
#include "wifi/wifi-utils-wext.h"
|
||||
#include "wifi/nm-wifi-utils.h"
|
||||
#include "wifi/nm-wifi-utils-wext.h"
|
||||
#include "wpan/nm-wpan-utils.h"
|
||||
#include "nm-utils/unaligned.h"
|
||||
#include "nm-utils/nm-udev-utils.h"
|
||||
|
||||
|
|
@ -154,6 +155,13 @@ G_STATIC_ASSERT (RTA_MAX == (__RTA_MAX - 1));
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
/* Appeared in in kernel prior to 3.13 dated 19 January, 2014 */
|
||||
#ifndef ARPHRD_6LOWPAN
|
||||
#define ARPHRD_6LOWPAN 825
|
||||
#endif
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#define IFLA_MACSEC_UNSPEC 0
|
||||
#define IFLA_MACSEC_SCI 1
|
||||
#define IFLA_MACSEC_PORT 2
|
||||
|
|
@ -317,6 +325,7 @@ static void cache_on_change (NMPlatform *platform,
|
|||
const NMPObject *obj_new);
|
||||
static void cache_prune_all (NMPlatform *platform);
|
||||
static gboolean event_handler_read_netlink (NMPlatform *platform, gboolean wait_for_acks);
|
||||
static struct nl_sock *_genl_sock (NMLinuxPlatform *platform);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
|
|
@ -533,6 +542,8 @@ static const LinkDesc linktypes[] = {
|
|||
{ NM_LINK_TYPE_WIFI, "wifi", NULL, "wlan" },
|
||||
{ NM_LINK_TYPE_WWAN_NET, "wwan", NULL, "wwan" },
|
||||
{ NM_LINK_TYPE_WIMAX, "wimax", "wimax", "wimax" },
|
||||
{ NM_LINK_TYPE_WPAN, "wpan", NULL, NULL },
|
||||
{ NM_LINK_TYPE_6LOWPAN, "6lowpan", NULL, NULL },
|
||||
|
||||
{ NM_LINK_TYPE_BNEP, "bluetooth", NULL, "bluetooth" },
|
||||
{ NM_LINK_TYPE_DUMMY, "dummy", "dummy", NULL },
|
||||
|
|
@ -841,6 +852,10 @@ _linktype_get_type (NMPlatform *platform,
|
|||
return NM_LINK_TYPE_IP6TNL;
|
||||
else if (arptype == ARPHRD_PPP)
|
||||
return NM_LINK_TYPE_PPP;
|
||||
else if (arptype == ARPHRD_IEEE802154)
|
||||
return NM_LINK_TYPE_WPAN;
|
||||
else if (arptype == ARPHRD_6LOWPAN)
|
||||
return NM_LINK_TYPE_6LOWPAN;
|
||||
|
||||
{
|
||||
NMPUtilsEthtoolDriverInfo driver_info;
|
||||
|
|
@ -885,7 +900,7 @@ _linktype_get_type (NMPlatform *platform,
|
|||
}
|
||||
|
||||
/* Fallback for drivers that don't call SET_NETDEV_DEVTYPE() */
|
||||
if (wifi_utils_is_wifi (dirfd, ifname_verified))
|
||||
if (nm_wifi_utils_is_wifi (dirfd, ifname_verified))
|
||||
return NM_LINK_TYPE_WIFI;
|
||||
}
|
||||
|
||||
|
|
@ -1714,6 +1729,7 @@ _new_from_nl_link (NMPlatform *platform, const NMPCache *cache, struct nlmsghdr
|
|||
NMPObject *lnk_data = NULL;
|
||||
gboolean address_complete_from_cache = TRUE;
|
||||
gboolean lnk_data_complete_from_cache = TRUE;
|
||||
gboolean need_ext_data = FALSE;
|
||||
gboolean af_inet6_token_valid = FALSE;
|
||||
gboolean af_inet6_addr_gen_mode_valid = FALSE;
|
||||
|
||||
|
|
@ -1868,6 +1884,12 @@ _new_from_nl_link (NMPlatform *platform, const NMPCache *cache, struct nlmsghdr
|
|||
case NM_LINK_TYPE_VXLAN:
|
||||
lnk_data = _parse_lnk_vxlan (nl_info_kind, nl_info_data);
|
||||
break;
|
||||
case NM_LINK_TYPE_WIFI:
|
||||
case NM_LINK_TYPE_OLPC_MESH:
|
||||
case NM_LINK_TYPE_WPAN:
|
||||
need_ext_data = TRUE;
|
||||
lnk_data_complete_from_cache = FALSE;
|
||||
break;
|
||||
default:
|
||||
lnk_data_complete_from_cache = FALSE;
|
||||
break;
|
||||
|
|
@ -1895,6 +1917,14 @@ _new_from_nl_link (NMPlatform *platform, const NMPCache *cache, struct nlmsghdr
|
|||
nmp_object_unref (lnk_data);
|
||||
lnk_data = (NMPObject *) nmp_object_ref (link_cached->_link.netlink.lnk);
|
||||
}
|
||||
|
||||
if ( need_ext_data
|
||||
&& link_cached->link.type == obj->link.type
|
||||
&& link_cached->_link.ext_data) {
|
||||
/* Prefer reuse of existing ext_data object */
|
||||
obj->_link.ext_data = g_object_ref (link_cached->_link.ext_data);
|
||||
}
|
||||
|
||||
if (address_complete_from_cache)
|
||||
obj->link.addr = link_cached->link.addr;
|
||||
if (!af_inet6_token_valid)
|
||||
|
|
@ -1912,6 +1942,33 @@ _new_from_nl_link (NMPlatform *platform, const NMPCache *cache, struct nlmsghdr
|
|||
|
||||
obj->_link.netlink.lnk = lnk_data;
|
||||
|
||||
if (need_ext_data && obj->_link.ext_data == NULL) {
|
||||
switch (obj->link.type) {
|
||||
case NM_LINK_TYPE_WIFI:
|
||||
obj->_link.ext_data = (GObject *) nm_wifi_utils_new (ifi->ifi_index,
|
||||
_genl_sock (NM_LINUX_PLATFORM (platform)),
|
||||
TRUE);
|
||||
break;
|
||||
case NM_LINK_TYPE_OLPC_MESH:
|
||||
#if HAVE_WEXT
|
||||
/* The kernel driver now uses nl80211, but we force use of WEXT because
|
||||
* the cfg80211 interactions are not quite ready to support access to
|
||||
* mesh control through nl80211 just yet.
|
||||
*/
|
||||
obj->_link.ext_data = (GObject *) nm_wifi_utils_wext_new (ifi->ifi_index, FALSE);
|
||||
#endif
|
||||
break;
|
||||
case NM_LINK_TYPE_WPAN:
|
||||
obj->_link.ext_data = (GObject *) nm_wpan_utils_new (ifi->ifi_index,
|
||||
_genl_sock (NM_LINUX_PLATFORM (platform)),
|
||||
TRUE);
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
obj->_link.netlink.is_in_netlink = TRUE;
|
||||
id_only_handled:
|
||||
obj_result = obj;
|
||||
|
|
@ -2966,6 +3023,8 @@ typedef struct {
|
|||
} DelayedActionWaitForNlResponseData;
|
||||
|
||||
typedef struct {
|
||||
struct nl_sock *genl;
|
||||
|
||||
struct nl_sock *nlh;
|
||||
guint32 nlh_seq_next;
|
||||
#ifdef NM_MORE_LOGGING
|
||||
|
|
@ -2997,8 +3056,6 @@ typedef struct {
|
|||
|
||||
gint is_handling;
|
||||
} delayed_action;
|
||||
|
||||
GHashTable *wifi_data;
|
||||
} NMLinuxPlatformPrivate;
|
||||
|
||||
struct _NMLinuxPlatform {
|
||||
|
|
@ -3038,6 +3095,14 @@ nm_linux_platform_setup (void)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
static struct nl_sock *
|
||||
_genl_sock (NMLinuxPlatform *platform)
|
||||
{
|
||||
NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform);
|
||||
|
||||
return priv->genl;
|
||||
}
|
||||
|
||||
#define ASSERT_SYSCTL_ARGS(pathid, dirfd, path) \
|
||||
G_STMT_START { \
|
||||
const char *const _pathid = (pathid); \
|
||||
|
|
@ -5718,6 +5783,41 @@ nla_put_failure:
|
|||
g_return_val_if_reached (FALSE);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
link_6lowpan_add (NMPlatform *platform,
|
||||
const char *name,
|
||||
int parent,
|
||||
const NMPlatformLink **out_link)
|
||||
{
|
||||
nm_auto_nlmsg struct nl_msg *nlmsg = NULL;
|
||||
struct nlattr *info;
|
||||
|
||||
nlmsg = _nl_msg_new_link (RTM_NEWLINK,
|
||||
NLM_F_CREATE | NLM_F_EXCL,
|
||||
0,
|
||||
name,
|
||||
0,
|
||||
0);
|
||||
if (!nlmsg)
|
||||
return FALSE;
|
||||
|
||||
NLA_PUT_U32 (nlmsg, IFLA_LINK, parent);
|
||||
|
||||
if (!(info = nla_nest_start (nlmsg, IFLA_LINKINFO)))
|
||||
goto nla_put_failure;
|
||||
|
||||
NLA_PUT_STRING (nlmsg, IFLA_INFO_KIND, "lowpan");
|
||||
|
||||
nla_nest_end (nlmsg, info);
|
||||
|
||||
return do_add_link_with_lookup (platform,
|
||||
NM_LINK_TYPE_6LOWPAN,
|
||||
name, nlmsg, out_link);
|
||||
nla_put_failure:
|
||||
g_return_val_if_reached (FALSE);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
_vlan_change_vlan_qos_mapping_create (gboolean is_ingress_map,
|
||||
gboolean reset_all,
|
||||
|
|
@ -5980,43 +6080,26 @@ infiniband_partition_delete (NMPlatform *platform, int parent, int p_key)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
static WifiData *
|
||||
wifi_get_wifi_data (NMPlatform *platform, int ifindex)
|
||||
static GObject *
|
||||
get_ext_data (NMPlatform *platform, int ifindex)
|
||||
{
|
||||
NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform);
|
||||
const NMPlatformLink *pllink;
|
||||
WifiData *wifi_data;
|
||||
const NMPObject *obj;
|
||||
|
||||
wifi_data = g_hash_table_lookup (priv->wifi_data, GINT_TO_POINTER (ifindex));
|
||||
pllink = nm_platform_link_get (platform, ifindex);
|
||||
obj = nmp_cache_lookup_link (nm_platform_get_cache (platform), ifindex);
|
||||
if (!obj)
|
||||
return NULL;
|
||||
|
||||
if (!wifi_data) {
|
||||
if (pllink) {
|
||||
if (pllink->type == NM_LINK_TYPE_WIFI)
|
||||
wifi_data = wifi_utils_init (ifindex, TRUE);
|
||||
else if (pllink->type == NM_LINK_TYPE_OLPC_MESH) {
|
||||
/* The kernel driver now uses nl80211, but we force use of WEXT because
|
||||
* the cfg80211 interactions are not quite ready to support access to
|
||||
* mesh control through nl80211 just yet.
|
||||
*/
|
||||
#if HAVE_WEXT
|
||||
wifi_data = wifi_wext_init (ifindex, FALSE);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (wifi_data)
|
||||
g_hash_table_insert (priv->wifi_data, GINT_TO_POINTER (ifindex), wifi_data);
|
||||
}
|
||||
}
|
||||
|
||||
return wifi_data;
|
||||
return obj->_link.ext_data;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#define WIFI_GET_WIFI_DATA_NETNS(wifi_data, platform, ifindex, retval) \
|
||||
nm_auto_pop_netns NMPNetns *netns = NULL; \
|
||||
WifiData *wifi_data; \
|
||||
NMWifiUtils *wifi_data; \
|
||||
if (!nm_platform_netns_push (platform, &netns)) \
|
||||
return retval; \
|
||||
wifi_data = wifi_get_wifi_data (platform, ifindex); \
|
||||
wifi_data = NM_WIFI_UTILS (get_ext_data (platform, ifindex)); \
|
||||
if (!wifi_data) \
|
||||
return retval;
|
||||
|
||||
|
|
@ -6025,7 +6108,7 @@ wifi_get_capabilities (NMPlatform *platform, int ifindex, NMDeviceWifiCapabiliti
|
|||
{
|
||||
WIFI_GET_WIFI_DATA_NETNS (wifi_data, platform, ifindex, FALSE);
|
||||
if (caps)
|
||||
*caps = wifi_utils_get_caps (wifi_data);
|
||||
*caps = nm_wifi_utils_get_caps (wifi_data);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
@ -6033,70 +6116,70 @@ static gboolean
|
|||
wifi_get_bssid (NMPlatform *platform, int ifindex, guint8 *bssid)
|
||||
{
|
||||
WIFI_GET_WIFI_DATA_NETNS (wifi_data, platform, ifindex, FALSE);
|
||||
return wifi_utils_get_bssid (wifi_data, bssid);
|
||||
return nm_wifi_utils_get_bssid (wifi_data, bssid);
|
||||
}
|
||||
|
||||
static guint32
|
||||
wifi_get_frequency (NMPlatform *platform, int ifindex)
|
||||
{
|
||||
WIFI_GET_WIFI_DATA_NETNS (wifi_data, platform, ifindex, 0);
|
||||
return wifi_utils_get_freq (wifi_data);
|
||||
return nm_wifi_utils_get_freq (wifi_data);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
wifi_get_quality (NMPlatform *platform, int ifindex)
|
||||
{
|
||||
WIFI_GET_WIFI_DATA_NETNS (wifi_data, platform, ifindex, FALSE);
|
||||
return wifi_utils_get_qual (wifi_data);
|
||||
return nm_wifi_utils_get_qual (wifi_data);
|
||||
}
|
||||
|
||||
static guint32
|
||||
wifi_get_rate (NMPlatform *platform, int ifindex)
|
||||
{
|
||||
WIFI_GET_WIFI_DATA_NETNS (wifi_data, platform, ifindex, FALSE);
|
||||
return wifi_utils_get_rate (wifi_data);
|
||||
return nm_wifi_utils_get_rate (wifi_data);
|
||||
}
|
||||
|
||||
static NM80211Mode
|
||||
wifi_get_mode (NMPlatform *platform, int ifindex)
|
||||
{
|
||||
WIFI_GET_WIFI_DATA_NETNS (wifi_data, platform, ifindex, NM_802_11_MODE_UNKNOWN);
|
||||
return wifi_utils_get_mode (wifi_data);
|
||||
return nm_wifi_utils_get_mode (wifi_data);
|
||||
}
|
||||
|
||||
static void
|
||||
wifi_set_mode (NMPlatform *platform, int ifindex, NM80211Mode mode)
|
||||
{
|
||||
WIFI_GET_WIFI_DATA_NETNS (wifi_data, platform, ifindex, );
|
||||
wifi_utils_set_mode (wifi_data, mode);
|
||||
nm_wifi_utils_set_mode (wifi_data, mode);
|
||||
}
|
||||
|
||||
static void
|
||||
wifi_set_powersave (NMPlatform *platform, int ifindex, guint32 powersave)
|
||||
{
|
||||
WIFI_GET_WIFI_DATA_NETNS (wifi_data, platform, ifindex, );
|
||||
wifi_utils_set_powersave (wifi_data, powersave);
|
||||
nm_wifi_utils_set_powersave (wifi_data, powersave);
|
||||
}
|
||||
|
||||
static guint32
|
||||
wifi_find_frequency (NMPlatform *platform, int ifindex, const guint32 *freqs)
|
||||
{
|
||||
WIFI_GET_WIFI_DATA_NETNS (wifi_data, platform, ifindex, 0);
|
||||
return wifi_utils_find_freq (wifi_data, freqs);
|
||||
return nm_wifi_utils_find_freq (wifi_data, freqs);
|
||||
}
|
||||
|
||||
static void
|
||||
wifi_indicate_addressing_running (NMPlatform *platform, int ifindex, gboolean running)
|
||||
{
|
||||
WIFI_GET_WIFI_DATA_NETNS (wifi_data, platform, ifindex, );
|
||||
wifi_utils_indicate_addressing_running (wifi_data, running);
|
||||
nm_wifi_utils_indicate_addressing_running (wifi_data, running);
|
||||
}
|
||||
|
||||
static NMSettingWirelessWakeOnWLan
|
||||
wifi_get_wake_on_wlan (NMPlatform *platform, int ifindex)
|
||||
{
|
||||
WIFI_GET_WIFI_DATA_NETNS (wifi_data, platform, ifindex, FALSE);
|
||||
return wifi_utils_get_wake_on_wlan (wifi_data);
|
||||
return nm_wifi_utils_get_wake_on_wlan (wifi_data);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
@ -6104,7 +6187,7 @@ wifi_set_wake_on_wlan (NMPlatform *platform, int ifindex,
|
|||
NMSettingWirelessWakeOnWLan wowl)
|
||||
{
|
||||
WIFI_GET_WIFI_DATA_NETNS (wifi_data, platform, ifindex, FALSE);
|
||||
return wifi_utils_set_wake_on_wlan (wifi_data, wowl);
|
||||
return nm_wifi_utils_set_wake_on_wlan (wifi_data, wowl);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
@ -6155,21 +6238,56 @@ static guint32
|
|||
mesh_get_channel (NMPlatform *platform, int ifindex)
|
||||
{
|
||||
WIFI_GET_WIFI_DATA_NETNS (wifi_data, platform, ifindex, 0);
|
||||
return wifi_utils_get_mesh_channel (wifi_data);
|
||||
return nm_wifi_utils_get_mesh_channel (wifi_data);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
mesh_set_channel (NMPlatform *platform, int ifindex, guint32 channel)
|
||||
{
|
||||
WIFI_GET_WIFI_DATA_NETNS (wifi_data, platform, ifindex, FALSE);
|
||||
return wifi_utils_set_mesh_channel (wifi_data, channel);
|
||||
return nm_wifi_utils_set_mesh_channel (wifi_data, channel);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
mesh_set_ssid (NMPlatform *platform, int ifindex, const guint8 *ssid, gsize len)
|
||||
{
|
||||
WIFI_GET_WIFI_DATA_NETNS (wifi_data, platform, ifindex, FALSE);
|
||||
return wifi_utils_set_mesh_ssid (wifi_data, ssid, len);
|
||||
return nm_wifi_utils_set_mesh_ssid (wifi_data, ssid, len);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#define WPAN_GET_WPAN_DATA(wpan_data, platform, ifindex, retval) \
|
||||
NMWpanUtils *wpan_data = NM_WPAN_UTILS (get_ext_data (platform, ifindex)); \
|
||||
if (!wpan_data) \
|
||||
return retval;
|
||||
|
||||
static guint16
|
||||
wpan_get_pan_id (NMPlatform *platform, int ifindex)
|
||||
{
|
||||
WPAN_GET_WPAN_DATA (wpan_data, platform, ifindex, G_MAXINT16);
|
||||
return nm_wpan_utils_get_pan_id (wpan_data);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
wpan_set_pan_id (NMPlatform *platform, int ifindex, guint16 pan_id)
|
||||
{
|
||||
WPAN_GET_WPAN_DATA (wpan_data, platform, ifindex, FALSE);
|
||||
return nm_wpan_utils_set_pan_id (wpan_data, pan_id);
|
||||
}
|
||||
|
||||
static guint16
|
||||
wpan_get_short_addr (NMPlatform *platform, int ifindex)
|
||||
{
|
||||
WPAN_GET_WPAN_DATA (wpan_data, platform, ifindex, G_MAXINT16);
|
||||
return nm_wpan_utils_get_short_addr (wpan_data);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
wpan_set_short_addr (NMPlatform *platform, int ifindex, guint16 short_addr)
|
||||
{
|
||||
WPAN_GET_WPAN_DATA (wpan_data, platform, ifindex, FALSE);
|
||||
return nm_wpan_utils_set_short_addr (wpan_data, short_addr);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
@ -6186,12 +6304,12 @@ link_get_wake_on_lan (NMPlatform *platform, int ifindex)
|
|||
if (type == NM_LINK_TYPE_ETHERNET)
|
||||
return nmp_utils_ethtool_get_wake_on_lan (ifindex);
|
||||
else if (type == NM_LINK_TYPE_WIFI) {
|
||||
WifiData *wifi_data = wifi_get_wifi_data (platform, ifindex);
|
||||
NMWifiUtils *wifi_data = NM_WIFI_UTILS (get_ext_data (platform, ifindex));
|
||||
|
||||
if (!wifi_data)
|
||||
return FALSE;
|
||||
|
||||
return wifi_utils_get_wowlan (wifi_data);
|
||||
return nm_wifi_utils_get_wake_on_wlan (wifi_data) != NM_SETTING_WIRELESS_WAKE_ON_WLAN_NONE;
|
||||
} else
|
||||
return FALSE;
|
||||
}
|
||||
|
|
@ -7013,7 +7131,6 @@ nm_linux_platform_init (NMLinuxPlatform *self)
|
|||
priv->delayed_action.list_master_connected = g_ptr_array_new ();
|
||||
priv->delayed_action.list_refresh_link = g_ptr_array_new ();
|
||||
priv->delayed_action.list_wait_for_nl_response = g_array_new (FALSE, TRUE, sizeof (DelayedActionWaitForNlResponseData));
|
||||
priv->wifi_data = g_hash_table_new_full (nm_direct_hash, NULL, NULL, (GDestroyNotify) wifi_utils_unref);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -7043,6 +7160,18 @@ constructed (GObject *_object)
|
|||
nmp_netns_get_current () == nmp_netns_get_initial () ? "/main" : "")),
|
||||
nm_platform_get_use_udev (platform) ? "use" : "no");
|
||||
|
||||
|
||||
priv->genl = nl_socket_alloc ();
|
||||
g_assert (priv->genl);
|
||||
|
||||
nle = nl_connect (priv->genl, NETLINK_GENERIC);
|
||||
if (nle) {
|
||||
_LOGE ("unable to connect the generic netlink socket \"%s\" (%d)",
|
||||
nl_geterror (nle), -nle);
|
||||
nl_socket_free (priv->genl);
|
||||
priv->genl = NULL;
|
||||
}
|
||||
|
||||
priv->nlh = nl_socket_alloc ();
|
||||
g_assert (priv->nlh);
|
||||
|
||||
|
|
@ -7161,12 +7290,12 @@ finalize (GObject *object)
|
|||
g_ptr_array_unref (priv->delayed_action.list_refresh_link);
|
||||
g_array_unref (priv->delayed_action.list_wait_for_nl_response);
|
||||
|
||||
nl_socket_free (priv->genl);
|
||||
|
||||
g_source_remove (priv->event_id);
|
||||
g_io_channel_unref (priv->event_channel);
|
||||
nl_socket_free (priv->nlh);
|
||||
|
||||
g_hash_table_unref (priv->wifi_data);
|
||||
|
||||
if (priv->sysctl_get_prev_values) {
|
||||
sysctl_clear_cache_list = g_slist_remove (sysctl_clear_cache_list, object);
|
||||
g_hash_table_destroy (priv->sysctl_get_prev_values);
|
||||
|
|
@ -7252,6 +7381,11 @@ nm_linux_platform_class_init (NMLinuxPlatformClass *klass)
|
|||
platform_class->mesh_set_channel = mesh_set_channel;
|
||||
platform_class->mesh_set_ssid = mesh_set_ssid;
|
||||
|
||||
platform_class->wpan_get_pan_id = wpan_get_pan_id;
|
||||
platform_class->wpan_set_pan_id = wpan_set_pan_id;
|
||||
platform_class->wpan_get_short_addr = wpan_get_short_addr;
|
||||
platform_class->wpan_set_short_addr = wpan_set_short_addr;
|
||||
|
||||
platform_class->link_gre_add = link_gre_add;
|
||||
platform_class->link_ip6tnl_add = link_ip6tnl_add;
|
||||
platform_class->link_macsec_add = link_macsec_add;
|
||||
|
|
@ -7259,6 +7393,7 @@ nm_linux_platform_class_init (NMLinuxPlatformClass *klass)
|
|||
platform_class->link_ipip_add = link_ipip_add;
|
||||
platform_class->link_sit_add = link_sit_add;
|
||||
platform_class->link_tun_add = link_tun_add;
|
||||
platform_class->link_6lowpan_add = link_6lowpan_add;
|
||||
|
||||
platform_class->object_delete = object_delete;
|
||||
platform_class->ip4_address_add = ip4_address_add;
|
||||
|
|
|
|||
|
|
@ -176,6 +176,12 @@ nla_get_u8 (const struct nlattr *nla)
|
|||
return *(const uint8_t *) nla_data (nla);
|
||||
}
|
||||
|
||||
static inline uint8_t
|
||||
nla_get_s8 (const struct nlattr *nla)
|
||||
{
|
||||
return *(const int8_t *) nla_data (nla);
|
||||
}
|
||||
|
||||
static inline uint8_t
|
||||
nla_get_u8_cond (/*const*/ struct nlattr *const*tb, int attr, uint8_t default_val)
|
||||
{
|
||||
|
|
@ -197,6 +203,12 @@ nla_get_u32(const struct nlattr *nla)
|
|||
return *(const uint32_t *) nla_data (nla);
|
||||
}
|
||||
|
||||
static inline int32_t
|
||||
nla_get_s32(const struct nlattr *nla)
|
||||
{
|
||||
return *(const int32_t *) nla_data (nla);
|
||||
}
|
||||
|
||||
uint64_t nla_get_u64 (const struct nlattr *nla);
|
||||
|
||||
static inline char *
|
||||
|
|
@ -232,12 +244,18 @@ nla_put_string (struct nl_msg *msg, int attrtype, const char *str)
|
|||
#define NLA_PUT_U8(msg, attrtype, value) \
|
||||
NLA_PUT_TYPE(msg, uint8_t, attrtype, value)
|
||||
|
||||
#define NLA_PUT_S8(msg, attrtype, value) \
|
||||
NLA_PUT_TYPE(msg, int8_t, attrtype, value)
|
||||
|
||||
#define NLA_PUT_U16(msg, attrtype, value) \
|
||||
NLA_PUT_TYPE(msg, uint16_t, attrtype, value)
|
||||
|
||||
#define NLA_PUT_U32(msg, attrtype, value) \
|
||||
NLA_PUT_TYPE(msg, uint32_t, attrtype, value)
|
||||
|
||||
#define NLA_PUT_S32(msg, attrtype, value) \
|
||||
NLA_PUT_TYPE(msg, int32_t, attrtype, value)
|
||||
|
||||
#define NLA_PUT_U64(msg, attrtype, value) \
|
||||
NLA_PUT_TYPE(msg, uint64_t, attrtype, value)
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright (C) 2012 - 2017 Red Hat, Inc.
|
||||
* Copyright (C) 2012 - 2018 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#include "nm-default.h"
|
||||
|
|
@ -807,6 +807,7 @@ _nm_platform_link_get_by_address_match_link (const NMPObject *obj, struct _nm_pl
|
|||
**/
|
||||
const NMPlatformLink *
|
||||
nm_platform_link_get_by_address (NMPlatform *self,
|
||||
NMLinkType link_type,
|
||||
gconstpointer address,
|
||||
size_t length)
|
||||
{
|
||||
|
|
@ -827,7 +828,7 @@ nm_platform_link_get_by_address (NMPlatform *self,
|
|||
g_return_val_if_reached (NULL);
|
||||
|
||||
obj = nmp_cache_lookup_link_full (nm_platform_get_cache (self),
|
||||
0, NULL, TRUE, NM_LINK_TYPE_NONE,
|
||||
0, NULL, TRUE, link_type,
|
||||
(NMPObjectMatchFn) _nm_platform_link_get_by_address_match_link, &d);
|
||||
return NMP_OBJECT_CAST_LINK (obj);
|
||||
}
|
||||
|
|
@ -2087,6 +2088,70 @@ nm_platform_link_tun_add (NMPlatform *self,
|
|||
return NM_PLATFORM_ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_platform_6lowpan_add:
|
||||
* @self: platform instance
|
||||
* @parent: parent link
|
||||
* @name: name of the new interface
|
||||
* @out_link: on success, the link object
|
||||
*
|
||||
* Create a 6LoWPAN interface.
|
||||
*/
|
||||
NMPlatformError
|
||||
nm_platform_link_6lowpan_add (NMPlatform *self,
|
||||
const char *name,
|
||||
int parent,
|
||||
const NMPlatformLink **out_link)
|
||||
{
|
||||
NMPlatformError plerr;
|
||||
|
||||
_CHECK_SELF (self, klass, NM_PLATFORM_ERROR_BUG);
|
||||
|
||||
g_return_val_if_fail (name, NM_PLATFORM_ERROR_BUG);
|
||||
|
||||
plerr = _link_add_check_existing (self, name, NM_LINK_TYPE_6LOWPAN, out_link);
|
||||
if (plerr != NM_PLATFORM_ERROR_SUCCESS)
|
||||
return plerr;
|
||||
|
||||
_LOGD ("adding 6lowpan '%s' parent %u", name, parent);
|
||||
|
||||
if (!klass->link_6lowpan_add (self, name, parent, out_link))
|
||||
return NM_PLATFORM_ERROR_UNSPECIFIED;
|
||||
return NM_PLATFORM_ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_platform_link_6lowpan_get_properties (NMPlatform *self, int ifindex, int *out_parent)
|
||||
{
|
||||
const NMPlatformLink *plink;
|
||||
_CHECK_SELF (self, klass, FALSE);
|
||||
|
||||
plink = nm_platform_link_get (self, ifindex);
|
||||
|
||||
if (!plink)
|
||||
return FALSE;
|
||||
if (plink->type != NM_LINK_TYPE_6LOWPAN)
|
||||
return FALSE;
|
||||
|
||||
if (plink->parent != 0) {
|
||||
NM_SET_OUT (out_parent, plink->parent);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* As of 4.16 kernel does not expose the peer_ifindex as IFA_LINK.
|
||||
* Find the WPAN device with the same MAC address. */
|
||||
if (out_parent) {
|
||||
const NMPlatformLink *parent_plink;
|
||||
|
||||
parent_plink = nm_platform_link_get_by_address (self, NM_LINK_TYPE_WPAN,
|
||||
plink->addr.data,
|
||||
plink->addr.len);
|
||||
NM_SET_OUT (out_parent, parent_plink ? parent_plink->ifindex : -1);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static gboolean
|
||||
|
|
@ -2538,6 +2603,7 @@ nm_platform_link_ipip_add (NMPlatform *self,
|
|||
* nm_platform_macsec_add:
|
||||
* @self: platform instance
|
||||
* @name: name of the new interface
|
||||
* @parent: parent link
|
||||
* @props: interface properties
|
||||
* @out_link: on success, the link object
|
||||
*
|
||||
|
|
@ -2939,6 +3005,46 @@ nm_platform_mesh_set_ssid (NMPlatform *self, int ifindex, const guint8 *ssid, gs
|
|||
return klass->mesh_set_ssid (self, ifindex, ssid, len);
|
||||
}
|
||||
|
||||
guint16
|
||||
nm_platform_wpan_get_pan_id (NMPlatform *self, int ifindex)
|
||||
{
|
||||
_CHECK_SELF (self, klass, FALSE);
|
||||
|
||||
g_return_val_if_fail (ifindex > 0, FALSE);
|
||||
|
||||
return klass->wpan_get_pan_id (self, ifindex);
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_platform_wpan_set_pan_id (NMPlatform *self, int ifindex, guint16 pan_id)
|
||||
{
|
||||
_CHECK_SELF (self, klass, FALSE);
|
||||
|
||||
g_return_val_if_fail (ifindex > 0, FALSE);
|
||||
|
||||
return klass->wpan_set_pan_id (self, ifindex, pan_id);
|
||||
}
|
||||
|
||||
guint16
|
||||
nm_platform_wpan_get_short_addr (NMPlatform *self, int ifindex)
|
||||
{
|
||||
_CHECK_SELF (self, klass, FALSE);
|
||||
|
||||
g_return_val_if_fail (ifindex > 0, FALSE);
|
||||
|
||||
return klass->wpan_get_short_addr (self, ifindex);
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_platform_wpan_set_short_addr (NMPlatform *self, int ifindex, guint16 short_addr)
|
||||
{
|
||||
_CHECK_SELF (self, klass, FALSE);
|
||||
|
||||
g_return_val_if_fail (ifindex > 0, FALSE);
|
||||
|
||||
return klass->wpan_set_short_addr (self, ifindex, short_addr);
|
||||
}
|
||||
|
||||
#define TO_STRING_DEV_BUF_SIZE (5+15+1)
|
||||
static const char *
|
||||
_to_string_dev (NMPlatform *self, int ifindex, char *buf, size_t size)
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright (C) 2009 - 2017 Red Hat, Inc.
|
||||
* Copyright (C) 2009 - 2018 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#ifndef __NETWORKMANAGER_PLATFORM_H__
|
||||
|
|
@ -854,6 +854,11 @@ typedef struct {
|
|||
const NMPlatformLink **out_link,
|
||||
int *out_fd);
|
||||
|
||||
gboolean (*link_6lowpan_add) (NMPlatform *platform,
|
||||
const char *name,
|
||||
int parent,
|
||||
const NMPlatformLink **out_link);
|
||||
|
||||
gboolean (*infiniband_partition_add) (NMPlatform *, int parent, int p_key, const NMPlatformLink **out_link);
|
||||
gboolean (*infiniband_partition_delete) (NMPlatform *, int parent, int p_key);
|
||||
|
||||
|
|
@ -875,6 +880,11 @@ typedef struct {
|
|||
gboolean (*mesh_set_channel) (NMPlatform *, int ifindex, guint32 channel);
|
||||
gboolean (*mesh_set_ssid) (NMPlatform *, int ifindex, const guint8 *ssid, gsize len);
|
||||
|
||||
guint16 (*wpan_get_pan_id) (NMPlatform *, int ifindex);
|
||||
gboolean (*wpan_set_pan_id) (NMPlatform *, int ifindex, guint16 pan_id);
|
||||
guint16 (*wpan_get_short_addr) (NMPlatform *, int ifindex);
|
||||
gboolean (*wpan_set_short_addr) (NMPlatform *, int ifindex, guint16 short_addr);
|
||||
|
||||
gboolean (*object_delete) (NMPlatform *, const NMPObject *obj);
|
||||
|
||||
gboolean (*ip4_address_add) (NMPlatform *,
|
||||
|
|
@ -1079,7 +1089,7 @@ const NMPObject *nm_platform_link_get_obj (NMPlatform *self,
|
|||
gboolean visible_only);
|
||||
const NMPlatformLink *nm_platform_link_get (NMPlatform *self, int ifindex);
|
||||
const NMPlatformLink *nm_platform_link_get_by_ifname (NMPlatform *self, const char *ifname);
|
||||
const NMPlatformLink *nm_platform_link_get_by_address (NMPlatform *self, gconstpointer address, size_t length);
|
||||
const NMPlatformLink *nm_platform_link_get_by_address (NMPlatform *self, NMLinkType link_type, gconstpointer address, size_t length);
|
||||
|
||||
GPtrArray *nm_platform_link_get_all (NMPlatform *self, gboolean sort_by_name);
|
||||
NMPlatformError nm_platform_link_dummy_add (NMPlatform *self, const char *name, const NMPlatformLink **out_link);
|
||||
|
|
@ -1255,6 +1265,11 @@ guint32 nm_platform_mesh_get_channel (NMPlatform *self, int ifindex);
|
|||
gboolean nm_platform_mesh_set_channel (NMPlatform *self, int ifindex, guint32 channel);
|
||||
gboolean nm_platform_mesh_set_ssid (NMPlatform *self, int ifindex, const guint8 *ssid, gsize len);
|
||||
|
||||
guint16 nm_platform_wpan_get_pan_id (NMPlatform *platform, int ifindex);
|
||||
gboolean nm_platform_wpan_set_pan_id (NMPlatform *platform, int ifindex, guint16 pan_id);
|
||||
guint16 nm_platform_wpan_get_short_addr (NMPlatform *platform, int ifindex);
|
||||
gboolean nm_platform_wpan_set_short_addr (NMPlatform *platform, int ifindex, guint16 short_addr);
|
||||
|
||||
void nm_platform_ip4_address_set_addr (NMPlatformIP4Address *addr, in_addr_t address, guint8 plen);
|
||||
const struct in6_addr *nm_platform_ip6_address_get_peer (const NMPlatformIP6Address *addr);
|
||||
|
||||
|
|
@ -1291,6 +1306,13 @@ NMPlatformError nm_platform_link_tun_add (NMPlatform *self,
|
|||
const NMPlatformLnkTun *props,
|
||||
const NMPlatformLink **out_link,
|
||||
int *out_fd);
|
||||
NMPlatformError nm_platform_link_6lowpan_add (NMPlatform *self,
|
||||
const char *name,
|
||||
int parent,
|
||||
const NMPlatformLink **out_link);
|
||||
gboolean nm_platform_link_6lowpan_get_properties (NMPlatform *self,
|
||||
int ifindex,
|
||||
int *out_parent);
|
||||
|
||||
const NMPlatformIP6Address *nm_platform_ip6_address_get (NMPlatform *self, int ifindex, struct in6_addr address);
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright (C) 2015 - 2017 Red Hat, Inc.
|
||||
* Copyright (C) 2015 - 2018 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#include "nm-default.h"
|
||||
|
|
@ -31,6 +31,9 @@
|
|||
#include "nm-core-utils.h"
|
||||
#include "nm-platform-utils.h"
|
||||
|
||||
#include "wifi/nm-wifi-utils.h"
|
||||
#include "wpan/nm-wpan-utils.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#define _NMLOG_DOMAIN LOGD_PLATFORM
|
||||
|
|
@ -456,6 +459,7 @@ _vt_cmd_obj_dispose_link (NMPObject *obj)
|
|||
udev_device_unref (obj->_link.udev.device);
|
||||
obj->_link.udev.device = NULL;
|
||||
}
|
||||
g_clear_object (&obj->_link.ext_data);
|
||||
nmp_object_unref (obj->_link.netlink.lnk);
|
||||
}
|
||||
|
||||
|
|
@ -908,6 +912,12 @@ _vt_cmd_obj_copy_link (NMPObject *dst, const NMPObject *src)
|
|||
nmp_object_unref (dst->_link.netlink.lnk);
|
||||
dst->_link.netlink.lnk = src->_link.netlink.lnk;
|
||||
}
|
||||
if (dst->_link.ext_data != src->_link.ext_data) {
|
||||
if (dst->_link.ext_data)
|
||||
g_clear_object (&dst->_link.ext_data);
|
||||
if (src->_link.ext_data)
|
||||
dst->_link.ext_data = g_object_ref (src->_link.ext_data);
|
||||
}
|
||||
dst->_link = src->_link;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright (C) 2015 - 2017 Red Hat, Inc.
|
||||
* Copyright (C) 2015 - 2018 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#ifndef __NMP_OBJECT_H__
|
||||
|
|
@ -164,6 +164,9 @@ typedef struct {
|
|||
*/
|
||||
struct udev_device *device;
|
||||
} udev;
|
||||
|
||||
/* Auxiliary data object for Wi-Fi and WPAN */
|
||||
GObject *ext_data;
|
||||
} NMPObjectLink;
|
||||
|
||||
typedef struct {
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright (C) 2015 Red Hat, Inc.
|
||||
* Copyright (C) 2015 - 2018 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#include "nm-default.h"
|
||||
|
|
@ -57,7 +57,7 @@ NMTST_DEFINE ();
|
|||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
nmtst_init_assert_logging (&argc, &argv, "INFO", "DEFAULT");
|
||||
nmtst_init_assert_logging (&argc, &argv, "WARN", "DEFAULT");
|
||||
|
||||
g_test_add_func ("/general/init_linux_platform", test_init_linux_platform);
|
||||
g_test_add_func ("/general/link_get_all", test_link_get_all);
|
||||
|
|
|
|||
|
|
@ -15,14 +15,14 @@
|
|||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright (C) 2005 - 2011 Red Hat, Inc.
|
||||
* Copyright (C) 2005 - 2018 Red Hat, Inc.
|
||||
* Copyright (C) 2006 - 2008 Novell, Inc.
|
||||
* Copyright (C) 2011 Intel Corporation. All rights reserved.
|
||||
*/
|
||||
|
||||
#include "nm-default.h"
|
||||
|
||||
#include "wifi-utils-nl80211.h"
|
||||
#include "nm-wifi-utils-nl80211.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
|
@ -32,7 +32,7 @@
|
|||
#include <linux/nl80211.h>
|
||||
|
||||
#include "platform/nm-netlink.h"
|
||||
#include "wifi-utils-private.h"
|
||||
#include "nm-wifi-utils-private.h"
|
||||
#include "platform/nm-platform.h"
|
||||
#include "platform/nm-platform-utils.h"
|
||||
#include "nm-utils.h"
|
||||
|
|
@ -47,14 +47,20 @@
|
|||
} G_STMT_END
|
||||
|
||||
typedef struct {
|
||||
WifiData parent;
|
||||
NMWifiUtils parent;
|
||||
struct nl_sock *nl_sock;
|
||||
guint32 *freqs;
|
||||
int id;
|
||||
int num_freqs;
|
||||
int phy;
|
||||
bool can_wowlan:1;
|
||||
} WifiDataNl80211;
|
||||
} NMWifiUtilsNl80211;
|
||||
|
||||
typedef struct {
|
||||
NMWifiUtilsClass parent;
|
||||
} NMWifiUtilsNl80211Class;
|
||||
|
||||
G_DEFINE_TYPE (NMWifiUtilsNl80211, nm_wifi_utils_nl80211, NM_TYPE_WIFI_UTILS)
|
||||
|
||||
static int
|
||||
ack_handler (struct nl_msg *msg, void *arg)
|
||||
|
|
@ -97,7 +103,7 @@ nla_put_failure:
|
|||
}
|
||||
|
||||
static struct nl_msg *
|
||||
nl80211_alloc_msg (WifiDataNl80211 *nl80211, guint32 cmd, guint32 flags)
|
||||
nl80211_alloc_msg (NMWifiUtilsNl80211 *nl80211, guint32 cmd, guint32 flags)
|
||||
{
|
||||
return _nl80211_alloc_msg (nl80211->id, nl80211->parent.ifindex, nl80211->phy, cmd, flags);
|
||||
}
|
||||
|
|
@ -154,7 +160,7 @@ _nl80211_send_and_recv (struct nl_sock *nl_sock,
|
|||
}
|
||||
|
||||
static int
|
||||
nl80211_send_and_recv (WifiDataNl80211 *nl80211,
|
||||
nl80211_send_and_recv (NMWifiUtilsNl80211 *nl80211,
|
||||
struct nl_msg *msg,
|
||||
int (*valid_handler) (struct nl_msg *, void *),
|
||||
void *valid_data)
|
||||
|
|
@ -164,13 +170,11 @@ nl80211_send_and_recv (WifiDataNl80211 *nl80211,
|
|||
}
|
||||
|
||||
static void
|
||||
wifi_nl80211_deinit (WifiData *parent)
|
||||
dispose (GObject *object)
|
||||
{
|
||||
WifiDataNl80211 *nl80211 = (WifiDataNl80211 *) parent;
|
||||
NMWifiUtilsNl80211 *nl80211 = NM_WIFI_UTILS_NL80211 (object);
|
||||
|
||||
if (nl80211->nl_sock)
|
||||
nl_socket_free (nl80211->nl_sock);
|
||||
g_free (nl80211->freqs);
|
||||
g_clear_pointer (&nl80211->freqs, g_free);
|
||||
}
|
||||
|
||||
struct nl80211_iface_info {
|
||||
|
|
@ -207,9 +211,9 @@ nl80211_iface_info_handler (struct nl_msg *msg, void *arg)
|
|||
}
|
||||
|
||||
static NM80211Mode
|
||||
wifi_nl80211_get_mode (WifiData *data)
|
||||
wifi_nl80211_get_mode (NMWifiUtils *data)
|
||||
{
|
||||
WifiDataNl80211 *nl80211 = (WifiDataNl80211 *) data;
|
||||
NMWifiUtilsNl80211 *nl80211 = (NMWifiUtilsNl80211 *) data;
|
||||
struct nl80211_iface_info iface_info = {
|
||||
.mode = NM_802_11_MODE_UNKNOWN,
|
||||
};
|
||||
|
|
@ -225,9 +229,9 @@ wifi_nl80211_get_mode (WifiData *data)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
wifi_nl80211_set_mode (WifiData *data, const NM80211Mode mode)
|
||||
wifi_nl80211_set_mode (NMWifiUtils *data, const NM80211Mode mode)
|
||||
{
|
||||
WifiDataNl80211 *nl80211 = (WifiDataNl80211 *) data;
|
||||
NMWifiUtilsNl80211 *nl80211 = (NMWifiUtilsNl80211 *) data;
|
||||
nm_auto_nlmsg struct nl_msg *msg = NULL;
|
||||
int err;
|
||||
|
||||
|
|
@ -255,9 +259,9 @@ nla_put_failure:
|
|||
}
|
||||
|
||||
static gboolean
|
||||
wifi_nl80211_set_powersave (WifiData *data, guint32 powersave)
|
||||
wifi_nl80211_set_powersave (NMWifiUtils *data, guint32 powersave)
|
||||
{
|
||||
WifiDataNl80211 *nl80211 = (WifiDataNl80211 *) data;
|
||||
NMWifiUtilsNl80211 *nl80211 = (NMWifiUtilsNl80211 *) data;
|
||||
nm_auto_nlmsg struct nl_msg *msg = NULL;
|
||||
int err;
|
||||
|
||||
|
|
@ -312,9 +316,9 @@ nl80211_get_wake_on_wlan_handler (struct nl_msg *msg, void *arg)
|
|||
}
|
||||
|
||||
static NMSettingWirelessWakeOnWLan
|
||||
wifi_nl80211_get_wake_on_wlan (WifiData *data)
|
||||
wifi_nl80211_get_wake_on_wlan (NMWifiUtils *data)
|
||||
{
|
||||
WifiDataNl80211 *nl80211 = (WifiDataNl80211 *) data;
|
||||
NMWifiUtilsNl80211 *nl80211 = (NMWifiUtilsNl80211 *) data;
|
||||
NMSettingWirelessWakeOnWLan wowl = NM_SETTING_WIRELESS_WAKE_ON_WLAN_IGNORE;
|
||||
nm_auto_nlmsg struct nl_msg *msg = NULL;
|
||||
|
||||
|
|
@ -326,9 +330,9 @@ wifi_nl80211_get_wake_on_wlan (WifiData *data)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
wifi_nl80211_set_wake_on_wlan (WifiData *data, NMSettingWirelessWakeOnWLan wowl)
|
||||
wifi_nl80211_set_wake_on_wlan (NMWifiUtils *data, NMSettingWirelessWakeOnWLan wowl)
|
||||
{
|
||||
WifiDataNl80211 *nl80211 = (WifiDataNl80211 *) data;
|
||||
NMWifiUtilsNl80211 *nl80211 = (NMWifiUtilsNl80211 *) data;
|
||||
nm_auto_nlmsg struct nl_msg *msg = NULL;
|
||||
struct nlattr *triggers;
|
||||
int err;
|
||||
|
|
@ -487,7 +491,7 @@ nl80211_bss_dump_handler (struct nl_msg *msg, void *arg)
|
|||
}
|
||||
|
||||
static void
|
||||
nl80211_get_bss_info (WifiDataNl80211 *nl80211,
|
||||
nl80211_get_bss_info (NMWifiUtilsNl80211 *nl80211,
|
||||
struct nl80211_bss_info *bss_info)
|
||||
{
|
||||
nm_auto_nlmsg struct nl_msg *msg = NULL;
|
||||
|
|
@ -500,9 +504,9 @@ nl80211_get_bss_info (WifiDataNl80211 *nl80211,
|
|||
}
|
||||
|
||||
static guint32
|
||||
wifi_nl80211_get_freq (WifiData *data)
|
||||
wifi_nl80211_get_freq (NMWifiUtils *data)
|
||||
{
|
||||
WifiDataNl80211 *nl80211 = (WifiDataNl80211 *) data;
|
||||
NMWifiUtilsNl80211 *nl80211 = (NMWifiUtilsNl80211 *) data;
|
||||
struct nl80211_bss_info bss_info;
|
||||
|
||||
nl80211_get_bss_info (nl80211, &bss_info);
|
||||
|
|
@ -511,9 +515,9 @@ wifi_nl80211_get_freq (WifiData *data)
|
|||
}
|
||||
|
||||
static guint32
|
||||
wifi_nl80211_find_freq (WifiData *data, const guint32 *freqs)
|
||||
wifi_nl80211_find_freq (NMWifiUtils *data, const guint32 *freqs)
|
||||
{
|
||||
WifiDataNl80211 *nl80211 = (WifiDataNl80211 *) data;
|
||||
NMWifiUtilsNl80211 *nl80211 = (NMWifiUtilsNl80211 *) data;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < nl80211->num_freqs; i++) {
|
||||
|
|
@ -527,9 +531,9 @@ wifi_nl80211_find_freq (WifiData *data, const guint32 *freqs)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
wifi_nl80211_get_bssid (WifiData *data, guint8 *out_bssid)
|
||||
wifi_nl80211_get_bssid (NMWifiUtils *data, guint8 *out_bssid)
|
||||
{
|
||||
WifiDataNl80211 *nl80211 = (WifiDataNl80211 *) data;
|
||||
NMWifiUtilsNl80211 *nl80211 = (NMWifiUtilsNl80211 *) data;
|
||||
struct nl80211_bss_info bss_info;
|
||||
|
||||
nl80211_get_bss_info (nl80211, &bss_info);
|
||||
|
|
@ -611,7 +615,7 @@ nl80211_station_handler (struct nl_msg *msg, void *arg)
|
|||
}
|
||||
|
||||
static void
|
||||
nl80211_get_ap_info (WifiDataNl80211 *nl80211,
|
||||
nl80211_get_ap_info (NMWifiUtilsNl80211 *nl80211,
|
||||
struct nl80211_station_info *sta_info)
|
||||
{
|
||||
nm_auto_nlmsg struct nl_msg *msg = NULL;
|
||||
|
|
@ -641,9 +645,9 @@ nla_put_failure:
|
|||
}
|
||||
|
||||
static guint32
|
||||
wifi_nl80211_get_rate (WifiData *data)
|
||||
wifi_nl80211_get_rate (NMWifiUtils *data)
|
||||
{
|
||||
WifiDataNl80211 *nl80211 = (WifiDataNl80211 *) data;
|
||||
NMWifiUtilsNl80211 *nl80211 = (NMWifiUtilsNl80211 *) data;
|
||||
struct nl80211_station_info sta_info;
|
||||
|
||||
nl80211_get_ap_info (nl80211, &sta_info);
|
||||
|
|
@ -652,9 +656,9 @@ wifi_nl80211_get_rate (WifiData *data)
|
|||
}
|
||||
|
||||
static int
|
||||
wifi_nl80211_get_qual (WifiData *data)
|
||||
wifi_nl80211_get_qual (NMWifiUtils *data)
|
||||
{
|
||||
WifiDataNl80211 *nl80211 = (WifiDataNl80211 *) data;
|
||||
NMWifiUtilsNl80211 *nl80211 = (NMWifiUtilsNl80211 *) data;
|
||||
struct nl80211_station_info sta_info;
|
||||
|
||||
nl80211_get_ap_info (nl80211, &sta_info);
|
||||
|
|
@ -662,9 +666,9 @@ wifi_nl80211_get_qual (WifiData *data)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
wifi_nl80211_indicate_addressing_running (WifiData *data, gboolean running)
|
||||
wifi_nl80211_indicate_addressing_running (NMWifiUtils *data, gboolean running)
|
||||
{
|
||||
WifiDataNl80211 *nl80211 = (WifiDataNl80211 *) data;
|
||||
NMWifiUtilsNl80211 *nl80211 = (NMWifiUtilsNl80211 *) data;
|
||||
nm_auto_nlmsg struct nl_msg *msg = NULL;
|
||||
int err;
|
||||
|
||||
|
|
@ -693,44 +697,6 @@ nla_put_failure:
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
struct nl80211_wowlan_info {
|
||||
gboolean enabled;
|
||||
};
|
||||
|
||||
static int
|
||||
nl80211_wowlan_handler (struct nl_msg *msg, void *arg)
|
||||
{
|
||||
struct nlattr *tb[NL80211_ATTR_MAX + 1];
|
||||
struct genlmsghdr *gnlh = nlmsg_data (nlmsg_hdr (msg));
|
||||
struct nl80211_wowlan_info *info = arg;
|
||||
|
||||
info->enabled = FALSE;
|
||||
|
||||
if (nla_parse (tb, NL80211_ATTR_MAX, genlmsg_attrdata (gnlh, 0),
|
||||
genlmsg_attrlen (gnlh, 0), NULL) < 0)
|
||||
return NL_SKIP;
|
||||
|
||||
if (tb[NL80211_ATTR_WOWLAN_TRIGGERS])
|
||||
info->enabled = TRUE;
|
||||
|
||||
return NL_SKIP;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
wifi_nl80211_get_wowlan (WifiData *data)
|
||||
{
|
||||
WifiDataNl80211 *nl80211 = (WifiDataNl80211 *) data;
|
||||
nm_auto_nlmsg struct nl_msg *msg = NULL;
|
||||
struct nl80211_wowlan_info info;
|
||||
|
||||
if (!nl80211->can_wowlan)
|
||||
return FALSE;
|
||||
|
||||
msg = nl80211_alloc_msg (nl80211, NL80211_CMD_GET_WOWLAN, 0);
|
||||
nl80211_send_and_recv (nl80211, msg, nl80211_wowlan_handler, &info);
|
||||
return info.enabled;
|
||||
}
|
||||
|
||||
struct nl80211_device_info {
|
||||
int phy;
|
||||
guint32 *freqs;
|
||||
|
|
@ -934,44 +900,53 @@ static int nl80211_wiphy_info_handler (struct nl_msg *msg, void *arg)
|
|||
return NL_SKIP;
|
||||
}
|
||||
|
||||
WifiData *
|
||||
wifi_nl80211_init (int ifindex)
|
||||
static void
|
||||
nm_wifi_utils_nl80211_init (NMWifiUtilsNl80211 *self)
|
||||
{
|
||||
static const WifiDataClass klass = {
|
||||
.struct_size = sizeof (WifiDataNl80211),
|
||||
.get_mode = wifi_nl80211_get_mode,
|
||||
.set_mode = wifi_nl80211_set_mode,
|
||||
.set_powersave = wifi_nl80211_set_powersave,
|
||||
.get_wake_on_wlan = wifi_nl80211_get_wake_on_wlan,
|
||||
.set_wake_on_wlan = wifi_nl80211_set_wake_on_wlan,
|
||||
.get_freq = wifi_nl80211_get_freq,
|
||||
.find_freq = wifi_nl80211_find_freq,
|
||||
.get_bssid = wifi_nl80211_get_bssid,
|
||||
.get_rate = wifi_nl80211_get_rate,
|
||||
.get_qual = wifi_nl80211_get_qual,
|
||||
.get_wowlan = wifi_nl80211_get_wowlan,
|
||||
.indicate_addressing_running = wifi_nl80211_indicate_addressing_running,
|
||||
.deinit = wifi_nl80211_deinit,
|
||||
};
|
||||
WifiDataNl80211 *nl80211;
|
||||
}
|
||||
|
||||
static void
|
||||
nm_wifi_utils_nl80211_class_init (NMWifiUtilsNl80211Class *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
NMWifiUtilsClass *wifi_utils_class = NM_WIFI_UTILS_CLASS (klass);
|
||||
|
||||
object_class->dispose = dispose;
|
||||
|
||||
wifi_utils_class->get_mode = wifi_nl80211_get_mode;
|
||||
wifi_utils_class->set_mode = wifi_nl80211_set_mode;
|
||||
wifi_utils_class->set_powersave = wifi_nl80211_set_powersave;
|
||||
wifi_utils_class->get_wake_on_wlan = wifi_nl80211_get_wake_on_wlan,
|
||||
wifi_utils_class->set_wake_on_wlan = wifi_nl80211_set_wake_on_wlan,
|
||||
wifi_utils_class->get_freq = wifi_nl80211_get_freq;
|
||||
wifi_utils_class->find_freq = wifi_nl80211_find_freq;
|
||||
wifi_utils_class->get_bssid = wifi_nl80211_get_bssid;
|
||||
wifi_utils_class->get_rate = wifi_nl80211_get_rate;
|
||||
wifi_utils_class->get_qual = wifi_nl80211_get_qual;
|
||||
wifi_utils_class->indicate_addressing_running = wifi_nl80211_indicate_addressing_running;
|
||||
}
|
||||
|
||||
NMWifiUtils *
|
||||
nm_wifi_utils_nl80211_new (int ifindex, struct nl_sock *genl)
|
||||
{
|
||||
NMWifiUtilsNl80211 *nl80211;
|
||||
nm_auto_nlmsg struct nl_msg *msg = NULL;
|
||||
struct nl80211_device_info device_info = {};
|
||||
char ifname[IFNAMSIZ];
|
||||
|
||||
if (!genl)
|
||||
return NULL;
|
||||
|
||||
if (!nmp_utils_if_indextoname (ifindex, ifname)) {
|
||||
_LOGW (LOGD_PLATFORM | LOGD_WIFI,
|
||||
"can't determine interface name for ifindex %d", ifindex);
|
||||
nm_sprintf_buf (ifname, "if %d", ifindex);
|
||||
}
|
||||
|
||||
nl80211 = wifi_data_new (&klass, ifindex);
|
||||
nl80211 = g_object_new (NM_TYPE_WIFI_UTILS_NL80211, NULL);
|
||||
|
||||
nl80211->nl_sock = nl_socket_alloc ();
|
||||
if (nl80211->nl_sock == NULL)
|
||||
goto error;
|
||||
|
||||
if (nl_connect (nl80211->nl_sock, NETLINK_GENERIC))
|
||||
goto error;
|
||||
nl80211->parent.ifindex = ifindex;
|
||||
nl80211->nl_sock = genl;
|
||||
|
||||
nl80211->id = genl_ctrl_resolve (nl80211->nl_sock, "nl80211");
|
||||
if (nl80211->id < 0) {
|
||||
|
|
@ -1035,10 +1010,9 @@ wifi_nl80211_init (int ifindex)
|
|||
_LOGI (LOGD_PLATFORM | LOGD_WIFI,
|
||||
"(%s): using nl80211 for WiFi device control",
|
||||
ifname);
|
||||
return (WifiData *) nl80211;
|
||||
return (NMWifiUtils *) nl80211;
|
||||
|
||||
error:
|
||||
wifi_utils_unref ((WifiData *) nl80211);
|
||||
g_object_unref (nl80211);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -16,13 +16,24 @@
|
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright (C) 2011 Intel Corporation. All rights reserved.
|
||||
* Copyright (C) 2018 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#ifndef __WIFI_UTILS_NL80211_H__
|
||||
#define __WIFI_UTILS_NL80211_H__
|
||||
|
||||
#include "wifi-utils.h"
|
||||
#include "nm-wifi-utils.h"
|
||||
#include "platform/nm-netlink.h"
|
||||
|
||||
WifiData *wifi_nl80211_init (int ifindex);
|
||||
#define NM_TYPE_WIFI_UTILS_NL80211 (nm_wifi_utils_nl80211_get_type ())
|
||||
#define NM_WIFI_UTILS_NL80211(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_WIFI_UTILS_NL80211, NMWifiUtilsNl80211))
|
||||
#define NM_WIFI_UTILS_NL80211_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_WIFI_UTILS_NL80211, NMWifiUtilsNl80211Class))
|
||||
#define NM_IS_WIFI_UTILS_NL80211(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_WIFI_UTILS_NL80211))
|
||||
#define NM_IS_WIFI_UTILS_NL80211_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_WIFI_UTILS_NL80211))
|
||||
#define NM_WIFI_UTILS_NL80211_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_WIFI_UTILS_NL80211, NMWifiUtilsNl80211Class))
|
||||
|
||||
GType nm_wifi_utils_nl80211_get_type (void);
|
||||
|
||||
NMWifiUtils *nm_wifi_utils_nl80211_new (int ifindex, struct nl_sock *genl);
|
||||
|
||||
#endif /* __WIFI_UTILS_NL80211_H__ */
|
||||
|
|
@ -15,70 +15,65 @@
|
|||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright (C) 2011 Red Hat, Inc.
|
||||
* Copyright (C) 2011 - 2018 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#ifndef __WIFI_UTILS_PRIVATE_H__
|
||||
#define __WIFI_UTILS_PRIVATE_H__
|
||||
|
||||
#include "nm-dbus-interface.h"
|
||||
#include "wifi-utils.h"
|
||||
#include "nm-wifi-utils.h"
|
||||
|
||||
typedef struct {
|
||||
gsize struct_size;
|
||||
GObjectClass parent;
|
||||
|
||||
NM80211Mode (*get_mode) (WifiData *data);
|
||||
NM80211Mode (*get_mode) (NMWifiUtils *data);
|
||||
|
||||
gboolean (*set_mode) (WifiData *data, const NM80211Mode mode);
|
||||
gboolean (*set_mode) (NMWifiUtils *data, const NM80211Mode mode);
|
||||
|
||||
/* Set power saving mode on an interface */
|
||||
gboolean (*set_powersave) (WifiData *data, guint32 powersave);
|
||||
gboolean (*set_powersave) (NMWifiUtils *data, guint32 powersave);
|
||||
|
||||
/* Get WakeOnWLAN configuration on an interface */
|
||||
NMSettingWirelessWakeOnWLan (*get_wake_on_wlan) (WifiData *data);
|
||||
NMSettingWirelessWakeOnWLan (*get_wake_on_wlan) (NMWifiUtils *data);
|
||||
|
||||
/* Set WakeOnWLAN mode on an interface */
|
||||
gboolean (*set_wake_on_wlan) (WifiData *data, NMSettingWirelessWakeOnWLan wowl);
|
||||
gboolean (*set_wake_on_wlan) (NMWifiUtils *data, NMSettingWirelessWakeOnWLan wowl);
|
||||
|
||||
/* Return current frequency in MHz (really associated BSS frequency) */
|
||||
guint32 (*get_freq) (WifiData *data);
|
||||
guint32 (*get_freq) (NMWifiUtils *data);
|
||||
|
||||
/* Return first supported frequency in the zero-terminated list */
|
||||
guint32 (*find_freq) (WifiData *data, const guint32 *freqs);
|
||||
guint32 (*find_freq) (NMWifiUtils *data, const guint32 *freqs);
|
||||
|
||||
/* Return current bitrate in Kbps */
|
||||
guint32 (*get_rate) (WifiData *data);
|
||||
guint32 (*get_rate) (NMWifiUtils *data);
|
||||
|
||||
gboolean (*get_bssid) (WifiData *data, guint8 *out_bssid);
|
||||
gboolean (*get_bssid) (NMWifiUtils *data, guint8 *out_bssid);
|
||||
|
||||
/* Return a signal strength percentage 0 - 100% for the current BSSID;
|
||||
* return -1 on errors or if not associated.
|
||||
*/
|
||||
int (*get_qual) (WifiData *data);
|
||||
|
||||
void (*deinit) (WifiData *data);
|
||||
|
||||
gboolean (*get_wowlan) (WifiData *data);
|
||||
int (*get_qual) (NMWifiUtils *data);
|
||||
|
||||
/* OLPC Mesh-only functions */
|
||||
|
||||
guint32 (*get_mesh_channel) (WifiData *data);
|
||||
guint32 (*get_mesh_channel) (NMWifiUtils *data);
|
||||
|
||||
/* channel == 0 means "auto channel" */
|
||||
gboolean (*set_mesh_channel) (WifiData *data, guint32 channel);
|
||||
gboolean (*set_mesh_channel) (NMWifiUtils *data, guint32 channel);
|
||||
|
||||
/* ssid == NULL means "auto SSID" */
|
||||
gboolean (*set_mesh_ssid) (WifiData *data, const guint8 *ssid, gsize len);
|
||||
gboolean (*set_mesh_ssid) (NMWifiUtils *data, const guint8 *ssid, gsize len);
|
||||
|
||||
gboolean (*indicate_addressing_running) (WifiData *data, gboolean running);
|
||||
} WifiDataClass;
|
||||
gboolean (*indicate_addressing_running) (NMWifiUtils *data, gboolean running);
|
||||
} NMWifiUtilsClass;
|
||||
|
||||
struct NMWifiUtils {
|
||||
GObject parent;
|
||||
|
||||
struct WifiData {
|
||||
const WifiDataClass *klass;
|
||||
int ifindex;
|
||||
NMDeviceWifiCapabilities caps;
|
||||
};
|
||||
|
||||
gpointer wifi_data_new (const WifiDataClass *klass, int ifindex);
|
||||
|
||||
#endif /* __WIFI_UTILS_PRIVATE_H__ */
|
||||
|
|
@ -15,13 +15,13 @@
|
|||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright (C) 2005 - 2011 Red Hat, Inc.
|
||||
* Copyright (C) 2005 - 2018 Red Hat, Inc.
|
||||
* Copyright (C) 2006 - 2008 Novell, Inc.
|
||||
*/
|
||||
|
||||
#include "nm-default.h"
|
||||
|
||||
#include "wifi-utils-wext.h"
|
||||
#include "nm-wifi-utils-wext.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
|
@ -38,17 +38,23 @@
|
|||
#include <sys/socket.h>
|
||||
#include <linux/wireless.h>
|
||||
|
||||
#include "wifi-utils-private.h"
|
||||
#include "nm-wifi-utils-private.h"
|
||||
#include "nm-utils.h"
|
||||
#include "platform/nm-platform-utils.h"
|
||||
|
||||
typedef struct {
|
||||
WifiData parent;
|
||||
NMWifiUtils parent;
|
||||
int fd;
|
||||
struct iw_quality max_qual;
|
||||
gint8 num_freqs;
|
||||
guint32 freqs[IW_MAX_FREQUENCIES];
|
||||
} WifiDataWext;
|
||||
} NMWifiUtilsWext;
|
||||
|
||||
typedef struct {
|
||||
NMWifiUtilsClass parent;
|
||||
} NMWifiUtilsWextClass;
|
||||
|
||||
G_DEFINE_TYPE (NMWifiUtilsWext, nm_wifi_utils_wext, NM_TYPE_WIFI_UTILS)
|
||||
|
||||
/* Until a new wireless-tools comes out that has the defs and the structure,
|
||||
* need to copy them here.
|
||||
|
|
@ -94,11 +100,11 @@ iw_freq_to_uint32 (const struct iw_freq *freq)
|
|||
}
|
||||
|
||||
static void
|
||||
wifi_wext_deinit (WifiData *parent)
|
||||
dispose (GObject *object)
|
||||
{
|
||||
WifiDataWext *wext = (WifiDataWext *) parent;
|
||||
NMWifiUtilsWext *wext = NM_WIFI_UTILS_WEXT (object);
|
||||
|
||||
nm_close (wext->fd);
|
||||
wext->fd = nm_close (wext->fd);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
@ -118,9 +124,9 @@ get_ifname (int ifindex, char *buffer, const char *op)
|
|||
}
|
||||
|
||||
static NM80211Mode
|
||||
wifi_wext_get_mode_ifname (WifiData *data, const char *ifname)
|
||||
wifi_wext_get_mode_ifname (NMWifiUtils *data, const char *ifname)
|
||||
{
|
||||
WifiDataWext *wext = (WifiDataWext *) data;
|
||||
NMWifiUtilsWext *wext = (NMWifiUtilsWext *) data;
|
||||
struct iwreq wrq;
|
||||
|
||||
memset (&wrq, 0, sizeof (struct iwreq));
|
||||
|
|
@ -150,7 +156,7 @@ wifi_wext_get_mode_ifname (WifiData *data, const char *ifname)
|
|||
}
|
||||
|
||||
static NM80211Mode
|
||||
wifi_wext_get_mode (WifiData *data)
|
||||
wifi_wext_get_mode (NMWifiUtils *data)
|
||||
{
|
||||
char ifname[IFNAMSIZ];
|
||||
|
||||
|
|
@ -161,9 +167,9 @@ wifi_wext_get_mode (WifiData *data)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
wifi_wext_set_mode (WifiData *data, const NM80211Mode mode)
|
||||
wifi_wext_set_mode (NMWifiUtils *data, const NM80211Mode mode)
|
||||
{
|
||||
WifiDataWext *wext = (WifiDataWext *) data;
|
||||
NMWifiUtilsWext *wext = (NMWifiUtilsWext *) data;
|
||||
struct iwreq wrq;
|
||||
char ifname[IFNAMSIZ];
|
||||
|
||||
|
|
@ -203,9 +209,9 @@ wifi_wext_set_mode (WifiData *data, const NM80211Mode mode)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
wifi_wext_set_powersave (WifiData *data, guint32 powersave)
|
||||
wifi_wext_set_powersave (NMWifiUtils *data, guint32 powersave)
|
||||
{
|
||||
WifiDataWext *wext = (WifiDataWext *) data;
|
||||
NMWifiUtilsWext *wext = (NMWifiUtilsWext *) data;
|
||||
struct iwreq wrq;
|
||||
char ifname[IFNAMSIZ];
|
||||
|
||||
|
|
@ -232,9 +238,9 @@ wifi_wext_set_powersave (WifiData *data, guint32 powersave)
|
|||
}
|
||||
|
||||
static guint32
|
||||
wifi_wext_get_freq (WifiData *data)
|
||||
wifi_wext_get_freq (NMWifiUtils *data)
|
||||
{
|
||||
WifiDataWext *wext = (WifiDataWext *) data;
|
||||
NMWifiUtilsWext *wext = (NMWifiUtilsWext *) data;
|
||||
struct iwreq wrq;
|
||||
char ifname[IFNAMSIZ];
|
||||
|
||||
|
|
@ -254,9 +260,9 @@ wifi_wext_get_freq (WifiData *data)
|
|||
}
|
||||
|
||||
static guint32
|
||||
wifi_wext_find_freq (WifiData *data, const guint32 *freqs)
|
||||
wifi_wext_find_freq (NMWifiUtils *data, const guint32 *freqs)
|
||||
{
|
||||
WifiDataWext *wext = (WifiDataWext *) data;
|
||||
NMWifiUtilsWext *wext = (NMWifiUtilsWext *) data;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < wext->num_freqs; i++) {
|
||||
|
|
@ -270,9 +276,9 @@ wifi_wext_find_freq (WifiData *data, const guint32 *freqs)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
wifi_wext_get_bssid (WifiData *data, guint8 *out_bssid)
|
||||
wifi_wext_get_bssid (NMWifiUtils *data, guint8 *out_bssid)
|
||||
{
|
||||
WifiDataWext *wext = (WifiDataWext *) data;
|
||||
NMWifiUtilsWext *wext = (NMWifiUtilsWext *) data;
|
||||
struct iwreq wrq;
|
||||
char ifname[IFNAMSIZ];
|
||||
|
||||
|
|
@ -292,9 +298,9 @@ wifi_wext_get_bssid (WifiData *data, guint8 *out_bssid)
|
|||
}
|
||||
|
||||
static guint32
|
||||
wifi_wext_get_rate (WifiData *data)
|
||||
wifi_wext_get_rate (NMWifiUtils *data)
|
||||
{
|
||||
WifiDataWext *wext = (WifiDataWext *) data;
|
||||
NMWifiUtilsWext *wext = (NMWifiUtilsWext *) data;
|
||||
struct iwreq wrq;
|
||||
int err;
|
||||
char ifname[IFNAMSIZ];
|
||||
|
|
@ -403,9 +409,9 @@ wext_qual_to_percent (const struct iw_quality *qual,
|
|||
}
|
||||
|
||||
static int
|
||||
wifi_wext_get_qual (WifiData *data)
|
||||
wifi_wext_get_qual (NMWifiUtils *data)
|
||||
{
|
||||
WifiDataWext *wext = (WifiDataWext *) data;
|
||||
NMWifiUtilsWext *wext = (NMWifiUtilsWext *) data;
|
||||
struct iwreq wrq;
|
||||
struct iw_statistics stats;
|
||||
char ifname[IFNAMSIZ];
|
||||
|
|
@ -433,13 +439,13 @@ wifi_wext_get_qual (WifiData *data)
|
|||
/* OLPC Mesh-only functions */
|
||||
|
||||
static guint32
|
||||
wifi_wext_get_mesh_channel (WifiData *data)
|
||||
wifi_wext_get_mesh_channel (NMWifiUtils *data)
|
||||
{
|
||||
WifiDataWext *wext = (WifiDataWext *) data;
|
||||
NMWifiUtilsWext *wext = (NMWifiUtilsWext *) data;
|
||||
guint32 freq;
|
||||
int i;
|
||||
|
||||
freq = wifi_utils_get_freq (data);
|
||||
freq = nm_wifi_utils_get_freq (data);
|
||||
for (i = 0; i < wext->num_freqs; i++) {
|
||||
if (freq == wext->freqs[i])
|
||||
return i + 1;
|
||||
|
|
@ -448,9 +454,9 @@ wifi_wext_get_mesh_channel (WifiData *data)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
wifi_wext_set_mesh_channel (WifiData *data, guint32 channel)
|
||||
wifi_wext_set_mesh_channel (NMWifiUtils *data, guint32 channel)
|
||||
{
|
||||
WifiDataWext *wext = (WifiDataWext *) data;
|
||||
NMWifiUtilsWext *wext = (NMWifiUtilsWext *) data;
|
||||
struct iwreq wrq;
|
||||
char ifname[IFNAMSIZ];
|
||||
|
||||
|
|
@ -477,9 +483,9 @@ wifi_wext_set_mesh_channel (WifiData *data, guint32 channel)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
wifi_wext_set_mesh_ssid (WifiData *data, const guint8 *ssid, gsize len)
|
||||
wifi_wext_set_mesh_ssid (NMWifiUtils *data, const guint8 *ssid, gsize len)
|
||||
{
|
||||
WifiDataWext *wext = (WifiDataWext *) data;
|
||||
NMWifiUtilsWext *wext = (NMWifiUtilsWext *) data;
|
||||
struct iwreq wrq;
|
||||
char buf[IW_ESSID_MAX_SIZE + 1];
|
||||
char ifname[IFNAMSIZ];
|
||||
|
|
@ -514,7 +520,7 @@ wifi_wext_set_mesh_ssid (WifiData *data, const guint8 *ssid, gsize len)
|
|||
/*****************************************************************************/
|
||||
|
||||
static gboolean
|
||||
wext_can_scan_ifname (WifiDataWext *wext, const char *ifname)
|
||||
wext_can_scan_ifname (NMWifiUtilsWext *wext, const char *ifname)
|
||||
{
|
||||
struct iwreq wrq;
|
||||
|
||||
|
|
@ -528,7 +534,7 @@ wext_can_scan_ifname (WifiDataWext *wext, const char *ifname)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
wext_get_range_ifname (WifiDataWext *wext,
|
||||
wext_get_range_ifname (NMWifiUtilsWext *wext,
|
||||
const char *ifname,
|
||||
struct iw_range *range,
|
||||
guint32 *response_len)
|
||||
|
|
@ -577,7 +583,7 @@ wext_get_range_ifname (WifiDataWext *wext,
|
|||
NM_WIFI_DEVICE_CAP_RSN)
|
||||
|
||||
static guint32
|
||||
wext_get_caps (WifiDataWext *wext, const char *ifname, struct iw_range *range)
|
||||
wext_get_caps (NMWifiUtilsWext *wext, const char *ifname, struct iw_range *range)
|
||||
{
|
||||
guint32 caps = NM_WIFI_DEVICE_CAP_NONE;
|
||||
|
||||
|
|
@ -626,25 +632,38 @@ wext_get_caps (WifiDataWext *wext, const char *ifname, struct iw_range *range)
|
|||
return caps;
|
||||
}
|
||||
|
||||
WifiData *
|
||||
wifi_wext_init (int ifindex, gboolean check_scan)
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
nm_wifi_utils_wext_init (NMWifiUtilsWext *self)
|
||||
{
|
||||
static const WifiDataClass klass = {
|
||||
.struct_size = sizeof (WifiDataWext),
|
||||
.get_mode = wifi_wext_get_mode,
|
||||
.set_mode = wifi_wext_set_mode,
|
||||
.set_powersave = wifi_wext_set_powersave,
|
||||
.get_freq = wifi_wext_get_freq,
|
||||
.find_freq = wifi_wext_find_freq,
|
||||
.get_bssid = wifi_wext_get_bssid,
|
||||
.get_rate = wifi_wext_get_rate,
|
||||
.get_qual = wifi_wext_get_qual,
|
||||
.deinit = wifi_wext_deinit,
|
||||
.get_mesh_channel = wifi_wext_get_mesh_channel,
|
||||
.set_mesh_channel = wifi_wext_set_mesh_channel,
|
||||
.set_mesh_ssid = wifi_wext_set_mesh_ssid,
|
||||
};
|
||||
WifiDataWext *wext;
|
||||
}
|
||||
|
||||
static void
|
||||
nm_wifi_utils_wext_class_init (NMWifiUtilsWextClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
NMWifiUtilsClass *wifi_utils_class = NM_WIFI_UTILS_CLASS (klass);
|
||||
|
||||
object_class->dispose = dispose;
|
||||
|
||||
wifi_utils_class->get_mode = wifi_wext_get_mode;
|
||||
wifi_utils_class->set_mode = wifi_wext_set_mode;
|
||||
wifi_utils_class->set_powersave = wifi_wext_set_powersave;
|
||||
wifi_utils_class->get_freq = wifi_wext_get_freq;
|
||||
wifi_utils_class->find_freq = wifi_wext_find_freq;
|
||||
wifi_utils_class->get_bssid = wifi_wext_get_bssid;
|
||||
wifi_utils_class->get_rate = wifi_wext_get_rate;
|
||||
wifi_utils_class->get_qual = wifi_wext_get_qual;
|
||||
wifi_utils_class->get_mesh_channel = wifi_wext_get_mesh_channel;
|
||||
wifi_utils_class->set_mesh_channel = wifi_wext_set_mesh_channel;
|
||||
wifi_utils_class->set_mesh_ssid = wifi_wext_set_mesh_ssid;
|
||||
}
|
||||
|
||||
NMWifiUtils *
|
||||
nm_wifi_utils_wext_new (int ifindex, gboolean check_scan)
|
||||
{
|
||||
NMWifiUtilsWext *wext;
|
||||
struct iw_range range;
|
||||
guint32 response_len = 0;
|
||||
struct iw_range_with_scan_capa *scan_capa_range;
|
||||
|
|
@ -658,8 +677,9 @@ wifi_wext_init (int ifindex, gboolean check_scan)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
wext = wifi_data_new (&klass, ifindex);
|
||||
wext = g_object_new (NM_TYPE_WIFI_UTILS_WEXT, NULL);
|
||||
|
||||
wext->parent.ifindex = ifindex;
|
||||
wext->fd = socket (PF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
|
||||
if (wext->fd < 0)
|
||||
goto error;
|
||||
|
|
@ -731,15 +751,15 @@ wifi_wext_init (int ifindex, gboolean check_scan)
|
|||
"(%s): using WEXT for WiFi device control",
|
||||
ifname);
|
||||
|
||||
return (WifiData *) wext;
|
||||
return (NMWifiUtils *) wext;
|
||||
|
||||
error:
|
||||
wifi_utils_unref ((WifiData *) wext);
|
||||
g_object_unref (wext);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gboolean
|
||||
wifi_wext_is_wifi (const char *iface)
|
||||
nm_wifi_utils_wext_is_wifi (const char *iface)
|
||||
{
|
||||
int fd;
|
||||
struct iwreq iwr;
|
||||
|
|
@ -15,16 +15,25 @@
|
|||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright (C) 2011 Red Hat, Inc.
|
||||
* Copyright (C) 2011 - 2018 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#ifndef __WIFI_UTILS_WEXT_H__
|
||||
#define __WIFI_UTILS_WEXT_H__
|
||||
|
||||
#include "wifi-utils.h"
|
||||
#include "nm-wifi-utils.h"
|
||||
|
||||
WifiData *wifi_wext_init (int ifindex, gboolean check_scan);
|
||||
#define NM_TYPE_WIFI_UTILS_WEXT (nm_wifi_utils_wext_get_type ())
|
||||
#define NM_WIFI_UTILS_WEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_WIFI_UTILS_WEXT, NMWifiUtilsWext))
|
||||
#define NM_WIFI_UTILS_WEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_WIFI_UTILS_WEXT, NMWifiUtilsWextClass))
|
||||
#define NM_IS_WIFI_UTILS_WEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_WIFI_UTILS_WEXT))
|
||||
#define NM_IS_WIFI_UTILS_WEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_WIFI_UTILS_WEXT))
|
||||
#define NM_WIFI_UTILS_WEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_WIFI_UTILS_WEXT, NMWifiUtilsWextClass))
|
||||
|
||||
gboolean wifi_wext_is_wifi (const char *iface);
|
||||
GType nm_wifi_utils_wext_get_type (void);
|
||||
|
||||
NMWifiUtils *nm_wifi_utils_wext_new (int ifindex, gboolean check_scan);
|
||||
|
||||
gboolean nm_wifi_utils_wext_is_wifi (const char *iface);
|
||||
|
||||
#endif /* __WIFI_UTILS_WEXT_H__ */
|
||||
240
src/platform/wifi/nm-wifi-utils.c
Normal file
240
src/platform/wifi/nm-wifi-utils.c
Normal file
|
|
@ -0,0 +1,240 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
||||
/* NetworkManager -- Network link manager
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright (C) 2005 - 2018 Red Hat, Inc.
|
||||
* Copyright (C) 2006 - 2008 Novell, Inc.
|
||||
*/
|
||||
|
||||
#include "nm-default.h"
|
||||
|
||||
#include "nm-wifi-utils.h"
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "nm-wifi-utils-private.h"
|
||||
#include "nm-wifi-utils-nl80211.h"
|
||||
#if HAVE_WEXT
|
||||
#include "nm-wifi-utils-wext.h"
|
||||
#endif
|
||||
#include "nm-core-utils.h"
|
||||
|
||||
#include "platform/nm-platform-utils.h"
|
||||
|
||||
G_DEFINE_ABSTRACT_TYPE (NMWifiUtils, nm_wifi_utils, G_TYPE_OBJECT)
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
nm_wifi_utils_init (NMWifiUtils *self)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
nm_wifi_utils_class_init (NMWifiUtilsClass *klass)
|
||||
{
|
||||
}
|
||||
|
||||
NMWifiUtils *
|
||||
nm_wifi_utils_new (int ifindex, struct nl_sock *genl, gboolean check_scan)
|
||||
{
|
||||
NMWifiUtils *ret;
|
||||
|
||||
g_return_val_if_fail (ifindex > 0, NULL);
|
||||
|
||||
ret = nm_wifi_utils_nl80211_new (ifindex, genl);
|
||||
|
||||
#if HAVE_WEXT
|
||||
if (ret == NULL)
|
||||
ret = nm_wifi_utils_wext_new (ifindex, check_scan);
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
NMDeviceWifiCapabilities
|
||||
nm_wifi_utils_get_caps (NMWifiUtils *data)
|
||||
{
|
||||
g_return_val_if_fail (data != NULL, NM_WIFI_DEVICE_CAP_NONE);
|
||||
|
||||
return data->caps;
|
||||
}
|
||||
|
||||
NM80211Mode
|
||||
nm_wifi_utils_get_mode (NMWifiUtils *data)
|
||||
{
|
||||
g_return_val_if_fail (data != NULL, NM_802_11_MODE_UNKNOWN);
|
||||
return NM_WIFI_UTILS_GET_CLASS (data)->get_mode (data);
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_wifi_utils_set_mode (NMWifiUtils *data, const NM80211Mode mode)
|
||||
{
|
||||
NMWifiUtilsClass *klass;
|
||||
|
||||
g_return_val_if_fail (data != NULL, FALSE);
|
||||
g_return_val_if_fail ( (mode == NM_802_11_MODE_INFRA)
|
||||
|| (mode == NM_802_11_MODE_AP)
|
||||
|| (mode == NM_802_11_MODE_ADHOC), FALSE);
|
||||
|
||||
klass = NM_WIFI_UTILS_GET_CLASS (data);
|
||||
|
||||
/* nl80211 probably doesn't need this */
|
||||
return klass->set_mode ? klass->set_mode (data, mode) : TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_wifi_utils_set_powersave (NMWifiUtils *data, guint32 powersave)
|
||||
{
|
||||
NMWifiUtilsClass *klass;
|
||||
|
||||
g_return_val_if_fail (data != NULL, FALSE);
|
||||
|
||||
klass = NM_WIFI_UTILS_GET_CLASS (data);
|
||||
return klass->set_powersave ? klass->set_powersave (data, powersave) : TRUE;
|
||||
}
|
||||
|
||||
NMSettingWirelessWakeOnWLan
|
||||
nm_wifi_utils_get_wake_on_wlan (NMWifiUtils *data)
|
||||
{
|
||||
NMWifiUtilsClass *klass;
|
||||
|
||||
g_return_val_if_fail (data != NULL, NM_SETTING_WIRELESS_WAKE_ON_WLAN_IGNORE);
|
||||
|
||||
klass = NM_WIFI_UTILS_GET_CLASS (data);
|
||||
|
||||
return klass->get_wake_on_wlan ? klass->get_wake_on_wlan (data) : NM_SETTING_WIRELESS_WAKE_ON_WLAN_IGNORE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_wifi_utils_set_wake_on_wlan (NMWifiUtils *data, NMSettingWirelessWakeOnWLan wowl)
|
||||
{
|
||||
NMWifiUtilsClass *klass;
|
||||
|
||||
g_return_val_if_fail (data != NULL, FALSE);
|
||||
|
||||
klass = NM_WIFI_UTILS_GET_CLASS (data);
|
||||
return klass->set_wake_on_wlan ? klass->set_wake_on_wlan (data, wowl) : FALSE;
|
||||
}
|
||||
|
||||
guint32
|
||||
nm_wifi_utils_get_freq (NMWifiUtils *data)
|
||||
{
|
||||
g_return_val_if_fail (data != NULL, 0);
|
||||
return NM_WIFI_UTILS_GET_CLASS (data)->get_freq (data);
|
||||
}
|
||||
|
||||
guint32
|
||||
nm_wifi_utils_find_freq (NMWifiUtils *data, const guint32 *freqs)
|
||||
{
|
||||
g_return_val_if_fail (data != NULL, 0);
|
||||
g_return_val_if_fail (freqs != NULL, 0);
|
||||
return NM_WIFI_UTILS_GET_CLASS (data)->find_freq (data, freqs);
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_wifi_utils_get_bssid (NMWifiUtils *data, guint8 *out_bssid)
|
||||
{
|
||||
g_return_val_if_fail (data != NULL, FALSE);
|
||||
g_return_val_if_fail (out_bssid != NULL, FALSE);
|
||||
|
||||
memset (out_bssid, 0, ETH_ALEN);
|
||||
return NM_WIFI_UTILS_GET_CLASS (data)->get_bssid (data, out_bssid);
|
||||
}
|
||||
|
||||
guint32
|
||||
nm_wifi_utils_get_rate (NMWifiUtils *data)
|
||||
{
|
||||
g_return_val_if_fail (data != NULL, 0);
|
||||
return NM_WIFI_UTILS_GET_CLASS (data)->get_rate (data);
|
||||
}
|
||||
|
||||
int
|
||||
nm_wifi_utils_get_qual (NMWifiUtils *data)
|
||||
{
|
||||
g_return_val_if_fail (data != NULL, 0);
|
||||
return NM_WIFI_UTILS_GET_CLASS (data)->get_qual (data);
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_wifi_utils_is_wifi (int dirfd, const char *ifname)
|
||||
{
|
||||
g_return_val_if_fail (dirfd >= 0, FALSE);
|
||||
|
||||
if (faccessat (dirfd, "phy80211", F_OK, 0) == 0)
|
||||
return TRUE;
|
||||
#if HAVE_WEXT
|
||||
if (nm_wifi_utils_wext_is_wifi (ifname))
|
||||
return TRUE;
|
||||
#endif
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* OLPC Mesh-only functions */
|
||||
|
||||
guint32
|
||||
nm_wifi_utils_get_mesh_channel (NMWifiUtils *data)
|
||||
{
|
||||
NMWifiUtilsClass *klass;
|
||||
|
||||
g_return_val_if_fail (data != NULL, FALSE);
|
||||
|
||||
klass = NM_WIFI_UTILS_GET_CLASS (data);
|
||||
g_return_val_if_fail (klass->get_mesh_channel != NULL, FALSE);
|
||||
|
||||
return klass->get_mesh_channel (data);
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_wifi_utils_set_mesh_channel (NMWifiUtils *data, guint32 channel)
|
||||
{
|
||||
NMWifiUtilsClass *klass;
|
||||
|
||||
g_return_val_if_fail (data != NULL, FALSE);
|
||||
g_return_val_if_fail (channel <= 13, FALSE);
|
||||
|
||||
klass = NM_WIFI_UTILS_GET_CLASS (data);
|
||||
g_return_val_if_fail (klass->set_mesh_channel != NULL, FALSE);
|
||||
|
||||
return klass->set_mesh_channel (data, channel);
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_wifi_utils_set_mesh_ssid (NMWifiUtils *data, const guint8 *ssid, gsize len)
|
||||
{
|
||||
NMWifiUtilsClass *klass;
|
||||
|
||||
g_return_val_if_fail (data != NULL, FALSE);
|
||||
|
||||
klass = NM_WIFI_UTILS_GET_CLASS (data);
|
||||
g_return_val_if_fail (klass->set_mesh_ssid != NULL, FALSE);
|
||||
|
||||
return klass->set_mesh_ssid (data, ssid, len);
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_wifi_utils_indicate_addressing_running (NMWifiUtils *data, gboolean running)
|
||||
{
|
||||
NMWifiUtilsClass *klass;
|
||||
|
||||
g_return_val_if_fail (data != NULL, FALSE);
|
||||
|
||||
klass = NM_WIFI_UTILS_GET_CLASS (data);
|
||||
return klass->indicate_addressing_running ? klass->indicate_addressing_running (data, running) : FALSE;
|
||||
}
|
||||
84
src/platform/wifi/nm-wifi-utils.h
Normal file
84
src/platform/wifi/nm-wifi-utils.h
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
||||
/* NetworkManager -- Network link manager
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright (C) 2005 - 2018 Red Hat, Inc.
|
||||
* Copyright (C) 2006 - 2008 Novell, Inc.
|
||||
*/
|
||||
|
||||
#ifndef __WIFI_UTILS_H__
|
||||
#define __WIFI_UTILS_H__
|
||||
|
||||
#include <net/ethernet.h>
|
||||
|
||||
#include "nm-dbus-interface.h"
|
||||
#include "nm-setting-wireless.h"
|
||||
#include "platform/nm-netlink.h"
|
||||
|
||||
typedef struct NMWifiUtils NMWifiUtils;
|
||||
|
||||
#define NM_TYPE_WIFI_UTILS (nm_wifi_utils_get_type ())
|
||||
#define NM_WIFI_UTILS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_WIFI_UTILS, NMWifiUtils))
|
||||
#define NM_WIFI_UTILS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_WIFI_UTILS, NMWifiUtilsClass))
|
||||
#define NM_IS_WIFI_UTILS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_WIFI_UTILS))
|
||||
#define NM_IS_WIFI_UTILS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_WIFI_UTILS))
|
||||
#define NM_WIFI_UTILS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_WIFI_UTILS, NMWifiUtilsClass))
|
||||
|
||||
GType nm_wifi_utils_get_type (void);
|
||||
|
||||
gboolean nm_wifi_utils_is_wifi (int dirfd, const char *ifname);
|
||||
|
||||
NMWifiUtils *nm_wifi_utils_new (int ifindex, struct nl_sock *genl, gboolean check_scan);
|
||||
|
||||
NMDeviceWifiCapabilities nm_wifi_utils_get_caps (NMWifiUtils *data);
|
||||
|
||||
NM80211Mode nm_wifi_utils_get_mode (NMWifiUtils *data);
|
||||
|
||||
gboolean nm_wifi_utils_set_mode (NMWifiUtils *data, const NM80211Mode mode);
|
||||
|
||||
/* Returns frequency in MHz */
|
||||
guint32 nm_wifi_utils_get_freq (NMWifiUtils *data);
|
||||
|
||||
/* Return the first supported frequency in the zero-terminated list.
|
||||
* Frequencies are specified in MHz. */
|
||||
guint32 nm_wifi_utils_find_freq (NMWifiUtils *data, const guint32 *freqs);
|
||||
|
||||
/* out_bssid must be ETH_ALEN bytes */
|
||||
gboolean nm_wifi_utils_get_bssid (NMWifiUtils *data, guint8 *out_bssid);
|
||||
|
||||
/* Returns current bitrate in Kbps */
|
||||
guint32 nm_wifi_utils_get_rate (NMWifiUtils *data);
|
||||
|
||||
/* Returns quality 0 - 100% on succes, or -1 on error */
|
||||
int nm_wifi_utils_get_qual (NMWifiUtils *data);
|
||||
|
||||
/* Tells the driver DHCP or SLAAC is running */
|
||||
gboolean nm_wifi_utils_indicate_addressing_running (NMWifiUtils *data, gboolean running);
|
||||
|
||||
gboolean nm_wifi_utils_set_powersave (NMWifiUtils *data, guint32 powersave);
|
||||
|
||||
NMSettingWirelessWakeOnWLan nm_wifi_utils_get_wake_on_wlan (NMWifiUtils *data);
|
||||
|
||||
gboolean nm_wifi_utils_set_wake_on_wlan (NMWifiUtils *data, NMSettingWirelessWakeOnWLan wowl);
|
||||
|
||||
/* OLPC Mesh-only functions */
|
||||
guint32 nm_wifi_utils_get_mesh_channel (NMWifiUtils *data);
|
||||
|
||||
gboolean nm_wifi_utils_set_mesh_channel (NMWifiUtils *data, guint32 channel);
|
||||
|
||||
gboolean nm_wifi_utils_set_mesh_ssid (NMWifiUtils *data, const guint8 *ssid, gsize len);
|
||||
|
||||
#endif /* __WIFI_UTILS_H__ */
|
||||
|
|
@ -1,241 +0,0 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
||||
/* NetworkManager -- Network link manager
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright (C) 2005 - 2011 Red Hat, Inc.
|
||||
* Copyright (C) 2006 - 2008 Novell, Inc.
|
||||
*/
|
||||
|
||||
#include "nm-default.h"
|
||||
|
||||
#include "wifi-utils.h"
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "wifi-utils-private.h"
|
||||
#include "wifi-utils-nl80211.h"
|
||||
#if HAVE_WEXT
|
||||
#include "wifi-utils-wext.h"
|
||||
#endif
|
||||
#include "nm-core-utils.h"
|
||||
|
||||
#include "platform/nm-platform-utils.h"
|
||||
|
||||
gpointer
|
||||
wifi_data_new (const WifiDataClass *klass, int ifindex)
|
||||
{
|
||||
WifiData *data;
|
||||
|
||||
nm_assert (klass);
|
||||
nm_assert (klass->struct_size > sizeof (WifiData));
|
||||
|
||||
data = g_malloc0 (klass->struct_size);
|
||||
data->klass = klass;
|
||||
data->ifindex = ifindex;
|
||||
return data;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
WifiData *
|
||||
wifi_utils_init (int ifindex, gboolean check_scan)
|
||||
{
|
||||
WifiData *ret;
|
||||
|
||||
g_return_val_if_fail (ifindex > 0, NULL);
|
||||
|
||||
ret = wifi_nl80211_init (ifindex);
|
||||
if (ret == NULL) {
|
||||
#if HAVE_WEXT
|
||||
ret = wifi_wext_init (ifindex, check_scan);
|
||||
#endif
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
wifi_utils_get_ifindex (WifiData *data)
|
||||
{
|
||||
g_return_val_if_fail (data != NULL, -1);
|
||||
|
||||
return data->ifindex;
|
||||
}
|
||||
|
||||
NMDeviceWifiCapabilities
|
||||
wifi_utils_get_caps (WifiData *data)
|
||||
{
|
||||
g_return_val_if_fail (data != NULL, NM_WIFI_DEVICE_CAP_NONE);
|
||||
|
||||
return data->caps;
|
||||
}
|
||||
|
||||
NM80211Mode
|
||||
wifi_utils_get_mode (WifiData *data)
|
||||
{
|
||||
g_return_val_if_fail (data != NULL, NM_802_11_MODE_UNKNOWN);
|
||||
return data->klass->get_mode (data);
|
||||
}
|
||||
|
||||
gboolean
|
||||
wifi_utils_set_mode (WifiData *data, const NM80211Mode mode)
|
||||
{
|
||||
g_return_val_if_fail (data != NULL, FALSE);
|
||||
g_return_val_if_fail ( (mode == NM_802_11_MODE_INFRA)
|
||||
|| (mode == NM_802_11_MODE_AP)
|
||||
|| (mode == NM_802_11_MODE_ADHOC), FALSE);
|
||||
|
||||
/* nl80211 probably doesn't need this */
|
||||
return data->klass->set_mode ? data->klass->set_mode (data, mode) : TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
wifi_utils_set_powersave (WifiData *data, guint32 powersave)
|
||||
{
|
||||
g_return_val_if_fail (data != NULL, FALSE);
|
||||
|
||||
return data->klass->set_powersave ? data->klass->set_powersave (data, powersave) : TRUE;
|
||||
}
|
||||
|
||||
NMSettingWirelessWakeOnWLan
|
||||
wifi_utils_get_wake_on_wlan (WifiData *data)
|
||||
{
|
||||
g_return_val_if_fail (data != NULL, FALSE);
|
||||
|
||||
return data->klass->get_wake_on_wlan
|
||||
? data->klass->get_wake_on_wlan (data)
|
||||
: NM_SETTING_WIRELESS_WAKE_ON_WLAN_IGNORE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
wifi_utils_set_wake_on_wlan (WifiData *data, NMSettingWirelessWakeOnWLan wowl)
|
||||
{
|
||||
g_return_val_if_fail (data != NULL, FALSE);
|
||||
|
||||
return data->klass->set_wake_on_wlan ?
|
||||
data->klass->set_wake_on_wlan (data, wowl) : FALSE;
|
||||
}
|
||||
|
||||
guint32
|
||||
wifi_utils_get_freq (WifiData *data)
|
||||
{
|
||||
g_return_val_if_fail (data != NULL, 0);
|
||||
return data->klass->get_freq (data);
|
||||
}
|
||||
|
||||
guint32
|
||||
wifi_utils_find_freq (WifiData *data, const guint32 *freqs)
|
||||
{
|
||||
g_return_val_if_fail (data != NULL, 0);
|
||||
g_return_val_if_fail (freqs != NULL, 0);
|
||||
return data->klass->find_freq (data, freqs);
|
||||
}
|
||||
|
||||
gboolean
|
||||
wifi_utils_get_bssid (WifiData *data, guint8 *out_bssid)
|
||||
{
|
||||
g_return_val_if_fail (data != NULL, FALSE);
|
||||
g_return_val_if_fail (out_bssid != NULL, FALSE);
|
||||
|
||||
memset (out_bssid, 0, ETH_ALEN);
|
||||
return data->klass->get_bssid (data, out_bssid);
|
||||
}
|
||||
|
||||
guint32
|
||||
wifi_utils_get_rate (WifiData *data)
|
||||
{
|
||||
g_return_val_if_fail (data != NULL, 0);
|
||||
return data->klass->get_rate (data);
|
||||
}
|
||||
|
||||
int
|
||||
wifi_utils_get_qual (WifiData *data)
|
||||
{
|
||||
g_return_val_if_fail (data != NULL, 0);
|
||||
return data->klass->get_qual (data);
|
||||
}
|
||||
|
||||
gboolean
|
||||
wifi_utils_get_wowlan (WifiData *data)
|
||||
{
|
||||
g_return_val_if_fail (data != NULL, 0);
|
||||
|
||||
if (!data->klass->get_wowlan)
|
||||
return FALSE;
|
||||
return data->klass->get_wowlan (data);
|
||||
}
|
||||
|
||||
void
|
||||
wifi_utils_unref (WifiData *data)
|
||||
{
|
||||
g_return_if_fail (data != NULL);
|
||||
|
||||
data->klass->deinit (data);
|
||||
g_free (data);
|
||||
}
|
||||
|
||||
gboolean
|
||||
wifi_utils_is_wifi (int dirfd, const char *ifname)
|
||||
{
|
||||
g_return_val_if_fail (dirfd >= 0, FALSE);
|
||||
|
||||
if (faccessat (dirfd, "phy80211", F_OK, 0) == 0)
|
||||
return TRUE;
|
||||
#if HAVE_WEXT
|
||||
if (wifi_wext_is_wifi (ifname))
|
||||
return TRUE;
|
||||
#endif
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* OLPC Mesh-only functions */
|
||||
|
||||
guint32
|
||||
wifi_utils_get_mesh_channel (WifiData *data)
|
||||
{
|
||||
g_return_val_if_fail (data != NULL, FALSE);
|
||||
g_return_val_if_fail (data->klass->get_mesh_channel != NULL, FALSE);
|
||||
return data->klass->get_mesh_channel (data);
|
||||
}
|
||||
|
||||
gboolean
|
||||
wifi_utils_set_mesh_channel (WifiData *data, guint32 channel)
|
||||
{
|
||||
g_return_val_if_fail (data != NULL, FALSE);
|
||||
g_return_val_if_fail (channel <= 13, FALSE);
|
||||
g_return_val_if_fail (data->klass->set_mesh_channel != NULL, FALSE);
|
||||
return data->klass->set_mesh_channel (data, channel);
|
||||
}
|
||||
|
||||
gboolean
|
||||
wifi_utils_set_mesh_ssid (WifiData *data, const guint8 *ssid, gsize len)
|
||||
{
|
||||
g_return_val_if_fail (data != NULL, FALSE);
|
||||
g_return_val_if_fail (data->klass->set_mesh_ssid != NULL, FALSE);
|
||||
return data->klass->set_mesh_ssid (data, ssid, len);
|
||||
}
|
||||
|
||||
gboolean
|
||||
wifi_utils_indicate_addressing_running (WifiData *data, gboolean running)
|
||||
{
|
||||
g_return_val_if_fail (data != NULL, FALSE);
|
||||
if (data->klass->indicate_addressing_running)
|
||||
return data->klass->indicate_addressing_running (data, running);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
@ -1,81 +0,0 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
||||
/* NetworkManager -- Network link manager
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright (C) 2005 - 2011 Red Hat, Inc.
|
||||
* Copyright (C) 2006 - 2008 Novell, Inc.
|
||||
*/
|
||||
|
||||
#ifndef __WIFI_UTILS_H__
|
||||
#define __WIFI_UTILS_H__
|
||||
|
||||
#include <net/ethernet.h>
|
||||
|
||||
#include "nm-dbus-interface.h"
|
||||
#include "nm-setting-wireless.h"
|
||||
|
||||
typedef struct WifiData WifiData;
|
||||
|
||||
gboolean wifi_utils_is_wifi (int dirfd, const char *ifname);
|
||||
|
||||
WifiData *wifi_utils_init (int ifindex, gboolean check_scan);
|
||||
|
||||
int wifi_utils_get_ifindex (WifiData *data);
|
||||
|
||||
void wifi_utils_unref (WifiData *data);
|
||||
|
||||
NMDeviceWifiCapabilities wifi_utils_get_caps (WifiData *data);
|
||||
|
||||
NM80211Mode wifi_utils_get_mode (WifiData *data);
|
||||
|
||||
gboolean wifi_utils_set_mode (WifiData *data, const NM80211Mode mode);
|
||||
|
||||
/* Returns frequency in MHz */
|
||||
guint32 wifi_utils_get_freq (WifiData *data);
|
||||
|
||||
/* Return the first supported frequency in the zero-terminated list.
|
||||
* Frequencies are specified in MHz. */
|
||||
guint32 wifi_utils_find_freq (WifiData *data, const guint32 *freqs);
|
||||
|
||||
/* out_bssid must be ETH_ALEN bytes */
|
||||
gboolean wifi_utils_get_bssid (WifiData *data, guint8 *out_bssid);
|
||||
|
||||
/* Returns current bitrate in Kbps */
|
||||
guint32 wifi_utils_get_rate (WifiData *data);
|
||||
|
||||
/* Returns quality 0 - 100% on succes, or -1 on error */
|
||||
int wifi_utils_get_qual (WifiData *data);
|
||||
|
||||
/* Tells the driver DHCP or SLAAC is running */
|
||||
gboolean wifi_utils_indicate_addressing_running (WifiData *data, gboolean running);
|
||||
|
||||
/* Returns true if WoWLAN is enabled on device */
|
||||
gboolean wifi_utils_get_wowlan (WifiData *data);
|
||||
|
||||
gboolean wifi_utils_set_powersave (WifiData *data, guint32 powersave);
|
||||
|
||||
NMSettingWirelessWakeOnWLan wifi_utils_get_wake_on_wlan (WifiData *data);
|
||||
|
||||
gboolean wifi_utils_set_wake_on_wlan (WifiData *data, NMSettingWirelessWakeOnWLan wowl);
|
||||
|
||||
/* OLPC Mesh-only functions */
|
||||
guint32 wifi_utils_get_mesh_channel (WifiData *data);
|
||||
|
||||
gboolean wifi_utils_set_mesh_channel (WifiData *data, guint32 channel);
|
||||
|
||||
gboolean wifi_utils_set_mesh_ssid (WifiData *data, const guint8 *ssid, gsize len);
|
||||
|
||||
#endif /* __WIFI_UTILS_H__ */
|
||||
286
src/platform/wpan/nm-wpan-utils.c
Normal file
286
src/platform/wpan/nm-wpan-utils.c
Normal file
|
|
@ -0,0 +1,286 @@
|
|||
/* NetworkManager -- Network link manager
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright (C) 2018 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#include "nm-default.h"
|
||||
|
||||
#include "nm-wpan-utils.h"
|
||||
|
||||
#include "platform/linux/nl802154.h"
|
||||
#include "platform/nm-netlink.h"
|
||||
|
||||
#define _NMLOG_PREFIX_NAME "wpan-nl802154"
|
||||
#define _NMLOG(level, domain, ...) \
|
||||
G_STMT_START { \
|
||||
nm_log ((level), (domain), NULL, NULL, \
|
||||
"%s: " _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \
|
||||
_NMLOG_PREFIX_NAME \
|
||||
_NM_UTILS_MACRO_REST(__VA_ARGS__)); \
|
||||
} G_STMT_END
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
struct NMWpanUtils {
|
||||
GObject parent;
|
||||
int ifindex;
|
||||
struct nl_sock *nl_sock;
|
||||
int id;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
GObjectClass parent;
|
||||
} NMWpanUtilsClass;
|
||||
|
||||
G_DEFINE_TYPE (NMWpanUtils, nm_wpan_utils, G_TYPE_OBJECT)
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static int
|
||||
ack_handler (struct nl_msg *msg, void *arg)
|
||||
{
|
||||
int *done = arg;
|
||||
*done = 1;
|
||||
return NL_STOP;
|
||||
}
|
||||
|
||||
static int
|
||||
finish_handler (struct nl_msg *msg, void *arg)
|
||||
{
|
||||
int *done = arg;
|
||||
*done = 1;
|
||||
return NL_SKIP;
|
||||
}
|
||||
|
||||
static int
|
||||
error_handler (struct sockaddr_nl *nla, struct nlmsgerr *err, void *arg)
|
||||
{
|
||||
int *done = arg;
|
||||
*done = err->error;
|
||||
return NL_SKIP;
|
||||
}
|
||||
|
||||
static struct nl_msg *
|
||||
_nl802154_alloc_msg (int id, int ifindex, guint32 cmd, guint32 flags)
|
||||
{
|
||||
nm_auto_nlmsg struct nl_msg *msg = NULL;
|
||||
|
||||
msg = nlmsg_alloc ();
|
||||
genlmsg_put (msg, 0, 0, id, 0, flags, cmd, 0);
|
||||
NLA_PUT_U32 (msg, NL802154_ATTR_IFINDEX, ifindex);
|
||||
return g_steal_pointer (&msg);
|
||||
|
||||
nla_put_failure:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static struct nl_msg *
|
||||
nl802154_alloc_msg (NMWpanUtils *self, guint32 cmd, guint32 flags)
|
||||
{
|
||||
return _nl802154_alloc_msg (self->id, self->ifindex, cmd, flags);
|
||||
}
|
||||
|
||||
static int
|
||||
_nl802154_send_and_recv (struct nl_sock *nl_sock,
|
||||
struct nl_msg *msg,
|
||||
int (*valid_handler) (struct nl_msg *, void *),
|
||||
void *valid_data)
|
||||
{
|
||||
int err;
|
||||
int done = 0;
|
||||
const struct nl_cb cb = {
|
||||
.err_cb = error_handler,
|
||||
.err_arg = &done,
|
||||
.finish_cb = finish_handler,
|
||||
.finish_arg = &done,
|
||||
.ack_cb = ack_handler,
|
||||
.ack_arg = &done,
|
||||
.valid_cb = valid_handler,
|
||||
.valid_arg = valid_data,
|
||||
};
|
||||
|
||||
g_return_val_if_fail (msg != NULL, -ENOMEM);
|
||||
|
||||
err = nl_send_auto (nl_sock, msg);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
||||
/* Loop until one of our NL callbacks says we're done; on success
|
||||
* done will be 1, on error it will be < 0.
|
||||
*/
|
||||
while (!done) {
|
||||
err = nl_recvmsgs (nl_sock, &cb);
|
||||
if (err < 0 && err != -EAGAIN) {
|
||||
_LOGW (LOGD_PLATFORM, "nl_recvmsgs() error: (%d) %s",
|
||||
err, nl_geterror (err));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (err >= 0 && done < 0)
|
||||
err = done;
|
||||
return err;
|
||||
}
|
||||
|
||||
static int
|
||||
nl802154_send_and_recv (NMWpanUtils *self,
|
||||
struct nl_msg *msg,
|
||||
int (*valid_handler) (struct nl_msg *, void *),
|
||||
void *valid_data)
|
||||
{
|
||||
return _nl802154_send_and_recv (self->nl_sock, msg,
|
||||
valid_handler, valid_data);
|
||||
}
|
||||
|
||||
struct nl802154_interface {
|
||||
guint16 pan_id;
|
||||
guint16 short_addr;
|
||||
|
||||
gboolean valid;
|
||||
};
|
||||
|
||||
static int
|
||||
nl802154_get_interface_handler (struct nl_msg *msg, void *arg)
|
||||
{
|
||||
struct nl802154_interface *info = arg;
|
||||
struct genlmsghdr *gnlh = nlmsg_data (nlmsg_hdr (msg));
|
||||
struct nlattr *tb[NL802154_ATTR_MAX + 1] = { 0, };
|
||||
static const struct nla_policy nl802154_policy[NL802154_ATTR_MAX + 1] = {
|
||||
[NL802154_ATTR_PAN_ID] = { .type = NLA_U16 },
|
||||
[NL802154_ATTR_SHORT_ADDR] = { .type = NLA_U16 },
|
||||
};
|
||||
|
||||
if (nla_parse (tb, NL802154_ATTR_MAX, genlmsg_attrdata (gnlh, 0),
|
||||
genlmsg_attrlen (gnlh, 0), nl802154_policy) < 0)
|
||||
return NL_SKIP;
|
||||
|
||||
if (tb[NL802154_ATTR_PAN_ID])
|
||||
info->pan_id = le16toh (nla_get_u16 (tb[NL802154_ATTR_PAN_ID]));
|
||||
|
||||
if (tb[NL802154_ATTR_SHORT_ADDR])
|
||||
info->short_addr = le16toh (nla_get_u16 (tb[NL802154_ATTR_SHORT_ADDR]));
|
||||
|
||||
info->valid = TRUE;
|
||||
|
||||
return NL_SKIP;
|
||||
}
|
||||
|
||||
static void
|
||||
nl802154_get_interface (NMWpanUtils *self,
|
||||
struct nl802154_interface *interface)
|
||||
{
|
||||
nm_auto_nlmsg struct nl_msg *msg = NULL;
|
||||
|
||||
memset (interface, 0, sizeof (*interface));
|
||||
|
||||
msg = nl802154_alloc_msg (self, NL802154_CMD_GET_INTERFACE, 0);
|
||||
|
||||
nl802154_send_and_recv (self, msg, nl802154_get_interface_handler, interface);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
guint16
|
||||
nm_wpan_utils_get_pan_id (NMWpanUtils *self)
|
||||
{
|
||||
struct nl802154_interface interface;
|
||||
|
||||
nl802154_get_interface (self, &interface);
|
||||
|
||||
return interface.pan_id;
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_wpan_utils_set_pan_id (NMWpanUtils *self, guint16 pan_id)
|
||||
{
|
||||
nm_auto_nlmsg struct nl_msg *msg = NULL;
|
||||
int err;
|
||||
|
||||
g_return_val_if_fail (self != NULL, FALSE);
|
||||
|
||||
msg = nl802154_alloc_msg (self, NL802154_CMD_SET_PAN_ID, 0);
|
||||
NLA_PUT_U16 (msg, NL802154_ATTR_PAN_ID, htole16 (pan_id));
|
||||
err = nl802154_send_and_recv (self, msg, NULL, NULL);
|
||||
return err >= 0;
|
||||
|
||||
nla_put_failure:
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
guint16
|
||||
nm_wpan_utils_get_short_addr (NMWpanUtils *self)
|
||||
{
|
||||
struct nl802154_interface interface;
|
||||
|
||||
nl802154_get_interface (self, &interface);
|
||||
|
||||
return interface.short_addr;
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_wpan_utils_set_short_addr (NMWpanUtils *self, guint16 short_addr)
|
||||
{
|
||||
nm_auto_nlmsg struct nl_msg *msg = NULL;
|
||||
int err;
|
||||
|
||||
g_return_val_if_fail (self != NULL, FALSE);
|
||||
|
||||
msg = nl802154_alloc_msg (self, NL802154_CMD_SET_SHORT_ADDR, 0);
|
||||
NLA_PUT_U16 (msg, NL802154_ATTR_SHORT_ADDR, htole16 (short_addr));
|
||||
err = nl802154_send_and_recv (self, msg, NULL, NULL);
|
||||
return err >= 0;
|
||||
|
||||
nla_put_failure:
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
nm_wpan_utils_init (NMWpanUtils *self)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
nm_wpan_utils_class_init (NMWpanUtilsClass *klass)
|
||||
{
|
||||
}
|
||||
|
||||
NMWpanUtils *
|
||||
nm_wpan_utils_new (int ifindex, struct nl_sock *genl, gboolean check_scan)
|
||||
{
|
||||
NMWpanUtils *self;
|
||||
int id;
|
||||
|
||||
g_return_val_if_fail (ifindex > 0, NULL);
|
||||
|
||||
if (!genl)
|
||||
return NULL;
|
||||
|
||||
id = genl_ctrl_resolve (genl, "nl802154");
|
||||
if (id < 0) {
|
||||
_LOGD (LOGD_PLATFORM, "genl_ctrl_resolve: failed to resolve \"nl802154\"");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
self = g_object_new (NM_TYPE_WPAN_UTILS, NULL);
|
||||
self->ifindex = ifindex;
|
||||
self->nl_sock = genl;
|
||||
self->id = id;
|
||||
|
||||
return self;
|
||||
}
|
||||
47
src/platform/wpan/nm-wpan-utils.h
Normal file
47
src/platform/wpan/nm-wpan-utils.h
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
/* NetworkManager -- Network link manager
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright (C) 2018 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#ifndef __WPAN_UTILS_H__
|
||||
#define __WPAN_UTILS_H__
|
||||
|
||||
#include <net/ethernet.h>
|
||||
|
||||
#include "nm-dbus-interface.h"
|
||||
#include "platform/nm-netlink.h"
|
||||
|
||||
typedef struct NMWpanUtils NMWpanUtils;
|
||||
|
||||
#define NM_TYPE_WPAN_UTILS (nm_wpan_utils_get_type ())
|
||||
#define NM_WPAN_UTILS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_WPAN_UTILS, NMWpanUtils))
|
||||
#define NM_WPAN_UTILS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_WPAN_UTILS, NMWpanUtilsClass))
|
||||
#define NM_IS_WPAN_UTILS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_WPAN_UTILS))
|
||||
#define NM_IS_WPAN_UTILS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_WPAN_UTILS))
|
||||
#define NM_WPAN_UTILS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_WPAN_UTILS, NMWpanUtilsClass))
|
||||
|
||||
GType nm_wpan_utils_get_type (void);
|
||||
|
||||
NMWpanUtils *nm_wpan_utils_new (int ifindex, struct nl_sock *genl, gboolean check_scan);
|
||||
|
||||
guint16 nm_wpan_utils_get_pan_id (NMWpanUtils *self);
|
||||
gboolean nm_wpan_utils_set_pan_id (NMWpanUtils *self, guint16 pan_id);
|
||||
|
||||
guint16 nm_wpan_utils_get_short_addr (NMWpanUtils *self);
|
||||
gboolean nm_wpan_utils_set_short_addr (NMWpanUtils *self, guint16 short_addr);
|
||||
|
||||
#endif /* __WPAN_UTILS_H__ */
|
||||
Loading…
Add table
Reference in a new issue