* Changed the _SIZEOF_ADDR_IFREQ() macro such that it can be used how we are
using it - hopefully, that is actually correct (it's adopted from FreeBSD). * Fixed bug that cut off the sockaddr_dl reported by the system, so that DHCP wouldn't work anymore (and ifconfig wouldn't show the actual MAC address anymore). * Changed the listing code to actually pad to ifreq size, and leave the length of the sockaddr untouched. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37941 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1415,29 +1415,29 @@ list_interfaces(int family, void* _buffer, size_t* bufferSize)
|
||||
|
||||
// Copy address
|
||||
InterfaceAddress* address = interface->FirstForFamily(family);
|
||||
sockaddr_storage storage;
|
||||
size_t length = 0;
|
||||
|
||||
if (address != NULL && address->local != NULL) {
|
||||
// Actual address
|
||||
memcpy(&storage, address->local, address->local->sa_len);
|
||||
buffer.Push(address->local, length = address->local->sa_len);
|
||||
} else {
|
||||
// Empty address
|
||||
storage.ss_len = 2;
|
||||
storage.ss_family = AF_UNSPEC;
|
||||
}
|
||||
|
||||
if (storage.ss_len < sizeof(sockaddr)) {
|
||||
// Make sure at least sizeof(sockaddr) bytes are written for
|
||||
// compatibility with other platforms
|
||||
memset((uint8*)&storage + storage.ss_len, 0,
|
||||
sizeof(sockaddr) - storage.ss_len);
|
||||
storage.ss_len = sizeof(sockaddr);
|
||||
sockaddr empty;
|
||||
empty.sa_len = 2;
|
||||
empty.sa_family = AF_UNSPEC;
|
||||
buffer.Push(&empty, length = empty.sa_len);
|
||||
}
|
||||
|
||||
if (address != NULL)
|
||||
address->ReleaseReference();
|
||||
|
||||
if (buffer.Push(&storage, storage.ss_len) == NULL)
|
||||
if (IF_NAMESIZE + length < sizeof(ifreq)) {
|
||||
// Make sure at least sizeof(ifreq) bytes are written for each
|
||||
// interface for compatibility with other platforms
|
||||
buffer.Pad(sizeof(ifreq) - IF_NAMESIZE - length);
|
||||
}
|
||||
|
||||
if (buffer.Status() != B_OK)
|
||||
return buffer.Status();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user