Re: How to add a plugin for NM



On Wed, 2010-03-24 at 09:59 +0800, Mu Qiao wrote:
> Wow, thanks. It's really helpful. I think I somehow know how to start.
> What I want to do is to make Gentoo work with NM, which now they can't
> work together.
> 
> There's one extra question. 
> I don't know clearly what features does ifcfg-rh or ifupdown provide.
> I think they can accept local configurations of hostname, DNS, ipv4
> wired and wireless network. Is there any other feature they provide? I
> could make a plan according to that. It is more helpful if you could
> estimate for me which are simpler or more difficult.

ifcfg-rh has very complete handling of both wifi and wired connections,
but not for PPP/3G or VPN.  ifcfg files are a <key>=<value> format so
they are pretty easy to parse, and one ifcfg file maps to one
NMConnection subclass.  So that's easy too.

I think if you support wired + wifi + ipv4/dhcp4 + ipv6+dhcp6 then
you'll be doing pretty well.  You can always extend from there.

NM also implements a fallback system so in
your /etc/NetworkManager/NetworkManager.conf
or /etc/NetworkManager/nm-system-settings.conf you'll see:

[main]
plugins=<your plugin>,keyfile

and if your plugin can't save the updated connection because it doesn't
support writing 3G for example, then keyfile will write it out and the
user doesn't get an error.

Dan

> Thanks again for your help :-)
> 
> On Wed, Mar 24, 2010 at 2:19 AM, Dan Williams <dcbw redhat com> wrote:
>         On Tue, 2010-03-23 at 20:55 +0800, Mu Qiao wrote:
>         > Hello,
>         >
>         > I need to develop a plugin for NM to read local
>         configuration files
>         > just like RH and Ubuntu do. (I'm not sure whether the plugin
>         is
>         > ifcfg-rh and ifupdown)
>         
>         
>         Great!
>         
>         > Where should I start? Where can I find documentations for
>         developing
>         > plugin and source code of ifcfg-rh and ifupdown?
>         
>         
>         The C interface is documented in:
>         
>         http://cgit.freede

>         sktop.org/NetworkManager/NetworkManager/tree/src/system-settings/nm-system-config-interface.h
>         
>         The 'keyfile' connection is probably the best example so far
>         as it's
>         most complete:
>         
>         http://cgit.freedesktop.org/NetworkManager/NetworkManager/tree/system-settings/plugins/keyfile
>         
>         But the ifcfg-suse plugin is actually the simplest one that
>         just
>         provides persistent hostname support.
>         
>         Basically, you have a GObject subclass that implements
>         NM_TYPE_SYSTEM_CONFIG_INTERFACE, which is the first link I
>         pasted.  That
>         implements the actual plugin, which has a number of properties
>         that
>         NetworkManager asks for like hostname and capabilities.
>         
>         That object then parses the config files, and for each
>         distinct saved
>         network "profile" or whatever on your distro, you create an
>         object
>         that's a subclass of NMSysconfigConnection as you can see in:
>         
>         http://cgit.freedesktop.org/NetworkManager/NetworkManager/tree/system-settings/plugins/keyfile/nm-keyfile-connection.h
>         
>         NMSysconfigConnection provides a number of helpful class
>         functions that
>         make your implementation a bit easier.  In any case, your
>         connection
>         subclass just wraps each distinct saved connection profile and
>         watches
>         that profile for changes.  The actual read/write work I
>         usually put into
>         separate files since they are easier to link into the unit
>         test
>         programs, plus the connection subclass can easily use them
>         anyway.
>         
>         If you need more pointers, let me know.  It does get somewhat
>         complicated when you do everything like reading and writing
>         connections,
>         but starting simple and expanding from there should be an
>         easier way to
>         go.
>         
>         Dan
>         
>         
> 
> 
> 
> -- 
> Best wishes,
> Qiao Mu




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