Blame libnm/nm-device-veth.c

Packit Service 87a54e
/* SPDX-License-Identifier: LGPL-2.1-or-later */
Packit Service a1bd4f
/*
Packit Service a1bd4f
 * Copyright (C) 2020 Red Hat, Inc.
Packit Service a1bd4f
 */
Packit Service a1bd4f
Packit Service 2bceb2
#include "libnm/nm-default-libnm.h"
Packit Service a1bd4f
Packit Service a1bd4f
#include "nm-device-veth.h"
Packit Service a1bd4f
Packit Service a1bd4f
#include "nm-setting-connection.h"
Packit Service a1bd4f
#include "nm-setting-veth.h"
Packit Service a1bd4f
#include "nm-setting-wired.h"
Packit Service a1bd4f
#include "nm-utils.h"
Packit Service a1bd4f
#include "nm-device-ethernet.h"
Packit Service a1bd4f
#include "nm-object-private.h"
Packit Service a1bd4f
Packit Service a1bd4f
/*****************************************************************************/
Packit Service a1bd4f
Packit Service a1bd4f
NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_PEER, );
Packit Service a1bd4f
Packit Service a1bd4f
typedef struct {
Packit Service 8f75d2
    NMLDBusPropertyO peer;
Packit Service a1bd4f
} NMDeviceVethPrivate;
Packit Service a1bd4f
Packit Service a1bd4f
struct _NMDeviceVeth {
Packit Service a1bd4f
    NMDeviceEthernet    parent;
Packit Service a1bd4f
    NMDeviceVethPrivate _priv;
Packit Service a1bd4f
};
Packit Service a1bd4f
Packit Service a1bd4f
struct _NMDeviceVethClass {
Packit Service a1bd4f
    NMDeviceEthernetClass parent;
Packit Service a1bd4f
};
Packit Service a1bd4f
Packit Service a1bd4f
G_DEFINE_TYPE(NMDeviceVeth, nm_device_veth, NM_TYPE_DEVICE_ETHERNET)
Packit Service a1bd4f
Packit Service a1bd4f
#define NM_DEVICE_VETH_GET_PRIVATE(self) \
Packit Service a1bd4f
    _NM_GET_PRIVATE(self, NMDeviceVeth, NM_IS_DEVICE_VETH, NMObject, NMDevice)
Packit Service a1bd4f
Packit Service a1bd4f
/*****************************************************************************/
Packit Service a1bd4f
Packit Service a1bd4f
/**
Packit Service a1bd4f
 * nm_device_veth_get_peer:
Packit Service a1bd4f
 * @device: a #NMDeviceVeth
Packit Service a1bd4f
 *
Packit Service 8f75d2
 * Returns: (transfer none): the device's peer device
Packit Service a1bd4f
 *
Packit Service a1bd4f
 * Since: 1.30
Packit Service a1bd4f
 **/
Packit Service 8f75d2
NMDevice *
Packit Service a1bd4f
nm_device_veth_get_peer(NMDeviceVeth *device)
Packit Service a1bd4f
{
Packit Service 8f75d2
    g_return_val_if_fail(NM_IS_DEVICE_VETH(device), FALSE);
Packit Service a1bd4f
Packit Service 8f75d2
    return nml_dbus_property_o_get_obj(&NM_DEVICE_VETH_GET_PRIVATE(device)->peer);
Packit Service a1bd4f
}
Packit Service a1bd4f
Packit Service a1bd4f
static GType
Packit Service a1bd4f
get_setting_type(NMDevice *device)
Packit Service a1bd4f
{
Packit Service a1bd4f
    return NM_TYPE_SETTING_VETH;
Packit Service a1bd4f
}
Packit Service a1bd4f
Packit Service a1bd4f
/*****************************************************************************/
Packit Service a1bd4f
Packit Service a1bd4f
static void
Packit Service a1bd4f
get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
Packit Service a1bd4f
{
Packit Service a1bd4f
    NMDeviceVeth *device = NM_DEVICE_VETH(object);
Packit Service a1bd4f
Packit Service a1bd4f
    switch (prop_id) {
Packit Service a1bd4f
    case PROP_PEER:
Packit Service 8f75d2
        g_value_set_object(value, nm_device_veth_get_peer(device));
Packit Service a1bd4f
        break;
Packit Service a1bd4f
    default:
Packit Service a1bd4f
        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
Packit Service a1bd4f
        break;
Packit Service a1bd4f
    }
Packit Service a1bd4f
}
Packit Service a1bd4f
Packit Service a1bd4f
static void
Packit Service a1bd4f
nm_device_veth_init(NMDeviceVeth *device)
Packit Service a1bd4f
{}
Packit Service a1bd4f
Packit Service 8f75d2
const NMLDBusMetaIface _nml_dbus_meta_iface_nm_device_veth =
Packit Service 8f75d2
    NML_DBUS_META_IFACE_INIT_PROP(NM_DBUS_INTERFACE_DEVICE_VETH,
Packit Service 8f75d2
                                  nm_device_veth_get_type,
Packit Service d0b836
                                  NML_DBUS_META_INTERFACE_PRIO_INSTANTIATE_30,
Packit Service 8f75d2
                                  NML_DBUS_META_IFACE_DBUS_PROPERTIES(
Packit Service 8f75d2
                                      NML_DBUS_META_PROPERTY_INIT_O_PROP("Peer",
Packit Service 8f75d2
                                                                         PROP_PEER,
Packit Service 8f75d2
                                                                         NMDeviceVeth,
Packit Service 8f75d2
                                                                         _priv.peer,
Packit Service 8f75d2
                                                                         nm_device_get_type), ), );
Packit Service a1bd4f
Packit Service a1bd4f
static void
Packit Service a1bd4f
nm_device_veth_class_init(NMDeviceVethClass *klass)
Packit Service a1bd4f
{
Packit Service a1bd4f
    GObjectClass * object_class    = G_OBJECT_CLASS(klass);
Packit Service a1bd4f
    NMObjectClass *nm_object_class = NM_OBJECT_CLASS(klass);
Packit Service a1bd4f
    NMDeviceClass *device_class    = NM_DEVICE_CLASS(klass);
Packit Service a1bd4f
Packit Service a1bd4f
    object_class->get_property = get_property;
Packit Service a1bd4f
Packit Service a1bd4f
    _NM_OBJECT_CLASS_INIT_PRIV_PTR_DIRECT(nm_object_class, NMDeviceVeth);
Packit Service a1bd4f
Packit Service 8f75d2
    _NM_OBJECT_CLASS_INIT_PROPERTY_O_FIELDS_1(nm_object_class, NMDeviceVethPrivate, peer);
Packit Service 8f75d2
Packit Service a1bd4f
    device_class->get_setting_type = get_setting_type;
Packit Service a1bd4f
Packit Service a1bd4f
    /**
Packit Service a1bd4f
     * NMDeviceVeth:peer:
Packit Service a1bd4f
     *
Packit Service 8f75d2
     * The device's peer device.
Packit Service a1bd4f
     *
Packit Service a1bd4f
     * Since: 1.30
Packit Service a1bd4f
     **/
Packit Service 8f75d2
    obj_properties[PROP_PEER] = g_param_spec_object(NM_DEVICE_VETH_PEER,
Packit Service a1bd4f
                                                    "",
Packit Service a1bd4f
                                                    "",
Packit Service 8f75d2
                                                    NM_TYPE_DEVICE,
Packit Service a1bd4f
                                                    G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
Packit Service a1bd4f
Packit Service a1bd4f
    _nml_dbus_meta_class_init_with_properties(object_class, &_nml_dbus_meta_iface_nm_device_veth);
Packit Service a1bd4f
}