From 4099bf2704ec0b962926967ae1ced46e1014b4a7 Mon Sep 17 00:00:00 2001 From: Antony Mee Date: Wed, 7 Jun 2006 03:08:38 +0000 Subject: [PATCH] * Support for GPRS over Bluetooth 97% complete git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1808 4912f4e0-d625-0410-9fb7-b9a5a253dbdc --- vpn-daemons/pptp/configure.in | 4 + .../pptp/properties/nm-ppp-dialog.glade | 1557 ++++++++++++----- .../pptp/properties/nm-ppp-properties.c | 183 +- .../pptp/properties/nm-ppp-properties.h | 34 - vpn-daemons/pptp/src/nm-ppp-starter.c | 258 ++- 5 files changed, 1465 insertions(+), 571 deletions(-) diff --git a/vpn-daemons/pptp/configure.in b/vpn-daemons/pptp/configure.in index 1b28944579..6818f04651 100644 --- a/vpn-daemons/pptp/configure.in +++ b/vpn-daemons/pptp/configure.in @@ -89,6 +89,10 @@ AS_AC_EXPAND(SBINDIR, $sbindir) AS_AC_EXPAND(LIBDIR, $libdir) AS_AC_EXPAND(LIBEXECDIR, $libexecdir) +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",[ diff --git a/vpn-daemons/pptp/properties/nm-ppp-dialog.glade b/vpn-daemons/pptp/properties/nm-ppp-dialog.glade index 6ce431466f..453119da56 100644 --- a/vpn-daemons/pptp/properties/nm-ppp-dialog.glade +++ b/vpn-daemons/pptp/properties/nm-ppp-dialog.glade @@ -285,7 +285,7 @@ True True - True + False 0 @@ -395,7 +395,7 @@ True True - True + False 0 @@ -502,48 +502,50 @@ - + True - Options relating to PPP (see 'man ppp') - True - False + True + False + 0 - + True - True - False - 4 + 0.5 + 0.5 + 1 + 1 + 0 + 0 + 12 + 0 - + True - 0.5 - 0.5 - 1 - 1 - 0 - 0 - 12 - 0 + False + 4 - + True False - 4 + 12 - + True - True - Use Peer DNS + _Device Address: True - GTK_RELIEF_NORMAL - True - True - False - True + False + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + pptp-remote 0 @@ -553,149 +555,71 @@ - + True - False - 4 + Host name or IP address of the PPTP server + True + True + True + 17 + 00:00:00:00 + True + * + False + + + 0 + True + True + + + + + 0 + False + False + + - - - True - Compression and encryption - False - True - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 0 - False - False - - + + + True + False + 12 - - - True - 0.5 - 0.5 - 1 - 1 - 0 - 0 - 18 - 0 + + + True + _Channel: + True + False + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + pptp-remote + + + 0 + False + False + + - - - True - 2 - 2 - False - 4 - 13 - - - - True - True - MPPE encryption - True - GTK_RELIEF_NORMAL - True - False - False - True - - - 0 - 1 - 0 - 1 - fill - - - - - - - True - True - MPPC Compression - True - GTK_RELIEF_NORMAL - True - False - False - True - - - 1 - 2 - 0 - 1 - fill - - - - - - - True - True - Deflate compression - True - GTK_RELIEF_NORMAL - True - False - False - True - - - 0 - 1 - 1 - 2 - fill - - - - - - - True - True - BSD Compression - True - GTK_RELIEF_NORMAL - True - False - False - True - - - 1 - 2 - 1 - 2 - fill - - - - - - - - 0 - True - True - - + + + True + True + True + True + 3 + + True + * + False 0 @@ -705,16 +629,245 @@ - + True True - Exclusive device access (UUCP-style lock) + Find Device True GTK_RELIEF_NORMAL True - False - False - True + + + 0 + False + False + + + + + 0 + True + True + + + + + + + + + + True + <b>Bluetooth options</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + label_item + + + + + 0 + True + True + + + + + + True + True + False + 0 + + + + True + 0.5 + 0.5 + 1 + 1 + 0 + 0 + 12 + 0 + + + + True + False + 4 + + + + True + False + 4 + + + + True + 0.5 + 0.5 + 1 + 1 + 0 + 0 + 18 + 0 + + + + True + 1 + 2 + False + 4 + 13 + + + + True + True + Modem Connection + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + 1 + 0 + 1 + fill + + + + + + + True + True + Hardware RTS/CTS + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 1 + 2 + 0 + 1 + fill + + + + + + + + 0 + True + True + + + + + 0 + False + False + + + + + + + + + + True + <b>Serial options</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + label_item + + + + + 0 + True + True + + + + + + True + True + False + 0 + + + + True + 0.5 + 0.5 + 1 + 1 + 0 + 0 + 12 + 0 + + + + True + False + 4 + + + + True + False + 12 + + + + True + _Access Point Name: + True + False + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + pptp-remote 0 @@ -724,16 +877,52 @@ - + True + Host name or IP address of the PPTP server True - Authenticate Peer + True + True + 0 + + True + * + False + + + 0 + True + True + + + + + 0 + False + False + + + + + + True + False + 12 + + + + True + _IP Address: True - GTK_RELIEF_NORMAL - True - False - False - True + False + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + pptp-remote 0 @@ -743,264 +932,735 @@ - + True + Host name or IP address of the PPTP server True - False + True + True + 0 + + True + * + False + + + 0 + True + True + + + + + 0 + True + True + + + + + + True + False + 12 + + + + True + _Packet Type + True + False + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + pptp-remote + + + 0 + False + False + + + + + + True + Host name or IP address of the PPTP server + True + True + True + 0 + + True + * + False + 9 + + + 0 + True + True + + + + + + True + _Context Num + True + False + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + pptp-remote + + + 0 + False + False + + + + + + True + Host name or IP address of the PPTP server + True + True + True + 0 + + True + * + False + 3 + + + 0 + True + True + + + + + 0 + True + True + + + + + + + + + + True + <b>GPRS options</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + label_item + + + + + 0 + True + True + + + + + + True + True + False + 4 + + + + True + 0.5 + 0.5 + 1 + 1 + 0 + 0 + 12 + 0 + + + + True + False + 4 + + + + True + False + 4 + + + + True + 0.5 + 0.5 + 1 + 1 + 0 + 0 + 18 + 0 + + + + True + 1 + 2 + False + 4 + 13 + + + + True + True + Require Explicit IP Addr + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 1 + 2 + 0 + 1 + fill + + + + + + + True + True + Use Peer DNS + True + GTK_RELIEF_NORMAL + True + True + False + True + + + 0 + 1 + 0 + 1 + fill + + + + + + + + 0 + True + True + + + + + 0 + True + True + + + + + + True + False + 4 + + + + True + Compression and encryption + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + 0.5 + 0.5 + 1 + 1 + 0 + 0 + 18 + 0 + + + + True + 2 + 2 + False + 4 + 13 + + + + True + True + MPPE encryption + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + 1 + 0 + 1 + fill + + + + + + + True + True + MPPC Compression + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 1 + 2 + 0 + 1 + fill + + + + + + + True + True + Deflate compression + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + 1 + 1 + 2 + fill + + + + + + + True + True + BSD Compression + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 1 + 2 + 1 + 2 + fill + + + + + + + + 0 + True + True + + + + + 0 + True + True + + + + + + True + True + Exclusive device access (UUCP-style lock) + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + False + False + + + + + + True + True + Authenticate Peer + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + False + False + + + + + + True + True + True + 0 + + + + True + False 0 - + True False - 0 + 12 - + True + 2 + 2 False - 0 + 1 + 10 - + True - + mtu False False GTK_JUSTIFY_LEFT False False - 0.5 + 0 0.5 0 0 - 0 - True - True + 0 + 1 + 0 + 1 + fill + - + True - 4 - 2 - False - 1 - 15 - - - - True - mtu - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 0 - 1 - 0 - 1 - fill - - - - - - - True - mru - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 0 - 1 - 1 - 2 - fill - - - - - - - True - lcp-echo-failure - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 0 - 1 - 2 - 3 - fill - - - - - - - True - lcp-echo-interval - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 0 - 1 - 3 - 4 - fill - - - - - - - 75 - True - Maximum Transmit Unit - True - 1 - 0 - False - GTK_UPDATE_ALWAYS - False - False - 10000 0 100000 10 100 100 - - - 1 - 2 - 0 - 1 - - - - - - - True - Maximum Receive Unit - True - 1 - 0 - False - GTK_UPDATE_ALWAYS - False - False - 1000 0 10000 10 100 100 - - - 1 - 2 - 1 - 2 - - - - - - - True - Disconnect after this many LCP echo requests fail - True - 1 - 0 - False - GTK_UPDATE_ALWAYS - False - False - 10 0 1000 1 10 10 - - - 1 - 2 - 2 - 3 - - - - - - - True - Time in seconds between echo requests - True - 1 - 0 - False - GTK_UPDATE_ALWAYS - False - False - 10 0 1000 1 10 10 - - - 1 - 2 - 3 - 4 - - - + mru + False + False + GTK_JUSTIFY_CENTER + False + False + 0 + 0.5 + 0 + 0 - 0 - False - False + 0 + 1 + 1 + 2 + fill + - + + 75 True - + Maximum Transmit Unit + True + 1 + 0 + False + GTK_UPDATE_ALWAYS + False + False + 1000 0 100000 10 100 100 + + + 1 + 2 + 0 + 1 + + + + + + + True + Maximum Receive Unit + True + 1 + 0 + False + GTK_UPDATE_ALWAYS + False + False + 1000 0 10000 10 100 100 + + + 1 + 2 + 1 + 2 + + + + + + 0 + False + False + + + + + + True + 3 + 2 + False + 1 + 10 + + + + True + connect-delay False False GTK_JUSTIFY_LEFT False False - 0.5 + 0 0.5 0 0 - 0 - True - True + 0 + 1 + 0 + 1 + fill + + + + + + + True + lcp-echo-failure + False + False + GTK_JUSTIFY_CENTER + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 1 + 2 + fill + + + + + + + True + Disconnect after this many LCP echo requests fail + True + 1 + 0 + False + GTK_UPDATE_ALWAYS + False + False + 10 0 1000 1 10 10 + + + 1 + 2 + 1 + 2 + + + + + + + True + lcp-echo-interval + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 2 + 3 + fill + + + + + + + True + Time in seconds between echo requests + True + 1 + 0 + False + GTK_UPDATE_ALWAYS + False + False + 10 0 1000 1 10 10 + + + 1 + 2 + 2 + 3 + + + + + + + True + Disconnect after this many LCP echo requests fail + True + 1 + 0 + False + GTK_UPDATE_ALWAYS + False + False + 0 0 30000 100 1000 1000 + + + 1 + 2 + 0 + 1 + @@ -1011,77 +1671,82 @@ - - - - - True - Numeric Tweaks - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - label_item + 0 + True + True - - 0 - False - False - - + True - True - Debug Output - True - GTK_RELIEF_NORMAL - True - False - False - True + Numeric Tweaks + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 - 0 - False - False + label_item + + 0 + False + False + + + + + + True + True + Debug Output + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + False + False + - - - - True - <b>PPP options</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - label_item - - + + + + True + <b>PPP options</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + label_item + + 0 @@ -1094,7 +1759,7 @@ True True - True + False 4 diff --git a/vpn-daemons/pptp/properties/nm-ppp-properties.c b/vpn-daemons/pptp/properties/nm-ppp-properties.c index baaf4d3dfa..bbcc94a16e 100644 --- a/vpn-daemons/pptp/properties/nm-ppp-properties.c +++ b/vpn-daemons/pptp/properties/nm-ppp-properties.c @@ -40,7 +40,54 @@ #include "vpnui_variant.h" #include "util_lists.h" -#include "nm-ppp-properties.h" +#define BUILD_BLUETOOTH + +#define VPNUI_DISPLAY_NAME _("Tunnel via pppd") +#define VPNUI_SERVICE_NAME "org.freedesktop.NetworkManager.ppp_starter" +#define VPNUI_BASIC_DEFAULTS "connection-name='';" \ + "ppp-debug=no;" \ + "usepeerdns=yes;" \ + "usepeerdns-overtunnel=yes;" \ + "encrypt-mppe=yes;" \ + "compress-mppc=no;" \ + "ppp-lock=yes;" \ + "ppp-auth-peer=no;" \ + "compress-bsd=no;" \ + "compress-deflate=no;" \ + "mru=1000;" \ + "mtu=1000;" \ + "lcp-echo-failure=10;" \ + "lcp-echo-interval=10;" \ + "use-routes=no;" \ + "routes=;" \ + "ppp-debug=no;" +#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;" +#define VPNUI_PPTP_DEFAULTS "pptp-remote='';" \ + "ppp-connection-type=pptp;" +#define VPNUI_DIALUP_DEFAULTS "phone-number=THIS DOESN'T DO ANYTHING;" \ + "ppp-crtscts=yes;" \ + "ppp-modem=yes;" \ + "ppp-connection-type=dialup;" + +#ifdef NMVPNUI_PPTP_PROPERTIES_C +#endif + +void impl_setup (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"; @@ -60,106 +107,158 @@ impl_setup (NetworkManagerVpnUIImpl *impl) // GCONF_NAME EXPORT_NAME DESCRIPTION(for summary) // VALIDATOR_Fn opt = vpnui_opt_new( - "connection-name", VPN_UI_OPTTYPE_STRING, + "connection-name", VPN_UI_OPTTYPE_STRING, NULL, "Description", _("Name"), GTK_SIGNAL_FUNC(&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, + "ppp-connection-type", VPN_UI_OPTTYPE_COMBO, + "ppp-connection-type", "Connection-Type", NULL, GTK_SIGNAL_FUNC(&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"), + "pptp-remote", VPN_UI_OPTTYPE_STRING, + "pptp-remote", "PPTP-Server", _("PPTP Server"), GTK_SIGNAL_FUNC(&editable_changed), &vld_non_empty, impl ); opt = vpnui_opt_new( - "phone-number", VPN_UI_OPTTYPE_STRING, - "phone-number", "Telephone-Number", _("Telephone Number"), + "phone-number", VPN_UI_OPTTYPE_STRING, + "phone-number", "Telephone-Number", _("Telephone Number"), GTK_SIGNAL_FUNC(&editable_changed), &vld_non_empty, impl ); opt = vpnui_opt_new( - "usepeerdns" , VPN_UI_OPTTYPE_YESNO , - "usepeerdns", "Use-Peer-DNS", _("Use Peer DNS"), + "bt-bdaddr", VPN_UI_OPTTYPE_STRING, + "bt-bdaddr", "Bluetooth-Address", _("Bluetooth Address"), + GTK_SIGNAL_FUNC(&editable_changed), &vld_non_empty, impl ); + + opt = vpnui_opt_new( + "bt-channel", VPN_UI_OPTTYPE_STRING, + "bt-channel", "Bluetooth-Channel", _("Bluetooth Channel"), + GTK_SIGNAL_FUNC(&editable_changed), &vld_non_empty, impl ); + + opt = vpnui_opt_new( + "gprs-apn", VPN_UI_OPTTYPE_STRING, + "gprs-apn", "GPRS-Access-Point-Name", _("GPRS APN"), + GTK_SIGNAL_FUNC(&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"), + GTK_SIGNAL_FUNC(&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."), + GTK_SIGNAL_FUNC(&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"), + GTK_SIGNAL_FUNC(&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"), + GTK_SIGNAL_FUNC(&editable_changed), NULL, impl ); + + opt = vpnui_opt_new( + "ppp-modem", VPN_UI_OPTTYPE_YESNO, + "ppp-modem", "PPP-Modem", _("Connect via a modem"), + GTK_SIGNAL_FUNC(&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"), + GTK_SIGNAL_FUNC(&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"), + "encrypt-mppe" , VPN_UI_OPTTYPE_YESNO , + "encrypt-mppe", "Encrypt-MPPE", _("Use MPPE encryption"), NULL, NULL, impl ); opt = vpnui_opt_new( - "compress-mppc" , VPN_UI_OPTTYPE_YESNO , - "compress-mppc", "Compress-MPPC", _("Use MPPC compression"), + "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"), + "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"), + "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"), + "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"), + "ppp-auth-peer" , VPN_UI_OPTTYPE_YESNO , + "ppp-auth-peer", "Auth-Peer", _("Authenticate remote peer"), NULL, NULL, impl ); opt = vpnui_opt_new( - "mtu" , VPN_UI_OPTTYPE_SPINNER , - "mtu", "MTU", _("Maximum transmit unit (in bytes)"), + "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)"), + "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"), + "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"), + "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-debug" , VPN_UI_OPTTYPE_YESNO , - "ppp-debug", NULL, NULL, + "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"), + "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"), + "routes" , VPN_UI_OPTTYPE_STRING , + "routes", "X-NM-Routes", _("Specific networks available"), GTK_SIGNAL_FUNC(&editable_changed), &vld_routes_if_sens, impl ); opt = vpnui_opt_new( - "use-routes" , VPN_UI_OPTTYPE_YESNO , - "use-routes", "Use-Routes", _("Limit to specific networks"), + "use-routes" , VPN_UI_OPTTYPE_YESNO , + "use-routes", "Use-Routes", _("Limit to specific networks"), GTK_SIGNAL_FUNC(&use_routes_toggled), NULL, impl ); 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); @@ -169,6 +268,14 @@ impl_setup (NetworkManagerVpnUIImpl *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, diff --git a/vpn-daemons/pptp/properties/nm-ppp-properties.h b/vpn-daemons/pptp/properties/nm-ppp-properties.h index 4280ec6b32..e69de29bb2 100644 --- a/vpn-daemons/pptp/properties/nm-ppp-properties.h +++ b/vpn-daemons/pptp/properties/nm-ppp-properties.h @@ -1,34 +0,0 @@ -#define VPNUI_ROUTES_WIDGET "routes" -#define VPNUI_ROUTES_TOGGLE_WIDGET "use-routes" -#define VPNUI_DISPLAY_NAME _("PPPD Tunnel Client") -#define VPNUI_SERVICE_NAME "org.freedesktop.NetworkManager.ppp_starter" -#define VPNUI_BASIC_DEFAULTS "connection-name='';" \ - "ppp-debug=no;" \ - "usepeerdns=yes;" \ - "usepeerdns-overtunnel=yes;" \ - "encrypt-mppe=yes;" \ - "compress-mppc=no;" \ - "ppp-lock=yes;" \ - "ppp-auth-peer=no;" \ - "compress-bsd=no;" \ - "compress-deflate=no;" \ - "mru=1000;" \ - "mtu=1000;" \ - "lcp-echo-failure=10;" \ - "lcp-echo-interval=10;" \ - "use-routes=no;" \ - "routes=;" \ - "ppp-debug=no;" -#define VPNUI_PPTP_DEFAULTS "pptp-remote='';" \ - "ppp-connection-type=pptp;" -#define VPNUI_DIALUP_DEFAULTS "phone-number=THIS DOESN'T DO ANYTHING;" \ - "ppp-connection-type=dialup;" - -#ifdef NMVPNUI_PPTP_PROPERTIES_C -#endif - -void impl_setup (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); - diff --git a/vpn-daemons/pptp/src/nm-ppp-starter.c b/vpn-daemons/pptp/src/nm-ppp-starter.c index 149fe7afa1..02e1850dd1 100644 --- a/vpn-daemons/pptp/src/nm-ppp-starter.c +++ b/vpn-daemons/pptp/src/nm-ppp-starter.c @@ -75,6 +75,7 @@ typedef struct NmPPPData guint quit_timer; guint helper_timer; char *str_ip4_vpn_gateway; + char *connection_type; struct in_addr ip4_vpn_gateway; char **auth_items; int num_auth_items; @@ -399,34 +400,19 @@ static void pppd_forked_watch_cb (GPid pid, gint status, gpointer user_data) nm_ppp_schedule_quit_timer (data, 10000); } - /* - * nm_ppp_start_vpn_binary + * nm_ppp_get_cmdline_pptp * - * Start the ppp binary with a set of arguments and a config file. + * Process and add to the pppd command line appropriately. * */ -static gint nm_ppp_start_ppp_binary (NmPPPData *data, char **data_items, const int num_items) +static gint nm_ppp_get_cmdline_pptp (NmPPPData *data, char **data_items, const int num_items, GPtrArray *ppp_argv) { - GPid pid; const char ** pptp_binary = NULL; - const char ** pppd_binary = NULL; - struct hostent *hostinfo = NULL; - GPtrArray * ppp_argv; - GError * error = NULL; - gint stdin_fd = -1; - GSource * pppd_watch; int i = 0; + struct hostent *hostinfo = NULL; char * pppd_pty = NULL; - char * cmdline = NULL; - - g_return_val_if_fail (data != NULL, -1); - - data->pid = 0; - - if ( (num_items == 0) || (data_items == NULL) ) { - return -1; - } + /* Find pptp */ pptp_binary = pptp_binary_paths; @@ -440,53 +426,147 @@ static gint nm_ppp_start_ppp_binary (NmPPPData *data, char **data_items, const i nm_info ("Could not find pptp binary."); return -1; } - - /* Find pppd */ - pppd_binary = pppd_binary_paths; - while (*pppd_binary != NULL) { - if (g_file_test (*pppd_binary, G_FILE_TEST_EXISTS)) - break; - pppd_binary++; - } - - if (!*pppd_binary) { - nm_info ("Could not find pppd binary."); - return -1; - } - - ppp_argv = g_ptr_array_new (); - g_ptr_array_add (ppp_argv, (gpointer) (*pppd_binary)); - + // First ppp parameter is the PPTP server for (i = 0; i < num_items; ++i) { if ( strcmp( data_items[i], "pptp-remote" ) == 0) { hostinfo = gethostbyname(data_items[++i]); if (!hostinfo) { - nm_info ("Could not resolve VPN servers IP."); + nm_info ("Could not resolve IP address of VPN server."); return -1; } data -> ip4_vpn_gateway = *(struct in_addr*)(hostinfo->h_addr_list[0]); data -> str_ip4_vpn_gateway = g_strdup( inet_ntoa( data -> ip4_vpn_gateway ) ); -// nm_info ("Lookup VPN server IP = '%s'",data->str_ip4_vpn_gateway); pppd_pty = g_strdup_printf ("%s %s --nolaunchpppd", (*pptp_binary), data->str_ip4_vpn_gateway); -// nm_info ("Starting pppd with pty %s",pppd_pty); - + g_ptr_array_add (ppp_argv, (gpointer) "pty"); g_ptr_array_add (ppp_argv, (gpointer) pppd_pty); - } } +/* TODO: this pppd_pty should get freed somewhere */ +// g_free(pppd_pty); -// g_ptr_array_add (ppp_argv, (gpointer) "nodetach"); - g_ptr_array_add (ppp_argv, (gpointer) "ipparam"); - g_ptr_array_add (ppp_argv, (gpointer) "NetworkManager"); - // Set the username... + /* Process other pptp options */ for (i = 0; i < num_items; ++i) { if ( strcmp( data_items[i], "pptp-remote" ) == 0) { g_ptr_array_add (ppp_argv, (gpointer) "remotename"); g_ptr_array_add (ppp_argv, (gpointer) data_items[++i]); - } else if ( (strcmp( data_items[i], "ppp-lock" ) == 0) && + } /* else if ( (strcmp( data_items[i], "ppp-lock" ) == 0) && + (strcmp( data_items[++i], "yes" ) == 0) ) { + g_ptr_array_add (ppp_argv, (gpointer) "lock"); + } */ + } +} + +/* + * nm_ppp_get_cmdline_dialup + * + * Process and add to the pppd command line appropriately. + * + */ +static gint nm_ppp_get_cmdline_dialup (NmPPPData *data, char **data_items, const int num_items, GPtrArray * ppp_argv) +{ +// int i = 0; +// // First ppp parameter is the PPTP server +// for (i = 0; i < num_items; ++i) { +// if ( strcmp( data_items[i], "pptp-remote" ) == 0) { +// hostinfo = gethostbyname(data_items[++i]); +// if (!hostinfo) { +// nm_info ("Could not resolve IP address of VPN server."); +// return -1; +// } +// data -> ip4_vpn_gateway = *(struct in_addr*)(hostinfo->h_addr_list[0]); +// data -> str_ip4_vpn_gateway = g_strdup( inet_ntoa( data -> ip4_vpn_gateway ) ); +// +// pppd_pty = g_strdup_printf ("%s %s --nolaunchpppd", (*pptp_binary), data->str_ip4_vpn_gateway); +// +// g_ptr_array_add (ppp_argv, (gpointer) "pty"); +// g_ptr_array_add (ppp_argv, (gpointer) pppd_pty); +// } +// } +// +// /* Process other pptp options */ +// for (i = 0; i < num_items; ++i) { +// if ( strcmp( data_items[i], "pptp-remote" ) == 0) { +// g_ptr_array_add (ppp_argv, (gpointer) "remotename"); +// g_ptr_array_add (ppp_argv, (gpointer) data_items[++i]); +// } /* else if ( (strcmp( data_items[i], "ppp-lock" ) == 0) && +// (strcmp( data_items[++i], "yes" ) == 0) ) { +// g_ptr_array_add (ppp_argv, (gpointer) "lock"); +// } */ +// } +} + +/* + * nm_ppp_get_cmdline_btgprs + * + * Process and add to the pppd command line appropriately. + * + */ +static gint nm_ppp_get_cmdline_btgprs (NmPPPData *data, char **data_items, const int num_items, GPtrArray * ppp_argv) +{ +// int i = 0; +// const char ** pptp_binary = NULL; +// +// /* Find pptp */ +// pptp_binary = pptp_binary_paths; +// while (*pptp_binary != NULL) { +// if (g_file_test (*pptp_binary, G_FILE_TEST_EXISTS)) +// break; +// pptp_binary++; +// } +// +// if (!*pptp_binary) { +// nm_info ("Could not find pptp binary."); +// return -1; +// } +// +// // First ppp parameter is the PPTP server +// for (i = 0; i < num_items; ++i) { +// if ( strcmp( data_items[i], "pptp-remote" ) == 0) { +// hostinfo = gethostbyname(data_items[++i]); +// if (!hostinfo) { +// nm_info ("Could not resolve IP address of VPN server."); +// return -1; +// } +// data -> ip4_vpn_gateway = *(struct in_addr*)(hostinfo->h_addr_list[0]); +// data -> str_ip4_vpn_gateway = g_strdup( inet_ntoa( data -> ip4_vpn_gateway ) ); +// +// pppd_pty = g_strdup_printf ("%s %s --nolaunchpppd", (*pptp_binary), data->str_ip4_vpn_gateway); +// +// g_ptr_array_add (ppp_argv, (gpointer) "pty"); +// g_ptr_array_add (ppp_argv, (gpointer) pppd_pty); +// } +// } +// +// /* Process other pptp options */ +// for (i = 0; i < num_items; ++i) { +// if ( strcmp( data_items[i], "pptp-remote" ) == 0) { +// g_ptr_array_add (ppp_argv, (gpointer) "remotename"); +// g_ptr_array_add (ppp_argv, (gpointer) data_items[++i]); +// } /* else if ( (strcmp( data_items[i], "ppp-lock" ) == 0) && +// (strcmp( data_items[++i], "yes" ) == 0) ) { +// g_ptr_array_add (ppp_argv, (gpointer) "lock"); +// } */ +// } +} + +/* + * nm_ppp_get_cmdline_ppp + * + * Process and add to the pppd command line appropriately. + * + */ +static gint nm_ppp_get_cmdline_ppp (NmPPPData *data, char **data_items, const int num_items, GPtrArray * ppp_argv) +{ + int i = 0; + // Announce ourselves as NetworkManager to the ip-up/down scripts + g_ptr_array_add (ppp_argv, (gpointer) "ipparam"); + g_ptr_array_add (ppp_argv, (gpointer) "NetworkManager"); + + for (i = 0; i < num_items; ++i) { + if ( (strcmp( data_items[i], "ppp-lock" ) == 0) && (strcmp( data_items[++i], "yes" ) == 0) ) { g_ptr_array_add (ppp_argv, (gpointer) "lock"); } else if ( (strcmp( data_items[i], "ppp-auth-peer" ) == 0) && @@ -538,10 +618,64 @@ static gint nm_ppp_start_ppp_binary (NmPPPData *data, char **data_items, const i } } + /* Add this here in case debug has been flagged by other means */ if (data->debug) g_ptr_array_add (ppp_argv, (gpointer) "debug"); g_ptr_array_add (ppp_argv, (gpointer) "plugin"); g_ptr_array_add (ppp_argv, (gpointer) NM_PPP_HELPER_PATH); +} + +/* + * nm_ppp_start_vpn_binary + * + * Start the ppp binary with a set of arguments and a config file. + * + */ +static gint nm_ppp_start_ppp_binary (NmPPPData *data, char **data_items, const int num_items) +{ + GPid pid; + const char ** pppd_binary = NULL; + GPtrArray * ppp_argv; + GError * error = NULL; + gint stdin_fd = -1; + GSource * pppd_watch; + char * cmdline = NULL; + + g_return_val_if_fail (data != NULL, -1); + + data->pid = 0; + + if ( (num_items == 0) || (data_items == NULL) ) { + return -1; + } + + /* Find pppd */ + pppd_binary = pppd_binary_paths; + while (*pppd_binary != NULL) { + if (g_file_test (*pppd_binary, G_FILE_TEST_EXISTS)) + break; + pppd_binary++; + } + + if (!*pppd_binary) { + nm_info ("Could not find pppd binary."); + return -1; + } + + ppp_argv = g_ptr_array_new (); + g_ptr_array_add (ppp_argv, (gpointer) (*pppd_binary)); + + if (strcmp("pptp",data->connection_type)==0) { + nm_ppp_get_cmdline_pptp(data,data_items,num_items,ppp_argv); + } else if (strcmp("dialup",data->connection_type)==0) { + nm_ppp_get_cmdline_dialup(data,data_items,num_items,ppp_argv); + } else if (strcmp("btgprs",data->connection_type)==0) { + nm_ppp_get_cmdline_btgprs(data,data_items,num_items,ppp_argv); + } else { + nm_warning("nm-ppp-starter: ppp-connection-type '%s' unknown",data->connection_type); + } + + nm_ppp_get_cmdline_ppp(data,data_items,num_items,ppp_argv); g_ptr_array_add (ppp_argv, NULL); @@ -557,13 +691,11 @@ static gint nm_ppp_start_ppp_binary (NmPPPData *data, char **data_items, const i NULL, NULL, &error)) { g_ptr_array_free (ppp_argv, TRUE); - g_free(pppd_pty); nm_warning ("pppd failed to start. error: '%s'", error->message); g_error_free(error); return -1; } g_ptr_array_free (ppp_argv, TRUE); - g_free(pppd_pty); pppd_watch = g_child_watch_source_new (pid); g_source_set_callback (pppd_watch, (GSourceFunc) pppd_start_watch_cb, data, NULL); @@ -594,7 +726,7 @@ typedef struct Option * Make sure the config options are sane * */ -static gboolean nm_ppp_config_options_validate (char **data_items, int num_items) +static gboolean nm_ppp_config_options_validate (NmPPPData *data, char **data_items, int num_items) { Option allowed_opts[] = { { "ppp-connection-type", OPT_TYPE_ASCII }, @@ -606,7 +738,7 @@ static gboolean nm_ppp_config_options_validate (char **data_items, int num_items { "compress-bsd", OPT_TYPE_ASCII }, { "compress-deflate", OPT_TYPE_ASCII }, { "encrypt-mppe", OPT_TYPE_ASCII }, - { "ppp-auth-peer", OPT_TYPE_ASCII }, + { "ppp-auth-peer", OPT_TYPE_ASCII }, { "ppp-lock", OPT_TYPE_ASCII }, { "mtu", OPT_TYPE_ASCII }, { "mru", OPT_TYPE_ASCII }, @@ -615,6 +747,15 @@ static gboolean nm_ppp_config_options_validate (char **data_items, int num_items { "ppp-debug", OPT_TYPE_ASCII }, { "use-routes", OPT_TYPE_ASCII }, { "routes", OPT_TYPE_ASCII }, + { "ppp-crtscts", OPT_TYPE_ASCII }, + { "ppp-noipdefault", OPT_TYPE_ASCII }, + { "ppp-modem", OPT_TYPE_ASCII }, + { "bt-bdaddr", OPT_TYPE_ASCII }, + { "bt-channel", OPT_TYPE_ASCII }, + { "gprs-packet-type", OPT_TYPE_ASCII }, + { "gprs-apn", OPT_TYPE_ASCII }, + { "gprs-ip", OPT_TYPE_ASCII }, + { "gprs-context-num", OPT_TYPE_ASCII }, { NULL, OPT_TYPE_UNKNOWN } }; unsigned int i; @@ -628,7 +769,18 @@ static gboolean nm_ppp_config_options_validate (char **data_items, int num_items nm_warning ("The number of VPN config options was not even."); return FALSE; } - + + if (data->connection_type!=NULL) g_free(data->connection_type); + for (i = 0; i < num_items; ++i) { + if ( strcmp( data_items[i], "ppp-connection-type" ) == 0) { + data->connection_type=g_strdup(data_items[++i]); + break; + } + } + if (data->connection_type==NULL) return FALSE; + + /* TODO: Need to add some different sections based on the connection_type */ + for (i = 0; i < num_items; i += 2) { Option *opt = NULL; @@ -762,7 +914,7 @@ static gboolean nm_ppp_dbus_handle_start_vpn (DBusMessage *message, NmPPPData *d goto out; } - if (!nm_ppp_config_options_validate (data_items, num_items)) + if (!nm_ppp_config_options_validate (data, data_items, num_items)) { nm_ppp_dbus_signal_failure (data, NM_DBUS_VPN_SIGNAL_VPN_CONFIG_BAD); goto out;