I’m working on an open-source program that needs to support multiple northbound agents, including ConfD. The problem is that different northbound agents encode YANG data in different ways (e.g. ConfD encodes IPv4 addresses using
in_addr structures whereas other programs encode IPv4 addresses using strings).
What I’m trying to do is to normalize all YANG data my program receives into raw strings and then parse this string myself (with the help of
libyang to identify the YANG type). This is certainly not very efficient but it simplifies things quite a bit for me.
Looking at the ConfD documentation I found the
CONFD_DAEMON_FLAG_STRINGSONLY flag which makes ConfD deliver strings (
C_BUF) for all YANG types, but unfortunately this flag is only available in the Data Provider API (I’m using CDB).
I also tried to use
confd_val2str() but I found it to be too complicated to use in a generic way (for all possible YANG types).
confd_pp_value() on the other hand is super convenient but it doesn’t provide the raw YANG data value (e.g.
enum<3> instead of
One solution I thought about is to write a function to convert a
confd_value structure to a string myself. It would be similar to
confd_pp_value() but without the “pretty” part, only the raw value would be printed. This idea however feels like an overkill to solve a simple problem. I’d appreciate if someone could shed some light on what would be the best way to do what I’m trying to do, any suggestion would be welcome.