NMDevice * nm_device_bridge_new_for_connection (NMConnection *connection) { const char *iface; g_return_val_if_fail (connection != NULL, NULL); iface = nm_connection_get_virtual_iface_name (connection); g_return_val_if_fail (iface != NULL, NULL); if ( !nm_platform_bridge_add (iface) && nm_platform_get_error () != NM_PLATFORM_ERROR_EXISTS) { nm_log_warn (LOGD_DEVICE | LOGD_BRIDGE, "(%s): failed to create bridge master interface for '%s': %s", iface, nm_connection_get_id (connection), nm_platform_get_error_msg ()); return NULL; } return (NMDevice *) g_object_new (NM_TYPE_DEVICE_BRIDGE, NM_DEVICE_IFACE, iface, NM_DEVICE_DRIVER, "bridge", NM_DEVICE_TYPE_DESC, "Bridge", NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_BRIDGE, NM_DEVICE_IS_MASTER, TRUE, NULL); }
static NMDevice * create_virtual_device_for_connection (NMDeviceFactory *factory, NMConnection *connection, NMDevice *parent, GError **error) { const char *iface; if (!nm_connection_is_type (connection, NM_SETTING_BOND_SETTING_NAME)) return NULL; iface = nm_connection_get_interface_name (connection); g_return_val_if_fail (iface != NULL, NULL); if ( !nm_platform_bond_add (iface) && nm_platform_get_error () != NM_PLATFORM_ERROR_EXISTS) { nm_log_warn (LOGD_DEVICE | LOGD_BOND, "(%s): failed to create bonding master interface for '%s': %s", iface, nm_connection_get_id (connection), nm_platform_get_error_msg ()); return NULL; } return (NMDevice *) g_object_new (NM_TYPE_DEVICE_BOND, NM_DEVICE_IFACE, iface, NM_DEVICE_DRIVER, "bonding", NM_DEVICE_TYPE_DESC, "Bond", NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_BOND, NM_DEVICE_IS_MASTER, TRUE, NULL); }
int main (int argc, char **argv) { const char *arg0 = *argv++; const command_t *command = NULL; gboolean status = TRUE; int error; g_type_init (); if (*argv && !g_strcmp0 (argv[1], "--fake")) { nm_fake_platform_setup (); } else nm_linux_platform_setup (); if (*argv) for (command = commands; command->name; command++) if (g_str_has_prefix (command->name, *argv)) break; if (command && command->name) { argv++; if (g_strv_length (argv) == command->argc) status = command->handler (argv); else { error ("Wrong number of arguments to '%s' (expected %d).\n\nUsage: %s %s %s\n-- %s\n", command->name, command->argc, arg0, command->name, command->arghelp, command->help); return EXIT_FAILURE; } } else { error ("Usage: %s COMMAND\n\n", arg0); error ("COMMAND\n"); for (command = commands; command->name; command++) error (" %s %s\n -- %s\n", command->name, command->arghelp, command->help); error ("\n"); } error = nm_platform_get_error (); if (error) { const char *msg = nm_platform_get_error_msg (); error ("nm-platform: %s\n", msg); } return !!error; }
static NMDevice * create_virtual_device_for_connection (NMDeviceFactory *factory, NMConnection *connection, NMDevice *parent, GError **error) { NMSettingInfiniband *s_infiniband; int p_key, parent_ifindex; const char *iface; if (!nm_connection_is_type (connection, NM_SETTING_INFINIBAND_SETTING_NAME)) return NULL; g_return_val_if_fail (NM_IS_DEVICE_INFINIBAND (parent), NULL); s_infiniband = nm_connection_get_setting_infiniband (connection); iface = nm_setting_infiniband_get_virtual_interface_name (s_infiniband); g_return_val_if_fail (iface != NULL, NULL); parent_ifindex = nm_device_get_ifindex (parent); p_key = nm_setting_infiniband_get_p_key (s_infiniband); if ( !nm_platform_infiniband_partition_add (parent_ifindex, p_key) && nm_platform_get_error () != NM_PLATFORM_ERROR_EXISTS) { nm_log_warn (LOGD_DEVICE | LOGD_INFINIBAND, "(%s): failed to add InfiniBand P_Key interface for '%s': %s", iface, nm_connection_get_id (connection), nm_platform_get_error_msg ()); return NULL; } return (NMDevice *) g_object_new (NM_TYPE_DEVICE_INFINIBAND, NM_DEVICE_IFACE, iface, NM_DEVICE_DRIVER, nm_device_get_driver (parent), NM_DEVICE_TYPE_DESC, "InfiniBand", NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_INFINIBAND, NULL); }