Re: Creating NetworkManager connections via DBus API



On Tue, 2014-07-08 at 05:55 +1000, Stuart Longland wrote:
Hi Dan,
On 08/07/14 02:55, Dan Williams wrote:
As thomas already mentioned, these should be covered in the API
documentation that he linked.  Note that IPv4 addresses are arrays of
uint32 (address/prefix/optional gateway) and IPv4 routes are too
(network/prefix/next-hop/metric).  The address/network/next-hop IP
address members are network-byte-order.  So the code in Python to push
that into the dict that can be sent over D-Bus is something like this,
taken from:
[...]
this is mainly because Python doesn't have strongly-typed variables, but
D-Bus does, so you have to tell Python what the mapping is between the
Python types and the D-Bus types.

Yep, just experimenting with python-networkmanager, it seems this is one
of the details it looks after: IP addresses are translated to strings,
endianness is taken care of, etc.  Dicts are plain Python dicts.

Just looking at the documentation there though, am I correct in assuming
that to set up a simple connection, you would have a dict of the form:

{'connection': { global connection settings },
 'ipv4': { IPv4 address settings },
 'ipv6': { IPv6 address settings },
}

and so the 'connection' bit would be mandatory, and you might have *one*
each of the other setting types?

The "type" setting (eg 803-3-ethernet, 802-11-wireless, gsm, cdma,
bluetooth, etc) is required too.  The 'type' setting and the
'connection' setting are the only required ones.  Usually you'd lock the
connection to a MAC address with the "type" setting, or it would contain
stuff like MTU, SSID, and other hardware-specific stuff, so you can't
really leave it out.

IPv4 and IPv6 are optional if you want automatic (DHCP, PPP/WWAN, etc)
addressing, but obviously if you want static you have to specify one or
both.

Dan



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