package quic

import (
	
	
	

	
)

// A closedLocalConn is a connection that we closed locally.
// When receiving packets for such a connection, we need to retransmit the packet containing the CONNECTION_CLOSE frame,
// with an exponential backoff.
type closedLocalConn struct {
	counter atomic.Uint32
	logger  utils.Logger

	sendPacket func(net.Addr, packetInfo)
}

var _ packetHandler = &closedLocalConn{}

// newClosedLocalConn creates a new closedLocalConn and runs it.
func newClosedLocalConn( func(net.Addr, packetInfo),  utils.Logger) packetHandler {
	return &closedLocalConn{
		sendPacket: ,
		logger:     ,
	}
}

func ( *closedLocalConn) ( receivedPacket) {
	 := .counter.Add(1)
	// exponential backoff
	// only send a CONNECTION_CLOSE for the 1st, 2nd, 4th, 8th, 16th, ... packet arriving
	if bits.OnesCount32() != 1 {
		return
	}
	.logger.Debugf("Received %d packets after sending CONNECTION_CLOSE. Retransmitting.", )
	.sendPacket(.remoteAddr, .info)
}

func ( *closedLocalConn) (error)                              {}
func ( *closedLocalConn) (TransportErrorCode) {}

// A closedRemoteConn is a connection that was closed remotely.
// For such a connection, we might receive reordered packets that were sent before the CONNECTION_CLOSE.
// We can just ignore those packets.
type closedRemoteConn struct{}

var _ packetHandler = &closedRemoteConn{}

func newClosedRemoteConn() packetHandler {
	return &closedRemoteConn{}
}

func ( *closedRemoteConn) (receivedPacket)                {}
func ( *closedRemoteConn) (error)                              {}
func ( *closedRemoteConn) (TransportErrorCode) {}