* Added support for printing AF_LINK addresses.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38055 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
a271028e37
commit
31a49a69c7
@ -803,7 +803,7 @@ BNetworkAddress::ResolveTo(const BNetworkAddress& address)
|
||||
BString
|
||||
BNetworkAddress::ToString(bool includePort) const
|
||||
{
|
||||
char buffer[128];
|
||||
char buffer[512];
|
||||
|
||||
switch (fAddress.ss_family) {
|
||||
case AF_INET:
|
||||
@ -816,6 +816,31 @@ BNetworkAddress::ToString(bool includePort) const
|
||||
buffer, sizeof(buffer));
|
||||
break;
|
||||
|
||||
case AF_LINK:
|
||||
{
|
||||
uint8 *byte = LinkLevelAddress();
|
||||
char* target = buffer;
|
||||
int bytesLeft = sizeof(buffer);
|
||||
target[0] = '\0';
|
||||
|
||||
for (size_t i = 0; i < LinkLevelAddressLength(); i++) {
|
||||
if (i != 0 && bytesLeft > 1) {
|
||||
target[0] = ':';
|
||||
target[1] = '\0';
|
||||
target++;
|
||||
bytesLeft--;
|
||||
}
|
||||
|
||||
int bytesWritten = snprintf(target, bytesLeft, "%02x", byte[i]);
|
||||
if (bytesWritten >= bytesLeft)
|
||||
break;
|
||||
|
||||
target += bytesWritten;
|
||||
bytesLeft -= bytesWritten;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user