/* * Create a new ppp interface */ static dbus_bool_t ni_objectmodel_ppp_device_new(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, *cfg; const char *ifname = NULL; if (argc != 2) goto error; if (!ni_dbus_variant_get_string(&argv[0], &ifname)) goto error; if (!(cfg = ni_objectmodel_ppp_device_arg(&argv[1]))) goto error; dev = ni_objectmodel_ppp_device_create(cfg, ifname, error); ni_netdev_put(cfg); if (dev) return ni_objectmodel_netif_factory_result(server, reply, dev, NULL, error); else return FALSE; error: return ni_dbus_error_invalid_args(error, factory_object->path, method->name); }
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); }
/* * Send Eventlog.connected() signal */ static void ni_testbus_eventlog_signal_eventsAdded(ni_dbus_object_t *eventlog_object, uint32_t last_seq) { ni_dbus_variant_t arg = NI_DBUS_VARIANT_INIT; ni_dbus_variant_set_uint32(&arg, last_seq); /* Send the signal */ ni_dbus_server_send_signal(ni_dbus_object_get_server(eventlog_object), eventlog_object, NI_TESTBUS_EVENTLOG_INTERFACE, "eventsAdded", 1, &arg); ni_dbus_variant_destroy(&arg); }
/* * Create a new ovs bridge interface */ static dbus_bool_t __ni_objectmodel_ovs_bridge_create(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 *ifp; const char *ifname = NULL; ni_assert(argc == 2); if (!ni_dbus_variant_get_string(&argv[0], &ifname) || !(ifp = __ni_objectmodel_ovs_bridge_device_arg(&argv[1]))) return ni_dbus_error_invalid_args(error, factory_object->path, method->name); if (!(ifp = __ni_objectmodel_ovs_bridge_newlink(ifp, ifname, error))) return FALSE; return ni_objectmodel_netif_factory_result(server, reply, ifp, NULL, error); }
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); }