handleUDP() — netty Function Reference
Architecture documentation for the handleUDP() function in PcapWriteHandler.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 06ef8177_bf66_5538_b798_56d322fe8d3e["handleUDP()"] 59f0289b_ecfd_de3c_3397_4cf08e2047d1["PcapWriteHandler"] 06ef8177_bf66_5538_b798_56d322fe8d3e -->|defined in| 59f0289b_ecfd_de3c_3397_4cf08e2047d1 ad9aed33_ce6c_03a6_768d_de9fb726fba9["channelRead()"] ad9aed33_ce6c_03a6_768d_de9fb726fba9 -->|calls| 06ef8177_bf66_5538_b798_56d322fe8d3e 2fb87f56_9808_98f7_33ce_8ee757b86601["write()"] 2fb87f56_9808_98f7_33ce_8ee757b86601 -->|calls| 06ef8177_bf66_5538_b798_56d322fe8d3e 4e4d1dfd_9ca2_974c_7198_72a58937e36e["completeUDPWrite()"] 06ef8177_bf66_5538_b798_56d322fe8d3e -->|calls| 4e4d1dfd_9ca2_974c_7198_72a58937e36e style 06ef8177_bf66_5538_b798_56d322fe8d3e fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
handler/src/main/java/io/netty/handler/pcap/PcapWriteHandler.java lines 482–545
private void handleUDP(ChannelHandlerContext ctx, Object msg, boolean isWriteOperation) {
ByteBuf udpBuf = ctx.alloc().buffer();
try {
if (msg instanceof DatagramPacket) {
// If bytes are 0 and `captureZeroByte` is false, we won't capture this.
if (((DatagramPacket) msg).content().readableBytes() == 0 && !captureZeroByte) {
logger.debug("Discarding Zero Byte UDP Packet");
return;
}
if (((DatagramPacket) msg).content().readableBytes() > 65507) {
logger.warn("Unable to write UDP packet to PCAP. Payload of size {} exceeds max size of 65507");
return;
}
DatagramPacket datagramPacket = ((DatagramPacket) msg).duplicate();
InetSocketAddress srcAddr = datagramPacket.sender();
InetSocketAddress dstAddr = datagramPacket.recipient();
// If `datagramPacket.sender()` is `null` then DatagramPacket is initialized
// `sender` (local) address. In this case, we'll get source address from Channel.
if (srcAddr == null) {
srcAddr = getLocalAddress(ctx.channel(), dstAddr);
}
logger.debug("Writing UDP Data of {} Bytes, isWriteOperation {}, Src Addr {}, Dst Addr {}",
datagramPacket.content().readableBytes(), isWriteOperation, srcAddr, dstAddr);
UDPPacket.writePacket(udpBuf, datagramPacket.content(), srcAddr.getPort(), dstAddr.getPort());
completeUDPWrite(srcAddr, dstAddr, udpBuf, ctx.alloc(), ctx);
} else if (msg instanceof ByteBuf &&
(!(ctx.channel() instanceof DatagramChannel) ||
((DatagramChannel) ctx.channel()).isConnected())) {
// If bytes are 0 and `captureZeroByte` is false, we won't capture this.
if (((ByteBuf) msg).readableBytes() == 0 && !captureZeroByte) {
logger.debug("Discarding Zero Byte UDP Packet");
return;
}
if (((ByteBuf) msg).readableBytes() > 65507) {
logger.warn("Unable to write UDP packet to PCAP. Payload of size {} exceeds max size of 65507");
return;
}
ByteBuf byteBuf = ((ByteBuf) msg).duplicate();
InetSocketAddress sourceAddr = isWriteOperation? initiatorAddr : handlerAddr;
InetSocketAddress destinationAddr = isWriteOperation? handlerAddr : initiatorAddr;
logger.debug("Writing UDP Data of {} Bytes, Src Addr {}, Dst Addr {}",
byteBuf.readableBytes(), sourceAddr, destinationAddr);
UDPPacket.writePacket(udpBuf, byteBuf, sourceAddr.getPort(), destinationAddr.getPort());
completeUDPWrite(sourceAddr, destinationAddr, udpBuf, ctx.alloc(), ctx);
} else {
logger.debug("Discarding Pcap Write for UDP Object: {}", msg);
}
} finally {
udpBuf.release();
}
}
Domain
Subdomains
Calls
Called By
Source
Frequently Asked Questions
What does handleUDP() do?
handleUDP() is a function in the netty codebase, defined in handler/src/main/java/io/netty/handler/pcap/PcapWriteHandler.java.
Where is handleUDP() defined?
handleUDP() is defined in handler/src/main/java/io/netty/handler/pcap/PcapWriteHandler.java at line 482.
What does handleUDP() call?
handleUDP() calls 1 function(s): completeUDPWrite.
What calls handleUDP()?
handleUDP() is called by 2 function(s): channelRead, write.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free