Commit a6de5792 authored by Jiří Klimeš's avatar Jiří Klimeš

cli/build: make WiMAX support optional

parent b6c436d8
......@@ -38,10 +38,14 @@
#include <nm-setting-cdma.h>
#include <nm-setting-bluetooth.h>
#include <nm-setting-olpc-mesh.h>
#if WITH_WIMAX
#include <nm-setting-wimax.h>
#endif
#include <nm-device-ethernet.h>
#include <nm-device-wifi.h>
#if WITH_WIMAX
#include <nm-device-wimax.h>
#endif
#include <nm-gsm-device.h>
#include <nm-cdma-device.h>
#include <nm-device-bt.h>
......@@ -107,7 +111,7 @@ static NmcOutputField nmc_fields_settings_names[] = {
SETTING_FIELD (NM_SETTING_WIMAX_SETTING_NAME, 0), /* 15 */
{NULL, NULL, 0, NULL, 0}
};
#define NMC_FIELDS_SETTINGS_NAMES_ALL NM_SETTING_CONNECTION_SETTING_NAME","\
#define NMC_FIELDS_SETTINGS_NAMES_ALL_X NM_SETTING_CONNECTION_SETTING_NAME","\
NM_SETTING_WIRED_SETTING_NAME","\
NM_SETTING_802_1X_SETTING_NAME","\
NM_SETTING_WIRELESS_SETTING_NAME","\
......@@ -121,8 +125,13 @@ static NmcOutputField nmc_fields_settings_names[] = {
NM_SETTING_CDMA_SETTING_NAME","\
NM_SETTING_BLUETOOTH_SETTING_NAME","\
NM_SETTING_OLPC_MESH_SETTING_NAME","\
NM_SETTING_VPN_SETTING_NAME","\
NM_SETTING_VPN_SETTING_NAME
#if WITH_WIMAX
#define NMC_FIELDS_SETTINGS_NAMES_ALL NMC_FIELDS_SETTINGS_NAMES_ALL_X","\
NM_SETTING_WIMAX_SETTING_NAME
#else
#define NMC_FIELDS_SETTINGS_NAMES_ALL NMC_FIELDS_SETTINGS_NAMES_ALL_X
#endif
typedef struct {
......@@ -155,12 +164,16 @@ static void
usage (void)
{
fprintf (stderr,
_("Usage: nmcli con { COMMAND | help }\n"
" COMMAND := { list | status | up | down }\n\n"
" list [id <id> | uuid <id>]\n"
" status\n"
" up id <id> | uuid <id> [iface <iface>] [ap <hwaddr>] [nsp <name>] [--nowait] [--timeout <timeout>]\n"
" down id <id> | uuid <id>\n"));
_("Usage: nmcli con { COMMAND | help }\n"
" COMMAND := { list | status | up | down }\n\n"
" 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"
#else
" up id <id> | uuid <id> [iface <iface>] [ap <hwaddr>] [--nowait] [--timeout <timeout>]\n"
#endif
" down id <id> | uuid <id>\n"));
}
/* quit main loop */
......@@ -353,6 +366,7 @@ nmc_connection_detail (NMConnection *connection, NmCli *nmc)
}
}
#if WITH_WIMAX
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) {
......@@ -361,6 +375,7 @@ nmc_connection_detail (NMConnection *connection, NmCli *nmc)
continue;
}
}
#endif
}
if (print_settings_array)
......@@ -846,6 +861,7 @@ check_olpc_mesh_compatible (NMDeviceOlpcMesh *device, NMConnection *connection,
}
#endif
#if WITH_WIMAX
static gboolean
check_wimax_compatible (NMDeviceWimax *device, NMConnection *connection, GError **error)
{
......@@ -890,6 +906,7 @@ check_wimax_compatible (NMDeviceWimax *device, NMConnection *connection, GError
return TRUE;
}
#endif
static gboolean
check_gsm_compatible (NMGsmDevice *device, NMConnection *connection, GError **error)
......@@ -959,8 +976,10 @@ nm_device_is_connection_compatible (NMDevice *device, NMConnection *connection,
return check_bt_compatible (NM_DEVICE_BT (device), connection, error);
// else if (NM_IS_DEVICE_OLPC_MESH (device))
// return check_olpc_mesh_compatible (NM_DEVICE_OLPC_MESH (device), connection, error);
#if WITH_WIMAX
else if (NM_IS_DEVICE_WIMAX (device))
return check_wimax_compatible (NM_DEVICE_WIMAX (device), connection, error);
#endif
else if (NM_IS_GSM_DEVICE (device))
return check_gsm_compatible (NM_GSM_DEVICE (device), connection, error);
else if (NM_IS_CDMA_DEVICE (device))
......@@ -1156,6 +1175,7 @@ find_device_for_connection (NmCli *nmc,
g_free (hwaddr_up);
}
#if WITH_WIMAX
if ( found_device
&& nsp
&& !strcmp (con_type, NM_SETTING_WIMAX_SETTING_NAME)
......@@ -1174,6 +1194,7 @@ find_device_for_connection (NmCli *nmc,
}
}
}
#endif
}
if (found_device) {
......@@ -1462,6 +1483,7 @@ do_connection_up (NmCli *nmc, int argc, char **argv)
ap = *argv;
}
#if WITH_WIMAX
else if (strcmp (*argv, "nsp") == 0) {
if (next_arg (&argc, &argv) != 0) {
g_string_printf (nmc->return_text, _("Error: %s argument is missing."), *argv);
......@@ -1471,6 +1493,7 @@ do_connection_up (NmCli *nmc, int argc, char **argv)
nsp = *argv;
}
#endif
else if (strcmp (*argv, "--nowait") == 0) {
wait = FALSE;
} else if (strcmp (*argv, "--timeout") == 0) {
......
......@@ -37,7 +37,9 @@
#include <nm-cdma-device.h>
#include <nm-device-bt.h>
//#include <nm-device-olpc-mesh.h>
#if WITH_WIMAX
#include <nm-device-wimax.h>
#endif
#include <nm-utils.h>
#include <nm-setting-ip4-config.h>
#include <nm-setting-ip6-config.h>
......@@ -50,7 +52,9 @@
#include <nm-setting-cdma.h>
#include <nm-setting-bluetooth.h>
#include <nm-setting-olpc-mesh.h>
#if WITH_WIMAX
#include <nm-setting-wimax.h>
#endif
#include "utils.h"
#include "devices.h"
......@@ -83,8 +87,13 @@ static NmcOutputField nmc_fields_dev_list_sections[] = {
{"IP6-DNS", N_("IP6-DNS"), 0, NULL, 0}, /* 10 */
{NULL, NULL, 0, NULL, 0}
};
#if WITH_WIMAX
#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,WIMAX-PROPERTIES,NSP,IP4-SETTINGS,IP4-DNS,IP6-SETTINGS,IP6-DNS"
#else
#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_COMMON "GENERAL,CAPABILITIES,WIFI-PROPERTIES,AP,WIRED-PROPERTIES,IP4-SETTINGS,IP4-DNS,IP6-SETTINGS,IP6-DNS"
#endif
/* Available fields for 'dev list' - GENERAL part */
static NmcOutputField nmc_fields_dev_list_general[] = {
......@@ -132,6 +141,7 @@ 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_COMMON "NAME,WEP,WPA,WPA2,TKIP,CCMP"
#if WITH_WIMAX
/* Available fields for 'dev list' - wimax properties part */
static NmcOutputField nmc_fields_dev_list_wimax_prop[] = {
{"NAME", N_("NAME"), 18, NULL, 0}, /* 0 */
......@@ -144,6 +154,7 @@ static NmcOutputField nmc_fields_dev_list_wimax_prop[] = {
};
#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"
#endif
/* Available fields for 'dev list' - IPv4 settings part */
static NmcOutputField nmc_fields_dev_list_ip4_settings[] = {
......@@ -206,6 +217,7 @@ 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_FOR_DEV_LIST "NAME,"NMC_FIELDS_DEV_WIFI_LIST_COMMON
#if WITH_WIMAX
/* Available fields for 'dev wimax list' */
static NmcOutputField nmc_fields_dev_wimax_list[] = {
{"NAME", N_("NAME"), 15, NULL, 0}, /* 0 */
......@@ -220,6 +232,7 @@ static NmcOutputField nmc_fields_dev_wimax_list[] = {
#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
#endif
/* static function prototypes */
......@@ -229,8 +242,9 @@ 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_device_disconnect (NmCli *nmc, int argc, char **argv);
static NMCResultCode do_device_wifi (NmCli *nmc, int argc, char **argv);
#if WITH_WIMAX
static NMCResultCode do_device_wimax (NmCli *nmc, int argc, char **argv);
#endif
extern GMainLoop *loop; /* glib main loop variable */
......@@ -238,13 +252,20 @@ static void
usage (void)
{
fprintf (stderr,
_("Usage: nmcli dev { COMMAND | help }\n\n"
" COMMAND := { status | list | disconnect | wifi | wimax }\n\n"
" status\n"
" list [iface <iface>]\n"
" disconnect iface <iface> [--nowait] [--timeout <timeout>]\n"
" wifi [list [iface <iface>] [hwaddr <hwaddr>]]\n"
" wimax [list [iface <iface>] [nsp <name>]]\n\n"));
_("Usage: nmcli dev { COMMAND | help }\n\n"
#if WITH_WIMAX
" COMMAND := { status | list | disconnect | wifi | wimax }\n\n"
#else
" COMMAND := { status | list | disconnect | wifi }\n\n"
#endif
" status\n"
" list [iface <iface>]\n"
" disconnect iface <iface> [--nowait] [--timeout <timeout>]\n"
" wifi [list [iface <iface>] [hwaddr <hwaddr>]]\n"
#if WITH_WIMAX
" wimax [list [iface <iface>] [nsp <name>]]\n\n"
#endif
));
}
/* quit main loop */
......@@ -297,8 +318,10 @@ get_device_type (NMDevice * device)
return NM_SETTING_BLUETOOTH_SETTING_NAME;
// else if (NM_IS_DEVICE_OLPC_MESH (device))
// return NM_SETTING_OLPC_MESH_SETTING_NAME;
#if WITH_WIMAX
else if (NM_IS_DEVICE_WIMAX (device))
return NM_SETTING_WIMAX_SETTING_NAME;
#endif
else
return _("Unknown");
}
......@@ -481,6 +504,7 @@ detail_access_point (gpointer data, gpointer user_data)
g_string_free (security_str, TRUE);
}
#if WITH_WIMAX
static void
detail_wimax_nsp (NMWimaxNsp *nsp, NmCli *nmc, NMDevice *dev, int idx)
{
......@@ -526,6 +550,7 @@ detail_wimax_nsp (NMWimaxNsp *nsp, NmCli *nmc, NMDevice *dev, int idx)
g_free (nsp_name);
g_free (quality_str);
}
#endif
struct cb_info {
NMClient *client;
......@@ -603,8 +628,10 @@ show_device_info (gpointer data, gpointer user_data)
hwaddr = nm_device_ethernet_get_hw_address (NM_DEVICE_ETHERNET (device));
else if (NM_IS_DEVICE_WIFI (device))
hwaddr = nm_device_wifi_get_hw_address (NM_DEVICE_WIFI (device));
#if WITH_WIMAX
else if (NM_IS_DEVICE_WIMAX (device))
hwaddr = nm_device_wimax_get_hw_address (NM_DEVICE_WIMAX (device));
#endif
nmc->allowed_fields[0].value = nmc_fields_dev_list_sections[0].name; /* "GENERAL"*/
nmc->allowed_fields[1].value = nm_device_get_iface (device);
......@@ -715,7 +742,9 @@ show_device_info (gpointer data, gpointer user_data)
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print values */
was_output = TRUE;
}
} else if (NM_IS_DEVICE_WIMAX (device)) {
}
#if WITH_WIMAX
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;
......@@ -784,6 +813,7 @@ show_device_info (gpointer data, gpointer user_data)
was_output = TRUE;
}
}
#endif
/* IP Setup info */
if (state == NM_DEVICE_STATE_ACTIVATED) {
......@@ -1435,6 +1465,7 @@ do_device_wifi (NmCli *nmc, int argc, char **argv)
return nmc->return_value;
}
#if WITH_WIMAX
static void
show_nsp_info (NMDevice *device, NmCli *nmc)
{
......@@ -1628,6 +1659,7 @@ do_device_wimax (NmCli *nmc, int argc, char **argv)
return nmc->return_value;
}
#endif
NMCResultCode
do_devices (NmCli *nmc, int argc, char **argv)
......@@ -1659,11 +1691,13 @@ do_devices (NmCli *nmc, int argc, char **argv)
goto opt_error;
nmc->return_value = do_device_wifi (nmc, argc-1, argv+1);
}
#if WITH_WIMAX
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);
}
#endif
else if (strcmp (*argv, "help") == 0) {
usage ();
}
......
......@@ -43,7 +43,11 @@ static NmcOutputField nmc_fields_nm_status[] = {
{"WIMAX", N_("WIMAX"), 10, NULL, 0}, /* 8 */
{NULL, NULL, 0, NULL, 0}
};
#if WITH_WIMAX
#define NMC_FIELDS_NM_STATUS_ALL "RUNNING,STATE,NET-ENABLED,WIFI-HARDWARE,WIFI,WWAN-HARDWARE,WWAN,WIMAX-HARDWARE,WIMAX"
#else
#define NMC_FIELDS_NM_STATUS_ALL "RUNNING,STATE,NET-ENABLED,WIFI-HARDWARE,WIFI,WWAN-HARDWARE,WWAN"
#endif
#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_WIFI "WIFI"
......@@ -64,14 +68,21 @@ static void
usage (void)
{
fprintf (stderr,
_("Usage: nmcli nm { COMMAND | help }\n\n"
" COMMAND := { status | enable | sleep | wifi | wwan | wimax }\n\n"
" status\n"
" enable [true|false]\n"
" sleep [true|false]\n"
" wifi [on|off]\n"
" wwan [on|off]\n"
" wimax [on|off]\n\n"));
_("Usage: nmcli nm { COMMAND | help }\n\n"
#if WITH_WIMAX
" COMMAND := { status | enable | sleep | wifi | wwan | wimax }\n\n"
#else
" COMMAND := { status | enable | sleep | wifi | wwan }\n\n"
#endif
" status\n"
" enable [true|false]\n"
" sleep [true|false]\n"
" wifi [on|off]\n"
" wwan [on|off]\n"
#if WITH_WIMAX
" wimax [on|off]\n\n"
#endif
));
}
/* quit main loop */
......@@ -107,7 +118,9 @@ show_nm_status (NmCli *nmc)
const char *net_enabled_str;
const char *wireless_hw_enabled_str, *wireless_enabled_str;
const char *wwan_hw_enabled_str, *wwan_enabled_str;
#if WITH_WIMAX
const char *wimax_hw_enabled_str, *wimax_enabled_str;
#endif
GError *error = NULL;
const char *fields_str;
const char *fields_all = NMC_FIELDS_NM_STATUS_ALL;
......@@ -149,11 +162,18 @@ show_nm_status (NmCli *nmc)
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_enabled_str = nm_client_wwan_get_enabled (nmc->client) ? _("enabled") : _("disabled");
#if WITH_WIMAX
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");
#endif
} else {
#if WITH_WIMAX
net_enabled_str = wireless_hw_enabled_str = wireless_enabled_str =
wwan_hw_enabled_str = wwan_enabled_str = wimax_hw_enabled_str = wimax_enabled_str = _("unknown");
#else
net_enabled_str = wireless_hw_enabled_str = wireless_enabled_str =
wwan_hw_enabled_str = wwan_enabled_str = _("unknown");
#endif
}
nmc->allowed_fields[0].value = nm_running ? _("running") : _("not running");
......@@ -163,8 +183,10 @@ show_nm_status (NmCli *nmc)
nmc->allowed_fields[4].value = wireless_enabled_str;
nmc->allowed_fields[5].value = wwan_hw_enabled_str;
nmc->allowed_fields[6].value = wwan_enabled_str;
#if WITH_WIMAX
nmc->allowed_fields[7].value = wimax_hw_enabled_str;
nmc->allowed_fields[8].value = wimax_enabled_str;
#endif
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag;
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print values */
......@@ -217,7 +239,9 @@ do_network_manager (NmCli *nmc, int argc, char **argv)
gboolean enable_net;
gboolean enable_wifi;
gboolean enable_wwan;
#if WITH_WIMAX
gboolean enable_wimax;
#endif
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;
......@@ -365,6 +389,7 @@ do_network_manager (NmCli *nmc, int argc, char **argv)
nm_client_wwan_set_enabled (nmc->client, enable_wwan);
}
}
#if WITH_WIMAX
else if (matches (*argv, "wimax") == 0) {
if (next_arg (&argc, &argv) != 0) {
if (!nmc_terse_option_check (nmc->print_output, nmc->required_fields, &error))
......@@ -403,6 +428,7 @@ do_network_manager (NmCli *nmc, int argc, char **argv)
nm_client_wimax_set_enabled (nmc->client, enable_wimax);
}
}
#endif
else if (strcmp (*argv, "help") == 0) {
usage ();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment