handlerRemoved() — netty Function Reference
Architecture documentation for the handlerRemoved() function in PcapWriteHandler.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 83e8cd99_fb62_b9e8_70a4_3ee322e6c838["handlerRemoved()"] 59f0289b_ecfd_de3c_3397_4cf08e2047d1["PcapWriteHandler"] 83e8cd99_fb62_b9e8_70a4_3ee322e6c838 -->|defined in| 59f0289b_ecfd_de3c_3397_4cf08e2047d1 bbfbdddd_98c4_8181_5429_a45dee375189["completeTCPWrite()"] 83e8cd99_fb62_b9e8_70a4_3ee322e6c838 -->|calls| bbfbdddd_98c4_8181_5429_a45dee375189 89999839_bf9a_67ff_18ff_46d98e911624["incrementUintSegmentNumber()"] 83e8cd99_fb62_b9e8_70a4_3ee322e6c838 -->|calls| 89999839_bf9a_67ff_18ff_46d98e911624 5c216ebb_cca2_4b62_0ccb_54f1456bc752["close()"] 83e8cd99_fb62_b9e8_70a4_3ee322e6c838 -->|calls| 5c216ebb_cca2_4b62_0ccb_54f1456bc752 style 83e8cd99_fb62_b9e8_70a4_3ee322e6c838 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
handler/src/main/java/io/netty/handler/pcap/PcapWriteHandler.java lines 616–658
@Override
public void handlerRemoved(ChannelHandlerContext ctx) throws Exception {
// If `isTCP` is true and state is WRITING, then we'll simulate a `FIN` flow.
if (channelType == ChannelType.TCP && state.get() == State.WRITING) {
logger.debug("Starting Fake TCP FIN+ACK Flow to close connection");
ByteBufAllocator byteBufAllocator = ctx.alloc();
ByteBuf tcpBuf = byteBufAllocator.buffer();
try {
long initiatorSegmentNumber = isServerPipeline? receiveSegmentNumber : sendSegmentNumber;
long initiatorAckNumber = isServerPipeline? sendSegmentNumber : receiveSegmentNumber;
// Write FIN+ACK with Normal Source and Destination Address
TCPPacket.writePacket(tcpBuf, null, initiatorSegmentNumber, initiatorAckNumber, initiatorAddr.getPort(),
handlerAddr.getPort(), TCPPacket.TCPFlag.FIN, TCPPacket.TCPFlag.ACK);
completeTCPWrite(initiatorAddr, handlerAddr, tcpBuf, byteBufAllocator, ctx);
// Write FIN+ACK with Reversed Source and Destination Address
TCPPacket.writePacket(tcpBuf, null, initiatorAckNumber, initiatorSegmentNumber, handlerAddr.getPort(),
initiatorAddr.getPort(), TCPPacket.TCPFlag.FIN, TCPPacket.TCPFlag.ACK);
completeTCPWrite(handlerAddr, initiatorAddr, tcpBuf, byteBufAllocator, ctx);
// Increment by 1 when responding to FIN
sendSegmentNumber = incrementUintSegmentNumber(sendSegmentNumber, 1);
receiveSegmentNumber = incrementUintSegmentNumber(receiveSegmentNumber, 1);
initiatorSegmentNumber = isServerPipeline? receiveSegmentNumber : sendSegmentNumber;
initiatorAckNumber = isServerPipeline? sendSegmentNumber : receiveSegmentNumber;
// Write ACK with Normal Source and Destination Address
TCPPacket.writePacket(tcpBuf, null, initiatorSegmentNumber, initiatorAckNumber,
initiatorAddr.getPort(), handlerAddr.getPort(), TCPPacket.TCPFlag.ACK);
completeTCPWrite(initiatorAddr, handlerAddr, tcpBuf, byteBufAllocator, ctx);
} finally {
tcpBuf.release();
}
logger.debug("Finished Fake TCP FIN+ACK Flow to close connection");
}
close();
super.handlerRemoved(ctx);
}
Domain
Subdomains
Source
Frequently Asked Questions
What does handlerRemoved() do?
handlerRemoved() is a function in the netty codebase, defined in handler/src/main/java/io/netty/handler/pcap/PcapWriteHandler.java.
Where is handlerRemoved() defined?
handlerRemoved() is defined in handler/src/main/java/io/netty/handler/pcap/PcapWriteHandler.java at line 616.
What does handlerRemoved() call?
handlerRemoved() calls 3 function(s): close, completeTCPWrite, incrementUintSegmentNumber.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free