* Support for GPRS over Bluetooth 97% complete

git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1808 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
Antony Mee 2006-06-07 03:08:38 +00:00
parent 0e24b9e39f
commit 4099bf2704
5 changed files with 1465 additions and 571 deletions

View file

@ -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",[

File diff suppressed because it is too large Load diff

View file

@ -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,

View file

@ -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);

View file

@ -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;