Re: disable &/or activate wifi access point using libnm



On Thu, 2013-01-10 at 08:41 -0500, david feeney wrote:
> Dan,
> 
> Thank you very much for your response.  Please see my comments below.
> 
> 1) I was thinking that an Access Point (AP) is synonymous with SSID. 

There can be multiple Access Points that all use the same SSID and the
same security settings, and are all connected via Ethernet.  This is the
normal situation for deployments that need to cover more area than a
single AP has range to, like in companies and universities.

Think of it like a small cellular/mobile network: each AP is a base
station, and each laptop is the handset.  While in a call you can move
between base stations and your connection doesn't drop.  It's just that
WiFi is restricted to lower power, and can't cover as large an area as a
cellular base station because of that.

> 2) In my network environment, there are many different AP that I can
> connect to, all within view of each other.

Right; each SSID may be represented by an NMConnection object in
NetworkManager.  In reality, you'll only want a Connection for the WiFi
SSIDs you actually use.

> 3) There are even different AP with the same SSID, but different
> BSSID; I do not know what this means.

This is the situation I describe above, which provides seamless
connectivity over more area than a single AP can cover.  The client (ie,
NetworkManager, wpa_supplicant, and the kernel) will roam between access
points with the same SSID to maintain a connection.

Dan

> On Wed, Jan 9, 2013 at 4:45 PM, Dan Williams <dcbw redhat com> wrote:
>         On Wed, 2013-01-09 at 00:52 -0500, david feeney wrote:
>         > Hello,
>         >
>         > I have two questions:
>         >
>         > 1)  I would like to know how to disable an active Wifi
>         Access Point;
>         > I do not want to disable the device, just the disconnect the
>         Access
>         > Point.
>         
>         
>         You'd call the Disconnect() method of the Device object which
>         you'd like
>         to disconnect from the AP.  This places the device into
>         "manual" mode
>         where it will no longer autoconnect to any network unless it's
>         told to
>         connect via the D-Bus API.  This function is
>         nm_device_disconnect() in
>         libnm-glib.
>         
> I thought "device" would be the physical device and then I not be able
> to use it to "view" the available networks. 
> Manual mode sounds appropriate for this case. Then in Manual Mode I
> could direct it to connect to specific SSIDs? 
> Then to take it "out" of Manual mode I would issue "nm_device_new()"?
> 
> 
> Here is my situation, consider I have 3 SSID all in view at the same
> time, all of which I am able to connect to.
> 
> SSID1  <---- currently connected
> SSID2
> SSID3
> 
> case 1:  disconnect from SSID1, do not connect to any other SSID, but
> be able to connect any SSID at a later time.
> case 2: disconnect from SSID1 and connect to SSID2
> 
> And if I take it "out" of Manual mode it sounds like it is going to
> automatically re-connect to the last connected SSID;
> there is no way to "steer" it to connect to a different SSID.
> 
>  
>         You can also use the Manager object's DeactivateConnection()
>         method,
>         which will terminate the network connection and then proceed
>         to
>         determine the best available network to connect to, and
>         reconnect.
>         That's likely to be the exact same network you were just
>         connected to
>         however.  This function is nm_client_deactivate_connection()
>         in
>         libnm-glib.
>         
>         > for example, from the example get-ap-info-libnm-glib.c :
>         >
>         > ===================
>         >     /* Get active AP */
>         >     if (nm_device_get_state (device) ==
>         NM_DEVICE_STATE_ACTIVATED) {
>         >         if ((active_ap =
>         nm_device_wifi_get_active_access_point
>         > (NM_DEVICE_WIFI (device)))) {
>         >             active_ssid = nm_access_point_get_ssid
>         (active_ap);
>         >             active_ssid_str = nm_utils_ssid_to_utf8
>         (active_ssid);
>         >         }
>         >     }
>         > ===================
>         >
>         > How would I disable "active_ap"?
>         
>         
>         That code deals with a specific wifi AP; disconnecting from a
>         specific
>         wifi AP is likely not what you want (though it could be?).
>          Instead I
>         assume you want to disconnect from the wifi network which that
>         AP is a
>         part of (ie, disconnect from that SSID).  Is that correct?
>         
> I am a novice in this area, so please bear with me.  I though a wifi
> AP is a physical router and the SSID is just the Id of the router.
> The specific router just provides a different gateway to the WAN.
> 
> In my environment there are many AP (SSID/BSSID) that I can connect
> too.
> I just need to be able to pick which one; it may be the previous one
> or it may be a different one.
> 
> 
>  
>         If so, then the stuff I talked about above is how to do that.
>         
>         Disconnecting from a specific WiFi AP isn't something that's
>         generally
>         useful, though if that's what you're trying to do we can
>         discuss that
>         further.
>         
>         >
>         > 2)  Similarly,  how would I active a different Access_point
>         "xyz"?
>         
>         
>         Again, *access point* or wifi network (ie, SSID)?  If we're
>         talking
>         about wifi network (ie, SSID), then there needs to be a
>         Connection
>         object created for that.  Think of the Connection object as a
>         bundle of
>         properties that describe a network, including the SSID,
>         security
>         settings, etc.  This can be done either by:
>         
>         a) building up the connection manually (via
>         nm_connection_new(),
>         nm_connection_add_setting(), etc) and then calling
>         nm_remote_settings_add_connection() and finally
>         nm_client_activate_connection() on the returned object.
>         
>         b) calling nm_client_add_and_activate_connection() with object
>         path of
>         the NMAccessPoint object you'd like to use as a template for
>         the final
>         Connection.  This will create the new connection, save it to
>         disk, and
>         then attempt to connect to that wifi network.
>         
>         See add-connection-libnm-glib.c for (a), and for (b) see
>         http://git.gnome.org/browse/network-manager-applet/tree/src/applet.c in
>         conjunction with
>         http://git.gnome.org/browse/network-manager-applet/tree/src/applet-device-wifi.c#n401 .
>         
> 
> Thank you very much Dan, you have been very helpful and have given me
> a LOT to digest.
> 
> Let me try some of your suggestions and I think a solution will
> precipitate.
> 
> I do appreciate your time, thanks again.
> 
> Regards,
> 
> david 
> 
>         Dan
>         
> 




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