atmodem: set the PPP authentication method to use
authorPhilip Paeps <philip@paeps.cx>
Thu, 19 Jun 2014 10:07:07 +0000 (12:07 +0200)
committerDenis Kenzior <denkenz@gmail.com>
Sat, 21 Jun 2014 17:02:51 +0000 (12:02 -0500)
drivers/atmodem/gprs-context.c

index 2217097..be44443 100644 (file)
@@ -59,6 +59,7 @@ enum state {
 struct gprs_context_data {
        GAtChat *chat;
        unsigned int active_context;
+       GAtPPPAuthMethod auth_method;
        char username[OFONO_GPRS_MAX_USERNAME_LENGTH + 1];
        char password[OFONO_GPRS_MAX_PASSWORD_LENGTH + 1];
        GAtPPP *ppp;
@@ -154,6 +155,7 @@ static gboolean setup_ppp(struct ofono_gprs_context *gc)
        if (getenv("OFONO_PPP_DEBUG"))
                g_at_ppp_set_debug(gcd->ppp, ppp_debug, "PPP");
 
+       g_at_ppp_set_auth_method(gcd->ppp, gcd->auth_method);
        g_at_ppp_set_credentials(gcd->ppp, gcd->username, gcd->password);
 
        /* set connect and disconnect callbacks */
@@ -243,6 +245,18 @@ static void at_gprs_activate_primary(struct ofono_gprs_context *gc,
        memcpy(gcd->username, ctx->username, sizeof(ctx->username));
        memcpy(gcd->password, ctx->password, sizeof(ctx->password));
 
+       /* We only support CHAP and PAP */
+       switch (ctx->auth_method) {
+       case OFONO_GPRS_AUTH_METHOD_CHAP:
+               gcd->auth_method = G_AT_PPP_AUTH_METHOD_CHAP;
+               break;
+       case OFONO_GPRS_AUTH_METHOD_PAP:
+               gcd->auth_method = G_AT_PPP_AUTH_METHOD_PAP;
+               break;
+       default:
+               goto error;
+       }
+
        gcd->state = STATE_ENABLING;
 
        if (gcd->vendor == OFONO_VENDOR_ZTE) {