Hi !
I made a function to retrieve MAC address of ethernet adaptor. When I retrieve nicconfig structure using DCMD_IO_NET_GET_CONFIG devctl option, MAC address is good but length is always 0 !!! So I use a constant
MAC_ADDRESS_LENGTH which is equals to 6.
Is normal or is it a bug ? I am using QNX 6.3.
Here is code of my function :
// Retrieve the mac address of an ethernet interface
// return 0->OK or -1->Error
int retrieve_mac_address(unsigned char *interface_name,unsigned char *mac_address)
{
int fd;
int error;
int i;
nic_config_t nicconfig;
char full_int_name[50];
sprintf(full_int_name,"/dev/io-net/%s",interface_name);
if ((fd = open(full_int_name, O_RDONLY)) == -1)
{
printf("retrieve_mac_address open returned error %s\n\r",strerror(errno));
return(-1);
}
if (error = devctl(fd, DCMD_IO_NET_GET_CONFIG, &nicconfig, sizeof(nicconfig), NULL))
{
printf("retrieve_mac_address devctl returned error %s\n\r",strerror(error));
return(-1);
}
// MAC length should be 6 be we read always 0...
printf("retrieve_mac_address MAC length : %d\n\r",nicconfig.mac_length);
printf("retrieve_mac_address Permanent MAC address : ");
for (i=0 ; i< MAC_ADDRESS_LENGTH; i++)
{
printf("%02X ",nicconfig.permanent_address[i]);
}
printf("\n\r");
printf("retrieve_mac_address Current MAC address : ");
for (i=0 ; i< MAC_ADDRESS_LENGTH ; i++)
{
printf("%02X ",nicconfig.current_address[i]);
mac_address[i] = nicconfig.current_address[i];
}
printf("\n\r");
close (fd);
return(0);
}
Thanks for your help !!