Need help in reading leaf of type mac-address

Hi,
currently, my yang file looks like below:


I have subscribed to the list as cdb_subscribe.
Can you please help me in reading the mac address which is of type mac-address.
When I am trying to read it as cdb_get_buf , it shows error.

Regards,
Biswajit

The base type of yang:mac-address is a string. You can use either cdb_get_buf( ) or cdb_get_str( ) to read this data in your cdb subscriber. You can find example usage of both of these calls in the examples.confd/intro/1-2-3 example.

Yes, this is the case for most of the “interesting” types defined in ietf-yang-types and ietf-inet-types - besides yang:mac-address e.g. yang:object-identifier, yang:date-and-time, inet:ipv4-address, …

But no, ConfD parses yang:mac-address and most of the other “interesting” types into a “binary” form used internally and in the APIs, to relieve applications from doing this and to achieve more space-efficient storage. The mapping between YANG and “internal” types is described in the confd_types(3) manual page - specifically for yang:mac-address:

       yang:mac-address
           The mac-address type represents an IEEE 802 MAC address.

           The length of the ConfD C_BINARY representation is always 6.

           o   value.type = C_BINARY

           o   union element = buf

           o   C type = confd_buf_t

           o   SMIv2 type = OCTET STRING

I.e. the proper type safe function to use for reading leafs of this type is cdb_get_binary().

2 Likes

Thanks for your correction.