package io.netty.channel.epoll;

import g.a.a.a.a;
import io.netty.channel.DefaultFileRegion;
import io.netty.channel.unix.Errors;
import io.netty.channel.unix.NativeInetAddress;
import io.netty.channel.unix.PeerCredentials;
import io.netty.channel.unix.Socket;
import java.net.InetAddress;
import java.nio.channels.ClosedChannelException;

/* JADX INFO: loaded from: classes.dex */
public final class LinuxSocket extends Socket {
    private static final long MAX_UINT32_T = 4294967295L;
    private static final Errors.NativeIoException SENDFILE_CONNECTION_RESET_EXCEPTION = Errors.newConnectionResetException("syscall:sendfile(...)", Errors.ERRNO_EPIPE_NEGATIVE);
    private static final ClosedChannelException SENDFILE_CLOSED_CHANNEL_EXCEPTION = (ClosedChannelException) a.N(Native.class, "sendfile(...)");

    public LinuxSocket(int i2) {
        super(i2);
    }

    private static native PeerCredentials getPeerCredentials(int i2);

    private static native int getTcpDeferAccept(int i2);

    private static native void getTcpInfo(int i2, long[] jArr);

    private static native int getTcpKeepCnt(int i2);

    private static native int getTcpKeepIdle(int i2);

    private static native int getTcpKeepIntvl(int i2);

    private static native int getTcpNotSentLowAt(int i2);

    private static native int getTcpUserTimeout(int i2);

    private static native int isIpFreeBind(int i2);

    private static native int isIpTransparent(int i2);

    private static native int isTcpCork(int i2);

    private static native int isTcpFastOpenConnect(int i2);

    private static native int isTcpQuickAck(int i2);

    public static LinuxSocket newSocketDgram() {
        return new LinuxSocket(Socket.newSocketDgram0());
    }

    public static LinuxSocket newSocketDomain() {
        return new LinuxSocket(Socket.newSocketDomain0());
    }

    public static LinuxSocket newSocketStream() {
        return new LinuxSocket(Socket.newSocketStream0());
    }

    private static native long sendFile(int i2, DefaultFileRegion defaultFileRegion, long j2, long j3, long j4);

    private static native void setIpFreeBind(int i2, int i3);

    private static native void setIpTransparent(int i2, int i3);

    private static native void setTcpCork(int i2, int i3);

    private static native void setTcpDeferAccept(int i2, int i3);

    private static native void setTcpFastOpen(int i2, int i3);

    private static native void setTcpFastOpenConnect(int i2, int i3);

    private static native void setTcpKeepCnt(int i2, int i3);

    private static native void setTcpKeepIdle(int i2, int i3);

    private static native void setTcpKeepIntvl(int i2, int i3);

    private static native void setTcpMd5Sig(int i2, byte[] bArr, int i3, byte[] bArr2);

    private static native void setTcpNotSentLowAt(int i2, int i3);

    private static native void setTcpQuickAck(int i2, int i3);

    private static native void setTcpUserTimeout(int i2, int i3);

    public PeerCredentials getPeerCredentials() {
        return getPeerCredentials(intValue());
    }

    public int getTcpDeferAccept() {
        return getTcpDeferAccept(intValue());
    }

    public void getTcpInfo(EpollTcpInfo epollTcpInfo) {
        getTcpInfo(intValue(), epollTcpInfo.info);
    }

    public int getTcpKeepCnt() {
        return getTcpKeepCnt(intValue());
    }

    public int getTcpKeepIdle() {
        return getTcpKeepIdle(intValue());
    }

    public int getTcpKeepIntvl() {
        return getTcpKeepIntvl(intValue());
    }

    public long getTcpNotSentLowAt() {
        return ((long) getTcpNotSentLowAt(intValue())) & 4294967295L;
    }

    public int getTcpUserTimeout() {
        return getTcpUserTimeout(intValue());
    }

    public boolean isIpFreeBind() {
        return isIpFreeBind(intValue()) != 0;
    }

    public boolean isIpTransparent() {
        return isIpTransparent(intValue()) != 0;
    }

    public boolean isTcpCork() {
        return isTcpCork(intValue()) != 0;
    }

    public boolean isTcpFastOpenConnect() {
        return isTcpFastOpenConnect(intValue()) != 0;
    }

    public boolean isTcpQuickAck() {
        return isTcpQuickAck(intValue()) != 0;
    }

    public long sendFile(DefaultFileRegion defaultFileRegion, long j2, long j3, long j4) {
        defaultFileRegion.open();
        long jSendFile = sendFile(intValue(), defaultFileRegion, j2, j3, j4);
        return jSendFile >= 0 ? jSendFile : Errors.ioResult("sendfile", (int) jSendFile, SENDFILE_CONNECTION_RESET_EXCEPTION, SENDFILE_CLOSED_CHANNEL_EXCEPTION);
    }

    public void setIpFreeBind(boolean z2) {
        setIpFreeBind(intValue(), z2 ? 1 : 0);
    }

    public void setIpTransparent(boolean z2) {
        setIpTransparent(intValue(), z2 ? 1 : 0);
    }

    public void setTcpCork(boolean z2) {
        setTcpCork(intValue(), z2 ? 1 : 0);
    }

    public void setTcpDeferAccept(int i2) {
        setTcpDeferAccept(intValue(), i2);
    }

    public void setTcpFastOpen(int i2) {
        setTcpFastOpen(intValue(), i2);
    }

    public void setTcpFastOpenConnect(boolean z2) {
        setTcpFastOpenConnect(intValue(), z2 ? 1 : 0);
    }

    public void setTcpKeepCnt(int i2) {
        setTcpKeepCnt(intValue(), i2);
    }

    public void setTcpKeepIdle(int i2) {
        setTcpKeepIdle(intValue(), i2);
    }

    public void setTcpKeepIntvl(int i2) {
        setTcpKeepIntvl(intValue(), i2);
    }

    public void setTcpMd5Sig(InetAddress inetAddress, byte[] bArr) {
        NativeInetAddress nativeInetAddressNewInstance = NativeInetAddress.newInstance(inetAddress);
        setTcpMd5Sig(intValue(), nativeInetAddressNewInstance.address(), nativeInetAddressNewInstance.scopeId(), bArr);
    }

    public void setTcpNotSentLowAt(long j2) {
        if (j2 < 0 || j2 > 4294967295L) {
            throw new IllegalArgumentException("tcpNotSentLowAt must be a uint32_t");
        }
        setTcpNotSentLowAt(intValue(), (int) j2);
    }

    public void setTcpQuickAck(boolean z2) {
        setTcpQuickAck(intValue(), z2 ? 1 : 0);
    }

    public void setTcpUserTimeout(int i2) {
        setTcpUserTimeout(intValue(), i2);
    }
}
