cli: add support for WiMAX devices and connections
This commit is contained in:
@@ -38,8 +38,10 @@
|
|||||||
#include <nm-setting-cdma.h>
|
#include <nm-setting-cdma.h>
|
||||||
#include <nm-setting-bluetooth.h>
|
#include <nm-setting-bluetooth.h>
|
||||||
#include <nm-setting-olpc-mesh.h>
|
#include <nm-setting-olpc-mesh.h>
|
||||||
|
#include <nm-setting-wimax.h>
|
||||||
#include <nm-device-ethernet.h>
|
#include <nm-device-ethernet.h>
|
||||||
#include <nm-device-wifi.h>
|
#include <nm-device-wifi.h>
|
||||||
|
#include <nm-device-wimax.h>
|
||||||
#include <nm-gsm-device.h>
|
#include <nm-gsm-device.h>
|
||||||
#include <nm-cdma-device.h>
|
#include <nm-cdma-device.h>
|
||||||
#include <nm-device-bt.h>
|
#include <nm-device-bt.h>
|
||||||
@@ -108,6 +110,7 @@ static NmcOutputField nmc_fields_settings_names[] = {
|
|||||||
SETTING_FIELD (NM_SETTING_BLUETOOTH_SETTING_NAME, 0), /* 12 */
|
SETTING_FIELD (NM_SETTING_BLUETOOTH_SETTING_NAME, 0), /* 12 */
|
||||||
SETTING_FIELD (NM_SETTING_OLPC_MESH_SETTING_NAME, 0), /* 13 */
|
SETTING_FIELD (NM_SETTING_OLPC_MESH_SETTING_NAME, 0), /* 13 */
|
||||||
SETTING_FIELD (NM_SETTING_VPN_SETTING_NAME, 0), /* 14 */
|
SETTING_FIELD (NM_SETTING_VPN_SETTING_NAME, 0), /* 14 */
|
||||||
|
SETTING_FIELD (NM_SETTING_WIMAX_SETTING_NAME, 0), /* 15 */
|
||||||
{NULL, NULL, 0, NULL, 0}
|
{NULL, NULL, 0, NULL, 0}
|
||||||
};
|
};
|
||||||
#define NMC_FIELDS_SETTINGS_NAMES_ALL NM_SETTING_CONNECTION_SETTING_NAME","\
|
#define NMC_FIELDS_SETTINGS_NAMES_ALL NM_SETTING_CONNECTION_SETTING_NAME","\
|
||||||
@@ -124,7 +127,8 @@ static NmcOutputField nmc_fields_settings_names[] = {
|
|||||||
NM_SETTING_CDMA_SETTING_NAME","\
|
NM_SETTING_CDMA_SETTING_NAME","\
|
||||||
NM_SETTING_BLUETOOTH_SETTING_NAME","\
|
NM_SETTING_BLUETOOTH_SETTING_NAME","\
|
||||||
NM_SETTING_OLPC_MESH_SETTING_NAME","\
|
NM_SETTING_OLPC_MESH_SETTING_NAME","\
|
||||||
NM_SETTING_VPN_SETTING_NAME
|
NM_SETTING_VPN_SETTING_NAME","\
|
||||||
|
NM_SETTING_WIMAX_SETTING_NAME
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@@ -143,7 +147,7 @@ static void quit (void);
|
|||||||
static void show_connection (NMConnection *data, gpointer user_data);
|
static void show_connection (NMConnection *data, gpointer user_data);
|
||||||
static NMConnection *find_connection (GSList *list, const char *filter_type, const char *filter_val);
|
static NMConnection *find_connection (GSList *list, const char *filter_type, const char *filter_val);
|
||||||
static gboolean find_device_for_connection (NmCli *nmc, NMConnection *connection, const char *iface, const char *ap,
|
static gboolean find_device_for_connection (NmCli *nmc, NMConnection *connection, const char *iface, const char *ap,
|
||||||
NMDevice **device, const char **spec_object, GError **error);
|
const char *nsp, NMDevice **device, const char **spec_object, GError **error);
|
||||||
static const char *active_connection_state_to_string (NMActiveConnectionState state);
|
static const char *active_connection_state_to_string (NMActiveConnectionState state);
|
||||||
static void active_connection_state_cb (NMActiveConnection *active, GParamSpec *pspec, gpointer user_data);
|
static void active_connection_state_cb (NMActiveConnection *active, GParamSpec *pspec, gpointer user_data);
|
||||||
static void activate_connection_cb (gpointer user_data, const char *path, GError *error);
|
static void activate_connection_cb (gpointer user_data, const char *path, GError *error);
|
||||||
@@ -161,7 +165,7 @@ usage (void)
|
|||||||
" COMMAND := { list | status | up | down }\n\n"
|
" COMMAND := { list | status | up | down }\n\n"
|
||||||
" list [id <id> | uuid <id> | system | user]\n"
|
" list [id <id> | uuid <id> | system | user]\n"
|
||||||
" status\n"
|
" status\n"
|
||||||
" up id <id> | uuid <id> [iface <iface>] [ap <hwaddr>] [--nowait] [--timeout <timeout>]\n"
|
" up id <id> | uuid <id> [iface <iface>] [ap <hwaddr>] [nsp <name>] [--nowait] [--timeout <timeout>]\n"
|
||||||
" down id <id> | uuid <id>\n"));
|
" down id <id> | uuid <id>\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -354,6 +358,15 @@ nmc_connection_detail (NMConnection *connection, NmCli *nmc)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!strcasecmp (nmc_fields_settings_names[section_idx].name, nmc_fields_settings_names[15].name)) {
|
||||||
|
setting = nm_connection_get_setting (connection, NM_TYPE_SETTING_WIMAX);
|
||||||
|
if (setting) {
|
||||||
|
setting_wimax_details (setting, nmc);
|
||||||
|
was_output = TRUE;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (print_settings_array)
|
if (print_settings_array)
|
||||||
@@ -885,6 +898,51 @@ check_olpc_mesh_compatible (NMDeviceOlpcMesh *device, NMConnection *connection,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
check_wimax_compatible (NMDeviceWimax *device, NMConnection *connection, GError **error)
|
||||||
|
{
|
||||||
|
NMSettingConnection *s_con;
|
||||||
|
NMSettingWimax *s_wimax;
|
||||||
|
const GByteArray *mac;
|
||||||
|
const char *device_mac_str;
|
||||||
|
struct ether_addr *device_mac = NULL;
|
||||||
|
|
||||||
|
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
||||||
|
|
||||||
|
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
|
||||||
|
g_assert (s_con);
|
||||||
|
|
||||||
|
if (strcmp (nm_setting_connection_get_connection_type (s_con), NM_SETTING_WIMAX_SETTING_NAME)) {
|
||||||
|
g_set_error (error, 0, 0,
|
||||||
|
"The connection was not a WiMAX connection.");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
s_wimax = NM_SETTING_WIMAX (nm_connection_get_setting (connection, NM_TYPE_SETTING_WIMAX));
|
||||||
|
if (!s_wimax) {
|
||||||
|
g_set_error (error, 0, 0,
|
||||||
|
"The connection was not a valid WiMAX connection.");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
device_mac_str = nm_device_wimax_get_hw_address (device);
|
||||||
|
if (device_mac_str)
|
||||||
|
device_mac = ether_aton (device_mac_str);
|
||||||
|
if (!device_mac) {
|
||||||
|
g_set_error (error, 0, 0, "Invalid device MAC address.");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
mac = nm_setting_wimax_get_mac_address (s_wimax);
|
||||||
|
if (mac && memcmp (mac->data, device_mac->ether_addr_octet, ETH_ALEN)) {
|
||||||
|
g_set_error (error, 0, 0,
|
||||||
|
"The connection's MAC address did not match this device.");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
nm_device_is_connection_compatible (NMDevice *device, NMConnection *connection, GError **error)
|
nm_device_is_connection_compatible (NMDevice *device, NMConnection *connection, GError **error)
|
||||||
{
|
{
|
||||||
@@ -899,6 +957,8 @@ nm_device_is_connection_compatible (NMDevice *device, NMConnection *connection,
|
|||||||
return check_bt_compatible (NM_DEVICE_BT (device), connection, error);
|
return check_bt_compatible (NM_DEVICE_BT (device), connection, error);
|
||||||
// else if (NM_IS_DEVICE_OLPC_MESH (device))
|
// else if (NM_IS_DEVICE_OLPC_MESH (device))
|
||||||
// return check_olpc_mesh_compatible (NM_DEVICE_OLPC_MESH (device), connection, error);
|
// return check_olpc_mesh_compatible (NM_DEVICE_OLPC_MESH (device), connection, error);
|
||||||
|
else if (NM_IS_DEVICE_WIMAX (device))
|
||||||
|
return check_wimax_compatible (NM_DEVICE_WIMAX (device), connection, error);
|
||||||
|
|
||||||
g_set_error (error, 0, 0, "unhandled device type '%s'", G_OBJECT_TYPE_NAME (device));
|
g_set_error (error, 0, 0, "unhandled device type '%s'", G_OBJECT_TYPE_NAME (device));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -989,13 +1049,20 @@ get_default_active_connection (NmCli *nmc, NMDevice **device)
|
|||||||
* IN: connection: connection to activate
|
* IN: connection: connection to activate
|
||||||
* iface: device interface name to use (optional)
|
* iface: device interface name to use (optional)
|
||||||
* ap: access point to use (optional; valid just for 802-11-wireless)
|
* ap: access point to use (optional; valid just for 802-11-wireless)
|
||||||
|
* nsp: Network Service Provider to use (option; valid only for wimax)
|
||||||
* OUT: device: found device
|
* OUT: device: found device
|
||||||
* spec_object: specific_object path of NMAccessPoint
|
* spec_object: specific_object path of NMAccessPoint
|
||||||
* RETURNS: TRUE when a device is found, FALSE otherwise.
|
* RETURNS: TRUE when a device is found, FALSE otherwise.
|
||||||
*/
|
*/
|
||||||
static gboolean
|
static gboolean
|
||||||
find_device_for_connection (NmCli *nmc, NMConnection *connection, const char *iface, const char *ap,
|
find_device_for_connection (NmCli *nmc,
|
||||||
NMDevice **device, const char **spec_object, GError **error)
|
NMConnection *connection,
|
||||||
|
const char *iface,
|
||||||
|
const char *ap,
|
||||||
|
const char *nsp,
|
||||||
|
NMDevice **device,
|
||||||
|
const char **spec_object,
|
||||||
|
GError **error)
|
||||||
{
|
{
|
||||||
NMSettingConnection *s_con;
|
NMSettingConnection *s_con;
|
||||||
const char *con_type;
|
const char *con_type;
|
||||||
@@ -1082,6 +1149,25 @@ find_device_for_connection (NmCli *nmc, NMConnection *connection, const char *if
|
|||||||
}
|
}
|
||||||
g_free (hwaddr_up);
|
g_free (hwaddr_up);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( found_device
|
||||||
|
&& nsp
|
||||||
|
&& !strcmp (con_type, NM_SETTING_WIMAX_SETTING_NAME)
|
||||||
|
&& NM_IS_DEVICE_WIMAX (dev)) {
|
||||||
|
const GPtrArray *nsps = nm_device_wimax_get_nsps (NM_DEVICE_WIMAX (dev));
|
||||||
|
found_device = NULL; /* Mark as not found; set to the device again later, only if NSP matches */
|
||||||
|
|
||||||
|
for (j = 0; nsps && (j < nsps->len); j++) {
|
||||||
|
NMWimaxNsp *candidate_nsp = g_ptr_array_index (nsps, j);
|
||||||
|
const char *candidate_name = nm_wimax_nsp_get_name (candidate_nsp);
|
||||||
|
|
||||||
|
if (!strcmp (nsp, candidate_name)) {
|
||||||
|
found_device = dev;
|
||||||
|
*spec_object = nm_object_get_path (NM_OBJECT (candidate_nsp));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (found_device) {
|
if (found_device) {
|
||||||
@@ -1324,6 +1410,7 @@ do_connection_up (NmCli *nmc, int argc, char **argv)
|
|||||||
const char *con_type;
|
const char *con_type;
|
||||||
const char *iface = NULL;
|
const char *iface = NULL;
|
||||||
const char *ap = NULL;
|
const char *ap = NULL;
|
||||||
|
const char *nsp = NULL;
|
||||||
gboolean id_specified = FALSE;
|
gboolean id_specified = FALSE;
|
||||||
gboolean wait = TRUE;
|
gboolean wait = TRUE;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
@@ -1371,6 +1458,15 @@ do_connection_up (NmCli *nmc, int argc, char **argv)
|
|||||||
|
|
||||||
ap = *argv;
|
ap = *argv;
|
||||||
}
|
}
|
||||||
|
else if (strcmp (*argv, "nsp") == 0) {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsp = *argv;
|
||||||
|
}
|
||||||
else if (strcmp (*argv, "--nowait") == 0) {
|
else if (strcmp (*argv, "--nowait") == 0) {
|
||||||
wait = FALSE;
|
wait = FALSE;
|
||||||
} else if (strcmp (*argv, "--timeout") == 0) {
|
} else if (strcmp (*argv, "--timeout") == 0) {
|
||||||
@@ -1412,7 +1508,7 @@ do_connection_up (NmCli *nmc, int argc, char **argv)
|
|||||||
g_assert (s_con);
|
g_assert (s_con);
|
||||||
con_type = nm_setting_connection_get_connection_type (s_con);
|
con_type = nm_setting_connection_get_connection_type (s_con);
|
||||||
|
|
||||||
device_found = find_device_for_connection (nmc, connection, iface, ap, &device, &spec_object, &error);
|
device_found = find_device_for_connection (nmc, connection, iface, ap, nsp, &device, &spec_object, &error);
|
||||||
|
|
||||||
if (!device_found) {
|
if (!device_found) {
|
||||||
if (error)
|
if (error)
|
||||||
|
@@ -29,7 +29,6 @@
|
|||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <glib/gi18n.h>
|
#include <glib/gi18n.h>
|
||||||
#include <nm-client.h>
|
#include <nm-client.h>
|
||||||
#include <nm-device-wifi.h>
|
|
||||||
|
|
||||||
#include <nm-client.h>
|
#include <nm-client.h>
|
||||||
#include <nm-device.h>
|
#include <nm-device.h>
|
||||||
@@ -39,6 +38,7 @@
|
|||||||
#include <nm-cdma-device.h>
|
#include <nm-cdma-device.h>
|
||||||
#include <nm-device-bt.h>
|
#include <nm-device-bt.h>
|
||||||
//#include <nm-device-olpc-mesh.h>
|
//#include <nm-device-olpc-mesh.h>
|
||||||
|
#include <nm-device-wimax.h>
|
||||||
#include <nm-utils.h>
|
#include <nm-utils.h>
|
||||||
#include <nm-setting-ip4-config.h>
|
#include <nm-setting-ip4-config.h>
|
||||||
#include <nm-setting-ip6-config.h>
|
#include <nm-setting-ip6-config.h>
|
||||||
@@ -51,6 +51,7 @@
|
|||||||
#include <nm-setting-cdma.h>
|
#include <nm-setting-cdma.h>
|
||||||
#include <nm-setting-bluetooth.h>
|
#include <nm-setting-bluetooth.h>
|
||||||
#include <nm-setting-olpc-mesh.h>
|
#include <nm-setting-olpc-mesh.h>
|
||||||
|
#include <nm-setting-wimax.h>
|
||||||
|
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "devices.h"
|
#include "devices.h"
|
||||||
@@ -75,14 +76,16 @@ static NmcOutputField nmc_fields_dev_list_sections[] = {
|
|||||||
{"WIFI-PROPERTIES", N_("WIFI-PROPERTIES"), 0, NULL, 0}, /* 2 */
|
{"WIFI-PROPERTIES", N_("WIFI-PROPERTIES"), 0, NULL, 0}, /* 2 */
|
||||||
{"AP", N_("AP"), 0, NULL, 0}, /* 3 */
|
{"AP", N_("AP"), 0, NULL, 0}, /* 3 */
|
||||||
{"WIRED-PROPERTIES", N_("WIRED-PROPERTIES"), 0, NULL, 0}, /* 4 */
|
{"WIRED-PROPERTIES", N_("WIRED-PROPERTIES"), 0, NULL, 0}, /* 4 */
|
||||||
{"IP4-SETTINGS", N_("IP4-SETTINGS"), 0, NULL, 0}, /* 5 */
|
{"WIMAX-PROPERTIES", N_("WIMAX-PROPERTIES"), 0, NULL, 0}, /* 5 */
|
||||||
{"IP4-DNS", N_("IP4-DNS"), 0, NULL, 0}, /* 6 */
|
{"NSP", N_("NSP"), 0, NULL, 0}, /* 6 */
|
||||||
{"IP6-SETTINGS", N_("IP6-SETTINGS"), 0, NULL, 0}, /* 7 */
|
{"IP4-SETTINGS", N_("IP4-SETTINGS"), 0, NULL, 0}, /* 7 */
|
||||||
{"IP6-DNS", N_("IP6-DNS"), 0, NULL, 0}, /* 8 */
|
{"IP4-DNS", N_("IP4-DNS"), 0, NULL, 0}, /* 8 */
|
||||||
|
{"IP6-SETTINGS", N_("IP6-SETTINGS"), 0, NULL, 0}, /* 9 */
|
||||||
|
{"IP6-DNS", N_("IP6-DNS"), 0, NULL, 0}, /* 10 */
|
||||||
{NULL, NULL, 0, NULL, 0}
|
{NULL, NULL, 0, NULL, 0}
|
||||||
};
|
};
|
||||||
#define NMC_FIELDS_DEV_LIST_SECTIONS_ALL "GENERAL,CAPABILITIES,WIFI-PROPERTIES,AP,WIRED-PROPERTIES,IP4-SETTINGS,IP4-DNS,IP6-SETTINGS,IP6-DNS"
|
#define NMC_FIELDS_DEV_LIST_SECTIONS_ALL "GENERAL,CAPABILITIES,WIFI-PROPERTIES,AP,WIRED-PROPERTIES,WIMAX-PROPERTIES,NSP,IP4-SETTINGS,IP4-DNS,IP6-SETTINGS,IP6-DNS"
|
||||||
#define NMC_FIELDS_DEV_LIST_SECTIONS_COMMON "GENERAL,CAPABILITIES,WIFI-PROPERTIES,AP,WIRED-PROPERTIES,IP4-SETTINGS,IP4-DNS,IP6-SETTINGS,IP6-DNS"
|
#define NMC_FIELDS_DEV_LIST_SECTIONS_COMMON "GENERAL,CAPABILITIES,WIFI-PROPERTIES,AP,WIRED-PROPERTIES,WIMAX-PROPERTIES,NSP,IP4-SETTINGS,IP4-DNS,IP6-SETTINGS,IP6-DNS"
|
||||||
|
|
||||||
/* Available fields for 'dev list' - GENERAL part */
|
/* Available fields for 'dev list' - GENERAL part */
|
||||||
static NmcOutputField nmc_fields_dev_list_general[] = {
|
static NmcOutputField nmc_fields_dev_list_general[] = {
|
||||||
@@ -130,6 +133,19 @@ static NmcOutputField nmc_fields_dev_list_wifi_prop[] = {
|
|||||||
#define NMC_FIELDS_DEV_LIST_WIFI_PROP_ALL "NAME,WEP,WPA,WPA2,TKIP,CCMP"
|
#define NMC_FIELDS_DEV_LIST_WIFI_PROP_ALL "NAME,WEP,WPA,WPA2,TKIP,CCMP"
|
||||||
#define NMC_FIELDS_DEV_LIST_WIFI_PROP_COMMON "NAME,WEP,WPA,WPA2,TKIP,CCMP"
|
#define NMC_FIELDS_DEV_LIST_WIFI_PROP_COMMON "NAME,WEP,WPA,WPA2,TKIP,CCMP"
|
||||||
|
|
||||||
|
/* Available fields for 'dev list' - wimax properties part */
|
||||||
|
static NmcOutputField nmc_fields_dev_list_wimax_prop[] = {
|
||||||
|
{"NAME", N_("NAME"), 18, NULL, 0}, /* 0 */
|
||||||
|
{"CTR-FREQ", N_("CTR-FREQ"), 7, NULL, 0}, /* 1 */
|
||||||
|
{"RSSI", N_("RSSI"), 5, NULL, 0}, /* 2 */
|
||||||
|
{"CINR", N_("CINR"), 5, NULL, 0}, /* 3 */
|
||||||
|
{"TX-POW", N_("TX-POW"), 5, NULL, 0}, /* 4 */
|
||||||
|
{"BSID", N_("BSID"), 18, NULL, 0}, /* 5 */
|
||||||
|
{NULL, NULL, 0, NULL, 0}
|
||||||
|
};
|
||||||
|
#define NMC_FIELDS_DEV_LIST_WIMAX_PROP_ALL "NAME,CTR-FREQ,RSSI,CINR,TX-POW,BSID"
|
||||||
|
#define NMC_FIELDS_DEV_LIST_WIMAX_PROP_COMMON "NAME,CTR-FREQ,RSSI,CINR,TX-POW,BSID"
|
||||||
|
|
||||||
/* Available fields for 'dev list' - IPv4 settings part */
|
/* Available fields for 'dev list' - IPv4 settings part */
|
||||||
static NmcOutputField nmc_fields_dev_list_ip4_settings[] = {
|
static NmcOutputField nmc_fields_dev_list_ip4_settings[] = {
|
||||||
{"NAME", N_("NAME"), 15, NULL, 0}, /* 0 */
|
{"NAME", N_("NAME"), 15, NULL, 0}, /* 0 */
|
||||||
@@ -191,6 +207,21 @@ static NmcOutputField nmc_fields_dev_wifi_list[] = {
|
|||||||
#define NMC_FIELDS_DEV_WIFI_LIST_COMMON "SSID,BSSID,MODE,FREQ,RATE,SIGNAL,SECURITY,ACTIVE"
|
#define NMC_FIELDS_DEV_WIFI_LIST_COMMON "SSID,BSSID,MODE,FREQ,RATE,SIGNAL,SECURITY,ACTIVE"
|
||||||
#define NMC_FIELDS_DEV_WIFI_LIST_FOR_DEV_LIST "NAME,"NMC_FIELDS_DEV_WIFI_LIST_COMMON
|
#define NMC_FIELDS_DEV_WIFI_LIST_FOR_DEV_LIST "NAME,"NMC_FIELDS_DEV_WIFI_LIST_COMMON
|
||||||
|
|
||||||
|
/* Available fields for 'dev wimax list' */
|
||||||
|
static NmcOutputField nmc_fields_dev_wimax_list[] = {
|
||||||
|
{"NAME", N_("NAME"), 15, NULL, 0}, /* 0 */
|
||||||
|
{"NSP", N_("NSP"), 33, NULL, 0}, /* 1 */
|
||||||
|
{"SIGNAL", N_("SIGNAL"), 8, NULL, 0}, /* 2 */
|
||||||
|
{"TYPE", N_("TYPE"), 16, NULL, 0}, /* 3 */
|
||||||
|
{"DEVICE", N_("DEVICE"), 10, NULL, 0}, /* 4 */
|
||||||
|
{"ACTIVE", N_("ACTIVE"), 8, NULL, 0}, /* 5 */
|
||||||
|
{"DBUS-PATH", N_("DBUS-PATH"), 46, NULL, 0}, /* 6 */
|
||||||
|
{NULL, NULL, 0, NULL, 0}
|
||||||
|
};
|
||||||
|
#define NMC_FIELDS_DEV_WIMAX_LIST_ALL "NSP,SIGNAL,TYPE,DEVICE,ACTIVE,DBUS-PATH"
|
||||||
|
#define NMC_FIELDS_DEV_WIMAX_LIST_COMMON "NSP,SIGNAL,TYPE,DEVICE,ACTIVE"
|
||||||
|
#define NMC_FIELDS_DEV_WIMAX_LIST_FOR_DEV_LIST "NAME,"NMC_FIELDS_DEV_WIMAX_LIST_COMMON
|
||||||
|
|
||||||
|
|
||||||
/* static function prototypes */
|
/* static function prototypes */
|
||||||
static void usage (void);
|
static void usage (void);
|
||||||
@@ -199,6 +230,7 @@ static NMCResultCode do_devices_status (NmCli *nmc, int argc, char **argv);
|
|||||||
static NMCResultCode do_devices_list (NmCli *nmc, int argc, char **argv);
|
static NMCResultCode do_devices_list (NmCli *nmc, int argc, char **argv);
|
||||||
static NMCResultCode do_device_disconnect (NmCli *nmc, int argc, char **argv);
|
static NMCResultCode do_device_disconnect (NmCli *nmc, int argc, char **argv);
|
||||||
static NMCResultCode do_device_wifi (NmCli *nmc, int argc, char **argv);
|
static NMCResultCode do_device_wifi (NmCli *nmc, int argc, char **argv);
|
||||||
|
static NMCResultCode do_device_wimax (NmCli *nmc, int argc, char **argv);
|
||||||
|
|
||||||
|
|
||||||
extern GMainLoop *loop; /* glib main loop variable */
|
extern GMainLoop *loop; /* glib main loop variable */
|
||||||
@@ -208,11 +240,12 @@ usage (void)
|
|||||||
{
|
{
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("Usage: nmcli dev { COMMAND | help }\n\n"
|
_("Usage: nmcli dev { COMMAND | help }\n\n"
|
||||||
" COMMAND := { status | list | disconnect | wifi }\n\n"
|
" COMMAND := { status | list | disconnect | wifi | wimax }\n\n"
|
||||||
" status\n"
|
" status\n"
|
||||||
" list [iface <iface>]\n"
|
" list [iface <iface>]\n"
|
||||||
" disconnect iface <iface> [--nowait] [--timeout <timeout>]\n"
|
" disconnect iface <iface> [--nowait] [--timeout <timeout>]\n"
|
||||||
" wifi [list [iface <iface>] [hwaddr <hwaddr>]]\n\n"));
|
" wifi [list [iface <iface>] [hwaddr <hwaddr>]]\n"
|
||||||
|
" wimax [list [iface <iface>] [nsp <name>]]\n\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* quit main loop */
|
/* quit main loop */
|
||||||
@@ -265,6 +298,8 @@ get_device_type (NMDevice * device)
|
|||||||
return NM_SETTING_BLUETOOTH_SETTING_NAME;
|
return NM_SETTING_BLUETOOTH_SETTING_NAME;
|
||||||
// else if (NM_IS_DEVICE_OLPC_MESH (device))
|
// else if (NM_IS_DEVICE_OLPC_MESH (device))
|
||||||
// return NM_SETTING_OLPC_MESH_SETTING_NAME;
|
// return NM_SETTING_OLPC_MESH_SETTING_NAME;
|
||||||
|
else if (NM_IS_DEVICE_WIMAX (device))
|
||||||
|
return NM_SETTING_WIMAX_SETTING_NAME;
|
||||||
else
|
else
|
||||||
return _("Unknown");
|
return _("Unknown");
|
||||||
}
|
}
|
||||||
@@ -447,6 +482,52 @@ detail_access_point (gpointer data, gpointer user_data)
|
|||||||
g_string_free (security_str, TRUE);
|
g_string_free (security_str, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
detail_wimax_nsp (NMWimaxNsp *nsp, NmCli *nmc, NMDevice *dev, int idx)
|
||||||
|
{
|
||||||
|
NMDeviceWimax *wimax = NM_DEVICE_WIMAX (dev);
|
||||||
|
char *nsp_name, *quality_str;
|
||||||
|
const char *ntype;
|
||||||
|
gboolean active = FALSE;
|
||||||
|
|
||||||
|
switch (nm_wimax_nsp_get_network_type (nsp)) {
|
||||||
|
case NM_WIMAX_NSP_NETWORK_TYPE_HOME:
|
||||||
|
ntype = _("Home");
|
||||||
|
break;
|
||||||
|
case NM_WIMAX_NSP_NETWORK_TYPE_PARTNER:
|
||||||
|
ntype = _("Partner");
|
||||||
|
break;
|
||||||
|
case NM_WIMAX_NSP_NETWORK_TYPE_ROAMING_PARTNER:
|
||||||
|
ntype = _("Roaming");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ntype = _("Unknown");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nm_device_get_state (dev) == NM_DEVICE_STATE_ACTIVATED) {
|
||||||
|
if (nsp == nm_device_wimax_get_active_nsp (wimax))
|
||||||
|
active = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
quality_str = g_strdup_printf ("%u", nm_wimax_nsp_get_signal_quality (nsp));
|
||||||
|
nsp_name = g_strdup_printf ("NSP%d", idx); /* NSP */
|
||||||
|
|
||||||
|
nmc->allowed_fields[0].value = nsp_name;
|
||||||
|
nmc->allowed_fields[1].value = nm_wimax_nsp_get_name (nsp);
|
||||||
|
nmc->allowed_fields[2].value = quality_str;
|
||||||
|
nmc->allowed_fields[3].value = ntype;
|
||||||
|
nmc->allowed_fields[4].value = nm_device_get_iface (dev);
|
||||||
|
nmc->allowed_fields[5].value = active ? _("yes") : _("no");
|
||||||
|
nmc->allowed_fields[6].value = nm_object_get_path (NM_OBJECT (nsp));
|
||||||
|
|
||||||
|
nmc->print_fields.flags &= ~NMC_PF_FLAG_MAIN_HEADER_ADD & ~NMC_PF_FLAG_MAIN_HEADER_ONLY & ~NMC_PF_FLAG_FIELD_NAMES; /* Clear header flags */
|
||||||
|
print_fields (nmc->print_fields, nmc->allowed_fields);
|
||||||
|
|
||||||
|
g_free (nsp_name);
|
||||||
|
g_free (quality_str);
|
||||||
|
}
|
||||||
|
|
||||||
struct cb_info {
|
struct cb_info {
|
||||||
NMClient *client;
|
NMClient *client;
|
||||||
const GPtrArray *active;
|
const GPtrArray *active;
|
||||||
@@ -523,6 +604,8 @@ show_device_info (gpointer data, gpointer user_data)
|
|||||||
hwaddr = nm_device_ethernet_get_hw_address (NM_DEVICE_ETHERNET (device));
|
hwaddr = nm_device_ethernet_get_hw_address (NM_DEVICE_ETHERNET (device));
|
||||||
else if (NM_IS_DEVICE_WIFI (device))
|
else if (NM_IS_DEVICE_WIFI (device))
|
||||||
hwaddr = nm_device_wifi_get_hw_address (NM_DEVICE_WIFI (device));
|
hwaddr = nm_device_wifi_get_hw_address (NM_DEVICE_WIFI (device));
|
||||||
|
else if (NM_IS_DEVICE_WIMAX (device))
|
||||||
|
hwaddr = nm_device_wimax_get_hw_address (NM_DEVICE_WIMAX (device));
|
||||||
|
|
||||||
nmc->allowed_fields[0].value = nmc_fields_dev_list_sections[0].name; /* "GENERAL"*/
|
nmc->allowed_fields[0].value = nmc_fields_dev_list_sections[0].name; /* "GENERAL"*/
|
||||||
nmc->allowed_fields[1].value = nm_device_get_iface (device);
|
nmc->allowed_fields[1].value = nm_device_get_iface (device);
|
||||||
@@ -633,6 +716,74 @@ show_device_info (gpointer data, gpointer user_data)
|
|||||||
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print values */
|
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print values */
|
||||||
was_output = TRUE;
|
was_output = TRUE;
|
||||||
}
|
}
|
||||||
|
} else if (NM_IS_DEVICE_WIMAX (device)) {
|
||||||
|
/* WIMAX-PROPERTIES */
|
||||||
|
if (!strcasecmp (nmc_fields_dev_list_sections[section_idx].name, nmc_fields_dev_list_sections[5].name)) {
|
||||||
|
char *cfreq = NULL, *rssi = NULL, *cinr = NULL, *txpow = NULL;
|
||||||
|
guint tmp_uint;
|
||||||
|
gint tmp_int;
|
||||||
|
const char *bsid;
|
||||||
|
|
||||||
|
nmc->allowed_fields = nmc_fields_dev_list_wimax_prop;
|
||||||
|
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_FIELD_NAMES;
|
||||||
|
nmc->print_fields.indices = parse_output_fields (NMC_FIELDS_DEV_LIST_WIMAX_PROP_ALL, nmc->allowed_fields, NULL);
|
||||||
|
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print header */
|
||||||
|
|
||||||
|
nmc->allowed_fields[0].value = nmc_fields_dev_list_sections[5].name; /* "WIMAX-PROPERTIES" */
|
||||||
|
|
||||||
|
/* Center frequency */
|
||||||
|
tmp_uint = nm_device_wimax_get_center_frequency (NM_DEVICE_WIMAX (device));
|
||||||
|
if (tmp_uint)
|
||||||
|
cfreq = g_strdup_printf ("%'.1f MHz", (double) tmp_uint / 1000.0);
|
||||||
|
nmc->allowed_fields[1].value = cfreq ? cfreq : "";
|
||||||
|
|
||||||
|
/* RSSI */
|
||||||
|
tmp_int = nm_device_wimax_get_rssi (NM_DEVICE_WIMAX (device));
|
||||||
|
if (tmp_int)
|
||||||
|
rssi = g_strdup_printf ("%d dBm", tmp_int);
|
||||||
|
nmc->allowed_fields[2].value = rssi ? rssi : "";
|
||||||
|
|
||||||
|
/* CINR */
|
||||||
|
tmp_int = nm_device_wimax_get_cinr (NM_DEVICE_WIMAX (device));
|
||||||
|
if (tmp_int)
|
||||||
|
cinr = g_strdup_printf ("%d dB", tmp_int);
|
||||||
|
nmc->allowed_fields[3].value = cinr ? cinr : "";
|
||||||
|
|
||||||
|
/* TX Power */
|
||||||
|
tmp_int = nm_device_wimax_get_tx_power (NM_DEVICE_WIMAX (device));
|
||||||
|
if (tmp_int)
|
||||||
|
txpow = g_strdup_printf ("%'.2f dBm", (float) tmp_int / 2.0);
|
||||||
|
nmc->allowed_fields[4].value = txpow ? txpow : "";
|
||||||
|
|
||||||
|
/* BSID */
|
||||||
|
bsid = nm_device_wimax_get_bsid (NM_DEVICE_WIMAX (device));
|
||||||
|
nmc->allowed_fields[5].value = bsid ? bsid : "";
|
||||||
|
|
||||||
|
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_SECTION_PREFIX;
|
||||||
|
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print values */
|
||||||
|
was_output = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* section NSP */
|
||||||
|
if (!strcasecmp (nmc_fields_dev_list_sections[section_idx].name, nmc_fields_dev_list_sections[6].name)) {
|
||||||
|
const GPtrArray *nsps;
|
||||||
|
int g, idx = 1;
|
||||||
|
|
||||||
|
nmc->allowed_fields = nmc_fields_dev_wimax_list;
|
||||||
|
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_FIELD_NAMES;
|
||||||
|
nmc->print_fields.indices = parse_output_fields (NMC_FIELDS_DEV_WIMAX_LIST_FOR_DEV_LIST, nmc->allowed_fields, NULL);
|
||||||
|
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print header */
|
||||||
|
|
||||||
|
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_SECTION_PREFIX;
|
||||||
|
|
||||||
|
nsps = nm_device_wimax_get_nsps (NM_DEVICE_WIMAX (device));
|
||||||
|
for (g = 0; nsps && g < nsps->len; g++) {
|
||||||
|
NMWimaxNsp *nsp = g_ptr_array_index (nsps, g);
|
||||||
|
|
||||||
|
detail_wimax_nsp (nsp, nmc, device, idx++);
|
||||||
|
}
|
||||||
|
was_output = TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* IP Setup info */
|
/* IP Setup info */
|
||||||
@@ -642,7 +793,7 @@ show_device_info (gpointer data, gpointer user_data)
|
|||||||
GSList *iter;
|
GSList *iter;
|
||||||
|
|
||||||
/* IP4-SETTINGS */
|
/* IP4-SETTINGS */
|
||||||
if (cfg4 && !strcasecmp (nmc_fields_dev_list_sections[section_idx].name, nmc_fields_dev_list_sections[5].name)) {
|
if (cfg4 && !strcasecmp (nmc_fields_dev_list_sections[section_idx].name, nmc_fields_dev_list_sections[7].name)) {
|
||||||
nmc->allowed_fields = nmc_fields_dev_list_ip4_settings;
|
nmc->allowed_fields = nmc_fields_dev_list_ip4_settings;
|
||||||
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_FIELD_NAMES;
|
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_FIELD_NAMES;
|
||||||
nmc->print_fields.indices = parse_output_fields (NMC_FIELDS_DEV_LIST_IP4_SETTINGS_ALL, nmc->allowed_fields, NULL);
|
nmc->print_fields.indices = parse_output_fields (NMC_FIELDS_DEV_LIST_IP4_SETTINGS_ALL, nmc->allowed_fields, NULL);
|
||||||
@@ -662,7 +813,7 @@ show_device_info (gpointer data, gpointer user_data)
|
|||||||
|
|
||||||
gateway_str = ip4_address_as_string (nm_ip4_address_get_gateway (addr));
|
gateway_str = ip4_address_as_string (nm_ip4_address_get_gateway (addr));
|
||||||
|
|
||||||
nmc->allowed_fields[0].value = nmc_fields_dev_list_sections[5].name; /* "IP4-SETTINGS" */
|
nmc->allowed_fields[0].value = nmc_fields_dev_list_sections[7].name; /* "IP4-SETTINGS" */
|
||||||
nmc->allowed_fields[1].value = addr_str;
|
nmc->allowed_fields[1].value = addr_str;
|
||||||
nmc->allowed_fields[2].value = prefix_str;
|
nmc->allowed_fields[2].value = prefix_str;
|
||||||
nmc->allowed_fields[3].value = gateway_str;
|
nmc->allowed_fields[3].value = gateway_str;
|
||||||
@@ -676,7 +827,7 @@ show_device_info (gpointer data, gpointer user_data)
|
|||||||
was_output = TRUE;
|
was_output = TRUE;
|
||||||
}
|
}
|
||||||
/* IP4-DNS */
|
/* IP4-DNS */
|
||||||
if (cfg4 && !strcasecmp (nmc_fields_dev_list_sections[section_idx].name, nmc_fields_dev_list_sections[6].name)) {
|
if (cfg4 && !strcasecmp (nmc_fields_dev_list_sections[section_idx].name, nmc_fields_dev_list_sections[8].name)) {
|
||||||
array = nm_ip4_config_get_nameservers (cfg4);
|
array = nm_ip4_config_get_nameservers (cfg4);
|
||||||
if (array) {
|
if (array) {
|
||||||
int i;
|
int i;
|
||||||
@@ -687,7 +838,7 @@ show_device_info (gpointer data, gpointer user_data)
|
|||||||
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print header */
|
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print header */
|
||||||
|
|
||||||
for (i = 0; i < array->len; i++) {
|
for (i = 0; i < array->len; i++) {
|
||||||
char *dns_name = g_strdup_printf ("%s%d", nmc_fields_dev_list_sections[6].name, i+1);
|
char *dns_name = g_strdup_printf ("%s%d", nmc_fields_dev_list_sections[8].name, i+1);
|
||||||
tmp = ip4_address_as_string (g_array_index (array, guint32, i));
|
tmp = ip4_address_as_string (g_array_index (array, guint32, i));
|
||||||
nmc->allowed_fields[0].value = dns_name; /* "IP4-DNS<num>" */
|
nmc->allowed_fields[0].value = dns_name; /* "IP4-DNS<num>" */
|
||||||
nmc->allowed_fields[1].value = tmp;
|
nmc->allowed_fields[1].value = tmp;
|
||||||
@@ -702,7 +853,7 @@ show_device_info (gpointer data, gpointer user_data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* IP6-SETTINGS */
|
/* IP6-SETTINGS */
|
||||||
if (cfg6 && !strcasecmp (nmc_fields_dev_list_sections[section_idx].name, nmc_fields_dev_list_sections[7].name)) {
|
if (cfg6 && !strcasecmp (nmc_fields_dev_list_sections[section_idx].name, nmc_fields_dev_list_sections[9].name)) {
|
||||||
nmc->allowed_fields = nmc_fields_dev_list_ip6_settings;
|
nmc->allowed_fields = nmc_fields_dev_list_ip6_settings;
|
||||||
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_FIELD_NAMES;
|
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_FIELD_NAMES;
|
||||||
nmc->print_fields.indices = parse_output_fields (NMC_FIELDS_DEV_LIST_IP6_SETTINGS_ALL, nmc->allowed_fields, NULL);
|
nmc->print_fields.indices = parse_output_fields (NMC_FIELDS_DEV_LIST_IP6_SETTINGS_ALL, nmc->allowed_fields, NULL);
|
||||||
@@ -718,7 +869,7 @@ show_device_info (gpointer data, gpointer user_data)
|
|||||||
prefix_str = g_strdup_printf ("%d", prefix);
|
prefix_str = g_strdup_printf ("%d", prefix);
|
||||||
gateway_str = ip6_address_as_string (nm_ip6_address_get_gateway (addr));
|
gateway_str = ip6_address_as_string (nm_ip6_address_get_gateway (addr));
|
||||||
|
|
||||||
nmc->allowed_fields[0].value = nmc_fields_dev_list_sections[7].name; /* "IP6-SETTINGS" */
|
nmc->allowed_fields[0].value = nmc_fields_dev_list_sections[9].name; /* "IP6-SETTINGS" */
|
||||||
nmc->allowed_fields[1].value = addr_str;
|
nmc->allowed_fields[1].value = addr_str;
|
||||||
nmc->allowed_fields[2].value = prefix_str;
|
nmc->allowed_fields[2].value = prefix_str;
|
||||||
nmc->allowed_fields[3].value = gateway_str;
|
nmc->allowed_fields[3].value = gateway_str;
|
||||||
@@ -732,7 +883,7 @@ show_device_info (gpointer data, gpointer user_data)
|
|||||||
was_output = TRUE;
|
was_output = TRUE;
|
||||||
}
|
}
|
||||||
/* IP6-DNS */
|
/* IP6-DNS */
|
||||||
if (cfg6 && !strcasecmp (nmc_fields_dev_list_sections[section_idx].name, nmc_fields_dev_list_sections[8].name)) {
|
if (cfg6 && !strcasecmp (nmc_fields_dev_list_sections[section_idx].name, nmc_fields_dev_list_sections[10].name)) {
|
||||||
int i = 1;
|
int i = 1;
|
||||||
nmc->allowed_fields = nmc_fields_dev_list_ip6_dns;
|
nmc->allowed_fields = nmc_fields_dev_list_ip6_dns;
|
||||||
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_FIELD_NAMES;
|
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_FIELD_NAMES;
|
||||||
@@ -740,7 +891,7 @@ show_device_info (gpointer data, gpointer user_data)
|
|||||||
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print header */
|
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print header */
|
||||||
|
|
||||||
for (iter = (GSList *) nm_ip6_config_get_nameservers (cfg6); iter; iter = g_slist_next (iter)) {
|
for (iter = (GSList *) nm_ip6_config_get_nameservers (cfg6); iter; iter = g_slist_next (iter)) {
|
||||||
char *dns_name = g_strdup_printf ("%s%d", nmc_fields_dev_list_sections[8].name, i++);
|
char *dns_name = g_strdup_printf ("%s%d", nmc_fields_dev_list_sections[10].name, i++);
|
||||||
|
|
||||||
tmp = ip6_address_as_string (iter->data);
|
tmp = ip6_address_as_string (iter->data);
|
||||||
nmc->allowed_fields[0].value = dns_name; /* "IP6-DNS<num>" */
|
nmc->allowed_fields[0].value = dns_name; /* "IP6-DNS<num>" */
|
||||||
@@ -1246,6 +1397,199 @@ do_device_wifi (NmCli *nmc, int argc, char **argv)
|
|||||||
return nmc->return_value;
|
return nmc->return_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
show_nsp_info (NMDevice *device, NmCli *nmc)
|
||||||
|
{
|
||||||
|
const GPtrArray *nsps;
|
||||||
|
int i, idx = 1;
|
||||||
|
|
||||||
|
nsps = nm_device_wimax_get_nsps (NM_DEVICE_WIMAX (device));
|
||||||
|
for (i = 0; nsps && i < nsps->len; i++) {
|
||||||
|
NMWimaxNsp *nsp = g_ptr_array_index (nsps, i);
|
||||||
|
|
||||||
|
detail_wimax_nsp (nsp, nmc, device, idx++);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static NMCResultCode
|
||||||
|
do_device_wimax_list (NmCli *nmc, int argc, char **argv)
|
||||||
|
{
|
||||||
|
GError *error = NULL;
|
||||||
|
NMDevice *device = NULL;
|
||||||
|
NMWimaxNsp *nsp = NULL;
|
||||||
|
const char *iface = NULL;
|
||||||
|
const char *nsp_user = NULL;
|
||||||
|
const GPtrArray *devices;
|
||||||
|
const GPtrArray *nsps;
|
||||||
|
int i, j;
|
||||||
|
char *fields_str;
|
||||||
|
char *fields_all = NMC_FIELDS_DEV_WIMAX_LIST_ALL;
|
||||||
|
char *fields_common = NMC_FIELDS_DEV_WIMAX_LIST_COMMON;
|
||||||
|
guint32 mode_flag = (nmc->print_output == NMC_PRINT_PRETTY) ? NMC_PF_FLAG_PRETTY : (nmc->print_output == NMC_PRINT_TERSE) ? NMC_PF_FLAG_TERSE : 0;
|
||||||
|
guint32 multiline_flag = nmc->multiline_output ? NMC_PF_FLAG_MULTILINE : 0;
|
||||||
|
guint32 escape_flag = nmc->escape_values ? NMC_PF_FLAG_ESCAPE : 0;
|
||||||
|
|
||||||
|
while (argc > 0) {
|
||||||
|
if (strcmp (*argv, "iface") == 0) {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
iface = *argv;
|
||||||
|
} else if (strcmp (*argv, "nsp") == 0) {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
nsp_user = *argv;
|
||||||
|
} else {
|
||||||
|
fprintf (stderr, _("Unknown parameter: %s\n"), *argv);
|
||||||
|
}
|
||||||
|
|
||||||
|
argc--;
|
||||||
|
argv++;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* create NMClient */
|
||||||
|
if (!nmc->get_client (nmc))
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
devices = nm_client_get_devices (nmc->client);
|
||||||
|
|
||||||
|
if (!nmc->required_fields || strcasecmp (nmc->required_fields, "common") == 0)
|
||||||
|
fields_str = fields_common;
|
||||||
|
else if (!nmc->required_fields || strcasecmp (nmc->required_fields, "all") == 0)
|
||||||
|
fields_str = fields_all;
|
||||||
|
else
|
||||||
|
fields_str = nmc->required_fields;
|
||||||
|
|
||||||
|
nmc->allowed_fields = nmc_fields_dev_wimax_list;
|
||||||
|
nmc->print_fields.indices = parse_output_fields (fields_str, nmc->allowed_fields, &error);
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
if (error->code == 0)
|
||||||
|
g_string_printf (nmc->return_text, _("Error: 'dev wimax': %s"), error->message);
|
||||||
|
else
|
||||||
|
g_string_printf (nmc->return_text, _("Error: 'dev wimax': %s; allowed fields: %s"), error->message, NMC_FIELDS_DEV_WIMAX_LIST_ALL);
|
||||||
|
g_error_free (error);
|
||||||
|
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_MAIN_HEADER_ADD | NMC_PF_FLAG_FIELD_NAMES;
|
||||||
|
nmc->print_fields.header_name = _("WiMAX NSP list");
|
||||||
|
|
||||||
|
if (iface) {
|
||||||
|
/* Device specified - list only NSPs of this interface */
|
||||||
|
for (i = 0; devices && (i < devices->len); i++) {
|
||||||
|
NMDevice *candidate = g_ptr_array_index (devices, i);
|
||||||
|
const char *dev_iface = nm_device_get_iface (candidate);
|
||||||
|
|
||||||
|
if (!strcmp (dev_iface, iface)) {
|
||||||
|
device = candidate;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!device) {
|
||||||
|
g_string_printf (nmc->return_text, _("Error: Device '%s' not found."), iface);
|
||||||
|
nmc->return_value = NMC_RESULT_ERROR_UNKNOWN;
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (NM_IS_DEVICE_WIMAX (device)) {
|
||||||
|
if (nsp_user) {
|
||||||
|
/* Specific NSP requested - list only that */
|
||||||
|
nsps = nm_device_wimax_get_nsps (NM_DEVICE_WIMAX (device));
|
||||||
|
for (j = 0, nsp = NULL; nsps && (j < nsps->len); j++) {
|
||||||
|
NMWimaxNsp *candidate_nsp = g_ptr_array_index (nsps, j);
|
||||||
|
const char *candidate_name = nm_wimax_nsp_get_name (candidate_nsp);
|
||||||
|
char *nsp_up;
|
||||||
|
|
||||||
|
nsp_up = g_ascii_strup (nsp_user, -1);
|
||||||
|
if (!strcmp (nsp_up, candidate_name))
|
||||||
|
nsp = candidate_nsp;
|
||||||
|
g_free (nsp_up);
|
||||||
|
}
|
||||||
|
if (!nsp) {
|
||||||
|
g_string_printf (nmc->return_text, _("Error: NSP with name '%s' not found."), nsp_user);
|
||||||
|
nmc->return_value = NMC_RESULT_ERROR_UNKNOWN;
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print header */
|
||||||
|
detail_wimax_nsp (nsp, nmc, device, 1);
|
||||||
|
} else {
|
||||||
|
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print header */
|
||||||
|
show_nsp_info (device, nmc);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
g_string_printf (nmc->return_text, _("Error: Device '%s' is not a WiMAX device."), iface);
|
||||||
|
nmc->return_value = NMC_RESULT_ERROR_UNKNOWN;
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/* List NSPs for all devices */
|
||||||
|
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print header */
|
||||||
|
if (nsp_user) {
|
||||||
|
/* Specific NSP requested - list only that */
|
||||||
|
for (i = 0; devices && (i < devices->len); i++) {
|
||||||
|
NMDevice *dev = g_ptr_array_index (devices, i);
|
||||||
|
int idx = 1;
|
||||||
|
|
||||||
|
if (!NM_IS_DEVICE_WIMAX (dev))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
nsps = nm_device_wimax_get_nsps (NM_DEVICE_WIMAX (dev));
|
||||||
|
for (j = 0, nsp = NULL; nsps && (j < nsps->len); j++) {
|
||||||
|
NMWimaxNsp *candidate_nsp = g_ptr_array_index (nsps, j);
|
||||||
|
const char *candidate_name = nm_wimax_nsp_get_name (candidate_nsp);
|
||||||
|
char *nsp_up;
|
||||||
|
|
||||||
|
nsp_up = g_ascii_strup (nsp_user, -1);
|
||||||
|
if (!strcmp (nsp_up, candidate_name)) {
|
||||||
|
nsp = candidate_nsp;
|
||||||
|
detail_wimax_nsp (nsp, nmc, dev, idx);
|
||||||
|
}
|
||||||
|
g_free (nsp_up);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!nsp) {
|
||||||
|
g_string_printf (nmc->return_text, _("Error: Access point with hwaddr '%s' not found."), nsp_user);
|
||||||
|
nmc->return_value = NMC_RESULT_ERROR_UNKNOWN;
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (i = 0; devices && (i < devices->len); i++) {
|
||||||
|
NMDevice *dev = g_ptr_array_index (devices, i);
|
||||||
|
if (NM_IS_DEVICE_WIMAX (dev))
|
||||||
|
show_nsp_info (dev, nmc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
error:
|
||||||
|
return nmc->return_value;
|
||||||
|
}
|
||||||
|
|
||||||
|
static NMCResultCode
|
||||||
|
do_device_wimax (NmCli *nmc, int argc, char **argv)
|
||||||
|
{
|
||||||
|
if (argc == 0)
|
||||||
|
nmc->return_value = do_device_wimax_list (nmc, argc-1, argv+1);
|
||||||
|
else if (argc > 0) {
|
||||||
|
if (matches (*argv, "list") == 0) {
|
||||||
|
nmc->return_value = do_device_wimax_list (nmc, argc-1, argv+1);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
g_string_printf (nmc->return_text, _("Error: 'dev wimax' command '%s' is not valid."), *argv);
|
||||||
|
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nmc->return_value;
|
||||||
|
}
|
||||||
|
|
||||||
NMCResultCode
|
NMCResultCode
|
||||||
do_devices (NmCli *nmc, int argc, char **argv)
|
do_devices (NmCli *nmc, int argc, char **argv)
|
||||||
@@ -1281,6 +1625,11 @@ do_devices (NmCli *nmc, int argc, char **argv)
|
|||||||
goto opt_error;
|
goto opt_error;
|
||||||
nmc->return_value = do_device_wifi (nmc, argc-1, argv+1);
|
nmc->return_value = do_device_wifi (nmc, argc-1, argv+1);
|
||||||
}
|
}
|
||||||
|
else if (matches (*argv, "wimax") == 0) {
|
||||||
|
if (!nmc_terse_option_check (nmc->print_output, nmc->required_fields, &error))
|
||||||
|
goto opt_error;
|
||||||
|
nmc->return_value = do_device_wimax (nmc, argc-1, argv+1);
|
||||||
|
}
|
||||||
else if (strcmp (*argv, "help") == 0) {
|
else if (strcmp (*argv, "help") == 0) {
|
||||||
usage ();
|
usage ();
|
||||||
}
|
}
|
||||||
|
@@ -39,13 +39,16 @@ static NmcOutputField nmc_fields_nm_status[] = {
|
|||||||
{"WIFI", N_("WIFI"), 10, NULL, 0}, /* 4 */
|
{"WIFI", N_("WIFI"), 10, NULL, 0}, /* 4 */
|
||||||
{"WWAN-HARDWARE", N_("WWAN-HARDWARE"), 15, NULL, 0}, /* 5 */
|
{"WWAN-HARDWARE", N_("WWAN-HARDWARE"), 15, NULL, 0}, /* 5 */
|
||||||
{"WWAN", N_("WWAN"), 10, NULL, 0}, /* 6 */
|
{"WWAN", N_("WWAN"), 10, NULL, 0}, /* 6 */
|
||||||
{NULL, NULL, 0, NULL, 0}
|
{"WIMAX-HARDWARE", N_("WIMAX-HARDWARE"), 15, NULL, 0}, /* 7 */
|
||||||
|
{"WIMAX", N_("WIMAX"), 10, NULL, 0}, /* 8 */
|
||||||
|
{NULL, NULL, 0, NULL, 0}
|
||||||
};
|
};
|
||||||
#define NMC_FIELDS_NM_STATUS_ALL "RUNNING,STATE,NET-ENABLED,WIFI-HARDWARE,WIFI,WWAN-HARDWARE,WWAN"
|
#define NMC_FIELDS_NM_STATUS_ALL "RUNNING,STATE,NET-ENABLED,WIFI-HARDWARE,WIFI,WWAN-HARDWARE,WWAN,WIMAX-HARDWARE,WIMAX"
|
||||||
#define NMC_FIELDS_NM_STATUS_COMMON "RUNNING,STATE,WIFI-HARDWARE,WIFI,WWAN-HARDWARE,WWAN"
|
#define NMC_FIELDS_NM_STATUS_COMMON "RUNNING,STATE,WIFI-HARDWARE,WIFI,WWAN-HARDWARE,WWAN"
|
||||||
#define NMC_FIELDS_NM_NET_ENABLED "NET-ENABLED"
|
#define NMC_FIELDS_NM_NET_ENABLED "NET-ENABLED"
|
||||||
#define NMC_FIELDS_NM_WIFI "WIFI"
|
#define NMC_FIELDS_NM_WIFI "WIFI"
|
||||||
#define NMC_FIELDS_NM_WWAN "WWAN"
|
#define NMC_FIELDS_NM_WWAN "WWAN"
|
||||||
|
#define NMC_FIELDS_NM_WIMAX "WIMAX"
|
||||||
|
|
||||||
|
|
||||||
extern GMainLoop *loop;
|
extern GMainLoop *loop;
|
||||||
@@ -62,12 +65,13 @@ usage (void)
|
|||||||
{
|
{
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("Usage: nmcli nm { COMMAND | help }\n\n"
|
_("Usage: nmcli nm { COMMAND | help }\n\n"
|
||||||
" COMMAND := { status | enable | sleep | wifi | wwan }\n\n"
|
" COMMAND := { status | enable | sleep | wifi | wwan | wimax }\n\n"
|
||||||
" status\n"
|
" status\n"
|
||||||
" enable [true|false]\n"
|
" enable [true|false]\n"
|
||||||
" sleep [true|false]\n"
|
" sleep [true|false]\n"
|
||||||
" wifi [on|off]\n"
|
" wifi [on|off]\n"
|
||||||
" wwan [on|off]\n\n"));
|
" wwan [on|off]\n"
|
||||||
|
" wimax [on|off]\n\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* quit main loop */
|
/* quit main loop */
|
||||||
@@ -103,6 +107,7 @@ show_nm_status (NmCli *nmc)
|
|||||||
NMState state;
|
NMState state;
|
||||||
const char *wireless_hw_enabled_str, *wireless_enabled_str;
|
const char *wireless_hw_enabled_str, *wireless_enabled_str;
|
||||||
const char *wwan_hw_enabled_str, *wwan_enabled_str;
|
const char *wwan_hw_enabled_str, *wwan_enabled_str;
|
||||||
|
const char *wimax_hw_enabled_str, *wimax_enabled_str;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
const char *fields_str;
|
const char *fields_str;
|
||||||
const char *fields_all = NMC_FIELDS_NM_STATUS_ALL;
|
const char *fields_all = NMC_FIELDS_NM_STATUS_ALL;
|
||||||
@@ -145,8 +150,10 @@ show_nm_status (NmCli *nmc)
|
|||||||
wireless_enabled_str = nm_client_wireless_get_enabled (nmc->client) ? _("enabled") : _("disabled");
|
wireless_enabled_str = nm_client_wireless_get_enabled (nmc->client) ? _("enabled") : _("disabled");
|
||||||
wwan_hw_enabled_str = nm_client_wwan_hardware_get_enabled (nmc->client) ? _("enabled") : _("disabled");
|
wwan_hw_enabled_str = nm_client_wwan_hardware_get_enabled (nmc->client) ? _("enabled") : _("disabled");
|
||||||
wwan_enabled_str = nm_client_wwan_get_enabled (nmc->client) ? _("enabled") : _("disabled");
|
wwan_enabled_str = nm_client_wwan_get_enabled (nmc->client) ? _("enabled") : _("disabled");
|
||||||
|
wimax_hw_enabled_str = nm_client_wimax_hardware_get_enabled (nmc->client) ? _("enabled") : _("disabled");
|
||||||
|
wimax_enabled_str = nm_client_wimax_get_enabled (nmc->client) ? _("enabled") : _("disabled");
|
||||||
} else {
|
} else {
|
||||||
wireless_hw_enabled_str = wireless_enabled_str = wwan_hw_enabled_str = wwan_enabled_str = _("unknown");
|
wireless_hw_enabled_str = wireless_enabled_str = wwan_hw_enabled_str = wwan_enabled_str = wimax_hw_enabled_str = wimax_enabled_str = _("unknown");
|
||||||
}
|
}
|
||||||
|
|
||||||
nmc->allowed_fields[0].value = nm_running ? _("running") : _("not running");
|
nmc->allowed_fields[0].value = nm_running ? _("running") : _("not running");
|
||||||
@@ -156,6 +163,8 @@ show_nm_status (NmCli *nmc)
|
|||||||
nmc->allowed_fields[4].value = wireless_enabled_str;
|
nmc->allowed_fields[4].value = wireless_enabled_str;
|
||||||
nmc->allowed_fields[5].value = wwan_hw_enabled_str;
|
nmc->allowed_fields[5].value = wwan_hw_enabled_str;
|
||||||
nmc->allowed_fields[6].value = wwan_enabled_str;
|
nmc->allowed_fields[6].value = wwan_enabled_str;
|
||||||
|
nmc->allowed_fields[7].value = wimax_hw_enabled_str;
|
||||||
|
nmc->allowed_fields[8].value = wimax_enabled_str;
|
||||||
|
|
||||||
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag;
|
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag;
|
||||||
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print values */
|
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print values */
|
||||||
@@ -208,6 +217,7 @@ do_network_manager (NmCli *nmc, int argc, char **argv)
|
|||||||
gboolean enable_net;
|
gboolean enable_net;
|
||||||
gboolean enable_wifi;
|
gboolean enable_wifi;
|
||||||
gboolean enable_wwan;
|
gboolean enable_wwan;
|
||||||
|
gboolean enable_wimax;
|
||||||
guint32 mode_flag = (nmc->print_output == NMC_PRINT_PRETTY) ? NMC_PF_FLAG_PRETTY : (nmc->print_output == NMC_PRINT_TERSE) ? NMC_PF_FLAG_TERSE : 0;
|
guint32 mode_flag = (nmc->print_output == NMC_PRINT_PRETTY) ? NMC_PF_FLAG_PRETTY : (nmc->print_output == NMC_PRINT_TERSE) ? NMC_PF_FLAG_TERSE : 0;
|
||||||
guint32 multiline_flag = nmc->multiline_output ? NMC_PF_FLAG_MULTILINE : 0;
|
guint32 multiline_flag = nmc->multiline_output ? NMC_PF_FLAG_MULTILINE : 0;
|
||||||
guint32 escape_flag = nmc->escape_values ? NMC_PF_FLAG_ESCAPE : 0;
|
guint32 escape_flag = nmc->escape_values ? NMC_PF_FLAG_ESCAPE : 0;
|
||||||
@@ -341,6 +351,38 @@ do_network_manager (NmCli *nmc, int argc, char **argv)
|
|||||||
nm_client_wwan_set_enabled (nmc->client, enable_wwan);
|
nm_client_wwan_set_enabled (nmc->client, enable_wwan);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (matches (*argv, "wimax") == 0) {
|
||||||
|
if (next_arg (&argc, &argv) != 0) {
|
||||||
|
if (!nmc_terse_option_check (nmc->print_output, nmc->required_fields, &error))
|
||||||
|
goto opt_error;
|
||||||
|
/* no argument, show current WiMAX state */
|
||||||
|
if (nmc->required_fields && strcasecmp (nmc->required_fields, "WIMAX")) {
|
||||||
|
g_string_printf (nmc->return_text, _("Error: '--fields' value '%s' is not valid here; allowed fields: %s"),
|
||||||
|
nmc->required_fields, NMC_FIELDS_NM_WIMAX);
|
||||||
|
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
nmc->allowed_fields = nmc_fields_nm_status;
|
||||||
|
nmc->print_fields.indices = parse_output_fields (NMC_FIELDS_NM_WIMAX, nmc->allowed_fields, NULL);
|
||||||
|
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_MAIN_HEADER_ADD | NMC_PF_FLAG_FIELD_NAMES;
|
||||||
|
nmc->print_fields.header_name = _("WiMAX enabled");
|
||||||
|
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print header */
|
||||||
|
nmc->allowed_fields[8].value = nm_client_wimax_get_enabled (nmc->client) ? _("enabled") : _("disabled");
|
||||||
|
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag;
|
||||||
|
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print header */
|
||||||
|
} else {
|
||||||
|
if (!strcmp (*argv, "on"))
|
||||||
|
enable_wimax = TRUE;
|
||||||
|
else if (!strcmp (*argv, "off"))
|
||||||
|
enable_wimax = FALSE;
|
||||||
|
else {
|
||||||
|
g_string_printf (nmc->return_text, _("Error: invalid 'wimax' parameter: '%s'."), *argv);
|
||||||
|
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
nm_client_wimax_set_enabled (nmc->client, enable_wimax);
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (strcmp (*argv, "help") == 0) {
|
else if (strcmp (*argv, "help") == 0) {
|
||||||
usage ();
|
usage ();
|
||||||
}
|
}
|
||||||
|
@@ -402,6 +402,18 @@ static NmcOutputField nmc_fields_setting_vpn[] = {
|
|||||||
NM_SETTING_VPN_SECRETS
|
NM_SETTING_VPN_SECRETS
|
||||||
#define NMC_FIELDS_SETTING_VPN_COMMON NMC_FIELDS_SETTING_VPN_ALL
|
#define NMC_FIELDS_SETTING_VPN_COMMON NMC_FIELDS_SETTING_VPN_ALL
|
||||||
|
|
||||||
|
/* Available fields for NM_SETTING_WIMAX_SETTING_NAME */
|
||||||
|
static NmcOutputField nmc_fields_setting_wimax[] = {
|
||||||
|
SETTING_FIELD ("name", 6), /* 0 */
|
||||||
|
SETTING_FIELD (NM_SETTING_WIMAX_MAC_ADDRESS, 19), /* 1 */
|
||||||
|
SETTING_FIELD (NM_SETTING_WIMAX_NETWORK_NAME, 40), /* 2 */
|
||||||
|
{NULL, NULL, 0, NULL, 0}
|
||||||
|
};
|
||||||
|
#define NMC_FIELDS_SETTING_WIMAX_ALL "name"","\
|
||||||
|
NM_SETTING_WIMAX_MAC_ADDRESS","\
|
||||||
|
NM_SETTING_WIMAX_NETWORK_NAME
|
||||||
|
#define NMC_FIELDS_SETTING_WIMAX_COMMON NMC_FIELDS_SETTING_WIMAX_ALL
|
||||||
|
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
wep_key_type_to_string (NMWepKeyType type)
|
wep_key_type_to_string (NMWepKeyType type)
|
||||||
@@ -1381,3 +1393,37 @@ setting_vpn_details (NMSetting *setting, NmCli *nmc)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
setting_wimax_details (NMSetting *setting, NmCli *nmc)
|
||||||
|
{
|
||||||
|
NMSettingWimax *s_wimax;
|
||||||
|
const GByteArray *mac;
|
||||||
|
char *device_mac_str = NULL;
|
||||||
|
guint32 mode_flag = (nmc->print_output == NMC_PRINT_PRETTY) ? NMC_PF_FLAG_PRETTY : (nmc->print_output == NMC_PRINT_TERSE) ? NMC_PF_FLAG_TERSE : 0;
|
||||||
|
guint32 multiline_flag = nmc->multiline_output ? NMC_PF_FLAG_MULTILINE : 0;
|
||||||
|
guint32 escape_flag = nmc->escape_values ? NMC_PF_FLAG_ESCAPE : 0;
|
||||||
|
|
||||||
|
g_return_val_if_fail (NM_IS_SETTING_WIMAX (setting), FALSE);
|
||||||
|
s_wimax = (NMSettingWimax *) setting;
|
||||||
|
|
||||||
|
nmc->allowed_fields = nmc_fields_setting_wimax;
|
||||||
|
nmc->print_fields.indices = parse_output_fields (NMC_FIELDS_SETTING_WIMAX_ALL, nmc->allowed_fields, NULL);
|
||||||
|
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_FIELD_NAMES;
|
||||||
|
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print field names */
|
||||||
|
|
||||||
|
mac = nm_setting_wimax_get_mac_address (s_wimax);
|
||||||
|
if (mac)
|
||||||
|
device_mac_str = g_strdup_printf ("%02X:%02X:%02X:%02X:%02X:%02X", mac->data[0], mac->data[1], mac->data[2], mac->data[3], mac->data[4], mac->data[5]);
|
||||||
|
|
||||||
|
nmc->allowed_fields[0].value = NM_SETTING_WIMAX_SETTING_NAME;
|
||||||
|
nmc->allowed_fields[1].value = device_mac_str;
|
||||||
|
nmc->allowed_fields[2].value = nm_setting_wimax_get_network_name (s_wimax);
|
||||||
|
|
||||||
|
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_SECTION_PREFIX;
|
||||||
|
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print values */
|
||||||
|
|
||||||
|
g_free (device_mac_str);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -35,6 +35,7 @@
|
|||||||
#include <nm-setting-bluetooth.h>
|
#include <nm-setting-bluetooth.h>
|
||||||
#include <nm-setting-olpc-mesh.h>
|
#include <nm-setting-olpc-mesh.h>
|
||||||
#include <nm-setting-vpn.h>
|
#include <nm-setting-vpn.h>
|
||||||
|
#include <nm-setting-wimax.h>
|
||||||
|
|
||||||
#include "nmcli.h"
|
#include "nmcli.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
@@ -55,5 +56,6 @@ gboolean setting_cdma_details (NMSetting *setting, NmCli *nmc);
|
|||||||
gboolean setting_bluetooth_details (NMSetting *setting, NmCli *nmc);
|
gboolean setting_bluetooth_details (NMSetting *setting, NmCli *nmc);
|
||||||
gboolean setting_olpc_mesh_details (NMSetting *setting, NmCli *nmc);
|
gboolean setting_olpc_mesh_details (NMSetting *setting, NmCli *nmc);
|
||||||
gboolean setting_vpn_details (NMSetting *setting, NmCli *nmc);
|
gboolean setting_vpn_details (NMSetting *setting, NmCli *nmc);
|
||||||
|
gboolean setting_wimax_details (NMSetting *setting, NmCli *nmc);
|
||||||
|
|
||||||
#endif /* NMC_SETTINGS_H */
|
#endif /* NMC_SETTINGS_H */
|
||||||
|
Reference in New Issue
Block a user