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