Java Code Examples for android.system.OsConstants#IPPROTO_TCP

The following examples show how to use android.system.OsConstants#IPPROTO_TCP . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OffloadController.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
private static int connectionTimeoutUpdateSecondsFor(int proto) {
    // TODO: Replace this with more thoughtful work, perhaps reading from
    // and maybe writing to any required
    //
    //     /proc/sys/net/netfilter/nf_conntrack_tcp_timeout_*
    //     /proc/sys/net/netfilter/nf_conntrack_udp_timeout{,_stream}
    //
    // entries.  TBD.
    if (proto == OsConstants.IPPROTO_TCP) {
        // Cf. /proc/sys/net/netfilter/nf_conntrack_tcp_timeout_established
        return 432000;
    } else {
        // Cf. /proc/sys/net/netfilter/nf_conntrack_udp_timeout_stream
        return 180;
    }
}
 
Example 2
Source File: OffloadController.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
private static String protoNameFor(int proto) {
    // OsConstants values are not constant expressions; no switch statement.
    if (proto == OsConstants.IPPROTO_UDP) {
        return "UDP";
    } else if (proto == OsConstants.IPPROTO_TCP) {
        return "TCP";
    }
    return null;
}
 
Example 3
Source File: OffloadHardwareInterface.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
private static int networkProtocolToOsConstant(int proto) {
    switch (proto) {
        case NetworkProtocol.TCP: return OsConstants.IPPROTO_TCP;
        case NetworkProtocol.UDP: return OsConstants.IPPROTO_UDP;
        default:
            // The caller checks this value and will log an error. Just make
            // sure it won't collide with valid OsContants.IPPROTO_* values.
            return -Math.abs(proto);
    }
}