[0]DEBUG badly formatted or nonexistent path - Typeless element --> CONFD_ERR

Hi, I have the following yang snippet :
list host-ip {
key “ip”;
leaf ip{
type inet:ipv4-address;
}
}
I am trying to extract the ipv4 and print it to file like this:
n = cdb_num_instances(rsock, “host-ip”);
for (i=0; i<n; i++) {
if(cdb_get_ipv4(rsock, &ip, “host-ip[%d]”, i) == CONFD_OK)
{
//print to file here
}
}

however, when I run the cli and enter an ipv4 i looks for:
Possible completions: < host-ip:IPv4 address range >

I dont know what the range is? and i have tried it with a string type also and still got the range so I am not sure if it is causing the error above:[0]DEBUG badly formatted or nonexistent path - Typeless element --> CONFD_ERR ???

I am trying to have a list of ipv4s, am i doing this correctly and why is it saying typless element?
many thanks.

If host-ip is a top level list in a YANG module, then your code should look like the following:

n = cdb_num_instances(rsock, “/host-ip”);
for (i=0; i if(cdb_get_ipv4(rsock, &ip, “/host-ip[%d]”, i) == CONFD_OK)
{
//print to file here
}
}

Hi and thanks for the response. Yes sorry I should have mentioned i have had it that way already. I just cant seem to get any info on what the typeless element means or why it mentions range when using the cli to enter the ip address through the cli.
Thanks.

For your question on the badly formatted or nonexistent path, you get this error since you are providing a path to cdb_get_ipv4() which points to the list (typeless) element, not the IPv4 element. The correct path is in your example “/host-ip[%d]/ip”.
I.e.:

n = cdb_num_instances(rsock, "/host-ip");
for (i=0;i < n; i++) {
   if (cdb_get_ipv4(rsock, &ip, "/host-ip[%d]/ip", i) == CONFD_OK) {
     printf("%s\n", inet_ntoa(ip));
   }
}

Regarding the range, that’s something that is automatically rendered for the ConfD CLI when in Cisco CLI mode (the only mode supported by ConfD Basic). However, the IETF standard inet:ipv4-address type does not allow ranges so only a range of 1 element is allowed. With the ConfD premium CLI, which you would be able supply with your product, you might want to extend the IETF type and add support for entering IP ranges.

Hi, That has solved my problem. thank you very much as I have spent a good bit of time trying to get it going.