Hi Dan,
Thanks a lot. It was great help. I got most of the things clear from
this mail. 

The things I want to work with is, 
Firstly, I want to check the available network connections (interfaces)
and then want to choose a particular connection/interface of my own as
the default connection, not the one by default provided by NM, (as
sometime I prefer other parameters 3G/satellite/wlan connections etc.
e.g. 3G connections are preferable than a satellite terminal connection
through Ethernet)

** So please let me know, how can I change the default route to a
particular connection (or interface eth0/wlan1/wlan2/pp0 etc.). I found
no such type of method in NM DBus Spec. I tried with 
org.freedesktop.NetworkManager-> ActivateConnection ( s: service_name,
o: connection, o: device, o: specific_object ) → o
by my own method call,  
    ni->activateConnection(activeCon.serviceName(),
activeCon.connection(), devicePath, activeCon.specificObject());

but it did not work as I expected. 
The Qt project folder with binary executable - nm, test source code -
main.cpp is dumped at http://folk.ntnu.no/ashraful/code/nm/

[> work like , "route delete default", then "route add default ..."]

I have tested with your tips and it works well. Got all the connections,
their corresponding interfaces and current default route. 
One deviance is that, when I deactivate a connection, the connection is
deactivated, shows in the small window, but NM runs again and establish
another connection with the same device. i.e. I have two WLAN, WLAN1 and
WLAN2, connection with WLAN2 is deactivated by dbus call, but the device
become again active. 

Regards,
Ashraf


On Tue, 2009-11-17 at 13:23 -0800, Dan Williams wrote:

> 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

Reply via email to