2

Where does nmcli and iwlist stored the cached list seen access points: in a common file or in volatile memory?

1 Answer 1

2

Quickly looking at the nmcli source code ($ apt-get source network-manager) it seems the structure containing the AP informations (src/devices/wifi/nm-wifi-ap.c) is stored on volatile memory (I am not sure if the structure is malloced or statically allocated but I would go for the former).

The structure is this one (actually there are two):

typedef struct {
char *supplicant_path;   /* D-Bus object path of this AP from wpa_supplicant */

/* Scanned or cached values */
GByteArray *       ssid;
char *             address;
NM80211Mode        mode;
guint8             strength;
guint32            freq;        /* Frequency in MHz; ie 2412 (== 2.412 GHz) */
guint32            max_bitrate; /* Maximum bitrate of the AP in Kbit/s (ie 54000 Kb/s == 54Mbit/s) */

NM80211ApFlags         flags;      /* General flags */
NM80211ApSecurityFlags wpa_flags;  /* WPA-related flags */
NM80211ApSecurityFlags rsn_flags;  /* RSN (WPA2) -related flags */

/* Non-scanned attributes */
bool                fake:1;       /* Whether or not the AP is from a scan */
bool                hotspot:1;    /* Whether the AP is a local device's hotspot network */
gint32              last_seen;  /* Timestamp when the AP was seen lastly (obtained via nm_utils_get_monotonic_timestamp_s()) */
} NMWifiAPPrivate;

struct _NMWifiAP {
    NMExportedObject parent;
    NMWifiAPPrivate _priv;
};

I have not digged the code deeply so I may be wrong, but I suppose this structure is allocated and fulfilled when we call nmcli device wifi list and then destroyed when the command exits. Maybe there are more complicated features which implies a 'save-state' in some sort of file or memory dump, but I cannot say right now.

I cannot say for iwlist (not actually looked at the code).

I would have posted this as a comment as it is not really an answer, but it is obviously too long.

UPDATE

Looking at nmcli github page, it states:

The NetworkManager daemon runs as a privileged service (since it must access and control hardware), but provides a D-Bus interface on the system bus to allow for fine-grained control of networking. NetworkManager does not store connections or settings, it is only the mechanism by which those connections are selected and activated.

To store pre-defined network connections, two separate services, the "system settings service" and the "user settings service" store connection information and provide these to NetworkManager, also via D-Bus. Each settings service can determine how and where it persistently stores the connection information; for example, the GNOME applet stores its configuration in GConf, and the system settings service stores it's config in distro-specific formats, or in a distro- agnostic format, depending on user/administrator preference.

1
  • So now I just need to dig into the code and find out where the list is loaded from, thanks :-)
    – Morten
    Sep 11, 2017 at 7:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .