On Mon, 2009-11-16 at 18:42 +0100, Syed Md. Ashraful Karim wrote: > Hi Lorn, > Thanks your very much for the link on Qt and NM Dbus wrapper > implementations. it saved my last weeks attempts to connect NM using > Qt. However, still I missed something, like finding routes/ip address > in the IP4Config interface, default gateway etc.
There's a few resources that can help you. The introspection data is what the NM DBus interface is directly constructed from. You can figure out the supported properties and methods there. http://cgit.freedesktop.org/NetworkManager/NetworkManager/tree/introspection The D-Bus specification is also constructed directly from the introspection data: http://projects.gnome.org/NetworkManager/developers/spec-08.html A description of how NM configuration and settings work is here: http://live.gnome.org/NetworkManagerConfiguration > Can you please help finding out, > - default gateway of each interface The IP4Config object provides you a list of IP addresses, and each address can have a gateway. For example, lets get the current active connection list: [d...@localhost ~]$ dbus-send --system --print-reply --dest=org.freedesktop.NetworkManager /org/freedesktop/NetworkManager org.freedesktop.DBus.Properties.Get string:org.freedesktop.NetworkManager string:ActiveConnections method return sender=:1.406 -> dest=:1.612 reply_serial=2 variant array [ object path "/org/freedesktop/NetworkManager/ActiveConnection/7" object path "/org/freedesktop/NetworkManager/ActiveConnection/8" ] And get the Devices property for the first active connection: [d...@localhost ~]$ dbus-send --system --print-reply --dest=org.freedesktop.NetworkManager /org/freedesktop/NetworkManager/ActiveConnection/7 org.freedesktop.DBus.Properties.Get string:org.freedesktop.NetworkManager.ActiveConnection string:Devices method return sender=:1.406 -> dest=:1.613 reply_serial=2 variant array [ object path "/org/freedesktop/NetworkManager/Devices/1" ] Great, we've got the active hardware device. Let's get it's IP4Config object: d...@localhost ~]$ dbus-send --system --print-reply --dest=org.freedesktop.NetworkManager /org/freedesktop/NetworkManager/Devices/1 org.freedesktop.DBus.Properties.Get string:org.freedesktop.NetworkManager.Device string:Ip4Config method return sender=:1.406 -> dest=:1.617 reply_serial=2 variant object path "/org/freedesktop/NetworkManager/IP4Config/4" Now, lets ask the IP4 config object what IP addresses it has: [d...@localhost ~]$ dbus-send --system --print-reply --dest=org.freedesktop.NetworkManager /org/freedesktop/NetworkManager/IP4Config/4 org.freedesktop.DBus.Properties.Get string:org.freedesktop.NetworkManager.IP4Config string:Addresses method return sender=:1.406 -> dest=:1.621 reply_serial=2 variant array [ array [ uint32 1711384768 uint32 24 uint32 16885952 ] ] from the D-Bus specification, we know the format of the reply. The 3rd uint32 is the that addresses gateway in network byte order. Most devices will only have one. But that is the gateway you're looking for. > - current default route of the system, and how can I change the > default route using NM Dbus, ( earlier i was calling command line tool > like, route add/delete default gw ... ). Now I want to do it by DBus > call to NM To change the default route, tell NetworkManager to activate another network connection that should have the default route that you want. What exactly are you trying to do? > - How to activate a particular interface (wlan0/eth0/ppp0). I cannot > use the following function in your class, how could I get these > parameters? is activateConnection means to set the default route to > that interface? or is there any way to set the default route to a > particular interface/ or its gateway? NetworkManager works on "Connection" objects, which describe all the settings needed to connect to a particular network. You tell NetworkManager to activate a certain connection, not a specific device. Connections can also apply to more than one device, or only to a specific device. Device names change and users can plug all sorts of devices into the system, so you almost never want to activate "eth0" because an ethernet device wont' always be eth0. Connections are stored by "settings services" (see NetworkManagerConfiguration linked to above). There are two of these; the user settings service, which is typically an applet running in the user's session, and a system settings service which is usually NetworkManager itself. So you tell NetworkManager to activate a connection provided by one of the two settings services. The D-Bus specification has more details on that as well in the description of the ActivateConnection method. Dan _______________________________________________ NetworkManager-list mailing list [email protected] http://mail.gnome.org/mailman/listinfo/networkmanager-list
