All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] gsmdial: add support for different authentication methods selection
@ 2021-01-01 21:12 s.e.golubtsov
  2021-01-04 17:18 ` Denis Kenzior
  0 siblings, 1 reply; 2+ messages in thread
From: s.e.golubtsov @ 2021-01-01 21:12 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 1802 bytes --]

From: Sergei Golubtsov <s.e.golubtsov@gmail.com>

Selection capability for authentication method via a command line
argument has been added
---
 gatchat/gsmdial.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/gatchat/gsmdial.c b/gatchat/gsmdial.c
index 60e4f245..0407f97c 100644
--- a/gatchat/gsmdial.c
+++ b/gatchat/gsmdial.c
@@ -53,6 +53,7 @@ static gint option_cid = 0;
 static gchar *option_apn = NULL;
 static gint option_offmode = 0;
 static gboolean option_legacy = FALSE;
+static gchar *option_auth_method;
 static gchar *option_username = NULL;
 static gchar *option_password = NULL;
 static gchar *option_pppdump = NULL;
@@ -369,6 +370,14 @@ static void connect_cb(gboolean ok, GAtResult *result, gpointer user_data)
 	}
 	g_at_ppp_set_debug(ppp, gsmdial_debug, "PPP");
 
+	GAtPPPAuthMethod auth_method = G_AT_PPP_AUTH_METHOD_CHAP;
+	if (strcmp(option_auth_method, "PAP") == 0) {
+		auth_method = G_AT_PPP_AUTH_METHOD_PAP;
+	} else if (strcmp(option_auth_method, "NONE") == 0) {
+		auth_method = G_AT_PPP_AUTH_METHOD_NONE;
+	}
+	g_at_ppp_set_auth_method(ppp, auth_method);
+
 	g_at_ppp_set_credentials(ppp, option_username, option_password);
 
 	g_at_ppp_set_acfc_enabled(ppp, option_acfc);
@@ -677,6 +686,10 @@ static GOptionEntry options[] = {
 				"Use ATD*99***<cid>#" },
 	{ "bluetooth", 'b', 0, G_OPTION_ARG_NONE, &option_bluetooth,
 				"Use only ATD*99" },
+	{ "auth", 'A', 0, G_OPTION_ARG_STRING, &option_auth_method,
+				"Specify the authentication method for the PPP"
+				" connection: CHAP, PAP or NONE. CHAP is used"
+				" by default." },
 	{ "username", 'u', 0, G_OPTION_ARG_STRING, &option_username,
 				"Specify PPP username" },
 	{ "password", 'w', 0, G_OPTION_ARG_STRING, &option_password,
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] gsmdial: add support for different authentication methods selection
  2021-01-01 21:12 [PATCH] gsmdial: add support for different authentication methods selection s.e.golubtsov
@ 2021-01-04 17:18 ` Denis Kenzior
  0 siblings, 0 replies; 2+ messages in thread
From: Denis Kenzior @ 2021-01-04 17:18 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 2564 bytes --]

Hi Sergei,

On 1/1/21 3:12 PM, s.e.golubtsov(a)gmail.com wrote:
> From: Sergei Golubtsov <s.e.golubtsov@gmail.com>
> 
> Selection capability for authentication method via a command line
> argument has been added
> ---
>   gatchat/gsmdial.c | 13 +++++++++++++
>   1 file changed, 13 insertions(+)
> 

denkenz(a)localhost ~/ofono-master $ make
make --no-print-directory all-am
   CC       gatchat/gsmdial.o
gatchat/gsmdial.c: In function ‘connect_cb’:
gatchat/gsmdial.c:373:2: error: ISO C90 forbids mixed declarations and code 
[-Werror=declaration-after-statement]
   373 |  GAtPPPAuthMethod auth_method = G_AT_PPP_AUTH_METHOD_CHAP;
       |  ^~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[1]: *** [Makefile:4078: gatchat/gsmdial.o] Error 1
make: *** [Makefile:2376: all] Error 2


> diff --git a/gatchat/gsmdial.c b/gatchat/gsmdial.c
> index 60e4f245..0407f97c 100644
> --- a/gatchat/gsmdial.c
> +++ b/gatchat/gsmdial.c
> @@ -53,6 +53,7 @@ static gint option_cid = 0;
>   static gchar *option_apn = NULL;
>   static gint option_offmode = 0;
>   static gboolean option_legacy = FALSE;
> +static gchar *option_auth_method;
>   static gchar *option_username = NULL;
>   static gchar *option_password = NULL;
>   static gchar *option_pppdump = NULL;
> @@ -369,6 +370,14 @@ static void connect_cb(gboolean ok, GAtResult *result, gpointer user_data)
>   	}
>   	g_at_ppp_set_debug(ppp, gsmdial_debug, "PPP");
>   
> +	GAtPPPAuthMethod auth_method = G_AT_PPP_AUTH_METHOD_CHAP;
> +	if (strcmp(option_auth_method, "PAP") == 0) {
> +		auth_method = G_AT_PPP_AUTH_METHOD_PAP;
> +	} else if (strcmp(option_auth_method, "NONE") == 0) {
> +		auth_method = G_AT_PPP_AUTH_METHOD_NONE;
> +	}
> +	g_at_ppp_set_auth_method(ppp, auth_method);
> +

Also please refer to doc/coding-style.txt item M1.

>   	g_at_ppp_set_credentials(ppp, option_username, option_password);
>   
>   	g_at_ppp_set_acfc_enabled(ppp, option_acfc);
> @@ -677,6 +686,10 @@ static GOptionEntry options[] = {
>   				"Use ATD*99***<cid>#" },
>   	{ "bluetooth", 'b', 0, G_OPTION_ARG_NONE, &option_bluetooth,
>   				"Use only ATD*99" },
> +	{ "auth", 'A', 0, G_OPTION_ARG_STRING, &option_auth_method,
> +				"Specify the authentication method for the PPP"
> +				" connection: CHAP, PAP or NONE. CHAP is used"
> +				" by default." },
>   	{ "username", 'u', 0, G_OPTION_ARG_STRING, &option_username,
>   				"Specify PPP username" },
>   	{ "password", 'w', 0, G_OPTION_ARG_STRING, &option_password,
> 

Regards,
-Denis

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-01-04 17:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-01 21:12 [PATCH] gsmdial: add support for different authentication methods selection s.e.golubtsov
2021-01-04 17:18 ` Denis Kenzior

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.