ConfD User Community

How to feed mac-address to confd_tag_value_t


#1

According to the below documentation, mac-address is read as binary value by confd.

yang:mac-address The mac-address type represents an IEEE 802 MAC address.
The length of the ConfD C_BINARY representation is always 6.
• value.type = C_BINARY
• union element = buf
• C type = confd_buf_t
• SMIv2 type = OCTET STRING

how do I set a mac-address string “01:01:01:01:01:01” as confd_tag_value_t in confd.

Using CONFD_SET_TAG_BINARY is giving me “30:31:3a:30:31:3a” value


#2

In one of our examples (linuxcfg) I can find following piece of code:

confd_value_t v;
CONFD_SET_BINARY(&v, ifPhysAddress, ifPhysAddress_len);

where

#define ADDRLEN 256 
u_int8_t  ifPhysAddress[ADDRLEN];
unsigned  ifPhysAddress_len; // number of octets really acquired

Is it possible that you have incorrectly filled the u_int8_t array?


#3

Sorry, I should have been more clear.

I understand the SET_BINARY takes physical address, but what value is in the physical address?

I have mac-address as string “30:31:01:31:3a:31”, In which format does confd need the mac-address?


#4

Not sure if I fully understand. Just create u_int8_t byte array of your mac address and then set with CONFD_SET_BINARY

e.g.

u_int8_t  ifPhysAddress[6];
ifPhysAddress[0] = 0x30
ifPhysAddress[1] = 0x31
...
ifPhysAddress[5] = 0x31

confd_value_t v;
CONFD_SET_BINARY(&v, ifPhysAddress, 6);

Is this what you are looking for? If you have string representation, you first need to split string to individual numbers and convert them to u_int8_t.


#5

i believe MAC address is to be filled as a binary representation of the actual MAC - not a string ASCII codes… If mac address is “11:22:33:44:55:66”, then it should be:

u_int8_t addr[6];
addr[0] = 0x11
addr[1] = 0x22
addr[2] = 0x33
addr[3] = 0x44
addr[4] = 0x55
addr[5] = 0x66


#6

Thank you. That worked