Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 0 additions & 36 deletions include/tscore/UDP_stubs.h

This file was deleted.

3 changes: 0 additions & 3 deletions iocore/aio/test_AIO.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@
using std::cout;
using std::endl;

// ToDo: It would be nice to decouple these UDP dependencies ...
#include "tscore/UDP_stubs.h"

// Necessary for AIO
int net_config_poll_timeout = 10;

Expand Down
62 changes: 21 additions & 41 deletions iocore/net/I_UDPPacket.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ class UDPPacket
/**
Add IOBufferBlock (chain) to end of packet.
@param block block chain to add.

*/
void append_block(IOBufferBlock *block);

Expand All @@ -63,48 +62,29 @@ class UDPPacket
int from_size;

LINK(UDPPacket, link);
};

/**
Create a new packet to be sent over UDPConnection. This actually
copies data from a buffer.
// Factory (static) methods

/**
Create a new packet to be sent over UDPConnection. Packet has no
destination or data.
*/
static UDPPacket *new_UDPPacket();

@param to address of where to send packet
@param when ink_hrtime relative to ink_get_hrtime_internal()
@param buf if !nullptr, then len bytes copied from buf and made into packet.
@param len # of bytes to copy from buf
*/
extern UDPPacket *new_UDPPacket(struct sockaddr const *to, ink_hrtime when = 0, char *buf = nullptr, int len = 0);
/**
Create a new packet to be sent over UDPConnection. This clones and
makes a reference to an existing IOBufferBlock chain.


@param to address of where to send packet
@param when ink_hrtime relative to ink_get_hrtime_internal()
@param block if !nullptr, then the IOBufferBlock chain of data to use
for packet
@param len # of bytes to reference from block
*/

TS_INLINE UDPPacket *new_UDPPacket(struct sockaddr const *to, ink_hrtime when = 0, IOBufferBlock *block = nullptr, int len = 0);
/**
Create a new packet to be sent over UDPConnection. Packet has no
destination or data.
*/
extern UDPPacket *new_UDPPacket();

/**
Create a new packet to be delivered to application.
Internal function only
*/
extern UDPPacket *new_incoming_UDPPacket(struct sockaddr *from, char *buf, int len);
/**
Create a new packet to be sent over UDPConnection. This actually
copies data from a buffer.

/**
Create a new packet to be delivered to application.
Internal function only
*/
extern UDPPacket *new_incoming_UDPPacket(struct sockaddr *from, Ptr<IOBufferBlock> &block);
@param to address of where to send packet
@param when ink_hrtime relative to ink_get_hrtime_internal()
@param buf IOBufferBlock chain of data to use
@param segment_size Segment size
*/
static UDPPacket *new_UDPPacket(struct sockaddr const *to, ink_hrtime when, Ptr<IOBufferBlock> &buf, uint16_t segment_size = 0);

//@}
/**
Create a new packet to be delivered to application.
Internal function only
*/
static UDPPacket *new_incoming_UDPPacket(struct sockaddr *from, struct sockaddr *to, Ptr<IOBufferBlock> &block);
};
1 change: 0 additions & 1 deletion iocore/net/P_UDPNet.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@

#include "tscore/ink_platform.h"
#include "I_UDPNet.h"
#include "P_UDPPacket.h"

// added by YTS Team, yamsat
static inline PollCont *get_UDPPollCont(EThread *);
Expand Down
143 changes: 0 additions & 143 deletions iocore/net/P_UDPPacket.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,146 +55,3 @@ class UDPPacketInternal : public UDPPacket
int in_the_priority_queue = 0;
int in_heap = 0;
};

extern ClassAllocator<UDPPacketInternal> udpPacketAllocator;

TS_INLINE
UDPPacketInternal::UDPPacketInternal()

{
memset(&from, '\0', sizeof(from));
memset(&to, '\0', sizeof(to));
}

TS_INLINE
UDPPacketInternal::~UDPPacketInternal()
{
chain = nullptr;
}

TS_INLINE void
UDPPacketInternal::free()
{
chain = nullptr;
if (conn)
conn->Release();
conn = nullptr;
udpPacketAllocator.free(this);
}

TS_INLINE void
UDPPacket::append_block(IOBufferBlock *block)
{
UDPPacketInternal *p = static_cast<UDPPacketInternal *>(this);

if (block) {
if (p->chain) { // append to end
IOBufferBlock *last = p->chain.get();
while (last->next) {
last = last->next.get();
}
last->next = block;
} else {
p->chain = block;
}
}
}

TS_INLINE int64_t
UDPPacket::getPktLength() const
{
UDPPacketInternal *p = const_cast<UDPPacketInternal *>(static_cast<const UDPPacketInternal *>(this));
IOBufferBlock *b;

p->pktLength = 0;
b = p->chain.get();
while (b) {
p->pktLength += b->read_avail();
b = b->next.get();
}
return p->pktLength;
}

TS_INLINE void
UDPPacket::free()
{
static_cast<UDPPacketInternal *>(this)->free();
}

TS_INLINE void
UDPPacket::setContinuation(Continuation *c)
{
static_cast<UDPPacketInternal *>(this)->cont = c;
}

TS_INLINE void
UDPPacket::setConnection(UDPConnection *c)
{
/*Code reviewed by Case Larsen. Previously, we just had
ink_assert(!conn). This prevents tunneling of packets
correctly---that is, you get packets from a server on a udp
conn. and want to send it to a player on another connection, the
assert will prevent that. The "if" clause enables correct
handling of the connection ref. counts in such a scenario. */

UDPConnectionInternal *&conn = static_cast<UDPPacketInternal *>(this)->conn;

if (conn) {
if (conn == c)
return;
conn->Release();
conn = nullptr;
}
conn = static_cast<UDPConnectionInternal *>(c);
conn->AddRef();
}

TS_INLINE IOBufferBlock *
UDPPacket::getIOBlockChain()
{
ink_assert(dynamic_cast<UDPPacketInternal *>(this) != nullptr);
return static_cast<UDPPacketInternal *>(this)->chain.get();
}

TS_INLINE UDPConnection *
UDPPacket::getConnection()
{
return static_cast<UDPPacketInternal *>(this)->conn;
}

TS_INLINE UDPPacket *
new_UDPPacket(struct sockaddr const *to, ink_hrtime when, Ptr<IOBufferBlock> &buf, uint16_t segment_size = 0)
{
UDPPacketInternal *p = udpPacketAllocator.alloc();

p->in_the_priority_queue = 0;
p->in_heap = 0;
p->delivery_time = when;
if (to)
ats_ip_copy(&p->to, to);
p->chain = buf;
p->segment_size = segment_size;
return p;
}

TS_INLINE UDPPacket *
new_incoming_UDPPacket(struct sockaddr *from, struct sockaddr *to, Ptr<IOBufferBlock> &block)
{
UDPPacketInternal *p = udpPacketAllocator.alloc();

p->in_the_priority_queue = 0;
p->in_heap = 0;
p->delivery_time = 0;
ats_ip_copy(&p->from, from);
ats_ip_copy(&p->to, to);
p->chain = block;

return p;
}

TS_INLINE UDPPacket *
new_UDPPacket()
{
UDPPacketInternal *p = udpPacketAllocator.alloc();
return p;
}
2 changes: 1 addition & 1 deletion iocore/net/QUICPacketHandler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ QUICPacketHandler::_send_packet(const QUICPacket &packet, UDPConnection *udp_con
void
QUICPacketHandler::_send_packet(UDPConnection *udp_con, IpEndpoint &addr, Ptr<IOBufferBlock> udp_payload)
{
UDPPacket *udp_packet = new_UDPPacket(addr, 0, udp_payload);
UDPPacket *udp_packet = UDPPacket::new_UDPPacket(addr, 0, udp_payload);

if (is_debug_tag_set(v_debug_tag)) {
ip_port_text_buffer ipb;
Expand Down
2 changes: 1 addition & 1 deletion iocore/net/QUICPacketHandler_quiche.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ QUICPacketHandler::close_connection(QUICNetVConnection *conn)
void
QUICPacketHandler::send_packet(UDPConnection *udp_con, IpEndpoint &addr, Ptr<IOBufferBlock> udp_payload, uint16_t segment_size)
{
UDPPacket *udp_packet = new_UDPPacket(addr, 0, udp_payload, segment_size);
UDPPacket *udp_packet = UDPPacket::new_UDPPacket(addr, 0, udp_payload, segment_size);

if (is_debug_tag_set(v_debug_tag)) {
ip_port_text_buffer ipb;
Expand Down
Loading