scripts: Report authentication error to connman
authorJukka Rissanen <jukka.rissanen@linux.intel.com>
Tue, 15 Nov 2011 11:06:23 +0000 (13:06 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Tue, 15 Nov 2011 12:41:44 +0000 (13:41 +0100)
The ppp plugin now checks ppp authentication error and report it
to correct connman plugin.

scripts/libppp-plugin.c

index ba79db0..911551c 100644 (file)
@@ -45,6 +45,7 @@ static char *interface;
 static char *path;
 
 static DBusConnection *connection;
+static int prev_phase;
 
 char pppd_version[] = VERSION;
 
@@ -238,11 +239,18 @@ static void ppp_phase_change(void *data, int arg)
 {
        const char *reason = "disconnect";
        DBusMessage *msg;
+       int send_msg = 0;
 
        if (connection == NULL)
                return;
 
-       if (arg == PHASE_DEAD || arg == PHASE_DISCONNECT) {
+       if (prev_phase == PHASE_AUTHENTICATE &&
+                               arg == PHASE_TERMINATE) {
+               reason = "auth failed";
+               send_msg = 1;
+       }
+
+       if (send_msg > 0 || arg == PHASE_DEAD || arg == PHASE_DISCONNECT) {
                msg = dbus_message_new_method_call(busname, path,
                                                interface, "notify");
                if (msg == NULL)
@@ -259,6 +267,8 @@ static void ppp_phase_change(void *data, int arg)
 
                dbus_message_unref(msg);
        }
+
+       prev_phase = arg;
 }
 
 int plugin_init(void)