This email list is read-only.  Emails sent to this list will be discarded
----------------------------------
 configure.ac          |    4 ++
 include/element.h     |   11 ++++---
 plugins/hso.c         |    4 --
 plugins/modem.c       |   10 ++++--
 scripts/Makefile.am   |    6 ++++
 scripts/pppd-plugin.c |   80 +++++++++++++++++++++++++++++++++++++++++++++++++
 src/element.c         |    2 +
 7 files changed, 105 insertions(+), 12 deletions(-)

New commits:
commit 2908e9d91aef3832151feb7294babcb7110e93d6
Author: Marcel Holtmann <[email protected]>
Date:   Wed Dec 31 19:44:33 2008 +0100

    Add element type for PPP

commit 2be69ed5050ac7bfa03af2ddce172e6fc02ddc84
Author: Marcel Holtmann <[email protected]>
Date:   Wed Dec 31 19:42:37 2008 +0100

    Add basic pppd plugin

commit 7a5d039927269f9f3f2fb5290e2ac5ca6f4b94a4
Author: Marcel Holtmann <[email protected]>
Date:   Wed Dec 31 19:30:32 2008 +0100

    Add check for pppd binary and header files

commit 7eb8af13972e60a68013008ffc71a3495ad63144
Author: Marcel Holtmann <[email protected]>
Date:   Wed Dec 31 19:27:56 2008 +0100

    Remove watch on shutdown

commit 63a37015b90200aa5dd9a0282dc260ea6d4b5afb
Author: Marcel Holtmann <[email protected]>
Date:   Wed Dec 31 09:56:33 2008 +0100

    Remove unused GIOChannel


Diff in this email is a maximum of 400 lines.
diff --git a/configure.ac b/configure.ac
index 42789a7..a22b82a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -47,6 +47,10 @@ AC_PATH_PROG(UDHCPC, [udhcpc], ,$PATH:/sbin:/usr/sbin)
 AC_PATH_PROG(DHCLIENT, [dhclient], ,$PATH:/sbin:/usr/sbin)
 AC_PATH_PROG(RESOLVCONF, [resolvconf], ,$PATH:/sbin:/usr/sbin)
 AC_PATH_PROG(WPASUPPLICANT, [wpa_supplicant], ,$PATH:/sbin:/usr/sbin)
+AC_PATH_PROG(PPPD, [pppd], ,$PATH:/sbin:/usr/sbin)
+
+AC_CHECK_HEADERS(pppd/pppd.h, pppd_found=no, pppd_found=yes)
+AM_CONDITIONAL(PPPD, test "${pppd_found}" = "yes")
 
 AC_CHECK_LIB(dl, dlopen, dummy=yes,
                        AC_MSG_ERROR(dynamic linking loader is required))
diff --git a/include/element.h b/include/element.h
index 812ac30..92f642f 100644
--- a/include/element.h
+++ b/include/element.h
@@ -58,11 +58,12 @@ enum connman_element_type {
        CONNMAN_ELEMENT_TYPE_DEVICE     = 3,
        CONNMAN_ELEMENT_TYPE_NETWORK    = 4,
        CONNMAN_ELEMENT_TYPE_SERVICE    = 5,
-       CONNMAN_ELEMENT_TYPE_IPV4       = 6,
-       CONNMAN_ELEMENT_TYPE_IPV6       = 7,
-       CONNMAN_ELEMENT_TYPE_DHCP       = 8,
-       CONNMAN_ELEMENT_TYPE_BOOTP      = 9,
-       CONNMAN_ELEMENT_TYPE_ZEROCONF   = 10,
+       CONNMAN_ELEMENT_TYPE_PPP        = 6,
+       CONNMAN_ELEMENT_TYPE_IPV4       = 7,
+       CONNMAN_ELEMENT_TYPE_IPV6       = 8,
+       CONNMAN_ELEMENT_TYPE_DHCP       = 9,
+       CONNMAN_ELEMENT_TYPE_BOOTP      = 10,
+       CONNMAN_ELEMENT_TYPE_ZEROCONF   = 11,
 
        CONNMAN_ELEMENT_TYPE_CONNECTION = 42,
 };
diff --git a/plugins/hso.c b/plugins/hso.c
index 335655c..98708dd 100644
--- a/plugins/hso.c
+++ b/plugins/hso.c
@@ -39,7 +39,6 @@
 
 struct hso_data {
        int index;
-       GIOChannel *channel;
        struct modem_data *modem;
 };
 
@@ -208,9 +207,6 @@ static int hso_disable(struct connman_device *device)
 
        modem_close(data->modem);
 
-       g_io_channel_shutdown(data->channel, TRUE, NULL);
-       g_io_channel_unref(data->channel);
-
        return 0;
 }
 
diff --git a/plugins/modem.c b/plugins/modem.c
index 4668bd3..47d7e21 100644
--- a/plugins/modem.c
+++ b/plugins/modem.c
@@ -40,6 +40,7 @@
 struct modem_data {
        char *device;
        GIOChannel *channel;
+       guint watch;
        GSList *callbacks;
        GSList *commands;
        char buf[1024];
@@ -200,7 +201,9 @@ static int open_device(const char *device)
        tcflush(fd, TCIOFLUSH);
 
        /* Switch TTY to raw mode */
+       memset(&ti, 0, sizeof(ti));
        cfmakeraw(&ti);
+
        tcsetattr(fd, TCSANOW, &ti);
 
        return fd;
@@ -232,7 +235,7 @@ int modem_open(struct modem_data *modem)
        modem->channel = g_io_channel_unix_new(fd);
        g_io_channel_set_close_on_unref(modem->channel, TRUE);
 
-       g_io_add_watch(modem->channel,
+       modem->watch = g_io_add_watch(modem->channel,
                                G_IO_IN | G_IO_NVAL | G_IO_HUP | G_IO_ERR,
                                                        modem_event, modem);
 
@@ -246,9 +249,10 @@ int modem_close(struct modem_data *modem)
        if (modem == NULL)
                return -ENOENT;
 
-       g_io_channel_shutdown(modem->channel, TRUE, NULL);
-       g_io_channel_unref(modem->channel);
+       g_source_remove(modem->watch);
+       modem->watch = 0;
 
+       g_io_channel_unref(modem->channel);
        modem->channel = NULL;
 
        return 0;
diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index b28f64f..9cf4e00 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -15,6 +15,12 @@ udhcpc_script_LDADD = @DBUS_LIBS@
 
 dhclient_script_LDADD = @DBUS_LIBS@
 
+if PPPD
+script_LTLIBRARIES = pppd-plugin.la
+
+pppd_plugin_la_LDFLAGS = -module -avoid-version
+endif
+
 AM_CFLAGS = @DBUS_CFLAGS@
 
 EXTRA_DIST = $(script_DATA)
diff --git a/scripts/pppd-plugin.c b/scripts/pppd-plugin.c
new file mode 100644
index 0000000..232d58a
--- /dev/null
+++ b/scripts/pppd-plugin.c
@@ -0,0 +1,80 @@
+/*
+ *
+ *  Connection Manager
+ *
+ *  Copyright (C) 2007-2008  Intel Corporation. All rights reserved.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  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 St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+#include <pppd/pppd.h>
+#include <pppd/fsm.h>
+#include <pppd/ipcp.h>
+
+static void notifier_phasechange(void *data, int arg)
+{
+       printf("phasechange: data %p arg %d\n", data, arg);
+}
+
+static void notifier_exit(void *data, int arg)
+{
+       printf("exitnotify: data %p arg %d\n", data, arg);
+}
+
+static void notifier_ipup(void *data, int arg)
+{
+       ipcp_options opts = ipcp_gotoptions[0];
+       ipcp_options peer = ipcp_hisoptions[0];
+
+       printf("ipup: data %p arg %d\n", data, arg);
+
+       printf("%s: %s -> %s\n", ifname,
+                               inet_ntoa(*((struct in_addr *) &opts.ouraddr)),
+                               inet_ntoa(*((struct in_addr *) &peer.hisaddr)));
+
+       script_unsetenv("USEPEERDNS");
+       script_unsetenv("DNS1");
+       script_unsetenv("DNS2");
+}
+
+static void notifier_ipdown(void *data, int arg)
+{
+       printf("ipdown: data %p arg %d\n", data, arg);
+}
+
+char pppd_version[] = VERSION;
+
+int plugin_init(void);
+
+int plugin_init(void)
+{
+       path_ipup[0] = '\0';
+       path_ipdown[0] = '\0';
+
+       add_notifier(&phasechange, notifier_phasechange, NULL);
+       add_notifier(&exitnotify, notifier_exit, NULL);
+
+       add_notifier(&ip_up_notifier, notifier_ipup, NULL);
+       add_notifier(&ip_down_notifier, notifier_ipdown, NULL);
+
+       return 0;
+}
diff --git a/src/element.c b/src/element.c
index 0271107..a3bfa02 100644
--- a/src/element.c
+++ b/src/element.c
@@ -106,6 +106,8 @@ static const char *type2string(enum connman_element_type 
type)
                return "network";
        case CONNMAN_ELEMENT_TYPE_SERVICE:
                return "service";
+       case CONNMAN_ELEMENT_TYPE_PPP:
+               return "ppp";
        case CONNMAN_ELEMENT_TYPE_IPV4:
                return "ipv4";
        case CONNMAN_ELEMENT_TYPE_IPV6:
_______________________________________________
Commits mailing list
[email protected]
https://lists.moblin.org/mailman/listinfo/commits

Reply via email to