server interface: ip made to use inet_ntop, mac address and ip to string made common

This commit is contained in:
2019-05-16 15:12:42 +02:00
parent 9315768159
commit 1943e77b24
7 changed files with 75 additions and 68 deletions

View File

@ -520,3 +520,19 @@ int Server_SendResult(int fileDes, intType itype, int update, void* retval, int
return ret;
}
void getMacAddressinString(char* cmac, int size, uint64_t mac) {
memset(cmac, 0, size);
sprintf(cmac,"%02x:%02x:%02x:%02x:%02x:%02x",(unsigned int)((mac>>40)&0xFF),
(unsigned int)((mac>>32)&0xFF),
(unsigned int)((mac>>24)&0xFF),
(unsigned int)((mac>>16)&0xFF),
(unsigned int)((mac>>8)&0xFF),
(unsigned int)((mac>>0)&0xFF));
}
void getIpAddressinString(char* cip, uint32_t ip) {
memset(cip, 0, INET_ADDRSTRLEN);
inet_ntop(AF_INET, &ip, cip, INET_ADDRSTRLEN);
}