//go:build linux

package quic

import (
	
	

	
)

type gsoSendConn struct {
	*basicConn
	conn gsoCapablePacketConn
}

func newGSOSendConn( gsoCapablePacketConn,  bool) (rawConn, bool, error) {
	,  := .SyscallConn()
	if  != nil {
		if errors.Is(, errors.ErrUnsupported) {
			return nil, false, nil
		}
		return nil, false, 
	}
	if !isGSOEnabled() {
		return nil, false, nil
	}
	return &gsoSendConn{
		basicConn: &basicConn{PacketConn: , supportsDF: },
		conn:      ,
	}, true, nil
}

func ( *gsoSendConn) ( []byte,  net.Addr,  []byte,  uint16,  protocol.ECN) (int, error) {
	if  != protocol.ECNUnsupported {
		panic("cannot use ECN with a GSO send connection")
	}
	if  == 0 {
		return .basicConn.WritePacket(, , , 0, )
	}
	if len() < minGSOSegments*int() {
		return .writePackets(, , , int(), )
	}
	 := 
	 = appendUDPSegmentSizeMsg(, )
	, ,  := .conn.WriteMsgUDP(, , .(*net.UDPAddr))
	return , 
}

func ( *gsoSendConn) ( []byte,  net.Addr,  []byte,  int,  protocol.ECN) (int, error) {
	 := 0
	for len() > 0 {
		 := min(len(), )
		,  := .basicConn.WritePacket([:], , , 0, )
		 += 
		if  != nil ||  !=  {
			return , 
		}
		 = [:]
	}
	return , nil
}

func ( *gsoSendConn) () connCapabilities {
	return connCapabilities{DF: .supportsDF, GSO: true}
}