mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-19 08:17:13 +02:00
server interface: ip made to use inet_ntop, mac address and ip to string made common
This commit is contained in:
@ -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);
|
||||
}
|
Reference in New Issue
Block a user