|
Packit Service |
87a54e |
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
Packit |
5756e2 |
/*
|
|
Packit |
5756e2 |
* Copyright (C) 2013 Red Hat, Inc.
|
|
Packit |
5756e2 |
*/
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/**
|
|
Packit |
5756e2 |
* SECTION:nmt-page-vlan
|
|
Packit |
5756e2 |
* @short_description: The editor page for VLAN connections
|
|
Packit |
5756e2 |
*/
|
|
Packit |
5756e2 |
|
|
Packit Service |
2bceb2 |
#include "libnm/nm-default-client.h"
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
#include "nm-editor-bindings.h"
|
|
Packit |
5756e2 |
|
|
Packit Service |
d0b836 |
#include <linux/if_ether.h>
|
|
Packit Service |
d0b836 |
|
|
Packit |
5756e2 |
#include "nmt-page-vlan.h"
|
|
Packit |
5756e2 |
#include "nmt-device-entry.h"
|
|
Packit |
5756e2 |
#include "nmt-mac-entry.h"
|
|
Packit |
5756e2 |
#include "nmt-mtu-entry.h"
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
G_DEFINE_TYPE(NmtPageVlan, nmt_page_vlan, NMT_TYPE_EDITOR_PAGE_DEVICE)
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
NmtEditorPage *
|
|
Packit Service |
a1bd4f |
nmt_page_vlan_new(NMConnection *conn, NmtDeviceEntry *deventry)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
return g_object_new(NMT_TYPE_PAGE_VLAN, "connection", conn, "device-entry", deventry, NULL);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
nmt_page_vlan_init(NmtPageVlan *vlan)
|
|
Packit Service |
a1bd4f |
{}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static gboolean
|
|
Packit Service |
a1bd4f |
vlan_device_filter(NmtDeviceEntry *deventry, NMDevice *device, gpointer user_data)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
// FIXME
|
|
Packit Service |
a1bd4f |
return NM_IS_DEVICE_ETHERNET(device);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
nmt_page_vlan_constructed(GObject *object)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
NmtPageVlan * vlan = NMT_PAGE_VLAN(object);
|
|
Packit Service |
a1bd4f |
NmtEditorSection *section;
|
|
Packit Service |
a1bd4f |
NmtEditorGrid * grid;
|
|
Packit Service |
a1bd4f |
NMSettingWired * s_wired;
|
|
Packit Service |
a1bd4f |
NMSettingVlan * s_vlan;
|
|
Packit Service |
a1bd4f |
NmtNewtWidget * widget, *parent, *id_entry;
|
|
Packit Service |
a1bd4f |
NMConnection * conn;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
conn = nmt_editor_page_get_connection(NMT_EDITOR_PAGE(vlan));
|
|
Packit Service |
a1bd4f |
s_vlan = nm_connection_get_setting_vlan(conn);
|
|
Packit Service |
a1bd4f |
if (!s_vlan) {
|
|
Packit Service |
a1bd4f |
nm_connection_add_setting(conn, nm_setting_vlan_new());
|
|
Packit Service |
a1bd4f |
s_vlan = nm_connection_get_setting_vlan(conn);
|
|
Packit Service |
a1bd4f |
}
|
|
Packit Service |
a1bd4f |
s_wired = nm_connection_get_setting_wired(conn);
|
|
Packit Service |
a1bd4f |
if (!s_wired) {
|
|
Packit Service |
a1bd4f |
nm_connection_add_setting(conn, nm_setting_wired_new());
|
|
Packit Service |
a1bd4f |
s_wired = nm_connection_get_setting_wired(conn);
|
|
Packit Service |
a1bd4f |
}
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
section = nmt_editor_section_new(_("VLAN"), NULL, TRUE);
|
|
Packit Service |
a1bd4f |
grid = nmt_editor_section_get_body(section);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
nm_editor_bind_vlan_name(s_vlan, nm_connection_get_setting_connection(conn));
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
widget = parent = nmt_device_entry_new(_("Parent"), 40, G_TYPE_NONE);
|
|
Packit Service |
a1bd4f |
nmt_device_entry_set_device_filter(NMT_DEVICE_ENTRY(widget), vlan_device_filter, vlan);
|
|
Packit Service |
a1bd4f |
g_object_bind_property(s_vlan,
|
|
Packit Service |
a1bd4f |
NM_SETTING_VLAN_PARENT,
|
|
Packit Service |
a1bd4f |
widget,
|
|
Packit Service |
a1bd4f |
"interface-name",
|
|
Packit Service |
a1bd4f |
G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
|
|
Packit Service |
a1bd4f |
g_object_bind_property(s_wired,
|
|
Packit Service |
a1bd4f |
NM_SETTING_WIRED_MAC_ADDRESS,
|
|
Packit Service |
a1bd4f |
widget,
|
|
Packit Service |
a1bd4f |
"mac-address",
|
|
Packit Service |
a1bd4f |
G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
|
|
Packit Service |
a1bd4f |
nmt_editor_grid_append(grid, NULL, widget, NULL);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
widget = id_entry = nmt_newt_entry_numeric_new(8, 0, 4094);
|
|
Packit Service |
a1bd4f |
g_object_bind_property(s_vlan,
|
|
Packit Service |
a1bd4f |
NM_SETTING_VLAN_ID,
|
|
Packit Service |
a1bd4f |
widget,
|
|
Packit Service |
a1bd4f |
"text",
|
|
Packit Service |
a1bd4f |
G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
|
|
Packit Service |
a1bd4f |
nmt_editor_grid_append(grid, _("VLAN id"), widget, NULL);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
nmt_editor_grid_append(grid, NULL, nmt_newt_separator_new(), NULL);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
widget = nmt_mac_entry_new(40, ETH_ALEN, NMT_MAC_ENTRY_TYPE_CLONED);
|
|
Packit Service |
a1bd4f |
g_object_bind_property(s_wired,
|
|
Packit Service |
a1bd4f |
NM_SETTING_WIRED_CLONED_MAC_ADDRESS,
|
|
Packit Service |
a1bd4f |
widget,
|
|
Packit Service |
a1bd4f |
"mac-address",
|
|
Packit Service |
a1bd4f |
G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
|
|
Packit Service |
a1bd4f |
nmt_editor_grid_append(grid, _("Cloned MAC address"), widget, NULL);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
widget = nmt_mtu_entry_new();
|
|
Packit Service |
a1bd4f |
g_object_bind_property(s_wired,
|
|
Packit Service |
a1bd4f |
NM_SETTING_WIRED_MTU,
|
|
Packit Service |
a1bd4f |
widget,
|
|
Packit Service |
a1bd4f |
"mtu",
|
|
Packit Service |
a1bd4f |
G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
|
|
Packit Service |
a1bd4f |
nmt_editor_grid_append(grid, _("MTU"), widget, NULL);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
nmt_editor_page_add_section(NMT_EDITOR_PAGE(vlan), section);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
G_OBJECT_CLASS(nmt_page_vlan_parent_class)->constructed(object);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
nmt_page_vlan_class_init(NmtPageVlanClass *vlan_class)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
GObjectClass *object_class = G_OBJECT_CLASS(vlan_class);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
/* virtual methods */
|
|
Packit Service |
a1bd4f |
object_class->constructed = nmt_page_vlan_constructed;
|
|
Packit |
5756e2 |
}
|