markchien | f87ebdc | 2019-12-07 22:02:28 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2019 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | package android.net.util; |
| 17 | |
| 18 | import java.io.FileDescriptor; |
| 19 | import java.net.SocketException; |
| 20 | |
| 21 | /** |
| 22 | * Native methods for tethering utilization. |
| 23 | * |
| 24 | * {@hide} |
| 25 | */ |
| 26 | public class TetheringUtils { |
| 27 | |
| 28 | /** |
| 29 | * Offload management process need to know conntrack rules to support NAT, but it may not have |
| 30 | * permission to create netlink netfilter sockets. Create two netlink netfilter sockets and |
| 31 | * share them with offload management process. |
| 32 | */ |
| 33 | public static native boolean configOffload(); |
| 34 | |
| 35 | /** |
| 36 | * Configures a socket for receiving ICMPv6 router solicitations and sending advertisements. |
| 37 | * @param fd the socket's {@link FileDescriptor}. |
| 38 | * @param ifIndex the interface index. |
| 39 | */ |
| 40 | public static native void setupRaSocket(FileDescriptor fd, int ifIndex) |
| 41 | throws SocketException; |
markchien | 6cf0e55 | 2019-12-06 15:24:53 +0800 | [diff] [blame^] | 42 | |
| 43 | /** |
| 44 | * Read s as an unsigned 16-bit integer. |
| 45 | */ |
| 46 | public static int uint16(short s) { |
| 47 | return s & 0xffff; |
| 48 | } |
markchien | f87ebdc | 2019-12-07 22:02:28 +0800 | [diff] [blame] | 49 | } |