|
Packit Service |
b23acc |
// SPDX-License-Identifier: GPL-2.0+
|
|
Packit Service |
b23acc |
/*
|
|
Packit Service |
b23acc |
* Copyright (C) 2014 Red Hat, Inc.
|
|
Packit Service |
b23acc |
*/
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
/**
|
|
Packit Service |
b23acc |
* SECTION:nmt-page-ppp
|
|
Packit Service |
b23acc |
* @short_description: The editor page for PPP configuration
|
|
Packit Service |
b23acc |
*/
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
#include "nm-default.h"
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
#include <stdlib.h>
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
#include "nmt-page-ppp.h"
|
|
Packit Service |
b23acc |
#include "nmt-newt-section.h"
|
|
Packit Service |
b23acc |
#include "nmt-newt-separator.h"
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
G_DEFINE_TYPE (NmtPagePpp, nmt_page_ppp, NMT_TYPE_EDITOR_PAGE)
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
typedef struct {
|
|
Packit Service |
b23acc |
guint32 lcp_echo_failure;
|
|
Packit Service |
b23acc |
guint32 lcp_echo_interval;
|
|
Packit Service |
b23acc |
} NmtPagePppPrivate;
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
#define NMT_PAGE_PPP_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NMT_TYPE_PAGE_PPP, NmtPagePppPrivate))
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
NmtEditorPage *
|
|
Packit Service |
b23acc |
nmt_page_ppp_new (NMConnection *conn)
|
|
Packit Service |
b23acc |
{
|
|
Packit Service |
b23acc |
return g_object_new (NMT_TYPE_PAGE_PPP,
|
|
Packit Service |
b23acc |
"connection", conn,
|
|
Packit Service |
b23acc |
NULL);
|
|
Packit Service |
b23acc |
}
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
static void
|
|
Packit Service |
b23acc |
nmt_page_ppp_init (NmtPagePpp *ppp)
|
|
Packit Service |
b23acc |
{
|
|
Packit Service |
b23acc |
}
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
static gboolean
|
|
Packit Service |
b23acc |
transform_lcp_echo_properties_to_checkbox (GBinding *binding,
|
|
Packit Service |
b23acc |
const GValue *from_value,
|
|
Packit Service |
b23acc |
GValue *to_value,
|
|
Packit Service |
b23acc |
gpointer user_data)
|
|
Packit Service |
b23acc |
{
|
|
Packit Service |
b23acc |
NMSettingPpp *s_ppp = NM_SETTING_PPP (g_binding_get_source (binding));
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
if ( nm_setting_ppp_get_lcp_echo_interval (s_ppp) != 0
|
|
Packit Service |
b23acc |
&& nm_setting_ppp_get_lcp_echo_failure (s_ppp) != 0)
|
|
Packit Service |
b23acc |
g_value_set_boolean (to_value, TRUE);
|
|
Packit Service |
b23acc |
else
|
|
Packit Service |
b23acc |
g_value_set_boolean (to_value, FALSE);
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
return TRUE;
|
|
Packit Service |
b23acc |
}
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
static gboolean
|
|
Packit Service |
b23acc |
transform_checkbox_to_lcp_echo_interval (GBinding *binding,
|
|
Packit Service |
b23acc |
const GValue *from_value,
|
|
Packit Service |
b23acc |
GValue *to_value,
|
|
Packit Service |
b23acc |
gpointer user_data)
|
|
Packit Service |
b23acc |
{
|
|
Packit Service |
b23acc |
NmtPagePpp *ppp = user_data;
|
|
Packit Service |
b23acc |
NmtPagePppPrivate *priv = NMT_PAGE_PPP_GET_PRIVATE (ppp);
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
if (g_value_get_boolean (from_value))
|
|
Packit Service |
b23acc |
g_value_set_uint (to_value, priv->lcp_echo_interval);
|
|
Packit Service |
b23acc |
else
|
|
Packit Service |
b23acc |
g_value_set_uint (to_value, 0);
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
return TRUE;
|
|
Packit Service |
b23acc |
}
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
static gboolean
|
|
Packit Service |
b23acc |
transform_checkbox_to_lcp_echo_failure (GBinding *binding,
|
|
Packit Service |
b23acc |
const GValue *from_value,
|
|
Packit Service |
b23acc |
GValue *to_value,
|
|
Packit Service |
b23acc |
gpointer user_data)
|
|
Packit Service |
b23acc |
{
|
|
Packit Service |
b23acc |
NmtPagePpp *ppp = user_data;
|
|
Packit Service |
b23acc |
NmtPagePppPrivate *priv = NMT_PAGE_PPP_GET_PRIVATE (ppp);
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
if (g_value_get_boolean (from_value))
|
|
Packit Service |
b23acc |
g_value_set_uint (to_value, priv->lcp_echo_failure);
|
|
Packit Service |
b23acc |
else
|
|
Packit Service |
b23acc |
g_value_set_uint (to_value, 0);
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
return TRUE;
|
|
Packit Service |
b23acc |
}
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
static void
|
|
Packit Service |
b23acc |
nmt_page_ppp_constructed (GObject *object)
|
|
Packit Service |
b23acc |
{
|
|
Packit Service |
b23acc |
NmtPagePpp *ppp = NMT_PAGE_PPP (object);
|
|
Packit Service |
b23acc |
NmtPagePppPrivate *priv = NMT_PAGE_PPP_GET_PRIVATE (ppp);
|
|
Packit Service |
b23acc |
NmtEditorSection *section;
|
|
Packit Service |
b23acc |
NmtEditorGrid *grid;
|
|
Packit Service |
b23acc |
NMSettingPpp *s_ppp;
|
|
Packit Service |
b23acc |
NmtNewtWidget *widget, *use_mppe;
|
|
Packit Service |
b23acc |
NmtNewtGrid *auth_grid, *mppe_grid;
|
|
Packit Service |
b23acc |
NmtNewtSection *auth_section, *mppe_section;
|
|
Packit Service |
b23acc |
NMConnection *conn;
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
conn = nmt_editor_page_get_connection (NMT_EDITOR_PAGE (ppp));
|
|
Packit Service |
b23acc |
s_ppp = nm_connection_get_setting_ppp (conn);
|
|
Packit Service |
b23acc |
if (s_ppp) {
|
|
Packit Service |
b23acc |
priv->lcp_echo_interval = nm_setting_ppp_get_lcp_echo_interval (s_ppp);
|
|
Packit Service |
b23acc |
priv->lcp_echo_failure = nm_setting_ppp_get_lcp_echo_failure (s_ppp);
|
|
Packit Service |
b23acc |
} else {
|
|
Packit Service |
b23acc |
s_ppp = (NMSettingPpp *) nm_setting_ppp_new ();
|
|
Packit Service |
b23acc |
nm_connection_add_setting (conn, (NMSetting *) s_ppp);
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
priv->lcp_echo_interval = 30;
|
|
Packit Service |
b23acc |
priv->lcp_echo_failure = 5;
|
|
Packit Service |
b23acc |
}
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
section = nmt_editor_section_new (_("PPP CONFIGURATION"), NULL, TRUE);
|
|
Packit Service |
b23acc |
grid = nmt_editor_section_get_body (section);
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
/* Auth methods */
|
|
Packit Service |
b23acc |
widget = nmt_newt_section_new (FALSE);
|
|
Packit Service |
b23acc |
auth_section = NMT_NEWT_SECTION (widget);
|
|
Packit Service |
b23acc |
g_object_set (auth_section, "open", TRUE, NULL);
|
|
Packit Service |
b23acc |
nmt_editor_grid_append (grid, NULL, widget, NULL);
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
widget = nmt_newt_label_new (_("Allowed authentication methods:"));
|
|
Packit Service |
b23acc |
nmt_newt_section_set_header (auth_section, widget);
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
widget = nmt_newt_grid_new ();
|
|
Packit Service |
b23acc |
auth_grid = NMT_NEWT_GRID (widget);
|
|
Packit Service |
b23acc |
nmt_newt_section_set_body (auth_section, widget);
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
widget = nmt_newt_checkbox_new (_("EAP"));
|
|
Packit Service |
b23acc |
g_object_bind_property (s_ppp, NM_SETTING_PPP_REFUSE_EAP,
|
|
Packit Service |
b23acc |
widget, "active",
|
|
Packit Service |
b23acc |
G_BINDING_BIDIRECTIONAL |
|
|
Packit Service |
b23acc |
G_BINDING_INVERT_BOOLEAN |
|
|
Packit Service |
b23acc |
G_BINDING_SYNC_CREATE);
|
|
Packit Service |
b23acc |
nmt_newt_grid_add (auth_grid, widget, 0, 0);
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
widget = nmt_newt_checkbox_new (_("PAP"));
|
|
Packit Service |
b23acc |
g_object_bind_property (s_ppp, NM_SETTING_PPP_REFUSE_PAP,
|
|
Packit Service |
b23acc |
widget, "active",
|
|
Packit Service |
b23acc |
G_BINDING_BIDIRECTIONAL |
|
|
Packit Service |
b23acc |
G_BINDING_INVERT_BOOLEAN |
|
|
Packit Service |
b23acc |
G_BINDING_SYNC_CREATE);
|
|
Packit Service |
b23acc |
nmt_newt_grid_add (auth_grid, widget, 0, 1);
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
widget = nmt_newt_checkbox_new (_("CHAP"));
|
|
Packit Service |
b23acc |
g_object_bind_property (s_ppp, NM_SETTING_PPP_REFUSE_CHAP,
|
|
Packit Service |
b23acc |
widget, "active",
|
|
Packit Service |
b23acc |
G_BINDING_BIDIRECTIONAL |
|
|
Packit Service |
b23acc |
G_BINDING_INVERT_BOOLEAN |
|
|
Packit Service |
b23acc |
G_BINDING_SYNC_CREATE);
|
|
Packit Service |
b23acc |
nmt_newt_grid_add (auth_grid, widget, 0, 2);
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
widget = nmt_newt_checkbox_new (_("MSCHAPv2"));
|
|
Packit Service |
b23acc |
g_object_bind_property (s_ppp, NM_SETTING_PPP_REFUSE_MSCHAPV2,
|
|
Packit Service |
b23acc |
widget, "active",
|
|
Packit Service |
b23acc |
G_BINDING_BIDIRECTIONAL |
|
|
Packit Service |
b23acc |
G_BINDING_INVERT_BOOLEAN |
|
|
Packit Service |
b23acc |
G_BINDING_SYNC_CREATE);
|
|
Packit Service |
b23acc |
nmt_newt_grid_add (auth_grid, widget, 0, 3);
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
widget = nmt_newt_checkbox_new (_("MSCHAP"));
|
|
Packit Service |
b23acc |
g_object_bind_property (s_ppp, NM_SETTING_PPP_REFUSE_MSCHAP,
|
|
Packit Service |
b23acc |
widget, "active",
|
|
Packit Service |
b23acc |
G_BINDING_BIDIRECTIONAL |
|
|
Packit Service |
b23acc |
G_BINDING_INVERT_BOOLEAN |
|
|
Packit Service |
b23acc |
G_BINDING_SYNC_CREATE);
|
|
Packit Service |
b23acc |
nmt_newt_grid_add (auth_grid, widget, 0, 4);
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
nmt_editor_grid_append (grid, NULL, nmt_newt_separator_new (), NULL);
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
/* MPPE */
|
|
Packit Service |
b23acc |
widget = nmt_newt_section_new (FALSE);
|
|
Packit Service |
b23acc |
mppe_section = NMT_NEWT_SECTION (widget);
|
|
Packit Service |
b23acc |
g_object_set (mppe_section, "open", TRUE, NULL);
|
|
Packit Service |
b23acc |
nmt_editor_grid_append (grid, NULL, widget, NULL);
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
widget = nmt_newt_checkbox_new (_("Use point-to-point encryption (MPPE)"));
|
|
Packit Service |
b23acc |
g_object_bind_property (s_ppp, NM_SETTING_PPP_REQUIRE_MPPE,
|
|
Packit Service |
b23acc |
widget, "active",
|
|
Packit Service |
b23acc |
G_BINDING_BIDIRECTIONAL |
|
|
Packit Service |
b23acc |
G_BINDING_SYNC_CREATE);
|
|
Packit Service |
b23acc |
use_mppe = widget;
|
|
Packit Service |
b23acc |
nmt_newt_section_set_header (mppe_section, widget);
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
widget = nmt_newt_grid_new ();
|
|
Packit Service |
b23acc |
mppe_grid = NMT_NEWT_GRID (widget);
|
|
Packit Service |
b23acc |
nmt_newt_section_set_body (mppe_section, widget);
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
widget = nmt_newt_checkbox_new (_("Require 128-bit encryption"));
|
|
Packit Service |
b23acc |
g_object_bind_property (use_mppe, "active",
|
|
Packit Service |
b23acc |
widget, "sensitive",
|
|
Packit Service |
b23acc |
G_BINDING_SYNC_CREATE);
|
|
Packit Service |
b23acc |
g_object_bind_property (s_ppp, NM_SETTING_PPP_REQUIRE_MPPE_128,
|
|
Packit Service |
b23acc |
widget, "active",
|
|
Packit Service |
b23acc |
G_BINDING_BIDIRECTIONAL |
|
|
Packit Service |
b23acc |
G_BINDING_SYNC_CREATE);
|
|
Packit Service |
b23acc |
nmt_newt_grid_add (mppe_grid, widget, 0, 0);
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
widget = nmt_newt_checkbox_new (_("Use stateful MPPE"));
|
|
Packit Service |
b23acc |
g_object_bind_property (use_mppe, "active",
|
|
Packit Service |
b23acc |
widget, "sensitive",
|
|
Packit Service |
b23acc |
G_BINDING_SYNC_CREATE);
|
|
Packit Service |
b23acc |
g_object_bind_property (s_ppp, NM_SETTING_PPP_MPPE_STATEFUL,
|
|
Packit Service |
b23acc |
widget, "active",
|
|
Packit Service |
b23acc |
G_BINDING_BIDIRECTIONAL |
|
|
Packit Service |
b23acc |
G_BINDING_SYNC_CREATE);
|
|
Packit Service |
b23acc |
nmt_newt_grid_add (mppe_grid, widget, 0, 1);
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
nmt_editor_grid_append (grid, NULL, nmt_newt_separator_new (), NULL);
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
widget = nmt_newt_checkbox_new (_("Allow BSD data compression"));
|
|
Packit Service |
b23acc |
g_object_bind_property (s_ppp, NM_SETTING_PPP_NOBSDCOMP,
|
|
Packit Service |
b23acc |
widget, "active",
|
|
Packit Service |
b23acc |
G_BINDING_BIDIRECTIONAL |
|
|
Packit Service |
b23acc |
G_BINDING_INVERT_BOOLEAN |
|
|
Packit Service |
b23acc |
G_BINDING_SYNC_CREATE);
|
|
Packit Service |
b23acc |
nmt_editor_grid_append (grid, NULL, widget, NULL);
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
widget = nmt_newt_checkbox_new (_("Allow Deflate data compression"));
|
|
Packit Service |
b23acc |
g_object_bind_property (s_ppp, NM_SETTING_PPP_NODEFLATE,
|
|
Packit Service |
b23acc |
widget, "active",
|
|
Packit Service |
b23acc |
G_BINDING_BIDIRECTIONAL |
|
|
Packit Service |
b23acc |
G_BINDING_INVERT_BOOLEAN |
|
|
Packit Service |
b23acc |
G_BINDING_SYNC_CREATE);
|
|
Packit Service |
b23acc |
nmt_editor_grid_append (grid, NULL, widget, NULL);
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
widget = nmt_newt_checkbox_new (_("Use TCP header compression"));
|
|
Packit Service |
b23acc |
g_object_bind_property (s_ppp, NM_SETTING_PPP_NO_VJ_COMP,
|
|
Packit Service |
b23acc |
widget, "active",
|
|
Packit Service |
b23acc |
G_BINDING_BIDIRECTIONAL |
|
|
Packit Service |
b23acc |
G_BINDING_INVERT_BOOLEAN |
|
|
Packit Service |
b23acc |
G_BINDING_SYNC_CREATE);
|
|
Packit Service |
b23acc |
nmt_editor_grid_append (grid, NULL, widget, NULL);
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
nmt_editor_grid_append (grid, NULL, nmt_newt_separator_new (), NULL);
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
widget = nmt_newt_checkbox_new (_("Send PPP echo packets"));
|
|
Packit Service |
b23acc |
g_object_bind_property_full (s_ppp, NM_SETTING_PPP_LCP_ECHO_INTERVAL,
|
|
Packit Service |
b23acc |
widget, "active",
|
|
Packit Service |
b23acc |
G_BINDING_BIDIRECTIONAL |
|
|
Packit Service |
b23acc |
G_BINDING_SYNC_CREATE,
|
|
Packit Service |
b23acc |
transform_lcp_echo_properties_to_checkbox,
|
|
Packit Service |
b23acc |
transform_checkbox_to_lcp_echo_interval,
|
|
Packit Service |
b23acc |
ppp, NULL);
|
|
Packit Service |
b23acc |
g_object_bind_property_full (s_ppp, NM_SETTING_PPP_LCP_ECHO_FAILURE,
|
|
Packit Service |
b23acc |
widget, "active",
|
|
Packit Service |
b23acc |
G_BINDING_BIDIRECTIONAL |
|
|
Packit Service |
b23acc |
G_BINDING_SYNC_CREATE,
|
|
Packit Service |
b23acc |
transform_lcp_echo_properties_to_checkbox,
|
|
Packit Service |
b23acc |
transform_checkbox_to_lcp_echo_failure,
|
|
Packit Service |
b23acc |
ppp, NULL);
|
|
Packit Service |
b23acc |
nmt_editor_grid_append (grid, NULL, widget, NULL);
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
nmt_editor_page_add_section (NMT_EDITOR_PAGE (ppp), section);
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
G_OBJECT_CLASS (nmt_page_ppp_parent_class)->constructed (object);
|
|
Packit Service |
b23acc |
}
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
static void
|
|
Packit Service |
b23acc |
nmt_page_ppp_class_init (NmtPagePppClass *ppp_class)
|
|
Packit Service |
b23acc |
{
|
|
Packit Service |
b23acc |
GObjectClass *object_class = G_OBJECT_CLASS (ppp_class);
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
g_type_class_add_private (object_class, sizeof (NmtPagePppPrivate));
|
|
Packit Service |
b23acc |
|
|
Packit Service |
b23acc |
object_class->constructed = nmt_page_ppp_constructed;
|
|
Packit Service |
b23acc |
}
|