mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-26 10:00:07 +01:00
2008-07-20 Dan Williams <dcbw@redhat.com>
Port to NM 0.7 VPN plugin API git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3838 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
parent
e058368698
commit
58d9db9a48
69 changed files with 3629 additions and 13874 deletions
|
|
@ -1,3 +1,7 @@
|
|||
2008-07-20 Dan Williams <dcbw@redhat.com>
|
||||
|
||||
Port to NM 0.7 VPN plugin API
|
||||
|
||||
2008-04-27 Dan Williams <dcbw@redhat.com>
|
||||
|
||||
* properties/Makefile.am
|
||||
|
|
|
|||
|
|
@ -1,24 +1,20 @@
|
|||
AUTOMAKE_OPTIONS = foreign
|
||||
|
||||
if WITH_GNOME
|
||||
SUBDIRS = src auth-dialog auth-dialog-general properties po
|
||||
SUBDIRS = src auth-dialog properties po
|
||||
else
|
||||
SUBDIRS = src
|
||||
endif
|
||||
|
||||
dbusservicedir = $(sysconfdir)/dbus-1/system.d
|
||||
dbusservice_DATA = nm-ppp-starter.conf
|
||||
dbusservice_DATA = nm-pptp-service.conf
|
||||
|
||||
nmvpnservice_in_files = nm-ppp-starter.name.in
|
||||
nmvpnservicedir = $(sysconfdir)/NetworkManager/VPN
|
||||
nmvpnservice_DATA = $(nmvpnservice_in_files:.name.in=.name)
|
||||
|
||||
%.name: %.name.in Makefile
|
||||
@sed -e "s|%bindir%|$(bindir)|g" \
|
||||
-e "s|%libdir%|$(libdir)|g" \
|
||||
-e "s|%libexecdir%|$(libexecdir)|g" $< > $@
|
||||
nmvpnservice_DATA = nm-pptp-service.name
|
||||
|
||||
if WITH_GNOME
|
||||
desktopdir = $(datadir)/applications
|
||||
desktop_in_files = nm-ppp.desktop.in
|
||||
desktop_in_files = nm-pptp.desktop.in
|
||||
desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
|
||||
@INTLTOOL_DESKTOP_RULE@
|
||||
|
||||
|
|
@ -26,14 +22,18 @@ icondir = $(datadir)/icons/hicolor/48x48/apps
|
|||
icon_DATA = gnome-mime-application-x-pptp-settings.png
|
||||
endif
|
||||
|
||||
EXTRA_DIST =\
|
||||
$(nmvpnservice_in_files) \
|
||||
$(dbusservice_DATA) \
|
||||
$(desktop_in_files) \
|
||||
$(icon_DATA) \
|
||||
intltool-extract.in \
|
||||
intltool-merge.in \
|
||||
intltool-update.in
|
||||
nm-pptp-service.name: $(srcdir)/nm-pptp-service.name.in Makefile
|
||||
sed -e 's|[@]BINDIR[@]|$(bindir)|g' \
|
||||
< $(srcdir)/nm-pptp-service.name.in \
|
||||
> nm-pptp-service.name
|
||||
|
||||
CLEANFILES = $(desktop_DATA) $(nmvpnservice_DATA) *~
|
||||
EXTRA_DIST = nm-pptp-service.name.in \
|
||||
$(dbusservice_DATA) \
|
||||
$(desktop_in_files) \
|
||||
$(icon_DATA) \
|
||||
intltool-extract.in \
|
||||
intltool-merge.in \
|
||||
intltool-update.in
|
||||
|
||||
CLEANFILES = $(nmvpnservice_DATA) $(desktop_DATA) *~
|
||||
DISTCLEANFILES = intltool-extract intltool-merge intltool-update
|
||||
|
|
|
|||
|
|
@ -1,15 +1,17 @@
|
|||
PPTP support for NetworkManager
|
||||
|
||||
Added by Antony Mee http://www.students.ncl.ac.uk/a.j.mee
|
||||
Based entirely on OpenVPN support by Tim Niemueller http://www.niemueller.de
|
||||
|
||||
This requires the Linux PPTP client installed
|
||||
http://pptpclient.sourceforge.net/
|
||||
|
||||
TODO: Support for passwords stored outside of /etc/ppp/chap-secrets
|
||||
0.7.x version:
|
||||
(C) 2008 Dan Williams <dcbw@redhat.com>, and Tambet Ingo <tambet@gmail.com>
|
||||
|
||||
Code released under the GPL. See COPYING file in the NetworkManager
|
||||
directory.
|
||||
0.6.x version:
|
||||
(C) 2005 - 2007 Antony Mee http://www.students.ncl.ac.uk/a.j.mee
|
||||
Based entirely on OpenVPN support by Tim Niemueller http://www.niemueller.de
|
||||
|
||||
|
||||
Theory of operation
|
||||
------------------------------
|
||||
|
||||
Aachen, 2005/11/12
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +0,0 @@
|
|||
Makefile.in
|
||||
Makefile
|
||||
nm-ppp-auth-dialog-general
|
||||
.libs
|
||||
.deps
|
||||
|
|
@ -1,115 +0,0 @@
|
|||
INCLUDES = -I${top_srcdir} -I${top_srcdir}/utils
|
||||
|
||||
libexec_PROGRAMS = nm-ppp-auth-dialog-general
|
||||
|
||||
nm_ppp_auth_dialog_general_CPPFLAGS = \
|
||||
$(GTHREAD_CFLAGS) \
|
||||
$(GTK_CFLAGS) \
|
||||
$(LIBGNOMEUI_CFLAGS) \
|
||||
$(GNOMEKEYRING_CFLAGS) \
|
||||
-DICONDIR=\""$(datadir)/pixmaps"\" \
|
||||
-DGLADEDIR=\""$(gladedir)"\" \
|
||||
-DAUTH_MODULES_DIR=\""$(libgenericauthmodulesdir)"\" \
|
||||
-DBINDIR=\""$(bindir)"\" \
|
||||
-DDBUS_API_SUBJECT_TO_CHANGE \
|
||||
-DG_DISABLE_DEPRECATED \
|
||||
-DGDK_DISABLE_DEPRECATED \
|
||||
-DGNOME_DISABLE_DEPRECATED \
|
||||
-DGNOMELOCALEDIR=\"$(datadir)/locale\" \
|
||||
-DVERSION=\"$(VERSION)\" \
|
||||
$(NULL)
|
||||
|
||||
nm_ppp_auth_dialog_general_SOURCES = \
|
||||
main.c \
|
||||
gnome-generic-auth-dialog.c \
|
||||
gnome-generic-auth-dialog.h \
|
||||
$(NULL)
|
||||
|
||||
nm_ppp_auth_dialog_general_LDADD = \
|
||||
$(GTK_LIBS) \
|
||||
$(LIBGNOMEUI_LIBS) \
|
||||
$(GNOMEKEYRING_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
libgenericauthmodulesdir=$(libdir)/NetworkManager/gnome-generic-auth
|
||||
libgenericauthmodules_LTLIBRARIES = \
|
||||
libanonymous-auth-module.la \
|
||||
libchap-auth-module.la \
|
||||
libmschapv2-auth-module.la
|
||||
|
||||
libanonymous_auth_module_la_SOURCES = \
|
||||
anonymous-auth-module.c
|
||||
|
||||
libmschapv2_auth_module_la_SOURCES = \
|
||||
mschapv2-auth-module.c
|
||||
|
||||
libchap_auth_module_la_SOURCES = \
|
||||
chap-auth-module.c
|
||||
|
||||
gladedir = $(datadir)/gnome-generic-auth
|
||||
glade_DATA = nm-ppp-auth.glade
|
||||
|
||||
libanonymous_auth_module_la_CFLAGS = \
|
||||
$(GLADE_CFLAGS) \
|
||||
$(GTK_CFLAGS) \
|
||||
$(GCONF_CFLAGS) \
|
||||
$(LIBGNOMEUI_CFLAGS) \
|
||||
-DICONDIR=\""$(datadir)/pixmaps"\" \
|
||||
-DGLADEDIR=\""$(gladedir)"\" \
|
||||
-DAUTH_MODULES_DIR=\""$(libgenericauthmodulesdir)"\" \
|
||||
-DG_DISABLE_DEPRECATED \
|
||||
-DGDK_DISABLE_DEPRECATED \
|
||||
-DGNOME_DISABLE_DEPRECATED \
|
||||
-DGNOMELOCALEDIR=\"$(datadir)/locale\" \
|
||||
-DVERSION=\"$(VERSION)\"
|
||||
|
||||
libanonymous_auth_module_la_LIBADD = \
|
||||
$(GLADE_LIBS) \
|
||||
$(GTK_LIBS) \
|
||||
$(GCONF_LIBS) \
|
||||
$(LIBGNOMEUI_LIBS)
|
||||
|
||||
libchap_auth_module_la_CFLAGS = \
|
||||
$(GLADE_CFLAGS) \
|
||||
$(GTK_CFLAGS) \
|
||||
$(GCONF_CFLAGS) \
|
||||
$(LIBGNOMEUI_CFLAGS) \
|
||||
-DICONDIR=\""$(datadir)/pixmaps"\" \
|
||||
-DGLADEDIR=\""$(gladedir)"\" \
|
||||
-DAUTH_MODULES_DIR=\""$(libgenericauthmodulesdir)"\" \
|
||||
-DG_DISABLE_DEPRECATED \
|
||||
-DGDK_DISABLE_DEPRECATED \
|
||||
-DGNOME_DISABLE_DEPRECATED \
|
||||
-DGNOMELOCALEDIR=\"$(datadir)/locale\" \
|
||||
-DVERSION=\"$(VERSION)\"
|
||||
|
||||
libmschapv2_auth_module_la_CFLAGS = \
|
||||
$(GLADE_CFLAGS) \
|
||||
$(GTK_CFLAGS) \
|
||||
$(GCONF_CFLAGS) \
|
||||
$(LIBGNOMEUI_CFLAGS) \
|
||||
-DICONDIR=\""$(datadir)/pixmaps"\" \
|
||||
-DGLADEDIR=\""$(gladedir)"\" \
|
||||
-DAUTH_MODULES_DIR=\""$(libgenericauthmodulesdir)"\" \
|
||||
-DG_DISABLE_DEPRECATED \
|
||||
-DGDK_DISABLE_DEPRECATED \
|
||||
-DGNOME_DISABLE_DEPRECATED \
|
||||
-DGNOMELOCALEDIR=\"$(datadir)/locale\" \
|
||||
-DVERSION=\"$(VERSION)\"
|
||||
|
||||
libchap_auth_module_la_LIBADD = \
|
||||
$(GLADE_LIBS) \
|
||||
$(GTK_LIBS) \
|
||||
$(GCONF_LIBS) \
|
||||
$(LIBGNOMEUI_LIBS)
|
||||
|
||||
libmschapv2_auth_module_la_LIBADD = \
|
||||
$(GLADE_LIBS) \
|
||||
$(GTK_LIBS) \
|
||||
$(GCONF_LIBS) \
|
||||
$(LIBGNOMEUI_LIBS)
|
||||
|
||||
EXTRA_DIST = \
|
||||
$(glade_DATA)
|
||||
|
||||
CLEANFILES = *.bak *.gladep *~
|
||||
|
|
@ -1,149 +0,0 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <glib/gi18n-lib.h>
|
||||
#include <string.h>
|
||||
#include <glade/glade.h>
|
||||
|
||||
#define GNOME_GENERIC_AUTH_MODULE_SUBJECT_TO_CHANGE
|
||||
#include "gnome-generic-auth-module.h"
|
||||
|
||||
/* Stuff to be provided by the specific instance */
|
||||
typedef struct _GnomeGenericAuthModuleImpl GnomeGenericAuthModuleImpl;
|
||||
|
||||
struct _GnomeGenericAuthModuleImpl {
|
||||
GnomeGenericAuthModule parent;
|
||||
|
||||
GladeXML *xml;
|
||||
|
||||
GtkWidget *widget;
|
||||
|
||||
// GtkEntry *w_connection_name;
|
||||
// GtkEntry *w_remote;
|
||||
};
|
||||
|
||||
#define GLADE_FILE "nm-ppp-auth.glade"
|
||||
#define GLADE_WIDGET "auth-none-widget"
|
||||
|
||||
#define AUTH_TYPE "NONE"
|
||||
#define AUTH_TYPE_DISPLAY_NAME "None (Anonymous)"
|
||||
|
||||
|
||||
void
|
||||
impl_clear_widget (GnomeGenericAuthModuleImpl *impl)
|
||||
{
|
||||
// g_return_if_fail(impl!=NULL);
|
||||
}
|
||||
|
||||
static const char *
|
||||
impl_get_display_name (GnomeGenericAuthModule *self)
|
||||
{
|
||||
return AUTH_TYPE_DISPLAY_NAME;
|
||||
}
|
||||
|
||||
|
||||
static const char *
|
||||
impl_get_auth_type (GnomeGenericAuthModule *self)
|
||||
{
|
||||
return AUTH_TYPE;
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
impl_get_widget (GnomeGenericAuthModule *self)
|
||||
{
|
||||
GnomeGenericAuthModuleImpl *impl = (GnomeGenericAuthModuleImpl *) self->data;
|
||||
|
||||
impl_clear_widget (impl);
|
||||
//
|
||||
// if (connection_name != NULL) {
|
||||
// if ((opt = impl->connection_name_opt) != NULL) {
|
||||
// vpnui_opt_set(opt,connection_name);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// for (item=properties; item != NULL; item = g_slist_next(g_slist_next(item)))
|
||||
// {
|
||||
// if (item->data==NULL) continue;
|
||||
// if ((g_slist_next(item))->data==NULL) continue;
|
||||
// opt = impl_opt_bygconf(impl,(char *)item->data);
|
||||
// if (opt==NULL) continue;
|
||||
// vpnui_opt_set(opt, (char *)(g_slist_next(item))->data);
|
||||
// }
|
||||
//
|
||||
// if (routes != NULL) {
|
||||
// GString *route_str;
|
||||
// char *str;
|
||||
//
|
||||
// route_str = g_string_new ("");
|
||||
// for (item = routes; item != NULL; item = g_slist_next (item)) {
|
||||
// if (item != routes) g_string_append_c(route_str, ' ');
|
||||
// g_string_append(route_str, (const char *) item->data);
|
||||
// }
|
||||
// str = g_string_free (route_str, FALSE);
|
||||
//
|
||||
// vpnui_opt_set(impl->routes_opt,str);
|
||||
// vpnui_opt_set(impl->routes_toggle_opt,"yes");
|
||||
// g_free (str);
|
||||
// }
|
||||
//
|
||||
// vpnui_expand_reset_all(impl);
|
||||
//
|
||||
return impl->widget;
|
||||
}
|
||||
|
||||
static GnomeGenericAuthModule*
|
||||
impl_get_object (void)
|
||||
{
|
||||
char *glade_file;
|
||||
GnomeGenericAuthModuleImpl *impl;
|
||||
|
||||
impl = g_new0 (GnomeGenericAuthModuleImpl, 1);
|
||||
|
||||
glade_file = g_strdup_printf ("%s/%s", GLADEDIR, GLADE_FILE);
|
||||
impl->xml = glade_xml_new (glade_file, NULL, GETTEXT_PACKAGE);
|
||||
g_free( glade_file );
|
||||
if (impl->xml != NULL) {
|
||||
|
||||
impl->widget = glade_xml_get_widget(impl->xml, GLADE_WIDGET);
|
||||
|
||||
// impl_setup(impl);
|
||||
|
||||
// impl->callback = NULL;
|
||||
|
||||
// if (impl->w_import_button!=NULL) {
|
||||
// g_signal_connect (GTK_OBJECT (impl->w_import_button),
|
||||
// "clicked", G_CALLBACK (import_button_clicked), impl);
|
||||
// }
|
||||
//
|
||||
// /* make the widget reusable */
|
||||
// g_signal_connect (GTK_OBJECT (impl->widget), "delete-event",
|
||||
// G_CALLBACK (gtk_widget_hide_on_delete), NULL);
|
||||
//
|
||||
impl_clear_widget (impl);
|
||||
|
||||
impl->parent.get_display_name = impl_get_display_name;
|
||||
impl->parent.get_auth_type = impl_get_auth_type;
|
||||
impl->parent.get_widget = impl_get_widget;
|
||||
impl->parent.data = impl;
|
||||
|
||||
return &(impl->parent);
|
||||
} else {
|
||||
g_free (impl);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
const char *
|
||||
get_auth_type (void)
|
||||
{
|
||||
return AUTH_TYPE;
|
||||
}
|
||||
|
||||
GnomeGenericAuthModule*
|
||||
gnome_generic_auth_module_factory (void)
|
||||
{
|
||||
return impl_get_object();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,204 +0,0 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <glib/gi18n-lib.h>
|
||||
#include <string.h>
|
||||
#include <glade/glade.h>
|
||||
|
||||
#define GNOME_GENERIC_AUTH_MODULE_SUBJECT_TO_CHANGE
|
||||
#include "gnome-generic-auth-module.h"
|
||||
|
||||
/* Stuff to be provided by the specific instance */
|
||||
typedef struct _GnomeGenericAuthModuleImpl GnomeGenericAuthModuleImpl;
|
||||
|
||||
struct _GnomeGenericAuthModuleImpl {
|
||||
GnomeGenericAuthModule parent;
|
||||
|
||||
GladeXML *xml;
|
||||
|
||||
GtkWidget *widget;
|
||||
|
||||
GtkEntry *w_username;
|
||||
GtkEntry *w_password;
|
||||
|
||||
};
|
||||
|
||||
#define GLADE_FILE "nm-ppp-auth.glade"
|
||||
#define GLADE_WIDGET "auth-chap-widget"
|
||||
//#define GLADE_WIDGET "table1"
|
||||
|
||||
#define AUTH_TYPE "CHAP"
|
||||
#define AUTH_TYPE_DISPLAY_NAME "CHAP Version 1"
|
||||
|
||||
static void
|
||||
entry_changed (GtkWidget *widget,gpointer data)
|
||||
{
|
||||
// GnomeGenericAuthModuleImpl *impl = (GnomeGenericAuthModuleImpl *) data;
|
||||
g_warning("Entry: %s (%s)",gtk_entry_get_text(GTK_ENTRY(widget)), gtk_widget_get_name(widget));
|
||||
}
|
||||
|
||||
static void
|
||||
clear_widget (GnomeGenericAuthModuleImpl *impl)
|
||||
{
|
||||
GList *children;
|
||||
GList *i;
|
||||
GtkWidget *w;
|
||||
g_warning("Clearing widget");
|
||||
gtk_entry_set_text(impl->w_username,"");
|
||||
gtk_entry_set_text(impl->w_password,"");
|
||||
gtk_widget_grab_focus (GTK_WIDGET(impl->w_username));
|
||||
//g_warning("Username %s", GTK_WIDGET_CAN_FOCUS(impl->w_username) ? "Can focus" : "Can't focus" );
|
||||
//g_warning("Username %s", GTK_WIDGET_VISIBLE(impl->w_username) ? "Is visible" : "Is not visible");
|
||||
//g_warning("Username %s", GTK_WIDGET_SENSITIVE(impl->w_username) ? "Is sensitive" : "Is not sensitive");
|
||||
//g_warning("Widget: %s",gtk_widget_get_name(impl->widget));
|
||||
impl->w_username = GTK_ENTRY(glade_xml_get_widget(impl->xml, "username"));
|
||||
g_signal_connect (impl->w_username, "changed", G_CALLBACK (entry_changed), impl);
|
||||
// gtk_widget_grab_focus (GTK_WIDGET(impl->w_username));
|
||||
gtk_widget_child_focus (GTK_WIDGET(impl->w_username),GTK_DIR_TAB_FORWARD);
|
||||
|
||||
children = gtk_container_get_children (GTK_CONTAINER (impl->widget));
|
||||
for (i = children; i != NULL; i = g_list_next (i)) {
|
||||
w = GTK_WIDGET (i->data);
|
||||
g_warning("Has child: %s",gtk_widget_get_name(w));
|
||||
}
|
||||
g_list_free (children);
|
||||
}
|
||||
|
||||
static void
|
||||
goto_next (GtkWidget *widget,gpointer data)
|
||||
{
|
||||
GnomeGenericAuthModuleImpl *impl = (GnomeGenericAuthModuleImpl *) data;
|
||||
g_warning("Goto next!");
|
||||
if (strcmp(gtk_widget_get_name(widget),"username")==0) {
|
||||
gtk_widget_grab_focus (GTK_WIDGET(impl->w_password));
|
||||
} else if (strcmp(gtk_widget_get_name(widget),"password")==0) {
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
impl_set_user (GnomeGenericAuthModule *self, const char *user)
|
||||
{
|
||||
GnomeGenericAuthModuleImpl *impl = (GnomeGenericAuthModuleImpl *) self->data;
|
||||
|
||||
gtk_entry_set_text(impl->w_username,user);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static const char *
|
||||
impl_get_user (GnomeGenericAuthModule *self)
|
||||
{
|
||||
GnomeGenericAuthModuleImpl *impl = (GnomeGenericAuthModuleImpl *) self->data;
|
||||
|
||||
return gtk_entry_get_text(impl->w_username);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
impl_set_secret (GnomeGenericAuthModule *self, const char *object, const char *secret)
|
||||
{
|
||||
GnomeGenericAuthModuleImpl *impl = (GnomeGenericAuthModuleImpl *) self->data;
|
||||
|
||||
if (strcmp(object,"password")==0) {
|
||||
gtk_entry_set_text(impl->w_password,secret);
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static GSList *
|
||||
impl_get_secrets (GnomeGenericAuthModule *self)
|
||||
{
|
||||
GnomeGenericAuthModuleImpl *impl = (GnomeGenericAuthModuleImpl *) self->data;
|
||||
GSList *secrets=NULL;
|
||||
|
||||
secrets =
|
||||
g_slist_append(secrets, g_strdup("password"));
|
||||
secrets =
|
||||
g_slist_append(secrets, g_strdup(gtk_entry_get_text(impl->w_password)));
|
||||
|
||||
return secrets;
|
||||
}
|
||||
|
||||
static const char *
|
||||
impl_get_display_name (GnomeGenericAuthModule *self)
|
||||
{
|
||||
return AUTH_TYPE_DISPLAY_NAME;
|
||||
}
|
||||
|
||||
|
||||
static const char *
|
||||
impl_get_auth_type (GnomeGenericAuthModule *self)
|
||||
{
|
||||
return AUTH_TYPE;
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
impl_get_widget (GnomeGenericAuthModule *self)
|
||||
{
|
||||
GnomeGenericAuthModuleImpl *impl = (GnomeGenericAuthModuleImpl *) self->data;
|
||||
|
||||
clear_widget (impl);
|
||||
|
||||
return impl->widget;
|
||||
}
|
||||
|
||||
static GnomeGenericAuthModule*
|
||||
impl_get_object (void)
|
||||
{
|
||||
char *glade_file;
|
||||
GnomeGenericAuthModuleImpl *impl;
|
||||
// GtkWidget *w;
|
||||
|
||||
g_warning("get widget");
|
||||
impl = g_new0 (GnomeGenericAuthModuleImpl, 1);
|
||||
glade_file = g_strdup_printf ("%s/%s", GLADEDIR, GLADE_FILE);
|
||||
impl->xml = glade_xml_new (glade_file, NULL, GETTEXT_PACKAGE);
|
||||
g_free( glade_file );
|
||||
if (impl->xml != NULL) {
|
||||
|
||||
impl->widget = glade_xml_get_widget(impl->xml, GLADE_WIDGET);
|
||||
|
||||
/* make the widget reusable */
|
||||
g_signal_connect (GTK_OBJECT (impl->widget), "delete-event",
|
||||
G_CALLBACK (gtk_widget_hide_on_delete), NULL);
|
||||
|
||||
impl->w_username = GTK_ENTRY(glade_xml_get_widget(impl->xml,"username"));
|
||||
impl->w_password = GTK_ENTRY(glade_xml_get_widget(impl->xml,"password"));
|
||||
g_signal_connect (impl->w_username, "activate", G_CALLBACK (goto_next), impl);
|
||||
g_signal_connect (impl->w_password, "activate", G_CALLBACK (goto_next), impl);
|
||||
|
||||
gtk_widget_show_all(impl->widget);
|
||||
clear_widget (impl);
|
||||
|
||||
impl->parent.get_user = impl_get_user;
|
||||
impl->parent.set_user = impl_set_user;
|
||||
impl->parent.get_secrets = impl_get_secrets;
|
||||
impl->parent.set_secret = impl_set_secret;
|
||||
impl->parent.get_display_name = impl_get_display_name;
|
||||
impl->parent.get_auth_type = impl_get_auth_type;
|
||||
impl->parent.get_widget = impl_get_widget;
|
||||
impl->parent.data = impl;
|
||||
|
||||
return &(impl->parent);
|
||||
} else {
|
||||
g_free (impl);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const char *
|
||||
get_auth_type (void)
|
||||
{
|
||||
return AUTH_TYPE;
|
||||
}
|
||||
|
||||
GnomeGenericAuthModule*
|
||||
gnome_generic_auth_module_factory (void)
|
||||
{
|
||||
return impl_get_object();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,947 +0,0 @@
|
|||
/* gnome-password-dialog.c - A use password prompting dialog widget.
|
||||
|
||||
Copyright (C) 2006
|
||||
|
||||
This is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU Library General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This software 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this package; see the file COPYING.LIB. If not,
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
|
||||
Authors: Antony J Mee <eemynotna@gmail.com>
|
||||
Based loosely on the gnome-two-password-dialog code by:
|
||||
Ramiro Estrugo <ramiro@eazel.com>
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
//#include "gnome-i18nP.h"
|
||||
#define GNOME_GENERIC_AUTH_MODULE_SUBJECT_TO_CHANGE
|
||||
#include "gnome-generic-auth-module.h"
|
||||
#include "gnome-generic-auth-dialog.h"
|
||||
//#include <gtk/gtkbox.h>
|
||||
//#include <gtk/gtkcheckbutton.h>
|
||||
//#include <gtk/gtkentry.h>
|
||||
//#include <gtk/gtkhbox.h>
|
||||
//#include <gtk/gtkimage.h>
|
||||
//#include <gtk/gtklabel.h>
|
||||
//#include <gtk/gtkmain.h>
|
||||
//#include <gtk/gtksignal.h>
|
||||
//#include <gtk/gtkstock.h>
|
||||
//#include <gtk/gtktable.h>
|
||||
//#include <gtk/gtkvbox.h>
|
||||
//#include <gtk/gtkradiobutton.h>
|
||||
//#include <gtk/gtkstock.h>
|
||||
#include <string.h>
|
||||
#include <glib.h>
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
#include <gtk/gtk.h>
|
||||
#define GNOME_GENERIC_AUTH_DIALOG_MODULES_DIR AUTH_MODULES_DIR
|
||||
|
||||
/* Layout constants */
|
||||
static const guint DIALOG_BORDER_WIDTH = 6;
|
||||
//static const guint CAPTION_TABLE_BORDER_WIDTH = 4;
|
||||
|
||||
struct GnomeGenericAuthDialogDetails
|
||||
{
|
||||
/* Attributes */
|
||||
GSList *allowed_auth_types;
|
||||
|
||||
/* Attributes */
|
||||
GSList *auth_modules;
|
||||
GnomeGenericAuthModule *current_module;
|
||||
|
||||
GtkWidget *remember_session_button;
|
||||
GtkWidget *remember_forever_button;
|
||||
|
||||
GtkWidget *current_widget;
|
||||
GtkWidget *widget_holder;
|
||||
GtkWidget *current_widget_old_parent;
|
||||
GtkComboBox *auth_type_combo;
|
||||
|
||||
|
||||
char *user;
|
||||
char *domain;
|
||||
char *server;
|
||||
char *protocol;
|
||||
guint32 port;
|
||||
|
||||
gboolean found_multiple_types;
|
||||
|
||||
/* TODO: */
|
||||
// gboolean can_remember_1;
|
||||
// char *remember_label_text2;
|
||||
// gboolean can_remember_2;
|
||||
// char *remember_label_text2;
|
||||
|
||||
};
|
||||
|
||||
|
||||
/* GnomeGenericAuthDialogClass methods */
|
||||
static void gnome_generic_auth_dialog_class_init (GnomeGenericAuthDialogClass *dialog);
|
||||
static void gnome_generic_auth_dialog_init (GnomeGenericAuthDialog *dialog);
|
||||
|
||||
/* GObjectClass methods */
|
||||
static void gnome_generic_auth_dialog_finalize (GObject *object);
|
||||
|
||||
|
||||
/* GtkDialog callbacks */
|
||||
//static void dialog_show_callback (GtkWidget *widget,
|
||||
// gpointer callback_data);
|
||||
static void dialog_close_callback (GtkWidget *widget,
|
||||
gpointer callback_data);
|
||||
|
||||
static gpointer parent_class;
|
||||
|
||||
GType
|
||||
gnome_generic_auth_dialog_get_type (void)
|
||||
{
|
||||
static GType type = 0;
|
||||
|
||||
if (!type) {
|
||||
static const GTypeInfo info = {
|
||||
sizeof (GnomeGenericAuthDialogClass),
|
||||
NULL, NULL,
|
||||
(GClassInitFunc) gnome_generic_auth_dialog_class_init,
|
||||
NULL, NULL,
|
||||
sizeof (GnomeGenericAuthDialog), 0,
|
||||
(GInstanceInitFunc) gnome_generic_auth_dialog_init,
|
||||
NULL
|
||||
};
|
||||
|
||||
type = g_type_register_static (gtk_dialog_get_type(),
|
||||
"GnomeGenericAuthDialog",
|
||||
&info, 0);
|
||||
|
||||
parent_class = g_type_class_ref (gtk_dialog_get_type());
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
static void save_to_keyring_as_needed(GnomeGenericAuthDialog *dialog)
|
||||
{
|
||||
switch (gnome_generic_auth_dialog_get_remember (dialog))
|
||||
{
|
||||
case GNOME_GENERIC_AUTH_DIALOG_REMEMBER_SESSION:
|
||||
// save_auth_info (connection_name, service_name, "session", auth_type, username, password);
|
||||
break;
|
||||
case GNOME_GENERIC_AUTH_DIALOG_REMEMBER_FOREVER:
|
||||
// save_auth_info (connection_name, service_name, NULL, auth_type, username, password);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void load_module (GnomeGenericAuthDialog *dialog, const char *path)
|
||||
{
|
||||
GModule *module;
|
||||
GnomeGenericAuthModule* (*module_factory) (void) = NULL;
|
||||
const char* (*module_get_auth_type) (void) = NULL;
|
||||
GnomeGenericAuthModule* impl;
|
||||
gboolean allowed = FALSE;
|
||||
const char *provided_auth_type;
|
||||
|
||||
module = g_module_open (path, G_MODULE_BIND_LAZY);
|
||||
if (module == NULL) {
|
||||
g_warning ("Cannot open module '%s'", path);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!g_module_symbol (module, "get_auth_type",
|
||||
(gpointer) &module_get_auth_type)) {
|
||||
g_warning ("Cannot locate function 'get_auth_type' in '%s': %s",
|
||||
path, g_module_error ());
|
||||
g_module_close (module);
|
||||
goto out;
|
||||
}
|
||||
|
||||
provided_auth_type = module_get_auth_type ();
|
||||
if (dialog->details->allowed_auth_types==NULL) {
|
||||
allowed=TRUE;
|
||||
} else {
|
||||
GSList *item;
|
||||
for (item=dialog->details->allowed_auth_types; item!=NULL; item=g_slist_next(item)) {
|
||||
if ((item->data!=NULL) && (strcmp(item->data,provided_auth_type)==0)) {
|
||||
allowed=TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!allowed) goto out;
|
||||
|
||||
if (!g_module_symbol (module, "gnome_generic_auth_module_factory",
|
||||
(gpointer) &module_factory)) {
|
||||
g_warning ("Cannot locate function 'gnome_generic_auth_module_factory' in '%s': %s",
|
||||
path, g_module_error ());
|
||||
g_module_close (module);
|
||||
goto out;
|
||||
}
|
||||
|
||||
impl = module_factory ();
|
||||
if (impl == NULL) {
|
||||
g_warning ("Function 'gnome_generic_auth_widget_factory' in '%s' returned NULL", path);
|
||||
g_module_close (module);
|
||||
goto out;
|
||||
}
|
||||
|
||||
// Inflict some state upon the module!
|
||||
impl->override_user=(dialog->details->user!=NULL);
|
||||
impl->override_domain=(dialog->details->user!=NULL);
|
||||
impl->override_server=(dialog->details->user!=NULL);
|
||||
impl->override_protocol=(dialog->details->user!=NULL);
|
||||
impl->override_port=(dialog->details->port!=0);
|
||||
|
||||
dialog->details->auth_modules = g_slist_append (dialog->details->auth_modules, impl);
|
||||
|
||||
out:
|
||||
;
|
||||
}
|
||||
|
||||
static void
|
||||
load_all_modules (GnomeGenericAuthDialog *dialog)
|
||||
{
|
||||
GDir *dir;
|
||||
|
||||
/* Load all VPN UI modules by inspecting .name files */
|
||||
if ((dir = g_dir_open (GNOME_GENERIC_AUTH_DIALOG_MODULES_DIR, 0, NULL)) != NULL) {
|
||||
const char *f;
|
||||
|
||||
while ((f = g_dir_read_name (dir)) != NULL) {
|
||||
char *so_path;
|
||||
// GKeyFile *keyfile;
|
||||
|
||||
if (!g_str_has_suffix (f, ".so"))
|
||||
continue;
|
||||
|
||||
so_path = g_strdup_printf ("%s/%s", GNOME_GENERIC_AUTH_DIALOG_MODULES_DIR, f);
|
||||
|
||||
load_module (dialog, so_path);
|
||||
g_free (so_path);
|
||||
}
|
||||
g_dir_close (dir);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gnome_generic_auth_dialog_class_init (GnomeGenericAuthDialogClass * klass)
|
||||
{
|
||||
G_OBJECT_CLASS (klass)->finalize = gnome_generic_auth_dialog_finalize;
|
||||
}
|
||||
|
||||
static void
|
||||
gnome_generic_auth_dialog_init (GnomeGenericAuthDialog *dialog)
|
||||
{
|
||||
dialog->details = g_new0 (GnomeGenericAuthDialogDetails, 1);
|
||||
dialog->details->auth_modules = NULL;
|
||||
dialog->details->allowed_auth_types = NULL;
|
||||
|
||||
// dialog->details->secondary_password_label = g_strdup ( _("_Secondary Password:") );
|
||||
}
|
||||
|
||||
/* GObjectClass methods */
|
||||
static void
|
||||
gnome_generic_auth_dialog_finalize (GObject *object)
|
||||
{
|
||||
GnomeGenericAuthDialog *dialog;
|
||||
|
||||
dialog = GNOME_GENERIC_AUTH_DIALOG (object);
|
||||
|
||||
// g_object_unref (dialog->details->username_entry);
|
||||
// g_object_unref (dialog->details->domain_entry);
|
||||
// g_object_unref (dialog->details->password_entry);
|
||||
// g_object_unref (dialog->details->password_entry_secondary);
|
||||
|
||||
if (dialog->details->allowed_auth_types != NULL) {
|
||||
g_slist_foreach(dialog->details->allowed_auth_types,(GFunc)g_free,NULL);
|
||||
g_slist_free(dialog->details->allowed_auth_types);
|
||||
}
|
||||
// g_slist_foreach(dialog->details->auth_modules,(GFunc)destroy_auth_method,NULL)
|
||||
if (dialog->details->auth_modules != NULL) {
|
||||
g_slist_foreach(dialog->details->auth_modules,(GFunc)g_free,NULL);
|
||||
g_slist_free(dialog->details->auth_modules);
|
||||
}
|
||||
|
||||
if (G_OBJECT_CLASS (parent_class)->finalize != NULL)
|
||||
(* G_OBJECT_CLASS (parent_class)->finalize) (object);
|
||||
}
|
||||
|
||||
static void auth_widget_reparent(GnomeGenericAuthDialog *dialog, GtkWidget *new_parent)
|
||||
{
|
||||
if (dialog->details->current_widget==NULL) {
|
||||
if (dialog->details->current_widget_old_parent!=NULL) {
|
||||
g_error("parent previously was not restored to widget");
|
||||
}
|
||||
return;
|
||||
}
|
||||
if ((new_parent==NULL) && (dialog->details->current_widget_old_parent==NULL)) {
|
||||
return;
|
||||
} else if (new_parent==NULL) {
|
||||
gtk_widget_reparent(dialog->details->current_widget,dialog->details->current_widget_old_parent);
|
||||
dialog->details->current_widget_old_parent=NULL;
|
||||
return;
|
||||
} else if (dialog->details->current_widget_old_parent==NULL) {
|
||||
dialog->details->current_widget_old_parent=gtk_widget_get_parent(dialog->details->current_widget);
|
||||
}
|
||||
|
||||
gtk_widget_reparent(dialog->details->current_widget,new_parent);
|
||||
}
|
||||
|
||||
static void auth_widget_get_current(GnomeGenericAuthDialog *dialog)
|
||||
{
|
||||
GSList *auth_modules;
|
||||
|
||||
if (dialog->details->current_widget!=NULL) {
|
||||
auth_widget_reparent(dialog,NULL);
|
||||
dialog->details->current_widget=NULL;
|
||||
}
|
||||
|
||||
auth_modules=dialog->details->auth_modules;
|
||||
|
||||
if (dialog->details->current_module != NULL) {
|
||||
dialog->details->current_widget = dialog->details->current_module->get_widget (dialog->details->current_module);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
dialog_close_callback (GtkWidget *widget, gpointer user_data)
|
||||
{
|
||||
GnomeGenericAuthDialog *dialog = (GnomeGenericAuthDialog *) user_data;
|
||||
|
||||
auth_widget_reparent(dialog,NULL);
|
||||
gtk_widget_hide (widget);
|
||||
}
|
||||
|
||||
static void
|
||||
auth_type_changed_callback (GtkWidget *widget, gpointer user_data)
|
||||
{
|
||||
GnomeGenericAuthDialog *dialog = (GnomeGenericAuthDialog *) user_data;
|
||||
GList *i;
|
||||
GList *children;
|
||||
GtkWidget *w;
|
||||
GSList *auth_modules;
|
||||
GtkWidget *widget_holder;
|
||||
// GtkWidget *widget_holder_parent;
|
||||
GtkComboBox *auth_type_combo;
|
||||
|
||||
auth_modules=dialog->details->auth_modules;
|
||||
widget_holder = dialog->details->widget_holder;
|
||||
auth_type_combo = dialog->details->auth_type_combo;
|
||||
|
||||
g_return_if_fail(widget_holder!=NULL);
|
||||
g_return_if_fail(GTK_IS_CONTAINER(widget_holder));
|
||||
|
||||
auth_widget_reparent(dialog,NULL);
|
||||
|
||||
/* show appropriate child */
|
||||
dialog->details->current_module = (GnomeGenericAuthModule *)
|
||||
g_slist_nth_data (auth_modules,
|
||||
gtk_combo_box_get_active (GTK_COMBO_BOX(auth_type_combo)));
|
||||
if (dialog->details->current_module == NULL) return;
|
||||
|
||||
auth_widget_get_current(dialog);
|
||||
auth_widget_reparent(dialog,dialog->details->widget_holder);
|
||||
|
||||
// dialog->details->current_module->set_validity_changed_callback (
|
||||
// dialog->details->current_module,
|
||||
// auth_widget_validity_changed, NULL);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gnome_generic_auth_dialog_set_secret (GnomeGenericAuthDialog *dialog, const char *object, const char *secret)
|
||||
{
|
||||
GnomeGenericAuthModule *module;
|
||||
|
||||
g_return_val_if_fail(dialog!=NULL,FALSE);
|
||||
g_return_val_if_fail(dialog->details!=NULL,FALSE);
|
||||
module = dialog->details->current_module;
|
||||
g_return_val_if_fail(module!=NULL,FALSE);
|
||||
g_return_val_if_fail(module->set_secret!=NULL,FALSE);
|
||||
|
||||
return module->set_secret(module,object,secret);
|
||||
}
|
||||
|
||||
const char *
|
||||
gnome_generic_auth_dialog_get_secret (GnomeGenericAuthDialog *dialog, const char *object)
|
||||
{
|
||||
GnomeGenericAuthModule *module;
|
||||
GSList *item;
|
||||
GSList *secrets;
|
||||
const char *secret=NULL;
|
||||
|
||||
g_return_val_if_fail(dialog!=NULL,NULL);
|
||||
g_return_val_if_fail(dialog->details!=NULL,NULL);
|
||||
module = dialog->details->current_module;
|
||||
g_return_val_if_fail(module!=NULL,NULL);
|
||||
g_return_val_if_fail(module->get_secrets!=NULL,NULL);
|
||||
|
||||
secrets=module->get_secrets(module);
|
||||
|
||||
for(item=secrets;
|
||||
(item!=NULL) && (g_slist_next(item)!=NULL) ;
|
||||
item=g_slist_next(g_slist_next(item))) {
|
||||
if (strcmp(object,(const char *)item->data)==0) {
|
||||
secret=(const char *)(g_slist_next(item)->data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
g_slist_free(secrets);
|
||||
return secret;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gnome_generic_auth_dialog_set_secrets (GnomeGenericAuthDialog *dialog, GSList *secrets)
|
||||
{
|
||||
GnomeGenericAuthModule *module;
|
||||
GSList *item;
|
||||
gboolean result = TRUE;
|
||||
const char *object;
|
||||
const char *secret;
|
||||
|
||||
g_return_val_if_fail(dialog!=NULL,FALSE);
|
||||
g_return_val_if_fail(dialog->details!=NULL,FALSE);
|
||||
module = dialog->details->current_module;
|
||||
g_return_val_if_fail(module!=NULL,FALSE);
|
||||
g_return_val_if_fail(module->set_secret!=NULL,FALSE);
|
||||
|
||||
for(item=secrets;
|
||||
(item!=NULL) && (g_slist_next(item)!=NULL) ;
|
||||
item=g_slist_next(g_slist_next(item))) {
|
||||
object=(const char *)(item->data);
|
||||
secret=(const char *)(g_slist_next(item)->data);
|
||||
result &= module->set_secret(module,object,secret);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
GSList *
|
||||
gnome_generic_auth_dialog_get_secrets (GnomeGenericAuthDialog *dialog)
|
||||
{
|
||||
GnomeGenericAuthModule *module;
|
||||
|
||||
g_return_val_if_fail(dialog!=NULL,NULL);
|
||||
g_return_val_if_fail(dialog->details!=NULL,NULL);
|
||||
module = dialog->details->current_module;
|
||||
g_return_val_if_fail(module!=NULL,NULL);
|
||||
g_return_val_if_fail(module->get_secrets!=NULL,NULL);
|
||||
|
||||
return module->get_secrets(module);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gnome_generic_auth_dialog_set_user (GnomeGenericAuthDialog *dialog, const char *user)
|
||||
{
|
||||
GnomeGenericAuthModule *module;
|
||||
|
||||
g_return_val_if_fail(dialog!=NULL,FALSE);
|
||||
g_return_val_if_fail(dialog->details!=NULL,FALSE);
|
||||
if (dialog->details->user!=NULL) return FALSE;
|
||||
|
||||
module = dialog->details->current_module;
|
||||
g_return_val_if_fail(module!=NULL,FALSE);
|
||||
g_return_val_if_fail(module->set_user!=NULL,FALSE);
|
||||
|
||||
return module->set_user(module,user);
|
||||
}
|
||||
|
||||
const char *
|
||||
gnome_generic_auth_dialog_get_user (GnomeGenericAuthDialog *dialog)
|
||||
{
|
||||
GnomeGenericAuthModule *module;
|
||||
|
||||
g_return_val_if_fail(dialog!=NULL,NULL);
|
||||
g_return_val_if_fail(dialog->details!=NULL,NULL);
|
||||
if (dialog->details->user!=NULL) return dialog->details->user;
|
||||
|
||||
module = dialog->details->current_module;
|
||||
g_return_val_if_fail(module!=NULL,NULL);
|
||||
g_return_val_if_fail(module->get_user!=NULL,NULL);
|
||||
|
||||
return module->get_user(module);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gnome_generic_auth_dialog_set_domain (GnomeGenericAuthDialog *dialog, const char *domain)
|
||||
{
|
||||
GnomeGenericAuthModule *module;
|
||||
|
||||
g_return_val_if_fail(dialog!=NULL,FALSE);
|
||||
g_return_val_if_fail(dialog->details!=NULL,FALSE);
|
||||
if (dialog->details->domain!=NULL) return FALSE;
|
||||
|
||||
module = dialog->details->current_module;
|
||||
g_return_val_if_fail(module!=NULL,FALSE);
|
||||
g_return_val_if_fail(module->set_domain!=NULL,FALSE);
|
||||
|
||||
return module->set_domain(module,domain);
|
||||
}
|
||||
|
||||
const char *
|
||||
gnome_generic_auth_dialog_get_domain (GnomeGenericAuthDialog *dialog)
|
||||
{
|
||||
GnomeGenericAuthModule *module;
|
||||
|
||||
g_return_val_if_fail(dialog!=NULL,NULL);
|
||||
g_return_val_if_fail(dialog->details!=NULL,NULL);
|
||||
if (dialog->details->domain!=NULL) return dialog->details->domain;
|
||||
|
||||
module = dialog->details->current_module;
|
||||
g_return_val_if_fail(module!=NULL,NULL);
|
||||
g_return_val_if_fail(module->get_domain!=NULL,NULL);
|
||||
return module->get_domain(module);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gnome_generic_auth_dialog_set_server (GnomeGenericAuthDialog *dialog, const char *server)
|
||||
{
|
||||
GnomeGenericAuthModule *module;
|
||||
|
||||
g_return_val_if_fail(dialog!=NULL,FALSE);
|
||||
g_return_val_if_fail(dialog->details!=NULL,FALSE);
|
||||
if (dialog->details->server!=NULL) return FALSE;
|
||||
|
||||
module = dialog->details->current_module;
|
||||
g_return_val_if_fail(module!=NULL,FALSE);
|
||||
g_return_val_if_fail(module->set_server!=NULL,FALSE);
|
||||
|
||||
return module->set_server(module,server);
|
||||
}
|
||||
|
||||
const char *
|
||||
gnome_generic_auth_dialog_get_server (GnomeGenericAuthDialog *dialog)
|
||||
{
|
||||
GnomeGenericAuthModule *module;
|
||||
|
||||
g_return_val_if_fail(dialog!=NULL,NULL);
|
||||
g_return_val_if_fail(dialog->details!=NULL,NULL);
|
||||
if (dialog->details->server!=NULL) return dialog->details->server;
|
||||
|
||||
module = dialog->details->current_module;
|
||||
g_return_val_if_fail(module!=NULL,NULL);
|
||||
g_return_val_if_fail(module->get_server!=NULL,NULL);
|
||||
return module->get_server(module);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gnome_generic_auth_dialog_set_port (GnomeGenericAuthDialog *dialog, guint32 port)
|
||||
{
|
||||
GnomeGenericAuthModule *module;
|
||||
|
||||
g_return_val_if_fail(dialog!=NULL,FALSE);
|
||||
g_return_val_if_fail(dialog->details!=NULL,FALSE);
|
||||
if (dialog->details->port!=0) return FALSE;
|
||||
|
||||
module = dialog->details->current_module;
|
||||
g_return_val_if_fail(module!=NULL,FALSE);
|
||||
g_return_val_if_fail(module->set_port!=NULL,FALSE);
|
||||
|
||||
return module->set_port(module,port);
|
||||
}
|
||||
|
||||
guint32
|
||||
gnome_generic_auth_dialog_get_port (GnomeGenericAuthDialog *dialog)
|
||||
{
|
||||
GnomeGenericAuthModule *module;
|
||||
|
||||
g_return_val_if_fail(dialog!=NULL,0);
|
||||
g_return_val_if_fail(dialog->details!=NULL,0);
|
||||
if (dialog->details->port!=0) return dialog->details->port;
|
||||
|
||||
module = dialog->details->current_module;
|
||||
g_return_val_if_fail(module!=NULL,0);
|
||||
g_return_val_if_fail(module->get_port!=NULL,0);
|
||||
return module->get_port(module);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gnome_generic_auth_dialog_set_protocol (GnomeGenericAuthDialog *dialog, const char *protocol)
|
||||
{
|
||||
GnomeGenericAuthModule *module;
|
||||
|
||||
g_return_val_if_fail(dialog!=NULL,FALSE);
|
||||
g_return_val_if_fail(dialog->details!=NULL,FALSE);
|
||||
if (dialog->details->protocol!=NULL) return FALSE;
|
||||
|
||||
module = dialog->details->current_module;
|
||||
g_return_val_if_fail(module!=NULL,FALSE);
|
||||
g_return_val_if_fail(module->set_protocol!=NULL,FALSE);
|
||||
|
||||
return module->set_protocol(module,protocol);
|
||||
}
|
||||
|
||||
const char *
|
||||
gnome_generic_auth_dialog_get_protocol (GnomeGenericAuthDialog *dialog)
|
||||
{
|
||||
GnomeGenericAuthModule *module;
|
||||
|
||||
g_return_val_if_fail(dialog!=NULL,NULL);
|
||||
g_return_val_if_fail(dialog->details!=NULL,NULL);
|
||||
if (dialog->details->protocol!=NULL) return dialog->details->protocol;
|
||||
|
||||
module = dialog->details->current_module;
|
||||
g_return_val_if_fail(module!=NULL,NULL);
|
||||
g_return_val_if_fail(module->get_protocol!=NULL,NULL);
|
||||
return module->get_protocol(module);
|
||||
}
|
||||
|
||||
const char *
|
||||
gnome_generic_auth_dialog_get_auth_type (GnomeGenericAuthDialog *dialog)
|
||||
{
|
||||
GnomeGenericAuthModule *module;
|
||||
|
||||
g_return_val_if_fail(dialog!=NULL,NULL);
|
||||
g_return_val_if_fail(dialog->details!=NULL,NULL);
|
||||
module = dialog->details->current_module;
|
||||
g_return_val_if_fail(dialog->details->current_module!=NULL,NULL);
|
||||
|
||||
return module->get_auth_type(module);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gnome_generic_auth_dialog_set_auth_type (GnomeGenericAuthDialog *dialog,
|
||||
const char *auth_type)
|
||||
{
|
||||
GSList *item;
|
||||
int i=0;
|
||||
|
||||
g_return_val_if_fail (GNOME_IS_GENERIC_AUTH_DIALOG (dialog),FALSE);
|
||||
g_return_val_if_fail (dialog->details->auth_type_combo != NULL,FALSE);
|
||||
|
||||
for (item = dialog->details->auth_modules; item != NULL; item = g_slist_next (item)) {
|
||||
GnomeGenericAuthModule *auth_module = (GnomeGenericAuthModule *)item->data;
|
||||
if (strcmp(auth_type,auth_module->get_auth_type(auth_module))==0) {
|
||||
gtk_combo_box_set_active (dialog->details->auth_type_combo, i);
|
||||
return TRUE;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
gboolean
|
||||
gnome_generic_auth_dialog_lookup_in_keyring (GnomeGenericAuthDialog *dialog) {
|
||||
GList *keyring_result;
|
||||
GList *item;
|
||||
const char *auth_type=NULL;
|
||||
GnomeKeyringNetworkPasswordData *data;
|
||||
const char *previous_auth_type=NULL;
|
||||
const char *first_auth_type=NULL;
|
||||
GnomeGenericAuthModule *module;
|
||||
|
||||
|
||||
g_return_val_if_fail (GNOME_IS_GENERIC_AUTH_DIALOG (dialog),FALSE);
|
||||
|
||||
if (dialog->details->current_module!=NULL)
|
||||
auth_type = gnome_generic_auth_dialog_get_auth_type(dialog);
|
||||
if (auth_type==NULL) dialog->details->found_multiple_types=FALSE;
|
||||
|
||||
if (gnome_keyring_find_network_password_sync (dialog->details->user,
|
||||
dialog->details->domain,
|
||||
dialog->details->server,
|
||||
NULL, /* object */
|
||||
dialog->details->protocol,
|
||||
auth_type,
|
||||
dialog->details->port,
|
||||
&keyring_result) != GNOME_KEYRING_RESULT_OK)
|
||||
return FALSE;
|
||||
// if (dialog->details->found_keys != NULL)
|
||||
// gnome_keyring_network_password_list_free (dialog->details->found_keys);
|
||||
// found_keys=NULL;
|
||||
|
||||
// Find the first auth_type we are allowed to use
|
||||
first_auth_type=NULL;
|
||||
for (item = keyring_result; item != NULL; item=g_list_next(item)) {
|
||||
data = (GnomeKeyringNetworkPasswordData *)item->data;
|
||||
if (gnome_generic_auth_dialog_set_auth_type(dialog,data->authtype)) {
|
||||
if (first_auth_type==NULL) first_auth_type=data->authtype;
|
||||
if ((previous_auth_type!=NULL) &&
|
||||
(strcmp(previous_auth_type,data->authtype)!=0)) {
|
||||
dialog->details->found_multiple_types=TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (first_auth_type==NULL) {
|
||||
gnome_keyring_network_password_list_free (keyring_result);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gnome_generic_auth_dialog_set_auth_type(dialog,first_auth_type);
|
||||
module = dialog->details->current_module;
|
||||
|
||||
for (item = keyring_result; item != NULL; item=g_list_next(item)) {
|
||||
data = (GnomeKeyringNetworkPasswordData *)item->data;
|
||||
if (strcmp(data->authtype,first_auth_type)==0) {
|
||||
if (data->user!=NULL) gnome_generic_auth_dialog_set_user(dialog, data->user);
|
||||
if (data->server!=NULL) gnome_generic_auth_dialog_set_server(dialog, data->server);
|
||||
if (data->domain!=NULL) gnome_generic_auth_dialog_set_domain(dialog, data->domain);
|
||||
if (data->protocol!=NULL) gnome_generic_auth_dialog_set_protocol(dialog, data->protocol);
|
||||
if (data->port!=0) gnome_generic_auth_dialog_set_port(dialog, data->port);
|
||||
if (data->object!=NULL || data->password!=NULL)
|
||||
gnome_generic_auth_dialog_set_secret(dialog, data->object, data->password);
|
||||
if (strcmp(data->keyring,"session")==0)
|
||||
gnome_generic_auth_dialog_set_remember (dialog, GNOME_GENERIC_AUTH_DIALOG_REMEMBER_SESSION);
|
||||
else
|
||||
gnome_generic_auth_dialog_set_remember (dialog, GNOME_GENERIC_AUTH_DIALOG_REMEMBER_FOREVER);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
gnome_keyring_network_password_list_free (keyring_result);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Public GnomeGenericAuthDialog methods */
|
||||
GtkWidget *
|
||||
gnome_generic_auth_dialog_new (const char *dialog_title,
|
||||
const char *message,
|
||||
const char *user,
|
||||
const char *domain,
|
||||
const char *server,
|
||||
const char *protocol,
|
||||
guint32 port,
|
||||
const char **allowed_types)
|
||||
{
|
||||
GnomeGenericAuthDialog *dialog;
|
||||
GtkWidget *widget_holder;
|
||||
GtkLabel *message_label;
|
||||
GtkLabel *auth_type_label;
|
||||
GtkWidget *auth_type_hbox;
|
||||
GtkComboBox *auth_type_combo_box;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *dialog_icon;
|
||||
GSList *allowed_auth_types=NULL;
|
||||
GSList *item;
|
||||
const char **types;
|
||||
|
||||
dialog = GNOME_GENERIC_AUTH_DIALOG (gtk_widget_new (gnome_generic_auth_dialog_get_type (), NULL));
|
||||
|
||||
dialog->details->user=NULL;
|
||||
dialog->details->server=NULL;
|
||||
dialog->details->protocol=NULL;
|
||||
dialog->details->domain=NULL;
|
||||
dialog->details->port=0;
|
||||
if (user!=NULL) dialog->details->user=g_strdup(user);
|
||||
if (server!=NULL) dialog->details->server=g_strdup(server);
|
||||
if (protocol!=NULL) dialog->details->protocol=g_strdup(protocol);
|
||||
if (domain!=NULL) dialog->details->domain=g_strdup(domain);
|
||||
if (port!=0) dialog->details->port=port;
|
||||
|
||||
if (allowed_types!=NULL) {
|
||||
for (types=allowed_types; *types !=NULL; *types++) {
|
||||
allowed_auth_types=g_slist_append(allowed_auth_types,g_strdup(*types));
|
||||
}
|
||||
dialog->details->allowed_auth_types = allowed_auth_types;
|
||||
}
|
||||
|
||||
load_all_modules(dialog);
|
||||
|
||||
if (dialog->details->auth_modules==NULL) {
|
||||
g_warning("gnome-generic-auth-dialog: Cannot find any authentication modules!");
|
||||
g_free(dialog);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gtk_window_set_title (GTK_WINDOW (dialog), dialog_title);
|
||||
gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
|
||||
gtk_dialog_add_buttons (GTK_DIALOG (dialog),
|
||||
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
||||
GTK_STOCK_OK, GTK_RESPONSE_OK,
|
||||
NULL);
|
||||
|
||||
/* Setup the dialog */
|
||||
gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
|
||||
|
||||
gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER);
|
||||
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
|
||||
|
||||
gtk_container_set_border_width (GTK_CONTAINER (dialog), DIALOG_BORDER_WIDTH);
|
||||
|
||||
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
|
||||
|
||||
// g_signal_connect (dialog, "show",
|
||||
// G_CALLBACK (dialog_show_callback), dialog);
|
||||
g_signal_connect (dialog, "close",
|
||||
G_CALLBACK (dialog_close_callback), dialog);
|
||||
|
||||
/* The table that holds the captions */
|
||||
// Get the current auth_widget.
|
||||
widget_holder = gtk_hbox_new(FALSE,0);
|
||||
g_object_ref (widget_holder);
|
||||
dialog->details->widget_holder = GTK_WIDGET(widget_holder);
|
||||
|
||||
/* fill in possibly choices in the druid when adding a connection */
|
||||
auth_type_hbox = gtk_hbox_new(FALSE,6);
|
||||
auth_type_label = GTK_LABEL (gtk_label_new (_("Authentication Type:")));
|
||||
gtk_label_set_justify (auth_type_label, GTK_JUSTIFY_LEFT);
|
||||
gtk_label_set_line_wrap (auth_type_label, TRUE);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (auth_type_hbox),
|
||||
GTK_WIDGET (auth_type_label),
|
||||
TRUE, /* expand */
|
||||
TRUE, /* fill */
|
||||
5); /* padding */
|
||||
auth_type_combo_box = GTK_COMBO_BOX(gtk_combo_box_new_text ());
|
||||
dialog->details->auth_type_combo = auth_type_combo_box;
|
||||
for (item = dialog->details->auth_modules; item != NULL; item = g_slist_next (item)) {
|
||||
GnomeGenericAuthModule *auth_module = (GnomeGenericAuthModule *)item->data;
|
||||
gtk_combo_box_append_text (GTK_COMBO_BOX(auth_type_combo_box), auth_module->get_display_name(auth_module));
|
||||
}
|
||||
g_signal_connect (auth_type_combo_box, "changed",
|
||||
G_CALLBACK (auth_type_changed_callback), (gpointer) dialog);
|
||||
gtk_box_pack_end (GTK_BOX (auth_type_hbox), GTK_WIDGET(auth_type_combo_box), TRUE, TRUE, 0);
|
||||
|
||||
//g_object_unref (widget_holder);
|
||||
|
||||
|
||||
/* Adds some eye-candy to the dialog */
|
||||
hbox = gtk_hbox_new (FALSE, 12);
|
||||
dialog_icon = gtk_image_new_from_stock (GTK_STOCK_DIALOG_AUTHENTICATION, GTK_ICON_SIZE_DIALOG);
|
||||
gtk_misc_set_alignment (GTK_MISC (dialog_icon), 0.5, 0.0);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), dialog_icon, FALSE, FALSE, 0);
|
||||
|
||||
gtk_box_set_spacing (GTK_BOX (GTK_DIALOG(dialog)->vbox), 12);
|
||||
gtk_container_set_border_width (GTK_CONTAINER(hbox), 6);
|
||||
gtk_box_set_spacing (GTK_BOX (hbox), 12);
|
||||
|
||||
/* Fills the vbox */
|
||||
vbox = gtk_vbox_new (FALSE, 0);
|
||||
|
||||
if (message) {
|
||||
message_label = GTK_LABEL (gtk_label_new (message));
|
||||
gtk_label_set_justify (message_label, GTK_JUSTIFY_LEFT);
|
||||
gtk_label_set_line_wrap (message_label, TRUE);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (vbox),
|
||||
GTK_WIDGET (message_label),
|
||||
TRUE, /* expand */
|
||||
TRUE, /* fill */
|
||||
5); /* padding */
|
||||
}
|
||||
|
||||
// THe following will be the widget from the plugin!
|
||||
gtk_box_pack_start (GTK_BOX (vbox), auth_type_hbox,
|
||||
TRUE, TRUE, 5);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), widget_holder,
|
||||
TRUE, TRUE, 5);
|
||||
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 5);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG(dialog)->vbox),
|
||||
hbox,
|
||||
TRUE, /* expand */
|
||||
TRUE, /* fill */
|
||||
0); /* padding */
|
||||
|
||||
gtk_widget_show (GTK_DIALOG (dialog)->vbox);
|
||||
|
||||
dialog->details->remember_session_button =
|
||||
gtk_check_button_new_with_mnemonic (_("_Remember for this session"));
|
||||
dialog->details->remember_forever_button =
|
||||
gtk_check_button_new_with_mnemonic (_("_Save in keyring"));
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (vbox), dialog->details->remember_session_button,
|
||||
TRUE, TRUE, 6);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), dialog->details->remember_forever_button,
|
||||
TRUE, TRUE, 0);
|
||||
|
||||
if (!gnome_generic_auth_dialog_lookup_in_keyring(dialog)) {
|
||||
g_warning("Lookup failed");
|
||||
gtk_combo_box_set_active (auth_type_combo_box, 0);
|
||||
}
|
||||
|
||||
return GTK_WIDGET (dialog);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gnome_generic_auth_dialog_run_and_block (GnomeGenericAuthDialog *dialog)
|
||||
{
|
||||
gint button_clicked;
|
||||
|
||||
g_return_val_if_fail (dialog != NULL, FALSE);
|
||||
g_return_val_if_fail (GNOME_IS_GENERIC_AUTH_DIALOG (dialog), FALSE);
|
||||
|
||||
button_clicked = gtk_dialog_run (GTK_DIALOG (dialog));
|
||||
|
||||
save_to_keyring_as_needed(dialog);
|
||||
|
||||
auth_widget_reparent(dialog,NULL);
|
||||
gtk_widget_hide (GTK_WIDGET (dialog));
|
||||
|
||||
return button_clicked == GTK_RESPONSE_OK;
|
||||
}
|
||||
|
||||
GnomeKeyringNetworkPasswordData *
|
||||
gnome_generic_auth_dialog_get_password_data (GnomeGenericAuthDialog *dialog)
|
||||
{
|
||||
g_return_val_if_fail (GNOME_IS_GENERIC_AUTH_DIALOG (dialog), NULL);
|
||||
|
||||
// return g_strdup (gtk_entry_get_text (GTK_ENTRY (dialog->details->username_entry)));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
gnome_generic_auth_dialog_set_show_remember (GnomeGenericAuthDialog *dialog,
|
||||
gboolean show_remember)
|
||||
{
|
||||
if (show_remember) {
|
||||
gtk_widget_show (dialog->details->remember_session_button);
|
||||
gtk_widget_show (dialog->details->remember_forever_button);
|
||||
} else {
|
||||
gtk_widget_hide (dialog->details->remember_session_button);
|
||||
gtk_widget_hide (dialog->details->remember_forever_button);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gnome_generic_auth_dialog_set_remember (GnomeGenericAuthDialog *dialog,
|
||||
GnomeGenericAuthDialogRemember remember)
|
||||
{
|
||||
gboolean session, forever;
|
||||
|
||||
session = FALSE;
|
||||
forever = FALSE;
|
||||
if (remember == GNOME_GENERIC_AUTH_DIALOG_REMEMBER_SESSION) {
|
||||
session = TRUE;
|
||||
} else if (remember == GNOME_GENERIC_AUTH_DIALOG_REMEMBER_FOREVER){
|
||||
forever = TRUE;
|
||||
}
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->details->remember_session_button),
|
||||
session);
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->details->remember_forever_button),
|
||||
forever);
|
||||
}
|
||||
|
||||
GnomeGenericAuthDialogRemember
|
||||
gnome_generic_auth_dialog_get_remember (GnomeGenericAuthDialog *dialog)
|
||||
{
|
||||
gboolean session, forever;
|
||||
|
||||
session = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->details->remember_session_button));
|
||||
forever = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->details->remember_forever_button));
|
||||
if (forever) {
|
||||
return GNOME_GENERIC_AUTH_DIALOG_REMEMBER_FOREVER;
|
||||
} else if (session) {
|
||||
return GNOME_GENERIC_AUTH_DIALOG_REMEMBER_SESSION;
|
||||
}
|
||||
return GNOME_GENERIC_AUTH_DIALOG_REMEMBER_NOTHING;
|
||||
}
|
||||
|
||||
|
|
@ -1,105 +0,0 @@
|
|||
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
|
||||
|
||||
/* gnome-generic-auth-dialog.h - A use a dialog widget with a combo
|
||||
* selection box to choose a sub-widget
|
||||
* which in turn then provides appropriate
|
||||
* widgets for a particular type of
|
||||
* authentication
|
||||
Based of gnome-two-password-dialog.[ch]
|
||||
from the Gnome Library.
|
||||
|
||||
This is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU Library General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This software 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with the Gnome Library; see the file COPYING.LIB. If not,
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
|
||||
Authors: Antony J Mee <eemynotna at gmail dot com>
|
||||
*/
|
||||
|
||||
#ifndef GNOME_GENERIC_AUTH_DIALOG_H
|
||||
#define GNOME_GENERIC_AUTH_DIALOG_H
|
||||
|
||||
#include <gtk/gtkdialog.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GNOME_TYPE_GENERIC_AUTH_DIALOG (gnome_generic_auth_dialog_get_type ())
|
||||
#define GNOME_GENERIC_AUTH_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNOME_TYPE_GENERIC_AUTH_DIALOG, GnomeGenericAuthDialog))
|
||||
#define GNOME_GENERIC_AUTH_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNOME_TYPE_GENERIC_AUTH_DIALOG, GnomeGenericAuthDialogClass))
|
||||
#define GNOME_IS_GENERIC_AUTH_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNOME_TYPE_GENERIC_AUTH_DIALOG))
|
||||
#define GNOME_IS_GENERIC_AUTH_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNOME_TYPE_GENERIC_AUTH_DIALOG))
|
||||
|
||||
typedef struct GnomeGenericAuthDialog GnomeGenericAuthDialog;
|
||||
typedef struct GnomeGenericAuthDialogClass GnomeGenericAuthDialogClass;
|
||||
typedef struct GnomeGenericAuthDialogDetails GnomeGenericAuthDialogDetails;
|
||||
|
||||
struct GnomeGenericAuthDialog
|
||||
{
|
||||
GtkDialog gtk_dialog;
|
||||
|
||||
GnomeGenericAuthDialogDetails *details;
|
||||
};
|
||||
|
||||
struct GnomeGenericAuthDialogClass
|
||||
{
|
||||
GtkDialogClass parent_class;
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
GNOME_GENERIC_AUTH_DIALOG_REMEMBER_NOTHING,
|
||||
GNOME_GENERIC_AUTH_DIALOG_REMEMBER_SESSION,
|
||||
GNOME_GENERIC_AUTH_DIALOG_REMEMBER_FOREVER
|
||||
} GnomeGenericAuthDialogRemember;
|
||||
|
||||
|
||||
GType gnome_generic_auth_dialog_get_type (void);
|
||||
GtkWidget *gnome_generic_auth_dialog_new (const char *dialog_title,
|
||||
const char *message,
|
||||
const char *user,
|
||||
const char *domain,
|
||||
const char *server,
|
||||
const char *protocol,
|
||||
guint32 port,
|
||||
const char **allowed_types);
|
||||
|
||||
gboolean gnome_generic_auth_dialog_run_and_block (GnomeGenericAuthDialog *dialog);
|
||||
|
||||
/* Attribute mutators */
|
||||
gboolean gnome_generic_auth_dialog_set_auth_type (GnomeGenericAuthDialog *dialog, const char *auth_type);
|
||||
gboolean gnome_generic_auth_dialog_set_user (GnomeGenericAuthDialog *dialog, const char *user);
|
||||
gboolean gnome_generic_auth_dialog_set_server (GnomeGenericAuthDialog *dialog, const char *server);
|
||||
gboolean gnome_generic_auth_dialog_set_domain (GnomeGenericAuthDialog *dialog, const char *domain);
|
||||
gboolean gnome_generic_auth_dialog_set_protocol (GnomeGenericAuthDialog *dialog, const char *protocol);
|
||||
gboolean gnome_generic_auth_dialog_set_port (GnomeGenericAuthDialog *dialog, guint32 port);
|
||||
|
||||
//void gnome_generic_auth_dialog_set_allowed_auth_types (GnomeGenericAuthDialog *dialog,
|
||||
// GSList *allowed_auth_types);
|
||||
|
||||
void gnome_generic_auth_dialog_set_show_remember (GnomeGenericAuthDialog *dialog,
|
||||
gboolean show_remember);
|
||||
void gnome_generic_auth_dialog_set_remember (GnomeGenericAuthDialog *dialog,
|
||||
GnomeGenericAuthDialogRemember remember);
|
||||
GnomeGenericAuthDialogRemember gnome_generic_auth_dialog_get_remember (GnomeGenericAuthDialog *dialog);
|
||||
|
||||
/* Attribute accessors */
|
||||
const char *gnome_generic_auth_dialog_get_auth_type (GnomeGenericAuthDialog *dialog);
|
||||
const char *gnome_generic_auth_dialog_get_user (GnomeGenericAuthDialog *dialog);
|
||||
const char *gnome_generic_auth_dialog_get_domain (GnomeGenericAuthDialog *dialog);
|
||||
const char *gnome_generic_auth_dialog_get_server (GnomeGenericAuthDialog *dialog);
|
||||
const char *gnome_generic_auth_dialog_get_protocol (GnomeGenericAuthDialog *dialog);
|
||||
guint32 gnome_generic_auth_dialog_get_port (GnomeGenericAuthDialog *dialog);
|
||||
GSList *gnome_generic_auth_dialog_get_secrets (GnomeGenericAuthDialog *dialog);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* GNOME_GENERIC_AUTH_DIALOG_H */
|
||||
|
|
@ -1,106 +0,0 @@
|
|||
/***************************************************************************
|
||||
* CVSID: $Id$
|
||||
*
|
||||
* gnome-generic-auth-widget.h : Public interface for generic auth widgets
|
||||
*
|
||||
* Copyright (C) 2006 Antony J Mee, <eemynotna at gmail dot com>
|
||||
*
|
||||
* ===
|
||||
* NOTE NOTE NOTE: All source for nm-vpn-properties is licensed to you
|
||||
* under your choice of the Academic Free License version 2.0, or the
|
||||
* GNU General Public License version 2.
|
||||
* ===
|
||||
*
|
||||
* Licensed under the Academic Free License version 2.0
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef GNOME_GENERIC_AUTH_MODULE_H
|
||||
#define GNOME_GENERIC_AUTH_MODULE_H
|
||||
|
||||
#ifndef GNOME_GENERIC_AUTH_MODULE_SUBJECT_TO_CHANGE
|
||||
#error "Please define GNOME_GENERIC_AUTH_MODULE_SUBJECT_TO_CHANGE to acknowledge your understanding that NetworkManager hasn't reached 1.0 and is subject to protocol and API churn. See the README for a full explanation."
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#include <gnome-keyring.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
struct _GnomeGenericAuthModule;
|
||||
typedef struct _GnomeGenericAuthModule GnomeGenericAuthModule;
|
||||
|
||||
typedef void (*GnomeGenericAuthModuleValidityCallback) (GnomeGenericAuthModule *self,
|
||||
gboolean is_valid,
|
||||
gpointer user_data);
|
||||
|
||||
struct _GnomeGenericAuthModule {
|
||||
const char *(*get_display_name) (GnomeGenericAuthModule *self);
|
||||
const char *(*get_auth_type) (GnomeGenericAuthModule *self);
|
||||
const char *(*get_domain) (GnomeGenericAuthModule *self);
|
||||
const char *(*get_server) (GnomeGenericAuthModule *self);
|
||||
const char *(*get_protocol) (GnomeGenericAuthModule *self);
|
||||
const char *(*get_user) (GnomeGenericAuthModule *self);
|
||||
GSList *(*get_secrets) (GnomeGenericAuthModule *self);
|
||||
guint32 (*get_port) (GnomeGenericAuthModule *self);
|
||||
|
||||
gboolean (*set_domain) (GnomeGenericAuthModule *self, const char *domain);
|
||||
gboolean (*set_user) (GnomeGenericAuthModule *self, const char *user);
|
||||
gboolean (*set_server) (GnomeGenericAuthModule *self, const char *server);
|
||||
gboolean (*set_protocol) (GnomeGenericAuthModule *self, const char *protocol);
|
||||
gboolean (*set_port) (GnomeGenericAuthModule *self, guint32 port);
|
||||
gboolean (*set_secret) (GnomeGenericAuthModule *self, const char *object, const char *secret);
|
||||
|
||||
GtkWidget *(*get_widget) (GnomeGenericAuthModule *self);
|
||||
|
||||
gboolean override_user;
|
||||
gboolean override_domain;
|
||||
gboolean override_server;
|
||||
gboolean override_protocol;
|
||||
gboolean override_port;
|
||||
|
||||
|
||||
// void (*set_validity_changed_callback) (GnomeGenericAuthModule *self,
|
||||
// GnomeGenericAuthModuleValidityCallback cb,
|
||||
// gpointer user_data);
|
||||
|
||||
// gboolean (*is_valid) (GnomeGenericAuthModule *self);
|
||||
|
||||
/*
|
||||
* get_confirmation_details:
|
||||
* retval is allocated and must be freed
|
||||
*/
|
||||
// void (*get_confirmation_details)(GnomeGenericAuthModule *self, gchar **retval);
|
||||
|
||||
// char *(*get_connection_name) (GnomeGenericAuthModule *self);
|
||||
|
||||
// GSList *(*get_properties) (GnomeGenericAuthModule *self);
|
||||
|
||||
// GSList *(*get_routes) (GnomeGenericAuthModule *self);
|
||||
|
||||
// gboolean (*can_export) (GnomeGenericAuthModule *self);
|
||||
|
||||
// gboolean (*import_file) (GnomeGenericAuthModule *self, const char *path);
|
||||
|
||||
// gboolean (*export) (GnomeGenericAuthModule *self, GSList *properties, GSList *routes, const char *connection_name);
|
||||
|
||||
gpointer data;
|
||||
};
|
||||
|
||||
#endif /* GNOME_GENERIC_AUTH_MODULE_H */
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 3.1 KiB |
|
|
@ -1,169 +0,0 @@
|
|||
/* NetworkManager Wireless Applet -- Display wireless access points and allow user control
|
||||
*
|
||||
* Dan Williams <dcbw@redhat.com>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* (C) Copyright 2004 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <glib/gi18n.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <libgnomeui/libgnomeui.h>
|
||||
#include <gnome-keyring.h>
|
||||
|
||||
#include "gnome-generic-auth-dialog.h"
|
||||
|
||||
#define SERVICE_NAME "org.freedesktop.NetworkManager.ppp_starter"
|
||||
|
||||
static GSList *
|
||||
get_passwords (const char *connection_name, const char *service_name, gboolean retry)
|
||||
{
|
||||
GSList *result;
|
||||
char *prompt;
|
||||
GnomeGenericAuthDialog *dialog;
|
||||
// GnomeGenericAuthDialogRemember remember;
|
||||
|
||||
result = NULL;
|
||||
|
||||
g_return_val_if_fail (connection_name != NULL, NULL);
|
||||
|
||||
prompt = g_strdup_printf (_("You need to authenticate to access '%s'."), connection_name);
|
||||
dialog = GNOME_GENERIC_AUTH_DIALOG(
|
||||
gnome_generic_auth_dialog_new (
|
||||
_("Authenticate Connection"),
|
||||
prompt,
|
||||
NULL, /* User */
|
||||
NULL, /* Domain */
|
||||
connection_name, /* Server - fixed */
|
||||
service_name, /* Protocol - Fixed */
|
||||
0, /* Port - can vary */
|
||||
NULL /* Allowed auth types */
|
||||
));
|
||||
if (dialog==NULL) {
|
||||
return NULL;
|
||||
}
|
||||
g_free (prompt);
|
||||
|
||||
gnome_generic_auth_dialog_set_show_remember (dialog, TRUE);
|
||||
//gnome_generic_auth_dialog_set_remember (dialog, GNOME_GENERIC_AUTH_DIALOG_REMEMBER_NOTHING);
|
||||
|
||||
gtk_widget_show (GTK_WIDGET(dialog));
|
||||
|
||||
if (gnome_generic_auth_dialog_run_and_block (dialog))
|
||||
{
|
||||
GSList *secrets;
|
||||
GSList *item;
|
||||
const char *username;
|
||||
// char *password;
|
||||
const char *auth_type;
|
||||
|
||||
username = gnome_generic_auth_dialog_get_user (dialog);
|
||||
auth_type = gnome_generic_auth_dialog_get_auth_type (dialog);
|
||||
secrets = gnome_generic_auth_dialog_get_secrets (dialog);
|
||||
|
||||
result = g_slist_append (result, g_strdup(auth_type));
|
||||
result = g_slist_append (result, g_strdup(username));
|
||||
|
||||
for (item=secrets; item!=NULL; item=g_slist_next(item))
|
||||
{
|
||||
g_free(item->data);
|
||||
item = g_slist_next(item);
|
||||
result = g_slist_append (result, item->data);
|
||||
}
|
||||
g_slist_free(secrets);
|
||||
|
||||
}
|
||||
|
||||
gtk_widget_destroy (GTK_WIDGET(dialog));
|
||||
return result;
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
GSList *i;
|
||||
GSList *passwords;
|
||||
static gboolean retry = FALSE;
|
||||
static gchar *connection_name = NULL;
|
||||
static gchar *auth_types = NULL;
|
||||
static gchar *service_name = NULL;
|
||||
GError *error = NULL;
|
||||
GOptionContext *context;
|
||||
GnomeProgram *program;
|
||||
GOptionEntry entries[] =
|
||||
{
|
||||
{ "reprompt", 'r', 0, G_OPTION_ARG_NONE, &retry, "Reprompt for passwords", NULL},
|
||||
{ "name", 'n', 0, G_OPTION_ARG_STRING, &connection_name, "Name of connection", NULL},
|
||||
{ "service", 's', 0, G_OPTION_ARG_STRING, &service_name, "Service type", NULL},
|
||||
{ "authtype", 'a', 0, G_OPTION_ARG_STRING_ARRAY, &auth_types, "Authentication Types", NULL},
|
||||
{ NULL }
|
||||
};
|
||||
char buf[1];
|
||||
|
||||
bindtextdomain (GETTEXT_PACKAGE, NULL);
|
||||
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
|
||||
textdomain (GETTEXT_PACKAGE);
|
||||
|
||||
passwords = NULL;
|
||||
|
||||
context = g_option_context_new ("- ppp auth dialog");
|
||||
g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
|
||||
|
||||
program = gnome_program_init ("nm-ppp-auth-dialog", VERSION,
|
||||
LIBGNOMEUI_MODULE,
|
||||
argc, argv,
|
||||
GNOME_PARAM_GOPTION_CONTEXT, context,
|
||||
GNOME_PARAM_NONE);
|
||||
|
||||
if (connection_name == NULL || service_name == NULL) {
|
||||
fprintf (stderr, "Have to supply both name and service\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (strcmp (service_name, SERVICE_NAME) != 0) {
|
||||
fprintf (stderr, "This dialog only works with the '%s' service\n", SERVICE_NAME);
|
||||
goto out;
|
||||
}
|
||||
|
||||
passwords = get_passwords (connection_name, service_name, retry);
|
||||
if (passwords == NULL)
|
||||
goto out;
|
||||
|
||||
/* dump the passwords to stdout */
|
||||
for (i = passwords; i != NULL; i = g_slist_next (i)) {
|
||||
char *password = (char *) i->data;
|
||||
printf ("%s\n", password);
|
||||
}
|
||||
printf ("\n\n");
|
||||
/* for good measure, flush stdout since Kansas is going Bye-Bye */
|
||||
fflush (stdout);
|
||||
|
||||
g_slist_foreach (passwords, (GFunc)g_free, NULL);
|
||||
g_slist_free (passwords);
|
||||
|
||||
/* wait for data on stdin */
|
||||
fread (buf, sizeof (char), sizeof (buf), stdin);
|
||||
|
||||
out:
|
||||
g_object_unref (program);
|
||||
|
||||
return passwords != NULL ? 0 : 1;
|
||||
}
|
||||
|
|
@ -1,190 +0,0 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <glib/gi18n-lib.h>
|
||||
#include <string.h>
|
||||
#include <glade/glade.h>
|
||||
|
||||
#define GNOME_GENERIC_AUTH_MODULE_SUBJECT_TO_CHANGE
|
||||
#include "gnome-generic-auth-module.h"
|
||||
|
||||
/* Stuff to be provided by the specific instance */
|
||||
typedef struct _GnomeGenericAuthModuleImpl GnomeGenericAuthModuleImpl;
|
||||
|
||||
struct _GnomeGenericAuthModuleImpl {
|
||||
GnomeGenericAuthModule parent;
|
||||
|
||||
GladeXML *xml;
|
||||
|
||||
GtkWidget *widget;
|
||||
|
||||
GtkEntry *w_remotename;
|
||||
GtkEntry *w_username;
|
||||
GtkEntry *w_password;
|
||||
|
||||
};
|
||||
|
||||
#define GLADE_FILE "nm-ppp-auth.glade"
|
||||
#define GLADE_WIDGET "auth-mschapv2-widget"
|
||||
|
||||
#define AUTH_TYPE "MSCHAPV2"
|
||||
#define AUTH_TYPE_DISPLAY_NAME "MS CHAP V2"
|
||||
|
||||
|
||||
static void
|
||||
clear_widget (GnomeGenericAuthModuleImpl *impl)
|
||||
{
|
||||
gtk_entry_set_text(impl->w_username,"");
|
||||
gtk_entry_set_text(impl->w_password,"");
|
||||
gtk_widget_grab_focus (GTK_WIDGET(impl->w_username));
|
||||
}
|
||||
|
||||
static void
|
||||
goto_next (GtkWidget *widget,gpointer data)
|
||||
{
|
||||
GnomeGenericAuthModuleImpl *impl = (GnomeGenericAuthModuleImpl *) data;
|
||||
g_warning("Goto next!");
|
||||
if (strcmp(gtk_widget_get_name(widget),"remotename")==0) {
|
||||
gtk_widget_grab_focus (GTK_WIDGET(impl->w_username));
|
||||
} else if (strcmp(gtk_widget_get_name(widget),"username")==0) {
|
||||
gtk_widget_grab_focus (GTK_WIDGET(impl->w_password));
|
||||
} else if (strcmp(gtk_widget_get_name(widget),"password")==0) {
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
impl_set_user (GnomeGenericAuthModule *self, const char *user)
|
||||
{
|
||||
GnomeGenericAuthModuleImpl *impl = (GnomeGenericAuthModuleImpl *) self->data;
|
||||
|
||||
gtk_entry_set_text(impl->w_username,user);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static const char *
|
||||
impl_get_user (GnomeGenericAuthModule *self)
|
||||
{
|
||||
GnomeGenericAuthModuleImpl *impl = (GnomeGenericAuthModuleImpl *) self->data;
|
||||
|
||||
return gtk_entry_get_text(impl->w_username);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
impl_set_secret (GnomeGenericAuthModule *self, const char *object, const char *secret)
|
||||
{
|
||||
GnomeGenericAuthModuleImpl *impl = (GnomeGenericAuthModuleImpl *) self->data;
|
||||
|
||||
g_warning("Setting secret: %s=%s",object,secret);
|
||||
if (strcmp(object,"remotename")==0) {
|
||||
gtk_entry_set_text(impl->w_remotename,secret);
|
||||
} else if (strcmp(object,"password")==0) {
|
||||
gtk_entry_set_text(impl->w_password,secret);
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static GSList *
|
||||
impl_get_secrets (GnomeGenericAuthModule *self)
|
||||
{
|
||||
GnomeGenericAuthModuleImpl *impl = (GnomeGenericAuthModuleImpl *) self->data;
|
||||
GSList *secrets=NULL;
|
||||
|
||||
secrets =
|
||||
g_slist_append(secrets, g_strdup("password"));
|
||||
secrets =
|
||||
g_slist_append(secrets, g_strdup(gtk_entry_get_text(impl->w_password)));
|
||||
secrets =
|
||||
g_slist_append(secrets, g_strdup("remotename"));
|
||||
secrets =
|
||||
g_slist_append(secrets, g_strdup(gtk_entry_get_text(impl->w_remotename)));
|
||||
|
||||
return secrets;
|
||||
}
|
||||
|
||||
static const char *
|
||||
impl_get_display_name (GnomeGenericAuthModule *self)
|
||||
{
|
||||
return AUTH_TYPE_DISPLAY_NAME;
|
||||
}
|
||||
|
||||
|
||||
static const char *
|
||||
impl_get_auth_type (GnomeGenericAuthModule *self)
|
||||
{
|
||||
return AUTH_TYPE;
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
impl_get_widget (GnomeGenericAuthModule *self)
|
||||
{
|
||||
GnomeGenericAuthModuleImpl *impl = (GnomeGenericAuthModuleImpl *) self->data;
|
||||
|
||||
clear_widget (impl);
|
||||
|
||||
return impl->widget;
|
||||
}
|
||||
|
||||
static GnomeGenericAuthModule*
|
||||
impl_get_object (void)
|
||||
{
|
||||
char *glade_file;
|
||||
GnomeGenericAuthModuleImpl *impl;
|
||||
// GtkWidget *w;
|
||||
|
||||
impl = g_new0 (GnomeGenericAuthModuleImpl, 1);
|
||||
glade_file = g_strdup_printf ("%s/%s", GLADEDIR, GLADE_FILE);
|
||||
impl->xml = glade_xml_new (glade_file, NULL, GETTEXT_PACKAGE);
|
||||
g_free( glade_file );
|
||||
if (impl->xml != NULL) {
|
||||
|
||||
impl->widget = glade_xml_get_widget(impl->xml, GLADE_WIDGET);
|
||||
|
||||
/* make the widget reusable */
|
||||
g_signal_connect (GTK_OBJECT (impl->widget), "delete-event",
|
||||
G_CALLBACK (gtk_widget_hide_on_delete), NULL);
|
||||
|
||||
impl->w_remotename = GTK_ENTRY(glade_xml_get_widget(impl->xml,"remotename"));
|
||||
impl->w_username = GTK_ENTRY(glade_xml_get_widget(impl->xml,"username"));
|
||||
impl->w_password = GTK_ENTRY(glade_xml_get_widget(impl->xml,"password"));
|
||||
|
||||
g_signal_connect (impl->w_remotename, "activate", G_CALLBACK (goto_next), impl);
|
||||
g_signal_connect (impl->w_username, "activate", G_CALLBACK (goto_next), impl);
|
||||
g_signal_connect (impl->w_password, "activate", G_CALLBACK (goto_next), impl);
|
||||
|
||||
gtk_widget_show_all(impl->widget);
|
||||
clear_widget (impl);
|
||||
|
||||
impl->parent.get_user = impl_get_user;
|
||||
impl->parent.set_user = impl_set_user;
|
||||
impl->parent.get_secrets = impl_get_secrets;
|
||||
impl->parent.set_secret = impl_set_secret;
|
||||
impl->parent.get_display_name = impl_get_display_name;
|
||||
impl->parent.get_auth_type = impl_get_auth_type;
|
||||
impl->parent.get_widget = impl_get_widget;
|
||||
impl->parent.data = impl;
|
||||
|
||||
return &(impl->parent);
|
||||
} else {
|
||||
g_free (impl);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const char *
|
||||
get_auth_type (void)
|
||||
{
|
||||
return AUTH_TYPE;
|
||||
}
|
||||
|
||||
GnomeGenericAuthModule*
|
||||
gnome_generic_auth_module_factory (void)
|
||||
{
|
||||
return impl_get_object();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,594 +0,0 @@
|
|||
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
|
||||
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
|
||||
|
||||
<glade-interface>
|
||||
<requires lib="gnome"/>
|
||||
|
||||
<widget class="GtkDialog" id="nm-ppp-auth">
|
||||
<property name="border_width">5</property>
|
||||
<property name="title" translatable="yes">Authentication Required</property>
|
||||
<property name="type">GTK_WINDOW_TOPLEVEL</property>
|
||||
<property name="window_position">GTK_WIN_POS_CENTER_ALWAYS</property>
|
||||
<property name="modal">True</property>
|
||||
<property name="resizable">False</property>
|
||||
<property name="destroy_with_parent">False</property>
|
||||
<property name="decorated">True</property>
|
||||
<property name="skip_taskbar_hint">False</property>
|
||||
<property name="skip_pager_hint">False</property>
|
||||
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
|
||||
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
|
||||
<property name="has_separator">False</property>
|
||||
|
||||
<child internal-child="vbox">
|
||||
<widget class="GtkVBox" id="dialog-vbox1">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">0</property>
|
||||
|
||||
<child internal-child="action_area">
|
||||
<widget class="GtkHButtonBox" id="dialog-action_area1">
|
||||
<property name="visible">True</property>
|
||||
<property name="layout_style">GTK_BUTTONBOX_END</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkButton" id="cancelbutton1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_default">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label">gtk-cancel</property>
|
||||
<property name="use_stock">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<property name="response_id">-6</property>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkButton" id="okbutton1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_default">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label">gtk-ok</property>
|
||||
<property name="use_stock">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<property name="response_id">-5</property>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="pack_type">GTK_PACK_END</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkHBox" id="hbox1">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">12</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkImage" id="image1">
|
||||
<property name="visible">True</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkVBox" id="main_vbox">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">12</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label1">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes"><span weight="bold" size="larger">Authentication Information</span>
|
||||
|
||||
The connection '%s' may need some form of authentication.
|
||||
|
||||
Please select an appropriate authentication type and provide the necessary credentials below:
|
||||
</property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">True</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">True</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkHBox" id="hbox2">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label2">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">_Authentication Type:</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
<property name="mnemonic_widget">auth-type</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkComboBox" id="auth-type">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkAlignment" id="alignment1">
|
||||
<property name="visible">True</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xscale">1</property>
|
||||
<property name="yscale">1</property>
|
||||
<property name="top_padding">0</property>
|
||||
<property name="bottom_padding">0</property>
|
||||
<property name="left_padding">80</property>
|
||||
<property name="right_padding">21</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkVBox" id="vbox3">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkCheckButton" id="remember_for_session">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label" translatable="yes">_Remember for this session</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<property name="active">False</property>
|
||||
<property name="inconsistent">False</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkCheckButton" id="save_in_keyring">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label" translatable="yes">_Save in keyring</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<property name="active">False</property>
|
||||
<property name="inconsistent">False</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
<widget class="GtkWindow" id="auth-none-window">
|
||||
<property name="border_width">2</property>
|
||||
<property name="width_request">82</property>
|
||||
<property name="height_request">116</property>
|
||||
<property name="title">auth-none-window</property>
|
||||
<property name="type">GTK_WINDOW_TOPLEVEL</property>
|
||||
<property name="window_position">GTK_WIN_POS_NONE</property>
|
||||
<property name="modal">False</property>
|
||||
<property name="resizable">False</property>
|
||||
<property name="destroy_with_parent">False</property>
|
||||
<property name="decorated">True</property>
|
||||
<property name="skip_taskbar_hint">False</property>
|
||||
<property name="skip_pager_hint">False</property>
|
||||
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
|
||||
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="auth-cone-widget">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes"></property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
<widget class="GtkWindow" id="auth-chap-window">
|
||||
<property name="border_width">12</property>
|
||||
<property name="title">auth-chap-window</property>
|
||||
<property name="type">GTK_WINDOW_TOPLEVEL</property>
|
||||
<property name="window_position">GTK_WIN_POS_NONE</property>
|
||||
<property name="modal">False</property>
|
||||
<property name="resizable">False</property>
|
||||
<property name="destroy_with_parent">False</property>
|
||||
<property name="decorated">True</property>
|
||||
<property name="skip_taskbar_hint">False</property>
|
||||
<property name="skip_pager_hint">False</property>
|
||||
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
|
||||
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkVBox" id="auth-chap-widget">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkTable" id="table1">
|
||||
<property name="visible">True</property>
|
||||
<property name="n_rows">2</property>
|
||||
<property name="n_columns">2</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="row_spacing">12</property>
|
||||
<property name="column_spacing">12</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label4">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">_Username:</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
<property name="mnemonic_widget">username</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="right_attach">1</property>
|
||||
<property name="top_attach">0</property>
|
||||
<property name="bottom_attach">1</property>
|
||||
<property name="x_options">fill</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label5">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">_Password:</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
<property name="mnemonic_widget">password</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="right_attach">1</property>
|
||||
<property name="top_attach">1</property>
|
||||
<property name="bottom_attach">2</property>
|
||||
<property name="x_options">fill</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkEntry" id="username">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="editable">True</property>
|
||||
<property name="visibility">True</property>
|
||||
<property name="max_length">0</property>
|
||||
<property name="text" translatable="yes"></property>
|
||||
<property name="has_frame">True</property>
|
||||
<property name="invisible_char">*</property>
|
||||
<property name="activates_default">False</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="right_attach">2</property>
|
||||
<property name="top_attach">0</property>
|
||||
<property name="bottom_attach">1</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkEntry" id="password">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="editable">True</property>
|
||||
<property name="visibility">False</property>
|
||||
<property name="max_length">0</property>
|
||||
<property name="text" translatable="yes"></property>
|
||||
<property name="has_frame">True</property>
|
||||
<property name="invisible_char">*</property>
|
||||
<property name="activates_default">False</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="right_attach">2</property>
|
||||
<property name="top_attach">1</property>
|
||||
<property name="bottom_attach">2</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
<widget class="GtkWindow" id="auth-mschapv2-window">
|
||||
<property name="title">auth-mschapv2-window</property>
|
||||
<property name="type">GTK_WINDOW_TOPLEVEL</property>
|
||||
<property name="window_position">GTK_WIN_POS_NONE</property>
|
||||
<property name="modal">False</property>
|
||||
<property name="resizable">False</property>
|
||||
<property name="destroy_with_parent">False</property>
|
||||
<property name="decorated">True</property>
|
||||
<property name="skip_taskbar_hint">False</property>
|
||||
<property name="skip_pager_hint">False</property>
|
||||
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
|
||||
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkVBox" id="auth-mschapv2-widget">
|
||||
<property name="border_width">6</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkTable" id="table2">
|
||||
<property name="visible">True</property>
|
||||
<property name="n_rows">3</property>
|
||||
<property name="n_columns">2</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="row_spacing">12</property>
|
||||
<property name="column_spacing">12</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label7">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">_Password:</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
<property name="mnemonic_widget">password</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="right_attach">1</property>
|
||||
<property name="top_attach">2</property>
|
||||
<property name="bottom_attach">3</property>
|
||||
<property name="x_options">fill</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkEntry" id="password">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="editable">True</property>
|
||||
<property name="visibility">False</property>
|
||||
<property name="max_length">0</property>
|
||||
<property name="text" translatable="yes"></property>
|
||||
<property name="has_frame">True</property>
|
||||
<property name="invisible_char">*</property>
|
||||
<property name="activates_default">False</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="right_attach">2</property>
|
||||
<property name="top_attach">2</property>
|
||||
<property name="bottom_attach">3</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkEntry" id="username">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="editable">True</property>
|
||||
<property name="visibility">True</property>
|
||||
<property name="max_length">0</property>
|
||||
<property name="text" translatable="yes"></property>
|
||||
<property name="has_frame">True</property>
|
||||
<property name="invisible_char">*</property>
|
||||
<property name="activates_default">False</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="right_attach">2</property>
|
||||
<property name="top_attach">1</property>
|
||||
<property name="bottom_attach">2</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label6">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">_Username:</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
<property name="mnemonic_widget">username</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="right_attach">1</property>
|
||||
<property name="top_attach">1</property>
|
||||
<property name="bottom_attach">2</property>
|
||||
<property name="x_options">fill</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label8">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">_Remote name:</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
<property name="mnemonic_widget">remotename</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="right_attach">1</property>
|
||||
<property name="top_attach">0</property>
|
||||
<property name="bottom_attach">1</property>
|
||||
<property name="x_options">fill</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkEntry" id="remotename">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="editable">True</property>
|
||||
<property name="visibility">True</property>
|
||||
<property name="max_length">0</property>
|
||||
<property name="text" translatable="yes"></property>
|
||||
<property name="has_frame">True</property>
|
||||
<property name="invisible_char">*</property>
|
||||
<property name="activates_default">False</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="right_attach">2</property>
|
||||
<property name="top_attach">0</property>
|
||||
<property name="bottom_attach">1</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
</glade-interface>
|
||||
|
|
@ -1,8 +1,9 @@
|
|||
INCLUDES = -I${top_srcdir} -I${top_srcdir}/utils
|
||||
INCLUDES = -I${top_srcdir}
|
||||
|
||||
libexec_PROGRAMS = nm-ppp-auth-dialog
|
||||
libexec_PROGRAMS = nm-pptp-auth-dialog
|
||||
|
||||
nm_ppp_auth_dialog_CPPFLAGS = \
|
||||
nm_pptp_auth_dialog_CPPFLAGS = \
|
||||
$(NM_UTILS_CFLAGS) \
|
||||
$(GTHREAD_CFLAGS) \
|
||||
$(GTK_CFLAGS) \
|
||||
$(LIBGNOMEUI_CFLAGS) \
|
||||
|
|
@ -18,13 +19,13 @@ nm_ppp_auth_dialog_CPPFLAGS = \
|
|||
-DVERSION=\"$(VERSION)\" \
|
||||
$(NULL)
|
||||
|
||||
nm_ppp_auth_dialog_SOURCES = \
|
||||
nm_pptp_auth_dialog_SOURCES = \
|
||||
main.c \
|
||||
gnome-two-password-dialog.c \
|
||||
gnome-two-password-dialog.h \
|
||||
$(NULL)
|
||||
|
||||
nm_ppp_auth_dialog_LDADD = \
|
||||
nm_pptp_auth_dialog_LDADD = \
|
||||
$(GTK_LIBS) \
|
||||
$(LIBGNOMEUI_LIBS) \
|
||||
$(GNOMEKEYRING_LIBS) \
|
||||
|
|
|
|||
|
|
@ -159,7 +159,6 @@ gnome_two_password_dialog_finalize (GObject *object)
|
|||
|
||||
g_free (password_dialog->details->remember_label_text);
|
||||
g_free (password_dialog->details->secondary_password_label);
|
||||
|
||||
g_free (password_dialog->details);
|
||||
|
||||
if (G_OBJECT_CLASS (parent_class)->finalize != NULL)
|
||||
|
|
@ -463,16 +462,15 @@ gnome_two_password_dialog_new (const char *dialog_title,
|
|||
gtk_widget_show_all (GTK_DIALOG (password_dialog)->vbox);
|
||||
|
||||
password_dialog->details->remember_session_button =
|
||||
gtk_check_button_new_with_mnemonic (_("_Remember password for this session"));
|
||||
gtk_check_button_new_with_mnemonic (_("_Remember passwords for this session"));
|
||||
password_dialog->details->remember_forever_button =
|
||||
gtk_check_button_new_with_mnemonic (_("_Save password in keyring"));
|
||||
gtk_check_button_new_with_mnemonic (_("_Save passwords in keyring"));
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (vbox), password_dialog->details->remember_session_button,
|
||||
FALSE, FALSE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), password_dialog->details->remember_forever_button,
|
||||
FALSE, FALSE, 0);
|
||||
|
||||
|
||||
|
||||
gnome_two_password_dialog_set_username (password_dialog, username);
|
||||
gnome_two_password_dialog_set_password (password_dialog, password);
|
||||
gnome_two_password_dialog_set_readonly_domain (password_dialog, readonly_username);
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* (C) Copyright 2004 Red Hat, Inc.
|
||||
* (C) Copyright 2008 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
|
|
@ -29,87 +29,118 @@
|
|||
#include <libgnomeui/libgnomeui.h>
|
||||
#include <gnome-keyring.h>
|
||||
|
||||
#include <nm-setting-vpn.h>
|
||||
#include <nm-setting-vpn-properties.h>
|
||||
|
||||
#include "../src/nm-pptp-service.h"
|
||||
#include "gnome-two-password-dialog.h"
|
||||
|
||||
#define VPN_SERVICE "org.freedesktop.NetworkManager.ppp_starter"
|
||||
#define KEYRING_CID_TAG "connection-id"
|
||||
#define KEYRING_SN_TAG "setting-name"
|
||||
#define KEYRING_SK_TAG "setting-key"
|
||||
|
||||
static char *
|
||||
find_one_password (const char *vpn_id,
|
||||
const char *vpn_name,
|
||||
const char *vpn_service,
|
||||
const char *secret_name,
|
||||
gboolean *is_session)
|
||||
{
|
||||
GList *found_list = NULL;
|
||||
GnomeKeyringResult ret;
|
||||
GnomeKeyringFound *found;
|
||||
char *secret;
|
||||
|
||||
ret = gnome_keyring_find_itemsv_sync (GNOME_KEYRING_ITEM_GENERIC_SECRET,
|
||||
&found_list,
|
||||
KEYRING_CID_TAG,
|
||||
GNOME_KEYRING_ATTRIBUTE_TYPE_STRING,
|
||||
vpn_id,
|
||||
KEYRING_SN_TAG,
|
||||
GNOME_KEYRING_ATTRIBUTE_TYPE_STRING,
|
||||
NM_SETTING_VPN_PROPERTIES_SETTING_NAME,
|
||||
KEYRING_SK_TAG,
|
||||
GNOME_KEYRING_ATTRIBUTE_TYPE_STRING,
|
||||
secret_name,
|
||||
NULL);
|
||||
if ((ret != GNOME_KEYRING_RESULT_OK) || (g_list_length (found_list) == 0))
|
||||
return NULL;
|
||||
|
||||
found = (GnomeKeyringFound *) found_list->data;
|
||||
|
||||
if (strcmp (found->keyring, "session") == 0)
|
||||
*is_session = TRUE;
|
||||
else
|
||||
*is_session = FALSE;
|
||||
|
||||
secret = found->secret ? g_strdup (found->secret) : NULL;
|
||||
gnome_keyring_found_list_free (found_list);
|
||||
|
||||
return secret;
|
||||
}
|
||||
|
||||
static GSList *
|
||||
lookup_pass (const char *vpn_name, const char *vpn_service, char *auth_type, gboolean *is_session)
|
||||
lookup_pass (const char *vpn_id, const char *vpn_name, const char *vpn_service, gboolean *is_session)
|
||||
{
|
||||
GSList *passwords;
|
||||
GList *keyring_result;
|
||||
GSList *passwords = NULL;
|
||||
char *password;
|
||||
|
||||
passwords = NULL;
|
||||
|
||||
if (gnome_keyring_find_network_password_sync (NULL, /* user */
|
||||
NULL, /* domain */
|
||||
vpn_name, /* server */
|
||||
NULL, /* object */
|
||||
vpn_service, /* protocol */
|
||||
auth_type, /* authtype */
|
||||
0, /* port */
|
||||
&keyring_result) != GNOME_KEYRING_RESULT_OK)
|
||||
return FALSE;
|
||||
|
||||
if (keyring_result != NULL && g_list_length (keyring_result) == 1) {
|
||||
GnomeKeyringNetworkPasswordData *data =
|
||||
(GnomeKeyringNetworkPasswordData *)keyring_result->data;
|
||||
char *username = NULL;
|
||||
char *password = NULL;
|
||||
char *auth_type = NULL;
|
||||
|
||||
username = data->user;
|
||||
password = data->password;
|
||||
auth_type = data->authtype;
|
||||
|
||||
if (password != NULL && username != NULL && auth_type != NULL) {
|
||||
// Statically set the authentication type for now.
|
||||
passwords = g_slist_append (passwords, g_strdup(auth_type));
|
||||
passwords = g_slist_append (passwords, g_strdup (username));
|
||||
passwords = g_slist_append (passwords, g_strdup (password));
|
||||
if (strcmp (data->keyring, "session") == 0)
|
||||
*is_session = TRUE;
|
||||
else
|
||||
*is_session = FALSE;
|
||||
}
|
||||
|
||||
gnome_keyring_network_password_list_free (keyring_result);
|
||||
}
|
||||
password = find_one_password (vpn_id, vpn_name, vpn_service, "password", is_session);
|
||||
if (password)
|
||||
passwords = g_slist_append (passwords, password);
|
||||
|
||||
return passwords;
|
||||
}
|
||||
|
||||
static void save_vpn_password (const char *vpn_name, const char *vpn_service, const char *keyring,
|
||||
const char *auth_type, const char *username, const char *password)
|
||||
static void
|
||||
save_vpn_password (const char *vpn_id,
|
||||
const char *vpn_name,
|
||||
const char *vpn_service,
|
||||
const char *keyring,
|
||||
const char *secret_name,
|
||||
const char *secret)
|
||||
{
|
||||
guint32 item_id;
|
||||
GnomeKeyringResult keyring_result;
|
||||
char *display_name;
|
||||
GnomeKeyringResult ret;
|
||||
GnomeKeyringAttributeList *attrs = NULL;
|
||||
guint32 id = 0;
|
||||
|
||||
keyring_result = gnome_keyring_set_network_password_sync (keyring,
|
||||
username,
|
||||
NULL,
|
||||
vpn_name,
|
||||
NULL,
|
||||
vpn_service,
|
||||
auth_type,
|
||||
0,
|
||||
password,
|
||||
&item_id);
|
||||
if (keyring_result != GNOME_KEYRING_RESULT_OK)
|
||||
{
|
||||
g_warning ("Couldn't store authentication information in keyring, code %d", (int) keyring_result);
|
||||
}
|
||||
display_name = g_strdup_printf ("VPN %s secret for %s/%s/" NM_SETTING_VPN_PROPERTIES_SETTING_NAME,
|
||||
secret_name,
|
||||
vpn_name,
|
||||
vpn_service);
|
||||
|
||||
attrs = gnome_keyring_attribute_list_new ();
|
||||
gnome_keyring_attribute_list_append_string (attrs,
|
||||
KEYRING_CID_TAG,
|
||||
vpn_id);
|
||||
gnome_keyring_attribute_list_append_string (attrs,
|
||||
KEYRING_SN_TAG,
|
||||
NM_SETTING_VPN_PROPERTIES_SETTING_NAME);
|
||||
gnome_keyring_attribute_list_append_string (attrs,
|
||||
KEYRING_SK_TAG,
|
||||
secret_name);
|
||||
|
||||
ret = gnome_keyring_item_create_sync (keyring,
|
||||
GNOME_KEYRING_ITEM_GENERIC_SECRET,
|
||||
display_name,
|
||||
attrs,
|
||||
secret,
|
||||
TRUE,
|
||||
&id);
|
||||
gnome_keyring_attribute_list_free (attrs);
|
||||
g_free (display_name);
|
||||
}
|
||||
|
||||
static GSList *
|
||||
get_passwords (const char *vpn_name, const char *vpn_service, gboolean retry)
|
||||
get_passwords (const char *vpn_id,
|
||||
const char *vpn_name,
|
||||
const char *vpn_service,
|
||||
gboolean retry)
|
||||
{
|
||||
GSList *result;
|
||||
char *prompt;
|
||||
GtkWidget *dialog;
|
||||
char *keyring_authtype;
|
||||
char *keyring_username;
|
||||
GtkWidget *dialog;
|
||||
char *keyring_password;
|
||||
gboolean keyring_is_session;
|
||||
GSList *keyring_result;
|
||||
|
|
@ -117,36 +148,34 @@ get_passwords (const char *vpn_name, const char *vpn_service, gboolean retry)
|
|||
|
||||
result = NULL;
|
||||
keyring_password = NULL;
|
||||
keyring_username = NULL;
|
||||
keyring_result = NULL;
|
||||
|
||||
g_return_val_if_fail (vpn_id != NULL, NULL);
|
||||
g_return_val_if_fail (vpn_name != NULL, NULL);
|
||||
|
||||
/* Use the system user name, since the VPN might have a different user name */
|
||||
if (!retry) {
|
||||
if ((result = lookup_pass (vpn_name, vpn_service, "CHAP", &keyring_is_session)) != NULL) {
|
||||
if ((result = lookup_pass (vpn_id, vpn_name, vpn_service, &keyring_is_session)) != NULL) {
|
||||
return result;
|
||||
}
|
||||
} else {
|
||||
if ((keyring_result = lookup_pass (vpn_name, vpn_service, "CHAP", &keyring_is_session)) != NULL) {
|
||||
keyring_authtype = g_strdup ((char *) keyring_result->data);
|
||||
keyring_username = g_strdup ((char *) (g_slist_next (keyring_result))->data);
|
||||
keyring_password = g_strdup ((char *) (g_slist_next (g_slist_next (keyring_result)))->data);
|
||||
}
|
||||
if ((keyring_result = lookup_pass (vpn_id, vpn_name, vpn_service, &keyring_is_session)) != NULL)
|
||||
keyring_password = g_strdup ((char *) (g_slist_next (keyring_result))->data);
|
||||
|
||||
g_slist_foreach (keyring_result, (GFunc)g_free, NULL);
|
||||
g_slist_free (keyring_result);
|
||||
}
|
||||
|
||||
prompt = g_strdup_printf (_("You need to authenticate to access '%s'."), vpn_name);
|
||||
dialog = gnome_two_password_dialog_new (_("Authenticate Connection"), prompt, NULL, NULL, FALSE);
|
||||
prompt = g_strdup_printf (_("You need to authenticate to access the Virtual Private Network '%s'."), vpn_name);
|
||||
dialog = gnome_two_password_dialog_new (_("Authenticate VPN"), prompt, NULL, NULL, FALSE);
|
||||
g_free (prompt);
|
||||
|
||||
gnome_two_password_dialog_set_show_username (GNOME_TWO_PASSWORD_DIALOG (dialog), FALSE);
|
||||
gnome_two_password_dialog_set_show_userpass_buttons (GNOME_TWO_PASSWORD_DIALOG (dialog), FALSE);
|
||||
gnome_two_password_dialog_set_show_username (GNOME_TWO_PASSWORD_DIALOG (dialog), TRUE);
|
||||
gnome_two_password_dialog_set_show_domain (GNOME_TWO_PASSWORD_DIALOG (dialog), FALSE);
|
||||
gnome_two_password_dialog_set_show_remember (GNOME_TWO_PASSWORD_DIALOG (dialog), TRUE);
|
||||
gnome_two_password_dialog_set_show_password_secondary (GNOME_TWO_PASSWORD_DIALOG (dialog), FALSE);
|
||||
//gnome_two_password_dialog_set_password_secondary_label (GNOME_TWO_PASSWORD_DIALOG (dialog), _("_Group Password:"));
|
||||
|
||||
/* use the same keyring storage options as from the items we put in the entry boxes */
|
||||
remember = GNOME_TWO_PASSWORD_DIALOG_REMEMBER_NOTHING;
|
||||
if (keyring_result != NULL) {
|
||||
|
|
@ -158,9 +187,6 @@ get_passwords (const char *vpn_name, const char *vpn_service, gboolean retry)
|
|||
gnome_two_password_dialog_set_remember (GNOME_TWO_PASSWORD_DIALOG (dialog), remember);
|
||||
|
||||
/* if retrying, put in the passwords from the keyring */
|
||||
if (keyring_username != NULL) {
|
||||
gnome_two_password_dialog_set_username (GNOME_TWO_PASSWORD_DIALOG (dialog), keyring_username);
|
||||
}
|
||||
if (keyring_password != NULL) {
|
||||
gnome_two_password_dialog_set_password (GNOME_TWO_PASSWORD_DIALOG (dialog), keyring_password);
|
||||
}
|
||||
|
|
@ -169,25 +195,18 @@ get_passwords (const char *vpn_name, const char *vpn_service, gboolean retry)
|
|||
|
||||
if (gnome_two_password_dialog_run_and_block (GNOME_TWO_PASSWORD_DIALOG (dialog)))
|
||||
{
|
||||
char *username;
|
||||
char *password;
|
||||
char *auth_type;
|
||||
|
||||
username = gnome_two_password_dialog_get_username (GNOME_TWO_PASSWORD_DIALOG (dialog));
|
||||
password = gnome_two_password_dialog_get_password (GNOME_TWO_PASSWORD_DIALOG (dialog));
|
||||
// Statically set the authentication type for now.
|
||||
auth_type = g_strdup("CHAP");
|
||||
result = g_slist_append (result, auth_type);
|
||||
result = g_slist_append (result, g_strdup(username));
|
||||
result = g_slist_append (result, g_strdup(password));
|
||||
result = g_slist_append (result, password);
|
||||
|
||||
switch (gnome_two_password_dialog_get_remember (GNOME_TWO_PASSWORD_DIALOG (dialog)))
|
||||
{
|
||||
case GNOME_TWO_PASSWORD_DIALOG_REMEMBER_SESSION:
|
||||
save_vpn_password (vpn_name, vpn_service, "session", auth_type, username, password);
|
||||
save_vpn_password (vpn_id, vpn_name, vpn_service, "session", "password", password);
|
||||
break;
|
||||
case GNOME_TWO_PASSWORD_DIALOG_REMEMBER_FOREVER:
|
||||
save_vpn_password (vpn_name, vpn_service, NULL, auth_type, username, password);
|
||||
save_vpn_password (vpn_id, vpn_name, vpn_service, NULL, "password", password);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
@ -195,10 +214,8 @@ get_passwords (const char *vpn_name, const char *vpn_service, gboolean retry)
|
|||
|
||||
}
|
||||
|
||||
if (keyring_username!=NULL) g_free (keyring_username);
|
||||
if (keyring_password!=NULL) g_free (keyring_password);
|
||||
g_free (keyring_password);
|
||||
|
||||
gtk_widget_hide (dialog);
|
||||
gtk_widget_destroy (dialog);
|
||||
|
||||
return result;
|
||||
|
|
@ -207,22 +224,23 @@ get_passwords (const char *vpn_name, const char *vpn_service, gboolean retry)
|
|||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
GSList *i;
|
||||
GSList *passwords;
|
||||
static gboolean retry = FALSE;
|
||||
static gchar *vpn_name = NULL;
|
||||
static gchar *vpn_id = NULL;
|
||||
static gchar *vpn_service = NULL;
|
||||
GError *error = NULL;
|
||||
char buf[1];
|
||||
int ret;
|
||||
GOptionContext *context;
|
||||
GnomeProgram *program;
|
||||
GOptionEntry entries[] =
|
||||
{
|
||||
{ "reprompt", 'r', 0, G_OPTION_ARG_NONE, &retry, "Reprompt for passwords", NULL},
|
||||
{ "id", 'i', 0, G_OPTION_ARG_STRING, &vpn_id, "ID of VPN connection", NULL},
|
||||
{ "name", 'n', 0, G_OPTION_ARG_STRING, &vpn_name, "Name of VPN connection", NULL},
|
||||
{ "service", 's', 0, G_OPTION_ARG_STRING, &vpn_service, "VPN service type", NULL},
|
||||
{ NULL }
|
||||
};
|
||||
char buf[1];
|
||||
|
||||
bindtextdomain (GETTEXT_PACKAGE, NULL);
|
||||
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
|
||||
|
|
@ -230,35 +248,35 @@ main (int argc, char *argv[])
|
|||
|
||||
passwords = NULL;
|
||||
|
||||
context = g_option_context_new ("- ppp auth dialog");
|
||||
context = g_option_context_new ("- pptp auth dialog");
|
||||
g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
|
||||
|
||||
program = gnome_program_init ("nm-ppp-auth-dialog", VERSION,
|
||||
|
||||
program = gnome_program_init ("nm-pptp-auth-dialog", VERSION,
|
||||
LIBGNOMEUI_MODULE,
|
||||
argc, argv,
|
||||
GNOME_PARAM_GOPTION_CONTEXT, context,
|
||||
GNOME_PARAM_NONE);
|
||||
|
||||
if (vpn_name == NULL || vpn_service == NULL) {
|
||||
fprintf (stderr, "Have to supply both name and service\n");
|
||||
|
||||
if (vpn_id == NULL || vpn_name == NULL || vpn_service == NULL) {
|
||||
fprintf (stderr, "Have to supply ID, name, and service\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (strcmp (vpn_service, VPN_SERVICE) != 0) {
|
||||
fprintf (stderr, "This dialog only works with the '%s' service\n", VPN_SERVICE);
|
||||
if (strcmp (vpn_service, NM_DBUS_SERVICE_PPTP) != 0) {
|
||||
fprintf (stderr, "This dialog only works with the '%s' service\n", NM_DBUS_SERVICE_PPTP);
|
||||
goto out;
|
||||
}
|
||||
|
||||
passwords = get_passwords (vpn_name, vpn_service, retry);
|
||||
passwords = get_passwords (vpn_id, vpn_name, vpn_service, retry);
|
||||
if (passwords == NULL)
|
||||
goto out;
|
||||
|
||||
/* dump the passwords to stdout */
|
||||
for (i = passwords; i != NULL; i = g_slist_next (i)) {
|
||||
char *password = (char *) i->data;
|
||||
printf ("%s\n", password);
|
||||
}
|
||||
|
||||
printf ("%s\n%s\n", NM_PPTP_KEY_PASSWORD, (char *) passwords->data);
|
||||
printf ("\n\n");
|
||||
|
||||
/* for good measure, flush stdout since Kansas is going Bye-Bye */
|
||||
fflush (stdout);
|
||||
|
||||
|
|
@ -266,7 +284,7 @@ main (int argc, char *argv[])
|
|||
g_slist_free (passwords);
|
||||
|
||||
/* wait for data on stdin */
|
||||
fread (buf, sizeof (char), sizeof (buf), stdin);
|
||||
ret = fread (buf, sizeof (char), sizeof (buf), stdin);
|
||||
|
||||
out:
|
||||
g_object_unref (program);
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
AC_PREREQ(2.59)
|
||||
|
||||
AC_INIT(NetworkManager-ppp_vpn, 0.7.0-beta, eemynotna@gmail.com, NetworkManager-ppp_vpn)
|
||||
|
||||
AC_INIT(NetworkManager-pptp, 0.7.0, dcbw@redhat.com, NetworkManager-pptp)
|
||||
AC_CONFIG_AUX_DIR(.)
|
||||
AM_INIT_AUTOMAKE([1.9 foreign no-dist-gzip dist-bzip2 subdir-objects])
|
||||
AM_MAINTAINER_MODE
|
||||
|
||||
AC_CONFIG_HEADERS([config.h])
|
||||
AC_CONFIG_HEADER(config.h)
|
||||
|
||||
dnl
|
||||
dnl Require programs
|
||||
|
|
@ -14,66 +15,23 @@ AM_PROG_CC_C_O
|
|||
AC_PROG_INSTALL
|
||||
AC_PROG_LIBTOOL
|
||||
|
||||
|
||||
dnl
|
||||
dnl Required headers
|
||||
dnl
|
||||
AC_HEADER_STDC
|
||||
AC_CHECK_HEADERS(fcntl.h paths.h sys/ioctl.h sys/time.h syslog.h unistd.h)
|
||||
|
||||
AC_ARG_WITH(pppd, AC_HELP_STRING([--with-pppd=DISTRO], [Specify path to pppd.h (and patchlevel.h)]))
|
||||
AC_ARG_WITH(pppd-version, AC_HELP_STRING([--with-pppd-version=DISTRO], [Version of pppd.h]))
|
||||
if test "z$with_pppd" != "z"; then
|
||||
AC_MSG_CHECKING([for $with_pppd/pppd.h])
|
||||
if test -f "$with_pppd/pppd.h"; then
|
||||
PPPD_CFLAGS="-I $with_pppd"
|
||||
PPPD_VERSION=`grep VERSION $with_pppd/patchlevel.h | awk '{print $3}' | sed -e 's/\s*"\s*//g'`
|
||||
found_pppd_headers=yes
|
||||
AC_MSG_RESULT(found version $PPPD_VERSION)
|
||||
else
|
||||
AC_MSG_ERROR(not found in $with_pppd)
|
||||
fi
|
||||
AC_CHECK_HEADERS(pppd/pppd.h,,
|
||||
AC_MSG_ERROR(couldn't find pppd.h. pppd development headers are required.))
|
||||
|
||||
AC_ARG_WITH([pppd-plugin-dir], AS_HELP_STRING([--with-pppd-plugin-dir=DIR], [path to the pppd plugins directory]))
|
||||
|
||||
if test -n "$with_pppd_plugin_dir" ; then
|
||||
PPPD_PLUGIN_DIR="$with_pppd_plugin_dir"
|
||||
else
|
||||
PPPD_PLUGIN_DIR="${libdir}/pppd/2.4.4"
|
||||
fi
|
||||
|
||||
if test "z$found_pppd_headers" = "z"; then
|
||||
AC_MSG_CHECKING([for pppd.h under $prefix/include])
|
||||
find_pppd_h=`find $prefix/include -name pppd.h | xargs | awk '{print $1}'`
|
||||
if echo $find_pppd_h | grep pppd.h; then
|
||||
with_pppd=`dirname $find_pppd_h`
|
||||
PPPD_CFLAGS="-I $with_pppd"
|
||||
PPPD_VERSION=`grep VERSION $with_pppd/patchlevel.h | awk '{print $3}' | sed -e 's/\s*"\s*//g'`
|
||||
found_pppd_headers=yes
|
||||
AC_MSG_RESULT(found version $PPPD_VERSION)
|
||||
else
|
||||
AC_MSG_RESULT(not found)
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "z$found_pppd_headers" = "z"; then
|
||||
if test "z$PPPD_VERSION" = "z"; then
|
||||
AC_MSG_RESULT(Couldn't find pppd.h trying to determine pppd version to use in tree headers)
|
||||
##### Find PPPD executable
|
||||
AC_CHECK_PROG(PPPD,pppd,pppd)
|
||||
if test "z$PPPD" = "z"; then
|
||||
AC_MSG_ERROR(Cannot compile without pppd)
|
||||
fi
|
||||
AC_MSG_RESULT(pppd version not found attempting to run 'pppd --version')
|
||||
PPPD_VERSION=`$PPPD --version 2>&1 | awk '{print $3}'`
|
||||
if test "z$PPPD_VERSION" = "z"; then
|
||||
AC_MSG_ERROR(Couldn't determine the version of your pppd package.)
|
||||
fi
|
||||
fi
|
||||
|
||||
if ! test -d "src/external/$PPPD_VERSION"; then
|
||||
AC_MSG_ERROR(pppd headers could not be found)
|
||||
fi
|
||||
|
||||
AC_MSG_RESULT(Found in source headers for pppd version $PPPD_VERSION)
|
||||
PPPD_CFLAGS="-I ./external/$PPPD_VERSION"
|
||||
fi
|
||||
|
||||
AC_SUBST([PPPD_VERSION])
|
||||
AC_SUBST(PPPD_CFLAGS)
|
||||
AC_SUBST(PPPD_PLUGIN_DIR)
|
||||
|
||||
dnl
|
||||
dnl Checks for typedefs, structures, and compiler characteristics.
|
||||
|
|
@ -95,7 +53,7 @@ dnl
|
|||
AC_ARG_WITH(gnome, AC_HELP_STRING([--without-gnome], [Build NetworkManager-pptp without GNOME support, e.g. vpn service only]))
|
||||
AM_CONDITIONAL(WITH_GNOME, test x"$with_gnome" != xno)
|
||||
|
||||
GETTEXT_PACKAGE=NetworkManager-ppp_vpn
|
||||
GETTEXT_PACKAGE=NetworkManager-pptp
|
||||
AC_SUBST(GETTEXT_PACKAGE)
|
||||
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [Gettext package])
|
||||
|
||||
|
|
@ -106,13 +64,13 @@ PKG_CHECK_MODULES(GTHREAD, gthread-2.0)
|
|||
AC_SUBST(GTHREAD_CFLAGS)
|
||||
AC_SUBST(GTHREAD_LIBS)
|
||||
|
||||
PKG_CHECK_MODULES(DBUS, dbus-glib-1 >= 0.30)
|
||||
AC_SUBST(DBUS_CFLAGS)
|
||||
AC_SUBST(DBUS_LIBS)
|
||||
PKG_CHECK_MODULES(DBUS, dbus-glib-1 >= 0.74)
|
||||
AC_SUBST(DBUS_GLIB_CFLAGS)
|
||||
AC_SUBST(DBUS_GLIB_LIBS)
|
||||
|
||||
PKG_CHECK_MODULES(NETWORK_MANAGER, NetworkManager >= 0.4.1 libnm-util >= 0.7.0)
|
||||
AC_SUBST(NETWORK_MANAGER_CFLAGS)
|
||||
AC_SUBST(NETWORK_MANAGER_LIBS)
|
||||
PKG_CHECK_MODULES(NM_UTILS, NetworkManager >= 0.7.0 libnm-util libnm_glib libnm_glib_vpn)
|
||||
AC_SUBST(NM_UTILS_CFLAGS)
|
||||
AC_SUBST(NM_UTILS_LIBS)
|
||||
|
||||
if test x"$with_gnome" != xno; then
|
||||
PKG_CHECK_MODULES(GTK, gtk+-2.0 >= 2.6)
|
||||
|
|
@ -140,19 +98,6 @@ if test x"$with_gnome" != xno; then
|
|||
AC_SUBST(GNOMEKEYRING_LIBS)
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE(nm-vpn-dbus-old,
|
||||
AC_HELP_STRING([ --enable-nm-vpn-dbus-old], [Build Plugin to use old non-'DBUS Dict' NetworkManager VPN interface [default=no]]),
|
||||
enable_nm_vpn_dbus_old="$enableval", enable_nm_vpn_dbus_old=no)
|
||||
NM_VPN_CFLAGS=
|
||||
if test "x$enable_nm_vpn_dbus_old" = "xyes" ; then
|
||||
NM_VPN_CFLAGS="-DNM_VPN_USE_OLD_DBUS_INTERFACE"
|
||||
fi
|
||||
AC_SUBST(NM_VPN_CFLAGS)
|
||||
|
||||
AC_ARG_ENABLE(bluetooth, [ --enable-bluetooth Build Bluetooth bits [default=no]], enable_bluetooth="$enableval", enable_bluetooth=no)
|
||||
if test "x$enable_bluetooth" = "xyes" ; then
|
||||
BUILD_BLUETOOTH="yes"
|
||||
fi
|
||||
AC_ARG_ENABLE(more-warnings,
|
||||
AC_HELP_STRING([--enable-more-warnings], [Maximum compiler warnings]),
|
||||
set_more_warnings="$enableval",[
|
||||
|
|
@ -186,13 +131,11 @@ else
|
|||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
|
||||
AC_CONFIG_FILES([
|
||||
AC_OUTPUT([
|
||||
Makefile
|
||||
src/Makefile
|
||||
auth-dialog/Makefile
|
||||
auth-dialog-general/Makefile
|
||||
properties/Makefile
|
||||
po/Makefile.in
|
||||
])
|
||||
|
||||
AC_OUTPUT
|
||||
|
|
|
|||
|
|
@ -1,16 +0,0 @@
|
|||
<!DOCTYPE busconfig PUBLIC
|
||||
"-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
|
||||
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
|
||||
<busconfig>
|
||||
<policy user="root">
|
||||
<allow own="org.freedesktop.NetworkManager.ppp_starter"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager.ppp_starter"/>
|
||||
<allow send_interface="org.freedesktop.NetworkManager.ppp_starter"/>
|
||||
</policy>
|
||||
<policy context="default">
|
||||
<deny own="org.freedesktop.NetworkManager.ppp_starter"/>
|
||||
<deny send_destination="org.freedesktop.NetworkManager.ppp_starter"/>
|
||||
<deny send_interface="org.freedesktop.NetworkManager.ppp_starter"/>
|
||||
</policy>
|
||||
</busconfig>
|
||||
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
[VPN Connection]
|
||||
name=ppp
|
||||
service=org.freedesktop.NetworkManager.ppp_starter
|
||||
program=@BINDIR@/nm-ppp-starter
|
||||
|
||||
[GNOME]
|
||||
auth-dialog=@LIBEXECDIR@/nm-ppp-auth-dialog
|
||||
properties=@PREFIX@/${LIB}/libnm-ppp-properties
|
||||
24
vpn-daemons/pptp/nm-pptp-service.conf
Normal file
24
vpn-daemons/pptp/nm-pptp-service.conf
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<!DOCTYPE busconfig PUBLIC
|
||||
"-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
|
||||
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
|
||||
<busconfig>
|
||||
<policy user="root">
|
||||
<allow own="org.freedesktop.NetworkManager.pptp"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager.pptp"/>
|
||||
<allow send_interface="org.freedesktop.NetworkManager.pptp"/>
|
||||
|
||||
<allow own="org.freedesktop.NetworkManager.pptp-ppp"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager.pptp-ppp"/>
|
||||
<allow send_interface="org.freedesktop.NetworkManager.pptp-ppp"/>
|
||||
</policy>
|
||||
<policy context="default">
|
||||
<deny own="org.freedesktop.NetworkManager.pptp"/>
|
||||
<deny send_destination="org.freedesktop.NetworkManager.pptp"/>
|
||||
<deny send_interface="org.freedesktop.NetworkManager.pptp"/>
|
||||
|
||||
<deny own="org.freedesktop.NetworkManager.pptp-ppp"/>
|
||||
<deny send_destination="org.freedesktop.NetworkManager.pptp-ppp"/>
|
||||
<deny send_interface="org.freedesktop.NetworkManager.pptp-ppp"/>
|
||||
</policy>
|
||||
</busconfig>
|
||||
|
||||
8
vpn-daemons/pptp/nm-pptp-service.name.in
Normal file
8
vpn-daemons/pptp/nm-pptp-service.name.in
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
[VPN Connection]
|
||||
name=pptp
|
||||
service=org.freedesktop.NetworkManager.pptp
|
||||
program=@BINDIR@/nm-pptp-service
|
||||
|
||||
[GNOME]
|
||||
auth-dialog=nm-pptp-auth-dialog
|
||||
properties=libnm-pptp-properties
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
_Name=VPN Connection Manager (PPP generic)
|
||||
_GenericName=VPN Connection Manager (PPP generic)
|
||||
_Comment=Add, Remove, and Edit VPN Connections
|
||||
Exec=nm-vpn-properties --import-service org.freedesktop.NetworkManager.ppp_starter --import-file %f
|
||||
_Name=PPTP VPN Connection Manager
|
||||
_GenericName=PPTP VPN Connection Manager
|
||||
_Comment=Add, Remove, and Edit PPTP VPN Connections
|
||||
Exec=nm-vpn-properties --import-service org.freedesktop.NetworkManager.pptp --import-file %f
|
||||
Icon=gnome-mime-application-x-ppp-settings
|
||||
Terminal=false
|
||||
Type=Application
|
||||
|
|
@ -1,12 +1,9 @@
|
|||
# List of source files containing translatable strings.
|
||||
# Please keep this file sorted alphabetically.
|
||||
auth-dialog-general/gnome-generic-auth-dialog.c
|
||||
auth-dialog-general/main.c
|
||||
auth-dialog-general/nm-ppp-auth.glade
|
||||
auth-dialog/gnome-two-password-dialog.c
|
||||
auth-dialog/main.c
|
||||
nm-ppp.desktop.in
|
||||
properties/nm-ppp-dialog.glade
|
||||
properties/nm-ppp-properties.c
|
||||
properties/vpnui_impl.c
|
||||
src/nm-ppp-starter.c
|
||||
nm-pptp.desktop.in
|
||||
properties/advanced-dialog.c
|
||||
properties/nm-pptp-dialog.glade
|
||||
properties/nm-pptp.c
|
||||
src/nm-pptp-service.c
|
||||
|
|
|
|||
|
|
@ -1,32 +1,22 @@
|
|||
lib_LTLIBRARIES = libnm-pptp-properties.la
|
||||
|
||||
libnm_pptp_properties_la_SOURCES = \
|
||||
nm-pptp.c \
|
||||
nm-pptp.h \
|
||||
advanced-dialog.c \
|
||||
advanced-dialog.h \
|
||||
import-export.c \
|
||||
import-export.h
|
||||
|
||||
lib_LTLIBRARIES = libnm-ppp-properties.la
|
||||
gladedir = $(datadir)/gnome-vpn-properties/pptp
|
||||
glade_DATA = nm-pptp-dialog.glade
|
||||
|
||||
libnm_ppp_properties_la_SOURCES = \
|
||||
nm-ppp-properties.c \
|
||||
vpnui_impl.c \
|
||||
vpnui_expand.c \
|
||||
vpnui_opt.c \
|
||||
vpnui_validate.c \
|
||||
vpnui_variant.c \
|
||||
util_lists.c \
|
||||
vpnui_impl.h \
|
||||
vpnui_opt.h \
|
||||
vpnui_expand.h \
|
||||
vpnui_validate.h \
|
||||
vpnui_variant.h \
|
||||
util_lists.h \
|
||||
vpnui_impl.h
|
||||
|
||||
gladedir = $(datadir)/gnome-vpn-properties/ppp
|
||||
glade_DATA = nm-ppp-dialog.glade
|
||||
|
||||
libnm_ppp_properties_la_CFLAGS = \
|
||||
libnm_pptp_properties_la_CFLAGS = \
|
||||
$(GLADE_CFLAGS) \
|
||||
$(GTK_CFLAGS) \
|
||||
$(GCONF_CFLAGS) \
|
||||
$(LIBGNOMEUI_CFLAGS) \
|
||||
$(NETWORK_MANAGER_CFLAGS) \
|
||||
$(NM_UTILS_CFLAGS) \
|
||||
-DICONDIR=\""$(datadir)/pixmaps"\" \
|
||||
-DGLADEDIR=\""$(gladedir)"\" \
|
||||
-DG_DISABLE_DEPRECATED \
|
||||
|
|
@ -35,14 +25,14 @@ libnm_ppp_properties_la_CFLAGS = \
|
|||
-DGNOMELOCALEDIR=\"$(datadir)/locale\" \
|
||||
-DVERSION=\"$(VERSION)\"
|
||||
|
||||
libnm_ppp_properties_la_LIBADD = \
|
||||
libnm_pptp_properties_la_LIBADD = \
|
||||
$(GLADE_LIBS) \
|
||||
$(GTK_LIBS) \
|
||||
$(GCONF_LIBS) \
|
||||
$(LIBGNOMEUI_LIBS) \
|
||||
$(NETWORK_MANAGER_LIBS)
|
||||
$(NM_UTILS_LIBS)
|
||||
|
||||
libnm_ppp_properties_la_LDFLAGS = \
|
||||
libnm_pptp_properties_la_LDFLAGS = \
|
||||
-avoid-version
|
||||
|
||||
CLEANFILES = *.bak *.gladep *~
|
||||
|
|
|
|||
478
vpn-daemons/pptp/properties/advanced-dialog.c
Normal file
478
vpn-daemons/pptp/properties/advanced-dialog.c
Normal file
|
|
@ -0,0 +1,478 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
||||
/***************************************************************************
|
||||
*
|
||||
* Copyright (C) 2008 Dan Williams, <dcbw@redhat.com>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <glib.h>
|
||||
#include <glib/gi18n-lib.h>
|
||||
#include <glade/glade.h>
|
||||
|
||||
#include <nm-connection.h>
|
||||
#include <nm-setting-vpn.h>
|
||||
#include <nm-setting-vpn-properties.h>
|
||||
|
||||
#include "advanced-dialog.h"
|
||||
#include "nm-pptp.h"
|
||||
#include "../src/nm-pptp-service.h"
|
||||
|
||||
#define COL_NAME 0
|
||||
#define COL_VALUE 1
|
||||
#define COL_TAG 2
|
||||
|
||||
#define TAG_PAP 0
|
||||
#define TAG_CHAP 1
|
||||
#define TAG_MSCHAP 2
|
||||
#define TAG_MSCHAPV2 3
|
||||
|
||||
static void
|
||||
nm_gvalue_destroy (gpointer data)
|
||||
{
|
||||
GValue *value = (GValue *) data;
|
||||
|
||||
g_value_unset (value);
|
||||
g_slice_free (GValue, value);
|
||||
}
|
||||
|
||||
static const char *advanced_keys[] = {
|
||||
NM_PPTP_KEY_REFUSE_EAP,
|
||||
NM_PPTP_KEY_REFUSE_PAP,
|
||||
NM_PPTP_KEY_REFUSE_CHAP,
|
||||
NM_PPTP_KEY_REFUSE_MSCHAP,
|
||||
NM_PPTP_KEY_REFUSE_MSCHAPV2,
|
||||
NM_PPTP_KEY_REQUIRE_MPPE,
|
||||
NM_PPTP_KEY_REQUIRE_MPPE_40,
|
||||
NM_PPTP_KEY_REQUIRE_MPPE_128,
|
||||
NM_PPTP_KEY_MPPE_STATEFUL,
|
||||
NM_PPTP_KEY_NOBSDCOMP,
|
||||
NM_PPTP_KEY_NODEFLATE,
|
||||
NM_PPTP_KEY_NO_VJ_COMP,
|
||||
NM_PPTP_KEY_LCP_ECHO_FAILURE,
|
||||
NM_PPTP_KEY_LCP_ECHO_INTERVAL,
|
||||
NULL
|
||||
};
|
||||
|
||||
static void
|
||||
copy_values (gpointer key, gpointer data, gpointer user_data)
|
||||
{
|
||||
GHashTable *hash = (GHashTable *) user_data;
|
||||
GValue *value = (GValue *) data;
|
||||
const char **i;
|
||||
|
||||
for (i = &advanced_keys[0]; *i; i++) {
|
||||
if (strcmp ((const char *) key, *i))
|
||||
continue;
|
||||
|
||||
if (G_VALUE_HOLDS_STRING (value)) {
|
||||
g_hash_table_insert (hash,
|
||||
g_strdup ((const char *) key),
|
||||
str_to_gvalue (g_value_get_string (value)));
|
||||
} else if (G_VALUE_HOLDS_INT (value)) {
|
||||
g_hash_table_insert (hash,
|
||||
g_strdup ((const char *) key),
|
||||
int_to_gvalue (g_value_get_int (value)));
|
||||
} else if (G_VALUE_HOLDS_UINT (value)) {
|
||||
g_hash_table_insert (hash,
|
||||
g_strdup ((const char *) key),
|
||||
uint_to_gvalue (g_value_get_uint (value)));
|
||||
} else if (G_VALUE_HOLDS_BOOLEAN (value)) {
|
||||
g_hash_table_insert (hash,
|
||||
g_strdup ((const char *) key),
|
||||
bool_to_gvalue (g_value_get_boolean (value)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GHashTable *
|
||||
advanced_dialog_new_hash_from_connection (NMConnection *connection,
|
||||
GError **error)
|
||||
{
|
||||
GHashTable *hash;
|
||||
NMSettingVPNProperties *s_vpn_props;
|
||||
|
||||
hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, nm_gvalue_destroy);
|
||||
|
||||
s_vpn_props = (NMSettingVPNProperties *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN_PROPERTIES);
|
||||
if (s_vpn_props && s_vpn_props->data)
|
||||
g_hash_table_foreach (s_vpn_props->data, copy_values, hash);
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
static void
|
||||
mppe_toggled_cb (GtkWidget *check, gpointer user_data)
|
||||
{
|
||||
GladeXML *xml = (GladeXML *) user_data;
|
||||
GtkWidget *widget;
|
||||
gboolean use_mppe;
|
||||
|
||||
use_mppe = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check));
|
||||
|
||||
widget = glade_xml_get_widget (xml, "ppp_mppe_security_label");
|
||||
gtk_widget_set_sensitive (widget, use_mppe);
|
||||
|
||||
widget = glade_xml_get_widget (xml, "ppp_mppe_security_combo");
|
||||
if (!use_mppe)
|
||||
gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0); /* default */
|
||||
gtk_widget_set_sensitive (widget, use_mppe);
|
||||
|
||||
widget = glade_xml_get_widget (xml, "ppp_allow_stateful_mppe");
|
||||
if (!use_mppe)
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE);
|
||||
gtk_widget_set_sensitive (widget, use_mppe);
|
||||
}
|
||||
|
||||
#define SEC_INDEX_DEFAULT 0
|
||||
#define SEC_INDEX_MPPE_128 1
|
||||
#define SEC_INDEX_MPPE_40 2
|
||||
|
||||
static void
|
||||
setup_security_combo (GladeXML *xml, GHashTable *hash)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
GtkListStore *store;
|
||||
GtkTreeIter iter;
|
||||
int active = -1;
|
||||
GValue *value;
|
||||
|
||||
g_return_if_fail (xml != NULL);
|
||||
g_return_if_fail (hash != NULL);
|
||||
|
||||
widget = glade_xml_get_widget (xml, "ppp_mppe_security_combo");
|
||||
|
||||
store = gtk_list_store_new (1, G_TYPE_STRING);
|
||||
|
||||
/* Default */
|
||||
gtk_list_store_append (store, &iter);
|
||||
gtk_list_store_set (store, &iter, 0, _("All Available (Default)"), -1);
|
||||
|
||||
/* MPPE-128 */
|
||||
gtk_list_store_append (store, &iter);
|
||||
gtk_list_store_set (store, &iter, 0, _("128-bit (most secure)"), -1);
|
||||
if (active < 0) {
|
||||
value = g_hash_table_lookup (hash, NM_PPTP_KEY_REQUIRE_MPPE_128);
|
||||
if (value && G_VALUE_HOLDS_BOOLEAN (value) && g_value_get_boolean (value))
|
||||
active = SEC_INDEX_MPPE_128;
|
||||
}
|
||||
|
||||
/* MPPE-40 */
|
||||
gtk_list_store_append (store, &iter);
|
||||
gtk_list_store_set (store, &iter, 0, _("40-bit (less secure)"), -1);
|
||||
if (active < 0) {
|
||||
value = g_hash_table_lookup (hash, NM_PPTP_KEY_REQUIRE_MPPE_40);
|
||||
if (value && G_VALUE_HOLDS_BOOLEAN (value) && g_value_get_boolean (value))
|
||||
active = SEC_INDEX_MPPE_40;
|
||||
}
|
||||
|
||||
gtk_combo_box_set_model (GTK_COMBO_BOX (widget), GTK_TREE_MODEL (store));
|
||||
g_object_unref (store);
|
||||
gtk_combo_box_set_active (GTK_COMBO_BOX (widget), active < 0 ? SEC_INDEX_DEFAULT : active);
|
||||
}
|
||||
|
||||
static void
|
||||
check_toggled_cb (GtkCellRendererToggle *cell, gchar *path_str, gpointer user_data)
|
||||
{
|
||||
GladeXML *xml = GLADE_XML (user_data);
|
||||
GtkWidget *widget;
|
||||
GtkTreePath *path = gtk_tree_path_new_from_string (path_str);
|
||||
GtkTreeModel *model;
|
||||
GtkTreeIter iter;
|
||||
gboolean toggle_item;
|
||||
|
||||
widget = glade_xml_get_widget (xml, "ppp_auth_methods");
|
||||
model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget));
|
||||
|
||||
gtk_tree_model_get_iter (model, &iter, path);
|
||||
gtk_tree_model_get (model, &iter, COL_VALUE, &toggle_item, -1);
|
||||
|
||||
toggle_item ^= 1;
|
||||
|
||||
/* set new value */
|
||||
gtk_list_store_set (GTK_LIST_STORE (model), &iter, COL_VALUE, toggle_item, -1);
|
||||
|
||||
gtk_tree_path_free (path);
|
||||
}
|
||||
|
||||
static void
|
||||
auth_methods_setup (GladeXML *xml, GHashTable *hash)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
GtkListStore *store;
|
||||
GtkTreeIter iter;
|
||||
GValue *value;
|
||||
gboolean allowed;
|
||||
gboolean use_mppe = FALSE;
|
||||
GtkCellRendererToggle *check_renderer;
|
||||
GtkCellRenderer *text_renderer;
|
||||
GtkTreeViewColumn *column;
|
||||
gint offset;
|
||||
|
||||
store = gtk_list_store_new (3, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_UINT);
|
||||
|
||||
/* Check for MPPE */
|
||||
value = g_hash_table_lookup (hash, NM_PPTP_KEY_REQUIRE_MPPE);
|
||||
if (value && G_VALUE_HOLDS_BOOLEAN (value) && g_value_get_boolean (value))
|
||||
use_mppe = TRUE;
|
||||
|
||||
/* Or MPPE-128 */
|
||||
value = g_hash_table_lookup (hash, NM_PPTP_KEY_REQUIRE_MPPE_128);
|
||||
if (value && G_VALUE_HOLDS_BOOLEAN (value) && g_value_get_boolean (value))
|
||||
use_mppe = TRUE;
|
||||
|
||||
/* Or MPPE-40 */
|
||||
value = g_hash_table_lookup (hash, NM_PPTP_KEY_REQUIRE_MPPE_40);
|
||||
if (value && G_VALUE_HOLDS_BOOLEAN (value) && g_value_get_boolean (value))
|
||||
use_mppe = TRUE;
|
||||
|
||||
/* PAP */
|
||||
value = g_hash_table_lookup (hash, NM_PPTP_KEY_REFUSE_PAP);
|
||||
allowed = (value && G_VALUE_HOLDS_BOOLEAN (value) && g_value_get_boolean (value)) ? FALSE : TRUE;
|
||||
gtk_list_store_append (store, &iter);
|
||||
gtk_list_store_set (store, &iter, COL_NAME, _("PAP"), COL_VALUE, allowed, COL_TAG, TAG_PAP, -1);
|
||||
|
||||
/* CHAP */
|
||||
value = g_hash_table_lookup (hash, NM_PPTP_KEY_REFUSE_CHAP);
|
||||
allowed = (value && G_VALUE_HOLDS_BOOLEAN (value) && g_value_get_boolean (value)) ? FALSE : TRUE;
|
||||
gtk_list_store_append (store, &iter);
|
||||
gtk_list_store_set (store, &iter, COL_NAME, _("CHAP"), COL_VALUE, allowed, COL_TAG, TAG_CHAP, -1);
|
||||
|
||||
/* MSCHAP */
|
||||
value = g_hash_table_lookup (hash, NM_PPTP_KEY_REFUSE_MSCHAP);
|
||||
allowed = (value && G_VALUE_HOLDS_BOOLEAN (value) && g_value_get_boolean (value)) ? FALSE : TRUE;
|
||||
gtk_list_store_append (store, &iter);
|
||||
gtk_list_store_set (store, &iter, COL_NAME, _("MSCHAP"), COL_VALUE, allowed, COL_TAG, TAG_MSCHAP, -1);
|
||||
|
||||
/* PAP */
|
||||
value = g_hash_table_lookup (hash, NM_PPTP_KEY_REFUSE_MSCHAPV2);
|
||||
allowed = (value && G_VALUE_HOLDS_BOOLEAN (value) && g_value_get_boolean (value)) ? FALSE : TRUE;
|
||||
gtk_list_store_append (store, &iter);
|
||||
gtk_list_store_set (store, &iter, COL_NAME, _("MSCHAPv2"), COL_VALUE, allowed, COL_TAG, TAG_MSCHAPV2, -1);
|
||||
|
||||
/* Set up the tree view */
|
||||
widget = glade_xml_get_widget (xml, "ppp_auth_methods");
|
||||
gtk_tree_view_set_model (GTK_TREE_VIEW (widget), GTK_TREE_MODEL (store));
|
||||
|
||||
check_renderer = GTK_CELL_RENDERER_TOGGLE (gtk_cell_renderer_toggle_new ());
|
||||
g_signal_connect (check_renderer, "toggled", G_CALLBACK (check_toggled_cb), xml);
|
||||
|
||||
offset = gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (widget),
|
||||
-1, "", GTK_CELL_RENDERER (check_renderer),
|
||||
"active", COL_VALUE,
|
||||
NULL);
|
||||
column = gtk_tree_view_get_column (GTK_TREE_VIEW (widget), offset - 1);
|
||||
gtk_tree_view_column_set_sizing (GTK_TREE_VIEW_COLUMN (column), GTK_TREE_VIEW_COLUMN_FIXED);
|
||||
gtk_tree_view_column_set_fixed_width (GTK_TREE_VIEW_COLUMN (column), 30);
|
||||
gtk_tree_view_column_set_clickable (GTK_TREE_VIEW_COLUMN (column), TRUE);
|
||||
|
||||
text_renderer = gtk_cell_renderer_text_new ();
|
||||
offset = gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (widget),
|
||||
-1, "", text_renderer,
|
||||
"text", COL_NAME,
|
||||
NULL);
|
||||
column = gtk_tree_view_get_column (GTK_TREE_VIEW (widget), offset - 1);
|
||||
gtk_tree_view_column_set_expand (GTK_TREE_VIEW_COLUMN (column), TRUE);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
advanced_dialog_new (GHashTable *hash)
|
||||
{
|
||||
GladeXML *xml;
|
||||
GtkWidget *dialog = NULL;
|
||||
char *glade_file = NULL;
|
||||
GtkWidget *widget;
|
||||
GValue *value;
|
||||
|
||||
g_return_val_if_fail (hash != NULL, NULL);
|
||||
|
||||
glade_file = g_strdup_printf ("%s/%s", GLADEDIR, "nm-pptp-dialog.glade");
|
||||
xml = glade_xml_new (glade_file, "pptp-advanced-dialog", GETTEXT_PACKAGE);
|
||||
if (xml == NULL)
|
||||
goto out;
|
||||
|
||||
dialog = glade_xml_get_widget (xml, "pptp-advanced-dialog");
|
||||
if (!dialog) {
|
||||
g_object_unref (G_OBJECT (xml));
|
||||
goto out;
|
||||
}
|
||||
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
|
||||
|
||||
g_object_set_data_full (G_OBJECT (dialog), "glade-xml",
|
||||
xml, (GDestroyNotify) g_object_unref);
|
||||
|
||||
|
||||
setup_security_combo (xml, hash);
|
||||
|
||||
widget = glade_xml_get_widget (xml, "ppp_use_mppe");
|
||||
g_signal_connect (G_OBJECT (widget), "toggled", G_CALLBACK (mppe_toggled_cb), xml);
|
||||
|
||||
value = g_hash_table_lookup (hash, NM_PPTP_KEY_REQUIRE_MPPE);
|
||||
if (value && G_VALUE_HOLDS_BOOLEAN (value)) {
|
||||
if (g_value_get_boolean (value))
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
|
||||
}
|
||||
mppe_toggled_cb (widget, xml);
|
||||
|
||||
value = g_hash_table_lookup (hash, NM_PPTP_KEY_MPPE_STATEFUL);
|
||||
if (value && G_VALUE_HOLDS_BOOLEAN (value)) {
|
||||
widget = glade_xml_get_widget (xml, "ppp_allow_stateful_mppe");
|
||||
if (g_value_get_boolean (value))
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
|
||||
}
|
||||
|
||||
widget = glade_xml_get_widget (xml, "ppp_allow_bsdcomp");
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
|
||||
value = g_hash_table_lookup (hash, NM_PPTP_KEY_NOBSDCOMP);
|
||||
if (value && G_VALUE_HOLDS_BOOLEAN (value)) {
|
||||
if (g_value_get_boolean (value))
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE);
|
||||
}
|
||||
|
||||
widget = glade_xml_get_widget (xml, "ppp_allow_deflate");
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
|
||||
value = g_hash_table_lookup (hash, NM_PPTP_KEY_NODEFLATE);
|
||||
if (value && G_VALUE_HOLDS_BOOLEAN (value)) {
|
||||
if (g_value_get_boolean (value))
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE);
|
||||
}
|
||||
|
||||
widget = glade_xml_get_widget (xml, "ppp_usevj");
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
|
||||
value = g_hash_table_lookup (hash, NM_PPTP_KEY_NO_VJ_COMP);
|
||||
if (value && G_VALUE_HOLDS_BOOLEAN (value)) {
|
||||
if (g_value_get_boolean (value))
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE);
|
||||
}
|
||||
|
||||
value = g_hash_table_lookup (hash, NM_PPTP_KEY_LCP_ECHO_INTERVAL);
|
||||
if (value && G_VALUE_HOLDS_UINT (value)) {
|
||||
widget = glade_xml_get_widget (xml, "ppp_send_echo_packets");
|
||||
if (g_value_get_uint (value))
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
|
||||
}
|
||||
|
||||
auth_methods_setup (xml, hash);
|
||||
|
||||
out:
|
||||
g_free (glade_file);
|
||||
return dialog;
|
||||
}
|
||||
|
||||
GHashTable *
|
||||
advanced_dialog_new_hash_from_dialog (GtkWidget *dialog, GError **error)
|
||||
{
|
||||
GHashTable *hash;
|
||||
GtkWidget *widget;
|
||||
GladeXML *xml;
|
||||
GtkTreeModel *model;
|
||||
GtkTreeIter iter;
|
||||
gboolean valid;
|
||||
|
||||
g_return_val_if_fail (dialog != NULL, NULL);
|
||||
if (error)
|
||||
g_return_val_if_fail (*error == NULL, NULL);
|
||||
|
||||
xml = g_object_get_data (G_OBJECT (dialog), "glade-xml");
|
||||
g_return_val_if_fail (xml != NULL, NULL);
|
||||
|
||||
hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, nm_gvalue_destroy);
|
||||
|
||||
widget = glade_xml_get_widget (xml, "ppp_use_mppe");
|
||||
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) {
|
||||
|
||||
widget = glade_xml_get_widget (xml, "ppp_mppe_security_combo");
|
||||
switch (gtk_combo_box_get_active (GTK_COMBO_BOX (widget))) {
|
||||
case SEC_INDEX_MPPE_128:
|
||||
g_hash_table_insert (hash, g_strdup (NM_PPTP_KEY_REQUIRE_MPPE_128), bool_to_gvalue (TRUE));
|
||||
break;
|
||||
case SEC_INDEX_MPPE_40:
|
||||
g_hash_table_insert (hash, g_strdup (NM_PPTP_KEY_REQUIRE_MPPE_40), bool_to_gvalue (TRUE));
|
||||
break;
|
||||
default:
|
||||
g_hash_table_insert (hash, g_strdup (NM_PPTP_KEY_REQUIRE_MPPE), bool_to_gvalue (TRUE));
|
||||
break;
|
||||
}
|
||||
|
||||
widget = glade_xml_get_widget (xml, "ppp_allow_stateful_mppe");
|
||||
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
|
||||
g_hash_table_insert (hash, g_strdup (NM_PPTP_KEY_MPPE_STATEFUL), bool_to_gvalue (TRUE));
|
||||
}
|
||||
|
||||
widget = glade_xml_get_widget (xml, "ppp_allow_bsdcomp");
|
||||
if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
|
||||
g_hash_table_insert (hash, g_strdup (NM_PPTP_KEY_NOBSDCOMP), bool_to_gvalue (TRUE));
|
||||
|
||||
widget = glade_xml_get_widget (xml, "ppp_allow_deflate");
|
||||
if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
|
||||
g_hash_table_insert (hash, g_strdup (NM_PPTP_KEY_NODEFLATE), bool_to_gvalue (TRUE));
|
||||
|
||||
widget = glade_xml_get_widget (xml, "ppp_usevj");
|
||||
if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
|
||||
g_hash_table_insert (hash, g_strdup (NM_PPTP_KEY_NO_VJ_COMP), bool_to_gvalue (TRUE));
|
||||
|
||||
widget = glade_xml_get_widget (xml, "ppp_send_echo_packets");
|
||||
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) {
|
||||
g_hash_table_insert (hash, g_strdup (NM_PPTP_KEY_LCP_ECHO_FAILURE), uint_to_gvalue (5));
|
||||
g_hash_table_insert (hash, g_strdup (NM_PPTP_KEY_LCP_ECHO_INTERVAL), uint_to_gvalue (30));
|
||||
}
|
||||
|
||||
widget = glade_xml_get_widget (xml, "ppp_auth_methods");
|
||||
model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget));
|
||||
valid = gtk_tree_model_get_iter_first (model, &iter);
|
||||
while (valid) {
|
||||
gboolean allowed;
|
||||
guint32 tag;
|
||||
|
||||
gtk_tree_model_get (model, &iter, COL_VALUE, &allowed, COL_TAG, &tag, -1);
|
||||
switch (tag) {
|
||||
case TAG_PAP:
|
||||
if (!allowed)
|
||||
g_hash_table_insert (hash, g_strdup (NM_PPTP_KEY_REFUSE_PAP), bool_to_gvalue (TRUE));
|
||||
break;
|
||||
case TAG_CHAP:
|
||||
if (!allowed)
|
||||
g_hash_table_insert (hash, g_strdup (NM_PPTP_KEY_REFUSE_CHAP), bool_to_gvalue (TRUE));
|
||||
break;
|
||||
case TAG_MSCHAP:
|
||||
if (!allowed)
|
||||
g_hash_table_insert (hash, g_strdup (NM_PPTP_KEY_REFUSE_MSCHAP), bool_to_gvalue (TRUE));
|
||||
break;
|
||||
case TAG_MSCHAPV2:
|
||||
if (!allowed)
|
||||
g_hash_table_insert (hash, g_strdup (NM_PPTP_KEY_REFUSE_MSCHAPV2), bool_to_gvalue (TRUE));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
valid = gtk_tree_model_iter_next (model, &iter);
|
||||
}
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
|
|
@ -1,8 +1,7 @@
|
|||
/* nm-ppp-starter - pptp (and other ppp) integration with NetworkManager
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
||||
/***************************************************************************
|
||||
*
|
||||
* Antony J Mee <eemynotna at gmail dot com>
|
||||
* Based on openvpn work by Tim Niemueller <tim@niemueller.de>
|
||||
* and Dan Williams <dcbw@redhat.com>
|
||||
* Copyright (C) 2008 Dan Williams, <dcbw@redhat.com>
|
||||
*
|
||||
* 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
|
||||
|
|
@ -18,13 +17,21 @@
|
|||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
*/
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef NM_PPP_SERVICE_H
|
||||
#define NM_PPP_SERVICE_H
|
||||
#ifndef _AUTH_HELPERS_H_
|
||||
#define _AUTH_HELPERS_H_
|
||||
|
||||
#define NM_DBUS_SERVICE_PPP_STARTER "org.freedesktop.NetworkManager.ppp_starter"
|
||||
#define NM_DBUS_INTERFACE_PPP_STARTER "org.freedesktop.NetworkManager.ppp_starter"
|
||||
#define NM_DBUS_PATH_PPP_STARTER "/org/freedesktop/NetworkManager/ppp_starter"
|
||||
#include <glib.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <gtk/gtkwidget.h>
|
||||
|
||||
#include <nm-connection.h>
|
||||
|
||||
GtkWidget *advanced_dialog_new (GHashTable *hash);
|
||||
|
||||
GHashTable *advanced_dialog_new_hash_from_connection (NMConnection *connection, GError **error);
|
||||
|
||||
GHashTable *advanced_dialog_new_hash_from_dialog (GtkWidget *dialog, GError **error);
|
||||
|
||||
#endif
|
||||
81
vpn-daemons/pptp/properties/import-export.c
Normal file
81
vpn-daemons/pptp/properties/import-export.c
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
||||
/***************************************************************************
|
||||
*
|
||||
* Copyright (C) 2008 Dan Williams, <dcbw@redhat.com>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include <glib/gi18n-lib.h>
|
||||
|
||||
#include <nm-setting-vpn.h>
|
||||
#include <nm-setting-vpn-properties.h>
|
||||
#include <nm-setting-connection.h>
|
||||
#include <nm-setting-ip4-config.h>
|
||||
|
||||
#include "import-export.h"
|
||||
#include "nm-pptp.h"
|
||||
#include "../src/nm-pptp-service.h"
|
||||
|
||||
NMConnection *
|
||||
do_import (const char *path, char **lines, GError **error)
|
||||
{
|
||||
NMConnection *connection = NULL;
|
||||
NMSettingConnection *s_con;
|
||||
NMSettingVPN *s_vpn;
|
||||
NMSettingVPNProperties *s_vpn_props;
|
||||
char *last_dot;
|
||||
|
||||
connection = nm_connection_new ();
|
||||
s_con = NM_SETTING_CONNECTION (nm_setting_connection_new ());
|
||||
nm_connection_add_setting (connection, NM_SETTING (s_con));
|
||||
|
||||
s_vpn = NM_SETTING_VPN (nm_setting_vpn_new ());
|
||||
s_vpn->service_type = g_strdup (NM_DBUS_SERVICE_PPTP);
|
||||
nm_connection_add_setting (connection, NM_SETTING (s_vpn));
|
||||
|
||||
s_vpn_props = NM_SETTING_VPN_PROPERTIES (nm_setting_vpn_properties_new ());
|
||||
nm_connection_add_setting (connection, NM_SETTING (s_vpn_props));
|
||||
|
||||
s_con->id = g_path_get_basename (path);
|
||||
last_dot = strrchr (s_con->id, '.');
|
||||
if (last_dot)
|
||||
*last_dot = '\0';
|
||||
|
||||
return connection;
|
||||
}
|
||||
|
||||
gboolean
|
||||
do_export (const char *path, NMConnection *connection, GError **error)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,8 +1,7 @@
|
|||
/* nm-ppp-starter - pptp (and other ppp) integration with NetworkManager
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
||||
/***************************************************************************
|
||||
*
|
||||
* Antony J Mee <eemynotna at gmail dot com>
|
||||
* Based on openvpn work by Tim Niemueller <tim@niemueller.de>
|
||||
* and Dan Williams <dcbw@redhat.com>
|
||||
* Copyright (C) 2008 Dan Williams, <dcbw@redhat.com>
|
||||
*
|
||||
* 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
|
||||
|
|
@ -18,13 +17,16 @@
|
|||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
*/
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef NM_PPPD_PLUGIN_H
|
||||
#define NM_PPPD_PLUGIN_H
|
||||
#ifndef _IMPORT_EXPORT_H_
|
||||
#define _IMPORT_EXPORT_H_
|
||||
|
||||
#define NM_DBUS_SERVICE_PPP "org.freedesktop.NetworkManager.ppp"
|
||||
#define NM_DBUS_INTERFACE_PPP "org.freedesktop.NetworkManager.ppp"
|
||||
#define NM_DBUS_PATH_PPP "/org/freedesktop/NetworkManager/ppp"
|
||||
#include <glib.h>
|
||||
#include <nm-connection.h>
|
||||
|
||||
NMConnection *do_import (const char *path, char **lines, GError **error);
|
||||
|
||||
gboolean do_export (const char *path, NMConnection *connection, GError **error);
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,465 +0,0 @@
|
|||
/***************************************************************************
|
||||
* CVSID: $Id$
|
||||
*
|
||||
* nm-pptp.c : GNOME UI dialogs for configuring PPTP connections
|
||||
*
|
||||
* Copyright (C) 2005 Antony Mee <eemynotna@gmail.com>
|
||||
* Based on work by Tim Niemueller <tim@niemueller.de>
|
||||
* and David Zeuthen, <davidz@redhat.com>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <glib/gi18n-lib.h>
|
||||
#include <string.h>
|
||||
#include <glade/glade.h>
|
||||
|
||||
#define NMVPNUI_PPTP_PROPERTIES_C
|
||||
|
||||
#include "vpnui_impl.h"
|
||||
#include "vpnui_opt.h"
|
||||
#include "vpnui_expand.h"
|
||||
#include "vpnui_validate.h"
|
||||
#include "vpnui_variant.h"
|
||||
#include "util_lists.h"
|
||||
|
||||
#define BUILD_BLUETOOTH
|
||||
|
||||
#define VPNUI_DISPLAY_NAME _("pppd tunnel (PPTP, BTGPRS, Dialup)")
|
||||
#define VPNUI_SERVICE_NAME "org.freedesktop.NetworkManager.ppp_starter"
|
||||
#define VPNUI_BASIC_DEFAULTS "connection-name='';" \
|
||||
"ppp-debug=no;" \
|
||||
"usepeerdns=yes;" \
|
||||
"usepeerdns-overtunnel=yes;" \
|
||||
"ppp-lock=yes;" \
|
||||
"ppp-auth-peer=no;" \
|
||||
"ppp-refuse-eap=no;" \
|
||||
"ppp-refuse-chap=no;" \
|
||||
"ppp-refuse-mschap=no;" \
|
||||
"lcp-echo-failure=10;" \
|
||||
"lcp-echo-interval=10;" \
|
||||
"use-routes=no;" \
|
||||
"routes=;" \
|
||||
"ppp-debug=no;" \
|
||||
"ppp-extra='';"
|
||||
#define VPNUI_BTOOTH_DEFAULTS "bt-bdaddr=00:00:00:00:00:00;" \
|
||||
"bt-channel=1;"
|
||||
#define VPNUI_GPRS_DEFAULTS "gprs-packet-type=IP;" \
|
||||
"gprs-context-num=1;" \
|
||||
"gprs-ip-address=0.0.0.0;" \
|
||||
"gprs-apn=internet;" \
|
||||
"ppp-crtscts=yes;" \
|
||||
"ppp-noipdefault=yes;" \
|
||||
"ppp-modem=yes;" \
|
||||
"usepeerdns=yes;" \
|
||||
"ppp-connect-delay=5000;"
|
||||
#define VPNUI_BTGPRS_DEFAULTS "ppp-connection-type=btgprs;" \
|
||||
"encrypt-mppe=no;" \
|
||||
"encrypt-mppe-128=no;" \
|
||||
"encrypt-mppe-stateful=no;" \
|
||||
"compress-mppc=no;" \
|
||||
"compress-bsd=no;" \
|
||||
"compress-deflate=no;" \
|
||||
"mru=1000;" \
|
||||
"mtu=1000;"
|
||||
#define VPNUI_PPTP_DEFAULTS "pptp-remote='';" \
|
||||
"ppp-connection-type=pptp;" \
|
||||
"encrypt-mppe=no;" \
|
||||
"encrypt-mppe-128=yes;" \
|
||||
"encrypt-mppe-stateful=yes;" \
|
||||
"compress-mppc=no;" \
|
||||
"compress-bsd=no;" \
|
||||
"compress-deflate=no;" \
|
||||
"mru=1416;" \
|
||||
"mtu=1416;"
|
||||
#define VPNUI_DIALUP_DEFAULTS "phone-number=THIS DOESN'T DO ANYTHING;" \
|
||||
"ppp-crtscts=yes;" \
|
||||
"ppp-modem=yes;" \
|
||||
"ppp-connection-type=dialup;" \
|
||||
"encrypt-mppe=no;" \
|
||||
"encrypt-mppe-128=no;" \
|
||||
"encrypt-mppe-stateful=no;" \
|
||||
"compress-mppc=no;" \
|
||||
"compress-bsd=no;" \
|
||||
"compress-deflate=no;" \
|
||||
"mru=1000;" \
|
||||
"mtu=1000;"
|
||||
|
||||
#ifdef NMVPNUI_PPTP_PROPERTIES_C
|
||||
#endif
|
||||
|
||||
void impl_setup (NetworkManagerVpnUIImpl *impl);
|
||||
void impl_hide_and_show (NetworkManagerVpnUIImpl *impl);
|
||||
void use_routes_toggled (GtkToggleButton *togglebutton, gpointer user_data);
|
||||
void editable_changed (GtkEditable *editable, gpointer user_data);
|
||||
void variant_changed (GtkComboBox *combo, gpointer user_data);
|
||||
|
||||
|
||||
const char *GLADE_FILE="nm-ppp-dialog.glade";
|
||||
const char *GLADE_WIDGET="nm-ppp-widget";
|
||||
|
||||
void
|
||||
impl_setup (NetworkManagerVpnUIImpl *impl)
|
||||
{
|
||||
GSList *item;
|
||||
VpnUIConfigOption *opt;
|
||||
VpnUIVariant *variant;
|
||||
// VpnUIExpander *expand;
|
||||
g_return_if_fail(impl!=NULL);
|
||||
|
||||
impl->display_name = VPNUI_DISPLAY_NAME;
|
||||
impl->service_name = VPNUI_SERVICE_NAME;
|
||||
// GLADE NAME TYPE
|
||||
// GCONF_NAME EXPORT_NAME DESCRIPTION(for summary)
|
||||
// VALIDATOR_Fn
|
||||
opt = vpnui_opt_new(
|
||||
"connection-name", VPN_UI_OPTTYPE_STRING,
|
||||
NULL, "Description", _("Name"),
|
||||
G_CALLBACK(&editable_changed), &vld_non_empty, impl );
|
||||
impl->connection_name_opt = opt;
|
||||
|
||||
opt = vpnui_opt_new(
|
||||
"ppp-connection-type", VPN_UI_OPTTYPE_COMBO,
|
||||
"ppp-connection-type", "Connection-Type", NULL,
|
||||
G_CALLBACK(&variant_changed), NULL, impl );
|
||||
impl->variant_combo = GTK_COMBO_BOX(opt->widget);
|
||||
|
||||
opt = vpnui_opt_new(
|
||||
"pptp-remote", VPN_UI_OPTTYPE_STRING,
|
||||
"pptp-remote", "PPTP-Server", _("PPTP Server"),
|
||||
G_CALLBACK(&editable_changed), &vld_non_empty, impl );
|
||||
|
||||
opt = vpnui_opt_new(
|
||||
"phone-number", VPN_UI_OPTTYPE_STRING,
|
||||
"phone-number", "Telephone-Number", _("Telephone Number"),
|
||||
G_CALLBACK(&editable_changed), &vld_non_empty, impl );
|
||||
|
||||
opt = vpnui_opt_new(
|
||||
"bt-bdaddr", VPN_UI_OPTTYPE_STRING,
|
||||
"bt-bdaddr", "Bluetooth-Address", _("Bluetooth Address"),
|
||||
G_CALLBACK(&editable_changed), &vld_non_empty, impl );
|
||||
|
||||
opt = vpnui_opt_new(
|
||||
"bt-channel", VPN_UI_OPTTYPE_STRING,
|
||||
"bt-channel", "Bluetooth-Channel", _("Bluetooth Channel"),
|
||||
G_CALLBACK(&editable_changed), &vld_non_empty, impl );
|
||||
|
||||
opt = vpnui_opt_new(
|
||||
"gprs-apn", VPN_UI_OPTTYPE_STRING,
|
||||
"gprs-apn", "GPRS-Access-Point-Name", _("GPRS APN"),
|
||||
G_CALLBACK(&editable_changed), &vld_non_empty, impl );
|
||||
|
||||
opt = vpnui_opt_new(
|
||||
"gprs-ip-address", VPN_UI_OPTTYPE_STRING,
|
||||
"gprs-ip-address", "GPRS-IP-Address", _("GPRS IP"),
|
||||
G_CALLBACK(&editable_changed), &vld_non_empty, impl );
|
||||
|
||||
opt = vpnui_opt_new(
|
||||
"gprs-context-num", VPN_UI_OPTTYPE_STRING,
|
||||
"gprs-context-num", "GPRS-Context-Number", _("GPRS Context No."),
|
||||
G_CALLBACK(&editable_changed), &vld_non_empty, impl );
|
||||
|
||||
opt = vpnui_opt_new(
|
||||
"gprs-packet-type", VPN_UI_OPTTYPE_STRING,
|
||||
"gprs-packet-type", "GPRS-Packet-Type", _("GPRS Packet Type"),
|
||||
G_CALLBACK(&editable_changed), &vld_non_empty, impl );
|
||||
|
||||
opt = vpnui_opt_new(
|
||||
"ppp-crtscts", VPN_UI_OPTTYPE_YESNO,
|
||||
"ppp-crtscts", "PPP-Hardware-CTSRTS", _("Use CTS/RTS flow control"),
|
||||
G_CALLBACK(&editable_changed), NULL, impl );
|
||||
|
||||
opt = vpnui_opt_new(
|
||||
"ppp-modem", VPN_UI_OPTTYPE_YESNO,
|
||||
"ppp-modem", "PPP-Modem", _("Connect via a modem"),
|
||||
G_CALLBACK(&editable_changed), NULL, impl );
|
||||
|
||||
opt = vpnui_opt_new(
|
||||
"ppp-noipdefault", VPN_UI_OPTTYPE_YESNO,
|
||||
"ppp-noipdefault", "PPP-No-IP-Default", _("Require IP to be provided"),
|
||||
G_CALLBACK(&editable_changed), NULL, impl );
|
||||
|
||||
opt = vpnui_opt_new(
|
||||
"usepeerdns" , VPN_UI_OPTTYPE_YESNO ,
|
||||
"usepeerdns", "Use-Peer-DNS", _("Use Peer DNS"),
|
||||
NULL, NULL, impl );
|
||||
|
||||
opt = vpnui_opt_new(
|
||||
"encrypt-mppe" , VPN_UI_OPTTYPE_YESNO ,
|
||||
"encrypt-mppe", "Encrypt-MPPE", _("Use MPPE encryption"),
|
||||
NULL, NULL, impl );
|
||||
|
||||
opt = vpnui_opt_new(
|
||||
"encrypt-mppe-128" , VPN_UI_OPTTYPE_YESNO ,
|
||||
"encrypt-mppe-128", "Encrypt-MPPE-128", _("Use 128 bit MPPE encryption"),
|
||||
NULL, NULL, impl );
|
||||
|
||||
opt = vpnui_opt_new(
|
||||
"encrypt-mppe-stateful" , VPN_UI_OPTTYPE_YESNO ,
|
||||
"encrypt-mppe-stateful", "Encrypt-MPPE-Stateful", _("Enable stateful MPPE"),
|
||||
NULL, NULL, impl );
|
||||
|
||||
opt = vpnui_opt_new(
|
||||
"compress-mppc" , VPN_UI_OPTTYPE_YESNO ,
|
||||
"compress-mppc", "Compress-MPPC", _("Use MPPC compression"),
|
||||
NULL, NULL, impl );
|
||||
|
||||
opt = vpnui_opt_new(
|
||||
"compress-deflate" , VPN_UI_OPTTYPE_YESNO ,
|
||||
"compress-deflate", "Compress-Deflate", _("Do not use deflate compression"),
|
||||
NULL, NULL, impl );
|
||||
|
||||
opt = vpnui_opt_new(
|
||||
"compress-bsd" , VPN_UI_OPTTYPE_YESNO ,
|
||||
"compress-bsd", "Compress-BSD", _("Do not use BSD compression"),
|
||||
NULL, NULL, impl );
|
||||
|
||||
opt = vpnui_opt_new(
|
||||
"ppp-lock" , VPN_UI_OPTTYPE_YESNO ,
|
||||
"ppp-lock", "PPP-Lock", _("Exclusive device access by pppd"),
|
||||
NULL, NULL, impl );
|
||||
|
||||
opt = vpnui_opt_new(
|
||||
"ppp-auth-peer" , VPN_UI_OPTTYPE_YESNO ,
|
||||
"ppp-auth-peer", "Auth-Peer", _("Authenticate remote peer"),
|
||||
NULL, NULL, impl );
|
||||
|
||||
opt = vpnui_opt_new(
|
||||
"ppp-refuse-eap" , VPN_UI_OPTTYPE_YESNO ,
|
||||
"ppp-refuse-eap", "Refuse-EAP", _("Refuse EAP"),
|
||||
NULL, NULL, impl );
|
||||
|
||||
opt = vpnui_opt_new(
|
||||
"ppp-refuse-chap" , VPN_UI_OPTTYPE_YESNO ,
|
||||
"ppp-refuse-chap", "Refuse-CHAP", _("Refuse CHAP"),
|
||||
NULL, NULL, impl );
|
||||
|
||||
opt = vpnui_opt_new(
|
||||
"ppp-refuse-mschap" , VPN_UI_OPTTYPE_YESNO ,
|
||||
"ppp-refuse-mschap", "Refuse-MSCHAP", _("Refuse MSCHAP"),
|
||||
NULL, NULL, impl );
|
||||
|
||||
opt = vpnui_opt_new(
|
||||
"mtu" , VPN_UI_OPTTYPE_SPINNER ,
|
||||
"mtu", "MTU", _("Maximum transmit unit (in bytes)"),
|
||||
NULL, NULL, impl );
|
||||
|
||||
opt = vpnui_opt_new(
|
||||
"mru" , VPN_UI_OPTTYPE_SPINNER ,
|
||||
"mru", "MRU", _("Maximum receive unit (in bytes)"),
|
||||
NULL, NULL, impl );
|
||||
|
||||
opt = vpnui_opt_new(
|
||||
"lcp-echo-failure" , VPN_UI_OPTTYPE_SPINNER ,
|
||||
"lcp-echo-failure", "LCP-Echo-Failure", _("Number of failed LCP echos to cause disconnect"),
|
||||
NULL, NULL, impl );
|
||||
|
||||
opt = vpnui_opt_new(
|
||||
"lcp-echo-interval" , VPN_UI_OPTTYPE_SPINNER ,
|
||||
"lcp-echo-interval", "LCP-Echo-Interval", _("Interval (in seconds) at which to issue LCP echos"),
|
||||
NULL, NULL, impl );
|
||||
|
||||
opt = vpnui_opt_new(
|
||||
"ppp-connect-delay" , VPN_UI_OPTTYPE_SPINNER ,
|
||||
"ppp-connect-delay", "PPP-Connect-Delay", _("Interval (in milliseconds) to wait before connecting."),
|
||||
NULL, NULL, impl );
|
||||
|
||||
opt = vpnui_opt_new(
|
||||
"ppp-extra", VPN_UI_OPTTYPE_STRING,
|
||||
"ppp-extra", "PPP-Custom-Options", _("Custom PPP options"),
|
||||
G_CALLBACK(&editable_changed), NULL, impl );
|
||||
|
||||
opt = vpnui_opt_new(
|
||||
"ppp-debug" , VPN_UI_OPTTYPE_YESNO ,
|
||||
"ppp-debug", NULL, NULL,
|
||||
NULL, NULL, impl );
|
||||
|
||||
opt = vpnui_opt_new(
|
||||
"usepeerdns-overtunnel" , VPN_UI_OPTTYPE_YESNO ,
|
||||
"usepeerdns-overtunnel", "Peer-DNS-Over-Tunnel", _("Use Peer DNS over the Tunnel"),
|
||||
NULL, NULL, impl );
|
||||
|
||||
|
||||
opt = vpnui_opt_new(
|
||||
"routes" , VPN_UI_OPTTYPE_STRING ,
|
||||
"routes", "X-NM-Routes", _("Specific networks available"),
|
||||
G_CALLBACK(&editable_changed), &vld_routes_if_sens, impl );
|
||||
impl->routes_opt = opt;
|
||||
|
||||
opt = vpnui_opt_new(
|
||||
"use-routes" , VPN_UI_OPTTYPE_YESNO ,
|
||||
"use-routes", "Use-Routes", _("Limit to specific networks"),
|
||||
G_CALLBACK(&use_routes_toggled), NULL, impl );
|
||||
impl->routes_toggle_opt = opt;
|
||||
|
||||
variant = vpnui_variant_new( "pptp","Windows VPN (PPTP)",
|
||||
VPNUI_BASIC_DEFAULTS VPNUI_PPTP_DEFAULTS,
|
||||
impl);
|
||||
|
||||
#ifdef BUILD_BLUETOOTH
|
||||
variant = vpnui_variant_new( "btgprs", "GPRS over Bluetooth (via mobile phone)",
|
||||
VPNUI_BASIC_DEFAULTS VPNUI_GPRS_DEFAULTS VPNUI_BTOOTH_DEFAULTS VPNUI_BTGPRS_DEFAULTS,
|
||||
impl);
|
||||
#endif
|
||||
|
||||
variant = vpnui_variant_new( "dialup", "Dialup",
|
||||
VPNUI_BASIC_DEFAULTS VPNUI_DIALUP_DEFAULTS,
|
||||
impl);
|
||||
//
|
||||
// GLADE NAME IMPLEMENTATION_OBJ
|
||||
// expand= vpnui_expand_new ("routing-expander",impl);
|
||||
// expand= vpnui_expand_new ("dialup-expander",impl);
|
||||
// expand= vpnui_expand_new ("pppd-expander",impl);
|
||||
// expand= vpnui_expand_new ("pptp-expander",impl);
|
||||
// expand= vpnui_expand_new ("bluetooth-expander",impl);
|
||||
// expand= vpnui_expand_new ("serial-expander",impl);
|
||||
// expand= vpnui_expand_new ("gprs-expander",impl);
|
||||
|
||||
// Attach to press event of the Bluetooth "Find Device" button.
|
||||
// will need libbtcl
|
||||
// impl->w_import_button = GTK_BUTTON (glade_xml_get_widget (impl->xml,
|
||||
// "import-button"));
|
||||
|
||||
// Attach an import_button
|
||||
impl->w_import_button = GTK_BUTTON (glade_xml_get_widget (impl->xml,
|
||||
"import-config-button"));
|
||||
}
|
||||
|
||||
void
|
||||
use_routes_toggled (GtkToggleButton *togglebutton, gpointer user_data)
|
||||
{
|
||||
NetworkManagerVpnUIImpl *impl = (NetworkManagerVpnUIImpl *) user_data;
|
||||
VpnUIConfigOption *opt = impl_opt_byglade(impl,"routes");
|
||||
|
||||
if (opt!=NULL) gtk_widget_set_sensitive (GTK_WIDGET (opt->widget),
|
||||
gtk_toggle_button_get_active (togglebutton));
|
||||
|
||||
if (impl->callback != NULL) {
|
||||
gboolean is_valid;
|
||||
|
||||
is_valid = impl_is_valid (&(impl->parent));
|
||||
impl->callback (&(impl->parent), is_valid, impl->callback_user_data);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
editable_changed (GtkEditable *editable, gpointer user_data)
|
||||
{
|
||||
NetworkManagerVpnUIImpl *impl = (NetworkManagerVpnUIImpl *) user_data;
|
||||
|
||||
if (impl->callback != NULL) {
|
||||
gboolean is_valid;
|
||||
|
||||
is_valid = impl_is_valid (&(impl->parent));
|
||||
impl->callback (&(impl->parent), is_valid, impl->callback_user_data);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
variant_changed (GtkComboBox *combo, gpointer user_data)
|
||||
{
|
||||
NetworkManagerVpnUIImpl *impl = (NetworkManagerVpnUIImpl *) user_data;
|
||||
char *variant_name;
|
||||
|
||||
|
||||
variant_name=gtk_combo_box_get_active_text(combo);
|
||||
|
||||
vpnui_variant_select_byname(impl,variant_name);
|
||||
|
||||
impl_hide_and_show(impl);
|
||||
|
||||
// vpnui_expand_reset_all(impl);
|
||||
|
||||
if (impl->callback != NULL) {
|
||||
gboolean is_valid;
|
||||
|
||||
is_valid = impl_is_valid (&(impl->parent));
|
||||
impl->callback (&(impl->parent), is_valid, impl->callback_user_data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
impl_hide_and_show (NetworkManagerVpnUIImpl *impl)
|
||||
{
|
||||
GtkWidget *serial_options = NULL;
|
||||
GtkWidget *gprs_options = NULL;
|
||||
GtkWidget *auth_options = NULL;
|
||||
GtkWidget *comp_enc_options = NULL;
|
||||
GtkWidget *routing_options = NULL;
|
||||
GtkWidget *ppp_options = NULL;
|
||||
GtkWidget *bluetooth_front = NULL;
|
||||
GtkWidget *pptp_front = NULL;
|
||||
GtkWidget *dialup_front = NULL;
|
||||
GtkComboBox *combo = NULL;
|
||||
char *variant_name;
|
||||
|
||||
if (impl==NULL) return;
|
||||
if (impl->xml==NULL) return;
|
||||
|
||||
combo = GTK_COMBO_BOX(glade_xml_get_widget(impl->xml, "ppp-connection-type"));
|
||||
if (combo==NULL) return;
|
||||
|
||||
ppp_options = glade_xml_get_widget(impl->xml, "ppp-options");
|
||||
auth_options = glade_xml_get_widget(impl->xml, "auth-options");
|
||||
comp_enc_options = glade_xml_get_widget(impl->xml, "comp-enc-options");
|
||||
routing_options = glade_xml_get_widget(impl->xml, "routing-options");
|
||||
gprs_options = glade_xml_get_widget(impl->xml, "gprs-options");
|
||||
serial_options = glade_xml_get_widget(impl->xml, "serial-options");
|
||||
bluetooth_front = glade_xml_get_widget(impl->xml, "bluetooth-front");
|
||||
dialup_front = glade_xml_get_widget(impl->xml, "dialup-front");
|
||||
pptp_front = glade_xml_get_widget(impl->xml, "pptp-front");
|
||||
|
||||
if (pptp_front) gtk_widget_hide(pptp_front);
|
||||
if (bluetooth_front) gtk_widget_hide(bluetooth_front);
|
||||
if (dialup_front) gtk_widget_hide(dialup_front);
|
||||
if (gprs_options) gtk_widget_hide(gprs_options);
|
||||
if (serial_options) gtk_widget_hide(serial_options);
|
||||
if (ppp_options) gtk_widget_hide(ppp_options);
|
||||
if (auth_options) gtk_widget_hide(auth_options);
|
||||
if (comp_enc_options) gtk_widget_hide(comp_enc_options);
|
||||
if (routing_options) gtk_widget_hide(routing_options);
|
||||
|
||||
variant_name=gtk_combo_box_get_active_text(combo);
|
||||
if (variant_name==NULL) return;
|
||||
|
||||
if (strcmp(variant_name,"pptp")==0) {
|
||||
if (pptp_front) gtk_widget_show(pptp_front);
|
||||
if (ppp_options) gtk_widget_show(ppp_options);
|
||||
if (auth_options) gtk_widget_show(auth_options);
|
||||
if (comp_enc_options) gtk_widget_show(comp_enc_options);
|
||||
if (routing_options) gtk_widget_show(routing_options);
|
||||
} else if (strcmp(variant_name,"dialup")==0) {
|
||||
if (dialup_front) gtk_widget_show(dialup_front);
|
||||
if (serial_options) gtk_widget_show(serial_options);
|
||||
if (ppp_options) gtk_widget_show(ppp_options);
|
||||
if (auth_options) gtk_widget_show(auth_options);
|
||||
if (comp_enc_options) gtk_widget_show(comp_enc_options);
|
||||
if (routing_options) gtk_widget_show(routing_options);
|
||||
} else if (strcmp(variant_name,"btgprs")==0) {
|
||||
if (bluetooth_front) gtk_widget_show(bluetooth_front);
|
||||
if (gprs_options) gtk_widget_show(gprs_options);
|
||||
if (serial_options) gtk_widget_show(serial_options);
|
||||
if (ppp_options) gtk_widget_show(ppp_options);
|
||||
if (auth_options) gtk_widget_show(auth_options);
|
||||
if (comp_enc_options) gtk_widget_show(comp_enc_options);
|
||||
if (routing_options) gtk_widget_show(routing_options);
|
||||
}
|
||||
}
|
||||
538
vpn-daemons/pptp/properties/nm-pptp-dialog.glade
Normal file
538
vpn-daemons/pptp/properties/nm-pptp-dialog.glade
Normal file
|
|
@ -0,0 +1,538 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
|
||||
<!--*- mode: xml -*-->
|
||||
<glade-interface>
|
||||
<widget class="GtkWindow" id="pptp-widget">
|
||||
<property name="title" translatable="yes">window1</property>
|
||||
<child>
|
||||
<widget class="GtkVBox" id="pptp-vbox">
|
||||
<property name="visible">True</property>
|
||||
<property name="border_width">12</property>
|
||||
<property name="spacing">16</property>
|
||||
<child>
|
||||
<widget class="GtkVBox" id="vbox8">
|
||||
<property name="visible">True</property>
|
||||
<property name="spacing">6</property>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label22">
|
||||
<property name="visible">True</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label" translatable="yes"><b>General</b></property>
|
||||
<property name="use_markup">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkAlignment" id="alignment8">
|
||||
<property name="visible">True</property>
|
||||
<property name="left_padding">12</property>
|
||||
<child>
|
||||
<widget class="GtkTable" id="table2">
|
||||
<property name="visible">True</property>
|
||||
<property name="n_rows">1</property>
|
||||
<property name="n_columns">2</property>
|
||||
<property name="column_spacing">6</property>
|
||||
<property name="row_spacing">6</property>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label23">
|
||||
<property name="visible">True</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label" translatable="yes">_Gateway:</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="mnemonic_widget">gateway_entry</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="x_options">GTK_FILL</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkEntry" id="gateway_entry">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="right_attach">2</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkVBox" id="vbox11">
|
||||
<property name="visible">True</property>
|
||||
<property name="spacing">6</property>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label25">
|
||||
<property name="visible">True</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label" translatable="yes"><b>Optional</b></property>
|
||||
<property name="use_markup">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkAlignment" id="alignment9">
|
||||
<property name="visible">True</property>
|
||||
<property name="left_padding">12</property>
|
||||
<child>
|
||||
<widget class="GtkTable" id="table3">
|
||||
<property name="visible">True</property>
|
||||
<property name="n_rows">2</property>
|
||||
<property name="n_columns">2</property>
|
||||
<property name="column_spacing">6</property>
|
||||
<property name="row_spacing">6</property>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label26">
|
||||
<property name="visible">True</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label" translatable="yes">User name:</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="x_options">GTK_FILL</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkEntry" id="user_entry">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="right_attach">2</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label27">
|
||||
<property name="visible">True</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label" translatable="yes">Domain:</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="top_attach">1</property>
|
||||
<property name="bottom_attach">2</property>
|
||||
<property name="x_options">GTK_FILL</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkEntry" id="domain_entry">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="right_attach">2</property>
|
||||
<property name="top_attach">1</property>
|
||||
<property name="bottom_attach">2</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkAlignment" id="alignment1">
|
||||
<property name="visible">True</property>
|
||||
<property name="xalign">1</property>
|
||||
<property name="xscale">0</property>
|
||||
<child>
|
||||
<widget class="GtkButton" id="advanced_button">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="response_id">0</property>
|
||||
<child>
|
||||
<widget class="GtkHBox" id="hbox2">
|
||||
<property name="visible">True</property>
|
||||
<property name="spacing">6</property>
|
||||
<child>
|
||||
<widget class="GtkImage" id="image1">
|
||||
<property name="visible">True</property>
|
||||
<property name="stock">gtk-preferences</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label1">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Ad_vanced...</property>
|
||||
<property name="use_markup">True</property>
|
||||
<property name="use_underline">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="pack_type">GTK_PACK_END</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<widget class="GtkDialog" id="pptp-advanced-dialog">
|
||||
<property name="border_width">5</property>
|
||||
<property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
|
||||
<property name="destroy_with_parent">True</property>
|
||||
<property name="icon_name">stock-preferences</property>
|
||||
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
|
||||
<property name="skip_pager_hint">True</property>
|
||||
<property name="has_separator">False</property>
|
||||
<child internal-child="vbox">
|
||||
<widget class="GtkVBox" id="dialog-vbox3">
|
||||
<property name="visible">True</property>
|
||||
<property name="spacing">2</property>
|
||||
<child>
|
||||
<widget class="GtkVBox" id="PppPage">
|
||||
<property name="visible">True</property>
|
||||
<property name="border_width">12</property>
|
||||
<property name="spacing">16</property>
|
||||
<child>
|
||||
<widget class="GtkVBox" id="vbox2">
|
||||
<property name="visible">True</property>
|
||||
<property name="spacing">6</property>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label28">
|
||||
<property name="visible">True</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label" translatable="yes"><b>Authentication</b></property>
|
||||
<property name="use_markup">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkAlignment" id="alignment2">
|
||||
<property name="visible">True</property>
|
||||
<property name="left_padding">12</property>
|
||||
<child>
|
||||
<widget class="GtkVBox" id="vbox4">
|
||||
<property name="visible">True</property>
|
||||
<property name="spacing">6</property>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="auth_methods_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label" translatable="yes">Allow the following authentication methods:</property>
|
||||
</widget>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkScrolledWindow" id="scrolledwindow1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
|
||||
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
|
||||
<property name="shadow_type">GTK_SHADOW_IN</property>
|
||||
<child>
|
||||
<widget class="GtkTreeView" id="ppp_auth_methods">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="headers_visible">False</property>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkVBox" id="vbox5">
|
||||
<property name="visible">True</property>
|
||||
<property name="spacing">6</property>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label29">
|
||||
<property name="visible">True</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label" translatable="yes"><b>Security and Compression</b></property>
|
||||
<property name="use_markup">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkAlignment" id="alignment3">
|
||||
<property name="visible">True</property>
|
||||
<property name="left_padding">12</property>
|
||||
<child>
|
||||
<widget class="GtkVBox" id="vbox6">
|
||||
<property name="visible">True</property>
|
||||
<child>
|
||||
<widget class="GtkVBox" id="vbox7">
|
||||
<property name="visible">True</property>
|
||||
<child>
|
||||
<widget class="GtkCheckButton" id="ppp_use_mppe">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label" translatable="yes">Use Point-to-Point Encryption (MPPE)</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="response_id">0</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkAlignment" id="alignment4">
|
||||
<property name="visible">True</property>
|
||||
<property name="left_padding">12</property>
|
||||
<child>
|
||||
<widget class="GtkVBox" id="vbox1">
|
||||
<property name="visible">True</property>
|
||||
<child>
|
||||
<widget class="GtkHBox" id="hbox1">
|
||||
<property name="visible">True</property>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="ppp_mppe_security_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label" translatable="yes">Security:</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="padding">6</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkComboBox" id="ppp_mppe_security_combo">
|
||||
<property name="visible">True</property>
|
||||
<property name="items" translatable="yes">Default</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkCheckButton" id="ppp_allow_stateful_mppe">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label" translatable="yes">Allow Stateful Encryption</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="response_id">0</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkCheckButton" id="ppp_allow_bsdcomp">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label" translatable="yes">Allow BSD data compression</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="response_id">0</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkCheckButton" id="ppp_allow_deflate">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label" translatable="yes">Allow Deflate data compression</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="response_id">0</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkCheckButton" id="ppp_usevj">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label" translatable="yes">Use TCP header compression</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="response_id">0</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkVBox" id="vbox9">
|
||||
<property name="visible">True</property>
|
||||
<property name="spacing">6</property>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label31">
|
||||
<property name="visible">True</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label" translatable="yes"><b>Echo</b></property>
|
||||
<property name="use_markup">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkAlignment" id="alignment5">
|
||||
<property name="visible">True</property>
|
||||
<property name="left_padding">12</property>
|
||||
<child>
|
||||
<widget class="GtkCheckButton" id="ppp_send_echo_packets">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label" translatable="yes">Send PPP echo packets</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="response_id">0</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child internal-child="action_area">
|
||||
<widget class="GtkHButtonBox" id="dialog-action_area3">
|
||||
<property name="visible">True</property>
|
||||
<property name="layout_style">GTK_BUTTONBOX_END</property>
|
||||
<child>
|
||||
<widget class="GtkButton" id="cancel_button">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="label" translatable="yes">gtk-cancel</property>
|
||||
<property name="use_stock">True</property>
|
||||
<property name="response_id">-6</property>
|
||||
</widget>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkButton" id="ok_button">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="label" translatable="yes">gtk-ok</property>
|
||||
<property name="use_stock">True</property>
|
||||
<property name="response_id">-5</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="pack_type">GTK_PACK_END</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
</glade-interface>
|
||||
654
vpn-daemons/pptp/properties/nm-pptp.c
Normal file
654
vpn-daemons/pptp/properties/nm-pptp.c
Normal file
|
|
@ -0,0 +1,654 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
||||
/***************************************************************************
|
||||
* nm-pptp.c : GNOME UI dialogs for configuring PPTP VPN connections
|
||||
*
|
||||
* Copyright (C) 2008 Dan Williams, <dcbw@redhat.com>
|
||||
* Based on work by David Zeuthen, <davidz@redhat.com>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <glib/gi18n-lib.h>
|
||||
#include <string.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <glade/glade.h>
|
||||
|
||||
#define NM_VPN_API_SUBJECT_TO_CHANGE
|
||||
|
||||
#include <nm-vpn-plugin-ui-interface.h>
|
||||
#include <nm-setting-vpn.h>
|
||||
#include <nm-setting-vpn-properties.h>
|
||||
#include <nm-setting-connection.h>
|
||||
#include <nm-setting-ip4-config.h>
|
||||
|
||||
#include "../src/nm-pptp-service.h"
|
||||
#include "nm-pptp.h"
|
||||
#include "import-export.h"
|
||||
#include "advanced-dialog.h"
|
||||
|
||||
#define PPTP_PLUGIN_NAME _("Point-to-Point Tunneling Protocol (PPTP)")
|
||||
#define PPTP_PLUGIN_DESC _("Compatible with Microsoft and other PPTP VPN servers.")
|
||||
#define PPTP_PLUGIN_SERVICE NM_DBUS_SERVICE_PPTP
|
||||
|
||||
|
||||
/************** plugin class **************/
|
||||
|
||||
static void pptp_plugin_ui_interface_init (NMVpnPluginUiInterface *iface_class);
|
||||
|
||||
G_DEFINE_TYPE_EXTENDED (PptpPluginUi, pptp_plugin_ui, G_TYPE_OBJECT, 0,
|
||||
G_IMPLEMENT_INTERFACE (NM_TYPE_VPN_PLUGIN_UI_INTERFACE,
|
||||
pptp_plugin_ui_interface_init))
|
||||
|
||||
/************** UI widget class **************/
|
||||
|
||||
static void pptp_plugin_ui_widget_interface_init (NMVpnPluginUiWidgetInterface *iface_class);
|
||||
|
||||
G_DEFINE_TYPE_EXTENDED (PptpPluginUiWidget, pptp_plugin_ui_widget, G_TYPE_OBJECT, 0,
|
||||
G_IMPLEMENT_INTERFACE (NM_TYPE_VPN_PLUGIN_UI_WIDGET_INTERFACE,
|
||||
pptp_plugin_ui_widget_interface_init))
|
||||
|
||||
#define PPTP_PLUGIN_UI_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), PPTP_TYPE_PLUGIN_UI_WIDGET, PptpPluginUiWidgetPrivate))
|
||||
|
||||
typedef struct {
|
||||
GladeXML *xml;
|
||||
GtkWidget *widget;
|
||||
GtkSizeGroup *group;
|
||||
GtkWindowGroup *window_group;
|
||||
gboolean window_added;
|
||||
GHashTable *advanced;
|
||||
} PptpPluginUiWidgetPrivate;
|
||||
|
||||
|
||||
GQuark
|
||||
pptp_plugin_ui_error_quark (void)
|
||||
{
|
||||
static GQuark error_quark = 0;
|
||||
|
||||
if (G_UNLIKELY (error_quark == 0))
|
||||
error_quark = g_quark_from_static_string ("pptp-plugin-ui-error-quark");
|
||||
|
||||
return error_quark;
|
||||
}
|
||||
|
||||
/* This should really be standard. */
|
||||
#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC }
|
||||
|
||||
GType
|
||||
pptp_plugin_ui_error_get_type (void)
|
||||
{
|
||||
static GType etype = 0;
|
||||
|
||||
if (etype == 0) {
|
||||
static const GEnumValue values[] = {
|
||||
/* Unknown error. */
|
||||
ENUM_ENTRY (PPTP_PLUGIN_UI_ERROR_UNKNOWN, "UnknownError"),
|
||||
/* The specified property was invalid. */
|
||||
ENUM_ENTRY (PPTP_PLUGIN_UI_ERROR_INVALID_PROPERTY, "InvalidProperty"),
|
||||
/* The specified property was missing and is required. */
|
||||
ENUM_ENTRY (PPTP_PLUGIN_UI_ERROR_MISSING_PROPERTY, "MissingProperty"),
|
||||
/* The file to import could not be read. */
|
||||
ENUM_ENTRY (PPTP_PLUGIN_UI_ERROR_FILE_NOT_READABLE, "FileNotReadable"),
|
||||
/* The file to import could was not an PPTP client file. */
|
||||
ENUM_ENTRY (PPTP_PLUGIN_UI_ERROR_FILE_NOT_PPTP, "FileNotPPTP"),
|
||||
{ 0, 0, 0 }
|
||||
};
|
||||
etype = g_enum_register_static ("PptpPluginUiError", values);
|
||||
}
|
||||
return etype;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
check_validity (PptpPluginUiWidget *self, GError **error)
|
||||
{
|
||||
PptpPluginUiWidgetPrivate *priv = PPTP_PLUGIN_UI_WIDGET_GET_PRIVATE (self);
|
||||
GtkWidget *widget;
|
||||
const char *str;
|
||||
GtkTreeModel *model;
|
||||
GtkTreeIter iter;
|
||||
|
||||
widget = glade_xml_get_widget (priv->xml, "gateway_entry");
|
||||
str = gtk_entry_get_text (GTK_ENTRY (widget));
|
||||
if (!str || !strlen (str)) {
|
||||
g_set_error (error,
|
||||
PPTP_PLUGIN_UI_ERROR,
|
||||
PPTP_PLUGIN_UI_ERROR_INVALID_PROPERTY,
|
||||
NM_PPTP_KEY_GATEWAY);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
stuff_changed_cb (GtkWidget *widget, gpointer user_data)
|
||||
{
|
||||
g_signal_emit_by_name (PPTP_PLUGIN_UI_WIDGET (user_data), "changed");
|
||||
}
|
||||
|
||||
static void
|
||||
advanced_dialog_close_cb (GtkWidget *dialog, gpointer user_data)
|
||||
{
|
||||
PptpPluginUiWidget *self = PPTP_PLUGIN_UI_WIDGET (user_data);
|
||||
|
||||
gtk_widget_hide (dialog);
|
||||
/* gtk_widget_destroy() will remove the window from the window group */
|
||||
gtk_widget_destroy (dialog);
|
||||
}
|
||||
|
||||
static void
|
||||
advanced_dialog_response_cb (GtkWidget *dialog, gint response, gpointer user_data)
|
||||
{
|
||||
PptpPluginUiWidget *self = PPTP_PLUGIN_UI_WIDGET (user_data);
|
||||
PptpPluginUiWidgetPrivate *priv = PPTP_PLUGIN_UI_WIDGET_GET_PRIVATE (self);
|
||||
GError *error = NULL;
|
||||
|
||||
if (response != GTK_RESPONSE_OK) {
|
||||
advanced_dialog_close_cb (dialog, self);
|
||||
return;
|
||||
}
|
||||
|
||||
if (priv->advanced)
|
||||
g_hash_table_destroy (priv->advanced);
|
||||
priv->advanced = advanced_dialog_new_hash_from_dialog (dialog, &error);
|
||||
if (!priv->advanced) {
|
||||
g_message ("%s: error reading advanced settings: %s", __func__, error->message);
|
||||
g_error_free (error);
|
||||
}
|
||||
advanced_dialog_close_cb (dialog, self);
|
||||
|
||||
stuff_changed_cb (NULL, self);
|
||||
}
|
||||
|
||||
static void
|
||||
advanced_button_clicked_cb (GtkWidget *button, gpointer user_data)
|
||||
{
|
||||
PptpPluginUiWidget *self = PPTP_PLUGIN_UI_WIDGET (user_data);
|
||||
PptpPluginUiWidgetPrivate *priv = PPTP_PLUGIN_UI_WIDGET_GET_PRIVATE (self);
|
||||
GtkWidget *dialog, *toplevel, *widget;
|
||||
|
||||
toplevel = gtk_widget_get_toplevel (priv->widget);
|
||||
g_return_if_fail (GTK_WIDGET_TOPLEVEL (toplevel));
|
||||
|
||||
dialog = advanced_dialog_new (priv->advanced);
|
||||
if (!dialog) {
|
||||
g_warning ("%s: failed to create the Advanced dialog!", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
gtk_window_group_add_window (priv->window_group, GTK_WINDOW (dialog));
|
||||
if (!priv->window_added) {
|
||||
gtk_window_group_add_window (priv->window_group, GTK_WINDOW (toplevel));
|
||||
priv->window_added = TRUE;
|
||||
}
|
||||
|
||||
gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (toplevel));
|
||||
g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (advanced_dialog_response_cb), self);
|
||||
g_signal_connect (G_OBJECT (dialog), "close", G_CALLBACK (advanced_dialog_close_cb), self);
|
||||
|
||||
gtk_widget_show_all (dialog);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
init_plugin_ui (PptpPluginUiWidget *self, NMConnection *connection, GError **error)
|
||||
{
|
||||
PptpPluginUiWidgetPrivate *priv = PPTP_PLUGIN_UI_WIDGET_GET_PRIVATE (self);
|
||||
NMSettingVPNProperties *s_vpn_props;
|
||||
GtkWidget *widget;
|
||||
GtkListStore *store;
|
||||
GtkTreeIter iter;
|
||||
int active = -1;
|
||||
GValue *value;
|
||||
|
||||
s_vpn_props = (NMSettingVPNProperties *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN_PROPERTIES);
|
||||
|
||||
priv->group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
|
||||
|
||||
widget = glade_xml_get_widget (priv->xml, "gateway_entry");
|
||||
if (!widget)
|
||||
return FALSE;
|
||||
gtk_size_group_add_widget (priv->group, widget);
|
||||
if (s_vpn_props) {
|
||||
value = g_hash_table_lookup (s_vpn_props->data, NM_PPTP_KEY_GATEWAY);
|
||||
if (value && G_VALUE_HOLDS_STRING (value))
|
||||
gtk_entry_set_text (GTK_ENTRY (widget), g_value_get_string (value));
|
||||
}
|
||||
g_signal_connect (G_OBJECT (widget), "changed", G_CALLBACK (stuff_changed_cb), self);
|
||||
|
||||
widget = glade_xml_get_widget (priv->xml, "user_entry");
|
||||
if (!widget)
|
||||
return FALSE;
|
||||
gtk_size_group_add_widget (priv->group, widget);
|
||||
if (s_vpn_props) {
|
||||
value = g_hash_table_lookup (s_vpn_props->data, NM_PPTP_KEY_USER);
|
||||
if (value && G_VALUE_HOLDS_STRING (value))
|
||||
gtk_entry_set_text (GTK_ENTRY (widget), g_value_get_string (value));
|
||||
}
|
||||
g_signal_connect (G_OBJECT (widget), "changed", G_CALLBACK (stuff_changed_cb), self);
|
||||
|
||||
widget = glade_xml_get_widget (priv->xml, "domain_entry");
|
||||
if (!widget)
|
||||
return FALSE;
|
||||
gtk_size_group_add_widget (priv->group, widget);
|
||||
if (s_vpn_props) {
|
||||
value = g_hash_table_lookup (s_vpn_props->data, NM_PPTP_KEY_DOMAIN);
|
||||
if (value && G_VALUE_HOLDS_STRING (value))
|
||||
gtk_entry_set_text (GTK_ENTRY (widget), g_value_get_string (value));
|
||||
}
|
||||
g_signal_connect (G_OBJECT (widget), "changed", G_CALLBACK (stuff_changed_cb), self);
|
||||
|
||||
widget = glade_xml_get_widget (priv->xml, "advanced_button");
|
||||
g_signal_connect (G_OBJECT (widget), "clicked", G_CALLBACK (advanced_button_clicked_cb), self);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static GObject *
|
||||
get_widget (NMVpnPluginUiWidgetInterface *iface)
|
||||
{
|
||||
PptpPluginUiWidget *self = PPTP_PLUGIN_UI_WIDGET (iface);
|
||||
PptpPluginUiWidgetPrivate *priv = PPTP_PLUGIN_UI_WIDGET_GET_PRIVATE (self);
|
||||
|
||||
return G_OBJECT (priv->widget);
|
||||
}
|
||||
|
||||
GValue *
|
||||
str_to_gvalue (const char *str)
|
||||
{
|
||||
GValue *value;
|
||||
|
||||
value = g_slice_new0 (GValue);
|
||||
g_value_init (value, G_TYPE_STRING);
|
||||
g_value_set_string (value, str);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
GValue *
|
||||
bool_to_gvalue (gboolean b)
|
||||
{
|
||||
GValue *value;
|
||||
|
||||
value = g_slice_new0 (GValue);
|
||||
g_value_init (value, G_TYPE_BOOLEAN);
|
||||
g_value_set_boolean (value, b);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
GValue *
|
||||
int_to_gvalue (gint i)
|
||||
{
|
||||
GValue *value;
|
||||
|
||||
value = g_slice_new0 (GValue);
|
||||
g_value_init (value, G_TYPE_INT);
|
||||
g_value_set_int (value, i);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
GValue *
|
||||
uint_to_gvalue (guint32 u)
|
||||
{
|
||||
GValue *value;
|
||||
|
||||
value = g_slice_new0 (GValue);
|
||||
g_value_init (value, G_TYPE_UINT);
|
||||
g_value_set_uint (value, u);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
static void
|
||||
hash_copy_advanced (gpointer key, gpointer data, gpointer user_data)
|
||||
{
|
||||
GHashTable *hash = (GHashTable *) user_data;
|
||||
GValue *value = (GValue *) data;
|
||||
|
||||
if (G_VALUE_HOLDS_STRING (value)) {
|
||||
g_hash_table_insert (hash,
|
||||
g_strdup ((const char *) key),
|
||||
str_to_gvalue (g_value_get_string (value)));
|
||||
} else if (G_VALUE_HOLDS_INT (value)) {
|
||||
g_hash_table_insert (hash,
|
||||
g_strdup ((const char *) key),
|
||||
int_to_gvalue (g_value_get_int (value)));
|
||||
} else if (G_VALUE_HOLDS_BOOLEAN (value)) {
|
||||
g_hash_table_insert (hash,
|
||||
g_strdup ((const char *) key),
|
||||
bool_to_gvalue (g_value_get_boolean (value)));
|
||||
} else {
|
||||
g_warning ("%s: unhandled key '%s' of type '%s'",
|
||||
__func__, (const char *) key, G_VALUE_TYPE_NAME (value));
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
update_connection (NMVpnPluginUiWidgetInterface *iface,
|
||||
NMConnection *connection,
|
||||
GError **error)
|
||||
{
|
||||
PptpPluginUiWidget *self = PPTP_PLUGIN_UI_WIDGET (iface);
|
||||
PptpPluginUiWidgetPrivate *priv = PPTP_PLUGIN_UI_WIDGET_GET_PRIVATE (self);
|
||||
NMSettingVPN *s_vpn;
|
||||
NMSettingVPNProperties *s_vpn_props;
|
||||
GtkWidget *widget;
|
||||
char *str;
|
||||
GtkTreeModel *model;
|
||||
GtkTreeIter iter;
|
||||
gboolean valid = FALSE;
|
||||
|
||||
if (!check_validity (self, error))
|
||||
return FALSE;
|
||||
|
||||
s_vpn = NM_SETTING_VPN (nm_setting_vpn_new ());
|
||||
s_vpn->service_type = g_strdup (NM_DBUS_SERVICE_PPTP);
|
||||
nm_connection_add_setting (connection, NM_SETTING (s_vpn));
|
||||
|
||||
s_vpn_props = NM_SETTING_VPN_PROPERTIES (nm_setting_vpn_properties_new ());
|
||||
|
||||
/* Gateway */
|
||||
widget = glade_xml_get_widget (priv->xml, "gateway_entry");
|
||||
str = (char *) gtk_entry_get_text (GTK_ENTRY (widget));
|
||||
if (str && strlen (str)) {
|
||||
g_hash_table_insert (s_vpn_props->data,
|
||||
g_strdup (NM_PPTP_KEY_GATEWAY),
|
||||
str_to_gvalue (str));
|
||||
}
|
||||
|
||||
/* Username */
|
||||
widget = glade_xml_get_widget (priv->xml, "user_entry");
|
||||
str = (char *) gtk_entry_get_text (GTK_ENTRY (widget));
|
||||
if (str && strlen (str)) {
|
||||
g_hash_table_insert (s_vpn_props->data,
|
||||
g_strdup (NM_PPTP_KEY_USER),
|
||||
str_to_gvalue (str));
|
||||
}
|
||||
|
||||
/* Domain */
|
||||
widget = glade_xml_get_widget (priv->xml, "domain_entry");
|
||||
str = (char *) gtk_entry_get_text (GTK_ENTRY (widget));
|
||||
if (str && strlen (str)) {
|
||||
g_hash_table_insert (s_vpn_props->data,
|
||||
g_strdup (NM_PPTP_KEY_DOMAIN),
|
||||
str_to_gvalue (str));
|
||||
}
|
||||
|
||||
if (priv->advanced)
|
||||
g_hash_table_foreach (priv->advanced, hash_copy_advanced, s_vpn_props->data);
|
||||
|
||||
nm_connection_add_setting (connection, NM_SETTING (s_vpn_props));
|
||||
valid = TRUE;
|
||||
|
||||
done:
|
||||
return valid;
|
||||
}
|
||||
|
||||
static NMVpnPluginUiWidgetInterface *
|
||||
nm_vpn_plugin_ui_widget_interface_new (NMConnection *connection, GError **error)
|
||||
{
|
||||
NMVpnPluginUiWidgetInterface *object;
|
||||
PptpPluginUiWidgetPrivate *priv;
|
||||
char *glade_file;
|
||||
|
||||
if (error)
|
||||
g_return_val_if_fail (*error == NULL, NULL);
|
||||
|
||||
object = NM_VPN_PLUGIN_UI_WIDGET_INTERFACE (g_object_new (PPTP_TYPE_PLUGIN_UI_WIDGET, NULL));
|
||||
if (!object) {
|
||||
g_set_error (error, PPTP_PLUGIN_UI_ERROR, 0, "could not create pptp object");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
priv = PPTP_PLUGIN_UI_WIDGET_GET_PRIVATE (object);
|
||||
|
||||
glade_file = g_strdup_printf ("%s/%s", GLADEDIR, "nm-pptp-dialog.glade");
|
||||
priv->xml = glade_xml_new (glade_file, "pptp-vbox", GETTEXT_PACKAGE);
|
||||
if (priv->xml == NULL) {
|
||||
g_set_error (error, PPTP_PLUGIN_UI_ERROR, 0,
|
||||
"could not load required resources at %s", glade_file);
|
||||
g_free (glade_file);
|
||||
g_object_unref (object);
|
||||
return NULL;
|
||||
}
|
||||
g_free (glade_file);
|
||||
|
||||
priv->widget = glade_xml_get_widget (priv->xml, "pptp-vbox");
|
||||
if (!priv->widget) {
|
||||
g_set_error (error, PPTP_PLUGIN_UI_ERROR, 0, "could not load UI widget");
|
||||
g_object_unref (object);
|
||||
return NULL;
|
||||
}
|
||||
g_object_ref_sink (priv->widget);
|
||||
|
||||
priv->window_group = gtk_window_group_new ();
|
||||
|
||||
if (!init_plugin_ui (PPTP_PLUGIN_UI_WIDGET (object), connection, error)) {
|
||||
g_object_unref (object);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
priv->advanced = advanced_dialog_new_hash_from_connection (connection, error);
|
||||
if (!priv->advanced) {
|
||||
g_object_unref (object);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
static void
|
||||
dispose (GObject *object)
|
||||
{
|
||||
PptpPluginUiWidget *plugin = PPTP_PLUGIN_UI_WIDGET (object);
|
||||
PptpPluginUiWidgetPrivate *priv = PPTP_PLUGIN_UI_WIDGET_GET_PRIVATE (plugin);
|
||||
|
||||
if (priv->group)
|
||||
g_object_unref (priv->group);
|
||||
|
||||
if (priv->window_group)
|
||||
g_object_unref (priv->window_group);
|
||||
|
||||
if (priv->widget)
|
||||
g_object_unref (priv->widget);
|
||||
|
||||
if (priv->xml)
|
||||
g_object_unref (priv->xml);
|
||||
|
||||
if (priv->advanced)
|
||||
g_hash_table_destroy (priv->advanced);
|
||||
|
||||
G_OBJECT_CLASS (pptp_plugin_ui_widget_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
pptp_plugin_ui_widget_class_init (PptpPluginUiWidgetClass *req_class)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (req_class);
|
||||
|
||||
g_type_class_add_private (req_class, sizeof (PptpPluginUiWidgetPrivate));
|
||||
|
||||
object_class->dispose = dispose;
|
||||
}
|
||||
|
||||
static void
|
||||
pptp_plugin_ui_widget_init (PptpPluginUiWidget *plugin)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
pptp_plugin_ui_widget_interface_init (NMVpnPluginUiWidgetInterface *iface_class)
|
||||
{
|
||||
/* interface implementation */
|
||||
iface_class->get_widget = get_widget;
|
||||
iface_class->update_connection = update_connection;
|
||||
}
|
||||
|
||||
static NMConnection *
|
||||
import (NMVpnPluginUiInterface *iface, const char *path, GError **error)
|
||||
{
|
||||
NMConnection *connection = NULL;
|
||||
char *contents = NULL;
|
||||
char **lines = NULL;
|
||||
char *ext;
|
||||
|
||||
ext = strrchr (path, '.');
|
||||
if (!ext) {
|
||||
g_set_error (error,
|
||||
PPTP_PLUGIN_UI_ERROR,
|
||||
PPTP_PLUGIN_UI_ERROR_FILE_NOT_PPTP,
|
||||
"unknown PPTP file extension");
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (strcmp (ext, ".conf") && strcmp (ext, ".cnf")) {
|
||||
g_set_error (error,
|
||||
PPTP_PLUGIN_UI_ERROR,
|
||||
PPTP_PLUGIN_UI_ERROR_FILE_NOT_PPTP,
|
||||
"unknown PPTP file extension");
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!g_file_get_contents (path, &contents, NULL, error))
|
||||
return NULL;
|
||||
|
||||
lines = g_strsplit_set (contents, "\r\n", 0);
|
||||
if (g_strv_length (lines) <= 1) {
|
||||
g_set_error (error,
|
||||
PPTP_PLUGIN_UI_ERROR,
|
||||
PPTP_PLUGIN_UI_ERROR_FILE_NOT_READABLE,
|
||||
"not a valid PPTP configuration file");
|
||||
goto out;
|
||||
}
|
||||
|
||||
connection = do_import (path, lines, error);
|
||||
|
||||
out:
|
||||
if (lines)
|
||||
g_strfreev (lines);
|
||||
g_free (contents);
|
||||
return connection;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
export (NMVpnPluginUiInterface *iface,
|
||||
const char *path,
|
||||
NMConnection *connection,
|
||||
GError **error)
|
||||
{
|
||||
return do_export (path, connection, error);
|
||||
}
|
||||
|
||||
static char *
|
||||
get_suggested_name (NMVpnPluginUiInterface *iface, NMConnection *connection)
|
||||
{
|
||||
NMSettingConnection *s_con;
|
||||
|
||||
g_return_val_if_fail (connection != NULL, NULL);
|
||||
|
||||
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
|
||||
g_return_val_if_fail (s_con != NULL, NULL);
|
||||
g_return_val_if_fail (s_con->id != NULL, NULL);
|
||||
|
||||
return g_strdup_printf ("%s (pptp).conf", s_con->id);
|
||||
}
|
||||
|
||||
static guint32
|
||||
get_capabilities (NMVpnPluginUiInterface *iface)
|
||||
{
|
||||
return (NM_VPN_PLUGIN_UI_CAPABILITY_IMPORT | NM_VPN_PLUGIN_UI_CAPABILITY_EXPORT);
|
||||
}
|
||||
|
||||
static NMVpnPluginUiWidgetInterface *
|
||||
ui_factory (NMVpnPluginUiInterface *iface, NMConnection *connection, GError **error)
|
||||
{
|
||||
return nm_vpn_plugin_ui_widget_interface_new (connection, error);
|
||||
}
|
||||
|
||||
static void
|
||||
get_property (GObject *object, guint prop_id,
|
||||
GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
switch (prop_id) {
|
||||
case NM_VPN_PLUGIN_UI_INTERFACE_PROP_NAME:
|
||||
g_value_set_string (value, PPTP_PLUGIN_NAME);
|
||||
break;
|
||||
case NM_VPN_PLUGIN_UI_INTERFACE_PROP_DESC:
|
||||
g_value_set_string (value, PPTP_PLUGIN_DESC);
|
||||
break;
|
||||
case NM_VPN_PLUGIN_UI_INTERFACE_PROP_SERVICE:
|
||||
g_value_set_string (value, PPTP_PLUGIN_SERVICE);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
pptp_plugin_ui_class_init (PptpPluginUiClass *req_class)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (req_class);
|
||||
|
||||
object_class->get_property = get_property;
|
||||
|
||||
g_object_class_override_property (object_class,
|
||||
NM_VPN_PLUGIN_UI_INTERFACE_PROP_NAME,
|
||||
NM_VPN_PLUGIN_UI_INTERFACE_NAME);
|
||||
|
||||
g_object_class_override_property (object_class,
|
||||
NM_VPN_PLUGIN_UI_INTERFACE_PROP_DESC,
|
||||
NM_VPN_PLUGIN_UI_INTERFACE_DESC);
|
||||
|
||||
g_object_class_override_property (object_class,
|
||||
NM_VPN_PLUGIN_UI_INTERFACE_PROP_SERVICE,
|
||||
NM_VPN_PLUGIN_UI_INTERFACE_SERVICE);
|
||||
}
|
||||
|
||||
static void
|
||||
pptp_plugin_ui_init (PptpPluginUi *plugin)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
pptp_plugin_ui_interface_init (NMVpnPluginUiInterface *iface_class)
|
||||
{
|
||||
/* interface implementation */
|
||||
iface_class->ui_factory = ui_factory;
|
||||
iface_class->get_capabilities = get_capabilities;
|
||||
iface_class->import = import;
|
||||
iface_class->export = export;
|
||||
iface_class->get_suggested_name = get_suggested_name;
|
||||
}
|
||||
|
||||
|
||||
G_MODULE_EXPORT NMVpnPluginUiInterface *
|
||||
nm_vpn_plugin_ui_factory (GError **error)
|
||||
{
|
||||
if (error)
|
||||
g_return_val_if_fail (*error == NULL, NULL);
|
||||
|
||||
return NM_VPN_PLUGIN_UI_INTERFACE (g_object_new (PPTP_TYPE_PLUGIN_UI, NULL));
|
||||
}
|
||||
|
||||
94
vpn-daemons/pptp/properties/nm-pptp.h
Normal file
94
vpn-daemons/pptp/properties/nm-pptp.h
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
||||
/***************************************************************************
|
||||
* nm-pptp.h : GNOME UI dialogs for configuring pptp VPN connections
|
||||
*
|
||||
* Copyright (C) 2008 Dan Williams, <dcbw@redhat.com>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef _NM_PPTP_H_
|
||||
#define _NM_PPTP_H_
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
typedef enum
|
||||
{
|
||||
PPTP_PLUGIN_UI_ERROR_UNKNOWN = 0,
|
||||
PPTP_PLUGIN_UI_ERROR_INVALID_PROPERTY,
|
||||
PPTP_PLUGIN_UI_ERROR_MISSING_PROPERTY,
|
||||
PPTP_PLUGIN_UI_ERROR_FILE_NOT_READABLE,
|
||||
PPTP_PLUGIN_UI_ERROR_FILE_NOT_PPTP
|
||||
} PptpPluginUiError;
|
||||
|
||||
#define PPTP_TYPE_PLUGIN_UI_ERROR (pptp_plugin_ui_error_get_type ())
|
||||
GType pptp_plugin_ui_error_get_type (void);
|
||||
|
||||
#define PPTP_PLUGIN_UI_ERROR (pptp_plugin_ui_error_quark ())
|
||||
GQuark pptp_plugin_ui_error_quark (void);
|
||||
|
||||
|
||||
#define PPTP_TYPE_PLUGIN_UI (pptp_plugin_ui_get_type ())
|
||||
#define PPTP_PLUGIN_UI(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PPTP_TYPE_PLUGIN_UI, PptpPluginUi))
|
||||
#define PPTP_PLUGIN_UI_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PPTP_TYPE_PLUGIN_UI, PptpPluginUiClass))
|
||||
#define PPTP_IS_PLUGIN_UI(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PPTP_TYPE_PLUGIN_UI))
|
||||
#define PPTP_IS_PLUGIN_UI_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), PPTP_TYPE_PLUGIN_UI))
|
||||
#define PPTP_PLUGIN_UI_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PPTP_TYPE_PLUGIN_UI, PptpPluginUiClass))
|
||||
|
||||
typedef struct _PptpPluginUi PptpPluginUi;
|
||||
typedef struct _PptpPluginUiClass PptpPluginUiClass;
|
||||
|
||||
struct _PptpPluginUi {
|
||||
GObject parent;
|
||||
};
|
||||
|
||||
struct _PptpPluginUiClass {
|
||||
GObjectClass parent;
|
||||
};
|
||||
|
||||
GType pptp_plugin_ui_get_type (void);
|
||||
|
||||
|
||||
#define PPTP_TYPE_PLUGIN_UI_WIDGET (pptp_plugin_ui_widget_get_type ())
|
||||
#define PPTP_PLUGIN_UI_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PPTP_TYPE_PLUGIN_UI_WIDGET, PptpPluginUiWidget))
|
||||
#define PPTP_PLUGIN_UI_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PPTP_TYPE_PLUGIN_UI_WIDGET, PptpPluginUiWidgetClass))
|
||||
#define PPTP_IS_PLUGIN_UI_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PPTP_TYPE_PLUGIN_UI_WIDGET))
|
||||
#define PPTP_IS_PLUGIN_UI_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), PPTP_TYPE_PLUGIN_UI_WIDGET))
|
||||
#define PPTP_PLUGIN_UI_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PPTP_TYPE_PLUGIN_UI_WIDGET, PptpPluginUiWidgetClass))
|
||||
|
||||
typedef struct _PptpPluginUiWidget PptpPluginUiWidget;
|
||||
typedef struct _PptpPluginUiWidgetClass PptpPluginUiWidgetClass;
|
||||
|
||||
struct _PptpPluginUiWidget {
|
||||
GObject parent;
|
||||
};
|
||||
|
||||
struct _PptpPluginUiWidgetClass {
|
||||
GObjectClass parent;
|
||||
};
|
||||
|
||||
GType pptp_plugin_ui_widget_get_type (void);
|
||||
|
||||
GValue *int_to_gvalue (gint i);
|
||||
|
||||
GValue *uint_to_gvalue (guint32 u);
|
||||
|
||||
GValue *bool_to_gvalue (gboolean b);
|
||||
|
||||
GValue *str_to_gvalue (const char *str);
|
||||
|
||||
#endif /* _NM_PPTP_H_ */
|
||||
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
#include <glib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define NMVPNUI_UTIL_LISTS_C
|
||||
#include "util_lists.h"
|
||||
|
||||
GSList *
|
||||
list_from_string (const char *string)
|
||||
{
|
||||
char **entries;
|
||||
char **parts;
|
||||
char **entry;
|
||||
char **part;
|
||||
int i;
|
||||
GSList *list=NULL;
|
||||
|
||||
if (string==NULL) return list;
|
||||
entries = g_strsplit(string,";",0);
|
||||
|
||||
for (entry=entries; *entry; entry++)
|
||||
{
|
||||
parts = g_strsplit(*entry,"=",2);
|
||||
part=parts;
|
||||
if ((!(*part)) || (strlen(*part)==0)) {
|
||||
g_strfreev(parts);
|
||||
continue;
|
||||
}
|
||||
|
||||
list = g_slist_append (list,g_strdup(*part));
|
||||
*part++;
|
||||
|
||||
if ((!(*part)) || (strlen(*part)==0) || (strcmp("''",*part)==0)) {
|
||||
list = g_slist_append (list,g_strdup(""));
|
||||
} else {
|
||||
list = g_slist_append (list,g_strdup(*part));
|
||||
}
|
||||
g_strfreev(parts);
|
||||
}
|
||||
g_strfreev(entries);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
#ifndef NMVPNUI_UTIL_LISTS_H
|
||||
#define NMVPNUI_UTIL_LISTS_H
|
||||
|
||||
#define STORAGE_CLASS extern
|
||||
#ifdef NMVPNUI_UTIL_LISTS_C
|
||||
#undef STORAGE_CLASS
|
||||
#define STORAGE_CLASS
|
||||
#endif
|
||||
|
||||
STORAGE_CLASS GSList *list_from_string (const char *string);
|
||||
|
||||
#undef STORAGE_CLASS
|
||||
#endif
|
||||
|
|
@ -1,72 +0,0 @@
|
|||
#include <string.h>
|
||||
#include <glade/glade.h>
|
||||
|
||||
#define NMVPNUI_EXPAND_C
|
||||
#include "vpnui_opt.h"
|
||||
#include "vpnui_expand.h"
|
||||
|
||||
void vpnui_expand_free(VpnUIExpander *expand)
|
||||
{
|
||||
g_return_if_fail(expand!=NULL);
|
||||
|
||||
if (expand->glade_name !=NULL) g_free(expand->glade_name);
|
||||
|
||||
g_free(expand);
|
||||
}
|
||||
|
||||
VpnUIExpander *vpnui_expand_new( char *glade_name,
|
||||
NetworkManagerVpnUIImpl *impl )
|
||||
{
|
||||
VpnUIExpander *expand;
|
||||
|
||||
g_return_val_if_fail(impl!=NULL,NULL);
|
||||
|
||||
if (!(expand = (VpnUIExpander *) g_new0(VpnUIExpander,1)))
|
||||
return NULL;
|
||||
|
||||
expand->glade_name=g_strdup(glade_name);
|
||||
|
||||
expand->impl=impl;
|
||||
|
||||
expand->widget = GTK_WIDGET (glade_xml_get_widget(expand->impl->xml, expand->glade_name));
|
||||
impl->expanders = g_slist_append(impl->expanders, (gpointer) expand);
|
||||
|
||||
return expand;
|
||||
}
|
||||
|
||||
void
|
||||
vpnui_expand_reset_all (NetworkManagerVpnUIImpl *impl)
|
||||
{
|
||||
GSList *item;
|
||||
|
||||
for (item=impl->expanders; item != NULL; item = g_slist_next(item))
|
||||
{
|
||||
vpnui_expand_reset((VpnUIExpander *)item->data);
|
||||
}
|
||||
|
||||
gtk_container_resize_children (GTK_CONTAINER (impl->widget));
|
||||
}
|
||||
|
||||
void vpnui_expand_reset(VpnUIExpander *expand)
|
||||
{
|
||||
GList *item;
|
||||
|
||||
g_return_if_fail(expand!=NULL);
|
||||
g_return_if_fail(expand->widget!=NULL);
|
||||
|
||||
if (GTK_IS_CONTAINER(expand->widget)) {
|
||||
if (vpnui_opt_has_active_children(GTK_CONTAINER(expand->widget),expand->impl)) {
|
||||
// gtk_expander_set_expanded(GTK_EXPANDER(expand->widget),TRUE);
|
||||
gtk_widget_show(GTK_WIDGET(expand->widget));
|
||||
} else {
|
||||
// gtk_expander_set_expanded(GTK_EXPANDER(expand->widget),FALSE);
|
||||
gtk_widget_hide(GTK_WIDGET(expand->widget));
|
||||
}
|
||||
}
|
||||
|
||||
// g_return_if_fail(expand!=NULL);
|
||||
// gtk_expander_set_expanded (GTK_EXPANDER(expand->widget), TRUE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
#ifndef NMVPNUI_EXPAND_H
|
||||
#define NMVPNUI_EXPAND_H
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <string.h>
|
||||
#include <glade/glade.h>
|
||||
|
||||
#include <vpnui_impl.h>
|
||||
|
||||
typedef struct VpnUIExpander
|
||||
{
|
||||
char *glade_name;
|
||||
NetworkManagerVpnUIImpl *impl;
|
||||
GtkWidget *widget;
|
||||
} VpnUIExpander;
|
||||
|
||||
#define STORAGE_CLASS extern
|
||||
#ifdef NMVPNUI_EXPAND_C
|
||||
#undef STORAGE_CLASS
|
||||
#define STORAGE_CLASS
|
||||
#endif
|
||||
|
||||
STORAGE_CLASS void vpnui_expand_free(VpnUIExpander *expand);
|
||||
STORAGE_CLASS VpnUIExpander *vpnui_expand_new( char *glade_name,
|
||||
NetworkManagerVpnUIImpl *impl );
|
||||
|
||||
STORAGE_CLASS void vpnui_expand_reset(VpnUIExpander *expand);
|
||||
STORAGE_CLASS void vpnui_expand_reset_all (NetworkManagerVpnUIImpl *impl);
|
||||
|
||||
#undef STORAGE_CLASS
|
||||
#endif
|
||||
|
|
@ -1,569 +0,0 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <glib/gi18n-lib.h>
|
||||
#include <string.h>
|
||||
#include <glade/glade.h>
|
||||
|
||||
#define NM_VPN_API_SUBJECT_TO_CHANGE
|
||||
#include <nm-vpn-ui-interface.h>
|
||||
|
||||
#define NMVPNUI_IMPL_C
|
||||
#include "vpnui_impl.h"
|
||||
#include "vpnui_expand.h"
|
||||
#include "vpnui_opt.h"
|
||||
|
||||
/* Stuff to be provided by the specific instance */
|
||||
extern const char *GLADE_FILE;
|
||||
extern const char *GLADE_WIDGET;
|
||||
extern void impl_setup (NetworkManagerVpnUIImpl *impl);
|
||||
extern void impl_hide_and_show (NetworkManagerVpnUIImpl *impl);
|
||||
|
||||
static void
|
||||
impl_set_validity_changed_callback (NetworkManagerVpnUI *self,
|
||||
NetworkManagerVpnUIDialogValidityCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
NetworkManagerVpnUIImpl *impl = (NetworkManagerVpnUIImpl *) self->data;
|
||||
|
||||
impl->callback = callback;
|
||||
impl->callback_user_data = user_data;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
impl_clear_widget (NetworkManagerVpnUIImpl *impl)
|
||||
{
|
||||
GSList *item;
|
||||
|
||||
g_return_if_fail(impl!=NULL);
|
||||
|
||||
if (impl->connection_name_opt!=NULL) vpnui_opt_set(impl->connection_name_opt,"");
|
||||
if (impl->variant_combo!=NULL) gtk_combo_box_set_active(impl->variant_combo,-1);
|
||||
if (impl->defaults!=NULL)
|
||||
for (item=impl->config_options; item != NULL; item = g_slist_next(item))
|
||||
{
|
||||
vpnui_opt_set_default((VpnUIConfigOption *)item->data, impl->defaults);
|
||||
}
|
||||
|
||||
// vpnui_expand_reset_all(impl);
|
||||
impl_hide_and_show(impl);
|
||||
}
|
||||
|
||||
static const char *
|
||||
impl_get_display_name (NetworkManagerVpnUI *self)
|
||||
{
|
||||
NetworkManagerVpnUIImpl *impl = (NetworkManagerVpnUIImpl *) self->data;
|
||||
return impl->display_name;
|
||||
}
|
||||
|
||||
static const char *
|
||||
impl_get_service_name (NetworkManagerVpnUI *self)
|
||||
{
|
||||
NetworkManagerVpnUIImpl *impl = (NetworkManagerVpnUIImpl *) self->data;
|
||||
return impl->service_name;
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
impl_get_widget (NetworkManagerVpnUI *self, GSList *properties, GSList *routes, const char *connection_name)
|
||||
{
|
||||
GSList *item;
|
||||
VpnUIConfigOption *opt;
|
||||
NetworkManagerVpnUIImpl *impl = (NetworkManagerVpnUIImpl *) self->data;
|
||||
|
||||
impl_clear_widget (impl);
|
||||
|
||||
if (connection_name != NULL) {
|
||||
if ((opt = impl->connection_name_opt) != NULL) {
|
||||
vpnui_opt_set(opt,connection_name);
|
||||
}
|
||||
}
|
||||
|
||||
for (item=properties; item != NULL; item = g_slist_next(g_slist_next(item)))
|
||||
{
|
||||
if (item->data==NULL) continue;
|
||||
if ((g_slist_next(item))->data==NULL) continue;
|
||||
opt = impl_opt_bygconf(impl,(char *)item->data);
|
||||
if (opt==NULL) continue;
|
||||
vpnui_opt_set(opt, (char *)(g_slist_next(item))->data);
|
||||
}
|
||||
|
||||
if (routes != NULL) {
|
||||
GString *route_str;
|
||||
char *str;
|
||||
|
||||
route_str = g_string_new ("");
|
||||
for (item = routes; item != NULL; item = g_slist_next (item)) {
|
||||
if (item != routes) g_string_append_c(route_str, ' ');
|
||||
g_string_append(route_str, (const char *) item->data);
|
||||
}
|
||||
str = g_string_free (route_str, FALSE);
|
||||
|
||||
if(impl->routes_opt!=NULL) vpnui_opt_set(impl->routes_opt,str);
|
||||
if(impl->routes_toggle_opt!=NULL) vpnui_opt_set(impl->routes_toggle_opt,"yes");
|
||||
g_free (str);
|
||||
}
|
||||
|
||||
// vpnui_expand_reset_all(impl);
|
||||
impl_hide_and_show(impl);
|
||||
|
||||
return impl->widget;
|
||||
}
|
||||
|
||||
static GSList *
|
||||
impl_get_properties (NetworkManagerVpnUI *self)
|
||||
{
|
||||
GSList *data;
|
||||
GSList *item;
|
||||
VpnUIConfigOption *opt;
|
||||
NetworkManagerVpnUIImpl *impl = (NetworkManagerVpnUIImpl *) self->data;
|
||||
|
||||
data = NULL;
|
||||
for (item=impl->config_options; item != NULL; item = g_slist_next(item))
|
||||
{
|
||||
opt = (VpnUIConfigOption *)item->data;
|
||||
if (opt==NULL) continue;
|
||||
if (opt->gconf_name==NULL) continue;
|
||||
if (!opt->active) continue;
|
||||
|
||||
data = g_slist_append (data, g_strdup(opt->gconf_name));
|
||||
data = g_slist_append (data, g_strdup(vpnui_opt_get(opt)));
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
static GSList *
|
||||
get_routes (NetworkManagerVpnUIImpl *impl)
|
||||
{
|
||||
GSList *routes;
|
||||
const char *routes_entry;
|
||||
const char *use_routes;
|
||||
char **substrs;
|
||||
unsigned int i;
|
||||
VpnUIConfigOption *opt;
|
||||
|
||||
routes = NULL;
|
||||
|
||||
opt = impl_opt_byglade(impl,"routes");
|
||||
g_return_val_if_fail(opt!=NULL,NULL);
|
||||
if (!opt->active) return NULL;
|
||||
routes_entry = vpnui_opt_get(opt);
|
||||
|
||||
opt = impl_opt_byglade(impl,"use-routes");
|
||||
g_return_val_if_fail(opt!=NULL,NULL);
|
||||
use_routes = vpnui_opt_get(impl_opt_byglade(impl,"use-routes"));
|
||||
|
||||
if (strcmp("no",use_routes)==0) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
substrs = g_strsplit (routes_entry, " ", 0);
|
||||
for (i = 0; substrs[i] != NULL; i++) {
|
||||
char *route;
|
||||
|
||||
if (strlen(substrs[i]) > 0)
|
||||
routes = g_slist_append (routes, g_strdup (substrs[i]));
|
||||
}
|
||||
|
||||
g_strfreev (substrs);
|
||||
|
||||
out:
|
||||
return routes;
|
||||
}
|
||||
|
||||
static GSList *
|
||||
impl_get_routes (NetworkManagerVpnUI *self)
|
||||
{
|
||||
NetworkManagerVpnUIImpl *impl = (NetworkManagerVpnUIImpl *) self->data;
|
||||
|
||||
return get_routes (impl);
|
||||
}
|
||||
|
||||
|
||||
static char *
|
||||
impl_get_connection_name (NetworkManagerVpnUI *self)
|
||||
{
|
||||
NetworkManagerVpnUIImpl *impl = (NetworkManagerVpnUIImpl *) self->data;
|
||||
|
||||
return g_strdup( vpnui_opt_get(impl->connection_name_opt) );
|
||||
}
|
||||
|
||||
|
||||
gboolean
|
||||
impl_is_valid (NetworkManagerVpnUI *self)
|
||||
{
|
||||
NetworkManagerVpnUIImpl *impl = (NetworkManagerVpnUIImpl *) self->data;
|
||||
GSList *item;
|
||||
gboolean is_valid;
|
||||
VpnUIConfigOption *opt;
|
||||
|
||||
is_valid = TRUE;
|
||||
for (item=impl->config_options; item != NULL; item = g_slist_next(item))
|
||||
{
|
||||
opt = (VpnUIConfigOption *)item->data;
|
||||
if (opt==NULL) continue;
|
||||
if (!opt->active) continue;
|
||||
is_valid &= vpnui_opt_validate(opt);
|
||||
if (!is_valid) return is_valid;
|
||||
}
|
||||
|
||||
return is_valid;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
impl_get_confirmation_details (NetworkManagerVpnUI *self, gchar **retval)
|
||||
{
|
||||
GString *buf;
|
||||
GSList *item;
|
||||
const char *value;
|
||||
VpnUIConfigOption *opt;
|
||||
NetworkManagerVpnUIImpl *impl = (NetworkManagerVpnUIImpl *) self->data;
|
||||
|
||||
// This is risky, should be variable length depending on actual data!
|
||||
buf = g_string_sized_new (1024);
|
||||
|
||||
g_string_append_printf (buf, _("The following '%s' connection will be created:"), impl->display_name);
|
||||
g_string_append (buf, "\n\n");
|
||||
for (item=impl->config_options; item != NULL; item = g_slist_next(item))
|
||||
{
|
||||
opt = (VpnUIConfigOption *)item->data;
|
||||
if (opt==NULL) continue;
|
||||
if (opt->description==NULL) continue;
|
||||
if (!opt->active) continue;
|
||||
|
||||
value = vpnui_opt_get(opt);
|
||||
if (value==NULL) continue;
|
||||
if (strlen(value)==0) continue;
|
||||
|
||||
g_string_append_printf (buf, _("\t%s: %s\n"), opt->description, value);
|
||||
}
|
||||
|
||||
g_string_append (buf, _("The connection details can be changed using the \"Back\" button."));
|
||||
g_string_append (buf, "\n");
|
||||
|
||||
*retval = g_string_free (buf, FALSE);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
import_from_file (NetworkManagerVpnUIImpl *impl, const char *path)
|
||||
{
|
||||
char *basename;
|
||||
GKeyFile *keyfile;
|
||||
VpnUIConfigOption *opt;
|
||||
GSList *item;
|
||||
gboolean file_is_good;
|
||||
|
||||
file_is_good = FALSE;
|
||||
basename = g_path_get_basename (path);
|
||||
|
||||
keyfile = g_key_file_new ();
|
||||
if (g_key_file_load_from_file (keyfile, path, 0, NULL)) {
|
||||
char *value = NULL;
|
||||
|
||||
for (item=impl->config_options; item != NULL; item = g_slist_next(item))
|
||||
{
|
||||
opt = (VpnUIConfigOption *)item->data;
|
||||
if (opt==NULL) continue;
|
||||
if (opt->export_name==NULL) continue;
|
||||
|
||||
value = g_key_file_get_string (keyfile, "main", opt->export_name, NULL);
|
||||
vpnui_opt_set(opt,value);
|
||||
g_free (value);
|
||||
}
|
||||
g_key_file_free (keyfile);
|
||||
}
|
||||
|
||||
g_free (basename);
|
||||
|
||||
impl_hide_and_show(impl);
|
||||
|
||||
return file_is_good;
|
||||
|
||||
// if (!file_is_good) {
|
||||
// GtkWidget *dialog;
|
||||
//
|
||||
// dialog = gtk_message_dialog_new (NULL,
|
||||
// GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
// GTK_MESSAGE_WARNING,
|
||||
// GTK_BUTTONS_CLOSE,
|
||||
// _("Cannot import settings"));
|
||||
// gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
|
||||
// _("The VPN settings file '%s' does not contain valid data."), basename);
|
||||
// gtk_dialog_run (GTK_DIALOG (dialog));
|
||||
// gtk_widget_destroy (dialog);
|
||||
// }
|
||||
}
|
||||
|
||||
static void
|
||||
show_widget (GtkWidget *widget, gpointer user_data)
|
||||
{
|
||||
g_warning("Widget show event");
|
||||
|
||||
impl_hide_and_show((NetworkManagerVpnUIImpl *) user_data);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
import_button_clicked (GtkButton *button, gpointer user_data)
|
||||
{
|
||||
char *filename = NULL;
|
||||
GtkWidget *dialog;
|
||||
NetworkManagerVpnUIImpl *impl = (NetworkManagerVpnUIImpl *) user_data;
|
||||
|
||||
dialog = gtk_file_chooser_dialog_new (_("Select file to import"),
|
||||
NULL,
|
||||
GTK_FILE_CHOOSER_ACTION_OPEN,
|
||||
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
||||
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
|
||||
NULL);
|
||||
|
||||
if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) {
|
||||
|
||||
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
|
||||
/*printf ("User selected '%s'\n", filename);*/
|
||||
|
||||
}
|
||||
|
||||
gtk_widget_destroy (dialog);
|
||||
|
||||
if (filename != NULL) {
|
||||
import_from_file (impl, filename);
|
||||
g_free (filename);
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
impl_can_export (NetworkManagerVpnUI *self)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
impl_import_file (NetworkManagerVpnUI *self, const char *path)
|
||||
{
|
||||
NetworkManagerVpnUIImpl *impl = (NetworkManagerVpnUIImpl *) self->data;
|
||||
|
||||
return import_from_file (impl, path);
|
||||
}
|
||||
|
||||
static void
|
||||
export_to_file (NetworkManagerVpnUIImpl *impl, const char *path,
|
||||
GSList *properties, GSList *routes, const char *connection_name)
|
||||
{
|
||||
FILE *f;
|
||||
GSList *item;
|
||||
VpnUIConfigOption *opt;
|
||||
// gboolean use_routes = FALSE;
|
||||
const char *export = NULL;
|
||||
const char *value = NULL;
|
||||
char *routes_str = NULL;
|
||||
|
||||
f = fopen (path, "w");
|
||||
if (f == NULL) return;
|
||||
|
||||
/* Print the header */
|
||||
fprintf (f, "[main]\n");
|
||||
|
||||
/* Handle the connection-name */
|
||||
if (connection_name != NULL) {
|
||||
opt = impl_opt_byglade(impl,"connection-name");
|
||||
if (opt != NULL ) {
|
||||
export = opt->export_name;
|
||||
value = connection_name;
|
||||
if ((export != NULL ) && (value!=NULL) ) {
|
||||
fprintf (f, "%s=%s\n",export,value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (item=properties; item != NULL; item = g_slist_next(g_slist_next(item)))
|
||||
{
|
||||
if (item->data==NULL) continue;
|
||||
if ((g_slist_next(item))->data==NULL) continue;
|
||||
opt = impl_opt_bygconf(impl,(char *)item->data);
|
||||
if (opt==NULL) continue;
|
||||
vpnui_opt_set(opt, (char *)(g_slist_next(item))->data);
|
||||
}
|
||||
|
||||
if (routes != NULL) {
|
||||
GString *route_str;
|
||||
char *str;
|
||||
|
||||
route_str = g_string_new ("");
|
||||
for (item = routes; item != NULL; item = g_slist_next (item)) {
|
||||
if (item != routes) g_string_append_c(route_str, ' ');
|
||||
g_string_append(route_str, (const char *) item->data);
|
||||
}
|
||||
str = g_string_free (route_str, FALSE);
|
||||
|
||||
if (impl->routes_opt!=NULL) vpnui_opt_set(impl->routes_opt,str);
|
||||
if (impl->routes_toggle_opt!=NULL) vpnui_opt_set(impl->routes_toggle_opt,"yes");
|
||||
g_free (str);
|
||||
}
|
||||
|
||||
/* Loop over properties and print them out */
|
||||
for (item=properties; item != NULL; item = g_slist_next(g_slist_next(item)))
|
||||
{
|
||||
if (item->data==NULL) continue;
|
||||
if ((g_slist_next(item))->data==NULL) continue;
|
||||
|
||||
// if (strcmp("use_routes",item->data)==0) {
|
||||
// if (strcmp("yes",(g_slist_next(item))->data)==0) use_routes=TRUE;
|
||||
// }
|
||||
|
||||
opt = impl_opt_bygconf(impl,(char *)item->data);
|
||||
if (opt==NULL) continue;
|
||||
if (opt->export_name==NULL) continue;
|
||||
if (!opt->active) continue;
|
||||
|
||||
export = opt->export_name;
|
||||
value = (const char *)(g_slist_next(item))->data;
|
||||
|
||||
if ((export != NULL ) && (value!=NULL) ) {
|
||||
fprintf (f, "%s=%s\n",export,value);
|
||||
}
|
||||
}
|
||||
|
||||
if (routes != NULL) {
|
||||
GString *route_str;
|
||||
char *str;
|
||||
|
||||
route_str = g_string_new ("");
|
||||
for (item = routes; item != NULL; item = g_slist_next (item)) {
|
||||
if (item != routes) g_string_append_c(route_str, ' ');
|
||||
g_string_append(route_str, (const char *) item->data);
|
||||
}
|
||||
value = ( str = g_string_free (route_str, FALSE) );
|
||||
value = str;
|
||||
|
||||
opt = impl_opt_byglade(impl,"routes");
|
||||
g_free (str);
|
||||
g_free (routes_str);
|
||||
}
|
||||
fclose (f);
|
||||
|
||||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
impl_export (NetworkManagerVpnUI *self, GSList *properties, GSList *routes, const char *connection_name)
|
||||
{
|
||||
char *suggested_name;
|
||||
char *path = NULL;
|
||||
GtkWidget *dialog;
|
||||
NetworkManagerVpnUIImpl *impl = (NetworkManagerVpnUIImpl *) self->data;
|
||||
|
||||
/*printf ("in impl_export\n");*/
|
||||
|
||||
dialog = gtk_file_chooser_dialog_new (_("Save as..."),
|
||||
NULL,
|
||||
GTK_FILE_CHOOSER_ACTION_SAVE,
|
||||
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
||||
GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
|
||||
NULL);
|
||||
|
||||
suggested_name = g_strdup_printf ("%s.pcf", connection_name);
|
||||
gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), suggested_name);
|
||||
g_free (suggested_name);
|
||||
|
||||
if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
|
||||
{
|
||||
|
||||
path = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
|
||||
|
||||
}
|
||||
|
||||
gtk_widget_destroy (dialog);
|
||||
|
||||
if (path != NULL) {
|
||||
if (g_file_test (path, G_FILE_TEST_EXISTS)) {
|
||||
int response;
|
||||
GtkWidget *dialog;
|
||||
|
||||
dialog = gtk_message_dialog_new (NULL,
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_QUESTION,
|
||||
GTK_BUTTONS_CANCEL,
|
||||
_("A file named \"%s\" already exists."), path);
|
||||
gtk_dialog_add_buttons (GTK_DIALOG (dialog), "_Replace", GTK_RESPONSE_OK, NULL);
|
||||
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
|
||||
_("Do you want to replace it with the one you are saving?"));
|
||||
response = gtk_dialog_run (GTK_DIALOG (dialog));
|
||||
gtk_widget_destroy (dialog);
|
||||
if (response == GTK_RESPONSE_OK)
|
||||
export_to_file (impl, path, properties, routes, connection_name);
|
||||
} else {
|
||||
export_to_file (impl, path, properties, routes, connection_name);
|
||||
}
|
||||
}
|
||||
|
||||
g_free (path);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static NetworkManagerVpnUI*
|
||||
impl_get_object (void)
|
||||
{
|
||||
char *glade_file;
|
||||
NetworkManagerVpnUIImpl *impl;
|
||||
|
||||
impl = g_new0 (NetworkManagerVpnUIImpl, 1);
|
||||
|
||||
glade_file = g_strdup_printf ("%s/%s", GLADEDIR, GLADE_FILE);
|
||||
impl->xml = glade_xml_new (glade_file, NULL, GETTEXT_PACKAGE);
|
||||
g_free( glade_file );
|
||||
if (impl->xml != NULL) {
|
||||
|
||||
impl->widget = glade_xml_get_widget(impl->xml, GLADE_WIDGET);
|
||||
|
||||
impl_setup(impl);
|
||||
|
||||
impl->callback = NULL;
|
||||
|
||||
if (impl->w_import_button!=NULL) {
|
||||
g_signal_connect (GTK_OBJECT (impl->w_import_button),
|
||||
"clicked", G_CALLBACK (import_button_clicked), impl);
|
||||
}
|
||||
|
||||
g_signal_connect (GTK_OBJECT (impl->widget),
|
||||
"show", G_CALLBACK (show_widget), impl);
|
||||
|
||||
/* make the widget reusable */
|
||||
g_signal_connect (GTK_OBJECT (impl->widget), "delete-event",
|
||||
G_CALLBACK (gtk_widget_hide_on_delete), NULL);
|
||||
|
||||
impl_clear_widget (impl);
|
||||
|
||||
impl->parent.get_display_name = impl_get_display_name;
|
||||
impl->parent.get_service_name = impl_get_service_name;
|
||||
impl->parent.get_widget = impl_get_widget;
|
||||
impl->parent.get_connection_name = impl_get_connection_name;
|
||||
impl->parent.get_properties = impl_get_properties;
|
||||
impl->parent.get_routes = impl_get_routes;
|
||||
impl->parent.set_validity_changed_callback = impl_set_validity_changed_callback;
|
||||
impl->parent.is_valid = impl_is_valid;
|
||||
impl->parent.get_confirmation_details = impl_get_confirmation_details;
|
||||
impl->parent.can_export = impl_can_export;
|
||||
impl->parent.import_file = impl_import_file;
|
||||
impl->parent.export = impl_export;
|
||||
impl->parent.data = impl;
|
||||
|
||||
return &(impl->parent);
|
||||
} else {
|
||||
g_free (impl);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
NetworkManagerVpnUI*
|
||||
nm_vpn_properties_factory (void)
|
||||
{
|
||||
return impl_get_object();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,77 +0,0 @@
|
|||
#ifndef NMVPNUI_IMPL_H
|
||||
#define NMVPNUI_IMPL_H
|
||||
|
||||
#include <glade/glade.h>
|
||||
|
||||
#define NM_VPN_API_SUBJECT_TO_CHANGE
|
||||
#include <nm-vpn-ui-interface.h>
|
||||
|
||||
|
||||
struct impl_config
|
||||
{
|
||||
const char *display_name;
|
||||
const char *glade_widget;
|
||||
const char *glade_file;
|
||||
const char *glade_connection_name;
|
||||
const char *glade_routes;
|
||||
const char *glade_routes_toggle;
|
||||
const char *glade_import_button;
|
||||
};
|
||||
|
||||
#define HAVE_VpnUIConfigOption
|
||||
typedef struct _VpnUIConfigOption VpnUIConfigOption;
|
||||
typedef struct _NetworkManagerVpnUIImpl NetworkManagerVpnUIImpl;
|
||||
|
||||
typedef void (*VpnUIHideShowCallback) (NetworkManagerVpnUIImpl *self);
|
||||
|
||||
struct _NetworkManagerVpnUIImpl {
|
||||
NetworkManagerVpnUI parent;
|
||||
|
||||
NetworkManagerVpnUIDialogValidityCallback callback;
|
||||
VpnUIHideShowCallback do_hide_and_show;
|
||||
gpointer callback_user_data;
|
||||
|
||||
GladeXML *xml;
|
||||
|
||||
GtkWidget *widget;
|
||||
|
||||
GSList *config_options;
|
||||
GSList *variants;
|
||||
|
||||
// GtkEntry *w_connection_name;
|
||||
// GtkEntry *w_remote;
|
||||
// GtkCheckButton *w_use_routes;
|
||||
// GtkEntry *w_routes;
|
||||
// GtkCheckButton *w_use_mppe;
|
||||
// GtkCheckButton *w_use_mppc;
|
||||
// GtkExpander *w_pppd_opt_info_expander;
|
||||
// GtkExpander *w_routing_opt_info_expander;
|
||||
// GtkExpander *w_pptp_opt_info_expander;
|
||||
VpnUIConfigOption *connection_name_opt;
|
||||
VpnUIConfigOption *routes_opt;
|
||||
VpnUIConfigOption *routes_toggle_opt;
|
||||
GtkComboBox *variant_combo;
|
||||
GtkButton *w_import_button;
|
||||
GSList *defaults;
|
||||
GSList *expanders;
|
||||
|
||||
const char *display_name;
|
||||
const char *service_name;
|
||||
};
|
||||
|
||||
#ifdef NMVPNUI_IMPL_C
|
||||
#define STORAGE_CLASS static
|
||||
#define STORAGE_CLASS2
|
||||
#else
|
||||
#define STORAGE_CLASS extern
|
||||
#define STORAGE_CLASS2 extern
|
||||
#endif
|
||||
|
||||
STORAGE_CLASS GSList *get_routes (NetworkManagerVpnUIImpl *impl);
|
||||
STORAGE_CLASS2 gboolean impl_is_valid (NetworkManagerVpnUI *self);
|
||||
STORAGE_CLASS void impl_set_validity_changed_callback (NetworkManagerVpnUI *self,
|
||||
NetworkManagerVpnUIDialogValidityCallback callback,
|
||||
gpointer user_data);
|
||||
|
||||
#undef STORAGE_CLASS
|
||||
#endif
|
||||
|
|
@ -1,350 +0,0 @@
|
|||
#include <gtk/gtk.h>
|
||||
#include <string.h>
|
||||
#include <glade/glade.h>
|
||||
|
||||
#define NMVPNUI_OPT_C
|
||||
#include "vpnui_impl.h"
|
||||
#include "util_lists.h"
|
||||
#include "vpnui_opt.h"
|
||||
|
||||
char get_opt_buffer[64];
|
||||
|
||||
extern void use_routes_toggled (GtkToggleButton *togglebutton, gpointer user_data);
|
||||
extern void editable_changed (GtkEditable *editable, gpointer user_data);
|
||||
extern void impl_set_validity_changed_callback (NetworkManagerVpnUI *self,
|
||||
NetworkManagerVpnUIDialogValidityCallback callback,
|
||||
gpointer user_data);
|
||||
|
||||
|
||||
void vpnui_opt_free(VpnUIConfigOption *opt)
|
||||
{
|
||||
g_return_if_fail(opt!=NULL);
|
||||
|
||||
if (opt->glade_name !=NULL) g_free(opt->glade_name);
|
||||
if (opt->gconf_name != NULL) g_free(opt->gconf_name);
|
||||
if (opt->export_name != NULL) g_free(opt->export_name);
|
||||
|
||||
g_free(opt);
|
||||
}
|
||||
|
||||
VpnUIConfigOption *vpnui_opt_new( char *glade_name,
|
||||
int option_type,
|
||||
char *gconf_name,
|
||||
char *export_name,
|
||||
char *description,
|
||||
void (*change_handler)(void),
|
||||
gboolean (*validator)(VpnUIConfigOption *opt),
|
||||
NetworkManagerVpnUIImpl *impl )
|
||||
{
|
||||
VpnUIConfigOption *opt;
|
||||
|
||||
g_return_val_if_fail(impl!=NULL,NULL);
|
||||
|
||||
if (impl->config_options == NULL) impl->config_options = NULL;
|
||||
|
||||
if (!(opt = (VpnUIConfigOption *) g_new0(VpnUIConfigOption,1)))
|
||||
return NULL;
|
||||
|
||||
opt->glade_name=g_strdup(glade_name);
|
||||
opt->option_type=option_type;
|
||||
if (gconf_name != NULL) opt->gconf_name=g_strdup(gconf_name);
|
||||
if (export_name != NULL) opt->export_name=g_strdup(export_name);
|
||||
if (description != NULL) opt->description=g_strdup(description);
|
||||
|
||||
opt->change_handler=change_handler;
|
||||
opt->validator=validator;
|
||||
|
||||
opt->impl=impl;
|
||||
impl->config_options = g_slist_append(impl->config_options, (gpointer) opt);
|
||||
|
||||
vpnui_opt_get_widget(opt);
|
||||
vpnui_opt_connect_signals(opt);
|
||||
|
||||
return opt;
|
||||
}
|
||||
|
||||
void vpnui_opt_connect_signals(VpnUIConfigOption *opt)
|
||||
{
|
||||
g_return_if_fail(opt!=NULL);
|
||||
g_return_if_fail(opt->widget!=NULL);
|
||||
g_return_if_fail(opt->impl!=NULL);
|
||||
|
||||
if (opt->change_handler==NULL) return;
|
||||
|
||||
switch (opt->option_type)
|
||||
{
|
||||
case VPN_UI_OPTTYPE_YESNO:
|
||||
g_signal_connect (GTK_OBJECT (opt->widget),
|
||||
"toggled", G_CALLBACK (opt->change_handler), opt->impl);
|
||||
break;
|
||||
case VPN_UI_OPTTYPE_STRING:
|
||||
g_signal_connect (GTK_OBJECT (opt->widget),
|
||||
"changed", G_CALLBACK (opt->change_handler), opt->impl);
|
||||
break;
|
||||
case VPN_UI_OPTTYPE_SPINNER:
|
||||
g_signal_connect (GTK_OBJECT (opt->widget),
|
||||
"changed", G_CALLBACK (opt->change_handler), opt->impl);
|
||||
break;
|
||||
case VPN_UI_OPTTYPE_COMBO:
|
||||
g_signal_connect (GTK_OBJECT (opt->widget),
|
||||
"changed", G_CALLBACK (opt->change_handler), opt->impl);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void vpnui_opt_get_widget(VpnUIConfigOption *opt)
|
||||
{
|
||||
g_return_if_fail(opt!=NULL);
|
||||
g_return_if_fail(opt->impl!=NULL);
|
||||
|
||||
switch (opt->option_type)
|
||||
{
|
||||
case VPN_UI_OPTTYPE_YESNO:
|
||||
case VPN_UI_OPTTYPE_STRING:
|
||||
case VPN_UI_OPTTYPE_SPINNER:
|
||||
case VPN_UI_OPTTYPE_COMBO:
|
||||
opt->widget = GTK_WIDGET (glade_xml_get_widget(opt->impl->xml, opt->glade_name));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const char * vpnui_opt_get(VpnUIConfigOption *opt)
|
||||
{
|
||||
GtkTreeModel *combo_tree;
|
||||
GtkTreeIter iter;
|
||||
char *setting;
|
||||
gdouble value;
|
||||
g_return_val_if_fail(opt!=NULL,NULL);
|
||||
|
||||
switch (opt->option_type)
|
||||
{
|
||||
case VPN_UI_OPTTYPE_YESNO:
|
||||
if (gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON (opt->widget) )) {
|
||||
return "yes";
|
||||
}
|
||||
return "no";
|
||||
case VPN_UI_OPTTYPE_STRING:
|
||||
return gtk_entry_get_text(GTK_ENTRY(opt->widget));
|
||||
case VPN_UI_OPTTYPE_SPINNER:
|
||||
value = gtk_spin_button_get_value(GTK_SPIN_BUTTON(opt->widget));
|
||||
sprintf(get_opt_buffer,"%.0f",value);
|
||||
return get_opt_buffer;
|
||||
case VPN_UI_OPTTYPE_COMBO:
|
||||
combo_tree = gtk_combo_box_get_model(GTK_COMBO_BOX(opt->widget));
|
||||
if (combo_tree==NULL) return NULL;
|
||||
if (!gtk_combo_box_get_active_iter(GTK_COMBO_BOX(opt->widget), &iter))
|
||||
return NULL;
|
||||
|
||||
gtk_tree_model_get (combo_tree, &iter, 0, &setting, -1);
|
||||
return setting;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void vpnui_opt_set(VpnUIConfigOption *opt, const char *value)
|
||||
{
|
||||
int num_value;
|
||||
GtkTreeModel *combo_tree;
|
||||
GtkTreeIter iter;
|
||||
gboolean found;
|
||||
|
||||
g_return_if_fail(opt!=NULL);
|
||||
g_return_if_fail(value!=NULL);
|
||||
|
||||
switch (opt->option_type)
|
||||
{
|
||||
case VPN_UI_OPTTYPE_YESNO:
|
||||
if (strcmp("yes",value) == 0) {
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (opt->widget), TRUE);
|
||||
} else if (strcmp("no",value) == 0) {
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (opt->widget), FALSE);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case VPN_UI_OPTTYPE_STRING:
|
||||
gtk_entry_set_text ( GTK_ENTRY( opt->widget ), value );
|
||||
break;
|
||||
case VPN_UI_OPTTYPE_SPINNER:
|
||||
sscanf(value,"%d",&num_value);
|
||||
gtk_spin_button_set_value(GTK_SPIN_BUTTON(opt->widget),num_value);
|
||||
break;
|
||||
case VPN_UI_OPTTYPE_COMBO:
|
||||
combo_tree = gtk_combo_box_get_model(GTK_COMBO_BOX(opt->widget));
|
||||
if (combo_tree==NULL) return;
|
||||
for (found = gtk_tree_model_get_iter_first(combo_tree, &iter);
|
||||
found == TRUE;
|
||||
found = gtk_tree_model_iter_next(combo_tree, &iter)) {
|
||||
char *setting;
|
||||
gtk_tree_model_get (combo_tree, &iter, 0, &setting, -1);
|
||||
if (strcmp(setting,value)==0) {
|
||||
gtk_combo_box_set_active_iter(GTK_COMBO_BOX(opt->widget),&iter);
|
||||
return;
|
||||
}
|
||||
}
|
||||
gtk_combo_box_set_active(GTK_COMBO_BOX(opt->widget),-1);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
gboolean vpnui_opt_set_default(VpnUIConfigOption *opt, GSList *defaults)
|
||||
{
|
||||
GSList *item;
|
||||
|
||||
g_return_val_if_fail(opt!=NULL,FALSE);
|
||||
g_return_val_if_fail(defaults!=NULL,FALSE);
|
||||
|
||||
|
||||
// if (defaults == NULL) {
|
||||
// vpnui_opt_set_inactive(opt);
|
||||
// return FALSE;
|
||||
// }
|
||||
if (opt==opt->impl->connection_name_opt) {
|
||||
if (strlen(vpnui_opt_get(opt))>0)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
for (item=defaults; item != NULL; item = g_slist_next(g_slist_next(item)))
|
||||
{
|
||||
if (strcmp((char *)item->data,opt->glade_name)!=0) continue;
|
||||
if ((g_slist_next(item))->data == NULL) continue;
|
||||
vpnui_opt_set(opt,(char *)(g_slist_next(item))->data);
|
||||
vpnui_opt_set_active(opt);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
vpnui_opt_set_inactive(opt);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gboolean vpnui_opt_query_default(VpnUIConfigOption *opt, GSList *defaults)
|
||||
{
|
||||
GSList *item;
|
||||
const char *value;
|
||||
|
||||
g_return_val_if_fail(opt!=NULL,TRUE);
|
||||
|
||||
if (defaults == NULL) return TRUE;
|
||||
|
||||
for (item=defaults; item != NULL; item = g_slist_next(g_slist_next(item)))
|
||||
{
|
||||
if (strcmp(item->data,opt->glade_name)!=0) continue;
|
||||
value = vpnui_opt_get(opt);
|
||||
if (strcmp((g_slist_next(item))->data,value)==0) {
|
||||
return TRUE;
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void vpnui_opt_set_active(VpnUIConfigOption *opt)
|
||||
{
|
||||
g_return_if_fail(opt!=NULL);
|
||||
|
||||
gtk_widget_set_sensitive(GTK_WIDGET(opt->widget),TRUE);
|
||||
opt->active = TRUE;
|
||||
}
|
||||
|
||||
void vpnui_opt_set_inactive(VpnUIConfigOption *opt)
|
||||
{
|
||||
g_return_if_fail(opt!=NULL);
|
||||
|
||||
if (GTK_WIDGET(opt->widget)==GTK_WIDGET(opt->impl->variant_combo)) return;
|
||||
if (opt==opt->impl->connection_name_opt) return;
|
||||
|
||||
gtk_widget_set_sensitive(GTK_WIDGET(opt->widget),FALSE);
|
||||
opt->active = FALSE;
|
||||
}
|
||||
|
||||
gboolean vpnui_opt_validate(VpnUIConfigOption *opt)
|
||||
{
|
||||
g_return_val_if_fail(opt!=NULL,TRUE);
|
||||
|
||||
if (opt->validator==NULL) return TRUE;
|
||||
return (opt->validator)(opt);
|
||||
}
|
||||
|
||||
VpnUIConfigOption *
|
||||
impl_opt_bygconf (NetworkManagerVpnUIImpl *impl, const char *name)
|
||||
{
|
||||
GSList *item;
|
||||
VpnUIConfigOption *opt;
|
||||
|
||||
for (item=impl->config_options; item != NULL; item = g_slist_next(item))
|
||||
{
|
||||
opt = (VpnUIConfigOption *)item->data;
|
||||
if (opt == NULL) continue;
|
||||
if (opt->gconf_name == NULL) continue;
|
||||
if (strcmp(opt->gconf_name,name)==0) return opt;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
VpnUIConfigOption *
|
||||
impl_opt_byglade (NetworkManagerVpnUIImpl *impl, const char *name)
|
||||
{
|
||||
GSList *item;
|
||||
VpnUIConfigOption *opt;
|
||||
|
||||
for (item=impl->config_options; item != NULL; item = g_slist_next(item))
|
||||
{
|
||||
opt = (VpnUIConfigOption *)item->data;
|
||||
if (opt == NULL) continue;
|
||||
if (opt->glade_name == NULL) continue;
|
||||
if (strcmp(opt->glade_name,name)==0) return opt;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gboolean vpnui_opt_has_active_children(GtkContainer *container, NetworkManagerVpnUIImpl *impl)
|
||||
{
|
||||
VpnUIConfigOption *opt;
|
||||
GList *item;
|
||||
|
||||
g_return_val_if_fail(GTK_IS_CONTAINER(container) ,FALSE);
|
||||
|
||||
for (item=gtk_container_get_children(container);
|
||||
item != NULL; item=g_list_next(item)) {
|
||||
if (item->data==NULL) continue;
|
||||
// g_warning("%s has child %s",gtk_widget_get_name(GTK_WIDGET(container)),
|
||||
// gtk_widget_get_name(GTK_WIDGET(item->data)));
|
||||
opt = impl_opt_byglade(impl,gtk_widget_get_name(GTK_WIDGET(item->data)));
|
||||
if (opt!=NULL && opt->active) return TRUE;
|
||||
|
||||
if (GTK_IS_CONTAINER(item->data)
|
||||
&& vpnui_opt_has_active_children(GTK_CONTAINER(item->data),impl)) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
//const char * vpnui_opt_get(VpnUIConfigOption *opt)
|
||||
//{
|
||||
// g_return_if_fail(opt!=NULL);
|
||||
//
|
||||
// switch (opt->option_type)
|
||||
// {
|
||||
// case VPN_UI_OPTTYPE_YESNO:
|
||||
// if (gtk_toggle_button_get_active ( GTK_CHECK_BUTTON (opt->widget) )) {
|
||||
// return "yes";
|
||||
// } else {
|
||||
// return "no";
|
||||
// }
|
||||
// break;
|
||||
// case VPN_UI_OPTTYPE_STRING:
|
||||
// return gtk_entry_get_text(GTK_ENTRY(opt->widget));
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// return NULL;
|
||||
//}
|
||||
|
|
@ -1,63 +0,0 @@
|
|||
#ifndef NMVPNUI_OPT_H
|
||||
#define NMVPNUI_OPT_H
|
||||
|
||||
|
||||
#include <string.h>
|
||||
#include <glade/glade.h>
|
||||
|
||||
//##include <NetworkManager/nm-vpn-ui-interface.h>
|
||||
#include "vpnui_impl.h"
|
||||
|
||||
#define VPN_UI_OPTTYPE_YESNO 1
|
||||
#define VPN_UI_OPTTYPE_STRING 2
|
||||
#define VPN_UI_OPTTYPE_SPINNER 3
|
||||
#define VPN_UI_OPTTYPE_COMBO 4
|
||||
|
||||
#ifndef HAVE_VpnUIConfigOption
|
||||
typedef struct _VpnUIConfigOption VpnUIConfigOption;
|
||||
#endif
|
||||
|
||||
struct _VpnUIConfigOption
|
||||
{
|
||||
char *glade_name;
|
||||
int option_type;
|
||||
char *gconf_name;
|
||||
char *export_name;
|
||||
char *description;
|
||||
gboolean active;
|
||||
GCallback change_handler;
|
||||
gboolean (*validator)(VpnUIConfigOption *opt);
|
||||
GtkWidget *widget;
|
||||
NetworkManagerVpnUIImpl *impl;
|
||||
};
|
||||
|
||||
#define STORAGE_CLASS extern
|
||||
#ifdef NMVPNUI_OPT_C
|
||||
#undef STORAGE_CLASS
|
||||
#define STORAGE_CLASS
|
||||
#endif
|
||||
|
||||
STORAGE_CLASS void vpnui_opt_free(VpnUIConfigOption *opt);
|
||||
STORAGE_CLASS VpnUIConfigOption *vpnui_opt_new( char *glade_name,
|
||||
int option_type,
|
||||
char *gconf_name,
|
||||
char *export_name,
|
||||
char *description,
|
||||
void (*change_handler)(void),
|
||||
gboolean (*validator)(VpnUIConfigOption *opt),
|
||||
NetworkManagerVpnUIImpl *impl );
|
||||
STORAGE_CLASS void vpnui_opt_set_active(VpnUIConfigOption *opt);
|
||||
STORAGE_CLASS void vpnui_opt_set_inactive(VpnUIConfigOption *opt);
|
||||
STORAGE_CLASS void vpnui_opt_get_widget(VpnUIConfigOption *opt);
|
||||
//static char * vpnui_opt_get(VpnUIConfigOption *opt);
|
||||
STORAGE_CLASS void vpnui_opt_set(VpnUIConfigOption *opt, const char *value);
|
||||
STORAGE_CLASS gboolean vpnui_opt_query_default(VpnUIConfigOption *opt, GSList *defaults);
|
||||
STORAGE_CLASS gboolean vpnui_opt_set_default(VpnUIConfigOption *opt, GSList *defaults);
|
||||
STORAGE_CLASS gboolean vpnui_opt_validate(VpnUIConfigOption *opt);
|
||||
STORAGE_CLASS const char * vpnui_opt_get(VpnUIConfigOption *opt);
|
||||
STORAGE_CLASS void vpnui_opt_connect_signals(VpnUIConfigOption *opt);
|
||||
STORAGE_CLASS VpnUIConfigOption *impl_opt_bygconf (NetworkManagerVpnUIImpl *impl, const char *name);
|
||||
STORAGE_CLASS VpnUIConfigOption *impl_opt_byglade (NetworkManagerVpnUIImpl *impl, const char *name);
|
||||
STORAGE_CLASS gboolean vpnui_opt_has_active_children(GtkContainer *container, NetworkManagerVpnUIImpl *impl);
|
||||
#undef STORAGE_CLASS
|
||||
#endif
|
||||
|
|
@ -1,98 +0,0 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#define NMVPNUI_VALIDATE_C
|
||||
#include "vpnui_impl.h"
|
||||
#include "vpnui_opt.h"
|
||||
#include "vpnui_validate.h"
|
||||
|
||||
gboolean vld_non_empty (VpnUIConfigOption *opt)
|
||||
{
|
||||
const char *value = vpnui_opt_get(opt);
|
||||
if ((value == NULL) || (strlen (value) == 0)) {
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean vld_non_empty_no_ws (VpnUIConfigOption *opt)
|
||||
{
|
||||
const char *value = vpnui_opt_get(opt);
|
||||
if ((value == NULL) ||
|
||||
(strlen (value) == 0) ||
|
||||
(strstr(value, " ") != NULL) ||
|
||||
(strstr(value, "\t") != NULL) ) {
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean vld_routes_if_sens (VpnUIConfigOption *opt)
|
||||
{
|
||||
GSList *item;
|
||||
GSList *routes = NULL;
|
||||
VpnUIConfigOption *opt2;
|
||||
const char *value;
|
||||
const char *use_routes;
|
||||
char **substrs;
|
||||
int i;
|
||||
gboolean sens, is_valid;
|
||||
|
||||
sens = GTK_WIDGET_IS_SENSITIVE(GTK_WIDGET(opt->widget));
|
||||
if (!sens) return TRUE;
|
||||
|
||||
// routes = get_routes (opt->impl);
|
||||
g_return_val_if_fail(opt!=NULL,TRUE);
|
||||
value = vpnui_opt_get(opt);
|
||||
|
||||
opt2 = impl_opt_byglade(opt->impl,"use-routes");
|
||||
g_return_val_if_fail(opt2!=NULL,TRUE);
|
||||
use_routes = vpnui_opt_get(opt2);
|
||||
|
||||
if (strcmp("yes",use_routes)==0) {
|
||||
substrs = g_strsplit (value, " ", 0);
|
||||
for (i = 0; substrs[i] != NULL; i++) {
|
||||
char *route;
|
||||
|
||||
if (strlen(substrs[i]) > 0)
|
||||
routes = g_slist_append (routes, g_strdup (substrs[i]));
|
||||
}
|
||||
|
||||
g_strfreev (substrs);
|
||||
}
|
||||
|
||||
is_valid=TRUE;
|
||||
for (item = routes; item != NULL; item = g_slist_next (item)) {
|
||||
int d1, d2, d3, d4, mask;
|
||||
|
||||
const char *route = (const char *) item->data;
|
||||
//printf ("route = '%s'\n", route);
|
||||
|
||||
if (sscanf (route, "%d.%d.%d.%d/%d", &d1, &d2, &d3, &d4, &mask) != 5) {
|
||||
is_valid = FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
/* TODO: this can be improved a bit */
|
||||
if (d1 < 0 || d1 > 255 ||
|
||||
d2 < 0 || d2 > 255 ||
|
||||
d3 < 0 || d3 > 255 ||
|
||||
d4 < 0 || d4 > 255 ||
|
||||
mask < 0 || mask > 32) {
|
||||
is_valid = FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (routes != NULL) {
|
||||
g_slist_foreach (routes, (GFunc)g_free, NULL);
|
||||
g_slist_free (routes);
|
||||
}
|
||||
|
||||
return is_valid;
|
||||
}
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
#ifndef NMVPNUI_VALIDATE_H
|
||||
#define NMVPNUI_VALIDATE_H
|
||||
|
||||
#define STORAGE_CLASS extern
|
||||
#ifdef NMVPNUI_VALIDATE_C
|
||||
#undef STORAGE_CLASS
|
||||
#define STORAGE_CLASS
|
||||
#endif
|
||||
|
||||
STORAGE_CLASS gboolean vld_non_empty (VpnUIConfigOption *value);
|
||||
STORAGE_CLASS gboolean vld_non_empty_no_ws (VpnUIConfigOption *value);
|
||||
STORAGE_CLASS gboolean vld_routes_if_sens (VpnUIConfigOption *value);
|
||||
|
||||
#undef STORAGE_CLASS
|
||||
#endif
|
||||
|
|
@ -1,123 +0,0 @@
|
|||
#include <string.h>
|
||||
#include <glade/glade.h>
|
||||
|
||||
#define NMVPNUI_EXPAND_C
|
||||
#include "util_lists.h"
|
||||
#include "vpnui_opt.h"
|
||||
#include "vpnui_variant.h"
|
||||
|
||||
|
||||
void vpnui_variant_free( VpnUIVariant *variant )
|
||||
{
|
||||
g_return_if_fail(variant != NULL);
|
||||
|
||||
g_free(variant->name);
|
||||
g_free(variant->defaults);
|
||||
g_free(variant);
|
||||
}
|
||||
|
||||
VpnUIVariant *vpnui_variant_new( const char *name, const char *description,
|
||||
const char *defaults,
|
||||
NetworkManagerVpnUIImpl *impl
|
||||
)
|
||||
{
|
||||
VpnUIVariant *variant;
|
||||
GtkListStore *store;
|
||||
GtkTreeIter iter;
|
||||
GtkCellRenderer *renderer;
|
||||
gboolean first_variant=FALSE;
|
||||
|
||||
g_return_val_if_fail(name != NULL,NULL);
|
||||
g_return_val_if_fail(defaults != NULL,NULL);
|
||||
g_return_val_if_fail(impl != NULL,NULL);
|
||||
g_return_val_if_fail(impl->variant_combo != NULL,NULL);
|
||||
|
||||
if (!(variant = (VpnUIVariant *) g_new0(VpnUIVariant,1)))
|
||||
return NULL;
|
||||
|
||||
variant->name = g_strdup(name);
|
||||
variant->description = g_strdup(description);
|
||||
variant->defaults = list_from_string(defaults);
|
||||
variant->impl = impl;
|
||||
|
||||
first_variant=(impl->variants == NULL);
|
||||
|
||||
if (first_variant) {
|
||||
store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
|
||||
} else {
|
||||
store =
|
||||
(GtkListStore *)gtk_combo_box_get_model(GTK_COMBO_BOX(impl->variant_combo));
|
||||
}
|
||||
|
||||
gtk_list_store_append (store, &iter);
|
||||
gtk_list_store_set (store, &iter, 0, variant->name, 1, variant->description, -1);
|
||||
|
||||
gtk_combo_box_set_model(impl->variant_combo,GTK_TREE_MODEL(store));
|
||||
if (first_variant) {
|
||||
gtk_cell_layout_clear (GTK_CELL_LAYOUT (impl->variant_combo));
|
||||
// renderer = gtk_cell_renderer_text_new ();
|
||||
// gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (impl->variant_combo), renderer, FALSE);
|
||||
// gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (impl->variant_combo), renderer,
|
||||
// "text", 0, "visible", FALSE,
|
||||
// NULL);
|
||||
renderer = gtk_cell_renderer_text_new ();
|
||||
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (impl->variant_combo), renderer, TRUE);
|
||||
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (impl->variant_combo), renderer,
|
||||
"text", 1,
|
||||
NULL);
|
||||
}
|
||||
|
||||
// gtk_combo_box_append_text(GTK_COMBO_BOX(impl->variant_combo), variant->name);
|
||||
g_object_unref (store);
|
||||
|
||||
impl->variants = g_slist_append(impl->variants, (gpointer) variant);
|
||||
return variant;
|
||||
}
|
||||
|
||||
VpnUIVariant *
|
||||
vpnui_variant_byname (NetworkManagerVpnUIImpl *impl, const char *name)
|
||||
{
|
||||
GSList *item;
|
||||
VpnUIVariant *variant;
|
||||
|
||||
if (name==NULL) return NULL;
|
||||
|
||||
for (item=impl->variants; item != NULL; item = g_slist_next(item))
|
||||
{
|
||||
variant = (VpnUIVariant *)item->data;
|
||||
if (variant == NULL) continue;
|
||||
if (variant->name == NULL) continue;
|
||||
if (strcmp(variant->name,name)==0) return variant;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
vpnui_variant_select (VpnUIVariant *variant)
|
||||
{
|
||||
NetworkManagerVpnUIImpl *impl;
|
||||
GSList *item;
|
||||
|
||||
g_return_if_fail(variant != NULL);
|
||||
impl=variant->impl;
|
||||
|
||||
impl->defaults=variant->defaults;
|
||||
for (item=impl->config_options; item != NULL; item = g_slist_next(item)) {
|
||||
vpnui_opt_set_default((VpnUIConfigOption *)item->data, impl->defaults);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
vpnui_variant_select_byname (NetworkManagerVpnUIImpl *impl, const char *name)
|
||||
{
|
||||
VpnUIVariant *variant;
|
||||
|
||||
g_return_if_fail(impl != NULL);
|
||||
|
||||
variant = vpnui_variant_byname(impl,name);
|
||||
if (variant == NULL) return;
|
||||
vpnui_variant_select(variant);
|
||||
}
|
||||
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
#ifndef NMVPNUI_VARIANT_H
|
||||
#define NMVPNUI_VARIANT_H
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <string.h>
|
||||
#include <glade/glade.h>
|
||||
|
||||
#include "vpnui_impl.h"
|
||||
|
||||
typedef struct VpnUIVariant
|
||||
{
|
||||
char *name;
|
||||
char *description;
|
||||
GSList *defaults;
|
||||
NetworkManagerVpnUIImpl *impl;
|
||||
} VpnUIVariant;
|
||||
|
||||
#define STORAGE_CLASS extern
|
||||
#ifdef NMVPNUI_EXPAND_C
|
||||
#undef STORAGE_CLASS
|
||||
#define STORAGE_CLASS
|
||||
#endif
|
||||
|
||||
STORAGE_CLASS void vpnui_variant_free( VpnUIVariant *variant );
|
||||
STORAGE_CLASS VpnUIVariant *vpnui_variant_new( const char *name,
|
||||
const char *description,
|
||||
const char *defaults,
|
||||
NetworkManagerVpnUIImpl *impl
|
||||
);
|
||||
STORAGE_CLASS VpnUIVariant *vpnui_variant_byname (NetworkManagerVpnUIImpl *impl, const char *name);
|
||||
STORAGE_CLASS void vpnui_variant_select (VpnUIVariant *variant);
|
||||
STORAGE_CLASS void vpnui_variant_select_byname (NetworkManagerVpnUIImpl *impl, const char *name);
|
||||
#undef STORAGE_CLASS
|
||||
#endif
|
||||
|
|
@ -1,13 +1,9 @@
|
|||
INCLUDES = -I${top_srcdir} \
|
||||
-I${top_srcdir}/utils \
|
||||
-I${top_srcdir}/vpn-daemons/pptp
|
||||
INCLUDES = -I${top_srcdir}
|
||||
|
||||
AM_CPPFLAGS = \
|
||||
$(DBUS_CFLAGS) \
|
||||
$(DBUS_GLIB_CFLAGS) \
|
||||
$(GTHREAD_CFLAGS) \
|
||||
$(NETWORK_MANAGER_CFLAGS) \
|
||||
$(PPPD_CFLAGS) \
|
||||
$(NM_VPN_CFLAGS) \
|
||||
$(NM_UTILS_CFLAGS) \
|
||||
-Wall \
|
||||
-DDBUS_API_SUBJECT_TO_CHANGE \
|
||||
-DG_DISABLE_DEPRECATED \
|
||||
|
|
@ -19,45 +15,42 @@ AM_CPPFLAGS = \
|
|||
-DLIBEXECDIR=\""$(libexecdir)"\" \
|
||||
-DLOCALSTATEDIR=\""$(localstatedir)"\" \
|
||||
-DDATADIR=\"$(datadir)\" \
|
||||
-DPLUGINDIR=\"$(PPPD_PLUGIN_DIR)\" \
|
||||
-fPIC
|
||||
|
||||
bin_PROGRAMS = nm-ppp-starter
|
||||
bin_PROGRAMS = nm-pptp-service
|
||||
|
||||
pppdplugindir = $(libexecdir)/pppd/$(PPPD_VERSION)
|
||||
pppdplugin_LTLIBRARIES = nm-pppd-plugin.la
|
||||
nm_pptp_service_SOURCES = \
|
||||
nm-pptp-service.c \
|
||||
nm-pptp-service.h
|
||||
|
||||
nm_ppp_starter_SOURCES = \
|
||||
nm-ppp-starter.c \
|
||||
nm-ppp-starter.h \
|
||||
nm-utils.c \
|
||||
nm-utils.h \
|
||||
external/2.4.3/pppd/patchlevel.h \
|
||||
external/2.4.3/pppd/ipcp.h \
|
||||
external/2.4.3/pppd/pppd.h \
|
||||
external/2.4.3/pppd/fsm.h \
|
||||
external/2.4.4/pppd/patchlevel.h \
|
||||
external/2.4.4/pppd/ipcp.h \
|
||||
external/2.4.4/pppd/pppd.h \
|
||||
external/2.4.4/pppd/fsm.h \
|
||||
external/2.4.4b1/pppd/patchlevel.h \
|
||||
external/2.4.4b1/pppd/ipcp.h \
|
||||
external/2.4.4b1/pppd/pppd.h \
|
||||
external/2.4.4b1/pppd/fsm.h
|
||||
nm-pptp-pppd-service-glue.h: $(top_srcdir)/src/nm-pptp-pppd-service.xml
|
||||
dbus-binding-tool --prefix=nm_pptp_pppd_service --mode=glib-server --output=$@ $<
|
||||
|
||||
nm_ppp_starter_LDADD = \
|
||||
$(DBUS_LIBS) \
|
||||
nm_pptp_service_LDADD = \
|
||||
$(DBUS_GLIB_LIBS) \
|
||||
$(GTHREAD_LIBS) \
|
||||
$(NETWORK_MANAGER_LIBS)
|
||||
$(NM_UTILS_LIBS)
|
||||
|
||||
nm_pppd_plugin_la_SOURCES = \
|
||||
nm-pppd-plugin.c \
|
||||
nm-pppd-plugin.h \
|
||||
nm-ppp-starter.h
|
||||
pppd_plugindir = $(PPPD_PLUGIN_DIR)
|
||||
pppd_plugin_LTLIBRARIES = nm-pptp-pppd-plugin.la
|
||||
|
||||
nm_pppd_plugin_la_LDFLAGS = -module
|
||||
nm_pptp_pppd_plugin_la_SOURCES = \
|
||||
nm-pptp-pppd-plugin.c \
|
||||
nm-ppp-status.h
|
||||
|
||||
nm_pppd_plugin_la_LIBADD = \
|
||||
$(DBUS_LIBS) \
|
||||
$(GTHREAD_LIBS)
|
||||
nm_pptp_pppd_plugin_la_CPPFLAGS = \
|
||||
$(DBUS_GLIB_CFLAGS) \
|
||||
$(GLIB_CFLAGS) \
|
||||
$(NM_UTILS_CFLAGS)
|
||||
|
||||
CLEANFILES = *~
|
||||
nm_pptp_pppd_plugin_la_LDFLAGS = -module -avoid-version
|
||||
|
||||
nm_pptp_pppd_plugin_la_LIBADD = \
|
||||
$(DBUS_GLIB_LIBS) \
|
||||
$(GLIB_LIBS) \
|
||||
$(NM_UTILS_LIBS)
|
||||
|
||||
BUILT_SOURCES = nm-pptp-pppd-service-glue.h
|
||||
|
||||
CLEANFILES = $(BUILT_SOURCES)
|
||||
|
|
|
|||
168
vpn-daemons/pptp/src/external/2.4.3/pppd/fsm.h
vendored
168
vpn-daemons/pptp/src/external/2.4.3/pppd/fsm.h
vendored
|
|
@ -1,168 +0,0 @@
|
|||
/*
|
||||
* fsm.h - {Link, IP} Control Protocol Finite State Machine definitions.
|
||||
*
|
||||
* Copyright (c) 1984-2000 Carnegie Mellon University. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. The name "Carnegie Mellon University" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For permission or any legal
|
||||
* details, please contact
|
||||
* Office of Technology Transfer
|
||||
* Carnegie Mellon University
|
||||
* 5000 Forbes Avenue
|
||||
* Pittsburgh, PA 15213-3890
|
||||
* (412) 268-4387, fax: (412) 268-7395
|
||||
* tech-transfer@andrew.cmu.edu
|
||||
*
|
||||
* 4. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by Computing Services
|
||||
* at Carnegie Mellon University (http://www.cmu.edu/computing/)."
|
||||
*
|
||||
* CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
|
||||
* FOR ANY SPECIAL, 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.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/*
|
||||
* Packet header = Code, id, length.
|
||||
*/
|
||||
#define HEADERLEN 4
|
||||
|
||||
|
||||
/*
|
||||
* CP (LCP, IPCP, etc.) codes.
|
||||
*/
|
||||
#define CONFREQ 1 /* Configuration Request */
|
||||
#define CONFACK 2 /* Configuration Ack */
|
||||
#define CONFNAK 3 /* Configuration Nak */
|
||||
#define CONFREJ 4 /* Configuration Reject */
|
||||
#define TERMREQ 5 /* Termination Request */
|
||||
#define TERMACK 6 /* Termination Ack */
|
||||
#define CODEREJ 7 /* Code Reject */
|
||||
|
||||
|
||||
/*
|
||||
* Each FSM is described by an fsm structure and fsm callbacks.
|
||||
*/
|
||||
typedef struct fsm {
|
||||
int unit; /* Interface unit number */
|
||||
int protocol; /* Data Link Layer Protocol field value */
|
||||
int state; /* State */
|
||||
int flags; /* Contains option bits */
|
||||
u_char id; /* Current id */
|
||||
u_char reqid; /* Current request id */
|
||||
u_char seen_ack; /* Have received valid Ack/Nak/Rej to Req */
|
||||
int timeouttime; /* Timeout time in milliseconds */
|
||||
int maxconfreqtransmits; /* Maximum Configure-Request transmissions */
|
||||
int retransmits; /* Number of retransmissions left */
|
||||
int maxtermtransmits; /* Maximum Terminate-Request transmissions */
|
||||
int nakloops; /* Number of nak loops since last ack */
|
||||
int rnakloops; /* Number of naks received */
|
||||
int maxnakloops; /* Maximum number of nak loops tolerated */
|
||||
struct fsm_callbacks *callbacks; /* Callback routines */
|
||||
char *term_reason; /* Reason for closing protocol */
|
||||
int term_reason_len; /* Length of term_reason */
|
||||
} fsm;
|
||||
|
||||
|
||||
typedef struct fsm_callbacks {
|
||||
void (*resetci) /* Reset our Configuration Information */
|
||||
__P((fsm *));
|
||||
int (*cilen) /* Length of our Configuration Information */
|
||||
__P((fsm *));
|
||||
void (*addci) /* Add our Configuration Information */
|
||||
__P((fsm *, u_char *, int *));
|
||||
int (*ackci) /* ACK our Configuration Information */
|
||||
__P((fsm *, u_char *, int));
|
||||
int (*nakci) /* NAK our Configuration Information */
|
||||
__P((fsm *, u_char *, int, int));
|
||||
int (*rejci) /* Reject our Configuration Information */
|
||||
__P((fsm *, u_char *, int));
|
||||
int (*reqci) /* Request peer's Configuration Information */
|
||||
__P((fsm *, u_char *, int *, int));
|
||||
void (*up) /* Called when fsm reaches OPENED state */
|
||||
__P((fsm *));
|
||||
void (*down) /* Called when fsm leaves OPENED state */
|
||||
__P((fsm *));
|
||||
void (*starting) /* Called when we want the lower layer */
|
||||
__P((fsm *));
|
||||
void (*finished) /* Called when we don't want the lower layer */
|
||||
__P((fsm *));
|
||||
void (*protreject) /* Called when Protocol-Reject received */
|
||||
__P((int));
|
||||
void (*retransmit) /* Retransmission is necessary */
|
||||
__P((fsm *));
|
||||
int (*extcode) /* Called when unknown code received */
|
||||
__P((fsm *, int, int, u_char *, int));
|
||||
char *proto_name; /* String name for protocol (for messages) */
|
||||
} fsm_callbacks;
|
||||
|
||||
|
||||
/*
|
||||
* Link states.
|
||||
*/
|
||||
#define INITIAL 0 /* Down, hasn't been opened */
|
||||
#define STARTING 1 /* Down, been opened */
|
||||
#define CLOSED 2 /* Up, hasn't been opened */
|
||||
#define STOPPED 3 /* Open, waiting for down event */
|
||||
#define CLOSING 4 /* Terminating the connection, not open */
|
||||
#define STOPPING 5 /* Terminating, but open */
|
||||
#define REQSENT 6 /* We've sent a Config Request */
|
||||
#define ACKRCVD 7 /* We've received a Config Ack */
|
||||
#define ACKSENT 8 /* We've sent a Config Ack */
|
||||
#define OPENED 9 /* Connection available */
|
||||
|
||||
|
||||
/*
|
||||
* Flags - indicate options controlling FSM operation
|
||||
*/
|
||||
#define OPT_PASSIVE 1 /* Don't die if we don't get a response */
|
||||
#define OPT_RESTART 2 /* Treat 2nd OPEN as DOWN, UP */
|
||||
#define OPT_SILENT 4 /* Wait for peer to speak first */
|
||||
|
||||
|
||||
/*
|
||||
* Timeouts.
|
||||
*/
|
||||
#define DEFTIMEOUT 3 /* Timeout time in seconds */
|
||||
#define DEFMAXTERMREQS 2 /* Maximum Terminate-Request transmissions */
|
||||
#define DEFMAXCONFREQS 10 /* Maximum Configure-Request transmissions */
|
||||
#define DEFMAXNAKLOOPS 5 /* Maximum number of nak loops */
|
||||
|
||||
|
||||
/*
|
||||
* Prototypes
|
||||
*/
|
||||
void fsm_init __P((fsm *));
|
||||
void fsm_lowerup __P((fsm *));
|
||||
void fsm_lowerdown __P((fsm *));
|
||||
void fsm_open __P((fsm *));
|
||||
void fsm_close __P((fsm *, char *));
|
||||
void fsm_input __P((fsm *, u_char *, int));
|
||||
void fsm_protreject __P((fsm *));
|
||||
void fsm_sdata __P((fsm *, int, int, u_char *, int));
|
||||
|
||||
|
||||
/*
|
||||
* Variables
|
||||
*/
|
||||
extern int peer_mru[]; /* currently negotiated peer MRU (per unit) */
|
||||
96
vpn-daemons/pptp/src/external/2.4.3/pppd/ipcp.h
vendored
96
vpn-daemons/pptp/src/external/2.4.3/pppd/ipcp.h
vendored
|
|
@ -1,96 +0,0 @@
|
|||
/*
|
||||
* ipcp.h - IP Control Protocol definitions.
|
||||
*
|
||||
* Copyright (c) 1984-2000 Carnegie Mellon University. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. The name "Carnegie Mellon University" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For permission or any legal
|
||||
* details, please contact
|
||||
* Office of Technology Transfer
|
||||
* Carnegie Mellon University
|
||||
* 5000 Forbes Avenue
|
||||
* Pittsburgh, PA 15213-3890
|
||||
* (412) 268-4387, fax: (412) 268-7395
|
||||
* tech-transfer@andrew.cmu.edu
|
||||
*
|
||||
* 4. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by Computing Services
|
||||
* at Carnegie Mellon University (http://www.cmu.edu/computing/)."
|
||||
*
|
||||
* CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
|
||||
* FOR ANY SPECIAL, 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.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/*
|
||||
* Options.
|
||||
*/
|
||||
#define CI_ADDRS 1 /* IP Addresses */
|
||||
#define CI_COMPRESSTYPE 2 /* Compression Type */
|
||||
#define CI_ADDR 3
|
||||
|
||||
#define CI_MS_DNS1 129 /* Primary DNS value */
|
||||
#define CI_MS_WINS1 130 /* Primary WINS value */
|
||||
#define CI_MS_DNS2 131 /* Secondary DNS value */
|
||||
#define CI_MS_WINS2 132 /* Secondary WINS value */
|
||||
|
||||
#define MAX_STATES 16 /* from slcompress.h */
|
||||
|
||||
#define IPCP_VJMODE_OLD 1 /* "old" mode (option # = 0x0037) */
|
||||
#define IPCP_VJMODE_RFC1172 2 /* "old-rfc"mode (option # = 0x002d) */
|
||||
#define IPCP_VJMODE_RFC1332 3 /* "new-rfc"mode (option # = 0x002d, */
|
||||
/* maxslot and slot number compression) */
|
||||
|
||||
#define IPCP_VJ_COMP 0x002d /* current value for VJ compression option*/
|
||||
#define IPCP_VJ_COMP_OLD 0x0037 /* "old" (i.e, broken) value for VJ */
|
||||
/* compression option*/
|
||||
|
||||
typedef struct ipcp_options {
|
||||
bool neg_addr; /* Negotiate IP Address? */
|
||||
bool old_addrs; /* Use old (IP-Addresses) option? */
|
||||
bool req_addr; /* Ask peer to send IP address? */
|
||||
bool default_route; /* Assign default route through interface? */
|
||||
bool proxy_arp; /* Make proxy ARP entry for peer? */
|
||||
bool neg_vj; /* Van Jacobson Compression? */
|
||||
bool old_vj; /* use old (short) form of VJ option? */
|
||||
bool accept_local; /* accept peer's value for ouraddr */
|
||||
bool accept_remote; /* accept peer's value for hisaddr */
|
||||
bool req_dns1; /* Ask peer to send primary DNS address? */
|
||||
bool req_dns2; /* Ask peer to send secondary DNS address? */
|
||||
int vj_protocol; /* protocol value to use in VJ option */
|
||||
int maxslotindex; /* values for RFC1332 VJ compression neg. */
|
||||
bool cflag;
|
||||
u_int32_t ouraddr, hisaddr; /* Addresses in NETWORK BYTE ORDER */
|
||||
u_int32_t dnsaddr[2]; /* Primary and secondary MS DNS entries */
|
||||
u_int32_t winsaddr[2]; /* Primary and secondary MS WINS entries */
|
||||
} ipcp_options;
|
||||
|
||||
extern fsm ipcp_fsm[];
|
||||
extern ipcp_options ipcp_wantoptions[];
|
||||
extern ipcp_options ipcp_gotoptions[];
|
||||
extern ipcp_options ipcp_allowoptions[];
|
||||
extern ipcp_options ipcp_hisoptions[];
|
||||
|
||||
char *ip_ntoa __P((u_int32_t));
|
||||
|
||||
extern struct protent ipcp_protent;
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
/* $Id$ */
|
||||
|
||||
#define VERSION "2.4.3"
|
||||
#define DATE "13 November 2004"
|
||||
910
vpn-daemons/pptp/src/external/2.4.3/pppd/pppd.h
vendored
910
vpn-daemons/pptp/src/external/2.4.3/pppd/pppd.h
vendored
|
|
@ -1,910 +0,0 @@
|
|||
/*
|
||||
* pppd.h - PPP daemon global declarations.
|
||||
*
|
||||
* Copyright (c) 1984-2000 Carnegie Mellon University. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. The name "Carnegie Mellon University" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For permission or any legal
|
||||
* details, please contact
|
||||
* Office of Technology Transfer
|
||||
* Carnegie Mellon University
|
||||
* 5000 Forbes Avenue
|
||||
* Pittsburgh, PA 15213-3890
|
||||
* (412) 268-4387, fax: (412) 268-7395
|
||||
* tech-transfer@andrew.cmu.edu
|
||||
*
|
||||
* 4. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by Computing Services
|
||||
* at Carnegie Mellon University (http://www.cmu.edu/computing/)."
|
||||
*
|
||||
* CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
|
||||
* FOR ANY SPECIAL, 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.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/*
|
||||
* TODO:
|
||||
*/
|
||||
|
||||
#ifndef __PPPD_H__
|
||||
#define __PPPD_H__
|
||||
|
||||
#include <stdio.h> /* for FILE */
|
||||
#include <limits.h> /* for NGROUPS_MAX */
|
||||
#include <sys/param.h> /* for MAXPATHLEN and BSD4_4, if defined */
|
||||
#include <sys/types.h> /* for u_int32_t, if defined */
|
||||
#include <sys/time.h> /* for struct timeval */
|
||||
#include <net/ppp_defs.h>
|
||||
#include "patchlevel.h"
|
||||
|
||||
#if defined(__STDC__)
|
||||
#include <stdarg.h>
|
||||
#define __V(x) x
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#define __V(x) (va_alist) va_dcl
|
||||
#define const
|
||||
#define volatile
|
||||
#endif
|
||||
|
||||
#ifdef INET6
|
||||
#include "eui64.h"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Limits.
|
||||
*/
|
||||
|
||||
#define NUM_PPP 1 /* One PPP interface supported (per process) */
|
||||
#define MAXWORDLEN 1024 /* max length of word in file (incl null) */
|
||||
#define MAXARGS 1 /* max # args to a command */
|
||||
#define MAXNAMELEN 256 /* max length of hostname or name for auth */
|
||||
#define MAXSECRETLEN 256 /* max length of password or secret */
|
||||
|
||||
/*
|
||||
* Option descriptor structure.
|
||||
*/
|
||||
|
||||
typedef unsigned char bool;
|
||||
|
||||
enum opt_type {
|
||||
o_special_noarg = 0,
|
||||
o_special = 1,
|
||||
o_bool,
|
||||
o_int,
|
||||
o_uint32,
|
||||
o_string,
|
||||
o_wild
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
char *name; /* name of the option */
|
||||
enum opt_type type;
|
||||
void *addr;
|
||||
char *description;
|
||||
unsigned int flags;
|
||||
void *addr2;
|
||||
int upper_limit;
|
||||
int lower_limit;
|
||||
const char *source;
|
||||
short int priority;
|
||||
short int winner;
|
||||
} option_t;
|
||||
|
||||
/* Values for flags */
|
||||
#define OPT_VALUE 0xff /* mask for presupplied value */
|
||||
#define OPT_HEX 0x100 /* int option is in hex */
|
||||
#define OPT_NOARG 0x200 /* option doesn't take argument */
|
||||
#define OPT_OR 0x400 /* OR in argument to value */
|
||||
#define OPT_INC 0x800 /* increment value */
|
||||
#define OPT_A2OR 0x800 /* for o_bool, OR arg to *(u_char *)addr2 */
|
||||
#define OPT_PRIV 0x1000 /* privileged option */
|
||||
#define OPT_STATIC 0x2000 /* string option goes into static array */
|
||||
#define OPT_LLIMIT 0x4000 /* check value against lower limit */
|
||||
#define OPT_ULIMIT 0x8000 /* check value against upper limit */
|
||||
#define OPT_LIMITS (OPT_LLIMIT|OPT_ULIMIT)
|
||||
#define OPT_ZEROOK 0x10000 /* 0 value is OK even if not within limits */
|
||||
#define OPT_HIDE 0x10000 /* for o_string, print value as ?????? */
|
||||
#define OPT_A2LIST 0x10000 /* for o_special, keep list of values */
|
||||
#define OPT_A2CLRB 0x10000 /* o_bool, clr val bits in *(u_char *)addr2 */
|
||||
#define OPT_NOINCR 0x20000 /* value mustn't be increased */
|
||||
#define OPT_ZEROINF 0x40000 /* with OPT_NOINCR, 0 == infinity */
|
||||
#define OPT_PRIO 0x80000 /* process option priorities for this option */
|
||||
#define OPT_PRIOSUB 0x100000 /* subsidiary member of priority group */
|
||||
#define OPT_ALIAS 0x200000 /* option is alias for previous option */
|
||||
#define OPT_A2COPY 0x400000 /* addr2 -> second location to rcv value */
|
||||
#define OPT_ENABLE 0x800000 /* use *addr2 as enable for option */
|
||||
#define OPT_A2CLR 0x1000000 /* clear *(bool *)addr2 */
|
||||
#define OPT_PRIVFIX 0x2000000 /* user can't override if set by root */
|
||||
#define OPT_INITONLY 0x4000000 /* option can only be set in init phase */
|
||||
#define OPT_DEVEQUIV 0x8000000 /* equiv to device name */
|
||||
#define OPT_DEVNAM (OPT_INITONLY | OPT_DEVEQUIV)
|
||||
#define OPT_A2PRINTER 0x10000000 /* *addr2 is a fn for printing option */
|
||||
#define OPT_A2STRVAL 0x20000000 /* *addr2 points to current string value */
|
||||
#define OPT_NOPRINT 0x40000000 /* don't print this option at all */
|
||||
|
||||
#define OPT_VAL(x) ((x) & OPT_VALUE)
|
||||
|
||||
/* Values for priority */
|
||||
#define OPRIO_DEFAULT 0 /* a default value */
|
||||
#define OPRIO_CFGFILE 1 /* value from a configuration file */
|
||||
#define OPRIO_CMDLINE 2 /* value from the command line */
|
||||
#define OPRIO_SECFILE 3 /* value from options in a secrets file */
|
||||
#define OPRIO_ROOT 100 /* added to priority if OPT_PRIVFIX && root */
|
||||
|
||||
#ifndef GIDSET_TYPE
|
||||
#define GIDSET_TYPE gid_t
|
||||
#endif
|
||||
|
||||
/* Structure representing a list of permitted IP addresses. */
|
||||
struct permitted_ip {
|
||||
int permit; /* 1 = permit, 0 = forbid */
|
||||
u_int32_t base; /* match if (addr & mask) == base */
|
||||
u_int32_t mask; /* base and mask are in network byte order */
|
||||
};
|
||||
|
||||
/*
|
||||
* Unfortunately, the linux kernel driver uses a different structure
|
||||
* for statistics from the rest of the ports.
|
||||
* This structure serves as a common representation for the bits
|
||||
* pppd needs.
|
||||
*/
|
||||
struct pppd_stats {
|
||||
unsigned int bytes_in;
|
||||
unsigned int bytes_out;
|
||||
unsigned int pkts_in;
|
||||
unsigned int pkts_out;
|
||||
};
|
||||
|
||||
/* Used for storing a sequence of words. Usually malloced. */
|
||||
struct wordlist {
|
||||
struct wordlist *next;
|
||||
char *word;
|
||||
};
|
||||
|
||||
/* An endpoint discriminator, used with multilink. */
|
||||
#define MAX_ENDP_LEN 20 /* maximum length of discriminator value */
|
||||
struct epdisc {
|
||||
unsigned char class;
|
||||
unsigned char length;
|
||||
unsigned char value[MAX_ENDP_LEN];
|
||||
};
|
||||
|
||||
/* values for epdisc.class */
|
||||
#define EPD_NULL 0 /* null discriminator, no data */
|
||||
#define EPD_LOCAL 1
|
||||
#define EPD_IP 2
|
||||
#define EPD_MAC 3
|
||||
#define EPD_MAGIC 4
|
||||
#define EPD_PHONENUM 5
|
||||
|
||||
typedef void (*notify_func) __P((void *, int));
|
||||
|
||||
struct notifier {
|
||||
struct notifier *next;
|
||||
notify_func func;
|
||||
void *arg;
|
||||
};
|
||||
|
||||
/*
|
||||
* Global variables.
|
||||
*/
|
||||
|
||||
extern int hungup; /* Physical layer has disconnected */
|
||||
extern int ifunit; /* Interface unit number */
|
||||
extern char ifname[]; /* Interface name */
|
||||
extern char hostname[]; /* Our hostname */
|
||||
extern u_char outpacket_buf[]; /* Buffer for outgoing packets */
|
||||
extern int devfd; /* fd of underlying device */
|
||||
extern int fd_ppp; /* fd for talking PPP */
|
||||
extern int phase; /* Current state of link - see values below */
|
||||
extern int baud_rate; /* Current link speed in bits/sec */
|
||||
extern char *progname; /* Name of this program */
|
||||
extern int redirect_stderr;/* Connector's stderr should go to file */
|
||||
extern char peer_authname[];/* Authenticated name of peer */
|
||||
extern int auth_done[NUM_PPP]; /* Methods actually used for auth */
|
||||
extern int privileged; /* We were run by real-uid root */
|
||||
extern int need_holdoff; /* Need holdoff period after link terminates */
|
||||
extern char **script_env; /* Environment variables for scripts */
|
||||
extern int detached; /* Have detached from controlling tty */
|
||||
extern GIDSET_TYPE groups[NGROUPS_MAX]; /* groups the user is in */
|
||||
extern int ngroups; /* How many groups valid in groups */
|
||||
extern struct pppd_stats link_stats; /* byte/packet counts etc. for link */
|
||||
extern int link_stats_valid; /* set if link_stats is valid */
|
||||
extern unsigned link_connect_time; /* time the link was up for */
|
||||
extern int using_pty; /* using pty as device (notty or pty opt.) */
|
||||
extern int log_to_fd; /* logging to this fd as well as syslog */
|
||||
extern bool log_default; /* log_to_fd is default (stdout) */
|
||||
extern char *no_ppp_msg; /* message to print if ppp not in kernel */
|
||||
extern volatile int status; /* exit status for pppd */
|
||||
extern bool devnam_fixed; /* can no longer change devnam */
|
||||
extern int unsuccess; /* # unsuccessful connection attempts */
|
||||
extern int do_callback; /* set if we want to do callback next */
|
||||
extern int doing_callback; /* set if this is a callback */
|
||||
extern int error_count; /* # of times error() has been called */
|
||||
extern char ppp_devnam[MAXPATHLEN];
|
||||
extern char remote_number[MAXNAMELEN]; /* Remote telephone number, if avail. */
|
||||
extern int ppp_session_number; /* Session number (eg PPPoE session) */
|
||||
extern int fd_devnull; /* fd open to /dev/null */
|
||||
|
||||
extern int listen_time; /* time to listen first (ms) */
|
||||
extern bool doing_multilink;
|
||||
extern bool multilink_master;
|
||||
extern bool bundle_eof;
|
||||
extern bool bundle_terminating;
|
||||
|
||||
extern struct notifier *pidchange; /* for notifications of pid changing */
|
||||
extern struct notifier *phasechange; /* for notifications of phase changes */
|
||||
extern struct notifier *exitnotify; /* for notification that we're exiting */
|
||||
extern struct notifier *sigreceived; /* notification of received signal */
|
||||
extern struct notifier *ip_up_notifier; /* IPCP has come up */
|
||||
extern struct notifier *ip_down_notifier; /* IPCP has gone down */
|
||||
extern struct notifier *auth_up_notifier; /* peer has authenticated */
|
||||
extern struct notifier *link_down_notifier; /* link has gone down */
|
||||
extern struct notifier *fork_notifier; /* we are a new child process */
|
||||
|
||||
/* Values for do_callback and doing_callback */
|
||||
#define CALLBACK_DIALIN 1 /* we are expecting the call back */
|
||||
#define CALLBACK_DIALOUT 2 /* we are dialling out to call back */
|
||||
|
||||
/*
|
||||
* Variables set by command-line options.
|
||||
*/
|
||||
|
||||
extern int debug; /* Debug flag */
|
||||
extern int kdebugflag; /* Tell kernel to print debug messages */
|
||||
extern int default_device; /* Using /dev/tty or equivalent */
|
||||
extern char devnam[MAXPATHLEN]; /* Device name */
|
||||
extern int crtscts; /* Use hardware flow control */
|
||||
extern bool modem; /* Use modem control lines */
|
||||
extern int inspeed; /* Input/Output speed requested */
|
||||
extern u_int32_t netmask; /* IP netmask to set on interface */
|
||||
extern bool lockflag; /* Create lock file to lock the serial dev */
|
||||
extern bool nodetach; /* Don't detach from controlling tty */
|
||||
extern bool updetach; /* Detach from controlling tty when link up */
|
||||
extern char *initializer; /* Script to initialize physical link */
|
||||
extern char *connect_script; /* Script to establish physical link */
|
||||
extern char *disconnect_script; /* Script to disestablish physical link */
|
||||
extern char *welcomer; /* Script to welcome client after connection */
|
||||
extern char *ptycommand; /* Command to run on other side of pty */
|
||||
extern int maxconnect; /* Maximum connect time (seconds) */
|
||||
extern char user[MAXNAMELEN];/* Our name for authenticating ourselves */
|
||||
extern char passwd[MAXSECRETLEN]; /* Password for PAP or CHAP */
|
||||
extern bool auth_required; /* Peer is required to authenticate */
|
||||
extern bool persist; /* Reopen link after it goes down */
|
||||
extern bool uselogin; /* Use /etc/passwd for checking PAP */
|
||||
extern char our_name[MAXNAMELEN];/* Our name for authentication purposes */
|
||||
extern char remote_name[MAXNAMELEN]; /* Peer's name for authentication */
|
||||
extern bool explicit_remote;/* remote_name specified with remotename opt */
|
||||
extern bool demand; /* Do dial-on-demand */
|
||||
extern bool killoldaddr; /* If our IP is reassigned on
|
||||
reconnect, kill active TCP
|
||||
connections using the old IP. */
|
||||
extern char *ipparam; /* Extra parameter for ip up/down scripts */
|
||||
extern bool cryptpap; /* Others' PAP passwords are encrypted */
|
||||
extern int idle_time_limit;/* Shut down link if idle for this long */
|
||||
extern int holdoff; /* Dead time before restarting */
|
||||
extern bool holdoff_specified; /* true if user gave a holdoff value */
|
||||
extern bool notty; /* Stdin/out is not a tty */
|
||||
extern char *pty_socket; /* Socket to connect to pty */
|
||||
extern char *record_file; /* File to record chars sent/received */
|
||||
extern bool sync_serial; /* Device is synchronous serial device */
|
||||
extern int maxfail; /* Max # of unsuccessful connection attempts */
|
||||
extern char linkname[MAXPATHLEN]; /* logical name for link */
|
||||
extern bool tune_kernel; /* May alter kernel settings as necessary */
|
||||
extern int connect_delay; /* Time to delay after connect script */
|
||||
extern int max_data_rate; /* max bytes/sec through charshunt */
|
||||
extern int req_unit; /* interface unit number to use */
|
||||
extern bool multilink; /* enable multilink operation */
|
||||
extern bool noendpoint; /* don't send or accept endpt. discrim. */
|
||||
extern char *bundle_name; /* bundle name for multilink */
|
||||
extern bool dump_options; /* print out option values */
|
||||
extern bool dryrun; /* check everything, print options, exit */
|
||||
extern int child_wait; /* # seconds to wait for children at end */
|
||||
|
||||
#ifdef MAXOCTETS
|
||||
extern unsigned int maxoctets; /* Maximum octetes per session (in bytes) */
|
||||
extern int maxoctets_dir; /* Direction :
|
||||
0 - in+out (default)
|
||||
1 - in
|
||||
2 - out
|
||||
3 - max(in,out) */
|
||||
extern int maxoctets_timeout; /* Timeout for check of octets limit */
|
||||
#define PPP_OCTETS_DIRECTION_SUM 0
|
||||
#define PPP_OCTETS_DIRECTION_IN 1
|
||||
#define PPP_OCTETS_DIRECTION_OUT 2
|
||||
#define PPP_OCTETS_DIRECTION_MAXOVERAL 3
|
||||
/* same as previos, but little different on RADIUS side */
|
||||
#define PPP_OCTETS_DIRECTION_MAXSESSION 4
|
||||
#endif
|
||||
|
||||
#ifdef PPP_FILTER
|
||||
extern struct bpf_program pass_filter; /* Filter for pkts to pass */
|
||||
extern struct bpf_program active_filter; /* Filter for link-active pkts */
|
||||
#endif
|
||||
|
||||
#ifdef MSLANMAN
|
||||
extern bool ms_lanman; /* Use LanMan password instead of NT */
|
||||
/* Has meaning only with MS-CHAP challenges */
|
||||
#endif
|
||||
|
||||
/* Values for auth_pending, auth_done */
|
||||
#define PAP_WITHPEER 0x1
|
||||
#define PAP_PEER 0x2
|
||||
#define CHAP_WITHPEER 0x4
|
||||
#define CHAP_PEER 0x8
|
||||
#define EAP_WITHPEER 0x10
|
||||
#define EAP_PEER 0x20
|
||||
|
||||
/* Values for auth_done only */
|
||||
#define CHAP_MD5_WITHPEER 0x40
|
||||
#define CHAP_MD5_PEER 0x80
|
||||
#define CHAP_MS_SHIFT 8 /* LSB position for MS auths */
|
||||
#define CHAP_MS_WITHPEER 0x100
|
||||
#define CHAP_MS_PEER 0x200
|
||||
#define CHAP_MS2_WITHPEER 0x400
|
||||
#define CHAP_MS2_PEER 0x800
|
||||
|
||||
extern char *current_option; /* the name of the option being parsed */
|
||||
extern int privileged_option; /* set iff the current option came from root */
|
||||
extern char *option_source; /* string saying where the option came from */
|
||||
extern int option_priority; /* priority of current options */
|
||||
|
||||
/*
|
||||
* Values for phase.
|
||||
*/
|
||||
#define PHASE_DEAD 0
|
||||
#define PHASE_INITIALIZE 1
|
||||
#define PHASE_SERIALCONN 2
|
||||
#define PHASE_DORMANT 3
|
||||
#define PHASE_ESTABLISH 4
|
||||
#define PHASE_AUTHENTICATE 5
|
||||
#define PHASE_CALLBACK 6
|
||||
#define PHASE_NETWORK 7
|
||||
#define PHASE_RUNNING 8
|
||||
#define PHASE_TERMINATE 9
|
||||
#define PHASE_DISCONNECT 10
|
||||
#define PHASE_HOLDOFF 11
|
||||
#define PHASE_MASTER 12
|
||||
|
||||
/*
|
||||
* The following struct gives the addresses of procedures to call
|
||||
* for a particular protocol.
|
||||
*/
|
||||
struct protent {
|
||||
u_short protocol; /* PPP protocol number */
|
||||
/* Initialization procedure */
|
||||
void (*init) __P((int unit));
|
||||
/* Process a received packet */
|
||||
void (*input) __P((int unit, u_char *pkt, int len));
|
||||
/* Process a received protocol-reject */
|
||||
void (*protrej) __P((int unit));
|
||||
/* Lower layer has come up */
|
||||
void (*lowerup) __P((int unit));
|
||||
/* Lower layer has gone down */
|
||||
void (*lowerdown) __P((int unit));
|
||||
/* Open the protocol */
|
||||
void (*open) __P((int unit));
|
||||
/* Close the protocol */
|
||||
void (*close) __P((int unit, char *reason));
|
||||
/* Print a packet in readable form */
|
||||
int (*printpkt) __P((u_char *pkt, int len,
|
||||
void (*printer) __P((void *, char *, ...)),
|
||||
void *arg));
|
||||
/* Process a received data packet */
|
||||
void (*datainput) __P((int unit, u_char *pkt, int len));
|
||||
bool enabled_flag; /* 0 iff protocol is disabled */
|
||||
char *name; /* Text name of protocol */
|
||||
char *data_name; /* Text name of corresponding data protocol */
|
||||
option_t *options; /* List of command-line options */
|
||||
/* Check requested options, assign defaults */
|
||||
void (*check_options) __P((void));
|
||||
/* Configure interface for demand-dial */
|
||||
int (*demand_conf) __P((int unit));
|
||||
/* Say whether to bring up link for this pkt */
|
||||
int (*active_pkt) __P((u_char *pkt, int len));
|
||||
};
|
||||
|
||||
/* Table of pointers to supported protocols */
|
||||
extern struct protent *protocols[];
|
||||
|
||||
/*
|
||||
* This struct contains pointers to a set of procedures for
|
||||
* doing operations on a "channel". A channel provides a way
|
||||
* to send and receive PPP packets - the canonical example is
|
||||
* a serial port device in PPP line discipline (or equivalently
|
||||
* with PPP STREAMS modules pushed onto it).
|
||||
*/
|
||||
struct channel {
|
||||
/* set of options for this channel */
|
||||
option_t *options;
|
||||
/* find and process a per-channel options file */
|
||||
void (*process_extra_options) __P((void));
|
||||
/* check all the options that have been given */
|
||||
void (*check_options) __P((void));
|
||||
/* get the channel ready to do PPP, return a file descriptor */
|
||||
int (*connect) __P((void));
|
||||
/* we're finished with the channel */
|
||||
void (*disconnect) __P((void));
|
||||
/* put the channel into PPP `mode' */
|
||||
int (*establish_ppp) __P((int));
|
||||
/* take the channel out of PPP `mode', restore loopback if demand */
|
||||
void (*disestablish_ppp) __P((int));
|
||||
/* set the transmit-side PPP parameters of the channel */
|
||||
void (*send_config) __P((int, u_int32_t, int, int));
|
||||
/* set the receive-side PPP parameters of the channel */
|
||||
void (*recv_config) __P((int, u_int32_t, int, int));
|
||||
/* cleanup on error or normal exit */
|
||||
void (*cleanup) __P((void));
|
||||
/* close the device, called in children after fork */
|
||||
void (*close) __P((void));
|
||||
};
|
||||
|
||||
extern struct channel *the_channel;
|
||||
|
||||
/*
|
||||
* Prototypes.
|
||||
*/
|
||||
|
||||
/* Procedures exported from main.c. */
|
||||
void set_ifunit __P((int)); /* set stuff that depends on ifunit */
|
||||
void detach __P((void)); /* Detach from controlling tty */
|
||||
void die __P((int)); /* Cleanup and exit */
|
||||
void quit __P((void)); /* like die(1) */
|
||||
void novm __P((char *)); /* Say we ran out of memory, and die */
|
||||
void timeout __P((void (*func)(void *), void *arg, int s, int us));
|
||||
/* Call func(arg) after s.us seconds */
|
||||
void untimeout __P((void (*func)(void *), void *arg));
|
||||
/* Cancel call to func(arg) */
|
||||
void record_child __P((int, char *, void (*) (void *), void *));
|
||||
pid_t safe_fork __P((int, int, int)); /* Fork & close stuff in child */
|
||||
int device_script __P((char *cmd, int in, int out, int dont_wait));
|
||||
/* Run `cmd' with given stdin and stdout */
|
||||
pid_t run_program __P((char *prog, char **args, int must_exist,
|
||||
void (*done)(void *), void *arg));
|
||||
/* Run program prog with args in child */
|
||||
void reopen_log __P((void)); /* (re)open the connection to syslog */
|
||||
void print_link_stats __P((void)); /* Print stats, if available */
|
||||
void reset_link_stats __P((int)); /* Reset (init) stats when link goes up */
|
||||
void update_link_stats __P((int)); /* Get stats at link termination */
|
||||
void script_setenv __P((char *, char *, int)); /* set script env var */
|
||||
void script_unsetenv __P((char *)); /* unset script env var */
|
||||
void new_phase __P((int)); /* signal start of new phase */
|
||||
void add_notifier __P((struct notifier **, notify_func, void *));
|
||||
void remove_notifier __P((struct notifier **, notify_func, void *));
|
||||
void notify __P((struct notifier *, int));
|
||||
int ppp_send_config __P((int, int, u_int32_t, int, int));
|
||||
int ppp_recv_config __P((int, int, u_int32_t, int, int));
|
||||
const char *protocol_name __P((int));
|
||||
void remove_pidfiles __P((void));
|
||||
void lock_db __P((void));
|
||||
void unlock_db __P((void));
|
||||
|
||||
/* Procedures exported from tty.c. */
|
||||
void tty_init __P((void));
|
||||
|
||||
/* Procedures exported from utils.c. */
|
||||
void log_packet __P((u_char *, int, char *, int));
|
||||
/* Format a packet and log it with syslog */
|
||||
void print_string __P((char *, int, void (*) (void *, char *, ...),
|
||||
void *)); /* Format a string for output */
|
||||
int slprintf __P((char *, int, char *, ...)); /* sprintf++ */
|
||||
int vslprintf __P((char *, int, char *, va_list)); /* vsprintf++ */
|
||||
size_t strlcpy __P((char *, const char *, size_t)); /* safe strcpy */
|
||||
size_t strlcat __P((char *, const char *, size_t)); /* safe strncpy */
|
||||
void dbglog __P((char *, ...)); /* log a debug message */
|
||||
void info __P((char *, ...)); /* log an informational message */
|
||||
void notice __P((char *, ...)); /* log a notice-level message */
|
||||
void warn __P((char *, ...)); /* log a warning message */
|
||||
void error __P((char *, ...)); /* log an error message */
|
||||
void fatal __P((char *, ...)); /* log an error message and die(1) */
|
||||
void init_pr_log __P((char *, int)); /* initialize for using pr_log */
|
||||
void pr_log __P((void *, char *, ...)); /* printer fn, output to syslog */
|
||||
void end_pr_log __P((void)); /* finish up after using pr_log */
|
||||
void dump_packet __P((const char *, u_char *, int));
|
||||
/* dump packet to debug log if interesting */
|
||||
ssize_t complete_read __P((int, void *, size_t));
|
||||
/* read a complete buffer */
|
||||
|
||||
/* Procedures exported from auth.c */
|
||||
void link_required __P((int)); /* we are starting to use the link */
|
||||
void start_link __P((int)); /* bring the link up now */
|
||||
void link_terminated __P((int)); /* we are finished with the link */
|
||||
void link_down __P((int)); /* the LCP layer has left the Opened state */
|
||||
void upper_layers_down __P((int));/* take all NCPs down */
|
||||
void link_established __P((int)); /* the link is up; authenticate now */
|
||||
void start_networks __P((int)); /* start all the network control protos */
|
||||
void continue_networks __P((int)); /* start network [ip, etc] control protos */
|
||||
void np_up __P((int, int)); /* a network protocol has come up */
|
||||
void np_down __P((int, int)); /* a network protocol has gone down */
|
||||
void np_finished __P((int, int)); /* a network protocol no longer needs link */
|
||||
void auth_peer_fail __P((int, int));
|
||||
/* peer failed to authenticate itself */
|
||||
void auth_peer_success __P((int, int, int, char *, int));
|
||||
/* peer successfully authenticated itself */
|
||||
void auth_withpeer_fail __P((int, int));
|
||||
/* we failed to authenticate ourselves */
|
||||
void auth_withpeer_success __P((int, int, int));
|
||||
/* we successfully authenticated ourselves */
|
||||
void auth_check_options __P((void));
|
||||
/* check authentication options supplied */
|
||||
void auth_reset __P((int)); /* check what secrets we have */
|
||||
int check_passwd __P((int, char *, int, char *, int, char **));
|
||||
/* Check peer-supplied username/password */
|
||||
int get_secret __P((int, char *, char *, char *, int *, int));
|
||||
/* get "secret" for chap */
|
||||
int get_srp_secret __P((int unit, char *client, char *server, char *secret,
|
||||
int am_server));
|
||||
int auth_ip_addr __P((int, u_int32_t));
|
||||
/* check if IP address is authorized */
|
||||
int auth_number __P((void)); /* check if remote number is authorized */
|
||||
int bad_ip_adrs __P((u_int32_t));
|
||||
/* check if IP address is unreasonable */
|
||||
|
||||
/* Procedures exported from demand.c */
|
||||
void demand_conf __P((void)); /* config interface(s) for demand-dial */
|
||||
void demand_block __P((void)); /* set all NPs to queue up packets */
|
||||
void demand_unblock __P((void)); /* set all NPs to pass packets */
|
||||
void demand_discard __P((void)); /* set all NPs to discard packets */
|
||||
void demand_rexmit __P((int)); /* retransmit saved frames for an NP */
|
||||
int loop_chars __P((unsigned char *, int)); /* process chars from loopback */
|
||||
int loop_frame __P((unsigned char *, int)); /* should we bring link up? */
|
||||
|
||||
/* Procedures exported from multilink.c */
|
||||
#ifdef HAVE_MULTILINK
|
||||
void mp_check_options __P((void)); /* Check multilink-related options */
|
||||
int mp_join_bundle __P((void)); /* join our link to an appropriate bundle */
|
||||
void mp_exit_bundle __P((void)); /* have disconnected our link from bundle */
|
||||
void mp_bundle_terminated __P((void));
|
||||
char *epdisc_to_str __P((struct epdisc *)); /* string from endpoint discrim. */
|
||||
int str_to_epdisc __P((struct epdisc *, char *)); /* endpt disc. from str */
|
||||
#else
|
||||
#define mp_bundle_terminated() /* nothing */
|
||||
#define mp_exit_bundle() /* nothing */
|
||||
#define doing_multilink 0
|
||||
#define multilink_master 0
|
||||
#endif
|
||||
|
||||
/* Procedures exported from sys-*.c */
|
||||
void sys_init __P((void)); /* Do system-dependent initialization */
|
||||
void sys_cleanup __P((void)); /* Restore system state before exiting */
|
||||
int sys_check_options __P((void)); /* Check options specified */
|
||||
void sys_close __P((void)); /* Clean up in a child before execing */
|
||||
int ppp_available __P((void)); /* Test whether ppp kernel support exists */
|
||||
int get_pty __P((int *, int *, char *, int)); /* Get pty master/slave */
|
||||
int open_ppp_loopback __P((void)); /* Open loopback for demand-dialling */
|
||||
int tty_establish_ppp __P((int)); /* Turn serial port into a ppp interface */
|
||||
void tty_disestablish_ppp __P((int)); /* Restore port to normal operation */
|
||||
void generic_disestablish_ppp __P((int dev_fd)); /* Restore device setting */
|
||||
int generic_establish_ppp __P((int dev_fd)); /* Make a ppp interface */
|
||||
void make_new_bundle __P((int, int, int, int)); /* Create new bundle */
|
||||
int bundle_attach __P((int)); /* Attach link to existing bundle */
|
||||
void cfg_bundle __P((int, int, int, int)); /* Configure existing bundle */
|
||||
void destroy_bundle __P((void)); /* Tell driver to destroy bundle */
|
||||
void clean_check __P((void)); /* Check if line was 8-bit clean */
|
||||
void set_up_tty __P((int, int)); /* Set up port's speed, parameters, etc. */
|
||||
void restore_tty __P((int)); /* Restore port's original parameters */
|
||||
void setdtr __P((int, int)); /* Raise or lower port's DTR line */
|
||||
void output __P((int, u_char *, int)); /* Output a PPP packet */
|
||||
void wait_input __P((struct timeval *));
|
||||
/* Wait for input, with timeout */
|
||||
void add_fd __P((int)); /* Add fd to set to wait for */
|
||||
void remove_fd __P((int)); /* Remove fd from set to wait for */
|
||||
int read_packet __P((u_char *)); /* Read PPP packet */
|
||||
int get_loop_output __P((void)); /* Read pkts from loopback */
|
||||
void tty_send_config __P((int, u_int32_t, int, int));
|
||||
/* Configure i/f transmit parameters */
|
||||
void tty_set_xaccm __P((ext_accm));
|
||||
/* Set extended transmit ACCM */
|
||||
void tty_recv_config __P((int, u_int32_t, int, int));
|
||||
/* Configure i/f receive parameters */
|
||||
int ccp_test __P((int, u_char *, int, int));
|
||||
/* Test support for compression scheme */
|
||||
void ccp_flags_set __P((int, int, int));
|
||||
/* Set kernel CCP state */
|
||||
int ccp_fatal_error __P((int)); /* Test for fatal decomp error in kernel */
|
||||
int get_idle_time __P((int, struct ppp_idle *));
|
||||
/* Find out how long link has been idle */
|
||||
int get_ppp_stats __P((int, struct pppd_stats *));
|
||||
/* Return link statistics */
|
||||
void netif_set_mtu __P((int, int)); /* Set PPP interface MTU */
|
||||
int netif_get_mtu __P((int)); /* Get PPP interface MTU */
|
||||
int sifvjcomp __P((int, int, int, int));
|
||||
/* Configure VJ TCP header compression */
|
||||
int sifup __P((int)); /* Configure i/f up for one protocol */
|
||||
int sifnpmode __P((int u, int proto, enum NPmode mode));
|
||||
/* Set mode for handling packets for proto */
|
||||
int sifdown __P((int)); /* Configure i/f down for one protocol */
|
||||
int sifaddr __P((int, u_int32_t, u_int32_t, u_int32_t));
|
||||
/* Configure IPv4 addresses for i/f */
|
||||
int cifaddr __P((int, u_int32_t, u_int32_t));
|
||||
/* Reset i/f IP addresses */
|
||||
#ifdef INET6
|
||||
int sif6addr __P((int, eui64_t, eui64_t));
|
||||
/* Configure IPv6 addresses for i/f */
|
||||
int cif6addr __P((int, eui64_t, eui64_t));
|
||||
/* Remove an IPv6 address from i/f */
|
||||
#endif
|
||||
int sifdefaultroute __P((int, u_int32_t, u_int32_t));
|
||||
/* Create default route through i/f */
|
||||
int cifdefaultroute __P((int, u_int32_t, u_int32_t));
|
||||
/* Delete default route through i/f */
|
||||
int sifproxyarp __P((int, u_int32_t));
|
||||
/* Add proxy ARP entry for peer */
|
||||
int cifproxyarp __P((int, u_int32_t));
|
||||
/* Delete proxy ARP entry for peer */
|
||||
u_int32_t GetMask __P((u_int32_t)); /* Get appropriate netmask for address */
|
||||
int lock __P((char *)); /* Create lock file for device */
|
||||
int relock __P((int)); /* Rewrite lock file with new pid */
|
||||
void unlock __P((void)); /* Delete previously-created lock file */
|
||||
void logwtmp __P((const char *, const char *, const char *));
|
||||
/* Write entry to wtmp file */
|
||||
int get_host_seed __P((void)); /* Get host-dependent random number seed */
|
||||
int have_route_to __P((u_int32_t)); /* Check if route to addr exists */
|
||||
#ifdef PPP_FILTER
|
||||
int set_filters __P((struct bpf_program *pass, struct bpf_program *active));
|
||||
/* Set filter programs in kernel */
|
||||
#endif
|
||||
#ifdef IPX_CHANGE
|
||||
int sipxfaddr __P((int, unsigned long, unsigned char *));
|
||||
int cipxfaddr __P((int));
|
||||
#endif
|
||||
int get_if_hwaddr __P((u_char *addr, char *name));
|
||||
char *get_first_ethernet __P((void));
|
||||
|
||||
/* Procedures exported from options.c */
|
||||
int setipaddr __P((char *, char **, int)); /* Set local/remote ip addresses */
|
||||
int parse_args __P((int argc, char **argv));
|
||||
/* Parse options from arguments given */
|
||||
int options_from_file __P((char *filename, int must_exist, int check_prot,
|
||||
int privileged));
|
||||
/* Parse options from an options file */
|
||||
int options_from_user __P((void)); /* Parse options from user's .ppprc */
|
||||
int options_for_tty __P((void)); /* Parse options from /etc/ppp/options.tty */
|
||||
int options_from_list __P((struct wordlist *, int privileged));
|
||||
/* Parse options from a wordlist */
|
||||
int getword __P((FILE *f, char *word, int *newlinep, char *filename));
|
||||
/* Read a word from a file */
|
||||
void option_error __P((char *fmt, ...));
|
||||
/* Print an error message about an option */
|
||||
int int_option __P((char *, int *));
|
||||
/* Simplified number_option for decimal ints */
|
||||
void add_options __P((option_t *)); /* Add extra options */
|
||||
void check_options __P((void)); /* check values after all options parsed */
|
||||
int override_value __P((const char *, int, const char *));
|
||||
/* override value if permitted by priority */
|
||||
void print_options __P((void (*) __P((void *, char *, ...)), void *));
|
||||
/* print out values of all options */
|
||||
|
||||
int parse_dotted_ip __P((char *, u_int32_t *));
|
||||
|
||||
/*
|
||||
* Hooks to enable plugins to change various things.
|
||||
*/
|
||||
extern int (*new_phase_hook) __P((int));
|
||||
extern int (*idle_time_hook) __P((struct ppp_idle *));
|
||||
extern int (*holdoff_hook) __P((void));
|
||||
extern int (*pap_check_hook) __P((void));
|
||||
extern int (*pap_auth_hook) __P((char *user, char *passwd, char **msgp,
|
||||
struct wordlist **paddrs,
|
||||
struct wordlist **popts));
|
||||
extern void (*pap_logout_hook) __P((void));
|
||||
extern int (*pap_passwd_hook) __P((char *user, char *passwd));
|
||||
extern int (*allowed_address_hook) __P((u_int32_t addr));
|
||||
extern void (*ip_up_hook) __P((void));
|
||||
extern void (*ip_down_hook) __P((void));
|
||||
extern void (*ip_choose_hook) __P((u_int32_t *));
|
||||
|
||||
extern int (*chap_check_hook) __P((void));
|
||||
extern int (*chap_passwd_hook) __P((char *user, char *passwd));
|
||||
|
||||
/* Let a plugin snoop sent and received packets. Useful for L2TP */
|
||||
extern void (*snoop_recv_hook) __P((unsigned char *p, int len));
|
||||
extern void (*snoop_send_hook) __P((unsigned char *p, int len));
|
||||
|
||||
/*
|
||||
* Inline versions of get/put char/short/long.
|
||||
* Pointer is advanced; we assume that both arguments
|
||||
* are lvalues and will already be in registers.
|
||||
* cp MUST be u_char *.
|
||||
*/
|
||||
#define GETCHAR(c, cp) { \
|
||||
(c) = *(cp)++; \
|
||||
}
|
||||
#define PUTCHAR(c, cp) { \
|
||||
*(cp)++ = (u_char) (c); \
|
||||
}
|
||||
|
||||
|
||||
#define GETSHORT(s, cp) { \
|
||||
(s) = *(cp)++ << 8; \
|
||||
(s) |= *(cp)++; \
|
||||
}
|
||||
#define PUTSHORT(s, cp) { \
|
||||
*(cp)++ = (u_char) ((s) >> 8); \
|
||||
*(cp)++ = (u_char) (s); \
|
||||
}
|
||||
|
||||
#define GETLONG(l, cp) { \
|
||||
(l) = *(cp)++ << 8; \
|
||||
(l) |= *(cp)++; (l) <<= 8; \
|
||||
(l) |= *(cp)++; (l) <<= 8; \
|
||||
(l) |= *(cp)++; \
|
||||
}
|
||||
#define PUTLONG(l, cp) { \
|
||||
*(cp)++ = (u_char) ((l) >> 24); \
|
||||
*(cp)++ = (u_char) ((l) >> 16); \
|
||||
*(cp)++ = (u_char) ((l) >> 8); \
|
||||
*(cp)++ = (u_char) (l); \
|
||||
}
|
||||
|
||||
#define INCPTR(n, cp) ((cp) += (n))
|
||||
#define DECPTR(n, cp) ((cp) -= (n))
|
||||
|
||||
/*
|
||||
* System dependent definitions for user-level 4.3BSD UNIX implementation.
|
||||
*/
|
||||
|
||||
#define TIMEOUT(r, f, t) timeout((r), (f), (t), 0)
|
||||
#define UNTIMEOUT(r, f) untimeout((r), (f))
|
||||
|
||||
#define BCOPY(s, d, l) memcpy(d, s, l)
|
||||
#define BZERO(s, n) memset(s, 0, n)
|
||||
#define BCMP(s1, s2, l) memcmp(s1, s2, l)
|
||||
|
||||
#define PRINTMSG(m, l) { info("Remote message: %0.*v", l, m); }
|
||||
|
||||
/*
|
||||
* MAKEHEADER - Add Header fields to a packet.
|
||||
*/
|
||||
#define MAKEHEADER(p, t) { \
|
||||
PUTCHAR(PPP_ALLSTATIONS, p); \
|
||||
PUTCHAR(PPP_UI, p); \
|
||||
PUTSHORT(t, p); }
|
||||
|
||||
/*
|
||||
* Exit status values.
|
||||
*/
|
||||
#define EXIT_OK 0
|
||||
#define EXIT_FATAL_ERROR 1
|
||||
#define EXIT_OPTION_ERROR 2
|
||||
#define EXIT_NOT_ROOT 3
|
||||
#define EXIT_NO_KERNEL_SUPPORT 4
|
||||
#define EXIT_USER_REQUEST 5
|
||||
#define EXIT_LOCK_FAILED 6
|
||||
#define EXIT_OPEN_FAILED 7
|
||||
#define EXIT_CONNECT_FAILED 8
|
||||
#define EXIT_PTYCMD_FAILED 9
|
||||
#define EXIT_NEGOTIATION_FAILED 10
|
||||
#define EXIT_PEER_AUTH_FAILED 11
|
||||
#define EXIT_IDLE_TIMEOUT 12
|
||||
#define EXIT_CONNECT_TIME 13
|
||||
#define EXIT_CALLBACK 14
|
||||
#define EXIT_PEER_DEAD 15
|
||||
#define EXIT_HANGUP 16
|
||||
#define EXIT_LOOPBACK 17
|
||||
#define EXIT_INIT_FAILED 18
|
||||
#define EXIT_AUTH_TOPEER_FAILED 19
|
||||
#ifdef MAXOCTETS
|
||||
#define EXIT_TRAFFIC_LIMIT 20
|
||||
#endif
|
||||
#define EXIT_CNID_AUTH_FAILED 21
|
||||
|
||||
/*
|
||||
* Debug macros. Slightly useful for finding bugs in pppd, not particularly
|
||||
* useful for finding out why your connection isn't being established.
|
||||
*/
|
||||
#ifdef DEBUGALL
|
||||
#define DEBUGMAIN 1
|
||||
#define DEBUGFSM 1
|
||||
#define DEBUGLCP 1
|
||||
#define DEBUGIPCP 1
|
||||
#define DEBUGIPV6CP 1
|
||||
#define DEBUGUPAP 1
|
||||
#define DEBUGCHAP 1
|
||||
#endif
|
||||
|
||||
#ifndef LOG_PPP /* we use LOG_LOCAL2 for syslog by default */
|
||||
#if defined(DEBUGMAIN) || defined(DEBUGFSM) || defined(DEBUGSYS) \
|
||||
|| defined(DEBUGLCP) || defined(DEBUGIPCP) || defined(DEBUGUPAP) \
|
||||
|| defined(DEBUGCHAP) || defined(DEBUG) || defined(DEBUGIPV6CP)
|
||||
#define LOG_PPP LOG_LOCAL2
|
||||
#else
|
||||
#define LOG_PPP LOG_DAEMON
|
||||
#endif
|
||||
#endif /* LOG_PPP */
|
||||
|
||||
#ifdef DEBUGMAIN
|
||||
#define MAINDEBUG(x) if (debug) dbglog x
|
||||
#else
|
||||
#define MAINDEBUG(x)
|
||||
#endif
|
||||
|
||||
#ifdef DEBUGSYS
|
||||
#define SYSDEBUG(x) if (debug) dbglog x
|
||||
#else
|
||||
#define SYSDEBUG(x)
|
||||
#endif
|
||||
|
||||
#ifdef DEBUGFSM
|
||||
#define FSMDEBUG(x) if (debug) dbglog x
|
||||
#else
|
||||
#define FSMDEBUG(x)
|
||||
#endif
|
||||
|
||||
#ifdef DEBUGLCP
|
||||
#define LCPDEBUG(x) if (debug) dbglog x
|
||||
#else
|
||||
#define LCPDEBUG(x)
|
||||
#endif
|
||||
|
||||
#ifdef DEBUGIPCP
|
||||
#define IPCPDEBUG(x) if (debug) dbglog x
|
||||
#else
|
||||
#define IPCPDEBUG(x)
|
||||
#endif
|
||||
|
||||
#ifdef DEBUGIPV6CP
|
||||
#define IPV6CPDEBUG(x) if (debug) dbglog x
|
||||
#else
|
||||
#define IPV6CPDEBUG(x)
|
||||
#endif
|
||||
|
||||
#ifdef DEBUGUPAP
|
||||
#define UPAPDEBUG(x) if (debug) dbglog x
|
||||
#else
|
||||
#define UPAPDEBUG(x)
|
||||
#endif
|
||||
|
||||
#ifdef DEBUGCHAP
|
||||
#define CHAPDEBUG(x) if (debug) dbglog x
|
||||
#else
|
||||
#define CHAPDEBUG(x)
|
||||
#endif
|
||||
|
||||
#ifdef DEBUGIPXCP
|
||||
#define IPXCPDEBUG(x) if (debug) dbglog x
|
||||
#else
|
||||
#define IPXCPDEBUG(x)
|
||||
#endif
|
||||
|
||||
#ifndef SIGTYPE
|
||||
#if defined(sun) || defined(SYSV) || defined(POSIX_SOURCE)
|
||||
#define SIGTYPE void
|
||||
#else
|
||||
#define SIGTYPE int
|
||||
#endif /* defined(sun) || defined(SYSV) || defined(POSIX_SOURCE) */
|
||||
#endif /* SIGTYPE */
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(a, b) ((a) < (b)? (a): (b))
|
||||
#endif
|
||||
#ifndef MAX
|
||||
#define MAX(a, b) ((a) > (b)? (a): (b))
|
||||
#endif
|
||||
|
||||
#ifndef offsetof
|
||||
#define offsetof(type, member) ((size_t) &((type *)0)->member)
|
||||
#endif
|
||||
|
||||
#endif /* __PPP_H__ */
|
||||
168
vpn-daemons/pptp/src/external/2.4.4/pppd/fsm.h
vendored
168
vpn-daemons/pptp/src/external/2.4.4/pppd/fsm.h
vendored
|
|
@ -1,168 +0,0 @@
|
|||
/*
|
||||
* fsm.h - {Link, IP} Control Protocol Finite State Machine definitions.
|
||||
*
|
||||
* Copyright (c) 1984-2000 Carnegie Mellon University. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. The name "Carnegie Mellon University" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For permission or any legal
|
||||
* details, please contact
|
||||
* Office of Technology Transfer
|
||||
* Carnegie Mellon University
|
||||
* 5000 Forbes Avenue
|
||||
* Pittsburgh, PA 15213-3890
|
||||
* (412) 268-4387, fax: (412) 268-7395
|
||||
* tech-transfer@andrew.cmu.edu
|
||||
*
|
||||
* 4. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by Computing Services
|
||||
* at Carnegie Mellon University (http://www.cmu.edu/computing/)."
|
||||
*
|
||||
* CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
|
||||
* FOR ANY SPECIAL, 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.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/*
|
||||
* Packet header = Code, id, length.
|
||||
*/
|
||||
#define HEADERLEN 4
|
||||
|
||||
|
||||
/*
|
||||
* CP (LCP, IPCP, etc.) codes.
|
||||
*/
|
||||
#define CONFREQ 1 /* Configuration Request */
|
||||
#define CONFACK 2 /* Configuration Ack */
|
||||
#define CONFNAK 3 /* Configuration Nak */
|
||||
#define CONFREJ 4 /* Configuration Reject */
|
||||
#define TERMREQ 5 /* Termination Request */
|
||||
#define TERMACK 6 /* Termination Ack */
|
||||
#define CODEREJ 7 /* Code Reject */
|
||||
|
||||
|
||||
/*
|
||||
* Each FSM is described by an fsm structure and fsm callbacks.
|
||||
*/
|
||||
typedef struct fsm {
|
||||
int unit; /* Interface unit number */
|
||||
int protocol; /* Data Link Layer Protocol field value */
|
||||
int state; /* State */
|
||||
int flags; /* Contains option bits */
|
||||
u_char id; /* Current id */
|
||||
u_char reqid; /* Current request id */
|
||||
u_char seen_ack; /* Have received valid Ack/Nak/Rej to Req */
|
||||
int timeouttime; /* Timeout time in milliseconds */
|
||||
int maxconfreqtransmits; /* Maximum Configure-Request transmissions */
|
||||
int retransmits; /* Number of retransmissions left */
|
||||
int maxtermtransmits; /* Maximum Terminate-Request transmissions */
|
||||
int nakloops; /* Number of nak loops since last ack */
|
||||
int rnakloops; /* Number of naks received */
|
||||
int maxnakloops; /* Maximum number of nak loops tolerated */
|
||||
struct fsm_callbacks *callbacks; /* Callback routines */
|
||||
char *term_reason; /* Reason for closing protocol */
|
||||
int term_reason_len; /* Length of term_reason */
|
||||
} fsm;
|
||||
|
||||
|
||||
typedef struct fsm_callbacks {
|
||||
void (*resetci) /* Reset our Configuration Information */
|
||||
__P((fsm *));
|
||||
int (*cilen) /* Length of our Configuration Information */
|
||||
__P((fsm *));
|
||||
void (*addci) /* Add our Configuration Information */
|
||||
__P((fsm *, u_char *, int *));
|
||||
int (*ackci) /* ACK our Configuration Information */
|
||||
__P((fsm *, u_char *, int));
|
||||
int (*nakci) /* NAK our Configuration Information */
|
||||
__P((fsm *, u_char *, int, int));
|
||||
int (*rejci) /* Reject our Configuration Information */
|
||||
__P((fsm *, u_char *, int));
|
||||
int (*reqci) /* Request peer's Configuration Information */
|
||||
__P((fsm *, u_char *, int *, int));
|
||||
void (*up) /* Called when fsm reaches OPENED state */
|
||||
__P((fsm *));
|
||||
void (*down) /* Called when fsm leaves OPENED state */
|
||||
__P((fsm *));
|
||||
void (*starting) /* Called when we want the lower layer */
|
||||
__P((fsm *));
|
||||
void (*finished) /* Called when we don't want the lower layer */
|
||||
__P((fsm *));
|
||||
void (*protreject) /* Called when Protocol-Reject received */
|
||||
__P((int));
|
||||
void (*retransmit) /* Retransmission is necessary */
|
||||
__P((fsm *));
|
||||
int (*extcode) /* Called when unknown code received */
|
||||
__P((fsm *, int, int, u_char *, int));
|
||||
char *proto_name; /* String name for protocol (for messages) */
|
||||
} fsm_callbacks;
|
||||
|
||||
|
||||
/*
|
||||
* Link states.
|
||||
*/
|
||||
#define INITIAL 0 /* Down, hasn't been opened */
|
||||
#define STARTING 1 /* Down, been opened */
|
||||
#define CLOSED 2 /* Up, hasn't been opened */
|
||||
#define STOPPED 3 /* Open, waiting for down event */
|
||||
#define CLOSING 4 /* Terminating the connection, not open */
|
||||
#define STOPPING 5 /* Terminating, but open */
|
||||
#define REQSENT 6 /* We've sent a Config Request */
|
||||
#define ACKRCVD 7 /* We've received a Config Ack */
|
||||
#define ACKSENT 8 /* We've sent a Config Ack */
|
||||
#define OPENED 9 /* Connection available */
|
||||
|
||||
|
||||
/*
|
||||
* Flags - indicate options controlling FSM operation
|
||||
*/
|
||||
#define OPT_PASSIVE 1 /* Don't die if we don't get a response */
|
||||
#define OPT_RESTART 2 /* Treat 2nd OPEN as DOWN, UP */
|
||||
#define OPT_SILENT 4 /* Wait for peer to speak first */
|
||||
|
||||
|
||||
/*
|
||||
* Timeouts.
|
||||
*/
|
||||
#define DEFTIMEOUT 3 /* Timeout time in seconds */
|
||||
#define DEFMAXTERMREQS 2 /* Maximum Terminate-Request transmissions */
|
||||
#define DEFMAXCONFREQS 10 /* Maximum Configure-Request transmissions */
|
||||
#define DEFMAXNAKLOOPS 5 /* Maximum number of nak loops */
|
||||
|
||||
|
||||
/*
|
||||
* Prototypes
|
||||
*/
|
||||
void fsm_init __P((fsm *));
|
||||
void fsm_lowerup __P((fsm *));
|
||||
void fsm_lowerdown __P((fsm *));
|
||||
void fsm_open __P((fsm *));
|
||||
void fsm_close __P((fsm *, char *));
|
||||
void fsm_input __P((fsm *, u_char *, int));
|
||||
void fsm_protreject __P((fsm *));
|
||||
void fsm_sdata __P((fsm *, int, int, u_char *, int));
|
||||
|
||||
|
||||
/*
|
||||
* Variables
|
||||
*/
|
||||
extern int peer_mru[]; /* currently negotiated peer MRU (per unit) */
|
||||
96
vpn-daemons/pptp/src/external/2.4.4/pppd/ipcp.h
vendored
96
vpn-daemons/pptp/src/external/2.4.4/pppd/ipcp.h
vendored
|
|
@ -1,96 +0,0 @@
|
|||
/*
|
||||
* ipcp.h - IP Control Protocol definitions.
|
||||
*
|
||||
* Copyright (c) 1984-2000 Carnegie Mellon University. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. The name "Carnegie Mellon University" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For permission or any legal
|
||||
* details, please contact
|
||||
* Office of Technology Transfer
|
||||
* Carnegie Mellon University
|
||||
* 5000 Forbes Avenue
|
||||
* Pittsburgh, PA 15213-3890
|
||||
* (412) 268-4387, fax: (412) 268-7395
|
||||
* tech-transfer@andrew.cmu.edu
|
||||
*
|
||||
* 4. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by Computing Services
|
||||
* at Carnegie Mellon University (http://www.cmu.edu/computing/)."
|
||||
*
|
||||
* CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
|
||||
* FOR ANY SPECIAL, 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.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/*
|
||||
* Options.
|
||||
*/
|
||||
#define CI_ADDRS 1 /* IP Addresses */
|
||||
#define CI_COMPRESSTYPE 2 /* Compression Type */
|
||||
#define CI_ADDR 3
|
||||
|
||||
#define CI_MS_DNS1 129 /* Primary DNS value */
|
||||
#define CI_MS_WINS1 130 /* Primary WINS value */
|
||||
#define CI_MS_DNS2 131 /* Secondary DNS value */
|
||||
#define CI_MS_WINS2 132 /* Secondary WINS value */
|
||||
|
||||
#define MAX_STATES 16 /* from slcompress.h */
|
||||
|
||||
#define IPCP_VJMODE_OLD 1 /* "old" mode (option # = 0x0037) */
|
||||
#define IPCP_VJMODE_RFC1172 2 /* "old-rfc"mode (option # = 0x002d) */
|
||||
#define IPCP_VJMODE_RFC1332 3 /* "new-rfc"mode (option # = 0x002d, */
|
||||
/* maxslot and slot number compression) */
|
||||
|
||||
#define IPCP_VJ_COMP 0x002d /* current value for VJ compression option*/
|
||||
#define IPCP_VJ_COMP_OLD 0x0037 /* "old" (i.e, broken) value for VJ */
|
||||
/* compression option*/
|
||||
|
||||
typedef struct ipcp_options {
|
||||
bool neg_addr; /* Negotiate IP Address? */
|
||||
bool old_addrs; /* Use old (IP-Addresses) option? */
|
||||
bool req_addr; /* Ask peer to send IP address? */
|
||||
bool default_route; /* Assign default route through interface? */
|
||||
bool proxy_arp; /* Make proxy ARP entry for peer? */
|
||||
bool neg_vj; /* Van Jacobson Compression? */
|
||||
bool old_vj; /* use old (short) form of VJ option? */
|
||||
bool accept_local; /* accept peer's value for ouraddr */
|
||||
bool accept_remote; /* accept peer's value for hisaddr */
|
||||
bool req_dns1; /* Ask peer to send primary DNS address? */
|
||||
bool req_dns2; /* Ask peer to send secondary DNS address? */
|
||||
int vj_protocol; /* protocol value to use in VJ option */
|
||||
int maxslotindex; /* values for RFC1332 VJ compression neg. */
|
||||
bool cflag;
|
||||
u_int32_t ouraddr, hisaddr; /* Addresses in NETWORK BYTE ORDER */
|
||||
u_int32_t dnsaddr[2]; /* Primary and secondary MS DNS entries */
|
||||
u_int32_t winsaddr[2]; /* Primary and secondary MS WINS entries */
|
||||
} ipcp_options;
|
||||
|
||||
extern fsm ipcp_fsm[];
|
||||
extern ipcp_options ipcp_wantoptions[];
|
||||
extern ipcp_options ipcp_gotoptions[];
|
||||
extern ipcp_options ipcp_allowoptions[];
|
||||
extern ipcp_options ipcp_hisoptions[];
|
||||
|
||||
char *ip_ntoa __P((u_int32_t));
|
||||
|
||||
extern struct protent ipcp_protent;
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
/* $Id$ */
|
||||
|
||||
#define VERSION "2.4.4"
|
||||
#define DATE "28 June 2006"
|
||||
907
vpn-daemons/pptp/src/external/2.4.4/pppd/pppd.h
vendored
907
vpn-daemons/pptp/src/external/2.4.4/pppd/pppd.h
vendored
|
|
@ -1,907 +0,0 @@
|
|||
/*
|
||||
* pppd.h - PPP daemon global declarations.
|
||||
*
|
||||
* Copyright (c) 1984-2000 Carnegie Mellon University. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. The name "Carnegie Mellon University" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For permission or any legal
|
||||
* details, please contact
|
||||
* Office of Technology Transfer
|
||||
* Carnegie Mellon University
|
||||
* 5000 Forbes Avenue
|
||||
* Pittsburgh, PA 15213-3890
|
||||
* (412) 268-4387, fax: (412) 268-7395
|
||||
* tech-transfer@andrew.cmu.edu
|
||||
*
|
||||
* 4. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by Computing Services
|
||||
* at Carnegie Mellon University (http://www.cmu.edu/computing/)."
|
||||
*
|
||||
* CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
|
||||
* FOR ANY SPECIAL, 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.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/*
|
||||
* TODO:
|
||||
*/
|
||||
|
||||
#ifndef __PPPD_H__
|
||||
#define __PPPD_H__
|
||||
|
||||
#include <stdio.h> /* for FILE */
|
||||
#include <limits.h> /* for NGROUPS_MAX */
|
||||
#include <sys/param.h> /* for MAXPATHLEN and BSD4_4, if defined */
|
||||
#include <sys/types.h> /* for u_int32_t, if defined */
|
||||
#include <sys/time.h> /* for struct timeval */
|
||||
#include <net/ppp_defs.h>
|
||||
#include "patchlevel.h"
|
||||
|
||||
#if defined(__STDC__)
|
||||
#include <stdarg.h>
|
||||
#define __V(x) x
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#define __V(x) (va_alist) va_dcl
|
||||
#define const
|
||||
#define volatile
|
||||
#endif
|
||||
|
||||
#ifdef INET6
|
||||
#include "eui64.h"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Limits.
|
||||
*/
|
||||
|
||||
#define NUM_PPP 1 /* One PPP interface supported (per process) */
|
||||
#define MAXWORDLEN 1024 /* max length of word in file (incl null) */
|
||||
#define MAXARGS 1 /* max # args to a command */
|
||||
#define MAXNAMELEN 256 /* max length of hostname or name for auth */
|
||||
#define MAXSECRETLEN 256 /* max length of password or secret */
|
||||
|
||||
/*
|
||||
* Option descriptor structure.
|
||||
*/
|
||||
|
||||
typedef unsigned char bool;
|
||||
|
||||
enum opt_type {
|
||||
o_special_noarg = 0,
|
||||
o_special = 1,
|
||||
o_bool,
|
||||
o_int,
|
||||
o_uint32,
|
||||
o_string,
|
||||
o_wild
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
char *name; /* name of the option */
|
||||
enum opt_type type;
|
||||
void *addr;
|
||||
char *description;
|
||||
unsigned int flags;
|
||||
void *addr2;
|
||||
int upper_limit;
|
||||
int lower_limit;
|
||||
const char *source;
|
||||
short int priority;
|
||||
short int winner;
|
||||
} option_t;
|
||||
|
||||
/* Values for flags */
|
||||
#define OPT_VALUE 0xff /* mask for presupplied value */
|
||||
#define OPT_HEX 0x100 /* int option is in hex */
|
||||
#define OPT_NOARG 0x200 /* option doesn't take argument */
|
||||
#define OPT_OR 0x400 /* OR in argument to value */
|
||||
#define OPT_INC 0x800 /* increment value */
|
||||
#define OPT_A2OR 0x800 /* for o_bool, OR arg to *(u_char *)addr2 */
|
||||
#define OPT_PRIV 0x1000 /* privileged option */
|
||||
#define OPT_STATIC 0x2000 /* string option goes into static array */
|
||||
#define OPT_LLIMIT 0x4000 /* check value against lower limit */
|
||||
#define OPT_ULIMIT 0x8000 /* check value against upper limit */
|
||||
#define OPT_LIMITS (OPT_LLIMIT|OPT_ULIMIT)
|
||||
#define OPT_ZEROOK 0x10000 /* 0 value is OK even if not within limits */
|
||||
#define OPT_HIDE 0x10000 /* for o_string, print value as ?????? */
|
||||
#define OPT_A2LIST 0x10000 /* for o_special, keep list of values */
|
||||
#define OPT_A2CLRB 0x10000 /* o_bool, clr val bits in *(u_char *)addr2 */
|
||||
#define OPT_NOINCR 0x20000 /* value mustn't be increased */
|
||||
#define OPT_ZEROINF 0x40000 /* with OPT_NOINCR, 0 == infinity */
|
||||
#define OPT_PRIO 0x80000 /* process option priorities for this option */
|
||||
#define OPT_PRIOSUB 0x100000 /* subsidiary member of priority group */
|
||||
#define OPT_ALIAS 0x200000 /* option is alias for previous option */
|
||||
#define OPT_A2COPY 0x400000 /* addr2 -> second location to rcv value */
|
||||
#define OPT_ENABLE 0x800000 /* use *addr2 as enable for option */
|
||||
#define OPT_A2CLR 0x1000000 /* clear *(bool *)addr2 */
|
||||
#define OPT_PRIVFIX 0x2000000 /* user can't override if set by root */
|
||||
#define OPT_INITONLY 0x4000000 /* option can only be set in init phase */
|
||||
#define OPT_DEVEQUIV 0x8000000 /* equiv to device name */
|
||||
#define OPT_DEVNAM (OPT_INITONLY | OPT_DEVEQUIV)
|
||||
#define OPT_A2PRINTER 0x10000000 /* *addr2 is a fn for printing option */
|
||||
#define OPT_A2STRVAL 0x20000000 /* *addr2 points to current string value */
|
||||
#define OPT_NOPRINT 0x40000000 /* don't print this option at all */
|
||||
|
||||
#define OPT_VAL(x) ((x) & OPT_VALUE)
|
||||
|
||||
/* Values for priority */
|
||||
#define OPRIO_DEFAULT 0 /* a default value */
|
||||
#define OPRIO_CFGFILE 1 /* value from a configuration file */
|
||||
#define OPRIO_CMDLINE 2 /* value from the command line */
|
||||
#define OPRIO_SECFILE 3 /* value from options in a secrets file */
|
||||
#define OPRIO_ROOT 100 /* added to priority if OPT_PRIVFIX && root */
|
||||
|
||||
#ifndef GIDSET_TYPE
|
||||
#define GIDSET_TYPE gid_t
|
||||
#endif
|
||||
|
||||
/* Structure representing a list of permitted IP addresses. */
|
||||
struct permitted_ip {
|
||||
int permit; /* 1 = permit, 0 = forbid */
|
||||
u_int32_t base; /* match if (addr & mask) == base */
|
||||
u_int32_t mask; /* base and mask are in network byte order */
|
||||
};
|
||||
|
||||
/*
|
||||
* Unfortunately, the linux kernel driver uses a different structure
|
||||
* for statistics from the rest of the ports.
|
||||
* This structure serves as a common representation for the bits
|
||||
* pppd needs.
|
||||
*/
|
||||
struct pppd_stats {
|
||||
unsigned int bytes_in;
|
||||
unsigned int bytes_out;
|
||||
unsigned int pkts_in;
|
||||
unsigned int pkts_out;
|
||||
};
|
||||
|
||||
/* Used for storing a sequence of words. Usually malloced. */
|
||||
struct wordlist {
|
||||
struct wordlist *next;
|
||||
char *word;
|
||||
};
|
||||
|
||||
/* An endpoint discriminator, used with multilink. */
|
||||
#define MAX_ENDP_LEN 20 /* maximum length of discriminator value */
|
||||
struct epdisc {
|
||||
unsigned char class;
|
||||
unsigned char length;
|
||||
unsigned char value[MAX_ENDP_LEN];
|
||||
};
|
||||
|
||||
/* values for epdisc.class */
|
||||
#define EPD_NULL 0 /* null discriminator, no data */
|
||||
#define EPD_LOCAL 1
|
||||
#define EPD_IP 2
|
||||
#define EPD_MAC 3
|
||||
#define EPD_MAGIC 4
|
||||
#define EPD_PHONENUM 5
|
||||
|
||||
typedef void (*notify_func) __P((void *, int));
|
||||
|
||||
struct notifier {
|
||||
struct notifier *next;
|
||||
notify_func func;
|
||||
void *arg;
|
||||
};
|
||||
|
||||
/*
|
||||
* Global variables.
|
||||
*/
|
||||
|
||||
extern int hungup; /* Physical layer has disconnected */
|
||||
extern int ifunit; /* Interface unit number */
|
||||
extern char ifname[]; /* Interface name */
|
||||
extern char hostname[]; /* Our hostname */
|
||||
extern u_char outpacket_buf[]; /* Buffer for outgoing packets */
|
||||
extern int devfd; /* fd of underlying device */
|
||||
extern int fd_ppp; /* fd for talking PPP */
|
||||
extern int phase; /* Current state of link - see values below */
|
||||
extern int baud_rate; /* Current link speed in bits/sec */
|
||||
extern char *progname; /* Name of this program */
|
||||
extern int redirect_stderr;/* Connector's stderr should go to file */
|
||||
extern char peer_authname[];/* Authenticated name of peer */
|
||||
extern int auth_done[NUM_PPP]; /* Methods actually used for auth */
|
||||
extern int privileged; /* We were run by real-uid root */
|
||||
extern int need_holdoff; /* Need holdoff period after link terminates */
|
||||
extern char **script_env; /* Environment variables for scripts */
|
||||
extern int detached; /* Have detached from controlling tty */
|
||||
extern GIDSET_TYPE groups[NGROUPS_MAX]; /* groups the user is in */
|
||||
extern int ngroups; /* How many groups valid in groups */
|
||||
extern struct pppd_stats link_stats; /* byte/packet counts etc. for link */
|
||||
extern int link_stats_valid; /* set if link_stats is valid */
|
||||
extern unsigned link_connect_time; /* time the link was up for */
|
||||
extern int using_pty; /* using pty as device (notty or pty opt.) */
|
||||
extern int log_to_fd; /* logging to this fd as well as syslog */
|
||||
extern bool log_default; /* log_to_fd is default (stdout) */
|
||||
extern char *no_ppp_msg; /* message to print if ppp not in kernel */
|
||||
extern volatile int status; /* exit status for pppd */
|
||||
extern bool devnam_fixed; /* can no longer change devnam */
|
||||
extern int unsuccess; /* # unsuccessful connection attempts */
|
||||
extern int do_callback; /* set if we want to do callback next */
|
||||
extern int doing_callback; /* set if this is a callback */
|
||||
extern int error_count; /* # of times error() has been called */
|
||||
extern char ppp_devnam[MAXPATHLEN];
|
||||
extern char remote_number[MAXNAMELEN]; /* Remote telephone number, if avail. */
|
||||
extern int ppp_session_number; /* Session number (eg PPPoE session) */
|
||||
extern int fd_devnull; /* fd open to /dev/null */
|
||||
|
||||
extern int listen_time; /* time to listen first (ms) */
|
||||
extern bool doing_multilink;
|
||||
extern bool multilink_master;
|
||||
extern bool bundle_eof;
|
||||
extern bool bundle_terminating;
|
||||
|
||||
extern struct notifier *pidchange; /* for notifications of pid changing */
|
||||
extern struct notifier *phasechange; /* for notifications of phase changes */
|
||||
extern struct notifier *exitnotify; /* for notification that we're exiting */
|
||||
extern struct notifier *sigreceived; /* notification of received signal */
|
||||
extern struct notifier *ip_up_notifier; /* IPCP has come up */
|
||||
extern struct notifier *ip_down_notifier; /* IPCP has gone down */
|
||||
extern struct notifier *auth_up_notifier; /* peer has authenticated */
|
||||
extern struct notifier *link_down_notifier; /* link has gone down */
|
||||
extern struct notifier *fork_notifier; /* we are a new child process */
|
||||
|
||||
/* Values for do_callback and doing_callback */
|
||||
#define CALLBACK_DIALIN 1 /* we are expecting the call back */
|
||||
#define CALLBACK_DIALOUT 2 /* we are dialling out to call back */
|
||||
|
||||
/*
|
||||
* Variables set by command-line options.
|
||||
*/
|
||||
|
||||
extern int debug; /* Debug flag */
|
||||
extern int kdebugflag; /* Tell kernel to print debug messages */
|
||||
extern int default_device; /* Using /dev/tty or equivalent */
|
||||
extern char devnam[MAXPATHLEN]; /* Device name */
|
||||
extern int crtscts; /* Use hardware flow control */
|
||||
extern bool modem; /* Use modem control lines */
|
||||
extern int inspeed; /* Input/Output speed requested */
|
||||
extern u_int32_t netmask; /* IP netmask to set on interface */
|
||||
extern bool lockflag; /* Create lock file to lock the serial dev */
|
||||
extern bool nodetach; /* Don't detach from controlling tty */
|
||||
extern bool updetach; /* Detach from controlling tty when link up */
|
||||
extern char *initializer; /* Script to initialize physical link */
|
||||
extern char *connect_script; /* Script to establish physical link */
|
||||
extern char *disconnect_script; /* Script to disestablish physical link */
|
||||
extern char *welcomer; /* Script to welcome client after connection */
|
||||
extern char *ptycommand; /* Command to run on other side of pty */
|
||||
extern int maxconnect; /* Maximum connect time (seconds) */
|
||||
extern char user[MAXNAMELEN];/* Our name for authenticating ourselves */
|
||||
extern char passwd[MAXSECRETLEN]; /* Password for PAP or CHAP */
|
||||
extern bool auth_required; /* Peer is required to authenticate */
|
||||
extern bool persist; /* Reopen link after it goes down */
|
||||
extern bool uselogin; /* Use /etc/passwd for checking PAP */
|
||||
extern char our_name[MAXNAMELEN];/* Our name for authentication purposes */
|
||||
extern char remote_name[MAXNAMELEN]; /* Peer's name for authentication */
|
||||
extern bool explicit_remote;/* remote_name specified with remotename opt */
|
||||
extern bool demand; /* Do dial-on-demand */
|
||||
extern char *ipparam; /* Extra parameter for ip up/down scripts */
|
||||
extern bool cryptpap; /* Others' PAP passwords are encrypted */
|
||||
extern int idle_time_limit;/* Shut down link if idle for this long */
|
||||
extern int holdoff; /* Dead time before restarting */
|
||||
extern bool holdoff_specified; /* true if user gave a holdoff value */
|
||||
extern bool notty; /* Stdin/out is not a tty */
|
||||
extern char *pty_socket; /* Socket to connect to pty */
|
||||
extern char *record_file; /* File to record chars sent/received */
|
||||
extern bool sync_serial; /* Device is synchronous serial device */
|
||||
extern int maxfail; /* Max # of unsuccessful connection attempts */
|
||||
extern char linkname[MAXPATHLEN]; /* logical name for link */
|
||||
extern bool tune_kernel; /* May alter kernel settings as necessary */
|
||||
extern int connect_delay; /* Time to delay after connect script */
|
||||
extern int max_data_rate; /* max bytes/sec through charshunt */
|
||||
extern int req_unit; /* interface unit number to use */
|
||||
extern bool multilink; /* enable multilink operation */
|
||||
extern bool noendpoint; /* don't send or accept endpt. discrim. */
|
||||
extern char *bundle_name; /* bundle name for multilink */
|
||||
extern bool dump_options; /* print out option values */
|
||||
extern bool dryrun; /* check everything, print options, exit */
|
||||
extern int child_wait; /* # seconds to wait for children at end */
|
||||
|
||||
#ifdef MAXOCTETS
|
||||
extern unsigned int maxoctets; /* Maximum octetes per session (in bytes) */
|
||||
extern int maxoctets_dir; /* Direction :
|
||||
0 - in+out (default)
|
||||
1 - in
|
||||
2 - out
|
||||
3 - max(in,out) */
|
||||
extern int maxoctets_timeout; /* Timeout for check of octets limit */
|
||||
#define PPP_OCTETS_DIRECTION_SUM 0
|
||||
#define PPP_OCTETS_DIRECTION_IN 1
|
||||
#define PPP_OCTETS_DIRECTION_OUT 2
|
||||
#define PPP_OCTETS_DIRECTION_MAXOVERAL 3
|
||||
/* same as previos, but little different on RADIUS side */
|
||||
#define PPP_OCTETS_DIRECTION_MAXSESSION 4
|
||||
#endif
|
||||
|
||||
#ifdef PPP_FILTER
|
||||
extern struct bpf_program pass_filter; /* Filter for pkts to pass */
|
||||
extern struct bpf_program active_filter; /* Filter for link-active pkts */
|
||||
#endif
|
||||
|
||||
#ifdef MSLANMAN
|
||||
extern bool ms_lanman; /* Use LanMan password instead of NT */
|
||||
/* Has meaning only with MS-CHAP challenges */
|
||||
#endif
|
||||
|
||||
/* Values for auth_pending, auth_done */
|
||||
#define PAP_WITHPEER 0x1
|
||||
#define PAP_PEER 0x2
|
||||
#define CHAP_WITHPEER 0x4
|
||||
#define CHAP_PEER 0x8
|
||||
#define EAP_WITHPEER 0x10
|
||||
#define EAP_PEER 0x20
|
||||
|
||||
/* Values for auth_done only */
|
||||
#define CHAP_MD5_WITHPEER 0x40
|
||||
#define CHAP_MD5_PEER 0x80
|
||||
#define CHAP_MS_SHIFT 8 /* LSB position for MS auths */
|
||||
#define CHAP_MS_WITHPEER 0x100
|
||||
#define CHAP_MS_PEER 0x200
|
||||
#define CHAP_MS2_WITHPEER 0x400
|
||||
#define CHAP_MS2_PEER 0x800
|
||||
|
||||
extern char *current_option; /* the name of the option being parsed */
|
||||
extern int privileged_option; /* set iff the current option came from root */
|
||||
extern char *option_source; /* string saying where the option came from */
|
||||
extern int option_priority; /* priority of current options */
|
||||
|
||||
/*
|
||||
* Values for phase.
|
||||
*/
|
||||
#define PHASE_DEAD 0
|
||||
#define PHASE_INITIALIZE 1
|
||||
#define PHASE_SERIALCONN 2
|
||||
#define PHASE_DORMANT 3
|
||||
#define PHASE_ESTABLISH 4
|
||||
#define PHASE_AUTHENTICATE 5
|
||||
#define PHASE_CALLBACK 6
|
||||
#define PHASE_NETWORK 7
|
||||
#define PHASE_RUNNING 8
|
||||
#define PHASE_TERMINATE 9
|
||||
#define PHASE_DISCONNECT 10
|
||||
#define PHASE_HOLDOFF 11
|
||||
#define PHASE_MASTER 12
|
||||
|
||||
/*
|
||||
* The following struct gives the addresses of procedures to call
|
||||
* for a particular protocol.
|
||||
*/
|
||||
struct protent {
|
||||
u_short protocol; /* PPP protocol number */
|
||||
/* Initialization procedure */
|
||||
void (*init) __P((int unit));
|
||||
/* Process a received packet */
|
||||
void (*input) __P((int unit, u_char *pkt, int len));
|
||||
/* Process a received protocol-reject */
|
||||
void (*protrej) __P((int unit));
|
||||
/* Lower layer has come up */
|
||||
void (*lowerup) __P((int unit));
|
||||
/* Lower layer has gone down */
|
||||
void (*lowerdown) __P((int unit));
|
||||
/* Open the protocol */
|
||||
void (*open) __P((int unit));
|
||||
/* Close the protocol */
|
||||
void (*close) __P((int unit, char *reason));
|
||||
/* Print a packet in readable form */
|
||||
int (*printpkt) __P((u_char *pkt, int len,
|
||||
void (*printer) __P((void *, char *, ...)),
|
||||
void *arg));
|
||||
/* Process a received data packet */
|
||||
void (*datainput) __P((int unit, u_char *pkt, int len));
|
||||
bool enabled_flag; /* 0 iff protocol is disabled */
|
||||
char *name; /* Text name of protocol */
|
||||
char *data_name; /* Text name of corresponding data protocol */
|
||||
option_t *options; /* List of command-line options */
|
||||
/* Check requested options, assign defaults */
|
||||
void (*check_options) __P((void));
|
||||
/* Configure interface for demand-dial */
|
||||
int (*demand_conf) __P((int unit));
|
||||
/* Say whether to bring up link for this pkt */
|
||||
int (*active_pkt) __P((u_char *pkt, int len));
|
||||
};
|
||||
|
||||
/* Table of pointers to supported protocols */
|
||||
extern struct protent *protocols[];
|
||||
|
||||
/*
|
||||
* This struct contains pointers to a set of procedures for
|
||||
* doing operations on a "channel". A channel provides a way
|
||||
* to send and receive PPP packets - the canonical example is
|
||||
* a serial port device in PPP line discipline (or equivalently
|
||||
* with PPP STREAMS modules pushed onto it).
|
||||
*/
|
||||
struct channel {
|
||||
/* set of options for this channel */
|
||||
option_t *options;
|
||||
/* find and process a per-channel options file */
|
||||
void (*process_extra_options) __P((void));
|
||||
/* check all the options that have been given */
|
||||
void (*check_options) __P((void));
|
||||
/* get the channel ready to do PPP, return a file descriptor */
|
||||
int (*connect) __P((void));
|
||||
/* we're finished with the channel */
|
||||
void (*disconnect) __P((void));
|
||||
/* put the channel into PPP `mode' */
|
||||
int (*establish_ppp) __P((int));
|
||||
/* take the channel out of PPP `mode', restore loopback if demand */
|
||||
void (*disestablish_ppp) __P((int));
|
||||
/* set the transmit-side PPP parameters of the channel */
|
||||
void (*send_config) __P((int, u_int32_t, int, int));
|
||||
/* set the receive-side PPP parameters of the channel */
|
||||
void (*recv_config) __P((int, u_int32_t, int, int));
|
||||
/* cleanup on error or normal exit */
|
||||
void (*cleanup) __P((void));
|
||||
/* close the device, called in children after fork */
|
||||
void (*close) __P((void));
|
||||
};
|
||||
|
||||
extern struct channel *the_channel;
|
||||
|
||||
/*
|
||||
* Prototypes.
|
||||
*/
|
||||
|
||||
/* Procedures exported from main.c. */
|
||||
void set_ifunit __P((int)); /* set stuff that depends on ifunit */
|
||||
void detach __P((void)); /* Detach from controlling tty */
|
||||
void die __P((int)); /* Cleanup and exit */
|
||||
void quit __P((void)); /* like die(1) */
|
||||
void novm __P((char *)); /* Say we ran out of memory, and die */
|
||||
void timeout __P((void (*func)(void *), void *arg, int s, int us));
|
||||
/* Call func(arg) after s.us seconds */
|
||||
void untimeout __P((void (*func)(void *), void *arg));
|
||||
/* Cancel call to func(arg) */
|
||||
void record_child __P((int, char *, void (*) (void *), void *));
|
||||
pid_t safe_fork __P((int, int, int)); /* Fork & close stuff in child */
|
||||
int device_script __P((char *cmd, int in, int out, int dont_wait));
|
||||
/* Run `cmd' with given stdin and stdout */
|
||||
pid_t run_program __P((char *prog, char **args, int must_exist,
|
||||
void (*done)(void *), void *arg, int wait));
|
||||
/* Run program prog with args in child */
|
||||
void reopen_log __P((void)); /* (re)open the connection to syslog */
|
||||
void print_link_stats __P((void)); /* Print stats, if available */
|
||||
void reset_link_stats __P((int)); /* Reset (init) stats when link goes up */
|
||||
void update_link_stats __P((int)); /* Get stats at link termination */
|
||||
void script_setenv __P((char *, char *, int)); /* set script env var */
|
||||
void script_unsetenv __P((char *)); /* unset script env var */
|
||||
void new_phase __P((int)); /* signal start of new phase */
|
||||
void add_notifier __P((struct notifier **, notify_func, void *));
|
||||
void remove_notifier __P((struct notifier **, notify_func, void *));
|
||||
void notify __P((struct notifier *, int));
|
||||
int ppp_send_config __P((int, int, u_int32_t, int, int));
|
||||
int ppp_recv_config __P((int, int, u_int32_t, int, int));
|
||||
const char *protocol_name __P((int));
|
||||
void remove_pidfiles __P((void));
|
||||
void lock_db __P((void));
|
||||
void unlock_db __P((void));
|
||||
|
||||
/* Procedures exported from tty.c. */
|
||||
void tty_init __P((void));
|
||||
|
||||
/* Procedures exported from utils.c. */
|
||||
void log_packet __P((u_char *, int, char *, int));
|
||||
/* Format a packet and log it with syslog */
|
||||
void print_string __P((char *, int, void (*) (void *, char *, ...),
|
||||
void *)); /* Format a string for output */
|
||||
int slprintf __P((char *, int, char *, ...)); /* sprintf++ */
|
||||
int vslprintf __P((char *, int, char *, va_list)); /* vsprintf++ */
|
||||
size_t strlcpy __P((char *, const char *, size_t)); /* safe strcpy */
|
||||
size_t strlcat __P((char *, const char *, size_t)); /* safe strncpy */
|
||||
void dbglog __P((char *, ...)); /* log a debug message */
|
||||
void info __P((char *, ...)); /* log an informational message */
|
||||
void notice __P((char *, ...)); /* log a notice-level message */
|
||||
void warn __P((char *, ...)); /* log a warning message */
|
||||
void error __P((char *, ...)); /* log an error message */
|
||||
void fatal __P((char *, ...)); /* log an error message and die(1) */
|
||||
void init_pr_log __P((char *, int)); /* initialize for using pr_log */
|
||||
void pr_log __P((void *, char *, ...)); /* printer fn, output to syslog */
|
||||
void end_pr_log __P((void)); /* finish up after using pr_log */
|
||||
void dump_packet __P((const char *, u_char *, int));
|
||||
/* dump packet to debug log if interesting */
|
||||
ssize_t complete_read __P((int, void *, size_t));
|
||||
/* read a complete buffer */
|
||||
|
||||
/* Procedures exported from auth.c */
|
||||
void link_required __P((int)); /* we are starting to use the link */
|
||||
void start_link __P((int)); /* bring the link up now */
|
||||
void link_terminated __P((int)); /* we are finished with the link */
|
||||
void link_down __P((int)); /* the LCP layer has left the Opened state */
|
||||
void upper_layers_down __P((int));/* take all NCPs down */
|
||||
void link_established __P((int)); /* the link is up; authenticate now */
|
||||
void start_networks __P((int)); /* start all the network control protos */
|
||||
void continue_networks __P((int)); /* start network [ip, etc] control protos */
|
||||
void np_up __P((int, int)); /* a network protocol has come up */
|
||||
void np_down __P((int, int)); /* a network protocol has gone down */
|
||||
void np_finished __P((int, int)); /* a network protocol no longer needs link */
|
||||
void auth_peer_fail __P((int, int));
|
||||
/* peer failed to authenticate itself */
|
||||
void auth_peer_success __P((int, int, int, char *, int));
|
||||
/* peer successfully authenticated itself */
|
||||
void auth_withpeer_fail __P((int, int));
|
||||
/* we failed to authenticate ourselves */
|
||||
void auth_withpeer_success __P((int, int, int));
|
||||
/* we successfully authenticated ourselves */
|
||||
void auth_check_options __P((void));
|
||||
/* check authentication options supplied */
|
||||
void auth_reset __P((int)); /* check what secrets we have */
|
||||
int check_passwd __P((int, char *, int, char *, int, char **));
|
||||
/* Check peer-supplied username/password */
|
||||
int get_secret __P((int, char *, char *, char *, int *, int));
|
||||
/* get "secret" for chap */
|
||||
int get_srp_secret __P((int unit, char *client, char *server, char *secret,
|
||||
int am_server));
|
||||
int auth_ip_addr __P((int, u_int32_t));
|
||||
/* check if IP address is authorized */
|
||||
int auth_number __P((void)); /* check if remote number is authorized */
|
||||
int bad_ip_adrs __P((u_int32_t));
|
||||
/* check if IP address is unreasonable */
|
||||
|
||||
/* Procedures exported from demand.c */
|
||||
void demand_conf __P((void)); /* config interface(s) for demand-dial */
|
||||
void demand_block __P((void)); /* set all NPs to queue up packets */
|
||||
void demand_unblock __P((void)); /* set all NPs to pass packets */
|
||||
void demand_discard __P((void)); /* set all NPs to discard packets */
|
||||
void demand_rexmit __P((int)); /* retransmit saved frames for an NP */
|
||||
int loop_chars __P((unsigned char *, int)); /* process chars from loopback */
|
||||
int loop_frame __P((unsigned char *, int)); /* should we bring link up? */
|
||||
|
||||
/* Procedures exported from multilink.c */
|
||||
#ifdef HAVE_MULTILINK
|
||||
void mp_check_options __P((void)); /* Check multilink-related options */
|
||||
int mp_join_bundle __P((void)); /* join our link to an appropriate bundle */
|
||||
void mp_exit_bundle __P((void)); /* have disconnected our link from bundle */
|
||||
void mp_bundle_terminated __P((void));
|
||||
char *epdisc_to_str __P((struct epdisc *)); /* string from endpoint discrim. */
|
||||
int str_to_epdisc __P((struct epdisc *, char *)); /* endpt disc. from str */
|
||||
#else
|
||||
#define mp_bundle_terminated() /* nothing */
|
||||
#define mp_exit_bundle() /* nothing */
|
||||
#define doing_multilink 0
|
||||
#define multilink_master 0
|
||||
#endif
|
||||
|
||||
/* Procedures exported from sys-*.c */
|
||||
void sys_init __P((void)); /* Do system-dependent initialization */
|
||||
void sys_cleanup __P((void)); /* Restore system state before exiting */
|
||||
int sys_check_options __P((void)); /* Check options specified */
|
||||
void sys_close __P((void)); /* Clean up in a child before execing */
|
||||
int ppp_available __P((void)); /* Test whether ppp kernel support exists */
|
||||
int get_pty __P((int *, int *, char *, int)); /* Get pty master/slave */
|
||||
int open_ppp_loopback __P((void)); /* Open loopback for demand-dialling */
|
||||
int tty_establish_ppp __P((int)); /* Turn serial port into a ppp interface */
|
||||
void tty_disestablish_ppp __P((int)); /* Restore port to normal operation */
|
||||
void generic_disestablish_ppp __P((int dev_fd)); /* Restore device setting */
|
||||
int generic_establish_ppp __P((int dev_fd)); /* Make a ppp interface */
|
||||
void make_new_bundle __P((int, int, int, int)); /* Create new bundle */
|
||||
int bundle_attach __P((int)); /* Attach link to existing bundle */
|
||||
void cfg_bundle __P((int, int, int, int)); /* Configure existing bundle */
|
||||
void destroy_bundle __P((void)); /* Tell driver to destroy bundle */
|
||||
void clean_check __P((void)); /* Check if line was 8-bit clean */
|
||||
void set_up_tty __P((int, int)); /* Set up port's speed, parameters, etc. */
|
||||
void restore_tty __P((int)); /* Restore port's original parameters */
|
||||
void setdtr __P((int, int)); /* Raise or lower port's DTR line */
|
||||
void output __P((int, u_char *, int)); /* Output a PPP packet */
|
||||
void wait_input __P((struct timeval *));
|
||||
/* Wait for input, with timeout */
|
||||
void add_fd __P((int)); /* Add fd to set to wait for */
|
||||
void remove_fd __P((int)); /* Remove fd from set to wait for */
|
||||
int read_packet __P((u_char *)); /* Read PPP packet */
|
||||
int get_loop_output __P((void)); /* Read pkts from loopback */
|
||||
void tty_send_config __P((int, u_int32_t, int, int));
|
||||
/* Configure i/f transmit parameters */
|
||||
void tty_set_xaccm __P((ext_accm));
|
||||
/* Set extended transmit ACCM */
|
||||
void tty_recv_config __P((int, u_int32_t, int, int));
|
||||
/* Configure i/f receive parameters */
|
||||
int ccp_test __P((int, u_char *, int, int));
|
||||
/* Test support for compression scheme */
|
||||
void ccp_flags_set __P((int, int, int));
|
||||
/* Set kernel CCP state */
|
||||
int ccp_fatal_error __P((int)); /* Test for fatal decomp error in kernel */
|
||||
int get_idle_time __P((int, struct ppp_idle *));
|
||||
/* Find out how long link has been idle */
|
||||
int get_ppp_stats __P((int, struct pppd_stats *));
|
||||
/* Return link statistics */
|
||||
void netif_set_mtu __P((int, int)); /* Set PPP interface MTU */
|
||||
int netif_get_mtu __P((int)); /* Get PPP interface MTU */
|
||||
int sifvjcomp __P((int, int, int, int));
|
||||
/* Configure VJ TCP header compression */
|
||||
int sifup __P((int)); /* Configure i/f up for one protocol */
|
||||
int sifnpmode __P((int u, int proto, enum NPmode mode));
|
||||
/* Set mode for handling packets for proto */
|
||||
int sifdown __P((int)); /* Configure i/f down for one protocol */
|
||||
int sifaddr __P((int, u_int32_t, u_int32_t, u_int32_t));
|
||||
/* Configure IPv4 addresses for i/f */
|
||||
int cifaddr __P((int, u_int32_t, u_int32_t));
|
||||
/* Reset i/f IP addresses */
|
||||
#ifdef INET6
|
||||
int sif6addr __P((int, eui64_t, eui64_t));
|
||||
/* Configure IPv6 addresses for i/f */
|
||||
int cif6addr __P((int, eui64_t, eui64_t));
|
||||
/* Remove an IPv6 address from i/f */
|
||||
#endif
|
||||
int sifdefaultroute __P((int, u_int32_t, u_int32_t));
|
||||
/* Create default route through i/f */
|
||||
int cifdefaultroute __P((int, u_int32_t, u_int32_t));
|
||||
/* Delete default route through i/f */
|
||||
int sifproxyarp __P((int, u_int32_t));
|
||||
/* Add proxy ARP entry for peer */
|
||||
int cifproxyarp __P((int, u_int32_t));
|
||||
/* Delete proxy ARP entry for peer */
|
||||
u_int32_t GetMask __P((u_int32_t)); /* Get appropriate netmask for address */
|
||||
int lock __P((char *)); /* Create lock file for device */
|
||||
int relock __P((int)); /* Rewrite lock file with new pid */
|
||||
void unlock __P((void)); /* Delete previously-created lock file */
|
||||
void logwtmp __P((const char *, const char *, const char *));
|
||||
/* Write entry to wtmp file */
|
||||
int get_host_seed __P((void)); /* Get host-dependent random number seed */
|
||||
int have_route_to __P((u_int32_t)); /* Check if route to addr exists */
|
||||
#ifdef PPP_FILTER
|
||||
int set_filters __P((struct bpf_program *pass, struct bpf_program *active));
|
||||
/* Set filter programs in kernel */
|
||||
#endif
|
||||
#ifdef IPX_CHANGE
|
||||
int sipxfaddr __P((int, unsigned long, unsigned char *));
|
||||
int cipxfaddr __P((int));
|
||||
#endif
|
||||
int get_if_hwaddr __P((u_char *addr, char *name));
|
||||
char *get_first_ethernet __P((void));
|
||||
|
||||
/* Procedures exported from options.c */
|
||||
int setipaddr __P((char *, char **, int)); /* Set local/remote ip addresses */
|
||||
int parse_args __P((int argc, char **argv));
|
||||
/* Parse options from arguments given */
|
||||
int options_from_file __P((char *filename, int must_exist, int check_prot,
|
||||
int privileged));
|
||||
/* Parse options from an options file */
|
||||
int options_from_user __P((void)); /* Parse options from user's .ppprc */
|
||||
int options_for_tty __P((void)); /* Parse options from /etc/ppp/options.tty */
|
||||
int options_from_list __P((struct wordlist *, int privileged));
|
||||
/* Parse options from a wordlist */
|
||||
int getword __P((FILE *f, char *word, int *newlinep, char *filename));
|
||||
/* Read a word from a file */
|
||||
void option_error __P((char *fmt, ...));
|
||||
/* Print an error message about an option */
|
||||
int int_option __P((char *, int *));
|
||||
/* Simplified number_option for decimal ints */
|
||||
void add_options __P((option_t *)); /* Add extra options */
|
||||
void check_options __P((void)); /* check values after all options parsed */
|
||||
int override_value __P((const char *, int, const char *));
|
||||
/* override value if permitted by priority */
|
||||
void print_options __P((void (*) __P((void *, char *, ...)), void *));
|
||||
/* print out values of all options */
|
||||
|
||||
int parse_dotted_ip __P((char *, u_int32_t *));
|
||||
|
||||
/*
|
||||
* Hooks to enable plugins to change various things.
|
||||
*/
|
||||
extern int (*new_phase_hook) __P((int));
|
||||
extern int (*idle_time_hook) __P((struct ppp_idle *));
|
||||
extern int (*holdoff_hook) __P((void));
|
||||
extern int (*pap_check_hook) __P((void));
|
||||
extern int (*pap_auth_hook) __P((char *user, char *passwd, char **msgp,
|
||||
struct wordlist **paddrs,
|
||||
struct wordlist **popts));
|
||||
extern void (*pap_logout_hook) __P((void));
|
||||
extern int (*pap_passwd_hook) __P((char *user, char *passwd));
|
||||
extern int (*allowed_address_hook) __P((u_int32_t addr));
|
||||
extern void (*ip_up_hook) __P((void));
|
||||
extern void (*ip_down_hook) __P((void));
|
||||
extern void (*ip_choose_hook) __P((u_int32_t *));
|
||||
|
||||
extern int (*chap_check_hook) __P((void));
|
||||
extern int (*chap_passwd_hook) __P((char *user, char *passwd));
|
||||
|
||||
/* Let a plugin snoop sent and received packets. Useful for L2TP */
|
||||
extern void (*snoop_recv_hook) __P((unsigned char *p, int len));
|
||||
extern void (*snoop_send_hook) __P((unsigned char *p, int len));
|
||||
|
||||
/*
|
||||
* Inline versions of get/put char/short/long.
|
||||
* Pointer is advanced; we assume that both arguments
|
||||
* are lvalues and will already be in registers.
|
||||
* cp MUST be u_char *.
|
||||
*/
|
||||
#define GETCHAR(c, cp) { \
|
||||
(c) = *(cp)++; \
|
||||
}
|
||||
#define PUTCHAR(c, cp) { \
|
||||
*(cp)++ = (u_char) (c); \
|
||||
}
|
||||
|
||||
|
||||
#define GETSHORT(s, cp) { \
|
||||
(s) = *(cp)++ << 8; \
|
||||
(s) |= *(cp)++; \
|
||||
}
|
||||
#define PUTSHORT(s, cp) { \
|
||||
*(cp)++ = (u_char) ((s) >> 8); \
|
||||
*(cp)++ = (u_char) (s); \
|
||||
}
|
||||
|
||||
#define GETLONG(l, cp) { \
|
||||
(l) = *(cp)++ << 8; \
|
||||
(l) |= *(cp)++; (l) <<= 8; \
|
||||
(l) |= *(cp)++; (l) <<= 8; \
|
||||
(l) |= *(cp)++; \
|
||||
}
|
||||
#define PUTLONG(l, cp) { \
|
||||
*(cp)++ = (u_char) ((l) >> 24); \
|
||||
*(cp)++ = (u_char) ((l) >> 16); \
|
||||
*(cp)++ = (u_char) ((l) >> 8); \
|
||||
*(cp)++ = (u_char) (l); \
|
||||
}
|
||||
|
||||
#define INCPTR(n, cp) ((cp) += (n))
|
||||
#define DECPTR(n, cp) ((cp) -= (n))
|
||||
|
||||
/*
|
||||
* System dependent definitions for user-level 4.3BSD UNIX implementation.
|
||||
*/
|
||||
|
||||
#define TIMEOUT(r, f, t) timeout((r), (f), (t), 0)
|
||||
#define UNTIMEOUT(r, f) untimeout((r), (f))
|
||||
|
||||
#define BCOPY(s, d, l) memcpy(d, s, l)
|
||||
#define BZERO(s, n) memset(s, 0, n)
|
||||
#define BCMP(s1, s2, l) memcmp(s1, s2, l)
|
||||
|
||||
#define PRINTMSG(m, l) { info("Remote message: %0.*v", l, m); }
|
||||
|
||||
/*
|
||||
* MAKEHEADER - Add Header fields to a packet.
|
||||
*/
|
||||
#define MAKEHEADER(p, t) { \
|
||||
PUTCHAR(PPP_ALLSTATIONS, p); \
|
||||
PUTCHAR(PPP_UI, p); \
|
||||
PUTSHORT(t, p); }
|
||||
|
||||
/*
|
||||
* Exit status values.
|
||||
*/
|
||||
#define EXIT_OK 0
|
||||
#define EXIT_FATAL_ERROR 1
|
||||
#define EXIT_OPTION_ERROR 2
|
||||
#define EXIT_NOT_ROOT 3
|
||||
#define EXIT_NO_KERNEL_SUPPORT 4
|
||||
#define EXIT_USER_REQUEST 5
|
||||
#define EXIT_LOCK_FAILED 6
|
||||
#define EXIT_OPEN_FAILED 7
|
||||
#define EXIT_CONNECT_FAILED 8
|
||||
#define EXIT_PTYCMD_FAILED 9
|
||||
#define EXIT_NEGOTIATION_FAILED 10
|
||||
#define EXIT_PEER_AUTH_FAILED 11
|
||||
#define EXIT_IDLE_TIMEOUT 12
|
||||
#define EXIT_CONNECT_TIME 13
|
||||
#define EXIT_CALLBACK 14
|
||||
#define EXIT_PEER_DEAD 15
|
||||
#define EXIT_HANGUP 16
|
||||
#define EXIT_LOOPBACK 17
|
||||
#define EXIT_INIT_FAILED 18
|
||||
#define EXIT_AUTH_TOPEER_FAILED 19
|
||||
#ifdef MAXOCTETS
|
||||
#define EXIT_TRAFFIC_LIMIT 20
|
||||
#endif
|
||||
#define EXIT_CNID_AUTH_FAILED 21
|
||||
|
||||
/*
|
||||
* Debug macros. Slightly useful for finding bugs in pppd, not particularly
|
||||
* useful for finding out why your connection isn't being established.
|
||||
*/
|
||||
#ifdef DEBUGALL
|
||||
#define DEBUGMAIN 1
|
||||
#define DEBUGFSM 1
|
||||
#define DEBUGLCP 1
|
||||
#define DEBUGIPCP 1
|
||||
#define DEBUGIPV6CP 1
|
||||
#define DEBUGUPAP 1
|
||||
#define DEBUGCHAP 1
|
||||
#endif
|
||||
|
||||
#ifndef LOG_PPP /* we use LOG_LOCAL2 for syslog by default */
|
||||
#if defined(DEBUGMAIN) || defined(DEBUGFSM) || defined(DEBUGSYS) \
|
||||
|| defined(DEBUGLCP) || defined(DEBUGIPCP) || defined(DEBUGUPAP) \
|
||||
|| defined(DEBUGCHAP) || defined(DEBUG) || defined(DEBUGIPV6CP)
|
||||
#define LOG_PPP LOG_LOCAL2
|
||||
#else
|
||||
#define LOG_PPP LOG_DAEMON
|
||||
#endif
|
||||
#endif /* LOG_PPP */
|
||||
|
||||
#ifdef DEBUGMAIN
|
||||
#define MAINDEBUG(x) if (debug) dbglog x
|
||||
#else
|
||||
#define MAINDEBUG(x)
|
||||
#endif
|
||||
|
||||
#ifdef DEBUGSYS
|
||||
#define SYSDEBUG(x) if (debug) dbglog x
|
||||
#else
|
||||
#define SYSDEBUG(x)
|
||||
#endif
|
||||
|
||||
#ifdef DEBUGFSM
|
||||
#define FSMDEBUG(x) if (debug) dbglog x
|
||||
#else
|
||||
#define FSMDEBUG(x)
|
||||
#endif
|
||||
|
||||
#ifdef DEBUGLCP
|
||||
#define LCPDEBUG(x) if (debug) dbglog x
|
||||
#else
|
||||
#define LCPDEBUG(x)
|
||||
#endif
|
||||
|
||||
#ifdef DEBUGIPCP
|
||||
#define IPCPDEBUG(x) if (debug) dbglog x
|
||||
#else
|
||||
#define IPCPDEBUG(x)
|
||||
#endif
|
||||
|
||||
#ifdef DEBUGIPV6CP
|
||||
#define IPV6CPDEBUG(x) if (debug) dbglog x
|
||||
#else
|
||||
#define IPV6CPDEBUG(x)
|
||||
#endif
|
||||
|
||||
#ifdef DEBUGUPAP
|
||||
#define UPAPDEBUG(x) if (debug) dbglog x
|
||||
#else
|
||||
#define UPAPDEBUG(x)
|
||||
#endif
|
||||
|
||||
#ifdef DEBUGCHAP
|
||||
#define CHAPDEBUG(x) if (debug) dbglog x
|
||||
#else
|
||||
#define CHAPDEBUG(x)
|
||||
#endif
|
||||
|
||||
#ifdef DEBUGIPXCP
|
||||
#define IPXCPDEBUG(x) if (debug) dbglog x
|
||||
#else
|
||||
#define IPXCPDEBUG(x)
|
||||
#endif
|
||||
|
||||
#ifndef SIGTYPE
|
||||
#if defined(sun) || defined(SYSV) || defined(POSIX_SOURCE)
|
||||
#define SIGTYPE void
|
||||
#else
|
||||
#define SIGTYPE int
|
||||
#endif /* defined(sun) || defined(SYSV) || defined(POSIX_SOURCE) */
|
||||
#endif /* SIGTYPE */
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(a, b) ((a) < (b)? (a): (b))
|
||||
#endif
|
||||
#ifndef MAX
|
||||
#define MAX(a, b) ((a) > (b)? (a): (b))
|
||||
#endif
|
||||
|
||||
#ifndef offsetof
|
||||
#define offsetof(type, member) ((size_t) &((type *)0)->member)
|
||||
#endif
|
||||
|
||||
#endif /* __PPP_H__ */
|
||||
168
vpn-daemons/pptp/src/external/2.4.4b1/pppd/fsm.h
vendored
168
vpn-daemons/pptp/src/external/2.4.4b1/pppd/fsm.h
vendored
|
|
@ -1,168 +0,0 @@
|
|||
/*
|
||||
* fsm.h - {Link, IP} Control Protocol Finite State Machine definitions.
|
||||
*
|
||||
* Copyright (c) 1984-2000 Carnegie Mellon University. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. The name "Carnegie Mellon University" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For permission or any legal
|
||||
* details, please contact
|
||||
* Office of Technology Transfer
|
||||
* Carnegie Mellon University
|
||||
* 5000 Forbes Avenue
|
||||
* Pittsburgh, PA 15213-3890
|
||||
* (412) 268-4387, fax: (412) 268-7395
|
||||
* tech-transfer@andrew.cmu.edu
|
||||
*
|
||||
* 4. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by Computing Services
|
||||
* at Carnegie Mellon University (http://www.cmu.edu/computing/)."
|
||||
*
|
||||
* CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
|
||||
* FOR ANY SPECIAL, 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.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/*
|
||||
* Packet header = Code, id, length.
|
||||
*/
|
||||
#define HEADERLEN 4
|
||||
|
||||
|
||||
/*
|
||||
* CP (LCP, IPCP, etc.) codes.
|
||||
*/
|
||||
#define CONFREQ 1 /* Configuration Request */
|
||||
#define CONFACK 2 /* Configuration Ack */
|
||||
#define CONFNAK 3 /* Configuration Nak */
|
||||
#define CONFREJ 4 /* Configuration Reject */
|
||||
#define TERMREQ 5 /* Termination Request */
|
||||
#define TERMACK 6 /* Termination Ack */
|
||||
#define CODEREJ 7 /* Code Reject */
|
||||
|
||||
|
||||
/*
|
||||
* Each FSM is described by an fsm structure and fsm callbacks.
|
||||
*/
|
||||
typedef struct fsm {
|
||||
int unit; /* Interface unit number */
|
||||
int protocol; /* Data Link Layer Protocol field value */
|
||||
int state; /* State */
|
||||
int flags; /* Contains option bits */
|
||||
u_char id; /* Current id */
|
||||
u_char reqid; /* Current request id */
|
||||
u_char seen_ack; /* Have received valid Ack/Nak/Rej to Req */
|
||||
int timeouttime; /* Timeout time in milliseconds */
|
||||
int maxconfreqtransmits; /* Maximum Configure-Request transmissions */
|
||||
int retransmits; /* Number of retransmissions left */
|
||||
int maxtermtransmits; /* Maximum Terminate-Request transmissions */
|
||||
int nakloops; /* Number of nak loops since last ack */
|
||||
int rnakloops; /* Number of naks received */
|
||||
int maxnakloops; /* Maximum number of nak loops tolerated */
|
||||
struct fsm_callbacks *callbacks; /* Callback routines */
|
||||
char *term_reason; /* Reason for closing protocol */
|
||||
int term_reason_len; /* Length of term_reason */
|
||||
} fsm;
|
||||
|
||||
|
||||
typedef struct fsm_callbacks {
|
||||
void (*resetci) /* Reset our Configuration Information */
|
||||
__P((fsm *));
|
||||
int (*cilen) /* Length of our Configuration Information */
|
||||
__P((fsm *));
|
||||
void (*addci) /* Add our Configuration Information */
|
||||
__P((fsm *, u_char *, int *));
|
||||
int (*ackci) /* ACK our Configuration Information */
|
||||
__P((fsm *, u_char *, int));
|
||||
int (*nakci) /* NAK our Configuration Information */
|
||||
__P((fsm *, u_char *, int, int));
|
||||
int (*rejci) /* Reject our Configuration Information */
|
||||
__P((fsm *, u_char *, int));
|
||||
int (*reqci) /* Request peer's Configuration Information */
|
||||
__P((fsm *, u_char *, int *, int));
|
||||
void (*up) /* Called when fsm reaches OPENED state */
|
||||
__P((fsm *));
|
||||
void (*down) /* Called when fsm leaves OPENED state */
|
||||
__P((fsm *));
|
||||
void (*starting) /* Called when we want the lower layer */
|
||||
__P((fsm *));
|
||||
void (*finished) /* Called when we don't want the lower layer */
|
||||
__P((fsm *));
|
||||
void (*protreject) /* Called when Protocol-Reject received */
|
||||
__P((int));
|
||||
void (*retransmit) /* Retransmission is necessary */
|
||||
__P((fsm *));
|
||||
int (*extcode) /* Called when unknown code received */
|
||||
__P((fsm *, int, int, u_char *, int));
|
||||
char *proto_name; /* String name for protocol (for messages) */
|
||||
} fsm_callbacks;
|
||||
|
||||
|
||||
/*
|
||||
* Link states.
|
||||
*/
|
||||
#define INITIAL 0 /* Down, hasn't been opened */
|
||||
#define STARTING 1 /* Down, been opened */
|
||||
#define CLOSED 2 /* Up, hasn't been opened */
|
||||
#define STOPPED 3 /* Open, waiting for down event */
|
||||
#define CLOSING 4 /* Terminating the connection, not open */
|
||||
#define STOPPING 5 /* Terminating, but open */
|
||||
#define REQSENT 6 /* We've sent a Config Request */
|
||||
#define ACKRCVD 7 /* We've received a Config Ack */
|
||||
#define ACKSENT 8 /* We've sent a Config Ack */
|
||||
#define OPENED 9 /* Connection available */
|
||||
|
||||
|
||||
/*
|
||||
* Flags - indicate options controlling FSM operation
|
||||
*/
|
||||
#define OPT_PASSIVE 1 /* Don't die if we don't get a response */
|
||||
#define OPT_RESTART 2 /* Treat 2nd OPEN as DOWN, UP */
|
||||
#define OPT_SILENT 4 /* Wait for peer to speak first */
|
||||
|
||||
|
||||
/*
|
||||
* Timeouts.
|
||||
*/
|
||||
#define DEFTIMEOUT 3 /* Timeout time in seconds */
|
||||
#define DEFMAXTERMREQS 2 /* Maximum Terminate-Request transmissions */
|
||||
#define DEFMAXCONFREQS 10 /* Maximum Configure-Request transmissions */
|
||||
#define DEFMAXNAKLOOPS 5 /* Maximum number of nak loops */
|
||||
|
||||
|
||||
/*
|
||||
* Prototypes
|
||||
*/
|
||||
void fsm_init __P((fsm *));
|
||||
void fsm_lowerup __P((fsm *));
|
||||
void fsm_lowerdown __P((fsm *));
|
||||
void fsm_open __P((fsm *));
|
||||
void fsm_close __P((fsm *, char *));
|
||||
void fsm_input __P((fsm *, u_char *, int));
|
||||
void fsm_protreject __P((fsm *));
|
||||
void fsm_sdata __P((fsm *, int, int, u_char *, int));
|
||||
|
||||
|
||||
/*
|
||||
* Variables
|
||||
*/
|
||||
extern int peer_mru[]; /* currently negotiated peer MRU (per unit) */
|
||||
|
|
@ -1,96 +0,0 @@
|
|||
/*
|
||||
* ipcp.h - IP Control Protocol definitions.
|
||||
*
|
||||
* Copyright (c) 1984-2000 Carnegie Mellon University. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. The name "Carnegie Mellon University" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For permission or any legal
|
||||
* details, please contact
|
||||
* Office of Technology Transfer
|
||||
* Carnegie Mellon University
|
||||
* 5000 Forbes Avenue
|
||||
* Pittsburgh, PA 15213-3890
|
||||
* (412) 268-4387, fax: (412) 268-7395
|
||||
* tech-transfer@andrew.cmu.edu
|
||||
*
|
||||
* 4. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by Computing Services
|
||||
* at Carnegie Mellon University (http://www.cmu.edu/computing/)."
|
||||
*
|
||||
* CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
|
||||
* FOR ANY SPECIAL, 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.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/*
|
||||
* Options.
|
||||
*/
|
||||
#define CI_ADDRS 1 /* IP Addresses */
|
||||
#define CI_COMPRESSTYPE 2 /* Compression Type */
|
||||
#define CI_ADDR 3
|
||||
|
||||
#define CI_MS_DNS1 129 /* Primary DNS value */
|
||||
#define CI_MS_WINS1 130 /* Primary WINS value */
|
||||
#define CI_MS_DNS2 131 /* Secondary DNS value */
|
||||
#define CI_MS_WINS2 132 /* Secondary WINS value */
|
||||
|
||||
#define MAX_STATES 16 /* from slcompress.h */
|
||||
|
||||
#define IPCP_VJMODE_OLD 1 /* "old" mode (option # = 0x0037) */
|
||||
#define IPCP_VJMODE_RFC1172 2 /* "old-rfc"mode (option # = 0x002d) */
|
||||
#define IPCP_VJMODE_RFC1332 3 /* "new-rfc"mode (option # = 0x002d, */
|
||||
/* maxslot and slot number compression) */
|
||||
|
||||
#define IPCP_VJ_COMP 0x002d /* current value for VJ compression option*/
|
||||
#define IPCP_VJ_COMP_OLD 0x0037 /* "old" (i.e, broken) value for VJ */
|
||||
/* compression option*/
|
||||
|
||||
typedef struct ipcp_options {
|
||||
bool neg_addr; /* Negotiate IP Address? */
|
||||
bool old_addrs; /* Use old (IP-Addresses) option? */
|
||||
bool req_addr; /* Ask peer to send IP address? */
|
||||
bool default_route; /* Assign default route through interface? */
|
||||
bool proxy_arp; /* Make proxy ARP entry for peer? */
|
||||
bool neg_vj; /* Van Jacobson Compression? */
|
||||
bool old_vj; /* use old (short) form of VJ option? */
|
||||
bool accept_local; /* accept peer's value for ouraddr */
|
||||
bool accept_remote; /* accept peer's value for hisaddr */
|
||||
bool req_dns1; /* Ask peer to send primary DNS address? */
|
||||
bool req_dns2; /* Ask peer to send secondary DNS address? */
|
||||
int vj_protocol; /* protocol value to use in VJ option */
|
||||
int maxslotindex; /* values for RFC1332 VJ compression neg. */
|
||||
bool cflag;
|
||||
u_int32_t ouraddr, hisaddr; /* Addresses in NETWORK BYTE ORDER */
|
||||
u_int32_t dnsaddr[2]; /* Primary and secondary MS DNS entries */
|
||||
u_int32_t winsaddr[2]; /* Primary and secondary MS WINS entries */
|
||||
} ipcp_options;
|
||||
|
||||
extern fsm ipcp_fsm[];
|
||||
extern ipcp_options ipcp_wantoptions[];
|
||||
extern ipcp_options ipcp_gotoptions[];
|
||||
extern ipcp_options ipcp_allowoptions[];
|
||||
extern ipcp_options ipcp_hisoptions[];
|
||||
|
||||
char *ip_ntoa __P((u_int32_t));
|
||||
|
||||
extern struct protent ipcp_protent;
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
/* $Id$ */
|
||||
|
||||
#define VERSION "2.4.4b1"
|
||||
#define DATE "28 August 2005"
|
||||
907
vpn-daemons/pptp/src/external/2.4.4b1/pppd/pppd.h
vendored
907
vpn-daemons/pptp/src/external/2.4.4b1/pppd/pppd.h
vendored
|
|
@ -1,907 +0,0 @@
|
|||
/*
|
||||
* pppd.h - PPP daemon global declarations.
|
||||
*
|
||||
* Copyright (c) 1984-2000 Carnegie Mellon University. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. The name "Carnegie Mellon University" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For permission or any legal
|
||||
* details, please contact
|
||||
* Office of Technology Transfer
|
||||
* Carnegie Mellon University
|
||||
* 5000 Forbes Avenue
|
||||
* Pittsburgh, PA 15213-3890
|
||||
* (412) 268-4387, fax: (412) 268-7395
|
||||
* tech-transfer@andrew.cmu.edu
|
||||
*
|
||||
* 4. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by Computing Services
|
||||
* at Carnegie Mellon University (http://www.cmu.edu/computing/)."
|
||||
*
|
||||
* CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
|
||||
* FOR ANY SPECIAL, 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.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/*
|
||||
* TODO:
|
||||
*/
|
||||
|
||||
#ifndef __PPPD_H__
|
||||
#define __PPPD_H__
|
||||
|
||||
#include <stdio.h> /* for FILE */
|
||||
#include <limits.h> /* for NGROUPS_MAX */
|
||||
#include <sys/param.h> /* for MAXPATHLEN and BSD4_4, if defined */
|
||||
#include <sys/types.h> /* for u_int32_t, if defined */
|
||||
#include <sys/time.h> /* for struct timeval */
|
||||
#include <net/ppp_defs.h>
|
||||
#include "patchlevel.h"
|
||||
|
||||
#if defined(__STDC__)
|
||||
#include <stdarg.h>
|
||||
#define __V(x) x
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#define __V(x) (va_alist) va_dcl
|
||||
#define const
|
||||
#define volatile
|
||||
#endif
|
||||
|
||||
#ifdef INET6
|
||||
#include "eui64.h"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Limits.
|
||||
*/
|
||||
|
||||
#define NUM_PPP 1 /* One PPP interface supported (per process) */
|
||||
#define MAXWORDLEN 1024 /* max length of word in file (incl null) */
|
||||
#define MAXARGS 1 /* max # args to a command */
|
||||
#define MAXNAMELEN 256 /* max length of hostname or name for auth */
|
||||
#define MAXSECRETLEN 256 /* max length of password or secret */
|
||||
|
||||
/*
|
||||
* Option descriptor structure.
|
||||
*/
|
||||
|
||||
typedef unsigned char bool;
|
||||
|
||||
enum opt_type {
|
||||
o_special_noarg = 0,
|
||||
o_special = 1,
|
||||
o_bool,
|
||||
o_int,
|
||||
o_uint32,
|
||||
o_string,
|
||||
o_wild
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
char *name; /* name of the option */
|
||||
enum opt_type type;
|
||||
void *addr;
|
||||
char *description;
|
||||
unsigned int flags;
|
||||
void *addr2;
|
||||
int upper_limit;
|
||||
int lower_limit;
|
||||
const char *source;
|
||||
short int priority;
|
||||
short int winner;
|
||||
} option_t;
|
||||
|
||||
/* Values for flags */
|
||||
#define OPT_VALUE 0xff /* mask for presupplied value */
|
||||
#define OPT_HEX 0x100 /* int option is in hex */
|
||||
#define OPT_NOARG 0x200 /* option doesn't take argument */
|
||||
#define OPT_OR 0x400 /* OR in argument to value */
|
||||
#define OPT_INC 0x800 /* increment value */
|
||||
#define OPT_A2OR 0x800 /* for o_bool, OR arg to *(u_char *)addr2 */
|
||||
#define OPT_PRIV 0x1000 /* privileged option */
|
||||
#define OPT_STATIC 0x2000 /* string option goes into static array */
|
||||
#define OPT_LLIMIT 0x4000 /* check value against lower limit */
|
||||
#define OPT_ULIMIT 0x8000 /* check value against upper limit */
|
||||
#define OPT_LIMITS (OPT_LLIMIT|OPT_ULIMIT)
|
||||
#define OPT_ZEROOK 0x10000 /* 0 value is OK even if not within limits */
|
||||
#define OPT_HIDE 0x10000 /* for o_string, print value as ?????? */
|
||||
#define OPT_A2LIST 0x10000 /* for o_special, keep list of values */
|
||||
#define OPT_A2CLRB 0x10000 /* o_bool, clr val bits in *(u_char *)addr2 */
|
||||
#define OPT_NOINCR 0x20000 /* value mustn't be increased */
|
||||
#define OPT_ZEROINF 0x40000 /* with OPT_NOINCR, 0 == infinity */
|
||||
#define OPT_PRIO 0x80000 /* process option priorities for this option */
|
||||
#define OPT_PRIOSUB 0x100000 /* subsidiary member of priority group */
|
||||
#define OPT_ALIAS 0x200000 /* option is alias for previous option */
|
||||
#define OPT_A2COPY 0x400000 /* addr2 -> second location to rcv value */
|
||||
#define OPT_ENABLE 0x800000 /* use *addr2 as enable for option */
|
||||
#define OPT_A2CLR 0x1000000 /* clear *(bool *)addr2 */
|
||||
#define OPT_PRIVFIX 0x2000000 /* user can't override if set by root */
|
||||
#define OPT_INITONLY 0x4000000 /* option can only be set in init phase */
|
||||
#define OPT_DEVEQUIV 0x8000000 /* equiv to device name */
|
||||
#define OPT_DEVNAM (OPT_INITONLY | OPT_DEVEQUIV)
|
||||
#define OPT_A2PRINTER 0x10000000 /* *addr2 is a fn for printing option */
|
||||
#define OPT_A2STRVAL 0x20000000 /* *addr2 points to current string value */
|
||||
#define OPT_NOPRINT 0x40000000 /* don't print this option at all */
|
||||
|
||||
#define OPT_VAL(x) ((x) & OPT_VALUE)
|
||||
|
||||
/* Values for priority */
|
||||
#define OPRIO_DEFAULT 0 /* a default value */
|
||||
#define OPRIO_CFGFILE 1 /* value from a configuration file */
|
||||
#define OPRIO_CMDLINE 2 /* value from the command line */
|
||||
#define OPRIO_SECFILE 3 /* value from options in a secrets file */
|
||||
#define OPRIO_ROOT 100 /* added to priority if OPT_PRIVFIX && root */
|
||||
|
||||
#ifndef GIDSET_TYPE
|
||||
#define GIDSET_TYPE gid_t
|
||||
#endif
|
||||
|
||||
/* Structure representing a list of permitted IP addresses. */
|
||||
struct permitted_ip {
|
||||
int permit; /* 1 = permit, 0 = forbid */
|
||||
u_int32_t base; /* match if (addr & mask) == base */
|
||||
u_int32_t mask; /* base and mask are in network byte order */
|
||||
};
|
||||
|
||||
/*
|
||||
* Unfortunately, the linux kernel driver uses a different structure
|
||||
* for statistics from the rest of the ports.
|
||||
* This structure serves as a common representation for the bits
|
||||
* pppd needs.
|
||||
*/
|
||||
struct pppd_stats {
|
||||
unsigned int bytes_in;
|
||||
unsigned int bytes_out;
|
||||
unsigned int pkts_in;
|
||||
unsigned int pkts_out;
|
||||
};
|
||||
|
||||
/* Used for storing a sequence of words. Usually malloced. */
|
||||
struct wordlist {
|
||||
struct wordlist *next;
|
||||
char *word;
|
||||
};
|
||||
|
||||
/* An endpoint discriminator, used with multilink. */
|
||||
#define MAX_ENDP_LEN 20 /* maximum length of discriminator value */
|
||||
struct epdisc {
|
||||
unsigned char class;
|
||||
unsigned char length;
|
||||
unsigned char value[MAX_ENDP_LEN];
|
||||
};
|
||||
|
||||
/* values for epdisc.class */
|
||||
#define EPD_NULL 0 /* null discriminator, no data */
|
||||
#define EPD_LOCAL 1
|
||||
#define EPD_IP 2
|
||||
#define EPD_MAC 3
|
||||
#define EPD_MAGIC 4
|
||||
#define EPD_PHONENUM 5
|
||||
|
||||
typedef void (*notify_func) __P((void *, int));
|
||||
|
||||
struct notifier {
|
||||
struct notifier *next;
|
||||
notify_func func;
|
||||
void *arg;
|
||||
};
|
||||
|
||||
/*
|
||||
* Global variables.
|
||||
*/
|
||||
|
||||
extern int hungup; /* Physical layer has disconnected */
|
||||
extern int ifunit; /* Interface unit number */
|
||||
extern char ifname[]; /* Interface name */
|
||||
extern char hostname[]; /* Our hostname */
|
||||
extern u_char outpacket_buf[]; /* Buffer for outgoing packets */
|
||||
extern int devfd; /* fd of underlying device */
|
||||
extern int fd_ppp; /* fd for talking PPP */
|
||||
extern int phase; /* Current state of link - see values below */
|
||||
extern int baud_rate; /* Current link speed in bits/sec */
|
||||
extern char *progname; /* Name of this program */
|
||||
extern int redirect_stderr;/* Connector's stderr should go to file */
|
||||
extern char peer_authname[];/* Authenticated name of peer */
|
||||
extern int auth_done[NUM_PPP]; /* Methods actually used for auth */
|
||||
extern int privileged; /* We were run by real-uid root */
|
||||
extern int need_holdoff; /* Need holdoff period after link terminates */
|
||||
extern char **script_env; /* Environment variables for scripts */
|
||||
extern int detached; /* Have detached from controlling tty */
|
||||
extern GIDSET_TYPE groups[NGROUPS_MAX]; /* groups the user is in */
|
||||
extern int ngroups; /* How many groups valid in groups */
|
||||
extern struct pppd_stats link_stats; /* byte/packet counts etc. for link */
|
||||
extern int link_stats_valid; /* set if link_stats is valid */
|
||||
extern unsigned link_connect_time; /* time the link was up for */
|
||||
extern int using_pty; /* using pty as device (notty or pty opt.) */
|
||||
extern int log_to_fd; /* logging to this fd as well as syslog */
|
||||
extern bool log_default; /* log_to_fd is default (stdout) */
|
||||
extern char *no_ppp_msg; /* message to print if ppp not in kernel */
|
||||
extern volatile int status; /* exit status for pppd */
|
||||
extern bool devnam_fixed; /* can no longer change devnam */
|
||||
extern int unsuccess; /* # unsuccessful connection attempts */
|
||||
extern int do_callback; /* set if we want to do callback next */
|
||||
extern int doing_callback; /* set if this is a callback */
|
||||
extern int error_count; /* # of times error() has been called */
|
||||
extern char ppp_devnam[MAXPATHLEN];
|
||||
extern char remote_number[MAXNAMELEN]; /* Remote telephone number, if avail. */
|
||||
extern int ppp_session_number; /* Session number (eg PPPoE session) */
|
||||
extern int fd_devnull; /* fd open to /dev/null */
|
||||
|
||||
extern int listen_time; /* time to listen first (ms) */
|
||||
extern bool doing_multilink;
|
||||
extern bool multilink_master;
|
||||
extern bool bundle_eof;
|
||||
extern bool bundle_terminating;
|
||||
|
||||
extern struct notifier *pidchange; /* for notifications of pid changing */
|
||||
extern struct notifier *phasechange; /* for notifications of phase changes */
|
||||
extern struct notifier *exitnotify; /* for notification that we're exiting */
|
||||
extern struct notifier *sigreceived; /* notification of received signal */
|
||||
extern struct notifier *ip_up_notifier; /* IPCP has come up */
|
||||
extern struct notifier *ip_down_notifier; /* IPCP has gone down */
|
||||
extern struct notifier *auth_up_notifier; /* peer has authenticated */
|
||||
extern struct notifier *link_down_notifier; /* link has gone down */
|
||||
extern struct notifier *fork_notifier; /* we are a new child process */
|
||||
|
||||
/* Values for do_callback and doing_callback */
|
||||
#define CALLBACK_DIALIN 1 /* we are expecting the call back */
|
||||
#define CALLBACK_DIALOUT 2 /* we are dialling out to call back */
|
||||
|
||||
/*
|
||||
* Variables set by command-line options.
|
||||
*/
|
||||
|
||||
extern int debug; /* Debug flag */
|
||||
extern int kdebugflag; /* Tell kernel to print debug messages */
|
||||
extern int default_device; /* Using /dev/tty or equivalent */
|
||||
extern char devnam[MAXPATHLEN]; /* Device name */
|
||||
extern int crtscts; /* Use hardware flow control */
|
||||
extern bool modem; /* Use modem control lines */
|
||||
extern int inspeed; /* Input/Output speed requested */
|
||||
extern u_int32_t netmask; /* IP netmask to set on interface */
|
||||
extern bool lockflag; /* Create lock file to lock the serial dev */
|
||||
extern bool nodetach; /* Don't detach from controlling tty */
|
||||
extern bool updetach; /* Detach from controlling tty when link up */
|
||||
extern char *initializer; /* Script to initialize physical link */
|
||||
extern char *connect_script; /* Script to establish physical link */
|
||||
extern char *disconnect_script; /* Script to disestablish physical link */
|
||||
extern char *welcomer; /* Script to welcome client after connection */
|
||||
extern char *ptycommand; /* Command to run on other side of pty */
|
||||
extern int maxconnect; /* Maximum connect time (seconds) */
|
||||
extern char user[MAXNAMELEN];/* Our name for authenticating ourselves */
|
||||
extern char passwd[MAXSECRETLEN]; /* Password for PAP or CHAP */
|
||||
extern bool auth_required; /* Peer is required to authenticate */
|
||||
extern bool persist; /* Reopen link after it goes down */
|
||||
extern bool uselogin; /* Use /etc/passwd for checking PAP */
|
||||
extern char our_name[MAXNAMELEN];/* Our name for authentication purposes */
|
||||
extern char remote_name[MAXNAMELEN]; /* Peer's name for authentication */
|
||||
extern bool explicit_remote;/* remote_name specified with remotename opt */
|
||||
extern bool demand; /* Do dial-on-demand */
|
||||
extern char *ipparam; /* Extra parameter for ip up/down scripts */
|
||||
extern bool cryptpap; /* Others' PAP passwords are encrypted */
|
||||
extern int idle_time_limit;/* Shut down link if idle for this long */
|
||||
extern int holdoff; /* Dead time before restarting */
|
||||
extern bool holdoff_specified; /* true if user gave a holdoff value */
|
||||
extern bool notty; /* Stdin/out is not a tty */
|
||||
extern char *pty_socket; /* Socket to connect to pty */
|
||||
extern char *record_file; /* File to record chars sent/received */
|
||||
extern bool sync_serial; /* Device is synchronous serial device */
|
||||
extern int maxfail; /* Max # of unsuccessful connection attempts */
|
||||
extern char linkname[MAXPATHLEN]; /* logical name for link */
|
||||
extern bool tune_kernel; /* May alter kernel settings as necessary */
|
||||
extern int connect_delay; /* Time to delay after connect script */
|
||||
extern int max_data_rate; /* max bytes/sec through charshunt */
|
||||
extern int req_unit; /* interface unit number to use */
|
||||
extern bool multilink; /* enable multilink operation */
|
||||
extern bool noendpoint; /* don't send or accept endpt. discrim. */
|
||||
extern char *bundle_name; /* bundle name for multilink */
|
||||
extern bool dump_options; /* print out option values */
|
||||
extern bool dryrun; /* check everything, print options, exit */
|
||||
extern int child_wait; /* # seconds to wait for children at end */
|
||||
|
||||
#ifdef MAXOCTETS
|
||||
extern unsigned int maxoctets; /* Maximum octetes per session (in bytes) */
|
||||
extern int maxoctets_dir; /* Direction :
|
||||
0 - in+out (default)
|
||||
1 - in
|
||||
2 - out
|
||||
3 - max(in,out) */
|
||||
extern int maxoctets_timeout; /* Timeout for check of octets limit */
|
||||
#define PPP_OCTETS_DIRECTION_SUM 0
|
||||
#define PPP_OCTETS_DIRECTION_IN 1
|
||||
#define PPP_OCTETS_DIRECTION_OUT 2
|
||||
#define PPP_OCTETS_DIRECTION_MAXOVERAL 3
|
||||
/* same as previos, but little different on RADIUS side */
|
||||
#define PPP_OCTETS_DIRECTION_MAXSESSION 4
|
||||
#endif
|
||||
|
||||
#ifdef PPP_FILTER
|
||||
extern struct bpf_program pass_filter; /* Filter for pkts to pass */
|
||||
extern struct bpf_program active_filter; /* Filter for link-active pkts */
|
||||
#endif
|
||||
|
||||
#ifdef MSLANMAN
|
||||
extern bool ms_lanman; /* Use LanMan password instead of NT */
|
||||
/* Has meaning only with MS-CHAP challenges */
|
||||
#endif
|
||||
|
||||
/* Values for auth_pending, auth_done */
|
||||
#define PAP_WITHPEER 0x1
|
||||
#define PAP_PEER 0x2
|
||||
#define CHAP_WITHPEER 0x4
|
||||
#define CHAP_PEER 0x8
|
||||
#define EAP_WITHPEER 0x10
|
||||
#define EAP_PEER 0x20
|
||||
|
||||
/* Values for auth_done only */
|
||||
#define CHAP_MD5_WITHPEER 0x40
|
||||
#define CHAP_MD5_PEER 0x80
|
||||
#define CHAP_MS_SHIFT 8 /* LSB position for MS auths */
|
||||
#define CHAP_MS_WITHPEER 0x100
|
||||
#define CHAP_MS_PEER 0x200
|
||||
#define CHAP_MS2_WITHPEER 0x400
|
||||
#define CHAP_MS2_PEER 0x800
|
||||
|
||||
extern char *current_option; /* the name of the option being parsed */
|
||||
extern int privileged_option; /* set iff the current option came from root */
|
||||
extern char *option_source; /* string saying where the option came from */
|
||||
extern int option_priority; /* priority of current options */
|
||||
|
||||
/*
|
||||
* Values for phase.
|
||||
*/
|
||||
#define PHASE_DEAD 0
|
||||
#define PHASE_INITIALIZE 1
|
||||
#define PHASE_SERIALCONN 2
|
||||
#define PHASE_DORMANT 3
|
||||
#define PHASE_ESTABLISH 4
|
||||
#define PHASE_AUTHENTICATE 5
|
||||
#define PHASE_CALLBACK 6
|
||||
#define PHASE_NETWORK 7
|
||||
#define PHASE_RUNNING 8
|
||||
#define PHASE_TERMINATE 9
|
||||
#define PHASE_DISCONNECT 10
|
||||
#define PHASE_HOLDOFF 11
|
||||
#define PHASE_MASTER 12
|
||||
|
||||
/*
|
||||
* The following struct gives the addresses of procedures to call
|
||||
* for a particular protocol.
|
||||
*/
|
||||
struct protent {
|
||||
u_short protocol; /* PPP protocol number */
|
||||
/* Initialization procedure */
|
||||
void (*init) __P((int unit));
|
||||
/* Process a received packet */
|
||||
void (*input) __P((int unit, u_char *pkt, int len));
|
||||
/* Process a received protocol-reject */
|
||||
void (*protrej) __P((int unit));
|
||||
/* Lower layer has come up */
|
||||
void (*lowerup) __P((int unit));
|
||||
/* Lower layer has gone down */
|
||||
void (*lowerdown) __P((int unit));
|
||||
/* Open the protocol */
|
||||
void (*open) __P((int unit));
|
||||
/* Close the protocol */
|
||||
void (*close) __P((int unit, char *reason));
|
||||
/* Print a packet in readable form */
|
||||
int (*printpkt) __P((u_char *pkt, int len,
|
||||
void (*printer) __P((void *, char *, ...)),
|
||||
void *arg));
|
||||
/* Process a received data packet */
|
||||
void (*datainput) __P((int unit, u_char *pkt, int len));
|
||||
bool enabled_flag; /* 0 iff protocol is disabled */
|
||||
char *name; /* Text name of protocol */
|
||||
char *data_name; /* Text name of corresponding data protocol */
|
||||
option_t *options; /* List of command-line options */
|
||||
/* Check requested options, assign defaults */
|
||||
void (*check_options) __P((void));
|
||||
/* Configure interface for demand-dial */
|
||||
int (*demand_conf) __P((int unit));
|
||||
/* Say whether to bring up link for this pkt */
|
||||
int (*active_pkt) __P((u_char *pkt, int len));
|
||||
};
|
||||
|
||||
/* Table of pointers to supported protocols */
|
||||
extern struct protent *protocols[];
|
||||
|
||||
/*
|
||||
* This struct contains pointers to a set of procedures for
|
||||
* doing operations on a "channel". A channel provides a way
|
||||
* to send and receive PPP packets - the canonical example is
|
||||
* a serial port device in PPP line discipline (or equivalently
|
||||
* with PPP STREAMS modules pushed onto it).
|
||||
*/
|
||||
struct channel {
|
||||
/* set of options for this channel */
|
||||
option_t *options;
|
||||
/* find and process a per-channel options file */
|
||||
void (*process_extra_options) __P((void));
|
||||
/* check all the options that have been given */
|
||||
void (*check_options) __P((void));
|
||||
/* get the channel ready to do PPP, return a file descriptor */
|
||||
int (*connect) __P((void));
|
||||
/* we're finished with the channel */
|
||||
void (*disconnect) __P((void));
|
||||
/* put the channel into PPP `mode' */
|
||||
int (*establish_ppp) __P((int));
|
||||
/* take the channel out of PPP `mode', restore loopback if demand */
|
||||
void (*disestablish_ppp) __P((int));
|
||||
/* set the transmit-side PPP parameters of the channel */
|
||||
void (*send_config) __P((int, u_int32_t, int, int));
|
||||
/* set the receive-side PPP parameters of the channel */
|
||||
void (*recv_config) __P((int, u_int32_t, int, int));
|
||||
/* cleanup on error or normal exit */
|
||||
void (*cleanup) __P((void));
|
||||
/* close the device, called in children after fork */
|
||||
void (*close) __P((void));
|
||||
};
|
||||
|
||||
extern struct channel *the_channel;
|
||||
|
||||
/*
|
||||
* Prototypes.
|
||||
*/
|
||||
|
||||
/* Procedures exported from main.c. */
|
||||
void set_ifunit __P((int)); /* set stuff that depends on ifunit */
|
||||
void detach __P((void)); /* Detach from controlling tty */
|
||||
void die __P((int)); /* Cleanup and exit */
|
||||
void quit __P((void)); /* like die(1) */
|
||||
void novm __P((char *)); /* Say we ran out of memory, and die */
|
||||
void timeout __P((void (*func)(void *), void *arg, int s, int us));
|
||||
/* Call func(arg) after s.us seconds */
|
||||
void untimeout __P((void (*func)(void *), void *arg));
|
||||
/* Cancel call to func(arg) */
|
||||
void record_child __P((int, char *, void (*) (void *), void *));
|
||||
pid_t safe_fork __P((int, int, int)); /* Fork & close stuff in child */
|
||||
int device_script __P((char *cmd, int in, int out, int dont_wait));
|
||||
/* Run `cmd' with given stdin and stdout */
|
||||
pid_t run_program __P((char *prog, char **args, int must_exist,
|
||||
void (*done)(void *), void *arg, int wait));
|
||||
/* Run program prog with args in child */
|
||||
void reopen_log __P((void)); /* (re)open the connection to syslog */
|
||||
void print_link_stats __P((void)); /* Print stats, if available */
|
||||
void reset_link_stats __P((int)); /* Reset (init) stats when link goes up */
|
||||
void update_link_stats __P((int)); /* Get stats at link termination */
|
||||
void script_setenv __P((char *, char *, int)); /* set script env var */
|
||||
void script_unsetenv __P((char *)); /* unset script env var */
|
||||
void new_phase __P((int)); /* signal start of new phase */
|
||||
void add_notifier __P((struct notifier **, notify_func, void *));
|
||||
void remove_notifier __P((struct notifier **, notify_func, void *));
|
||||
void notify __P((struct notifier *, int));
|
||||
int ppp_send_config __P((int, int, u_int32_t, int, int));
|
||||
int ppp_recv_config __P((int, int, u_int32_t, int, int));
|
||||
const char *protocol_name __P((int));
|
||||
void remove_pidfiles __P((void));
|
||||
void lock_db __P((void));
|
||||
void unlock_db __P((void));
|
||||
|
||||
/* Procedures exported from tty.c. */
|
||||
void tty_init __P((void));
|
||||
|
||||
/* Procedures exported from utils.c. */
|
||||
void log_packet __P((u_char *, int, char *, int));
|
||||
/* Format a packet and log it with syslog */
|
||||
void print_string __P((char *, int, void (*) (void *, char *, ...),
|
||||
void *)); /* Format a string for output */
|
||||
int slprintf __P((char *, int, char *, ...)); /* sprintf++ */
|
||||
int vslprintf __P((char *, int, char *, va_list)); /* vsprintf++ */
|
||||
size_t strlcpy __P((char *, const char *, size_t)); /* safe strcpy */
|
||||
size_t strlcat __P((char *, const char *, size_t)); /* safe strncpy */
|
||||
void dbglog __P((char *, ...)); /* log a debug message */
|
||||
void info __P((char *, ...)); /* log an informational message */
|
||||
void notice __P((char *, ...)); /* log a notice-level message */
|
||||
void warn __P((char *, ...)); /* log a warning message */
|
||||
void error __P((char *, ...)); /* log an error message */
|
||||
void fatal __P((char *, ...)); /* log an error message and die(1) */
|
||||
void init_pr_log __P((char *, int)); /* initialize for using pr_log */
|
||||
void pr_log __P((void *, char *, ...)); /* printer fn, output to syslog */
|
||||
void end_pr_log __P((void)); /* finish up after using pr_log */
|
||||
void dump_packet __P((const char *, u_char *, int));
|
||||
/* dump packet to debug log if interesting */
|
||||
ssize_t complete_read __P((int, void *, size_t));
|
||||
/* read a complete buffer */
|
||||
|
||||
/* Procedures exported from auth.c */
|
||||
void link_required __P((int)); /* we are starting to use the link */
|
||||
void start_link __P((int)); /* bring the link up now */
|
||||
void link_terminated __P((int)); /* we are finished with the link */
|
||||
void link_down __P((int)); /* the LCP layer has left the Opened state */
|
||||
void upper_layers_down __P((int));/* take all NCPs down */
|
||||
void link_established __P((int)); /* the link is up; authenticate now */
|
||||
void start_networks __P((int)); /* start all the network control protos */
|
||||
void continue_networks __P((int)); /* start network [ip, etc] control protos */
|
||||
void np_up __P((int, int)); /* a network protocol has come up */
|
||||
void np_down __P((int, int)); /* a network protocol has gone down */
|
||||
void np_finished __P((int, int)); /* a network protocol no longer needs link */
|
||||
void auth_peer_fail __P((int, int));
|
||||
/* peer failed to authenticate itself */
|
||||
void auth_peer_success __P((int, int, int, char *, int));
|
||||
/* peer successfully authenticated itself */
|
||||
void auth_withpeer_fail __P((int, int));
|
||||
/* we failed to authenticate ourselves */
|
||||
void auth_withpeer_success __P((int, int, int));
|
||||
/* we successfully authenticated ourselves */
|
||||
void auth_check_options __P((void));
|
||||
/* check authentication options supplied */
|
||||
void auth_reset __P((int)); /* check what secrets we have */
|
||||
int check_passwd __P((int, char *, int, char *, int, char **));
|
||||
/* Check peer-supplied username/password */
|
||||
int get_secret __P((int, char *, char *, char *, int *, int));
|
||||
/* get "secret" for chap */
|
||||
int get_srp_secret __P((int unit, char *client, char *server, char *secret,
|
||||
int am_server));
|
||||
int auth_ip_addr __P((int, u_int32_t));
|
||||
/* check if IP address is authorized */
|
||||
int auth_number __P((void)); /* check if remote number is authorized */
|
||||
int bad_ip_adrs __P((u_int32_t));
|
||||
/* check if IP address is unreasonable */
|
||||
|
||||
/* Procedures exported from demand.c */
|
||||
void demand_conf __P((void)); /* config interface(s) for demand-dial */
|
||||
void demand_block __P((void)); /* set all NPs to queue up packets */
|
||||
void demand_unblock __P((void)); /* set all NPs to pass packets */
|
||||
void demand_discard __P((void)); /* set all NPs to discard packets */
|
||||
void demand_rexmit __P((int)); /* retransmit saved frames for an NP */
|
||||
int loop_chars __P((unsigned char *, int)); /* process chars from loopback */
|
||||
int loop_frame __P((unsigned char *, int)); /* should we bring link up? */
|
||||
|
||||
/* Procedures exported from multilink.c */
|
||||
#ifdef HAVE_MULTILINK
|
||||
void mp_check_options __P((void)); /* Check multilink-related options */
|
||||
int mp_join_bundle __P((void)); /* join our link to an appropriate bundle */
|
||||
void mp_exit_bundle __P((void)); /* have disconnected our link from bundle */
|
||||
void mp_bundle_terminated __P((void));
|
||||
char *epdisc_to_str __P((struct epdisc *)); /* string from endpoint discrim. */
|
||||
int str_to_epdisc __P((struct epdisc *, char *)); /* endpt disc. from str */
|
||||
#else
|
||||
#define mp_bundle_terminated() /* nothing */
|
||||
#define mp_exit_bundle() /* nothing */
|
||||
#define doing_multilink 0
|
||||
#define multilink_master 0
|
||||
#endif
|
||||
|
||||
/* Procedures exported from sys-*.c */
|
||||
void sys_init __P((void)); /* Do system-dependent initialization */
|
||||
void sys_cleanup __P((void)); /* Restore system state before exiting */
|
||||
int sys_check_options __P((void)); /* Check options specified */
|
||||
void sys_close __P((void)); /* Clean up in a child before execing */
|
||||
int ppp_available __P((void)); /* Test whether ppp kernel support exists */
|
||||
int get_pty __P((int *, int *, char *, int)); /* Get pty master/slave */
|
||||
int open_ppp_loopback __P((void)); /* Open loopback for demand-dialling */
|
||||
int tty_establish_ppp __P((int)); /* Turn serial port into a ppp interface */
|
||||
void tty_disestablish_ppp __P((int)); /* Restore port to normal operation */
|
||||
void generic_disestablish_ppp __P((int dev_fd)); /* Restore device setting */
|
||||
int generic_establish_ppp __P((int dev_fd)); /* Make a ppp interface */
|
||||
void make_new_bundle __P((int, int, int, int)); /* Create new bundle */
|
||||
int bundle_attach __P((int)); /* Attach link to existing bundle */
|
||||
void cfg_bundle __P((int, int, int, int)); /* Configure existing bundle */
|
||||
void destroy_bundle __P((void)); /* Tell driver to destroy bundle */
|
||||
void clean_check __P((void)); /* Check if line was 8-bit clean */
|
||||
void set_up_tty __P((int, int)); /* Set up port's speed, parameters, etc. */
|
||||
void restore_tty __P((int)); /* Restore port's original parameters */
|
||||
void setdtr __P((int, int)); /* Raise or lower port's DTR line */
|
||||
void output __P((int, u_char *, int)); /* Output a PPP packet */
|
||||
void wait_input __P((struct timeval *));
|
||||
/* Wait for input, with timeout */
|
||||
void add_fd __P((int)); /* Add fd to set to wait for */
|
||||
void remove_fd __P((int)); /* Remove fd from set to wait for */
|
||||
int read_packet __P((u_char *)); /* Read PPP packet */
|
||||
int get_loop_output __P((void)); /* Read pkts from loopback */
|
||||
void tty_send_config __P((int, u_int32_t, int, int));
|
||||
/* Configure i/f transmit parameters */
|
||||
void tty_set_xaccm __P((ext_accm));
|
||||
/* Set extended transmit ACCM */
|
||||
void tty_recv_config __P((int, u_int32_t, int, int));
|
||||
/* Configure i/f receive parameters */
|
||||
int ccp_test __P((int, u_char *, int, int));
|
||||
/* Test support for compression scheme */
|
||||
void ccp_flags_set __P((int, int, int));
|
||||
/* Set kernel CCP state */
|
||||
int ccp_fatal_error __P((int)); /* Test for fatal decomp error in kernel */
|
||||
int get_idle_time __P((int, struct ppp_idle *));
|
||||
/* Find out how long link has been idle */
|
||||
int get_ppp_stats __P((int, struct pppd_stats *));
|
||||
/* Return link statistics */
|
||||
void netif_set_mtu __P((int, int)); /* Set PPP interface MTU */
|
||||
int netif_get_mtu __P((int)); /* Get PPP interface MTU */
|
||||
int sifvjcomp __P((int, int, int, int));
|
||||
/* Configure VJ TCP header compression */
|
||||
int sifup __P((int)); /* Configure i/f up for one protocol */
|
||||
int sifnpmode __P((int u, int proto, enum NPmode mode));
|
||||
/* Set mode for handling packets for proto */
|
||||
int sifdown __P((int)); /* Configure i/f down for one protocol */
|
||||
int sifaddr __P((int, u_int32_t, u_int32_t, u_int32_t));
|
||||
/* Configure IPv4 addresses for i/f */
|
||||
int cifaddr __P((int, u_int32_t, u_int32_t));
|
||||
/* Reset i/f IP addresses */
|
||||
#ifdef INET6
|
||||
int sif6addr __P((int, eui64_t, eui64_t));
|
||||
/* Configure IPv6 addresses for i/f */
|
||||
int cif6addr __P((int, eui64_t, eui64_t));
|
||||
/* Remove an IPv6 address from i/f */
|
||||
#endif
|
||||
int sifdefaultroute __P((int, u_int32_t, u_int32_t));
|
||||
/* Create default route through i/f */
|
||||
int cifdefaultroute __P((int, u_int32_t, u_int32_t));
|
||||
/* Delete default route through i/f */
|
||||
int sifproxyarp __P((int, u_int32_t));
|
||||
/* Add proxy ARP entry for peer */
|
||||
int cifproxyarp __P((int, u_int32_t));
|
||||
/* Delete proxy ARP entry for peer */
|
||||
u_int32_t GetMask __P((u_int32_t)); /* Get appropriate netmask for address */
|
||||
int lock __P((char *)); /* Create lock file for device */
|
||||
int relock __P((int)); /* Rewrite lock file with new pid */
|
||||
void unlock __P((void)); /* Delete previously-created lock file */
|
||||
void logwtmp __P((const char *, const char *, const char *));
|
||||
/* Write entry to wtmp file */
|
||||
int get_host_seed __P((void)); /* Get host-dependent random number seed */
|
||||
int have_route_to __P((u_int32_t)); /* Check if route to addr exists */
|
||||
#ifdef PPP_FILTER
|
||||
int set_filters __P((struct bpf_program *pass, struct bpf_program *active));
|
||||
/* Set filter programs in kernel */
|
||||
#endif
|
||||
#ifdef IPX_CHANGE
|
||||
int sipxfaddr __P((int, unsigned long, unsigned char *));
|
||||
int cipxfaddr __P((int));
|
||||
#endif
|
||||
int get_if_hwaddr __P((u_char *addr, char *name));
|
||||
char *get_first_ethernet __P((void));
|
||||
|
||||
/* Procedures exported from options.c */
|
||||
int setipaddr __P((char *, char **, int)); /* Set local/remote ip addresses */
|
||||
int parse_args __P((int argc, char **argv));
|
||||
/* Parse options from arguments given */
|
||||
int options_from_file __P((char *filename, int must_exist, int check_prot,
|
||||
int privileged));
|
||||
/* Parse options from an options file */
|
||||
int options_from_user __P((void)); /* Parse options from user's .ppprc */
|
||||
int options_for_tty __P((void)); /* Parse options from /etc/ppp/options.tty */
|
||||
int options_from_list __P((struct wordlist *, int privileged));
|
||||
/* Parse options from a wordlist */
|
||||
int getword __P((FILE *f, char *word, int *newlinep, char *filename));
|
||||
/* Read a word from a file */
|
||||
void option_error __P((char *fmt, ...));
|
||||
/* Print an error message about an option */
|
||||
int int_option __P((char *, int *));
|
||||
/* Simplified number_option for decimal ints */
|
||||
void add_options __P((option_t *)); /* Add extra options */
|
||||
void check_options __P((void)); /* check values after all options parsed */
|
||||
int override_value __P((const char *, int, const char *));
|
||||
/* override value if permitted by priority */
|
||||
void print_options __P((void (*) __P((void *, char *, ...)), void *));
|
||||
/* print out values of all options */
|
||||
|
||||
int parse_dotted_ip __P((char *, u_int32_t *));
|
||||
|
||||
/*
|
||||
* Hooks to enable plugins to change various things.
|
||||
*/
|
||||
extern int (*new_phase_hook) __P((int));
|
||||
extern int (*idle_time_hook) __P((struct ppp_idle *));
|
||||
extern int (*holdoff_hook) __P((void));
|
||||
extern int (*pap_check_hook) __P((void));
|
||||
extern int (*pap_auth_hook) __P((char *user, char *passwd, char **msgp,
|
||||
struct wordlist **paddrs,
|
||||
struct wordlist **popts));
|
||||
extern void (*pap_logout_hook) __P((void));
|
||||
extern int (*pap_passwd_hook) __P((char *user, char *passwd));
|
||||
extern int (*allowed_address_hook) __P((u_int32_t addr));
|
||||
extern void (*ip_up_hook) __P((void));
|
||||
extern void (*ip_down_hook) __P((void));
|
||||
extern void (*ip_choose_hook) __P((u_int32_t *));
|
||||
|
||||
extern int (*chap_check_hook) __P((void));
|
||||
extern int (*chap_passwd_hook) __P((char *user, char *passwd));
|
||||
|
||||
/* Let a plugin snoop sent and received packets. Useful for L2TP */
|
||||
extern void (*snoop_recv_hook) __P((unsigned char *p, int len));
|
||||
extern void (*snoop_send_hook) __P((unsigned char *p, int len));
|
||||
|
||||
/*
|
||||
* Inline versions of get/put char/short/long.
|
||||
* Pointer is advanced; we assume that both arguments
|
||||
* are lvalues and will already be in registers.
|
||||
* cp MUST be u_char *.
|
||||
*/
|
||||
#define GETCHAR(c, cp) { \
|
||||
(c) = *(cp)++; \
|
||||
}
|
||||
#define PUTCHAR(c, cp) { \
|
||||
*(cp)++ = (u_char) (c); \
|
||||
}
|
||||
|
||||
|
||||
#define GETSHORT(s, cp) { \
|
||||
(s) = *(cp)++ << 8; \
|
||||
(s) |= *(cp)++; \
|
||||
}
|
||||
#define PUTSHORT(s, cp) { \
|
||||
*(cp)++ = (u_char) ((s) >> 8); \
|
||||
*(cp)++ = (u_char) (s); \
|
||||
}
|
||||
|
||||
#define GETLONG(l, cp) { \
|
||||
(l) = *(cp)++ << 8; \
|
||||
(l) |= *(cp)++; (l) <<= 8; \
|
||||
(l) |= *(cp)++; (l) <<= 8; \
|
||||
(l) |= *(cp)++; \
|
||||
}
|
||||
#define PUTLONG(l, cp) { \
|
||||
*(cp)++ = (u_char) ((l) >> 24); \
|
||||
*(cp)++ = (u_char) ((l) >> 16); \
|
||||
*(cp)++ = (u_char) ((l) >> 8); \
|
||||
*(cp)++ = (u_char) (l); \
|
||||
}
|
||||
|
||||
#define INCPTR(n, cp) ((cp) += (n))
|
||||
#define DECPTR(n, cp) ((cp) -= (n))
|
||||
|
||||
/*
|
||||
* System dependent definitions for user-level 4.3BSD UNIX implementation.
|
||||
*/
|
||||
|
||||
#define TIMEOUT(r, f, t) timeout((r), (f), (t), 0)
|
||||
#define UNTIMEOUT(r, f) untimeout((r), (f))
|
||||
|
||||
#define BCOPY(s, d, l) memcpy(d, s, l)
|
||||
#define BZERO(s, n) memset(s, 0, n)
|
||||
#define BCMP(s1, s2, l) memcmp(s1, s2, l)
|
||||
|
||||
#define PRINTMSG(m, l) { info("Remote message: %0.*v", l, m); }
|
||||
|
||||
/*
|
||||
* MAKEHEADER - Add Header fields to a packet.
|
||||
*/
|
||||
#define MAKEHEADER(p, t) { \
|
||||
PUTCHAR(PPP_ALLSTATIONS, p); \
|
||||
PUTCHAR(PPP_UI, p); \
|
||||
PUTSHORT(t, p); }
|
||||
|
||||
/*
|
||||
* Exit status values.
|
||||
*/
|
||||
#define EXIT_OK 0
|
||||
#define EXIT_FATAL_ERROR 1
|
||||
#define EXIT_OPTION_ERROR 2
|
||||
#define EXIT_NOT_ROOT 3
|
||||
#define EXIT_NO_KERNEL_SUPPORT 4
|
||||
#define EXIT_USER_REQUEST 5
|
||||
#define EXIT_LOCK_FAILED 6
|
||||
#define EXIT_OPEN_FAILED 7
|
||||
#define EXIT_CONNECT_FAILED 8
|
||||
#define EXIT_PTYCMD_FAILED 9
|
||||
#define EXIT_NEGOTIATION_FAILED 10
|
||||
#define EXIT_PEER_AUTH_FAILED 11
|
||||
#define EXIT_IDLE_TIMEOUT 12
|
||||
#define EXIT_CONNECT_TIME 13
|
||||
#define EXIT_CALLBACK 14
|
||||
#define EXIT_PEER_DEAD 15
|
||||
#define EXIT_HANGUP 16
|
||||
#define EXIT_LOOPBACK 17
|
||||
#define EXIT_INIT_FAILED 18
|
||||
#define EXIT_AUTH_TOPEER_FAILED 19
|
||||
#ifdef MAXOCTETS
|
||||
#define EXIT_TRAFFIC_LIMIT 20
|
||||
#endif
|
||||
#define EXIT_CNID_AUTH_FAILED 21
|
||||
|
||||
/*
|
||||
* Debug macros. Slightly useful for finding bugs in pppd, not particularly
|
||||
* useful for finding out why your connection isn't being established.
|
||||
*/
|
||||
#ifdef DEBUGALL
|
||||
#define DEBUGMAIN 1
|
||||
#define DEBUGFSM 1
|
||||
#define DEBUGLCP 1
|
||||
#define DEBUGIPCP 1
|
||||
#define DEBUGIPV6CP 1
|
||||
#define DEBUGUPAP 1
|
||||
#define DEBUGCHAP 1
|
||||
#endif
|
||||
|
||||
#ifndef LOG_PPP /* we use LOG_LOCAL2 for syslog by default */
|
||||
#if defined(DEBUGMAIN) || defined(DEBUGFSM) || defined(DEBUGSYS) \
|
||||
|| defined(DEBUGLCP) || defined(DEBUGIPCP) || defined(DEBUGUPAP) \
|
||||
|| defined(DEBUGCHAP) || defined(DEBUG) || defined(DEBUGIPV6CP)
|
||||
#define LOG_PPP LOG_LOCAL2
|
||||
#else
|
||||
#define LOG_PPP LOG_DAEMON
|
||||
#endif
|
||||
#endif /* LOG_PPP */
|
||||
|
||||
#ifdef DEBUGMAIN
|
||||
#define MAINDEBUG(x) if (debug) dbglog x
|
||||
#else
|
||||
#define MAINDEBUG(x)
|
||||
#endif
|
||||
|
||||
#ifdef DEBUGSYS
|
||||
#define SYSDEBUG(x) if (debug) dbglog x
|
||||
#else
|
||||
#define SYSDEBUG(x)
|
||||
#endif
|
||||
|
||||
#ifdef DEBUGFSM
|
||||
#define FSMDEBUG(x) if (debug) dbglog x
|
||||
#else
|
||||
#define FSMDEBUG(x)
|
||||
#endif
|
||||
|
||||
#ifdef DEBUGLCP
|
||||
#define LCPDEBUG(x) if (debug) dbglog x
|
||||
#else
|
||||
#define LCPDEBUG(x)
|
||||
#endif
|
||||
|
||||
#ifdef DEBUGIPCP
|
||||
#define IPCPDEBUG(x) if (debug) dbglog x
|
||||
#else
|
||||
#define IPCPDEBUG(x)
|
||||
#endif
|
||||
|
||||
#ifdef DEBUGIPV6CP
|
||||
#define IPV6CPDEBUG(x) if (debug) dbglog x
|
||||
#else
|
||||
#define IPV6CPDEBUG(x)
|
||||
#endif
|
||||
|
||||
#ifdef DEBUGUPAP
|
||||
#define UPAPDEBUG(x) if (debug) dbglog x
|
||||
#else
|
||||
#define UPAPDEBUG(x)
|
||||
#endif
|
||||
|
||||
#ifdef DEBUGCHAP
|
||||
#define CHAPDEBUG(x) if (debug) dbglog x
|
||||
#else
|
||||
#define CHAPDEBUG(x)
|
||||
#endif
|
||||
|
||||
#ifdef DEBUGIPXCP
|
||||
#define IPXCPDEBUG(x) if (debug) dbglog x
|
||||
#else
|
||||
#define IPXCPDEBUG(x)
|
||||
#endif
|
||||
|
||||
#ifndef SIGTYPE
|
||||
#if defined(sun) || defined(SYSV) || defined(POSIX_SOURCE)
|
||||
#define SIGTYPE void
|
||||
#else
|
||||
#define SIGTYPE int
|
||||
#endif /* defined(sun) || defined(SYSV) || defined(POSIX_SOURCE) */
|
||||
#endif /* SIGTYPE */
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(a, b) ((a) < (b)? (a): (b))
|
||||
#endif
|
||||
#ifndef MAX
|
||||
#define MAX(a, b) ((a) > (b)? (a): (b))
|
||||
#endif
|
||||
|
||||
#ifndef offsetof
|
||||
#define offsetof(type, member) ((size_t) &((type *)0)->member)
|
||||
#endif
|
||||
|
||||
#endif /* __PPP_H__ */
|
||||
File diff suppressed because it is too large
Load diff
22
vpn-daemons/pptp/src/nm-ppp-status.h
Normal file
22
vpn-daemons/pptp/src/nm-ppp-status.h
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#ifndef NM_PPP_STATUS_H
|
||||
#define NM_PPP_STATUS_H
|
||||
|
||||
typedef enum {
|
||||
NM_PPP_STATUS_UNKNOWN,
|
||||
|
||||
NM_PPP_STATUS_DEAD,
|
||||
NM_PPP_STATUS_INITIALIZE,
|
||||
NM_PPP_STATUS_SERIALCONN,
|
||||
NM_PPP_STATUS_DORMANT,
|
||||
NM_PPP_STATUS_ESTABLISH,
|
||||
NM_PPP_STATUS_AUTHENTICATE,
|
||||
NM_PPP_STATUS_CALLBACK,
|
||||
NM_PPP_STATUS_NETWORK,
|
||||
NM_PPP_STATUS_RUNNING,
|
||||
NM_PPP_STATUS_TERMINATE,
|
||||
NM_PPP_STATUS_DISCONNECT,
|
||||
NM_PPP_STATUS_HOLDOFF,
|
||||
NM_PPP_STATUS_MASTER
|
||||
} NMPPPStatus;
|
||||
|
||||
#endif /* NM_PPP_STATUS_H */
|
||||
|
|
@ -1,507 +0,0 @@
|
|||
/* nm-pptp-service - pptp (and other pppd) integration with NetworkManager
|
||||
*
|
||||
* Antony J Mee <eemynotna at gmail dot com>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "pppd/pppd.h"
|
||||
|
||||
#include "pppd/fsm.h"
|
||||
#include "pppd/ipcp.h"
|
||||
#ifndef PPPD_VERSION
|
||||
#ifdef VERSION
|
||||
#define PPPD_VERSION VERSION
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <glib.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <regex.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <dbus/dbus.h>
|
||||
#include <dbus/dbus-glib-lowlevel.h>
|
||||
#include <dbus/dbus-glib.h>
|
||||
#include <NetworkManager.h>
|
||||
|
||||
#include "nm-ppp-starter.h"
|
||||
#include "nm-pppd-plugin.h"
|
||||
#include "nm-utils.h"
|
||||
|
||||
typedef struct NmPPPData
|
||||
{
|
||||
DBusConnection *con;
|
||||
gboolean got_auth_info;
|
||||
char *auth_type;
|
||||
char *username;
|
||||
char *password;
|
||||
int pppd_pid;
|
||||
} NmPPPData;
|
||||
|
||||
char pppd_version[] = PPPD_VERSION;
|
||||
|
||||
NmPPPData plugin_data;
|
||||
|
||||
int plugin_init();
|
||||
|
||||
void nm_ip_up(void *opaque, int arg);
|
||||
void nm_ip_down(void *opaque, int arg);
|
||||
void nm_exit_notify(void *opaque, int arg);
|
||||
|
||||
int nm_chap_passwd_hook(char *user, char *passwd);
|
||||
int nm_chap_check_hook(void);
|
||||
|
||||
void nm_notify_pid (NmPPPData *data);
|
||||
void send_config_error (DBusConnection *con, const char *item);
|
||||
gboolean nm_get_auth_items (NmPPPData *data);
|
||||
gboolean nm_store_auth_info (NmPPPData *data, char **auth_items, int num_auth_items);
|
||||
gboolean nm_dbus_prepare_connection(NmPPPData *data);
|
||||
void nm_dbus_kill_connection(NmPPPData *data);
|
||||
|
||||
gboolean nm_dbus_prepare_connection(NmPPPData *data)
|
||||
{
|
||||
// DBusMessage * message = NULL;
|
||||
DBusError error;
|
||||
// DBusObjectPathVTable vtable = { NULL,
|
||||
// &nm_dbus_message_handler,
|
||||
// NULL, NULL, NULL, NULL };
|
||||
|
||||
g_return_val_if_fail (data != NULL, FALSE);
|
||||
if (data->con != NULL) return TRUE;
|
||||
|
||||
|
||||
dbus_error_init (&error);
|
||||
data->con = dbus_bus_get (DBUS_BUS_SYSTEM, &error);
|
||||
if ((data->con == NULL) || dbus_error_is_set (&error))
|
||||
{
|
||||
info("Could not get the system bus. Make sure the message bus daemon is running?");
|
||||
goto out;
|
||||
}
|
||||
dbus_connection_set_exit_on_disconnect (data->con, FALSE);
|
||||
|
||||
// dbus_error_init (&error);
|
||||
// dbus_bus_request_name (data->con, NM_DBUS_SERVICE_PPP, 0, &error);
|
||||
// if (dbus_error_is_set (&error))
|
||||
// {
|
||||
// nm_warning ("Could not acquire the dbus service. dbus_bus_request_name() says: '%s'", error.message);
|
||||
// goto out;
|
||||
// }
|
||||
|
||||
// if (!dbus_connection_register_object_path (data->con, NM_DBUS_PATH_PPP, &vtable, data))
|
||||
// {
|
||||
// nm_warning ("Could not register a dbus handler for nm-ppp-service. Not enough memory?");
|
||||
// dbus_connection_unref(data->con);
|
||||
// data->con = NULL;
|
||||
// }
|
||||
out:
|
||||
if (dbus_error_is_set (&error))
|
||||
{
|
||||
dbus_error_free (&error);
|
||||
data->con = NULL;
|
||||
}
|
||||
if (data->con == NULL) return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void nm_dbus_kill_connection(NmPPPData *data)
|
||||
{
|
||||
g_return_if_fail (data != NULL);
|
||||
|
||||
if (data->con != NULL)
|
||||
dbus_connection_unref(data->con);
|
||||
if (data->username!=NULL) g_free(data->username);
|
||||
if (data->password!=NULL) g_free(data->password);
|
||||
}
|
||||
|
||||
int nm_chap_check_hook(void)
|
||||
{
|
||||
plugin_data.pppd_pid=getpid();
|
||||
nm_notify_pid (&plugin_data);
|
||||
|
||||
if (! nm_get_auth_items (&plugin_data))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (strcmp("CHAP",plugin_data.auth_type)!=0)
|
||||
{
|
||||
info("nm-pppd-plugin: No CHAP authentication available!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
info("nm-pppd-plugin: CHAP check hook.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
int nm_chap_passwd_hook(char *user, char *passwd)
|
||||
{
|
||||
info("nm-pppd-plugin: CHAP credentials requested.");
|
||||
|
||||
if (user == NULL)
|
||||
{
|
||||
info("nm-pppd-plugin: pppd didn't provide username buffer");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (passwd == NULL)
|
||||
{
|
||||
info("nm-pppd-plugin: pppd didn't provide password buffer");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (plugin_data.username == NULL)
|
||||
{
|
||||
info("nm-pppd-plugin: CHAP username not set");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (plugin_data.password == NULL)
|
||||
{
|
||||
info("nm-pppd-plugin: CHAP password not set");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (strlen(plugin_data.username) >= MAXNAMELEN)
|
||||
{
|
||||
info("nm-pppd-plugin: CHAP username too long!");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (strlen(plugin_data.password) >= MAXSECRETLEN)
|
||||
{
|
||||
info("nm-pppd-plugin: CHAP password too long!");
|
||||
return -1;
|
||||
}
|
||||
|
||||
strcpy(user, plugin_data.username);
|
||||
user[MAXNAMELEN-1]='\0';
|
||||
strcpy(passwd, plugin_data.password);
|
||||
passwd[MAXSECRETLEN-1]='\0';
|
||||
// info("nm-pppd-plugin: CHAP authenticating as '%s' with '%s'",user,passwd);
|
||||
//
|
||||
// Forget the username and password?
|
||||
//
|
||||
// if (plugin_data.username!=NULL) g_free(plugin_data.username);
|
||||
// if (plugin_data.password!=NULL) g_free(plugin_data.password);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void nm_exit_notify(void *opaque, int arg)
|
||||
{
|
||||
NmPPPData *data = (NmPPPData *)opaque;
|
||||
|
||||
nm_dbus_kill_connection(data);
|
||||
}
|
||||
|
||||
void nm_ip_down(void *opaque, int arg)
|
||||
{
|
||||
// DBusConnection *con = (DBusConnection *)opaque;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void nm_ip_up(void *opaque, int arg)
|
||||
{
|
||||
NmPPPData *data = (NmPPPData *)opaque;
|
||||
DBusConnection *con = data->con;
|
||||
DBusMessage *message;
|
||||
|
||||
char * str_ifname = NULL;
|
||||
// guint32 * uint_ip4_dns = NULL;
|
||||
guint32 uint_ip4_dns1 = 0;
|
||||
guint32 uint_ip4_dns2 = 0;
|
||||
guint32 uint_ip4_dns_len = 0;
|
||||
// guint32 * uint_ip4_wins = NULL;
|
||||
guint32 uint_ip4_wins1 = 0;
|
||||
guint32 uint_ip4_wins2 = 0;
|
||||
guint32 uint_ip4_wins_len = 0;
|
||||
guint32 uint_ip4_address = 0;
|
||||
guint32 uint_ip4_ptp_address = 0;
|
||||
guint32 uint_ip4_netmask = 0xFFFFFFFF; /* Default mask of 255.255.255.255 */
|
||||
// guint32 i=0;
|
||||
|
||||
|
||||
g_return_if_fail (con != NULL);
|
||||
if (ipcp_gotoptions[ifunit].ouraddr==0) {
|
||||
info ("nm-pppd-plugin: didn't receive an Internal IP4 Address from ppp.");
|
||||
send_config_error (con, "IP4 Address");
|
||||
return;
|
||||
}
|
||||
uint_ip4_address=ipcp_gotoptions[ifunit].ouraddr;
|
||||
|
||||
if (!(message = dbus_message_new_method_call (NM_DBUS_SERVICE_PPP_STARTER, NM_DBUS_PATH_PPP_STARTER, NM_DBUS_INTERFACE_PPP_STARTER, "signalIP4Config")))
|
||||
{
|
||||
nm_warning ("send_config_error(): Couldn't allocate the dbus message");
|
||||
return;
|
||||
}
|
||||
|
||||
if (ipcp_gotoptions[ifunit].dnsaddr) {
|
||||
if (ipcp_gotoptions[ifunit].dnsaddr[0]!=0) {
|
||||
uint_ip4_dns_len++;
|
||||
uint_ip4_dns1=ipcp_gotoptions[ifunit].dnsaddr[0];
|
||||
if (ipcp_gotoptions[ifunit].dnsaddr[1]!=0) {
|
||||
uint_ip4_dns_len++;
|
||||
uint_ip4_dns2=ipcp_gotoptions[ifunit].dnsaddr[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ipcp_gotoptions[ifunit].winsaddr) {
|
||||
if (ipcp_gotoptions[ifunit].winsaddr[0]!=0) {
|
||||
uint_ip4_wins_len++;
|
||||
uint_ip4_wins1=ipcp_gotoptions[ifunit].winsaddr[0];
|
||||
if (ipcp_gotoptions[ifunit].winsaddr[1]!=0) {
|
||||
uint_ip4_wins_len++;
|
||||
uint_ip4_wins2=ipcp_gotoptions[ifunit].winsaddr[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ifname==NULL) {
|
||||
info ("nm-pppd-plugin: didn't receive a tunnel device name.");
|
||||
send_config_error (con, "IP4 Address");
|
||||
}
|
||||
str_ifname = g_strdup(ifname);
|
||||
|
||||
dbus_message_append_args (message,
|
||||
DBUS_TYPE_STRING, &str_ifname,
|
||||
DBUS_TYPE_UINT32, &uint_ip4_address,
|
||||
DBUS_TYPE_UINT32, &uint_ip4_ptp_address,
|
||||
DBUS_TYPE_UINT32, &uint_ip4_netmask,
|
||||
// Array workaround
|
||||
DBUS_TYPE_UINT32, &uint_ip4_dns1,
|
||||
DBUS_TYPE_UINT32, &uint_ip4_dns2,
|
||||
DBUS_TYPE_UINT32, &uint_ip4_dns_len,
|
||||
DBUS_TYPE_UINT32, &uint_ip4_wins1,
|
||||
DBUS_TYPE_UINT32, &uint_ip4_wins2,
|
||||
DBUS_TYPE_UINT32, &uint_ip4_wins_len,
|
||||
DBUS_TYPE_INVALID);
|
||||
|
||||
if (!dbus_connection_send (con, message, NULL)) {
|
||||
info ("nm_ip_up(): could not send dbus message");
|
||||
dbus_message_unref (message);
|
||||
g_free(str_ifname);
|
||||
return;
|
||||
}
|
||||
|
||||
g_free(str_ifname);
|
||||
dbus_message_unref (message);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* send_config_error
|
||||
*
|
||||
* Notify nm-ppp-starter of a config error from pppd.
|
||||
*
|
||||
*/
|
||||
void send_config_error (DBusConnection *con, const char *item)
|
||||
{
|
||||
DBusMessage *message;
|
||||
|
||||
g_return_if_fail (con != NULL);
|
||||
g_return_if_fail (item != NULL);
|
||||
|
||||
if (!(message = dbus_message_new_method_call (NM_DBUS_SERVICE_PPP_STARTER, NM_DBUS_PATH_PPP_STARTER, NM_DBUS_INTERFACE_PPP_STARTER, "signalConfigError")))
|
||||
{
|
||||
nm_warning ("send_config_error(): Couldn't allocate the dbus message");
|
||||
return;
|
||||
}
|
||||
|
||||
dbus_message_append_args (message, DBUS_TYPE_STRING, &item, DBUS_TYPE_INVALID);
|
||||
if (!dbus_connection_send (con, message, NULL))
|
||||
nm_warning ("send_config_error(): could not send dbus message");
|
||||
|
||||
dbus_message_unref (message);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* nm_notify_pid
|
||||
*
|
||||
* Let the pppd starter service know our PID
|
||||
* so that pppd may be killed later.
|
||||
*
|
||||
*/
|
||||
void nm_notify_pid (NmPPPData *data)
|
||||
{
|
||||
DBusConnection *con;
|
||||
DBusMessage *message = NULL;
|
||||
|
||||
if (!nm_dbus_prepare_connection(data))
|
||||
return;
|
||||
|
||||
con = data->con;
|
||||
if (!(message = dbus_message_new_method_call (NM_DBUS_SERVICE_PPP_STARTER, NM_DBUS_PATH_PPP_STARTER, NM_DBUS_INTERFACE_PPP_STARTER, "notifyPID")))
|
||||
{
|
||||
nm_warning ("nm-pppd-plugin: Couldn't allocate the notifyPID dbus message");
|
||||
return;
|
||||
}
|
||||
|
||||
dbus_message_append_args (message,
|
||||
DBUS_TYPE_UINT32, &(data->pppd_pid),
|
||||
DBUS_TYPE_INVALID);
|
||||
|
||||
if (!dbus_connection_send (con, message, NULL)) {
|
||||
info ("nm_ip_up(): could not send dbus message");
|
||||
dbus_message_unref (message);
|
||||
return;
|
||||
}
|
||||
|
||||
// nm_warning("Sent notify message: %d",data->pppd_pid);
|
||||
dbus_message_unref (message);
|
||||
}
|
||||
/*
|
||||
* nm_get_auth_items
|
||||
*
|
||||
* Request credentials from PPP_STARTER service.
|
||||
*
|
||||
*/
|
||||
gboolean nm_get_auth_items (NmPPPData *data)
|
||||
{
|
||||
DBusConnection *con;
|
||||
int num_auth_items = -1;
|
||||
char *auth_items[3] = { NULL, NULL, NULL };
|
||||
// char **auth_items = NULL;
|
||||
DBusMessage *message = NULL;
|
||||
DBusMessage *reply = NULL;
|
||||
|
||||
if (!nm_dbus_prepare_connection(data))
|
||||
return FALSE;
|
||||
|
||||
con = data->con;
|
||||
|
||||
g_return_val_if_fail (con != NULL,FALSE);
|
||||
if (!(message = dbus_message_new_method_call (NM_DBUS_SERVICE_PPP_STARTER, NM_DBUS_PATH_PPP_STARTER, NM_DBUS_INTERFACE_PPP_STARTER, "getAuthInfo")))
|
||||
{
|
||||
nm_warning("nm-pppd-plugin: failed to create getAuthInfo message.");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
reply = dbus_connection_send_with_reply_and_block (con, message, -1, NULL);
|
||||
dbus_message_unref (message);
|
||||
if (!reply)
|
||||
{
|
||||
info("nm-pppd-plugin: no reply to getAuthInfo message.");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!(dbus_message_get_args (reply, NULL,
|
||||
DBUS_TYPE_STRING, &(auth_items[0]),
|
||||
DBUS_TYPE_STRING, &(auth_items[1]),
|
||||
DBUS_TYPE_STRING, &(auth_items[2]),
|
||||
// DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, &auth_items, &num_auth_items,
|
||||
DBUS_TYPE_INVALID)))
|
||||
{
|
||||
dbus_message_unref (reply);
|
||||
return FALSE;
|
||||
}
|
||||
num_auth_items=3;
|
||||
|
||||
if (!nm_store_auth_info (data, auth_items, num_auth_items))
|
||||
{
|
||||
//dbus_free_string_array (auth_items);
|
||||
dbus_message_unref (reply);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//dbus_free_string_array (auth_items);
|
||||
dbus_message_unref (reply);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* nm_store_auth_info
|
||||
*
|
||||
* Decode and temporarily store the authentication info provided.
|
||||
*
|
||||
*/
|
||||
gboolean nm_store_auth_info (NmPPPData *data, char **auth_items, int num_auth_items)
|
||||
{
|
||||
// int i=0;
|
||||
g_return_val_if_fail (auth_items != NULL, FALSE);
|
||||
g_return_val_if_fail (num_auth_items >= 1, FALSE);
|
||||
|
||||
nm_warning ("PPPD will authenticate using '%s'.", auth_items[0]);
|
||||
|
||||
if (strcmp ("CHAP", auth_items[0]) == 0) {
|
||||
g_return_val_if_fail (num_auth_items >= 3, FALSE);
|
||||
if (data->auth_type!=NULL) g_free(data->auth_type);
|
||||
if (data->username!=NULL) g_free(data->username);
|
||||
if (data->password!=NULL) g_free(data->password);
|
||||
data->auth_type=g_strdup(auth_items[0]);
|
||||
data->username=g_strdup(auth_items[1]);
|
||||
data->password=g_strdup(auth_items[2]);
|
||||
} else if (strcmp ("NONE", auth_items[0]) == 0) {
|
||||
if (data->auth_type!=NULL) g_free(data->auth_type);
|
||||
if (data->username!=NULL) g_free(data->username);
|
||||
if (data->password!=NULL) g_free(data->password);
|
||||
data->auth_type=g_strdup(auth_items[0]);
|
||||
} else {
|
||||
nm_warning ("PPPD authentication type '%s' is not allowed.", auth_items[0]);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
data->got_auth_info=TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int plugin_init()
|
||||
{
|
||||
// DBusConnection * con = NULL;
|
||||
// DBusMessage * message = NULL;
|
||||
// DBusError error;
|
||||
|
||||
// g_type_init ();
|
||||
// if (!g_thread_supported ())
|
||||
// g_thread_init (NULL);
|
||||
|
||||
// dbus_error_init (&error);
|
||||
// con = dbus_bus_get (DBUS_BUS_SYSTEM, &error);
|
||||
// if ((con == NULL) || dbus_error_is_set (&error))
|
||||
// {
|
||||
// dbus_error_free (&error);
|
||||
// info("Could not get the system bus. Make sure the message bus daemon is running?");
|
||||
// return -1;
|
||||
// }
|
||||
// dbus_connection_set_exit_on_disconnect (con, FALSE);
|
||||
//
|
||||
//
|
||||
// dbus_error_free (&error);
|
||||
|
||||
// add_options(ppp_options);
|
||||
|
||||
chap_check_hook = nm_chap_check_hook;
|
||||
chap_passwd_hook = nm_chap_passwd_hook;
|
||||
|
||||
add_notifier(&ip_down_notifier, nm_ip_down, (void *) &plugin_data);
|
||||
add_notifier(&ip_up_notifier, nm_ip_up, (void *) &plugin_data);
|
||||
add_notifier(&exitnotify, nm_exit_notify, (void *) &plugin_data);
|
||||
|
||||
info("nm-pppd-plugin: plugin initialized.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
324
vpn-daemons/pptp/src/nm-pptp-pppd-plugin.c
Normal file
324
vpn-daemons/pptp/src/nm-pptp-pppd-plugin.c
Normal file
|
|
@ -0,0 +1,324 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
||||
/* nm-pptp-service - pptp (and other pppd) integration with NetworkManager
|
||||
*
|
||||
* (C) 2007 - 2008 Novell, Inc.
|
||||
* (C) 2008 Red Hat, Inc.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <pppd/pppd.h>
|
||||
#include <pppd/fsm.h>
|
||||
#include <pppd/ipcp.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <glib/gtypes.h>
|
||||
#include <glib-object.h>
|
||||
#include <dbus/dbus-glib.h>
|
||||
|
||||
#include "nm-pptp-service.h"
|
||||
#include "nm-ppp-status.h"
|
||||
|
||||
#include <nm-utils.h>
|
||||
|
||||
int plugin_init (void);
|
||||
|
||||
char pppd_version[] = VERSION;
|
||||
|
||||
static DBusGProxy *proxy = NULL;
|
||||
|
||||
static void
|
||||
nm_phasechange (void *data, int arg)
|
||||
{
|
||||
NMPPPStatus ppp_status = NM_PPP_STATUS_UNKNOWN;
|
||||
char *ppp_phase;
|
||||
|
||||
g_return_if_fail (DBUS_IS_G_PROXY (proxy));
|
||||
|
||||
switch (arg) {
|
||||
case PHASE_DEAD:
|
||||
ppp_status = NM_PPP_STATUS_DEAD;
|
||||
ppp_phase = "dead";
|
||||
break;
|
||||
case PHASE_INITIALIZE:
|
||||
ppp_status = NM_PPP_STATUS_INITIALIZE;
|
||||
ppp_phase = "initialize";
|
||||
break;
|
||||
case PHASE_SERIALCONN:
|
||||
ppp_status = NM_PPP_STATUS_SERIALCONN;
|
||||
ppp_phase = "serial connection";
|
||||
break;
|
||||
case PHASE_DORMANT:
|
||||
ppp_status = NM_PPP_STATUS_DORMANT;
|
||||
ppp_phase = "dormant";
|
||||
break;
|
||||
case PHASE_ESTABLISH:
|
||||
ppp_status = NM_PPP_STATUS_ESTABLISH;
|
||||
ppp_phase = "establish";
|
||||
break;
|
||||
case PHASE_AUTHENTICATE:
|
||||
ppp_status = NM_PPP_STATUS_AUTHENTICATE;
|
||||
ppp_phase = "authenticate";
|
||||
break;
|
||||
case PHASE_CALLBACK:
|
||||
ppp_status = NM_PPP_STATUS_CALLBACK;
|
||||
ppp_phase = "callback";
|
||||
break;
|
||||
case PHASE_NETWORK:
|
||||
ppp_status = NM_PPP_STATUS_NETWORK;
|
||||
ppp_phase = "network";
|
||||
break;
|
||||
case PHASE_RUNNING:
|
||||
ppp_status = NM_PPP_STATUS_RUNNING;
|
||||
ppp_phase = "running";
|
||||
break;
|
||||
case PHASE_TERMINATE:
|
||||
ppp_status = NM_PPP_STATUS_TERMINATE;
|
||||
ppp_phase = "terminate";
|
||||
break;
|
||||
case PHASE_DISCONNECT:
|
||||
ppp_status = NM_PPP_STATUS_DISCONNECT;
|
||||
ppp_phase = "disconnect";
|
||||
break;
|
||||
case PHASE_HOLDOFF:
|
||||
ppp_status = NM_PPP_STATUS_HOLDOFF;
|
||||
ppp_phase = "holdoff";
|
||||
break;
|
||||
case PHASE_MASTER:
|
||||
ppp_status = NM_PPP_STATUS_MASTER;
|
||||
ppp_phase = "master";
|
||||
break;
|
||||
|
||||
default:
|
||||
ppp_phase = "unknown";
|
||||
break;
|
||||
}
|
||||
|
||||
if (ppp_status != NM_PPP_STATUS_UNKNOWN) {
|
||||
dbus_g_proxy_call_no_reply (proxy, "SetState",
|
||||
G_TYPE_UINT, ppp_status,
|
||||
G_TYPE_INVALID,
|
||||
G_TYPE_INVALID);
|
||||
}
|
||||
}
|
||||
|
||||
static GValue *
|
||||
str_to_gvalue (const char *str)
|
||||
{
|
||||
GValue *val;
|
||||
|
||||
val = g_slice_new0 (GValue);
|
||||
g_value_init (val, G_TYPE_STRING);
|
||||
g_value_set_string (val, str);
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
static GValue *
|
||||
uint_to_gvalue (guint32 i)
|
||||
{
|
||||
GValue *val;
|
||||
|
||||
val = g_slice_new0 (GValue);
|
||||
g_value_init (val, G_TYPE_UINT);
|
||||
g_value_set_uint (val, i);
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
static void
|
||||
value_destroy (gpointer data)
|
||||
{
|
||||
GValue *val = (GValue *) data;
|
||||
|
||||
g_value_unset (val);
|
||||
g_slice_free (GValue, val);
|
||||
}
|
||||
|
||||
static void
|
||||
nm_ip_up (void *data, int arg)
|
||||
{
|
||||
ipcp_options opts = ipcp_gotoptions[ifunit];
|
||||
ipcp_options peer_opts = ipcp_hisoptions[ifunit];
|
||||
GHashTable *hash;
|
||||
GArray *array;
|
||||
GValue *val;
|
||||
|
||||
g_return_if_fail (DBUS_IS_G_PROXY (proxy));
|
||||
|
||||
if (!opts.ouraddr) {
|
||||
g_warning ("Didn't receive an internal IP from pppd");
|
||||
return;
|
||||
}
|
||||
|
||||
hash = g_hash_table_new_full (g_str_hash, g_str_equal,
|
||||
NULL, value_destroy);
|
||||
|
||||
g_hash_table_insert (hash, NM_VPN_PLUGIN_IP4_CONFIG_TUNDEV,
|
||||
str_to_gvalue (ifname));
|
||||
|
||||
g_hash_table_insert (hash, NM_VPN_PLUGIN_IP4_CONFIG_ADDRESS,
|
||||
uint_to_gvalue (opts.ouraddr));
|
||||
|
||||
g_hash_table_insert (hash, NM_VPN_PLUGIN_IP4_CONFIG_PREFIX, uint_to_gvalue (32));
|
||||
|
||||
if (opts.dnsaddr[0] || opts.dnsaddr[1]) {
|
||||
array = g_array_new (FALSE, FALSE, sizeof (guint32));
|
||||
|
||||
if (opts.dnsaddr[0])
|
||||
g_array_append_val (array, opts.dnsaddr[0]);
|
||||
if (opts.dnsaddr[1])
|
||||
g_array_append_val (array, opts.dnsaddr[1]);
|
||||
|
||||
val = g_slice_new0 (GValue);
|
||||
g_value_init (val, DBUS_TYPE_G_UINT_ARRAY);
|
||||
g_value_set_boxed (val, array);
|
||||
|
||||
g_hash_table_insert (hash, NM_VPN_PLUGIN_IP4_CONFIG_DNS, val);
|
||||
}
|
||||
|
||||
/*
|
||||
if (opts.winsaddr[0] || opts.winsaddr[1]) {
|
||||
array = g_array_new (FALSE, FALSE, sizeof (guint32));
|
||||
|
||||
if (opts.winsaddr[0])
|
||||
g_array_append_val (array, opts.winsaddr[0]);
|
||||
if (opts.winsaddr[1])
|
||||
g_array_append_val (array, opts.winsaddr[1]);
|
||||
|
||||
val = g_slice_new0 (GValue);
|
||||
g_value_init (val, DBUS_TYPE_G_UINT_ARRAY);
|
||||
g_value_set_boxed (val, array);
|
||||
|
||||
g_hash_table_insert (hash, NM_VPN_PLUGIN_IP4_CONFIG_WINS, val);
|
||||
}
|
||||
*/
|
||||
|
||||
dbus_g_proxy_call_no_reply (proxy, "SetIp4Config",
|
||||
DBUS_TYPE_G_MAP_OF_VARIANT, hash, G_TYPE_INVALID,
|
||||
G_TYPE_INVALID);
|
||||
|
||||
g_hash_table_destroy (hash);
|
||||
}
|
||||
|
||||
static int
|
||||
get_chap_check()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
get_pap_check()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
get_credentials (char *username, char *password)
|
||||
{
|
||||
char *my_username;
|
||||
char *my_password;
|
||||
size_t len;
|
||||
GError *err = NULL;
|
||||
|
||||
if (username && !password) {
|
||||
/* pppd is checking pap support; return 1 for supported */
|
||||
return 1;
|
||||
}
|
||||
|
||||
g_return_val_if_fail (DBUS_IS_G_PROXY (proxy), -1);
|
||||
|
||||
my_username = my_password = NULL;
|
||||
dbus_g_proxy_call (proxy, "NeedSecrets", &err,
|
||||
G_TYPE_INVALID,
|
||||
G_TYPE_STRING, &my_username,
|
||||
G_TYPE_STRING, &my_password,
|
||||
G_TYPE_INVALID);
|
||||
|
||||
if (err) {
|
||||
g_warning ("Could not get secrets: %s", err->message);
|
||||
g_error_free (err);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (my_username) {
|
||||
len = strlen (my_username) + 1;
|
||||
len = len < MAXNAMELEN ? len : MAXNAMELEN;
|
||||
|
||||
strncpy (username, my_username, len);
|
||||
username[len - 1] = '\0';
|
||||
|
||||
g_free (my_username);
|
||||
}
|
||||
|
||||
if (my_password) {
|
||||
len = strlen (my_password) + 1;
|
||||
len = len < MAXSECRETLEN ? len : MAXSECRETLEN;
|
||||
|
||||
strncpy (password, my_password, len);
|
||||
password[len - 1] = '\0';
|
||||
|
||||
g_free (my_password);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
nm_exit_notify (void *data, int arg)
|
||||
{
|
||||
g_return_if_fail (DBUS_IS_G_PROXY (proxy));
|
||||
|
||||
g_object_unref (proxy);
|
||||
proxy = NULL;
|
||||
}
|
||||
|
||||
int
|
||||
plugin_init (void)
|
||||
{
|
||||
DBusGConnection *bus;
|
||||
GError *err = NULL;
|
||||
|
||||
g_type_init ();
|
||||
|
||||
bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &err);
|
||||
if (!bus) {
|
||||
g_warning ("Couldn't connect to system bus: %s", err->message);
|
||||
g_error_free (err);
|
||||
return -1;
|
||||
}
|
||||
|
||||
proxy = dbus_g_proxy_new_for_name (bus,
|
||||
NM_DBUS_SERVICE_PPTP_PPP,
|
||||
NM_DBUS_PATH_PPTP_PPP,
|
||||
NM_DBUS_INTERFACE_PPTP_PPP);
|
||||
|
||||
dbus_g_connection_unref (bus);
|
||||
|
||||
chap_passwd_hook = get_credentials;
|
||||
chap_check_hook = get_chap_check;
|
||||
pap_passwd_hook = get_credentials;
|
||||
pap_check_hook = get_pap_check;
|
||||
|
||||
add_notifier (&phasechange, nm_phasechange, NULL);
|
||||
add_notifier (&ip_up_notifier, nm_ip_up, NULL);
|
||||
add_notifier (&exitnotify, nm_exit_notify, proxy);
|
||||
|
||||
return 0;
|
||||
}
|
||||
21
vpn-daemons/pptp/src/nm-pptp-pppd-service.xml
Normal file
21
vpn-daemons/pptp/src/nm-pptp-pppd-service.xml
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<node name="/">
|
||||
<interface name="org.freedesktop.NetworkManager.pptp.ppp">
|
||||
<method name="NeedSecrets">
|
||||
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_pptp_service_need_secrets"/>
|
||||
<arg name="username" type="s" direction="out"/>
|
||||
<arg name="password" type="s" direction="out"/>
|
||||
</method>
|
||||
|
||||
<method name="SetIp4Config">
|
||||
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_pptp_service_set_ip4_config"/>
|
||||
<arg name="config" type="a{sv}" direction="in"/>
|
||||
</method>
|
||||
|
||||
<method name="SetState">
|
||||
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_pptp_service_set_state"/>
|
||||
<arg name="state" type="u" direction="in"/>
|
||||
</method>
|
||||
</interface>
|
||||
</node>
|
||||
1031
vpn-daemons/pptp/src/nm-pptp-service.c
Normal file
1031
vpn-daemons/pptp/src/nm-pptp-service.c
Normal file
File diff suppressed because it is too large
Load diff
82
vpn-daemons/pptp/src/nm-pptp-service.h
Normal file
82
vpn-daemons/pptp/src/nm-pptp-service.h
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
||||
/* nm-pptp-service - PPTP VPN integration with NetworkManager
|
||||
*
|
||||
* Dan Williams <dcbw@redhat.com>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* (C) Copyright 2008 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#ifndef NM_PPTP_PLUGIN_H
|
||||
#define NM_PPTP_PLUGIN_H
|
||||
|
||||
#include <glib/gtypes.h>
|
||||
#include <glib-object.h>
|
||||
#include <nm-vpn-plugin.h>
|
||||
|
||||
#define NM_TYPE_PPTP_PLUGIN (nm_pptp_plugin_get_type ())
|
||||
#define NM_PPTP_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_PPTP_PLUGIN, NMPptpPlugin))
|
||||
#define NM_PPTP_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_PPTP_PLUGIN, NMPptpPluginClass))
|
||||
#define NM_IS_PPTP_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_PPTP_PLUGIN))
|
||||
#define NM_IS_PPTP_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_PPTP_PLUGIN))
|
||||
#define NM_PPTP_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_PPTP_PLUGIN, NMPptpPluginClass))
|
||||
|
||||
/* For the pppd plugin <-> VPN plugin service */
|
||||
#define DBUS_TYPE_G_MAP_OF_VARIANT (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE))
|
||||
|
||||
#define NM_DBUS_SERVICE_PPTP_PPP "org.freedesktop.NetworkManager.pptp-ppp"
|
||||
#define NM_DBUS_PATH_PPTP_PPP "/org/freedesktop/NetworkManager/pptp/ppp"
|
||||
#define NM_DBUS_INTERFACE_PPTP_PPP "org.freedesktop.NetworkManager.pptp.ppp"
|
||||
|
||||
|
||||
/* For the NM <-> VPN plugin service */
|
||||
#define NM_DBUS_SERVICE_PPTP "org.freedesktop.NetworkManager.pptp"
|
||||
#define NM_DBUS_INTERFACE_PPTP "org.freedesktop.NetworkManager.pptp"
|
||||
#define NM_DBUS_PATH_PPTP "/org/freedesktop/NetworkManager/pptp"
|
||||
|
||||
#define NM_PPTP_KEY_GATEWAY "gateway"
|
||||
#define NM_PPTP_KEY_USER "user"
|
||||
#define NM_PPTP_KEY_PASSWORD "password"
|
||||
#define NM_PPTP_KEY_DOMAIN "domain"
|
||||
#define NM_PPTP_KEY_REFUSE_EAP "refuse-eap"
|
||||
#define NM_PPTP_KEY_REFUSE_PAP "refuse-pap"
|
||||
#define NM_PPTP_KEY_REFUSE_CHAP "refuse-chap"
|
||||
#define NM_PPTP_KEY_REFUSE_MSCHAP "refuse-mschap"
|
||||
#define NM_PPTP_KEY_REFUSE_MSCHAPV2 "refuse-mschapv2"
|
||||
#define NM_PPTP_KEY_REQUIRE_MPPE "require-mppe"
|
||||
#define NM_PPTP_KEY_REQUIRE_MPPE_40 "require-mppe-40"
|
||||
#define NM_PPTP_KEY_REQUIRE_MPPE_128 "require-mppe-128"
|
||||
#define NM_PPTP_KEY_MPPE_STATEFUL "mppe-stateful"
|
||||
#define NM_PPTP_KEY_NOBSDCOMP "nobsdcomp"
|
||||
#define NM_PPTP_KEY_NODEFLATE "nodeflate"
|
||||
#define NM_PPTP_KEY_NO_VJ_COMP "no-vj-comp"
|
||||
#define NM_PPTP_KEY_LCP_ECHO_FAILURE "lcp-echo-failure"
|
||||
#define NM_PPTP_KEY_LCP_ECHO_INTERVAL "lcp-echo-interval"
|
||||
|
||||
|
||||
typedef struct {
|
||||
NMVPNPlugin parent;
|
||||
} NMPptpPlugin;
|
||||
|
||||
typedef struct {
|
||||
NMVPNPluginClass parent;
|
||||
} NMPptpPluginClass;
|
||||
|
||||
GType nm_pptp_plugin_get_type (void);
|
||||
|
||||
NMPptpPlugin *nm_pptp_plugin_new (void);
|
||||
|
||||
#endif /* NM_PPTP_PLUGIN_H */
|
||||
|
|
@ -1,606 +0,0 @@
|
|||
/* NetworkManager -- Network link manager
|
||||
*
|
||||
* Ray Strode <rstrode@redhat.com>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* (C) Copyright 2005 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <glib.h>
|
||||
#include <dbus/dbus.h>
|
||||
#include "nm-utils.h"
|
||||
|
||||
gchar *nm_dbus_escape_object_path (const gchar *utf8_string)
|
||||
{
|
||||
const gchar *p;
|
||||
gchar *object_path;
|
||||
GString *string;
|
||||
|
||||
g_return_val_if_fail (utf8_string != NULL, NULL);
|
||||
g_return_val_if_fail (g_utf8_validate (utf8_string, -1, NULL), NULL);
|
||||
|
||||
string = g_string_sized_new ((strlen (utf8_string) + 1) * 6);
|
||||
|
||||
for (p = utf8_string; *p != '\0'; p = g_utf8_next_char (p))
|
||||
{
|
||||
gunichar character;
|
||||
|
||||
character = g_utf8_get_char (p);
|
||||
|
||||
if (((character >= ((gunichar) 'a')) &&
|
||||
(character <= ((gunichar) 'z'))) ||
|
||||
((character >= ((gunichar) 'A')) &&
|
||||
(character <= ((gunichar) 'Z'))) ||
|
||||
((character >= ((gunichar) '0')) &&
|
||||
(character <= ((gunichar) '9'))) ||
|
||||
(character == ((gunichar) '/')))
|
||||
{
|
||||
g_string_append_c (string, (gchar) character);
|
||||
continue;
|
||||
}
|
||||
|
||||
g_string_append_printf (string, "_%x_", character);
|
||||
}
|
||||
|
||||
object_path = string->str;
|
||||
|
||||
g_string_free (string, FALSE);
|
||||
|
||||
return object_path;
|
||||
}
|
||||
|
||||
gchar *nm_dbus_unescape_object_path (const gchar *object_path)
|
||||
{
|
||||
const gchar *p;
|
||||
gchar *utf8_string;
|
||||
GString *string;
|
||||
|
||||
g_return_val_if_fail (object_path != NULL, NULL);
|
||||
|
||||
string = g_string_sized_new (strlen (object_path) + 1);
|
||||
|
||||
for (p = object_path; *p != '\0'; p++)
|
||||
{
|
||||
const gchar *q;
|
||||
gchar *hex_digits, *end, utf8_character[6] = { '\0' };
|
||||
gint utf8_character_size;
|
||||
gunichar character;
|
||||
gulong hex_value;
|
||||
|
||||
if (*p != '_')
|
||||
{
|
||||
g_string_append_c (string, *p);
|
||||
continue;
|
||||
}
|
||||
|
||||
q = strchr (p + 1, '_');
|
||||
|
||||
if ((q == NULL) || (q == p + 1))
|
||||
{
|
||||
g_string_free (string, TRUE);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
hex_digits = g_strndup (p + 1, (q - 1) - p);
|
||||
|
||||
hex_value = strtoul (hex_digits, &end, 16);
|
||||
|
||||
character = (gunichar) hex_value;
|
||||
|
||||
if (((hex_value == G_MAXLONG) && (errno == ERANGE)) ||
|
||||
(hex_value > G_MAXUINT32) ||
|
||||
(*end != '\0') ||
|
||||
(!g_unichar_validate (character)))
|
||||
{
|
||||
g_free (hex_digits);
|
||||
g_string_free (string, TRUE);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
utf8_character_size =
|
||||
g_unichar_to_utf8 (character, utf8_character);
|
||||
|
||||
g_assert (utf8_character_size > 0);
|
||||
|
||||
g_string_append_len (string, utf8_character,
|
||||
utf8_character_size);
|
||||
|
||||
p = q;
|
||||
}
|
||||
|
||||
utf8_string = string->str;
|
||||
|
||||
g_string_free (string, FALSE);
|
||||
|
||||
return utf8_string;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Start a dict in a dbus message. Should be paired with a call to
|
||||
* {@link nmu_dbus_dict_close_write}.
|
||||
*
|
||||
* @param iter A valid dbus message iterator
|
||||
* @param iter_dict (out) A dict iterator to pass to further dict functions
|
||||
* @return TRUE on success, FALSE on failure
|
||||
*
|
||||
*/
|
||||
dbus_bool_t
|
||||
nmu_dbus_dict_open_write (DBusMessageIter *iter, DBusMessageIter *iter_dict)
|
||||
{
|
||||
if (!iter || !iter_dict)
|
||||
return FALSE;
|
||||
|
||||
return dbus_message_iter_open_container (iter,
|
||||
DBUS_TYPE_ARRAY,
|
||||
DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
|
||||
DBUS_TYPE_STRING_AS_STRING
|
||||
DBUS_TYPE_VARIANT_AS_STRING
|
||||
DBUS_DICT_ENTRY_END_CHAR_AS_STRING,
|
||||
iter_dict);
|
||||
}
|
||||
|
||||
/**
|
||||
* End a dict element in a dbus message. Should be paired with
|
||||
* a call to {@link nmu_dbus_dict_open_write}.
|
||||
*
|
||||
* @param iter valid dbus message iterator, same as passed to
|
||||
* nmu_dbus_dict_open_write()
|
||||
* @param iter_dict a dbus dict iterator returned from {@link nmu_dbus_dict_open_write}
|
||||
* @return TRUE on success, FALSE on failure
|
||||
*
|
||||
*/
|
||||
dbus_bool_t
|
||||
nmu_dbus_dict_close_write (DBusMessageIter *iter, DBusMessageIter *iter_dict)
|
||||
{
|
||||
if (!iter || !iter_dict)
|
||||
return FALSE;
|
||||
|
||||
return dbus_message_iter_close_container (iter, iter_dict);
|
||||
}
|
||||
|
||||
|
||||
static const char *
|
||||
_nmu_get_type_as_string_from_type (const int type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case DBUS_TYPE_BYTE:
|
||||
return DBUS_TYPE_BYTE_AS_STRING;
|
||||
case DBUS_TYPE_BOOLEAN:
|
||||
return DBUS_TYPE_BOOLEAN_AS_STRING;
|
||||
case DBUS_TYPE_INT16:
|
||||
return DBUS_TYPE_INT16_AS_STRING;
|
||||
case DBUS_TYPE_UINT16:
|
||||
return DBUS_TYPE_UINT16_AS_STRING;
|
||||
case DBUS_TYPE_INT32:
|
||||
return DBUS_TYPE_INT32_AS_STRING;
|
||||
case DBUS_TYPE_UINT32:
|
||||
return DBUS_TYPE_UINT32_AS_STRING;
|
||||
case DBUS_TYPE_INT64:
|
||||
return DBUS_TYPE_INT64_AS_STRING;
|
||||
case DBUS_TYPE_UINT64:
|
||||
return DBUS_TYPE_UINT64_AS_STRING;
|
||||
case DBUS_TYPE_DOUBLE:
|
||||
return DBUS_TYPE_DOUBLE_AS_STRING;
|
||||
case DBUS_TYPE_STRING:
|
||||
return DBUS_TYPE_STRING_AS_STRING;
|
||||
case DBUS_TYPE_OBJECT_PATH:
|
||||
return DBUS_TYPE_OBJECT_PATH_AS_STRING;
|
||||
case DBUS_TYPE_ARRAY:
|
||||
return DBUS_TYPE_ARRAY_AS_STRING;
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static dbus_bool_t
|
||||
_nmu_dbus_add_dict_entry_start (DBusMessageIter *iter_dict,
|
||||
DBusMessageIter *iter_dict_entry,
|
||||
const char *key,
|
||||
const int value_type)
|
||||
{
|
||||
if (!dbus_message_iter_open_container (iter_dict,
|
||||
DBUS_TYPE_DICT_ENTRY,
|
||||
NULL,
|
||||
iter_dict_entry))
|
||||
return FALSE;
|
||||
|
||||
if (!dbus_message_iter_append_basic (iter_dict_entry, DBUS_TYPE_STRING, &key))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
static dbus_bool_t
|
||||
_nmu_dbus_add_dict_entry_end (DBusMessageIter *iter_dict,
|
||||
DBusMessageIter *iter_dict_entry,
|
||||
DBusMessageIter *iter_dict_val)
|
||||
{
|
||||
if (!dbus_message_iter_close_container (iter_dict_entry, iter_dict_val))
|
||||
return FALSE;
|
||||
if (!dbus_message_iter_close_container (iter_dict, iter_dict_entry))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
static dbus_bool_t
|
||||
_nmu_dbus_add_dict_entry_basic (DBusMessageIter *iter_dict,
|
||||
const char *key,
|
||||
const int value_type,
|
||||
const void *value)
|
||||
{
|
||||
DBusMessageIter iter_dict_entry, iter_dict_val;
|
||||
const char * type_as_string = NULL;
|
||||
|
||||
type_as_string = _nmu_get_type_as_string_from_type (value_type);
|
||||
if (!type_as_string)
|
||||
return FALSE;
|
||||
|
||||
if (!_nmu_dbus_add_dict_entry_start (iter_dict, &iter_dict_entry,
|
||||
key, value_type))
|
||||
return FALSE;
|
||||
|
||||
if (!dbus_message_iter_open_container (&iter_dict_entry,
|
||||
DBUS_TYPE_VARIANT,
|
||||
type_as_string,
|
||||
&iter_dict_val))
|
||||
return FALSE;
|
||||
|
||||
if (!dbus_message_iter_append_basic (&iter_dict_val, value_type, value))
|
||||
return FALSE;
|
||||
|
||||
if (!_nmu_dbus_add_dict_entry_end (iter_dict, &iter_dict_entry,
|
||||
&iter_dict_val))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
static dbus_bool_t
|
||||
_nmu_dbus_add_dict_entry_byte_array (DBusMessageIter *iter_dict,
|
||||
const char *key,
|
||||
const char *value,
|
||||
const dbus_uint32_t value_len)
|
||||
{
|
||||
DBusMessageIter iter_dict_entry, iter_dict_val, iter_array;
|
||||
dbus_uint32_t i;
|
||||
|
||||
if (!_nmu_dbus_add_dict_entry_start (iter_dict, &iter_dict_entry,
|
||||
key, DBUS_TYPE_ARRAY))
|
||||
return FALSE;
|
||||
|
||||
if (!dbus_message_iter_open_container (&iter_dict_entry,
|
||||
DBUS_TYPE_VARIANT,
|
||||
DBUS_TYPE_ARRAY_AS_STRING
|
||||
DBUS_TYPE_BYTE_AS_STRING,
|
||||
&iter_dict_val))
|
||||
return FALSE;
|
||||
|
||||
if (!dbus_message_iter_open_container (&iter_dict_val, DBUS_TYPE_ARRAY,
|
||||
DBUS_TYPE_BYTE_AS_STRING, &iter_array))
|
||||
return FALSE;
|
||||
|
||||
for (i = 0; i < value_len; i++)
|
||||
{
|
||||
if (!dbus_message_iter_append_basic (&iter_array, DBUS_TYPE_BYTE,
|
||||
&(value[i])))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!dbus_message_iter_close_container (&iter_dict_val, &iter_array))
|
||||
return FALSE;
|
||||
|
||||
if (!_nmu_dbus_add_dict_entry_end (iter_dict, &iter_dict_entry,
|
||||
&iter_dict_val))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
static dbus_bool_t
|
||||
_nmu_dbus_add_dict_entry_string_array (DBusMessageIter *iter_dict,
|
||||
const char *key,
|
||||
const char **items,
|
||||
const dbus_uint32_t num_items)
|
||||
{
|
||||
DBusMessageIter iter_dict_entry, iter_dict_val, iter_array;
|
||||
dbus_uint32_t i;
|
||||
|
||||
if (!_nmu_dbus_add_dict_entry_start (iter_dict, &iter_dict_entry,
|
||||
key, DBUS_TYPE_ARRAY))
|
||||
return FALSE;
|
||||
|
||||
if (!dbus_message_iter_open_container (&iter_dict_entry,
|
||||
DBUS_TYPE_VARIANT,
|
||||
DBUS_TYPE_ARRAY_AS_STRING
|
||||
DBUS_TYPE_STRING_AS_STRING,
|
||||
&iter_dict_val))
|
||||
return FALSE;
|
||||
|
||||
if (!dbus_message_iter_open_container (&iter_dict_val, DBUS_TYPE_ARRAY,
|
||||
DBUS_TYPE_BYTE_AS_STRING, &iter_array))
|
||||
return FALSE;
|
||||
|
||||
for (i = 0; i < num_items; i++)
|
||||
{
|
||||
if (!dbus_message_iter_append_basic (&iter_array, DBUS_TYPE_STRING,
|
||||
&(items[i])))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!dbus_message_iter_close_container (&iter_dict_val, &iter_array))
|
||||
return FALSE;
|
||||
|
||||
if (!_nmu_dbus_add_dict_entry_end (iter_dict, &iter_dict_entry,
|
||||
&iter_dict_val))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a string entry to the dict.
|
||||
*
|
||||
* @param iter_dict A valid DBusMessageIter returned from {@link nmu_dbus_dict_open_write}
|
||||
* @param key The key of the dict item
|
||||
* @param value The string value
|
||||
* @return TRUE on success, FALSE on failure
|
||||
*
|
||||
*/
|
||||
dbus_bool_t
|
||||
nmu_dbus_dict_append_string (DBusMessageIter *iter_dict,
|
||||
const char * key,
|
||||
const char * value)
|
||||
{
|
||||
if (!key || !value) return FALSE;
|
||||
return _nmu_dbus_add_dict_entry_basic (iter_dict, key, DBUS_TYPE_STRING, &value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a byte entry to the dict.
|
||||
*
|
||||
* @param iter_dict A valid DBusMessageIter returned from {@link nmu_dbus_dict_open_write}
|
||||
* @param key The key of the dict item
|
||||
* @param value The byte value
|
||||
* @return TRUE on success, FALSE on failure
|
||||
*
|
||||
*/
|
||||
dbus_bool_t
|
||||
nmu_dbus_dict_append_byte (DBusMessageIter *iter_dict,
|
||||
const char * key,
|
||||
const char value)
|
||||
{
|
||||
if (!key) return FALSE;
|
||||
return _nmu_dbus_add_dict_entry_basic (iter_dict, key, DBUS_TYPE_BYTE, &value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a boolean entry to the dict.
|
||||
*
|
||||
* @param iter_dict A valid DBusMessageIter returned from {@link nmu_dbus_dict_open_write}
|
||||
* @param key The key of the dict item
|
||||
* @param value The boolean value
|
||||
* @return TRUE on success, FALSE on failure
|
||||
*
|
||||
*/
|
||||
dbus_bool_t
|
||||
nmu_dbus_dict_append_bool (DBusMessageIter *iter_dict,
|
||||
const char * key,
|
||||
const dbus_bool_t value)
|
||||
{
|
||||
if (!key) return FALSE;
|
||||
return _nmu_dbus_add_dict_entry_basic (iter_dict, key, DBUS_TYPE_BOOLEAN, &value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a 16-bit signed integer entry to the dict.
|
||||
*
|
||||
* @param iter_dict A valid DBusMessageIter returned from {@link nmu_dbus_dict_open_write}
|
||||
* @param key The key of the dict item
|
||||
* @param value The 16-bit signed integer value
|
||||
* @return TRUE on success, FALSE on failure
|
||||
*
|
||||
*/
|
||||
dbus_bool_t
|
||||
nmu_dbus_dict_append_int16 (DBusMessageIter *iter_dict,
|
||||
const char * key,
|
||||
const dbus_int16_t value)
|
||||
{
|
||||
if (!key) return FALSE;
|
||||
return _nmu_dbus_add_dict_entry_basic (iter_dict, key, DBUS_TYPE_INT16, &value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a 16-bit unsigned integer entry to the dict.
|
||||
*
|
||||
* @param iter_dict A valid DBusMessageIter returned from {@link nmu_dbus_dict_open_write}
|
||||
* @param key The key of the dict item
|
||||
* @param value The 16-bit unsigned integer value
|
||||
* @return TRUE on success, FALSE on failure
|
||||
*
|
||||
*/
|
||||
dbus_bool_t
|
||||
nmu_dbus_dict_append_uint16 (DBusMessageIter *iter_dict,
|
||||
const char * key,
|
||||
const dbus_uint16_t value)
|
||||
{
|
||||
if (!key) return FALSE;
|
||||
return _nmu_dbus_add_dict_entry_basic (iter_dict, key, DBUS_TYPE_UINT16, &value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a 32-bit signed integer to the dict.
|
||||
*
|
||||
* @param iter_dict A valid DBusMessageIter returned from {@link nmu_dbus_dict_open_write}
|
||||
* @param key The key of the dict item
|
||||
* @param value The 32-bit signed integer value
|
||||
* @return TRUE on success, FALSE on failure
|
||||
*
|
||||
*/
|
||||
dbus_bool_t
|
||||
nmu_dbus_dict_append_int32 (DBusMessageIter *iter_dict,
|
||||
const char * key,
|
||||
const dbus_int32_t value)
|
||||
{
|
||||
if (!key) return FALSE;
|
||||
return _nmu_dbus_add_dict_entry_basic (iter_dict, key, DBUS_TYPE_INT32, &value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a 32-bit unsigned integer entry to the dict.
|
||||
*
|
||||
* @param iter_dict A valid DBusMessageIter returned from {@link nmu_dbus_dict_open_write}
|
||||
* @param key The key of the dict item
|
||||
* @param value The 32-bit unsigned integer value
|
||||
* @return TRUE on success, FALSE on failure
|
||||
*
|
||||
*/
|
||||
dbus_bool_t
|
||||
nmu_dbus_dict_append_uint32 (DBusMessageIter *iter_dict,
|
||||
const char * key,
|
||||
const dbus_uint32_t value)
|
||||
{
|
||||
if (!key) return FALSE;
|
||||
return _nmu_dbus_add_dict_entry_basic (iter_dict, key, DBUS_TYPE_UINT32, &value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a 64-bit integer entry to the dict.
|
||||
*
|
||||
* @param iter_dict A valid DBusMessageIter returned from {@link nmu_dbus_dict_open_write}
|
||||
* @param key The key of the dict item
|
||||
* @param value The 64-bit integer value
|
||||
* @return TRUE on success, FALSE on failure
|
||||
*
|
||||
*/
|
||||
dbus_bool_t
|
||||
nmu_dbus_dict_append_int64 (DBusMessageIter *iter_dict,
|
||||
const char * key,
|
||||
const dbus_int64_t value)
|
||||
{
|
||||
if (!key) return FALSE;
|
||||
return _nmu_dbus_add_dict_entry_basic (iter_dict, key, DBUS_TYPE_INT64, &value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a 64-bit unsigned integer entry to the dict.
|
||||
*
|
||||
* @param iter_dict A valid DBusMessageIter returned from {@link nmu_dbus_dict_open_write}
|
||||
* @param key The key of the dict item
|
||||
* @param value The 64-bit unsigned integer value
|
||||
* @return TRUE on success, FALSE on failure
|
||||
*
|
||||
*/
|
||||
dbus_bool_t
|
||||
nmu_dbus_dict_append_uint64 (DBusMessageIter *iter_dict,
|
||||
const char * key,
|
||||
const dbus_uint64_t value)
|
||||
{
|
||||
if (!key) return FALSE;
|
||||
return _nmu_dbus_add_dict_entry_basic (iter_dict, key, DBUS_TYPE_UINT64, &value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a double-precision floating point entry to the dict.
|
||||
*
|
||||
* @param iter_dict A valid DBusMessageIter returned from {@link nmu_dbus_dict_open_write}
|
||||
* @param key The key of the dict item
|
||||
* @param value The double-precision floating point value
|
||||
* @return TRUE on success, FALSE on failure
|
||||
*
|
||||
*/
|
||||
dbus_bool_t
|
||||
nmu_dbus_dict_append_double (DBusMessageIter *iter_dict,
|
||||
const char * key,
|
||||
const double value)
|
||||
{
|
||||
if (!key) return FALSE;
|
||||
return _nmu_dbus_add_dict_entry_basic (iter_dict, key, DBUS_TYPE_DOUBLE, &value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a DBus object path entry to the dict.
|
||||
*
|
||||
* @param iter_dict A valid DBusMessageIter returned from {@link nmu_dbus_dict_open_write}
|
||||
* @param key The key of the dict item
|
||||
* @param value The DBus object path value
|
||||
* @return TRUE on success, FALSE on failure
|
||||
*
|
||||
*/
|
||||
dbus_bool_t
|
||||
nmu_dbus_dict_append_object_path (DBusMessageIter *iter_dict,
|
||||
const char * key,
|
||||
const char * value)
|
||||
{
|
||||
if (!key || !value) return FALSE;
|
||||
return _nmu_dbus_add_dict_entry_basic (iter_dict, key, DBUS_TYPE_OBJECT_PATH, &value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a byte array entry to the dict.
|
||||
*
|
||||
* @param iter_dict A valid DBusMessageIter returned from {@link nmu_dbus_dict_open_write}
|
||||
* @param key The key of the dict item
|
||||
* @param value The byte array
|
||||
* @param value_len The length of the byte array, in bytes
|
||||
* @return TRUE on success, FALSE on failure
|
||||
*
|
||||
*/
|
||||
dbus_bool_t
|
||||
nmu_dbus_dict_append_byte_array (DBusMessageIter *iter_dict,
|
||||
const char * key,
|
||||
const char * value,
|
||||
const dbus_uint32_t value_len)
|
||||
{
|
||||
if (!key) return FALSE;
|
||||
if (!value && (value_len != 0)) return FALSE;
|
||||
return _nmu_dbus_add_dict_entry_byte_array (iter_dict, key, value, value_len);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add a string array entry to the dict.
|
||||
*
|
||||
* @param iter_dict A valid DBusMessageIter returned from {@link nmu_dbus_dict_open_write}
|
||||
* @param key The key of the dict item
|
||||
* @param items The array of strings
|
||||
* @param num_items The number of strings in the array
|
||||
* @return TRUE on success, FALSE on failure
|
||||
*
|
||||
*/
|
||||
dbus_bool_t
|
||||
nmu_dbus_dict_append_string_array (DBusMessageIter *iter_dict,
|
||||
const char * key,
|
||||
const char ** items,
|
||||
const dbus_uint32_t num_items)
|
||||
{
|
||||
if (!key) return FALSE;
|
||||
if (!items && (num_items != 0)) return FALSE;
|
||||
return _nmu_dbus_add_dict_entry_string_array (iter_dict, key, items, num_items);
|
||||
}
|
||||
|
||||
|
|
@ -1,210 +0,0 @@
|
|||
/* NetworkManager -- Network link manager
|
||||
*
|
||||
* Ray Strode <rstrode@redhat.com>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* (C) Copyright 2005 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#ifndef NM_UTILS_H
|
||||
#define NM_UTILS_H
|
||||
|
||||
#include <glib.h>
|
||||
#include <execinfo.h>
|
||||
|
||||
#define nm_print_backtrace() \
|
||||
G_STMT_START \
|
||||
{ \
|
||||
void *_call_stack[512]; \
|
||||
int _call_stack_size; \
|
||||
char **_symbols; \
|
||||
_call_stack_size = backtrace (_call_stack, \
|
||||
G_N_ELEMENTS (_call_stack)); \
|
||||
_symbols = backtrace_symbols (_call_stack, _call_stack_size); \
|
||||
if (_symbols != NULL) \
|
||||
{ \
|
||||
int _i; \
|
||||
_i = 0; \
|
||||
g_critical ("traceback:\n"); \
|
||||
while (_i < _call_stack_size) \
|
||||
{ \
|
||||
g_critical ("\t%s\n", _symbols[_i]); \
|
||||
_i++; \
|
||||
} \
|
||||
free (_symbols); \
|
||||
} \
|
||||
} \
|
||||
G_STMT_END
|
||||
|
||||
#define nm_get_timestamp(timestamp) \
|
||||
G_STMT_START \
|
||||
{ \
|
||||
GTimeVal _tv; \
|
||||
g_get_current_time (&_tv); \
|
||||
*timestamp = (_tv.tv_sec * (1.0 * G_USEC_PER_SEC) + \
|
||||
_tv.tv_usec) / G_USEC_PER_SEC; \
|
||||
} \
|
||||
G_STMT_END
|
||||
|
||||
#define nm_info(fmt, args...) \
|
||||
G_STMT_START \
|
||||
{ \
|
||||
g_message ("<information>\t" fmt "\n", ##args); \
|
||||
} G_STMT_END
|
||||
|
||||
#define nm_info_str(fmt_str, args...) \
|
||||
G_STMT_START \
|
||||
{ \
|
||||
g_message ("<information>\t%s\n", fmt_str, ##args); \
|
||||
} G_STMT_END
|
||||
|
||||
#define nm_debug(fmt, args...) \
|
||||
G_STMT_START \
|
||||
{ \
|
||||
gdouble _timestamp; \
|
||||
nm_get_timestamp (&_timestamp); \
|
||||
g_debug ("<debug info>\t[%f] %s (): " fmt "\n", _timestamp, \
|
||||
G_STRFUNC, ##args); \
|
||||
} G_STMT_END
|
||||
|
||||
#define nm_debug_str(fmt_str, args...) \
|
||||
G_STMT_START \
|
||||
{ \
|
||||
gdouble _timestamp; \
|
||||
nm_get_timestamp (&_timestamp); \
|
||||
g_debug ("<debug info>\t[%f] %s (): %s\n", _timestamp, \
|
||||
G_STRFUNC, fmt_str, ##args); \
|
||||
} G_STMT_END
|
||||
|
||||
#define nm_warning(fmt, args...) \
|
||||
G_STMT_START \
|
||||
{ \
|
||||
g_warning ("<WARNING>\t %s (): " fmt "\n", \
|
||||
G_STRFUNC, ##args); \
|
||||
} G_STMT_END
|
||||
|
||||
#define nm_warning_str(fmt_str, args...) \
|
||||
G_STMT_START \
|
||||
{ \
|
||||
g_warning ("<WARNING>\t %s (): %s\n", \
|
||||
G_STRFUNC, fmt_str, ##args); \
|
||||
} G_STMT_END
|
||||
|
||||
#define nm_error(fmt, args...) \
|
||||
G_STMT_START \
|
||||
{ \
|
||||
gdouble _timestamp; \
|
||||
nm_get_timestamp (&_timestamp); \
|
||||
g_critical ("<ERROR>\t[%f] %s (): " fmt "\n", _timestamp, \
|
||||
G_STRFUNC, ##args); \
|
||||
nm_print_backtrace (); \
|
||||
G_BREAKPOINT (); \
|
||||
} G_STMT_END
|
||||
|
||||
#define nm_error_str(fmt_str, args...) \
|
||||
G_STMT_START \
|
||||
{ \
|
||||
gdouble _timestamp; \
|
||||
nm_get_timestamp (&_timestamp); \
|
||||
g_critical ("<ERROR>\t[%f] %s (): %s\n", _timestamp, \
|
||||
G_STRFUNC, fmt_str, ##args); \
|
||||
nm_print_backtrace (); \
|
||||
G_BREAKPOINT (); \
|
||||
} G_STMT_END
|
||||
|
||||
gchar *nm_dbus_escape_object_path (const gchar *utf8_string);
|
||||
gchar *nm_dbus_unescape_object_path (const gchar *object_path);
|
||||
|
||||
/*
|
||||
* Adding a dict to a DBusMessage
|
||||
*/
|
||||
|
||||
dbus_bool_t
|
||||
nmu_dbus_dict_open_write (DBusMessageIter *iter,
|
||||
DBusMessageIter *iter_dict);
|
||||
|
||||
dbus_bool_t
|
||||
nmu_dbus_dict_close_write (DBusMessageIter *iter,
|
||||
DBusMessageIter *iter_dict);
|
||||
|
||||
dbus_bool_t
|
||||
nmu_dbus_dict_append_string (DBusMessageIter *iter_dict,
|
||||
const char * key,
|
||||
const char * value);
|
||||
|
||||
dbus_bool_t
|
||||
nmu_dbus_dict_append_byte (DBusMessageIter *iter_dict,
|
||||
const char * key,
|
||||
const char value);
|
||||
|
||||
dbus_bool_t
|
||||
nmu_dbus_dict_append_bool (DBusMessageIter *iter_dict,
|
||||
const char * key,
|
||||
const dbus_bool_t value);
|
||||
|
||||
dbus_bool_t
|
||||
nmu_dbus_dict_append_int16 (DBusMessageIter *iter_dict,
|
||||
const char * key,
|
||||
const dbus_int16_t value);
|
||||
|
||||
dbus_bool_t
|
||||
nmu_dbus_dict_append_uint16 (DBusMessageIter *iter_dict,
|
||||
const char * key,
|
||||
const dbus_uint16_t value);
|
||||
|
||||
dbus_bool_t
|
||||
nmu_dbus_dict_append_int32 (DBusMessageIter *iter_dict,
|
||||
const char * key,
|
||||
const dbus_int32_t value);
|
||||
|
||||
dbus_bool_t
|
||||
nmu_dbus_dict_append_uint32 (DBusMessageIter *iter_dict,
|
||||
const char * key,
|
||||
const dbus_uint32_t value);
|
||||
|
||||
dbus_bool_t
|
||||
nmu_dbus_dict_append_int64 (DBusMessageIter *iter_dict,
|
||||
const char * key,
|
||||
const dbus_int64_t value);
|
||||
|
||||
dbus_bool_t
|
||||
nmu_dbus_dict_append_uint64 (DBusMessageIter *iter_dict,
|
||||
const char * key,
|
||||
const dbus_uint64_t value);
|
||||
|
||||
dbus_bool_t
|
||||
nmu_dbus_dict_append_double (DBusMessageIter *iter_dict,
|
||||
const char * key,
|
||||
const double value);
|
||||
|
||||
dbus_bool_t
|
||||
nmu_dbus_dict_append_object_path (DBusMessageIter *iter_dict,
|
||||
const char * key,
|
||||
const char * value);
|
||||
|
||||
dbus_bool_t
|
||||
nmu_dbus_dict_append_byte_array (DBusMessageIter *iter_dict,
|
||||
const char * key,
|
||||
const char * value,
|
||||
const dbus_uint32_t value_len);
|
||||
|
||||
dbus_bool_t
|
||||
nmu_dbus_dict_append_string_array (DBusMessageIter *iter_dict,
|
||||
const char * key,
|
||||
const char ** items,
|
||||
const dbus_uint32_t num_items);
|
||||
|
||||
#endif /* NM_UTILS_H */
|
||||
Loading…
Add table
Reference in a new issue