package io.netty.channel.epoll;

import io.netty.buffer.ByteBufAllocator;
import io.netty.channel.ChannelException;
import io.netty.channel.ChannelOption;
import io.netty.channel.MessageSizeEstimator;
import io.netty.channel.RecvByteBufAllocator;
import io.netty.channel.WriteBufferWaterMark;
import io.netty.channel.socket.SocketChannelConfig;
import io.netty.util.internal.PlatformDependent;
import java.io.IOException;
import java.net.InetAddress;
import java.util.Map;

/* JADX INFO: loaded from: classes.dex */
public final class EpollSocketChannelConfig extends EpollChannelConfig implements SocketChannelConfig {
    private volatile boolean allowHalfClosure;
    private final EpollSocketChannel channel;

    public EpollSocketChannelConfig(EpollSocketChannel epollSocketChannel) {
        super(epollSocketChannel);
        this.channel = epollSocketChannel;
        if (PlatformDependent.canEnableTcpNoDelayByDefault()) {
            setTcpNoDelay(true);
        }
        calculateMaxBytesPerGatheringWrite();
    }

    private void calculateMaxBytesPerGatheringWrite() {
        if ((getSendBufferSize() << 1) > 0) {
            setMaxBytesPerGatheringWrite(getSendBufferSize() << 1);
        }
    }

    @Override // io.netty.channel.epoll.EpollChannelConfig, io.netty.channel.DefaultChannelConfig, io.netty.channel.ChannelConfig
    public <T> T getOption(ChannelOption<T> channelOption) {
        return channelOption == ChannelOption.SO_RCVBUF ? (T) Integer.valueOf(getReceiveBufferSize()) : channelOption == ChannelOption.SO_SNDBUF ? (T) Integer.valueOf(getSendBufferSize()) : channelOption == ChannelOption.TCP_NODELAY ? (T) Boolean.valueOf(isTcpNoDelay()) : channelOption == ChannelOption.SO_KEEPALIVE ? (T) Boolean.valueOf(isKeepAlive()) : channelOption == ChannelOption.SO_REUSEADDR ? (T) Boolean.valueOf(isReuseAddress()) : channelOption == ChannelOption.SO_LINGER ? (T) Integer.valueOf(getSoLinger()) : channelOption == ChannelOption.IP_TOS ? (T) Integer.valueOf(getTrafficClass()) : channelOption == ChannelOption.ALLOW_HALF_CLOSURE ? (T) Boolean.valueOf(isAllowHalfClosure()) : channelOption == EpollChannelOption.TCP_CORK ? (T) Boolean.valueOf(isTcpCork()) : channelOption == EpollChannelOption.TCP_NOTSENT_LOWAT ? (T) Long.valueOf(getTcpNotSentLowAt()) : channelOption == EpollChannelOption.TCP_KEEPIDLE ? (T) Integer.valueOf(getTcpKeepIdle()) : channelOption == EpollChannelOption.TCP_KEEPINTVL ? (T) Integer.valueOf(getTcpKeepIntvl()) : channelOption == EpollChannelOption.TCP_KEEPCNT ? (T) Integer.valueOf(getTcpKeepCnt()) : channelOption == EpollChannelOption.TCP_USER_TIMEOUT ? (T) Integer.valueOf(getTcpUserTimeout()) : channelOption == EpollChannelOption.TCP_QUICKACK ? (T) Boolean.valueOf(isTcpQuickAck()) : channelOption == EpollChannelOption.IP_TRANSPARENT ? (T) Boolean.valueOf(isIpTransparent()) : channelOption == EpollChannelOption.TCP_FASTOPEN_CONNECT ? (T) Boolean.valueOf(isTcpFastOpenConnect()) : (T) super.getOption(channelOption);
    }

    @Override // io.netty.channel.epoll.EpollChannelConfig, io.netty.channel.DefaultChannelConfig, io.netty.channel.ChannelConfig
    public Map<ChannelOption<?>, Object> getOptions() {
        return getOptions(super.getOptions(), ChannelOption.SO_RCVBUF, ChannelOption.SO_SNDBUF, ChannelOption.TCP_NODELAY, ChannelOption.SO_KEEPALIVE, ChannelOption.SO_REUSEADDR, ChannelOption.SO_LINGER, ChannelOption.IP_TOS, ChannelOption.ALLOW_HALF_CLOSURE, EpollChannelOption.TCP_CORK, EpollChannelOption.TCP_NOTSENT_LOWAT, EpollChannelOption.TCP_KEEPCNT, EpollChannelOption.TCP_KEEPIDLE, EpollChannelOption.TCP_KEEPINTVL, EpollChannelOption.TCP_MD5SIG, EpollChannelOption.TCP_QUICKACK, EpollChannelOption.IP_TRANSPARENT, EpollChannelOption.TCP_FASTOPEN_CONNECT);
    }

    @Override // io.netty.channel.socket.SocketChannelConfig
    public int getReceiveBufferSize() {
        try {
            return this.channel.socket.getReceiveBufferSize();
        } catch (IOException e2) {
            throw new ChannelException(e2);
        }
    }

    @Override // io.netty.channel.socket.SocketChannelConfig
    public int getSendBufferSize() {
        try {
            return this.channel.socket.getSendBufferSize();
        } catch (IOException e2) {
            throw new ChannelException(e2);
        }
    }

    @Override // io.netty.channel.socket.SocketChannelConfig
    public int getSoLinger() {
        try {
            return this.channel.socket.getSoLinger();
        } catch (IOException e2) {
            throw new ChannelException(e2);
        }
    }

    public int getTcpKeepCnt() {
        try {
            return this.channel.socket.getTcpKeepCnt();
        } catch (IOException e2) {
            throw new ChannelException(e2);
        }
    }

    public int getTcpKeepIdle() {
        try {
            return this.channel.socket.getTcpKeepIdle();
        } catch (IOException e2) {
            throw new ChannelException(e2);
        }
    }

    public int getTcpKeepIntvl() {
        try {
            return this.channel.socket.getTcpKeepIntvl();
        } catch (IOException e2) {
            throw new ChannelException(e2);
        }
    }

    public long getTcpNotSentLowAt() {
        try {
            return this.channel.socket.getTcpNotSentLowAt();
        } catch (IOException e2) {
            throw new ChannelException(e2);
        }
    }

    public int getTcpUserTimeout() {
        try {
            return this.channel.socket.getTcpUserTimeout();
        } catch (IOException e2) {
            throw new ChannelException(e2);
        }
    }

    @Override // io.netty.channel.socket.SocketChannelConfig
    public int getTrafficClass() {
        try {
            return this.channel.socket.getTrafficClass();
        } catch (IOException e2) {
            throw new ChannelException(e2);
        }
    }

    @Override // io.netty.channel.socket.SocketChannelConfig
    public boolean isAllowHalfClosure() {
        return this.allowHalfClosure;
    }

    public boolean isIpTransparent() {
        try {
            return this.channel.socket.isIpTransparent();
        } catch (IOException e2) {
            throw new ChannelException(e2);
        }
    }

    @Override // io.netty.channel.socket.SocketChannelConfig
    public boolean isKeepAlive() {
        try {
            return this.channel.socket.isKeepAlive();
        } catch (IOException e2) {
            throw new ChannelException(e2);
        }
    }

    @Override // io.netty.channel.socket.SocketChannelConfig
    public boolean isReuseAddress() {
        try {
            return this.channel.socket.isReuseAddress();
        } catch (IOException e2) {
            throw new ChannelException(e2);
        }
    }

    public boolean isTcpCork() {
        try {
            return this.channel.socket.isTcpCork();
        } catch (IOException e2) {
            throw new ChannelException(e2);
        }
    }

    public boolean isTcpFastOpenConnect() {
        try {
            return this.channel.socket.isTcpFastOpenConnect();
        } catch (IOException e2) {
            throw new ChannelException(e2);
        }
    }

    @Override // io.netty.channel.socket.SocketChannelConfig
    public boolean isTcpNoDelay() {
        try {
            return this.channel.socket.isTcpNoDelay();
        } catch (IOException e2) {
            throw new ChannelException(e2);
        }
    }

    public boolean isTcpQuickAck() {
        try {
            return this.channel.socket.isTcpQuickAck();
        } catch (IOException e2) {
            throw new ChannelException(e2);
        }
    }

    @Override // io.netty.channel.epoll.EpollChannelConfig, io.netty.channel.DefaultChannelConfig, io.netty.channel.ChannelConfig
    public EpollSocketChannelConfig setAllocator(ByteBufAllocator byteBufAllocator) {
        super.setAllocator(byteBufAllocator);
        return this;
    }

    @Override // io.netty.channel.socket.SocketChannelConfig
    public EpollSocketChannelConfig setAllowHalfClosure(boolean z2) {
        this.allowHalfClosure = z2;
        return this;
    }

    @Override // io.netty.channel.DefaultChannelConfig, io.netty.channel.ChannelConfig
    public EpollSocketChannelConfig setAutoClose(boolean z2) {
        super.setAutoClose(z2);
        return this;
    }

    @Override // io.netty.channel.epoll.EpollChannelConfig, io.netty.channel.DefaultChannelConfig, io.netty.channel.ChannelConfig
    public EpollSocketChannelConfig setAutoRead(boolean z2) {
        super.setAutoRead(z2);
        return this;
    }

    @Override // io.netty.channel.epoll.EpollChannelConfig, io.netty.channel.DefaultChannelConfig, io.netty.channel.ChannelConfig
    public EpollSocketChannelConfig setConnectTimeoutMillis(int i2) {
        super.setConnectTimeoutMillis(i2);
        return this;
    }

    @Override // io.netty.channel.epoll.EpollChannelConfig
    public EpollSocketChannelConfig setEpollMode(EpollMode epollMode) {
        super.setEpollMode(epollMode);
        return this;
    }

    public EpollSocketChannelConfig setIpTransparent(boolean z2) {
        try {
            this.channel.socket.setIpTransparent(z2);
            return this;
        } catch (IOException e2) {
            throw new ChannelException(e2);
        }
    }

    @Override // io.netty.channel.socket.SocketChannelConfig
    public EpollSocketChannelConfig setKeepAlive(boolean z2) {
        try {
            this.channel.socket.setKeepAlive(z2);
            return this;
        } catch (IOException e2) {
            throw new ChannelException(e2);
        }
    }

    @Override // io.netty.channel.epoll.EpollChannelConfig, io.netty.channel.DefaultChannelConfig, io.netty.channel.ChannelConfig
    @Deprecated
    public EpollSocketChannelConfig setMaxMessagesPerRead(int i2) {
        super.setMaxMessagesPerRead(i2);
        return this;
    }

    @Override // io.netty.channel.epoll.EpollChannelConfig, io.netty.channel.DefaultChannelConfig, io.netty.channel.ChannelConfig
    public EpollSocketChannelConfig setMessageSizeEstimator(MessageSizeEstimator messageSizeEstimator) {
        super.setMessageSizeEstimator(messageSizeEstimator);
        return this;
    }

    /* JADX WARN: Multi-variable type inference failed */
    @Override // io.netty.channel.epoll.EpollChannelConfig, io.netty.channel.DefaultChannelConfig, io.netty.channel.ChannelConfig
    public <T> boolean setOption(ChannelOption<T> channelOption, T t2) {
        validate(channelOption, t2);
        if (channelOption == ChannelOption.SO_RCVBUF) {
            setReceiveBufferSize(((Integer) t2).intValue());
            return true;
        }
        if (channelOption == ChannelOption.SO_SNDBUF) {
            setSendBufferSize(((Integer) t2).intValue());
            return true;
        }
        if (channelOption == ChannelOption.TCP_NODELAY) {
            setTcpNoDelay(((Boolean) t2).booleanValue());
            return true;
        }
        if (channelOption == ChannelOption.SO_KEEPALIVE) {
            setKeepAlive(((Boolean) t2).booleanValue());
            return true;
        }
        if (channelOption == ChannelOption.SO_REUSEADDR) {
            setReuseAddress(((Boolean) t2).booleanValue());
            return true;
        }
        if (channelOption == ChannelOption.SO_LINGER) {
            setSoLinger(((Integer) t2).intValue());
            return true;
        }
        if (channelOption == ChannelOption.IP_TOS) {
            setTrafficClass(((Integer) t2).intValue());
            return true;
        }
        if (channelOption == ChannelOption.ALLOW_HALF_CLOSURE) {
            setAllowHalfClosure(((Boolean) t2).booleanValue());
            return true;
        }
        if (channelOption == EpollChannelOption.TCP_CORK) {
            setTcpCork(((Boolean) t2).booleanValue());
            return true;
        }
        if (channelOption == EpollChannelOption.TCP_NOTSENT_LOWAT) {
            setTcpNotSentLowAt(((Long) t2).longValue());
            return true;
        }
        if (channelOption == EpollChannelOption.TCP_KEEPIDLE) {
            setTcpKeepIdle(((Integer) t2).intValue());
            return true;
        }
        if (channelOption == EpollChannelOption.TCP_KEEPCNT) {
            setTcpKeepCnt(((Integer) t2).intValue());
            return true;
        }
        if (channelOption == EpollChannelOption.TCP_KEEPINTVL) {
            setTcpKeepIntvl(((Integer) t2).intValue());
            return true;
        }
        if (channelOption == EpollChannelOption.TCP_USER_TIMEOUT) {
            setTcpUserTimeout(((Integer) t2).intValue());
            return true;
        }
        if (channelOption == EpollChannelOption.IP_TRANSPARENT) {
            setIpTransparent(((Boolean) t2).booleanValue());
            return true;
        }
        if (channelOption == EpollChannelOption.TCP_MD5SIG) {
            setTcpMd5Sig((Map) t2);
            return true;
        }
        if (channelOption == EpollChannelOption.TCP_QUICKACK) {
            setTcpQuickAck(((Boolean) t2).booleanValue());
            return true;
        }
        if (channelOption != EpollChannelOption.TCP_FASTOPEN_CONNECT) {
            return super.setOption(channelOption, t2);
        }
        setTcpFastOpenConnect(((Boolean) t2).booleanValue());
        return true;
    }

    @Override // io.netty.channel.socket.SocketChannelConfig
    public EpollSocketChannelConfig setPerformancePreferences(int i2, int i3, int i4) {
        return this;
    }

    @Override // io.netty.channel.socket.SocketChannelConfig
    public EpollSocketChannelConfig setReceiveBufferSize(int i2) {
        try {
            this.channel.socket.setReceiveBufferSize(i2);
            return this;
        } catch (IOException e2) {
            throw new ChannelException(e2);
        }
    }

    @Override // io.netty.channel.epoll.EpollChannelConfig, io.netty.channel.DefaultChannelConfig, io.netty.channel.ChannelConfig
    public EpollSocketChannelConfig setRecvByteBufAllocator(RecvByteBufAllocator recvByteBufAllocator) {
        super.setRecvByteBufAllocator(recvByteBufAllocator);
        return this;
    }

    @Override // io.netty.channel.socket.SocketChannelConfig
    public EpollSocketChannelConfig setReuseAddress(boolean z2) {
        try {
            this.channel.socket.setReuseAddress(z2);
            return this;
        } catch (IOException e2) {
            throw new ChannelException(e2);
        }
    }

    @Override // io.netty.channel.socket.SocketChannelConfig
    public EpollSocketChannelConfig setSendBufferSize(int i2) {
        try {
            this.channel.socket.setSendBufferSize(i2);
            calculateMaxBytesPerGatheringWrite();
            return this;
        } catch (IOException e2) {
            throw new ChannelException(e2);
        }
    }

    @Override // io.netty.channel.socket.SocketChannelConfig
    public EpollSocketChannelConfig setSoLinger(int i2) {
        try {
            this.channel.socket.setSoLinger(i2);
            return this;
        } catch (IOException e2) {
            throw new ChannelException(e2);
        }
    }

    public EpollSocketChannelConfig setTcpCork(boolean z2) {
        try {
            this.channel.socket.setTcpCork(z2);
            return this;
        } catch (IOException e2) {
            throw new ChannelException(e2);
        }
    }

    public EpollSocketChannelConfig setTcpFastOpenConnect(boolean z2) {
        try {
            this.channel.socket.setTcpFastOpenConnect(z2);
            return this;
        } catch (IOException e2) {
            throw new ChannelException(e2);
        }
    }

    public EpollSocketChannelConfig setTcpKeepCnt(int i2) {
        try {
            this.channel.socket.setTcpKeepCnt(i2);
            return this;
        } catch (IOException e2) {
            throw new ChannelException(e2);
        }
    }

    @Deprecated
    public EpollSocketChannelConfig setTcpKeepCntl(int i2) {
        return setTcpKeepCnt(i2);
    }

    public EpollSocketChannelConfig setTcpKeepIdle(int i2) {
        try {
            this.channel.socket.setTcpKeepIdle(i2);
            return this;
        } catch (IOException e2) {
            throw new ChannelException(e2);
        }
    }

    public EpollSocketChannelConfig setTcpKeepIntvl(int i2) {
        try {
            this.channel.socket.setTcpKeepIntvl(i2);
            return this;
        } catch (IOException e2) {
            throw new ChannelException(e2);
        }
    }

    public EpollSocketChannelConfig setTcpMd5Sig(Map<InetAddress, byte[]> map) {
        try {
            this.channel.setTcpMd5Sig(map);
            return this;
        } catch (IOException e2) {
            throw new ChannelException(e2);
        }
    }

    @Override // io.netty.channel.socket.SocketChannelConfig
    public EpollSocketChannelConfig setTcpNoDelay(boolean z2) {
        try {
            this.channel.socket.setTcpNoDelay(z2);
            return this;
        } catch (IOException e2) {
            throw new ChannelException(e2);
        }
    }

    public EpollSocketChannelConfig setTcpNotSentLowAt(long j2) {
        try {
            this.channel.socket.setTcpNotSentLowAt(j2);
            return this;
        } catch (IOException e2) {
            throw new ChannelException(e2);
        }
    }

    public EpollSocketChannelConfig setTcpQuickAck(boolean z2) {
        try {
            this.channel.socket.setTcpQuickAck(z2);
            return this;
        } catch (IOException e2) {
            throw new ChannelException(e2);
        }
    }

    public EpollSocketChannelConfig setTcpUserTimeout(int i2) {
        try {
            this.channel.socket.setTcpUserTimeout(i2);
            return this;
        } catch (IOException e2) {
            throw new ChannelException(e2);
        }
    }

    @Override // io.netty.channel.socket.SocketChannelConfig
    public EpollSocketChannelConfig setTrafficClass(int i2) {
        try {
            this.channel.socket.setTrafficClass(i2);
            return this;
        } catch (IOException e2) {
            throw new ChannelException(e2);
        }
    }

    @Override // io.netty.channel.epoll.EpollChannelConfig, io.netty.channel.DefaultChannelConfig, io.netty.channel.ChannelConfig
    @Deprecated
    public EpollSocketChannelConfig setWriteBufferHighWaterMark(int i2) {
        super.setWriteBufferHighWaterMark(i2);
        return this;
    }

    @Override // io.netty.channel.epoll.EpollChannelConfig, io.netty.channel.DefaultChannelConfig, io.netty.channel.ChannelConfig
    @Deprecated
    public EpollSocketChannelConfig setWriteBufferLowWaterMark(int i2) {
        super.setWriteBufferLowWaterMark(i2);
        return this;
    }

    @Override // io.netty.channel.epoll.EpollChannelConfig, io.netty.channel.DefaultChannelConfig, io.netty.channel.ChannelConfig
    public EpollSocketChannelConfig setWriteBufferWaterMark(WriteBufferWaterMark writeBufferWaterMark) {
        super.setWriteBufferWaterMark(writeBufferWaterMark);
        return this;
    }

    @Override // io.netty.channel.epoll.EpollChannelConfig, io.netty.channel.DefaultChannelConfig, io.netty.channel.ChannelConfig
    public EpollSocketChannelConfig setWriteSpinCount(int i2) {
        super.setWriteSpinCount(i2);
        return this;
    }
}
