On 11/18/2011 11:39 AM, Weiping Pan wrote:
+ value = svGetValue (ifcfg, "VLAN_FLAGS", FALSE);
+ if (g_strcmp0("VLAN_FLAG_GVRP", value)) {
+ vlan_flags |= VLAN_FLAG_GVRP;
+ } else if (g_strcmp0("VLAN_FLAG_LOOSE_BINDING", value)) {
+ vlan_flags |= VLAN_FLAG_LOOSE_BINDING;
+ }
+ g_object_set(s_vlan, NM_SETTING_VLAN_VLAN_FLAGS, vlan_flags,
NULL);
+ g_free(value);
+
+ vlan_priority_ingress_map = svGetValue (ifcfg,
"VLAN_INGRESS_PRIORITY_MAP", FALSE);
+ if (vlan_priority_ingress_map) {
+ g_object_set(s_vlan,
NM_SETTING_VLAN_VLAN_INGRESS_PRIORITY_MAP,
vlan_priority_ingress_map, NULL);
+ g_free(vlan_priority_ingress_map);
+ }
So like I was talking about earlier, it's probably just easier to
parse
the ingress/egress priorities when reading the ifcfg file in, rather
than having them as a string. That probably means adding list
iterator
functions like we have for IP addresses, nameservers, etc, and
creating
a small opaque structure for them (though we could just store them
internally as a 32-bit number and pack both of the<uint>:<uint> into
that, and save a lot of allocation). So we'd then get something like:
guint32 nm_setting_vlan_get_num_ingress_priorities (NMSettingVlan
*setting);
gboolean nm_setting_vlan_get_ingress_priority (NMSettingVlan
*setting, guint32 i, guint32 *out_a, guint32 *out_b);
gboolean nm_setting_vlan_add_ingress_priority (NMSettingVlan
*setting, guint32 a, b);
void nm_setting_vlan_remove_ingress_priority (NMSettingVlan
*setting, guint32 i);
void nm_setting_vlan_clear_ingress_priorities (NMSettingVlan
*setting);
for both ingress and egress; that'll be a lot easier to work with
internally in NM since we'll only have to parse it once and then we
can
just iterate through and pull them out.
It's a bit more complicated than that for the actual GObject
properties
though (and thus D-Bus marshalling). I vote we keep it simple and
make
the GObject property type DBUS_TYPE_G_LIST_OF_STRING. This makes it
easier to use from D-Bus, but it also means we need converters for the
get_property() and set_property() functions in nm-setting-vlan.c.
These
would take a GSList<string> and parse each "<uint>:<uint>"
element into
the right integers to pass to nm_setting_vlan_add_ingress_priority().
Then in set_property() we'd do the reverse and build up a GSList of
allocated strings using the ingress/egress priorites and use that
in the
call to g_value_set_boxed (). There are some examples of that in
various places, like the IPv4 config where we box/unbox (ie
marshall/demarshall) the property. I can explain more here if you
want.
Thanks,
Dan
Hi, Dan,
I met a problem when using DBUS_TYPE_G_LIST_OF_STRING.
Take the following settings for example,
VLAN_INGRESS_PRIORITY_MAP=0:1,2:5
VLAN_EGRESS_PRIORITY_MAP=12:3,14:7
When I call nm_connection_dump() in test_read_vlan_interface()
function in src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c,
the output is messy.
priority-ingress-map : ['', '\002'] (s)
priority-egress-map : ['\f', '\016'] (s)
I don't know how to fix it.
The patch is attached, many thanks!
Weiping Pan
Now I know how to fix it, the problem is in get_property.
Please see my V3 patchset.
thanks
Weiping Pan
_______________________________________________
networkmanager-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/networkmanager-list
_______________________________________________
networkmanager-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/networkmanager-list