# We have any function to get CONFD\_GET\_IPV4 and V6 both at a time?

**URL:** https://dmap-community.ductus.global/t/we-have-any-function-to-get-confd-get-ipv4-and-v6-both-at-a-time/1416
**Category:** NETCONF
**Created:** [July 20, 2017, 6:39am UTC](https://dmap-community.ductus.global/t/we-have-any-function-to-get-confd-get-ipv4-and-v6-both-at-a-time/1416 "2017-07-20T06:39:18Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Bibin](https://avatars.discourse-cdn.com/v4/letter/b/977dab/32.png) [@Bibin](https://dmap-community.ductus.global/u/Bibin)
#### Post date: [July 20, 2017, 6:39am UTC](https://dmap-community.ductus.global/t/we-have-any-function-to-get-confd-get-ipv4-and-v6-both-at-a-time/1416/1 "2017-07-20T06:39:18Z")

</div>

Hi ,

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

```auto
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.

Thanks,  
Bibin

---

<div class="post-metadata">

### Author: ![mnovak](https://yyz2.discourse-cdn.com/flex010/user_avatar/dmap-community.ductus.global/mnovak/32/183_2.png) [@mnovak](https://dmap-community.ductus.global/u/mnovak)
#### Post date: [July 20, 2017, 8:40am UTC](https://dmap-community.ductus.global/t/we-have-any-function-to-get-confd-get-ipv4-and-v6-both-at-a-time/1416/2 "2017-07-20T08:40:43Z")

</div>

Hello,  
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._

---

<div class="post-metadata">

### Author: ![Bibin](https://avatars.discourse-cdn.com/v4/letter/b/977dab/32.png) [@Bibin](https://dmap-community.ductus.global/u/Bibin)
#### Post date: [July 22, 2017, 7:02am UTC](https://dmap-community.ductus.global/t/we-have-any-function-to-get-confd-get-ipv4-and-v6-both-at-a-time/1416/3 "2017-07-22T07:02:43Z")

</div>

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 ?

Regards,  
Bibin

---

<div class="post-metadata">

### Author: ![mnovak](https://yyz2.discourse-cdn.com/flex010/user_avatar/dmap-community.ductus.global/mnovak/32/183_2.png) [@mnovak](https://dmap-community.ductus.global/u/mnovak)
#### Post date: [July 24, 2017, 8:16am UTC](https://dmap-community.ductus.global/t/we-have-any-function-to-get-confd-get-ipv4-and-v6-both-at-a-time/1416/4 "2017-07-24T08:16:01Z")

</div>

Hello,

yes. Use something like this

`v` is `confd_value_t *`

```auto
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)
    }
}

```
