我的职能如下:
int parse_mac(const char *hwaddr, uint8_t *dst_mac)
{
(void)hwaddr; (void)dst_mac;
//TODO: Parse the MAC address (string) pointed to by hwaddr and store
//the result in dst. Return 0 on success and -1 on error.
struct ether_addr* ether_address = ether_aton(hwaddr);
if(ether_address==NULL){
return -1;
}
int i;
for(i=0;i<6;i++){
//*(dst_mac+i) = (*ether_address).ether_addr_octet[i];
}
printf("%c\n",(*ether_address).ether_addr_octet[0]);
return 0;
}给定一个MAC地址(由hwaddr指出),我想通过ether_aton将其转换为我的ether_aton变量。但是,ether_address结果结构中的数组似乎是空的。例如,底部的printf给我一个空的字符。怎么了?
发布于 2016-05-11 15:53:46
基本上,ether_aton将您的MAC地址转换为数字,该地址有十六进制字符,由冒号分隔。在我的代码中,我试图打印%c,而我应该打印%d。
https://stackoverflow.com/questions/37166834
复制相似问题