Re: How to add pppoe connection in NM plug-in
- From: Mu Qiao <qiaomuf gmail com>
- To: Dan Williams <dcbw redhat com>
- Cc: networkmanager-list gnome org
- Subject: Re: How to add pppoe connection in NM plug-in
- Date: Tue, 27 Apr 2010 08:15:23 +0800
On Tue, Apr 27, 2010 at 7:18 AM, Dan Williams <dcbw redhat com> wrote:
> On Mon, 2010-04-26 at 21:04 +0800, Mu Qiao wrote:
>> Hi dear Dan and all,
>> I've tried to find how to add pppoe connection in NM plug-in. But I
>> didn't find any example in existing plugin source code. Is there
>> anything I missed?
>
> The connection editor does add PPPoE. Note that until we fix a few
> things, PPPoE is only available on Ethernet (ie wired) devices, not yet
> on wifi. Making that work is fairly high on the to-do list.
>
>> Then I tried to write code in the way similar as adding a
>> wired_connection_setting as following:
>>
>> NMSettingPPPOE *s_pppoe;
>> gchar *value;
>> s_pppoe = NM_SETTING_PPPOE(nm_setting_pppoe_new());
>> //NM_SETTING_PPPOE_SERVICE NM_SETTING_PPPOE_USERNAME
>> NM_SETTING_PPPOE_PASSWORD
>> value = ifnet_getdata(block, "username");
>> if (!value) {
>> g_set_error(error, ifnet_plugin_error_quark(), 0,
>> "ppp requires at lease a username");
>> return;
>> }
>> g_object_set(s_pppoe, NM_SETTING_PPPOE_USERNAME, value, NULL);
>> value = ifnet_getdata(block, "password");
>> if (!value) {
>> value="";
>> }
>> g_object_set(s_pppoe, NM_SETTING_PPPOE_PASSWORD, value, NULL);
>> nm_connection_add_setting(connection, NM_SETTING(s_pppoe));
>>
>> Am I doing in the right way? Is there any other thing I should take
>> care of? Could please give me some direction.
>
> That looks mostly right, actually. But make sure to set the
> NMSettingConnection's 'type' property to NM_SETTING_PPPOE_SETTING_NAME.
>
> Try calling "nm_connection_verify()" on your final connection at some
> point. Does that return TRUE or FALSE, and if FALSE, what is the error
> that it returns?
>
> Dan
>
>
>
I set that property by:
g_object_set(setting,
NM_SETTING_CONNECTION_TYPE, type,
NM_SETTING_CONNECTION_ID, idstr,
NM_SETTING_CONNECTION_UUID, uuid,
NM_SETTING_CONNECTION_READ_ONLY, TRUE,
NM_SETTING_CONNECTION_AUTOCONNECT, FALSE, NULL);
(type is NM_SETTING_PPPOE_SETTING_NAME)
During setting building, there was no error detected. When I called
nm_connection_verify(), it returned FALSE. I printed the error by:
if (error && *error)
PLUGIN_PRINT("SCPlugin-Ifnet",
"Found error: %s", (*error)->message);
in /var/log/messages, the code above generated one line:
SCPlugin-Ifnet: Found error: (null)
To sum up the connection building code I've written:
nm_connection_add_setting(connection, NM_SETTING(setting));
g_object_set(setting,
NM_SETTING_CONNECTION_TYPE, type,
NM_SETTING_CONNECTION_ID, idstr,
NM_SETTING_CONNECTION_UUID, uuid,
NM_SETTING_CONNECTION_READ_ONLY, TRUE,
NM_SETTING_CONNECTION_AUTOCONNECT, FALSE, NULL);
g_object_set(s_pppoe, NM_SETTING_PPPOE_USERNAME, value, NULL);
g_object_set(s_pppoe, NM_SETTING_PPPOE_PASSWORD, value, NULL);
nm_connection_add_setting(connection, NM_SETTING(s_pppoe));
g_object_set(ip4_setting,
NM_SETTING_IP4_CONFIG_METHOD,
NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL);
nm_connection_add_setting(connection, NM_SETTING(ip4_setting));
success = nm_connection_verify(connection, error);
if (error && *error)
PLUGIN_PRINT("SCPlugin-Ifnet",
"Found error: %s", (*error)->message);
--
Best wishes,
Mu Qiao
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]