libyang icon indicating copy to clipboard operation
libyang copied to clipboard

typedef on plugin's type does not call the right plugin callbacks

Open Haititi opened this issue 3 years ago • 1 comments

Hi.

typedef listen-ipv6-address {
    type inet:ipv6-address-no-zone;
    default "::0";
}

If i try to store a value in a leaf of type inet:ipv6-address, the plugin callback lyplg_type_store_ipv6_address_no_zone() is correctly called in order to store the value correctly. This actually helps in handling the different ways we could define an IPv6 address (for example, "::0" and and "0.0.0.0.0.0.0.0" are actually the same).

But if i try to store a value in a leaf of type listen-ipv6-address, the plugin callback lyplg_type_store_string() is called instead. As the base type is "inet:ipv6-address-no-zone", shouldn't it call lyplg_type_store_ipv6_address_no_zone() as in the first case ?

Even if i were to remove the default "::0"; part, we would end up with a simple alias, but we would still lose the functionalities provided by the ipv6-address-no-zone type plugin.

can this be changed?

Haititi avatar Jul 11 '22 13:07 Haititi

I just proposed a simple fix for this issue. It's actually similar to what is done here : https://github.com/CESNET/libyang/blob/b282fb6a24272294119b1400505aaacea5ae3cfc/src/schema_compile_node.c#L2143

I hope it helps :)

Haititi avatar Jul 12 '22 16:07 Haititi