cli: use nm_access_point_get_bssid() instead of nm_access_point_get_hw_address()

nm_access_point_get_hw_address() is deprecated in 0.9.
Also change 'hwaddr' parameter for 'nmcli dev wifi list' to 'bssid'. 'hwaddr'
still works but is deprecated and not documented any more.
This commit is contained in:
Jiří Klimeš 2011-09-06 13:37:23 +02:00
parent 4bb50e4380
commit b7e853c362
3 changed files with 39 additions and 38 deletions

View file

@ -169,9 +169,9 @@ usage (void)
" list [id <id> | uuid <id>]\n"
" status\n"
#if WITH_WIMAX
" up id <id> | uuid <id> [iface <iface>] [ap <hwaddr>] [nsp <name>] [--nowait] [--timeout <timeout>]\n"
" up id <id> | uuid <id> [iface <iface>] [ap <BSSID>] [nsp <name>] [--nowait] [--timeout <timeout>]\n"
#else
" up id <id> | uuid <id> [iface <iface>] [ap <hwaddr>] [--nowait] [--timeout <timeout>]\n"
" up id <id> | uuid <id> [iface <iface>] [ap <BSSID>] [--nowait] [--timeout <timeout>]\n"
#endif
" down id <id> | uuid <id>\n"));
}
@ -1117,21 +1117,21 @@ find_device_for_connection (NmCli *nmc,
}
if (found_device && ap && !strcmp (con_type, "802-11-wireless") && NM_IS_DEVICE_WIFI (dev)) {
char *hwaddr_up = g_ascii_strup (ap, -1);
char *bssid_up = g_ascii_strup (ap, -1);
const GPtrArray *aps = nm_device_wifi_get_access_points (NM_DEVICE_WIFI (dev));
found_device = NULL; /* Mark as not found; set to the device again later, only if AP matches */
for (j = 0; aps && (j < aps->len); j++) {
NMAccessPoint *candidate_ap = g_ptr_array_index (aps, j);
const char *candidate_hwaddr = nm_access_point_get_hw_address (candidate_ap);
const char *candidate_bssid = nm_access_point_get_bssid (candidate_ap);
if (!strcmp (hwaddr_up, candidate_hwaddr)) {
if (!strcmp (bssid_up, candidate_bssid)) {
found_device = dev;
*spec_object = nm_object_get_path (NM_OBJECT (candidate_ap));
break;
}
}
g_free (hwaddr_up);
g_free (bssid_up);
}
#if WITH_WIMAX

View file

@ -262,7 +262,7 @@ usage (void)
" status\n"
" list [iface <iface>]\n"
" disconnect iface <iface> [--nowait] [--timeout <timeout>]\n"
" wifi [list [iface <iface>] [hwaddr <hwaddr>]]\n"
" wifi [list [iface <iface>] [bssid <BSSID>]]\n"
#if WITH_WIMAX
" wimax [list [iface <iface>] [nsp <name>]]\n\n"
#endif
@ -441,15 +441,15 @@ detail_access_point (gpointer data, gpointer user_data)
NM80211ApSecurityFlags wpa_flags, rsn_flags;
guint32 freq, bitrate;
guint8 strength;
const GByteArray *ssid;
const char *hwaddr;
const GByteArray *ssid;
const char *bssid;
NM80211Mode mode;
char *freq_str, *ssid_str, *bitrate_str, *strength_str, *wpa_flags_str, *rsn_flags_str;
GString *security_str;
char *ap_name;
if (info->active_bssid) {
const char *current_bssid = nm_access_point_get_hw_address (ap);
const char *current_bssid = nm_access_point_get_bssid (ap);
if (current_bssid && !strcmp (current_bssid, info->active_bssid))
active = TRUE;
}
@ -459,7 +459,7 @@ detail_access_point (gpointer data, gpointer user_data)
wpa_flags = nm_access_point_get_wpa_flags (ap);
rsn_flags = nm_access_point_get_rsn_flags (ap);
ssid = nm_access_point_get_ssid (ap);
hwaddr = nm_access_point_get_hw_address (ap);
bssid = nm_access_point_get_bssid (ap);
freq = nm_access_point_get_frequency (ap);
mode = nm_access_point_get_mode (ap);
bitrate = nm_access_point_get_max_bitrate (ap);
@ -497,7 +497,7 @@ detail_access_point (gpointer data, gpointer user_data)
ap_name = g_strdup_printf ("AP%d", info->index++); /* AP */
info->nmc->allowed_fields[0].value = ap_name;
info->nmc->allowed_fields[1].value = ssid_str;
info->nmc->allowed_fields[2].value = hwaddr;
info->nmc->allowed_fields[2].value = bssid;
info->nmc->allowed_fields[3].value = mode == NM_802_11_MODE_ADHOC ? _("Ad-Hoc") : mode == NM_802_11_MODE_INFRA ? _("Infrastructure") : _("Unknown");
info->nmc->allowed_fields[4].value = freq_str;
info->nmc->allowed_fields[5].value = bitrate_str;
@ -725,7 +725,7 @@ show_device_info (gpointer data, gpointer user_data)
if (!strcasecmp (nmc_fields_dev_list_sections[section_idx].name, nmc_fields_dev_list_sections[3].name)) {
if (state == NM_DEVICE_STATE_ACTIVATED) {
active_ap = nm_device_wifi_get_active_access_point (NM_DEVICE_WIFI (device));
active_bssid = active_ap ? nm_access_point_get_hw_address (active_ap) : NULL;
active_bssid = active_ap ? nm_access_point_get_bssid (active_ap) : NULL;
}
nmc->allowed_fields = nmc_fields_dev_wifi_list;
@ -1275,7 +1275,7 @@ show_acces_point_info (NMDevice *device, NmCli *nmc)
if (nm_device_get_state (device) == NM_DEVICE_STATE_ACTIVATED) {
active_ap = nm_device_wifi_get_active_access_point (NM_DEVICE_WIFI (device));
active_bssid = active_ap ? nm_access_point_get_hw_address (active_ap) : NULL;
active_bssid = active_ap ? nm_access_point_get_bssid (active_ap) : NULL;
}
info = g_malloc0 (sizeof (APInfo));
@ -1296,7 +1296,7 @@ do_device_wifi_list (NmCli *nmc, int argc, char **argv)
NMDevice *device = NULL;
NMAccessPoint *ap = NULL;
const char *iface = NULL;
const char *hwaddr_user = NULL;
const char *bssid_user = NULL;
const GPtrArray *devices;
const GPtrArray *aps;
APInfo *info;
@ -1316,13 +1316,14 @@ do_device_wifi_list (NmCli *nmc, int argc, char **argv)
goto error;
}
iface = *argv;
} else if (strcmp (*argv, "hwaddr") == 0) {
} else if (strcmp (*argv, "bssid") == 0 || strcmp (*argv, "hwaddr") == 0) {
/* hwaddr is deprecated and will be removed later */
if (next_arg (&argc, &argv) != 0) {
g_string_printf (nmc->return_text, _("Error: %s argument is missing."), *argv);
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
goto error;
}
hwaddr_user = *argv;
bssid_user = *argv;
} else {
fprintf (stderr, _("Unknown parameter: %s\n"), *argv);
}
@ -1392,21 +1393,21 @@ do_device_wifi_list (NmCli *nmc, int argc, char **argv)
}
if (NM_IS_DEVICE_WIFI (device)) {
if (hwaddr_user) {
if (bssid_user) {
/* Specific AP requested - list only that */
aps = nm_device_wifi_get_access_points (NM_DEVICE_WIFI (device));
for (j = 0; aps && (j < aps->len); j++) {
char *hwaddr_up;
char *bssid_up;
NMAccessPoint *candidate_ap = g_ptr_array_index (aps, j);
const char *candidate_hwaddr = nm_access_point_get_hw_address (candidate_ap);
const char *candidate_bssid = nm_access_point_get_bssid (candidate_ap);
hwaddr_up = g_ascii_strup (hwaddr_user, -1);
if (!strcmp (hwaddr_up, candidate_hwaddr))
bssid_up = g_ascii_strup (bssid_user, -1);
if (!strcmp (bssid_up, candidate_bssid))
ap = candidate_ap;
g_free (hwaddr_up);
g_free (bssid_up);
}
if (!ap) {
g_string_printf (nmc->return_text, _("Error: Access point with hwaddr '%s' not found."), hwaddr_user);
g_string_printf (nmc->return_text, _("Error: Access point with bssid '%s' not found."), bssid_user);
nmc->return_value = NMC_RESULT_ERROR_UNKNOWN;
goto error;
}
@ -1430,7 +1431,7 @@ do_device_wifi_list (NmCli *nmc, int argc, char **argv)
} else {
/* List APs for all devices */
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print header */
if (hwaddr_user) {
if (bssid_user) {
/* Specific AP requested - list only that */
for (i = 0; devices && (i < devices->len); i++) {
NMDevice *dev = g_ptr_array_index (devices, i);
@ -1440,12 +1441,12 @@ do_device_wifi_list (NmCli *nmc, int argc, char **argv)
aps = nm_device_wifi_get_access_points (NM_DEVICE_WIFI (dev));
for (j = 0; aps && (j < aps->len); j++) {
char *hwaddr_up;
char *bssid_up;
NMAccessPoint *candidate_ap = g_ptr_array_index (aps, j);
const char *candidate_hwaddr = nm_access_point_get_hw_address (candidate_ap);
const char *candidate_bssid = nm_access_point_get_bssid (candidate_ap);
hwaddr_up = g_ascii_strup (hwaddr_user, -1);
if (!strcmp (hwaddr_up, candidate_hwaddr)) {
bssid_up = g_ascii_strup (bssid_user, -1);
if (!strcmp (bssid_up, candidate_bssid)) {
ap = candidate_ap;
info = g_malloc0 (sizeof (APInfo));
@ -1456,11 +1457,11 @@ do_device_wifi_list (NmCli *nmc, int argc, char **argv)
detail_access_point (ap, info);
g_free (info);
}
g_free (hwaddr_up);
g_free (bssid_up);
}
}
if (!ap) {
g_string_printf (nmc->return_text, _("Error: Access point with hwaddr '%s' not found."), hwaddr_user);
g_string_printf (nmc->return_text, _("Error: Access point with bssid '%s' not found."), bssid_user);
nmc->return_value = NMC_RESULT_ERROR_UNKNOWN;
goto error;
}
@ -1667,7 +1668,7 @@ do_device_wimax_list (NmCli *nmc, int argc, char **argv)
}
}
if (!nsp) {
g_string_printf (nmc->return_text, _("Error: Access point with hwaddr '%s' not found."), nsp_user);
g_string_printf (nmc->return_text, _("Error: Access point with nsp '%s' not found."), nsp_user);
nmc->return_value = NMC_RESULT_ERROR_UNKNOWN;
goto error;
}

View file

@ -20,9 +20,9 @@
.\" Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111,
.\" USA.
.\"
.\" Copyright (C) 2010 Red Hat, Inc.
.\" Copyright (C) 2010 - 2011 Red Hat, Inc.
.\"
.TH NMCLI "1" "22 September 2010"
.TH NMCLI "1" "6 September 2011"
.SH NAME
nmcli \- command-line tool for controlling NetworkManager
@ -226,7 +226,7 @@ Print status of active connections.
No simple reference.
.fi
.TP
.B up id <id> | uuid <id> [iface <iface>] [ap <hwaddr>] [\-\-nowait] [\-\-timeout <timeout>]
.B up id <id> | uuid <id> [iface <iface>] [ap <BSSID>] [\-\-nowait] [\-\-timeout <timeout>]
.br
Activate a connection. The connection is identified by its name using \fIid\fP
or UUID using \fIuuid\fP. For requiring particular device to activate
@ -303,9 +303,9 @@ method: Disconnect
arguments: none
.fi
.TP
.B wifi [list [iface <iface>] [hwaddr <hwaddr>]]
.B wifi [list [iface <iface>] [bssid <BSSID>]]
.br
List available WiFi access points. \fIiface\fP and \fIhwaddr\fP options
List available WiFi access points. \fIiface\fP and \fIbssid\fP options
can be used to get just APs for particular interface or specific AP,
respectively.
.br
@ -329,7 +329,7 @@ or null.
.RE
Notes about localization:
.br
Be aware that \fInmcli\fP is localized and that's why the output depends on
Be aware that \fInmcli\fP is localized and that's why the output depends on
your environment. It's important to realize that especially when you parse the
output.
.br