Re: [PATCH] gsm: pass the PPP auth preferences for STATIC and DHCP device use



On Mon, 2012-03-12 at 20:01 +0000, Andrew Bird wrote:
> When using the either DHCP or STATIC IpMethods the modem manager
> or device itself negotiates the PPP session so we need to pass
> the authentication preferences through to MM.
> 
> Notes:
> 	1/ Using a bitfield now that happens to match the Ericsson
> in the lower orders so that it's far more tidy.
> 	2/ Devices that wish to utilise this should observe the
> following:
> 	If the bitfield doesn't exist in the dict, then MM uses the
> modem default, if it does, MM tries to fulfill the request. If the
> modem can only accept one value (Qualcomm-type devices accept only
> None, PAP or CHAP with AT$QCPDPP) then MM picks the appropriate one
> from the dict if only one of PAP or CHAP was given, otherwise we
> default to PAP.

Pushed, thanks; changed the enum entries to be the actual bitfield
values themselves instead of the bit position though to be a bit
clearer.

Dan

> Signed-off-by: Andrew Bird <ajb spheresystems co uk>
> ---
>  src/modem-manager/nm-modem-gsm.c |   26 ++++++++++++++++++++++++++
>  1 files changed, 26 insertions(+), 0 deletions(-)
> 
> diff --git a/src/modem-manager/nm-modem-gsm.c b/src/modem-manager/nm-modem-gsm.c
> index 66b7ad9..37edd55 100644
> --- a/src/modem-manager/nm-modem-gsm.c
> +++ b/src/modem-manager/nm-modem-gsm.c
> @@ -62,6 +62,17 @@ typedef enum {
>      MM_MODEM_GSM_ALLOWED_MODE_LAST = MM_MODEM_GSM_ALLOWED_MODE_3G_ONLY
>  } MMModemGsmAllowedMode;
>  
> +typedef enum {
> +    /* bits 0..4 order match Ericsson device bitmap */
> +    MM_MODEM_GSM_ALLOWED_AUTH_NONE     = 0,
> +    MM_MODEM_GSM_ALLOWED_AUTH_PAP      = 1,
> +    MM_MODEM_GSM_ALLOWED_AUTH_CHAP     = 2,
> +    MM_MODEM_GSM_ALLOWED_AUTH_MSCHAP   = 3,
> +    MM_MODEM_GSM_ALLOWED_AUTH_MSCHAPV2 = 4,
> +    MM_MODEM_GSM_ALLOWED_AUTH_EAP      = 5,
> +
> +    MM_MODEM_GSM_ALLOWED_AUTH_LAST = MM_MODEM_GSM_ALLOWED_AUTH_EAP
> +} MMModemGsmAllowedAuth;
>  
>  G_DEFINE_TYPE (NMModemGsm, nm_modem_gsm, NM_TYPE_MODEM)
>  
> @@ -326,6 +337,7 @@ static GHashTable *
>  create_connect_properties (NMConnection *connection)
>  {
>  	NMSettingGsm *setting;
> +	NMSettingPPP *s_ppp;
>  	GHashTable *properties;
>  	const char *str;
>  
> @@ -384,6 +396,20 @@ create_connect_properties (NMConnection *connection)
>  	if (nm_setting_gsm_get_home_only (setting))
>  		value_hash_add_bool (properties, "home_only", TRUE);
>  
> +	/* For IpMethod == STATIC or DHCP */
> +	s_ppp = nm_connection_get_setting_ppp (connection);
> +	if (s_ppp) {
> +		guint32 auth = 0;
> +		auth |= (nm_setting_ppp_get_noauth (s_ppp) << MM_MODEM_GSM_ALLOWED_AUTH_NONE);
> +		auth |= ((!nm_setting_ppp_get_refuse_pap (s_ppp)) << MM_MODEM_GSM_ALLOWED_AUTH_PAP);
> +		auth |= ((!nm_setting_ppp_get_refuse_chap (s_ppp)) << MM_MODEM_GSM_ALLOWED_AUTH_CHAP);
> +		auth |= ((!nm_setting_ppp_get_refuse_mschap (s_ppp)) << MM_MODEM_GSM_ALLOWED_AUTH_MSCHAP);
> +		auth |= ((!nm_setting_ppp_get_refuse_mschapv2 (s_ppp)) << MM_MODEM_GSM_ALLOWED_AUTH_MSCHAPV2);
> +		auth |= ((!nm_setting_ppp_get_refuse_eap (s_ppp)) << MM_MODEM_GSM_ALLOWED_AUTH_EAP);
> +
> +		value_hash_add_uint (properties, "allowed_auth", auth);
> +	}
> +
>  	return properties;
>  }
>  




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]