static NMActStageReturn act_stage2_config (NMDevice *device, NMDeviceStateReason *reason) { NMDeviceOlpcMesh *self = NM_DEVICE_OLPC_MESH (device); NMConnection *connection; NMSettingOlpcMesh *s_mesh; guint32 channel; GBytes *ssid; const char *anycast_addr; connection = nm_device_get_connection (device); g_assert (connection); s_mesh = nm_connection_get_setting_olpc_mesh (connection); g_assert (s_mesh); channel = nm_setting_olpc_mesh_get_channel (s_mesh); if (channel != 0) _mesh_set_channel (self, channel); ssid = nm_setting_olpc_mesh_get_ssid (s_mesh); nm_platform_mesh_set_ssid (nm_device_get_ifindex (device), g_bytes_get_data (ssid, NULL), g_bytes_get_size (ssid)); anycast_addr = nm_setting_olpc_mesh_get_dhcp_anycast_address (s_mesh); nm_device_set_dhcp_anycast_address (device, anycast_addr); return NM_ACT_STAGE_RETURN_SUCCESS; }
static NMActStageReturn act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason) { NMActStageReturn ret = NM_ACT_STAGE_RETURN_SUCCESS; NMConnection *connection; NMSettingBridge *s_bridge; const char *iface; g_return_val_if_fail (reason != NULL, NM_ACT_STAGE_RETURN_FAILURE); ret = NM_DEVICE_CLASS (nm_device_bridge_parent_class)->act_stage1_prepare (dev, reason); if (ret == NM_ACT_STAGE_RETURN_SUCCESS) { connection = nm_device_get_connection (dev); g_assert (connection); s_bridge = nm_connection_get_setting_bridge (connection); g_assert (s_bridge); iface = nm_device_get_ip_iface (dev); g_assert (iface); set_sysfs_uint (iface, G_OBJECT (s_bridge), NM_SETTING_BRIDGE_STP, "bridge", "stp_state", FALSE, FALSE); set_sysfs_uint (iface, G_OBJECT (s_bridge), NM_SETTING_BRIDGE_PRIORITY, "bridge", "priority", TRUE, FALSE); set_sysfs_uint (iface, G_OBJECT (s_bridge), NM_SETTING_BRIDGE_FORWARD_DELAY, "bridge", "forward_delay", TRUE, TRUE); set_sysfs_uint (iface, G_OBJECT (s_bridge), NM_SETTING_BRIDGE_HELLO_TIME, "bridge", "hello_time", TRUE, TRUE); set_sysfs_uint (iface, G_OBJECT (s_bridge), NM_SETTING_BRIDGE_MAX_AGE, "bridge", "max_age", TRUE, TRUE); set_sysfs_uint (iface, G_OBJECT (s_bridge), NM_SETTING_BRIDGE_AGEING_TIME, "bridge", "ageing_time", TRUE, TRUE); } return ret; }
static NMActStageReturn act_stage2_config (NMDevice *device, NMDeviceStateReason *out_reason) { NMDeviceAdsl *self = NM_DEVICE_ADSL (device); NMDeviceAdslPrivate *priv = NM_DEVICE_ADSL_GET_PRIVATE (self); NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE; NMSettingAdsl *s_adsl; const char *protocol; g_assert (out_reason); s_adsl = nm_connection_get_setting_adsl (nm_device_get_connection (device)); g_assert (s_adsl); protocol = nm_setting_adsl_get_protocol (s_adsl); nm_log_dbg (LOGD_ADSL, "(%s): using ADSL protocol '%s'", nm_device_get_iface (device), protocol); if (g_strcmp0 (protocol, NM_SETTING_ADSL_PROTOCOL_PPPOE) == 0) { /* PPPoE needs RFC2684 bridging before we can do PPP over it */ if (!br2684_create_iface (self, s_adsl)) { *out_reason = NM_DEVICE_STATE_REASON_BR2684_FAILED; goto done; } /* Set up the VCC */ if (!br2684_assign_vcc (self, s_adsl)) { *out_reason = NM_DEVICE_STATE_REASON_BR2684_FAILED; goto done; } /* Watch for the 'nas' interface going away */ priv->lost_link_id = g_signal_connect (nm_platform_get (), "link-removed", G_CALLBACK (lost_link), self); nm_log_dbg (LOGD_ADSL, "(%s): ATM setup successful", nm_device_get_iface (device)); /* otherwise we're good for stage3 */ nm_platform_link_set_up (priv->nas_ifindex); ret = NM_ACT_STAGE_RETURN_SUCCESS; } else if (g_strcmp0 (protocol, NM_SETTING_ADSL_PROTOCOL_PPPOA) == 0) { /* PPPoA doesn't need anything special */ ret = NM_ACT_STAGE_RETURN_SUCCESS; } else { nm_log_warn (LOGD_ADSL, "(%s): unhandled ADSL protocol '%s'", nm_device_get_iface (device), protocol); } done: return ret; }
static NMActStageReturn act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason) { NMActStageReturn ret; NMConnection *connection = nm_device_get_connection (device); g_assert (connection); ret = NM_DEVICE_CLASS (nm_device_bridge_parent_class)->act_stage1_prepare (device, reason); if (ret != NM_ACT_STAGE_RETURN_SUCCESS) return ret; commit_master_options (device, nm_connection_get_setting_bridge (connection)); return NM_ACT_STAGE_RETURN_SUCCESS; }
static void real_ip4_config_pre_commit (NMDevice *self, NMIP4Config *config) { NMConnection *connection; NMSettingInfiniband *s_infiniband; guint32 mtu; connection = nm_device_get_connection (self); g_assert (connection); s_infiniband = nm_connection_get_setting_infiniband (connection); g_assert (s_infiniband); /* MTU override */ mtu = nm_setting_infiniband_get_mtu (s_infiniband); if (mtu) nm_ip4_config_set_mtu (config, mtu); }
static void ip4_config_pre_commit (NMDevice *device, NMIP4Config *config) { NMConnection *connection; NMSettingWired *s_wired; guint32 mtu; connection = nm_device_get_connection (device); g_assert (connection); s_wired = nm_connection_get_setting_wired (connection); if (s_wired) { mtu = nm_setting_wired_get_mtu (s_wired); if (mtu) nm_ip4_config_set_mtu (config, mtu); } }
static NMActStageReturn act_stage2_config (NMDevice *device, NMDeviceStateReason *reason) { NMDeviceWimaxPrivate *priv = NM_DEVICE_WIMAX_GET_PRIVATE (device); NMConnection *connection; NMSettingWimax *s_wimax; const char *nsp_name, *iface; int ret; iface = nm_device_get_iface (device); g_assert (iface); connection = nm_device_get_connection (device); g_assert (connection); s_wimax = nm_connection_get_setting_wimax (connection); g_assert (s_wimax); nsp_name = nm_setting_wimax_get_network_name (s_wimax); g_assert (nsp_name); nm_log_info (LOGD_WIMAX, "(%s): connecting to NSP '%s'", iface, nsp_name); priv->connect_failed = FALSE; ret = iwmx_sdk_connect (priv->sdk, nsp_name); if (ret < 0 && ret != -EINPROGRESS) { nm_log_err (LOGD_WIMAX, "(%s): failed to connect to NSP '%s'", iface, nsp_name); *reason = NM_DEVICE_STATE_REASON_CONFIG_FAILED; return NM_ACT_STAGE_RETURN_FAILURE; } /* FIXME: Is 40 seconds good estimation? I have no idea */ priv->activation_timeout_id = g_timeout_add_seconds (40, activation_timed_out, device); return NM_ACT_STAGE_RETURN_POSTPONE; }
static NMActStageReturn act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason) { NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE (dev); NMActStageReturn ret = NM_ACT_STAGE_RETURN_SUCCESS; NMConnection *connection; NMSettingTeam *s_team; g_return_val_if_fail (reason != NULL, NM_ACT_STAGE_RETURN_FAILURE); ret = NM_DEVICE_CLASS (nm_device_team_parent_class)->act_stage1_prepare (dev, reason); if (ret == NM_ACT_STAGE_RETURN_SUCCESS) { connection = nm_device_get_connection (dev); g_assert (connection); s_team = nm_connection_get_setting_team (connection); g_assert (s_team); if (teamd_start (dev, s_team, priv)) ret = NM_ACT_STAGE_RETURN_POSTPONE; else ret = NM_ACT_STAGE_RETURN_FAILURE; } return ret; }
static NMActStageReturn apply_bonding_config (NMDevice *device) { NMConnection *connection; NMSettingBond *s_bond; int ifindex = nm_device_get_ifindex (device); const char *mode, *value; char *contents; gboolean set_arp_interval = TRUE; /* Option restrictions: * * arp_interval conflicts miimon > 0 * arp_interval conflicts [ alb, tlb ] * arp_validate needs [ active-backup ] * downdelay needs miimon * updelay needs miimon * primary needs [ active-backup, tlb, alb ] * * clearing miimon requires that arp_interval be 0, but clearing * arp_interval doesn't require miimon to be 0 */ connection = nm_device_get_connection (device); g_assert (connection); s_bond = nm_connection_get_setting_bond (connection); g_assert (s_bond); mode = nm_setting_bond_get_option_by_name (s_bond, NM_SETTING_BOND_OPTION_MODE); if (mode == NULL) mode = "balance-rr"; value = nm_setting_bond_get_option_by_name (s_bond, NM_SETTING_BOND_OPTION_MIIMON); if (value && atoi (value)) { /* clear arp interval */ set_bond_attr (device, "arp_interval", "0"); set_arp_interval = FALSE; set_bond_attr (device, "miimon", value); set_simple_option (device, "updelay", s_bond, NM_SETTING_BOND_OPTION_UPDELAY); set_simple_option (device, "downdelay", s_bond, NM_SETTING_BOND_OPTION_DOWNDELAY); } else if (!value) { /* If not given, and arp_interval is not given, default to 100 */ long int val_int; char *end; value = nm_setting_bond_get_option_by_name (s_bond, NM_SETTING_BOND_OPTION_ARP_INTERVAL); errno = 0; val_int = strtol (value ? value : "0", &end, 10); if (!value || (val_int == 0 && errno == 0 && *end == '\0')) set_bond_attr (device, "miimon", "100"); } /* The stuff after 'mode' requires the given mode or doesn't care */ set_bond_attr (device, "mode", mode); /* arp_interval not compatible with ALB, TLB */ if (g_strcmp0 (mode, "balance-alb") == 0 || g_strcmp0 (mode, "balance-tlb") == 0) set_arp_interval = FALSE; if (set_arp_interval) { set_simple_option (device, "arp_interval", s_bond, NM_SETTING_BOND_OPTION_ARP_INTERVAL); /* Just let miimon get cleared automatically; even setting miimon to * 0 (disabled) clears arp_interval. */ } value = nm_setting_bond_get_option_by_name (s_bond, NM_SETTING_BOND_OPTION_ARP_VALIDATE); /* arp_validate > 0 only valid in active-backup mode */ if ( value && g_strcmp0 (value, "0") != 0 && g_strcmp0 (value, "none") != 0 && g_strcmp0 (mode, "active-backup") == 0) set_bond_attr (device, "arp_validate", value); else set_bond_attr (device, "arp_validate", "0"); if ( g_strcmp0 (mode, "active-backup") == 0 || g_strcmp0 (mode, "balance-alb") == 0 || g_strcmp0 (mode, "balance-tlb") == 0) { value = nm_setting_bond_get_option_by_name (s_bond, NM_SETTING_BOND_OPTION_PRIMARY); set_bond_attr (device, "primary", value ? value : ""); } /* Clear ARP targets */ contents = nm_platform_master_get_option (ifindex, "arp_ip_target"); set_arp_targets (device, contents, " \n", "-"); g_free (contents); /* Add new ARP targets */ value = nm_setting_bond_get_option_by_name (s_bond, NM_SETTING_BOND_OPTION_ARP_IP_TARGET); set_arp_targets (device, value, ",", "+"); set_simple_option (device, "primary_reselect", s_bond, NM_SETTING_BOND_OPTION_PRIMARY_RESELECT); set_simple_option (device, "fail_over_mac", s_bond, NM_SETTING_BOND_OPTION_FAIL_OVER_MAC); set_simple_option (device, "use_carrier", s_bond, NM_SETTING_BOND_OPTION_USE_CARRIER); set_simple_option (device, "ad_select", s_bond, NM_SETTING_BOND_OPTION_AD_SELECT); set_simple_option (device, "xmit_hash_policy", s_bond, NM_SETTING_BOND_OPTION_XMIT_HASH_POLICY); set_simple_option (device, "resend_igmp", s_bond, NM_SETTING_BOND_OPTION_RESEND_IGMP); return NM_ACT_STAGE_RETURN_SUCCESS; }
static NMActStageReturn act_stage2_config (NMDevice *device, NMDeviceStateReason *reason) { NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE (device); DBusGConnection *bus; gboolean dun = FALSE; NMConnection *connection; connection = nm_device_get_connection (device); g_assert (connection); priv->bt_type = get_connection_bt_type (connection); if (priv->bt_type == NM_BT_CAPABILITY_NONE) { // FIXME: set a reason code return NM_ACT_STAGE_RETURN_FAILURE; } if (priv->bt_type == NM_BT_CAPABILITY_DUN && !priv->mm_running) { *reason = NM_DEVICE_STATE_REASON_MODEM_MANAGER_UNAVAILABLE; return NM_ACT_STAGE_RETURN_FAILURE; } if (priv->bt_type == NM_BT_CAPABILITY_DUN) dun = TRUE; else if (priv->bt_type == NM_BT_CAPABILITY_NAP) dun = FALSE; else g_assert_not_reached (); bus = nm_dbus_manager_get_connection (priv->dbus_mgr); priv->dev_proxy = dbus_g_proxy_new_for_name (bus, BLUEZ_SERVICE, nm_device_get_udi (device), BLUEZ_DEVICE_INTERFACE); if (!priv->dev_proxy) { // FIXME: set a reason code return NM_ACT_STAGE_RETURN_FAILURE; } /* Watch for BT device property changes */ dbus_g_object_register_marshaller (_nm_marshal_VOID__STRING_BOXED, G_TYPE_NONE, G_TYPE_STRING, G_TYPE_VALUE, G_TYPE_INVALID); dbus_g_proxy_add_signal (priv->dev_proxy, "PropertyChanged", G_TYPE_STRING, G_TYPE_VALUE, G_TYPE_INVALID); dbus_g_proxy_connect_signal (priv->dev_proxy, "PropertyChanged", G_CALLBACK (bluez_property_changed), device, NULL); priv->type_proxy = dbus_g_proxy_new_for_name (bus, BLUEZ_SERVICE, nm_device_get_udi (device), dun ? BLUEZ_SERIAL_INTERFACE : BLUEZ_NETWORK_INTERFACE); if (!priv->type_proxy) { // FIXME: set a reason code return NM_ACT_STAGE_RETURN_FAILURE; } nm_log_dbg (LOGD_BT, "(%s): requesting connection to the device", nm_device_get_iface (device)); /* Connect to the BT device */ dbus_g_proxy_begin_call_with_timeout (priv->type_proxy, "Connect", bluez_connect_cb, device, NULL, 20000, G_TYPE_STRING, dun ? BLUETOOTH_DUN_UUID : BLUETOOTH_NAP_UUID, G_TYPE_INVALID); if (priv->timeout_id) g_source_remove (priv->timeout_id); priv->timeout_id = g_timeout_add_seconds (30, bt_connect_timeout, device); return NM_ACT_STAGE_RETURN_POSTPONE; }