static GObject* constructor (GType type, guint n_construct_params, GObjectConstructParam *construct_params) { GObject *object; NMDeviceAdslPrivate *priv; GError *error = NULL; object = G_OBJECT_CLASS (nm_device_adsl_parent_class)->constructor (type, n_construct_params, construct_params); if (!object) return NULL; priv = NM_DEVICE_ADSL_GET_PRIVATE (object); priv->atm_index = get_atm_index (nm_device_get_iface (NM_DEVICE (object)), &error); if (priv->atm_index < 0) { nm_log_dbg (LOGD_ADSL, "error reading ATM device index: (%d) %s", error ? error->code : -1, error && error->message ? error->message : "(unknown)"); g_clear_error (&error); g_object_unref (object); return NULL; } else { nm_log_dbg (LOGD_ADSL, "(%s): ATM device index %d", nm_device_get_iface (NM_DEVICE (object)), priv->atm_index); } /* Poll the carrier */ priv->carrier_poll_id = g_timeout_add_seconds (5, carrier_update_cb, object); return object; }
gboolean nm_device_bt_modem_removed (NMDeviceBt *self, NMModem *modem) { NMDeviceBtPrivate *priv; NMDeviceState state; g_return_val_if_fail (self != NULL, FALSE); g_return_val_if_fail (NM_IS_DEVICE_BT (self), FALSE); g_return_val_if_fail (modem != NULL, FALSE); g_return_val_if_fail (NM_IS_MODEM (modem), FALSE); priv = NM_DEVICE_BT_GET_PRIVATE (self); if (modem != priv->modem) return FALSE; /* Fail the device if the modem was removed while active */ state = nm_device_get_state (NM_DEVICE (self)); if ( state == NM_DEVICE_STATE_ACTIVATED || nm_device_is_activating (NM_DEVICE (self))) { nm_device_state_changed (NM_DEVICE (self), NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_BT_FAILED); } else { g_object_unref (priv->modem); priv->modem = NULL; } return TRUE; }
NMActRequest * nm_act_request_new (NMConnection *connection, const char *specific_object, gboolean user_requested, gboolean assumed, gpointer *device) { GObject *object; NMActRequestPrivate *priv; g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL); g_return_val_if_fail (NM_DEVICE (device), NULL); object = g_object_new (NM_TYPE_ACT_REQUEST, NULL); if (!object) return NULL; priv = NM_ACT_REQUEST_GET_PRIVATE (object); priv->connection = g_object_ref (connection); if (specific_object) priv->specific_object = g_strdup (specific_object); priv->device = NM_DEVICE (device); g_signal_connect (device, "state-changed", G_CALLBACK (device_state_changed), NM_ACT_REQUEST (object)); priv->user_requested = user_requested; priv->assumed = assumed; return NM_ACT_REQUEST (object); }
static NMActStageReturn real_act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason) { NMDeviceOlpcMeshPrivate *priv = NM_DEVICE_OLPC_MESH_GET_PRIVATE (dev); gboolean scanning; /* disconnect companion device, if it is connected */ if (nm_device_get_act_request (NM_DEVICE (priv->companion))) { nm_log_info (LOGD_OLPC_MESH, "(%s): disconnecting companion device %s", nm_device_get_iface (dev), nm_device_get_iface (priv->companion)); /* FIXME: VPN stuff here is a bug; but we can't really change API now... */ nm_device_state_changed (NM_DEVICE (priv->companion), NM_DEVICE_STATE_DISCONNECTED, NM_VPN_CONNECTION_STATE_REASON_USER_DISCONNECTED); nm_log_info (LOGD_OLPC_MESH, "(%s): companion %s disconnected", nm_device_get_iface (dev), nm_device_get_iface (priv->companion)); } /* wait with continuing configuration untill the companion device is done scanning */ g_object_get (priv->companion, "scanning", &scanning, NULL); if (scanning) { priv->stage1_waiting = TRUE; return NM_ACT_STAGE_RETURN_POSTPONE; } return NM_ACT_STAGE_RETURN_SUCCESS; }
static void set_enabled (NMDevice *device, gboolean enabled) { NMDeviceWimax *self = NM_DEVICE_WIMAX (device); NMDeviceWimaxPrivate *priv = NM_DEVICE_WIMAX_GET_PRIVATE (self); gboolean old_available; int ret; const char *iface; iface = nm_device_get_iface (NM_DEVICE (self)); nm_log_dbg (LOGD_WIMAX, "(%s): setting radio enabled %d -> %d", iface, priv->enabled, enabled); if (priv->enabled == enabled) return; old_available = nm_device_is_available (NM_DEVICE (device)); priv->enabled = enabled; nm_log_dbg (LOGD_WIMAX, "(%s): radio now %s", iface, priv->enabled ? "enabled" : "disabled"); /* Set the WiMAX device RF state to the current user-specified enabled state */ if (priv->sdk) { ret = iwmx_sdk_rf_state_set (priv->sdk, enabled ? WIMAX_API_RF_ON : WIMAX_API_RF_OFF); if (ret < 0 && ret != -EINPROGRESS) { nm_log_warn (LOGD_WIMAX, "(%s): failed to %s radio", iface, priv->enabled ? "enable" : "disable"); } } update_availability (self, old_available); }
static gboolean carrier_action_defer_cb (gpointer user_data) { NMDeviceWired *self = NM_DEVICE_WIRED (user_data); NMDeviceWiredPrivate *priv = NM_DEVICE_WIRED_GET_PRIVATE (self); NMDeviceState state; priv->carrier_action_defer_id = 0; state = nm_device_get_state (NM_DEVICE (self)); if (state == NM_DEVICE_STATE_UNAVAILABLE) { if (priv->carrier) nm_device_queue_state (NM_DEVICE (self), NM_DEVICE_STATE_DISCONNECTED, NM_DEVICE_STATE_REASON_CARRIER); else { /* clear any queued state changes if they wouldn't be valid when the * carrier is off. */ if (nm_device_queued_state_peek (NM_DEVICE (self)) >= NM_DEVICE_STATE_DISCONNECTED) nm_device_queued_state_clear (NM_DEVICE (self)); } } else if (state >= NM_DEVICE_STATE_DISCONNECTED) { if (!priv->carrier) nm_device_queue_state (NM_DEVICE (self), NM_DEVICE_STATE_UNAVAILABLE, NM_DEVICE_STATE_REASON_CARRIER); } return FALSE; }
static NMActStageReturn act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason) { NMDeviceOlpcMesh *self = NM_DEVICE_OLPC_MESH (device); NMDeviceOlpcMeshPrivate *priv = NM_DEVICE_OLPC_MESH_GET_PRIVATE (device); NMActStageReturn ret; gboolean scanning; ret = NM_DEVICE_CLASS (nm_device_olpc_mesh_parent_class)->act_stage1_prepare (device, reason); if (ret != NM_ACT_STAGE_RETURN_SUCCESS) return ret; /* disconnect companion device, if it is connected */ if (nm_device_get_act_request (NM_DEVICE (priv->companion))) { _LOGI (LOGD_OLPC, "disconnecting companion device %s", nm_device_get_iface (priv->companion)); /* FIXME: VPN stuff here is a bug; but we can't really change API now... */ nm_device_state_changed (NM_DEVICE (priv->companion), NM_DEVICE_STATE_DISCONNECTED, NM_DEVICE_STATE_REASON_USER_REQUESTED); _LOGI (LOGD_OLPC, "companion %s disconnected", nm_device_get_iface (priv->companion)); } /* wait with continuing configuration untill the companion device is done scanning */ g_object_get (priv->companion, "scanning", &scanning, NULL); if (scanning) { priv->stage1_waiting = TRUE; return NM_ACT_STAGE_RETURN_POSTPONE; } return NM_ACT_STAGE_RETURN_SUCCESS; }
static GObject* constructor (GType type, guint n_construct_params, GObjectConstructParam *construct_params) { GObject *object; GObjectClass *klass; NMDeviceOlpcMesh *self; NMDeviceWifiCapabilities caps; klass = G_OBJECT_CLASS (nm_device_olpc_mesh_parent_class); object = klass->constructor (type, n_construct_params, construct_params); if (!object) return NULL; self = NM_DEVICE_OLPC_MESH (object); if (!nm_platform_wifi_get_capabilities (nm_device_get_ifindex (NM_DEVICE (self)), &caps)) { _LOGW (LOGD_HW | LOGD_OLPC, "failed to initialize WiFi driver"); g_object_unref (object); return NULL; } g_signal_connect (nm_manager_get (), "device-added", G_CALLBACK (device_added_cb), self); g_signal_connect (nm_manager_get (), "device-removed", G_CALLBACK (device_removed_cb), self); /* shorter timeout for mesh connectivity */ nm_device_set_dhcp_timeout (NM_DEVICE (self), 20); return object; }
static gboolean check_companion_cb (gpointer user_data) { NMDeviceOlpcMesh *self = NM_DEVICE_OLPC_MESH (user_data); NMDeviceOlpcMeshPrivate *priv = NM_DEVICE_OLPC_MESH_GET_PRIVATE (self); NMManager *manager; GSList *list; if (priv->companion != NULL) { nm_device_state_changed (NM_DEVICE (user_data), NM_DEVICE_STATE_DISCONNECTED, NM_DEVICE_STATE_REASON_NONE); return FALSE; } if (priv->device_added_id != 0) return FALSE; manager = nm_manager_get (); priv->device_added_id = g_signal_connect (manager, "device-added", G_CALLBACK (device_added_cb), self); /* Try to find the companion if it's already known to the NMManager */ for (list = nm_manager_get_devices (manager); list ; list = g_slist_next (list)) { if (is_companion (self, NM_DEVICE (list->data))) break; } g_object_unref (manager); return FALSE; }
static gboolean carrier_update_cb (gpointer user_data) { NMDeviceAdsl *self = NM_DEVICE_ADSL (user_data); GError *error = NULL; gboolean carrier = FALSE; char *path, *contents; const char *iface; gboolean success; iface = nm_device_get_iface (NM_DEVICE (self)); path = g_strdup_printf ("/sys/class/atm/%s/carrier", iface); success = g_file_get_contents (path, &contents, NULL, &error); g_free (path); if (!success) { nm_log_dbg (LOGD_ADSL, "error reading %s: (%d) %s", path, error ? error->code : -1, error && error->message ? error->message : "(unknown)"); g_clear_error (&error); return TRUE; } carrier = (gboolean) atoi (contents); g_free (contents); nm_device_set_carrier (NM_DEVICE (self), carrier); return TRUE; }
static void get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { NMDeviceBridgePrivate *priv = NM_DEVICE_BRIDGE_GET_PRIVATE (object); GPtrArray *slaves; GSList *list, *iter; char *hwaddr; switch (prop_id) { case PROP_HW_ADDRESS: hwaddr = nm_utils_hwaddr_ntoa (priv->hw_addr, nm_utils_hwaddr_type (priv->hw_addr_len)); g_value_take_string (value, hwaddr); break; case PROP_CARRIER: g_value_set_boolean (value, nm_device_wired_get_carrier (NM_DEVICE_WIRED (object))); break; case PROP_SLAVES: slaves = g_ptr_array_new (); list = nm_device_master_get_slaves (NM_DEVICE (object)); for (iter = list; iter; iter = iter->next) g_ptr_array_add (slaves, g_strdup (nm_device_get_path (NM_DEVICE (iter->data)))); g_slist_free (list); g_value_take_boxed (value, slaves); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }
static void constructed (GObject *object) { G_OBJECT_CLASS (nm_device_bridge_parent_class)->constructed (object); nm_log_dbg (LOGD_HW | LOGD_BRIDGE, "(%s): kernel ifindex %d", nm_device_get_iface (NM_DEVICE (object)), nm_device_get_ifindex (NM_DEVICE (object))); }
static void emit_nsp_added_removed (NMDeviceWimax *self, guint signum, NMWimaxNsp *nsp, gboolean recheck_available_connections) { g_signal_emit (self, signals[signum], 0, nsp); g_object_notify (G_OBJECT (self), NM_DEVICE_WIMAX_NSPS); nm_device_emit_recheck_auto_activate (NM_DEVICE (self)); if (recheck_available_connections) nm_device_recheck_available_connections (NM_DEVICE (self)); }
/** * nm_act_request_new: * * @connection: the connection to activate @device with * @specific_object: the object path of the specific object (ie, WiFi access point, * etc) that will be used to activate @connection and @device * @user_requested: pass %TRUE if the activation was requested via D-Bus, * otherwise %FALSE if requested internally by NM (ie, autoconnect) * @user_uid: if @user_requested is %TRUE, the Unix UID of the user that requested * @dbus_sender: if @user_requested is %TRUE, the D-BUS sender that requested * the activation * @assumed: pass %TRUE if the activation should "assume" (ie, taking over) an * existing connection made before this instance of NM started * @device: the device/interface to configure according to @connection * @dependency: if the activation depends on another device (ie, VLAN slave, * bond slave, etc) pass the #NMActiveConnection that this activation request * should wait for before proceeding * * Begins activation of @device using the given @connection and other details. * * Returns: the new activation request on success, %NULL on error. */ NMActRequest * nm_act_request_new (NMConnection *connection, const char *specific_object, gboolean user_requested, gulong user_uid, const char *dbus_sender, gboolean assumed, gpointer *device, NMActiveConnection *dependency) { GObject *object; NMActRequestPrivate *priv; g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL); g_return_val_if_fail (NM_DEVICE (device), NULL); object = g_object_new (NM_TYPE_ACT_REQUEST, NM_ACTIVE_CONNECTION_SPECIFIC_OBJECT, specific_object, NULL); if (!object) return NULL; priv = NM_ACT_REQUEST_GET_PRIVATE (object); priv->connection = g_object_ref (connection); priv->device = NM_DEVICE (device); g_signal_connect (device, "state-changed", G_CALLBACK (device_state_changed), NM_ACT_REQUEST (object)); priv->user_uid = user_uid; priv->user_requested = user_requested; priv->dbus_sender = g_strdup (dbus_sender); priv->assumed = assumed; if (dependency) { priv->dep = dependency; g_object_weak_ref (G_OBJECT (dependency), (GWeakNotify) dep_gone, object); priv->dep_state_id = g_signal_connect (dependency, "notify::" NM_ACTIVE_CONNECTION_STATE, G_CALLBACK (dep_state_changed), object); } if (!nm_active_connection_export (NM_ACTIVE_CONNECTION (object), connection, nm_device_get_path (NM_DEVICE (device)))) { g_object_unref (object); object = NULL; } return (NMActRequest *) object; }
static void device_added_cb (NMManager *manager, NMDevice *other, gpointer user_data) { NMDeviceOlpcMesh *self = NM_DEVICE_OLPC_MESH (user_data); NMDeviceOlpcMeshPrivate *priv = NM_DEVICE_OLPC_MESH_GET_PRIVATE (self); if (!priv->companion && check_companion (self, other)) { nm_device_state_changed (NM_DEVICE (self), NM_DEVICE_STATE_DISCONNECTED, NM_DEVICE_STATE_REASON_NONE); nm_device_remove_pending_action (NM_DEVICE (self), "waiting for companion", TRUE); } }
static gboolean bt_connect_timeout (gpointer user_data) { NMDeviceBt *self = NM_DEVICE_BT (user_data); nm_log_dbg (LOGD_BT, "(%s): initial connection timed out", nm_device_get_iface (NM_DEVICE (self))); NM_DEVICE_BT_GET_PRIVATE (self)->timeout_id = 0; nm_device_state_changed (NM_DEVICE (self), NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_BT_FAILED); return FALSE; }
static gboolean is_companion (NMDeviceOlpcMesh *self, NMDevice *other) { NMDeviceOlpcMeshPrivate *priv = NM_DEVICE_OLPC_MESH_GET_PRIVATE (self); struct ether_addr their_addr; NMManager *manager; if (!NM_IS_DEVICE_WIFI (other)) return FALSE; nm_device_wifi_get_address (NM_DEVICE_WIFI (other), &their_addr); if (memcmp (priv->hw_addr.ether_addr_octet, their_addr.ether_addr_octet, ETH_ALEN) != 0) { return FALSE; } /* FIXME detect when our companion leaves */ priv->companion = other; /* When we've found the companion, stop listening for other devices */ manager = nm_manager_get (); if (priv->device_added_id) { g_signal_handler_disconnect (manager, priv->device_added_id); priv->device_added_id = 0; } g_object_unref (manager); nm_device_state_changed (NM_DEVICE (self), NM_DEVICE_STATE_DISCONNECTED, NM_DEVICE_STATE_REASON_NONE); nm_log_info (LOGD_OLPC_MESH, "(%s): found companion WiFi device %s", nm_device_get_iface (NM_DEVICE (self)), nm_device_get_iface (other)); g_signal_connect (G_OBJECT (other), "state-changed", G_CALLBACK (companion_state_changed_cb), self); g_signal_connect (G_OBJECT (other), "notify::scanning", G_CALLBACK (companion_notify_cb), self); g_signal_connect (G_OBJECT (other), "scanning-allowed", G_CALLBACK (companion_scan_allowed_cb), self); g_signal_connect (G_OBJECT (other), "autoconnect-allowed", G_CALLBACK (companion_autoconnect_allowed_cb), self); g_object_notify (G_OBJECT (self), NM_DEVICE_OLPC_MESH_COMPANION); return TRUE; }
static gboolean link_timeout_cb (gpointer user_data) { NMDeviceWimax *self = NM_DEVICE_WIMAX (user_data); NMDeviceWimaxPrivate *priv = NM_DEVICE_WIMAX_GET_PRIVATE (self); priv->link_timeout_id = 0; nm_log_dbg (LOGD_WIMAX, "(%s): link timed out", nm_device_get_iface (NM_DEVICE (self))); nm_device_state_changed (NM_DEVICE (self), NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_CARRIER); return FALSE; }
static gboolean carrier_update_cb (gpointer user_data) { NMDeviceAdsl *self = NM_DEVICE_ADSL (user_data); int carrier; char *path; path = g_strdup_printf ("/sys/class/atm/%s/carrier", ASSERT_VALID_PATH_COMPONENT (nm_device_get_iface (NM_DEVICE (self)))); carrier = (int) nm_platform_sysctl_get_int_checked (NM_PLATFORM_GET, path, 10, 0, 1, -1); g_free (path); if (carrier != -1) nm_device_set_carrier (NM_DEVICE (self), carrier); return TRUE; }
static void deactivate (NMDevice *device) { NMDeviceAdsl *self = NM_DEVICE_ADSL (device); NMDeviceAdslPrivate *priv = NM_DEVICE_ADSL_GET_PRIVATE (self); if (priv->ppp_manager) { g_object_unref (priv->ppp_manager); priv->ppp_manager = NULL; } if (priv->lost_link_id) { g_signal_handler_disconnect (nm_platform_get (), priv->lost_link_id); priv->lost_link_id = 0; } if (priv->brfd >= 0) { close (priv->brfd); priv->brfd = -1; } /* FIXME: kernel has no way of explicitly deleting the 'nasX' interface yet, * so it gets leaked. It does get destroyed when it's no longer in use, * but we have no control over that. */ if (priv->nas_ifindex >= 0) priv->nas_ifindex = -1; g_free (priv->nas_ifname); priv->nas_ifname = NULL; /* Poke NMDevice to notice that our hw_address is no longer valid */ nm_device_update_hw_address (NM_DEVICE (self)); }
static void constructed (GObject *object) { update_properties (NM_DEVICE (object)); G_OBJECT_CLASS (nm_device_macvlan_parent_class)->constructed (object); }
/** * nm_device_wimax_get_active_nsp: * @wimax: a #NMDeviceWimax * * Gets the active #NMWimaxNsp. * * Returns: (transfer full): the access point or %NULL if none is active * * Deprecated: 1.2: WiMAX is no longer supported. **/ NMWimaxNsp * nm_device_wimax_get_active_nsp (NMDeviceWimax *wimax) { NMDeviceState state; g_return_val_if_fail (NM_IS_DEVICE_WIMAX (wimax), NULL); state = nm_device_get_state (NM_DEVICE (wimax)); switch (state) { case NM_DEVICE_STATE_PREPARE: case NM_DEVICE_STATE_CONFIG: case NM_DEVICE_STATE_NEED_AUTH: case NM_DEVICE_STATE_IP_CONFIG: case NM_DEVICE_STATE_IP_CHECK: case NM_DEVICE_STATE_SECONDARIES: case NM_DEVICE_STATE_ACTIVATED: case NM_DEVICE_STATE_DEACTIVATING: break; default: return NULL; break; } return NM_DEVICE_WIMAX_GET_PRIVATE (wimax)->active_nsp; }
static void device_master_changed (GObject *object, GParamSpec *pspec, gpointer user_data) { NMDevice *device = NM_DEVICE (object); NMActiveConnection *self = NM_ACTIVE_CONNECTION (user_data); NMActiveConnection *master; NMActiveConnectionState master_state; if (NM_ACTIVE_CONNECTION (nm_device_get_act_request (device)) != self) return; if (!nm_device_get_master (device)) return; if (!nm_active_connection_get_master (self)) return; g_signal_handlers_disconnect_by_func (device, G_CALLBACK (device_master_changed), self); master = nm_active_connection_get_master (self); master_state = nm_active_connection_get_state (master); if (master_state >= NM_ACTIVE_CONNECTION_STATE_DEACTIVATING) { /* Master failed before attaching the slave */ if (NM_ACTIVE_CONNECTION_GET_CLASS (self)->master_failed) NM_ACTIVE_CONNECTION_GET_CLASS (self)->master_failed (self); } }
/** * nm_act_request_new: * * @connection: the connection to activate @device with * @specific_object: the object path of the specific object (ie, WiFi access point, * etc) that will be used to activate @connection and @device * @user_requested: pass %TRUE if the activation was requested via D-Bus, * otherwise %FALSE if requested internally by NM (ie, autoconnect) * @user_uid: if @user_requested is %TRUE, the Unix UID of the user that requested * @dbus_sender: if @user_requested is %TRUE, the D-BUS sender that requested * the activation * @assumed: pass %TRUE if the activation should "assume" (ie, taking over) an * existing connection made before this instance of NM started * @device: the device/interface to configure according to @connection * @master: if the activation depends on another device (ie, bond or bridge * master to which this device will be enslaved) pass the #NMDevice that this * activation request be enslaved to * * Begins activation of @device using the given @connection and other details. * * Returns: the new activation request on success, %NULL on error. */ NMActRequest * nm_act_request_new (NMConnection *connection, const char *specific_object, gboolean user_requested, gulong user_uid, const char *dbus_sender, gboolean assumed, NMDevice *device, NMDevice *master) { GObject *object; g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL); g_return_val_if_fail (NM_DEVICE (device), NULL); object = g_object_new (NM_TYPE_ACT_REQUEST, NM_ACTIVE_CONNECTION_INT_CONNECTION, connection, NM_ACTIVE_CONNECTION_INT_DEVICE, device, NM_ACTIVE_CONNECTION_SPECIFIC_OBJECT, specific_object, NM_ACTIVE_CONNECTION_INT_USER_REQUESTED, user_requested, NM_ACTIVE_CONNECTION_INT_USER_UID, user_uid, NM_ACTIVE_CONNECTION_INT_ASSUMED, assumed, NM_ACTIVE_CONNECTION_INT_MASTER, master, NULL); if (object) { nm_active_connection_export (NM_ACTIVE_CONNECTION (object)); NM_ACT_REQUEST_GET_PRIVATE (object)->dbus_sender = g_strdup (dbus_sender); } return (NMActRequest *) object; }
static void force_disconnect (NMDeviceWimax *self, struct wmxsdk *sdk) { WIMAX_API_DEVICE_STATUS status; int ret; const char *iface; g_return_if_fail (sdk != NULL); iface = nm_device_get_iface (NM_DEVICE (self)); status = iwmxsdk_status_get (sdk); if ((int) status < 0) { nm_log_err (LOGD_WIMAX, "(%s): failed to read WiMAX device status: %d", iface, status); return; } if ( status == WIMAX_API_DEVICE_STATUS_Connecting || status == WIMAX_API_DEVICE_STATUS_Data_Connected) { nm_log_dbg (LOGD_WIMAX, "(%s): requesting disconnect", iface); ret = iwmx_sdk_disconnect (sdk); if (ret < 0 && ret != -EINPROGRESS) { nm_log_err (LOGD_WIMAX, "(%s): failed to disconnect WiMAX device: %d", iface, ret); } } }
static gboolean update_availability (NMDeviceWimax *self, gboolean old_available) { NMDevice *device = NM_DEVICE (self); NMDeviceState state; gboolean new_available, changed = FALSE; new_available = nm_device_is_available (device); if (new_available == old_available) return FALSE; state = nm_device_get_state (device); if (state == NM_DEVICE_STATE_UNAVAILABLE) { if (new_available == TRUE) { nm_device_state_changed (device, NM_DEVICE_STATE_DISCONNECTED, NM_DEVICE_STATE_REASON_NONE); changed = TRUE; } } else if (state >= NM_DEVICE_STATE_DISCONNECTED) { if (new_available == FALSE) { nm_device_state_changed (device, NM_DEVICE_STATE_UNAVAILABLE, NM_DEVICE_STATE_REASON_NONE); changed = TRUE; } } return changed; }
static void reload_tun_properties (NMDeviceTun *self) { NMDeviceTunPrivate *priv = NM_DEVICE_TUN_GET_PRIVATE (self); GObject *object = G_OBJECT (self); NMPlatformTunProperties props; if (!nm_platform_tun_get_properties (NM_PLATFORM_GET, nm_device_get_ifindex (NM_DEVICE (self)), &props)) { _LOGD (LOGD_HW, "could not read tun properties"); return; } g_object_freeze_notify (object); if (priv->props.owner != props.owner) g_object_notify (object, NM_DEVICE_TUN_OWNER); if (priv->props.group != props.group) g_object_notify (object, NM_DEVICE_TUN_GROUP); if (priv->props.no_pi != props.no_pi) g_object_notify (object, NM_DEVICE_TUN_NO_PI); if (priv->props.vnet_hdr != props.vnet_hdr) g_object_notify (object, NM_DEVICE_TUN_VNET_HDR); if (priv->props.multi_queue != props.multi_queue) g_object_notify (object, NM_DEVICE_TUN_MULTI_QUEUE); memcpy (&priv->props, &props, sizeof (NMPlatformTunProperties)); g_object_thaw_notify (object); }
static void carrier_off (NMNetlinkMonitor *monitor, int idx, gpointer user_data) { NMDevice *device = NM_DEVICE (user_data); NMDeviceWired *self = NM_DEVICE_WIRED (device); guint32 caps; /* Make sure signal is for us */ if (idx == nm_device_get_ifindex (device)) { NMDeviceState state; gboolean defer = FALSE; caps = nm_device_get_capabilities (device); g_return_if_fail (caps & NM_DEVICE_CAP_CARRIER_DETECT); /* Defer carrier-off event actions while connected by a few seconds * so that tripping over a cable, power-cycling a switch, or breaking * off the RJ45 locking tab isn't so catastrophic. */ state = nm_device_get_state (device); if (state > NM_DEVICE_STATE_DISCONNECTED) defer = TRUE; set_carrier (self, FALSE, defer); } }
static void update_switches_visibility (NmnApplet *applet) { NmnAppletPrivate *priv = GET_PRIVATE (applet); GtkTable *table; gboolean visible; int ethernet; int wifi; int modem; int wimax; int bt; ethernet = wifi = modem = wimax = bt = 0; if (!nmn_model_offline_mode_get_active (priv->model)) { const GPtrArray *devices; int i; devices = nm_client_get_devices (nmn_model_get_client (priv->model)); for (i = 0; devices && i < devices->len; i++) { NMDevice *device = NM_DEVICE (g_ptr_array_index (devices, i)); if (NM_IS_DEVICE_ETHERNET (device)) ethernet++; else if (NM_IS_DEVICE_WIFI (device)) wifi++; else if (NM_IS_SERIAL_DEVICE (device)) modem++; else if (NM_IS_DEVICE_BT (device)) bt++; } } table = GTK_TABLE (priv->switches_table); visible = wifi > 0; gtk_table_set_row_spacing (table, SWITCHES_ROW_WIFI, visible ? 6 : 0); g_object_set (priv->enable_wifi_label, "visible", visible, NULL); g_object_set (priv->enable_wifi, "visible", visible, NULL); visible = ethernet > 0; gtk_table_set_row_spacing (table, SWITCHES_ROW_ETHERNET, visible ? 6 : 0); g_object_set (priv->enable_ethernet_label, "visible", visible, NULL); g_object_set (priv->enable_ethernet, "visible", visible, NULL); visible = modem > 0; gtk_table_set_row_spacing (table, SWITCHES_ROW_3G, visible ? 6 : 0); g_object_set (priv->enable_3g_label, "visible", visible, NULL); g_object_set (priv->enable_3g, "visible", visible, NULL); visible = wimax > 0; gtk_table_set_row_spacing (table, SWITCHES_ROW_WIMAX, visible ? 6 : 0); g_object_set (priv->enable_wimax_label, "visible", visible, NULL); g_object_set (priv->enable_wimax, "visible", visible, NULL); visible = bt > 0; gtk_table_set_row_spacing (table, SWITCHES_ROW_BT, visible ? 6 : 0); g_object_set (priv->enable_bt_label, "visible", visible, NULL); g_object_set (priv->enable_bt, "visible", visible, NULL); }
static gboolean pppoe_vcc_config (NMDeviceAdsl *self) { NMDeviceAdslPrivate *priv = NM_DEVICE_ADSL_GET_PRIVATE (self); NMDevice *device = NM_DEVICE (self); NMSettingAdsl *s_adsl; s_adsl = nm_connection_get_setting_adsl (nm_device_get_applied_connection (device)); g_assert (s_adsl); /* Set up the VCC */ if (!br2684_assign_vcc (self, s_adsl)) return FALSE; /* Watch for the 'nas' interface going away */ g_signal_connect (NM_PLATFORM_GET, NM_PLATFORM_SIGNAL_LINK_CHANGED, G_CALLBACK (link_changed_cb), self); _LOGD (LOGD_ADSL, "ATM setup successful"); /* otherwise we're good for stage3 */ nm_platform_link_set_up (NM_PLATFORM_GET, priv->nas_ifindex, NULL); return TRUE; }