static gboolean do_slave_set_option (char **argv) { int ifindex = parse_ifindex (*argv++); const char *option = *argv++; const char *value = *argv++; return nm_platform_slave_set_option (NM_PLATFORM_GET, ifindex, option, value); }
static void commit_option (NMDevice *device, NMSetting *setting, const Option *option, gboolean slave) { int ifindex = nm_device_get_ifindex (device); GParamSpec *pspec; GValue val = G_VALUE_INIT; guint32 uval = 0; gs_free char *value = NULL; g_assert (setting); pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (setting), option->name); g_assert (pspec); /* Get the property's value */ g_value_init (&val, G_PARAM_SPEC_VALUE_TYPE (pspec)); g_object_get_property ((GObject *) setting, option->name, &val); if (G_VALUE_HOLDS_BOOLEAN (&val)) uval = g_value_get_boolean (&val) ? 1 : 0; else if (G_VALUE_HOLDS_UINT (&val)) { uval = g_value_get_uint (&val); /* zero means "unspecified" for some NM properties but isn't in the * allowed kernel range, so reset the property to the default value. */ if (option->default_if_zero && uval == 0) { g_value_unset (&val); g_value_init (&val, G_PARAM_SPEC_VALUE_TYPE (pspec)); g_param_value_set_default (pspec, &val); uval = g_value_get_uint (&val); } /* Linux kernel bridge interfaces use 'centiseconds' for time-based values. * In reality it's not centiseconds, but depends on HZ and USER_HZ, which * is almost always works out to be a multiplier of 100, so we can assume * centiseconds. See clock_t_to_jiffies(). */ if (option->user_hz_compensate) uval *= 100; } else g_assert_not_reached (); g_value_unset (&val); value = g_strdup_printf ("%u", uval); if (slave) nm_platform_slave_set_option (ifindex, option->sysname, value); else nm_platform_master_set_option (ifindex, option->sysname, value); }