/** * panel_device_to_sortable_string: * * Try to return order of approximate connection speed. **/ const gchar * panel_device_to_sortable_string (NMDevice *device) { const gchar *value = NULL; NMDeviceModemCapabilities caps; switch (nm_device_get_device_type (device)) { case NM_DEVICE_TYPE_ETHERNET: value = "1"; break; case NM_DEVICE_TYPE_WIFI: value = "2"; break; case NM_DEVICE_TYPE_MODEM: caps = nm_device_modem_get_current_capabilities (NM_DEVICE_MODEM (device)); if ((caps & NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS) || (caps & NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO)) { value = "3"; } break; case NM_DEVICE_TYPE_BT: value = "4"; break; case NM_DEVICE_TYPE_OLPC_MESH: value = "5"; break; default: value = "6"; break; } return value; }
/** * panel_device_to_icon_name: **/ const gchar * panel_device_to_icon_name (NMDevice *device) { const gchar *value = NULL; NMDeviceState state; NMDeviceModemCapabilities caps; switch (nm_device_get_device_type (device)) { case NM_DEVICE_TYPE_ETHERNET: state = nm_device_get_state (device); if (state == NM_DEVICE_STATE_UNAVAILABLE) { value = "network-wired-disconnected"; } else { value = "network-wired"; } break; case NM_DEVICE_TYPE_WIFI: case NM_DEVICE_TYPE_BT: case NM_DEVICE_TYPE_OLPC_MESH: value = "network-wireless"; break; case NM_DEVICE_TYPE_MODEM: caps = nm_device_modem_get_current_capabilities (NM_DEVICE_MODEM (device)); if ((caps & NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS) || (caps & NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO)) { value = "network-wireless"; } break; default: break; } return value; }
static gboolean get_secrets (SecretsRequest *req, GError **error) { NMDevice *device; BroadbandDeviceInfo *devinfo; device = applet_get_device_for_connection (req->applet, req->connection); if (!device) { g_set_error (error, NM_SECRET_AGENT_ERROR, NM_SECRET_AGENT_ERROR_INTERNAL_ERROR, "%s.%d (%s): failed to find device for active connection.", __FILE__, __LINE__, __func__); return FALSE; } if (!mobile_helper_get_secrets (nm_device_modem_get_current_capabilities (NM_DEVICE_MODEM (device)), req, error)) return FALSE; devinfo = g_object_get_data (G_OBJECT (device), "devinfo"); g_assert (devinfo); /* A GetSecrets PIN dialog overrides the initial unlock dialog */ if (devinfo->dialog) unlock_dialog_destroy (devinfo); return TRUE; }
static gboolean connection_compatible (NMDevice *device, NMConnection *connection, GError **error) { NMSettingGsm *s_gsm; NMSettingCdma *s_cdma; NMDeviceModemCapabilities current_caps; if (!NM_DEVICE_CLASS (nm_device_modem_parent_class)->connection_compatible (device, connection, error)) return FALSE; if ( !nm_connection_is_type (connection, NM_SETTING_GSM_SETTING_NAME) && !nm_connection_is_type (connection, NM_SETTING_CDMA_SETTING_NAME)) { g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION, _("The connection was not a modem connection.")); return FALSE; } s_gsm = nm_connection_get_setting_gsm (connection); s_cdma = nm_connection_get_setting_cdma (connection); if (!s_cdma && !s_gsm) { g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INVALID_CONNECTION, _("The connection was not a valid modem connection.")); return FALSE; } current_caps = nm_device_modem_get_current_capabilities (NM_DEVICE_MODEM (device)); if (!(s_gsm && MODEM_CAPS_3GPP (current_caps)) && !(s_cdma && MODEM_CAPS_3GPP2 (current_caps))) { g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION, _("The device is lacking capabilities required by the connection.")); return FALSE; } return TRUE; }
void cc_network_panel_connect_to_3g_network (CcNetworkPanel *panel, NMClient *client, NMRemoteSettings *settings, NMDevice *device) { GtkWidget *toplevel = cc_shell_get_toplevel (cc_panel_get_shell (CC_PANEL (panel))); if (toplevel == NULL) { toplevel = GTK_WIDGET (panel); } MobileDialogClosure *closure; NMAMobileWizard *wizard; NMDeviceModemCapabilities caps; gboolean visible = FALSE; g_debug ("connect to 3g"); if (!NM_IS_DEVICE_MODEM (device)) { g_warning ("Network panel loaded with connect-3g but the selected device" " is not a modem"); return; } closure = g_slice_new (MobileDialogClosure); closure->client = g_object_ref (client); closure->settings = g_object_ref (settings); closure->device = g_object_ref (device); caps = nm_device_modem_get_current_capabilities (NM_DEVICE_MODEM (device)); if (caps & NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS) { wizard = nma_mobile_wizard_new (GTK_WINDOW (toplevel), NULL, NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS, FALSE, gsm_mobile_wizard_done, closure); if (wizard == NULL) { g_warning ("failed to construct GSM wizard"); return; } } else if (caps & NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO) { wizard = nma_mobile_wizard_new (GTK_WINDOW (toplevel), NULL, NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO, FALSE, cdma_mobile_wizard_done, closure); if (wizard == NULL) { g_warning ("failed to construct CDMA wizard"); return; } } else { g_warning ("Network panel loaded with connect-3g but the selected device" " does not support GSM or CDMA"); mobile_dialog_closure_free (closure); return; } g_object_get (G_OBJECT (toplevel), "visible", &visible, NULL); if (visible) { g_debug ("Scheduling showing the Mobile wizard"); g_idle_add ((GSourceFunc) show_wizard_idle_cb, wizard); } else { g_debug ("Will show wizard a bit later, toplevel is not visible"); g_signal_connect (G_OBJECT (toplevel), "notify::visible", G_CALLBACK (toplevel_shown), wizard); } }
static void constructed (GObject *object) { NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE (object); G_OBJECT_CLASS (nm_device_modem_parent_class)->constructed (object); priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_DEVICE_MODEM); register_properties (NM_DEVICE_MODEM (object)); }
static void modem_enabled_cb (NMModem *modem, GParamSpec *pspec, gpointer user_data) { NMDeviceModem *self = NM_DEVICE_MODEM (user_data); NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE (self); real_set_enabled (NM_DEVICE (self), nm_modem_get_mm_enabled (priv->modem)); g_signal_emit (G_OBJECT (self), signals[ENABLE_CHANGED], 0); }
static gboolean new_auto_connection (NMDevice *device, gpointer dclass_data, AppletNewAutoConnectionCallback callback, gpointer callback_data) { return mobile_helper_wizard (nm_device_modem_get_current_capabilities (NM_DEVICE_MODEM (device)), callback, callback_data); }
static GType get_setting_type (NMDevice *device) { NMDeviceModemCapabilities caps; caps = nm_device_modem_get_current_capabilities (NM_DEVICE_MODEM (device)); if (caps & (NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS | NM_DEVICE_MODEM_CAPABILITY_LTE)) return NM_TYPE_SETTING_GSM; else if (caps & NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO) return NM_TYPE_SETTING_CDMA; else return G_TYPE_INVALID; }
static const char * get_type_description (NMDevice *device) { NMDeviceModemCapabilities caps; caps = nm_device_modem_get_current_capabilities (NM_DEVICE_MODEM (device)); if (caps & NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS) return "gsm"; else if (caps & NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO) return "cdma"; else return NULL; }
static void set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { switch (prop_id) { case PROP_MODEM: /* construct-only */ set_modem (NM_DEVICE_MODEM (object), g_value_get_object (value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }
static void constructed (GObject *object) { NMDeviceModemPrivate *priv; G_OBJECT_CLASS (nm_device_modem_parent_class)->constructed (object); priv = NM_DEVICE_MODEM_GET_PRIVATE (object); priv->proxy = dbus_g_proxy_new_for_name (nm_object_get_connection (NM_OBJECT (object)), NM_DBUS_SERVICE, nm_object_get_path (NM_OBJECT (object)), NM_DBUS_INTERFACE_DEVICE_MODEM); register_properties (NM_DEVICE_MODEM (object)); }
static void modem_need_auth (NMModem *modem, const char *setting_name, gboolean retry, RequestSecretsCaller caller, const char *hint1, const char *hint2, gpointer user_data) { NMDeviceModem *self = NM_DEVICE_MODEM (user_data); NMActRequest *req; req = nm_device_get_act_request (NM_DEVICE (self)); g_assert (req); nm_device_state_changed (NM_DEVICE (self), NM_DEVICE_STATE_NEED_AUTH, NM_DEVICE_STATE_REASON_NONE); nm_act_request_get_secrets (req, setting_name, retry, caller, hint1, hint2); }
void applet_broadband_connect_network (NMApplet *applet, NMDevice *device) { ConnectNetworkInfo *info; info = g_malloc0 (sizeof (*info)); info->applet = applet; info->device = g_object_ref (device); if (!mobile_helper_wizard (nm_device_modem_get_current_capabilities (NM_DEVICE_MODEM (device)), wizard_done, info)) { g_warning ("Couldn't run mobile wizard for broadband device"); g_object_unref (info->device); g_free (info); } }
static void get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { NMDeviceModem *self = NM_DEVICE_MODEM (object); switch (prop_id) { case PROP_MODEM_CAPS: g_value_set_flags (value, nm_device_modem_get_modem_capabilities (self)); break; case PROP_CURRENT_CAPS: g_value_set_flags (value, nm_device_modem_get_current_capabilities (self)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }
static void real_set_enabled (NMDevice *device, gboolean enabled) { NMDeviceModem *self = NM_DEVICE_MODEM (device); NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE (self); NMDeviceState state; if (priv->modem) { nm_modem_set_mm_enabled (priv->modem, enabled); if (enabled == FALSE) { state = nm_device_get_state (NM_DEVICE (device)); if (state == NM_DEVICE_STATE_ACTIVATED) { nm_device_state_changed (NM_DEVICE (device), NM_DEVICE_STATE_DISCONNECTED, NM_DEVICE_STATE_REASON_NONE); } } } }
static gboolean connection_compatible (NMDevice *device, NMConnection *connection, GError **error) { NMSettingConnection *s_con; NMSettingGsm *s_gsm; NMSettingCdma *s_cdma; const char *ctype; NMDeviceModemCapabilities current_caps; g_return_val_if_fail (error == NULL || *error == NULL, FALSE); s_con = nm_connection_get_setting_connection (connection); g_assert (s_con); ctype = nm_setting_connection_get_connection_type (s_con); if ( strcmp (ctype, NM_SETTING_GSM_SETTING_NAME) != 0 && strcmp (ctype, NM_SETTING_CDMA_SETTING_NAME) != 0) { g_set_error (error, NM_DEVICE_MODEM_ERROR, NM_DEVICE_MODEM_ERROR_NOT_MODEM_CONNECTION, "The connection was not a modem connection."); return FALSE; } s_gsm = nm_connection_get_setting_gsm (connection); s_cdma = nm_connection_get_setting_cdma (connection); if (!s_cdma && !s_gsm) { g_set_error (error, NM_DEVICE_MODEM_ERROR, NM_DEVICE_MODEM_ERROR_INVALID_MODEM_CONNECTION, "The connection was not a valid modem connection."); return FALSE; } current_caps = nm_device_modem_get_current_capabilities (NM_DEVICE_MODEM (device)); if ( !(s_gsm && (current_caps & NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS)) && !(s_cdma && (current_caps & NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO))) { g_set_error (error, NM_DEVICE_MODEM_ERROR, NM_DEVICE_MODEM_ERROR_MISSING_DEVICE_CAPS, "The device missed capabilities required by the GSM/CDMA connection."); return FALSE; } return TRUE; }
static void set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE (object); switch (prop_id) { case PROP_MODEM: /* construct-only */ set_modem (NM_DEVICE_MODEM (object), g_value_get_object (value)); break; case PROP_CAPABILITIES: priv->caps = g_value_get_uint (value); break; case PROP_CURRENT_CAPABILITIES: priv->current_caps = g_value_get_uint (value); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }
/** * panel_device_to_localized_string: **/ const gchar * panel_device_to_localized_string (NMDevice *device) { const gchar *value = NULL; NMDeviceModemCapabilities caps; switch (nm_device_get_device_type (device)) { case NM_DEVICE_TYPE_UNKNOWN: /* TRANSLATORS: device type */ value = _("Unknown"); break; case NM_DEVICE_TYPE_ETHERNET: /* TRANSLATORS: device type */ value = _("Wired"); break; case NM_DEVICE_TYPE_WIFI: /* TRANSLATORS: device type */ value = _("Wireless"); break; case NM_DEVICE_TYPE_MODEM: caps = nm_device_modem_get_current_capabilities (NM_DEVICE_MODEM (device)); if ((caps & NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS) || (caps & NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO)) { /* TRANSLATORS: device type */ value = _("Mobile broadband"); } break; case NM_DEVICE_TYPE_BT: /* TRANSLATORS: device type */ value = _("Bluetooth"); break; case NM_DEVICE_TYPE_OLPC_MESH: /* TRANSLATORS: device type */ value = _("Mesh"); break; default: break; } return value; }
/** * panel_device_to_icon_name: **/ const gchar * panel_device_to_icon_name (NMDevice *device, gboolean symbolic) { const gchar *value = NULL; NMDeviceState state; NMDeviceModemCapabilities caps; switch (nm_device_get_device_type (device)) { case NM_DEVICE_TYPE_ETHERNET: state = nm_device_get_state (device); if (state <= NM_DEVICE_STATE_DISCONNECTED) { value = symbolic ? "network-wired-disconnected-symbolic" : "network-wired-disconnected"; } else { value = symbolic ? "network-wired-symbolic" : "network-wired"; } break; case NM_DEVICE_TYPE_WIFI: case NM_DEVICE_TYPE_BT: case NM_DEVICE_TYPE_OLPC_MESH: value = symbolic ? "network-wireless-signal-excellent-symbolic" : "network-wireless"; break; case NM_DEVICE_TYPE_MODEM: caps = nm_device_modem_get_current_capabilities (NM_DEVICE_MODEM (device)); if ((caps & NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS) || (caps & NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO)) { value = symbolic ? "network-cellular-signal-excellent-symbolic" : "network-cellular"; break; } /* fall thru */ default: value = symbolic ? "network-idle-symbolic" : "network-idle"; break; } return value; }
static void cdma_device_added (NMDevice *device, NMApplet *applet) { NMDeviceModem *modem = NM_DEVICE_MODEM (device); CdmaDeviceInfo *info; DBusGConnection *bus; const char *udi; GError *error = NULL; udi = nm_device_get_udi (device); if (!udi) return; bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error); if (!bus) { g_warning ("%s: failed to connect to D-Bus: (%d) %s", __func__, error->code, error->message); g_clear_error (&error); return; } info = g_malloc0 (sizeof (CdmaDeviceInfo)); info->applet = applet; info->device = device; info->bus = bus; info->quality_valid = FALSE; info->props_proxy = dbus_g_proxy_new_for_name (bus, "org.freedesktop.ModemManager", udi, "org.freedesktop.DBus.Properties"); if (!info->props_proxy) { g_message ("%s: failed to create D-Bus properties proxy.", __func__); cdma_device_info_free (info); return; } info->cdma_proxy = dbus_g_proxy_new_for_name (bus, "org.freedesktop.ModemManager", udi, "org.freedesktop.ModemManager.Modem.Cdma"); if (!info->cdma_proxy) { g_message ("%s: failed to create CDMA proxy.", __func__); cdma_device_info_free (info); return; } g_object_set_data_full (G_OBJECT (modem), "devinfo", info, cdma_device_info_free); /* Registration state change signal */ dbus_g_object_register_marshaller (_nma_marshal_VOID__UINT_UINT, G_TYPE_NONE, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_INVALID); dbus_g_proxy_add_signal (info->cdma_proxy, "RegistrationStateChanged", G_TYPE_UINT, G_TYPE_UINT, G_TYPE_INVALID); dbus_g_proxy_connect_signal (info->cdma_proxy, "RegistrationStateChanged", G_CALLBACK (reg_state_changed_cb), info, NULL); /* Signal quality change signal */ dbus_g_object_register_marshaller (g_cclosure_marshal_VOID__UINT, G_TYPE_NONE, G_TYPE_UINT, G_TYPE_INVALID); dbus_g_proxy_add_signal (info->cdma_proxy, "SignalQuality", G_TYPE_UINT, G_TYPE_INVALID); dbus_g_proxy_connect_signal (info->cdma_proxy, "SignalQuality", G_CALLBACK (signal_quality_changed_cb), info, NULL); /* Modem property change signal */ dbus_g_object_register_marshaller (_nma_marshal_VOID__STRING_BOXED, G_TYPE_NONE, G_TYPE_STRING, DBUS_TYPE_G_MAP_OF_VARIANT, G_TYPE_INVALID); dbus_g_proxy_add_signal (info->props_proxy, "MmPropertiesChanged", G_TYPE_STRING, DBUS_TYPE_G_MAP_OF_VARIANT, G_TYPE_INVALID); dbus_g_proxy_connect_signal (info->props_proxy, "MmPropertiesChanged", G_CALLBACK (modem_properties_changed), info, NULL); /* Ask whether the device is enabled */ dbus_g_proxy_begin_call (info->props_proxy, "Get", enabled_reply, info, NULL, G_TYPE_STRING, MM_OLD_DBUS_INTERFACE_MODEM, G_TYPE_STRING, "Enabled", G_TYPE_INVALID); }
static void detail_device (gpointer data, gpointer user_data) { NMDevice *device = NM_DEVICE (data); char *tmp; NMDeviceState state; guint32 caps; guint32 speed; const GArray *array; gboolean is_default = FALSE; const char *id = NULL; NMActiveConnection *active; active = nm_device_get_active_connection (device); if (active) { NMConnection *connection; NMSettingConnection *s_con; is_default = nm_active_connection_get_default (active); connection = get_connection_for_active (active); if (connection) { s_con = nm_connection_get_setting_connection (connection); if (s_con) id = nm_setting_connection_get_id (s_con); } } print_header ("Device", nm_device_get_iface (device), id); /* General information */ if (NM_IS_DEVICE_ETHERNET (device)) print_string ("Type", "Wired"); else if (NM_IS_DEVICE_WIFI (device)) print_string ("Type", "802.11 WiFi"); else if (NM_IS_DEVICE_MODEM (device)) { NMDeviceModemCapabilities modem_caps; modem_caps = nm_device_modem_get_current_capabilities (NM_DEVICE_MODEM (device)); if (modem_caps & NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS) print_string ("Type", "Mobile Broadband (GSM)"); else if (modem_caps & NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO) print_string ("Type", "Mobile Broadband (CDMA)"); else print_string ("Type", "Mobile Broadband (unknown)"); } else if (NM_IS_DEVICE_BT (device)) print_string ("Type", "Bluetooth"); else if (NM_IS_DEVICE_WIMAX (device)) print_string ("Type", "WiMAX"); print_string ("Driver", nm_device_get_driver (device) ? nm_device_get_driver (device) : "(unknown)"); state = nm_device_get_state (device); print_string ("State", get_dev_state_string (state)); if (is_default) print_string ("Default", "yes"); else print_string ("Default", "no"); tmp = NULL; if (NM_IS_DEVICE_ETHERNET (device)) tmp = g_strdup (nm_device_ethernet_get_hw_address (NM_DEVICE_ETHERNET (device))); else if (NM_IS_DEVICE_WIFI (device)) tmp = g_strdup (nm_device_wifi_get_hw_address (NM_DEVICE_WIFI (device))); else if (NM_IS_DEVICE_WIMAX (device)) tmp = g_strdup (nm_device_wimax_get_hw_address (NM_DEVICE_WIMAX (device))); if (tmp) { print_string ("HW Address", tmp); g_free (tmp); } /* Capabilities */ caps = nm_device_get_capabilities (device); printf ("\n Capabilities:\n"); if (caps & NM_DEVICE_CAP_CARRIER_DETECT) print_string (" Carrier Detect", "yes"); speed = 0; if (NM_IS_DEVICE_ETHERNET (device)) { /* Speed in Mb/s */ speed = nm_device_ethernet_get_speed (NM_DEVICE_ETHERNET (device)); } else if (NM_IS_DEVICE_WIFI (device)) { /* Speed in b/s */ speed = nm_device_wifi_get_bitrate (NM_DEVICE_WIFI (device)); speed /= 1000; } if (speed) { char *speed_string; speed_string = g_strdup_printf ("%u Mb/s", speed); print_string (" Speed", speed_string); g_free (speed_string); } /* Wireless specific information */ if ((NM_IS_DEVICE_WIFI (device))) { guint32 wcaps; NMAccessPoint *active_ap = NULL; const char *active_bssid = NULL; const GPtrArray *aps; printf ("\n Wireless Properties\n"); wcaps = nm_device_wifi_get_capabilities (NM_DEVICE_WIFI (device)); if (wcaps & (NM_WIFI_DEVICE_CAP_CIPHER_WEP40 | NM_WIFI_DEVICE_CAP_CIPHER_WEP104)) print_string (" WEP Encryption", "yes"); if (wcaps & NM_WIFI_DEVICE_CAP_WPA) print_string (" WPA Encryption", "yes"); if (wcaps & NM_WIFI_DEVICE_CAP_RSN) print_string (" WPA2 Encryption", "yes"); 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; } printf ("\n Wireless Access Points %s\n", active_ap ? "(* = current AP)" : ""); aps = nm_device_wifi_get_access_points (NM_DEVICE_WIFI (device)); if (aps && aps->len) g_ptr_array_foreach ((GPtrArray *) aps, detail_access_point, (gpointer) active_bssid); } else if (NM_IS_DEVICE_ETHERNET (device)) { printf ("\n Wired Properties\n"); if (nm_device_ethernet_get_carrier (NM_DEVICE_ETHERNET (device))) print_string (" Carrier", "on"); else print_string (" Carrier", "off"); } else if (NM_IS_DEVICE_WIMAX (device)) { NMDeviceWimax *wimax = NM_DEVICE_WIMAX (device); NMWimaxNsp *active_nsp = NULL; const char *active_name = NULL; const GPtrArray *nsps; if (nm_device_get_state (device) == NM_DEVICE_STATE_ACTIVATED) { guint tmp_uint; gint tmp_int; const char *tmp_str; active_nsp = nm_device_wimax_get_active_nsp (wimax); active_name = active_nsp ? nm_wimax_nsp_get_name (active_nsp) : NULL; printf ("\n Link Status\n"); tmp_uint = nm_device_wimax_get_center_frequency (wimax); if (tmp_uint) tmp = g_strdup_printf ("%'.1f MHz", (double) tmp_uint / 1000.0); else tmp = g_strdup ("(unknown)"); print_string (" Center Freq.", tmp); g_free (tmp); tmp_int = nm_device_wimax_get_rssi (wimax); if (tmp_int) tmp = g_strdup_printf ("%d dBm", tmp_int); else tmp = g_strdup ("(unknown)"); print_string (" RSSI", tmp); g_free (tmp); tmp_int = nm_device_wimax_get_cinr (wimax); if (tmp_int) tmp = g_strdup_printf ("%d dB", tmp_int); else tmp = g_strdup ("(unknown)"); print_string (" CINR", tmp); g_free (tmp); tmp_int = nm_device_wimax_get_tx_power (wimax); if (tmp_int) tmp = g_strdup_printf ("%'.2f dBm", (float) tmp_int / 2.0); else tmp = g_strdup ("(unknown)"); print_string (" TX Power", tmp); g_free (tmp); tmp_str = nm_device_wimax_get_bsid (wimax); if (tmp_str) print_string (" BSID", tmp_str); else print_string (" BSID", "(unknown)"); } printf ("\n WiMAX NSPs %s\n", active_nsp ? "(* current NSP)" : ""); nsps = nm_device_wimax_get_nsps (NM_DEVICE_WIMAX (device)); if (nsps && nsps->len) g_ptr_array_foreach ((GPtrArray *) nsps, detail_nsp, (gpointer) active_name); } /* IP Setup info */ if (state == NM_DEVICE_STATE_ACTIVATED) { NMIP4Config *cfg4 = nm_device_get_ip4_config (device); NMIP6Config *cfg6 = nm_device_get_ip6_config (device); GSList *iter; if (cfg4) { printf ("\n IPv4 Settings:\n"); for (iter = (GSList *) nm_ip4_config_get_addresses (cfg4); iter; iter = g_slist_next (iter)) { NMIP4Address *addr = (NMIP4Address *) iter->data; guint32 prefix = nm_ip4_address_get_prefix (addr); char *tmp2; tmp = ip4_address_as_string (nm_ip4_address_get_address (addr)); print_string (" Address", tmp); g_free (tmp); tmp2 = ip4_address_as_string (nm_utils_ip4_prefix_to_netmask (prefix)); tmp = g_strdup_printf ("%d (%s)", prefix, tmp2); g_free (tmp2); print_string (" Prefix", tmp); g_free (tmp); tmp = ip4_address_as_string (nm_ip4_address_get_gateway (addr)); print_string (" Gateway", tmp); g_free (tmp); printf ("\n"); } array = nm_ip4_config_get_nameservers (cfg4); if (array) { int i; for (i = 0; i < array->len; i++) { tmp = ip4_address_as_string (g_array_index (array, guint32, i)); print_string (" DNS", tmp); g_free (tmp); } } } if (cfg6) { printf ("\n IPv6 Settings:\n"); for (iter = (GSList *) nm_ip6_config_get_addresses (cfg6); iter; iter = g_slist_next (iter)) { NMIP6Address *addr = (NMIP6Address *) iter->data; guint32 prefix = nm_ip6_address_get_prefix (addr); tmp = ip6_address_as_string (nm_ip6_address_get_address (addr)); print_string (" Address", tmp); g_free (tmp); tmp = g_strdup_printf ("%d", prefix); print_string (" Prefix", tmp); g_free (tmp); tmp = ip6_address_as_string (nm_ip6_address_get_gateway (addr)); print_string (" Gateway", tmp); g_free (tmp); printf ("\n"); } for (iter = (GSList *) nm_ip6_config_get_nameservers (cfg6); iter; iter = g_slist_next (iter)) { tmp = ip6_address_as_string (iter->data); print_string (" DNS", tmp); g_free (tmp); } } } printf ("\n\n"); }