Blame libnm/nm-device-wpan.c

Packit Service 87a54e
/* SPDX-License-Identifier: LGPL-2.1-or-later */
Packit 5756e2
/*
Packit 5756e2
 * Copyright (C) 2018 Lubomir Rintel <lkundrak@v3.sk>
Packit 5756e2
 */
Packit 5756e2
Packit 5756e2
#include "nm-default.h"
Packit 5756e2
Packit 5756e2
#include "nm-device-wpan.h"
Packit 5756e2
Packit 5756e2
#include "nm-object-private.h"
Packit 5756e2
#include "nm-setting-wpan.h"
Packit 5756e2
#include "nm-setting-connection.h"
Packit 5756e2
Packit 5756e2
/*****************************************************************************/
Packit 5756e2
Packit 5756e2
struct _NMDeviceWpan {
Packit Service a1bd4f
    NMDevice parent;
Packit 5756e2
};
Packit 5756e2
Packit 5756e2
struct _NMDeviceWpanClass {
Packit Service a1bd4f
    NMDeviceClass parent;
Packit 5756e2
};
Packit 5756e2
Packit Service a1bd4f
G_DEFINE_TYPE(NMDeviceWpan, nm_device_wpan, NM_TYPE_DEVICE)
Packit 5756e2
/*****************************************************************************/
Packit 5756e2
Packit 5756e2
/**
Packit 5756e2
 * nm_device_wpan_get_hw_address: (skip)
Packit 5756e2
 * @device: a #NMDeviceWpan
Packit 5756e2
 *
Packit 5756e2
 * Gets the active hardware (MAC) address of the #NMDeviceWpan
Packit 5756e2
 *
Packit 5756e2
 * Returns: the active hardware address. This is the internal string used by the
Packit 5756e2
 * device, and must not be modified.
Packit 5756e2
 *
Packit 5756e2
 * Deprecated: 1.24: Use nm_device_get_hw_address() instead.
Packit 5756e2
 **/
Packit 5756e2
const char *
Packit Service a1bd4f
nm_device_wpan_get_hw_address(NMDeviceWpan *device)
Packit 5756e2
{
Packit Service a1bd4f
    g_return_val_if_fail(NM_IS_DEVICE_WPAN(device), NULL);
Packit 5756e2
Packit Service a1bd4f
    return nm_device_get_hw_address(NM_DEVICE(device));
Packit 5756e2
}
Packit 5756e2
Packit 5756e2
static gboolean
Packit Service a1bd4f
connection_compatible(NMDevice *device, NMConnection *connection, GError **error)
Packit 5756e2
{
Packit Service a1bd4f
    if (!NM_DEVICE_CLASS(nm_device_wpan_parent_class)
Packit Service a1bd4f
             ->connection_compatible(device, connection, error))
Packit Service a1bd4f
        return FALSE;
Packit Service a1bd4f
Packit Service a1bd4f
    if (!nm_connection_is_type(connection, NM_SETTING_WPAN_SETTING_NAME)) {
Packit Service a1bd4f
        g_set_error_literal(error,
Packit Service a1bd4f
                            NM_DEVICE_ERROR,
Packit Service a1bd4f
                            NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION,
Packit Service a1bd4f
                            _("The connection was not a wpan connection."));
Packit Service a1bd4f
        return FALSE;
Packit Service a1bd4f
    }
Packit Service a1bd4f
Packit Service a1bd4f
    return TRUE;
Packit 5756e2
}
Packit 5756e2
Packit 5756e2
static GType
Packit Service a1bd4f
get_setting_type(NMDevice *device)
Packit 5756e2
{
Packit Service a1bd4f
    return NM_TYPE_SETTING_WPAN;
Packit 5756e2
}
Packit 5756e2
Packit 5756e2
/*****************************************************************************/
Packit 5756e2
Packit 5756e2
static void
Packit Service a1bd4f
nm_device_wpan_init(NMDeviceWpan *device)
Packit Service a1bd4f
{}
Packit Service a1bd4f
Packit Service a1bd4f
const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_wpan = NML_DBUS_META_IFACE_INIT(
Packit Service a1bd4f
    NM_DBUS_INTERFACE_DEVICE_WPAN,
Packit Service a1bd4f
    nm_device_wpan_get_type,
Packit Service a1bd4f
    NML_DBUS_META_INTERFACE_PRIO_INSTANTIATE_30,
Packit Service a1bd4f
    NML_DBUS_META_IFACE_DBUS_PROPERTIES(
Packit Service a1bd4f
        NML_DBUS_META_PROPERTY_INIT_FCN("HwAddress",
Packit Service a1bd4f
                                        0,
Packit Service a1bd4f
                                        "s",
Packit Service a1bd4f
                                        _nm_device_notify_update_prop_hw_address), ), );
Packit 5756e2
Packit 5756e2
static void
Packit Service a1bd4f
nm_device_wpan_class_init(NMDeviceWpanClass *wpan_class)
Packit 5756e2
{
Packit Service a1bd4f
    NMDeviceClass *device_class = NM_DEVICE_CLASS(wpan_class);
Packit 5756e2
Packit Service a1bd4f
    device_class->connection_compatible = connection_compatible;
Packit Service a1bd4f
    device_class->get_setting_type      = get_setting_type;
Packit 5756e2
}