Conversion to confd_value_t

Hi,

we are using external DB.
in our DB, most of the parameters are saved as string.
we have yang model similar to the “server” example (simple trans), with ipv4 as one of the parameters.

as part of the “get_elem” implementation I have trouble with returning the ipv4 value.
I wounder if you can suggest what is the easy way to convert between a string which contains ip value (“1.1.1.1” for example) to the return value as part of the CONFD_SET_IPV4.

thanks in advance
Inbal

There are several ways to address your scenario:

  • You can tell ConfD to give you strings, and expect strings back, for all elements, by setting the CONFD_DAEMON_FLAGS_STRINGSONLY flag via confd_set_daemon_flags().

  • You can use confd_str2val() if you have loaded schema information via e.g. confd_load_schemas() - here’s an exact quote from the confd_types(3) manual page:

         confd_value_t v;
         csp = confd_find_cs_node(kp, kp->len);
         confd_str2val(csp->info.type, "10.0.0.1", &v);
    
  • In this specific case, you could also use the C library function inet_pton().