miniature cleanups.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20874 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
90c0876839
commit
4e8a1b331f
@ -9,6 +9,8 @@
|
||||
#ifndef ADDRESS_UTILITIES_H
|
||||
#define ADDRESS_UTILITIES_H
|
||||
|
||||
#include <NetUtilities.h>
|
||||
|
||||
#include <net_datalink.h>
|
||||
|
||||
#include <sys/socket.h>
|
||||
@ -102,6 +104,11 @@ public:
|
||||
return fModule->update_to(fAddress, from);
|
||||
}
|
||||
|
||||
AddressString AsString(bool printPort = false) const
|
||||
{
|
||||
return AddressString(fModule, fAddress, printPort);
|
||||
}
|
||||
|
||||
const sockaddr *operator *() const { return fAddress; }
|
||||
sockaddr *operator *() { return fAddress; }
|
||||
|
||||
@ -176,6 +183,11 @@ public:
|
||||
return CopyTo((sockaddr *)to);
|
||||
}
|
||||
|
||||
AddressString AsString(bool printPort = false) const
|
||||
{
|
||||
return AddressString(fModule, fAddress, printPort);
|
||||
}
|
||||
|
||||
const sockaddr *operator *() const { return fAddress; }
|
||||
|
||||
private:
|
||||
|
@ -100,29 +100,38 @@ Checksum::PseudoHeader(net_address_module_info *addressModule,
|
||||
// is automatically freed at end of scope:
|
||||
class AddressString {
|
||||
public:
|
||||
inline AddressString(net_domain *domain, const sockaddr *address,
|
||||
AddressString(net_domain *domain, const sockaddr *address,
|
||||
bool printPort = false)
|
||||
: fBuffer(NULL)
|
||||
{
|
||||
domain->address_module->print_address(address, &fBuffer, printPort);
|
||||
}
|
||||
|
||||
inline AddressString(net_domain *domain, const sockaddr &address,
|
||||
AddressString(net_domain *domain, const sockaddr &address,
|
||||
bool printPort = false)
|
||||
: fBuffer(NULL)
|
||||
{
|
||||
domain->address_module->print_address(&address, &fBuffer, printPort);
|
||||
}
|
||||
|
||||
inline ~AddressString()
|
||||
AddressString(net_address_module_info *address_module,
|
||||
const sockaddr *address, bool printPort = false)
|
||||
: fBuffer(NULL)
|
||||
{
|
||||
free(fBuffer);
|
||||
address_module->print_address(address, &fBuffer, printPort);
|
||||
}
|
||||
|
||||
inline char *Data()
|
||||
|
||||
~AddressString()
|
||||
{
|
||||
if (fBuffer)
|
||||
free(fBuffer);
|
||||
}
|
||||
|
||||
const char *Data() const
|
||||
{
|
||||
return fBuffer;
|
||||
}
|
||||
|
||||
private:
|
||||
char *fBuffer;
|
||||
};
|
||||
|
@ -635,9 +635,6 @@ UdpEndpointManager::Deframe(net_buffer *buffer)
|
||||
|
||||
udp_header &header = bufferHeader.Data();
|
||||
|
||||
struct sockaddr *source = (struct sockaddr *)&buffer->source;
|
||||
struct sockaddr *destination = (struct sockaddr *)&buffer->destination;
|
||||
|
||||
if (buffer->interface == NULL || buffer->interface->domain == NULL) {
|
||||
TRACE_EPM(" Deframe(): UDP packed dropped as there was no domain "
|
||||
"specified (interface %p).", buffer->interface);
|
||||
@ -647,12 +644,14 @@ UdpEndpointManager::Deframe(net_buffer *buffer)
|
||||
net_domain *domain = buffer->interface->domain;
|
||||
net_address_module_info *addressModule = domain->address_module;
|
||||
|
||||
addressModule->set_port(source, header.source_port);
|
||||
addressModule->set_port(destination, header.destination_port);
|
||||
SocketAddress source(addressModule, &buffer->source);
|
||||
SocketAddress destination(addressModule, &buffer->destination);
|
||||
|
||||
TRACE_EPM(" Deframe(): data from %s to %s",
|
||||
AddressString(domain, source, true).Data(),
|
||||
AddressString(domain, destination, true).Data());
|
||||
source.SetPort(header.source_port);
|
||||
destination.SetPort(header.destination_port);
|
||||
|
||||
TRACE_EPM(" Deframe(): data from %s to %s", source.AsString(true).Data(),
|
||||
destination.AsString(true).Data());
|
||||
|
||||
uint16 udpLength = ntohs(header.udp_length);
|
||||
if (udpLength > buffer->size) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user