We have any function to get CONFD_GET_IPV4 and V6 both at a time?

Hi ,

I want to retrieve value from YANG model, i.e, in YANG file i am using,

leaf destip {
              type "inettype:ip-address";
              mandatory true;
              description "destip will take both V4 and V6";

so do have any function to retrieve the V4 and V6 at a time , as for my scenario destip will take both V4 and V6.

In confd user guide CONFD_GET_IPV4 and CONFD_GET_IPV6 are two separate functions.

Can anyone help me to find a way how to retrieve the value.


I assume you mean type type inet:ip-address (found in ietf-inet-types.yang) and you have confd_value_t value. You just need to extract IPV4 or IPV6. is it correct?

In that case (as described in ConfD User Gude) you shoudl first check type element (if it is C_IPV4 or C_IPV6) and according to taht extract ipv4 or ipv6 using CONFD_GET_IPV4 or CONFD_GET_IPV6

_The union type has no special confd_value_t representation - elements are represented as one of the member types according to the current value instantiation. This means that for unions that comprise different “primitive” types, applications must check the type element to determine the type, and the type safe alternatives to the cdb_get() and maapi_get_elem() functions can not be used.

inet:ip-addressThe ip-address type represents an IP address and is IP version neutral. The format of the textual representations implies the IP version.This is a union of the inet:ipv4-address and inet:ipv6-address types defined below. The representation is thus identical to the representation for one of these types.

H Novak,

Thanks for the response.

Our application should support both V4 and V6 at a time.
So if i try to retrieve V4 using confd_get_IPV4() func it will work. Then if the user gives V6 then the assertion fails stating that it accepts c_IPV4 .

So how can we make it possible to retrieve both values support from application ?



yes. Use something like this

v is confd_value_t *

if (v->type == C_IPV4) {
    struct in_addr ip =  CONFD_GET_IPV4(v)
} else {
    if (v->type == C_IPV6) {
         struct in6_addr ip6 = CONFD_GET_IPV6(v)