dbus_bool_t ni_objectmodel_macvtap_newlink(ni_dbus_object_t *factory_object, const ni_dbus_method_t *method, unsigned int argc, const ni_dbus_variant_t *argv, ni_dbus_message_t *reply, DBusError *error) { ni_dbus_server_t *server = ni_dbus_object_get_server(factory_object); ni_netdev_t *dev; const char *ifname = NULL; NI_TRACE_ENTER(); ni_assert(argc == 2); if (!ni_dbus_variant_get_string(&argv[0], &ifname) || !(dev = __ni_objectmodel_macvlan_device_arg(&argv[1], NI_IFTYPE_MACVTAP))) { return ni_dbus_error_invalid_args(error, factory_object->path, method->name); } if (!(dev = __ni_objectmodel_macvlan_newlink(dev, ifname, error))) return FALSE; return ni_objectmodel_netif_factory_result(server, reply, dev, NULL, error); }
/* * Create a new PPP interface * We're given two arguments, the interface name and the <ppp> configuration data. * However, we ignore all the config data at this point and just create the * device. The configuration data is consumed by a subsequent call to changeDevice * (where we build a config file from it). */ dbus_bool_t ni_objectmodel_ppp_newlink(ni_dbus_object_t *factory_object, const ni_dbus_method_t *method, unsigned int argc, const ni_dbus_variant_t *argv, ni_dbus_message_t *reply, DBusError *error, __get_device_arg_fn_t get_device_arg_fn) { ni_dbus_server_t *server = ni_dbus_object_get_server(factory_object); const char *ifname = NULL; ni_netdev_t *dev, *dev_cfg; NI_TRACE_ENTER(); ni_assert(argc == 2); if (!ni_dbus_variant_get_string(&argv[0], &ifname)) return ni_dbus_error_invalid_args(error, factory_object->path, method->name); if (!(dev_cfg = get_device_arg_fn(&argv[1], error))) return FALSE; dev = __ni_objectmodel_ppp_newlink(dev_cfg, ifname, error); ni_netdev_put(dev_cfg); if (dev == NULL) return FALSE; return ni_objectmodel_netif_factory_result(server, reply, dev, NULL, error); }
static dbus_bool_t __ni_objectmodel_tuntap_newlink(ni_iftype_t iftype, ni_dbus_object_t *factory_object, const ni_dbus_method_t *method, unsigned int argc, const ni_dbus_variant_t *argv, ni_dbus_message_t *reply, DBusError *error) { ni_dbus_server_t *server = ni_dbus_object_get_server(factory_object); const char *ifname = NULL; ni_netdev_t *dev; ni_netdev_t *cfg; NI_TRACE_ENTER(); ni_assert(argc == 2); if (!ni_dbus_variant_get_string(&argv[0], &ifname) || !(cfg = __ni_objectmodel_tuntap_device_arg(&argv[1], iftype))) { return ni_dbus_error_invalid_args(error, factory_object->path, method->name); } ni_string_dup(&cfg->name, ifname); dev = __ni_objectmodel_tuntap_create(cfg, error); ni_netdev_put(cfg); if (!dev) return FALSE; return ni_objectmodel_netif_factory_result(server, reply, dev, NULL, error); }
/* * Destructor for DBus client handle */ void ni_dbus_client_free(ni_dbus_client_t *dbc) { NI_TRACE_ENTER(); if (!dbc) return; if (dbc->connection) ni_dbus_connection_free(dbc->connection); dbc->connection = NULL; ni_string_free(&dbc->bus_name); free(dbc); }
static dbus_bool_t ni_objectmodel_ib_newchild(ni_dbus_object_t *factory_object, const ni_dbus_method_t *method, unsigned int argc, const ni_dbus_variant_t *argv, ni_dbus_message_t *reply, DBusError *error) { ni_dbus_server_t *server = ni_dbus_object_get_server(factory_object); ni_netdev_t *cfg, *dev; const char *ifname = NULL; NI_TRACE_ENTER(); if (argc != 2 || !ni_dbus_variant_get_string(&argv[0], &ifname) || !ifname || !(cfg = __ni_objectmodel_ibchild_device_arg(&argv[1]))) { return ni_dbus_error_invalid_args(error, factory_object->path, method->name); } if (!(dev = __ni_objectmodel_ib_newchild(cfg, ifname, error))) { ni_netdev_put(cfg); return FALSE; } ni_netdev_put(cfg); return ni_objectmodel_netif_factory_result(server, reply, dev, NULL, error); }