diff options
author | Erik Kline <ek@google.com> | 2015-03-10 22:04:27 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-03-10 22:04:27 +0000 |
commit | b186e3c9195112f7acf938be388889dd773c2b18 (patch) | |
tree | 117e14d5da80d8e3cd6f2afcba5b8eacee303eed /luni/src/main/java/android | |
parent | 2e1d4fcc089f4d3451e9c982e7b192143df37674 (diff) | |
parent | 24c68680f1c187fa9d2a9cc4c4ddb5ae09fa7dfb (diff) | |
download | libcore-b186e3c9195112f7acf938be388889dd773c2b18.zip libcore-b186e3c9195112f7acf938be388889dd773c2b18.tar.gz libcore-b186e3c9195112f7acf938be388889dd773c2b18.tar.bz2 |
am 24c68680: am 649f614e: am 2882e512: Merge "Add support for netlink sockets and addresses."
* commit '24c68680f1c187fa9d2a9cc4c4ddb5ae09fa7dfb':
Add support for netlink sockets and addresses.
Diffstat (limited to 'luni/src/main/java/android')
-rw-r--r-- | luni/src/main/java/android/system/NetlinkSocketAddress.java | 61 | ||||
-rw-r--r-- | luni/src/main/java/android/system/Os.java | 4 | ||||
-rw-r--r-- | luni/src/main/java/android/system/OsConstants.java | 15 |
3 files changed, 80 insertions, 0 deletions
diff --git a/luni/src/main/java/android/system/NetlinkSocketAddress.java b/luni/src/main/java/android/system/NetlinkSocketAddress.java new file mode 100644 index 0000000..af78cd0 --- /dev/null +++ b/luni/src/main/java/android/system/NetlinkSocketAddress.java @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2015 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.system; + +import libcore.util.Objects; +import java.net.SocketAddress; + +/** + * Netlink socket address. + * + * Corresponds to Linux's {@code struct sockaddr_nl} from + * <a href="https://github.com/torvalds/linux/blob/master/include/uapi/linux/netlink.h"><linux/netlink.h></a>. + * + * @hide + */ +public final class NetlinkSocketAddress extends SocketAddress { + /** port ID */ + private final int nlPortId; + + /** multicast groups mask */ + private final int nlGroupsMask; + + public NetlinkSocketAddress() { + this(0, 0); + } + + public NetlinkSocketAddress(int nlPortId) { + this(nlPortId, 0); + } + + public NetlinkSocketAddress(int nlPortId, int nlGroupsMask) { + this.nlPortId = nlPortId; + this.nlGroupsMask = nlGroupsMask; + } + + public int getPortId() { + return nlPortId; + } + + public int getGroupsMask() { + return nlGroupsMask; + } + + @Override public String toString() { + return Objects.toString(this); + } +} diff --git a/luni/src/main/java/android/system/Os.java b/luni/src/main/java/android/system/Os.java index 8028f23..ee683d2 100644 --- a/luni/src/main/java/android/system/Os.java +++ b/luni/src/main/java/android/system/Os.java @@ -54,6 +54,8 @@ public final class Os { */ public static void bind(FileDescriptor fd, InetAddress address, int port) throws ErrnoException, SocketException { Libcore.os.bind(fd, address, port); } + /** @hide */ public static void bind(FileDescriptor fd, SocketAddress address) throws ErrnoException, SocketException { Libcore.os.bind(fd, address); } + /** * See <a href="http://man7.org/linux/man-pages/man2/chmod.2.html">chmod(2)</a>. */ @@ -74,6 +76,8 @@ public final class Os { */ public static void connect(FileDescriptor fd, InetAddress address, int port) throws ErrnoException, SocketException { Libcore.os.connect(fd, address, port); } + /** @hide */ public static void connect(FileDescriptor fd, SocketAddress address) throws ErrnoException, SocketException { Libcore.os.connect(fd, address); } + /** * See <a href="http://man7.org/linux/man-pages/man2/dup.2.html">dup(2)</a>. */ diff --git a/luni/src/main/java/android/system/OsConstants.java b/luni/src/main/java/android/system/OsConstants.java index 1f9205c..a52004b 100644 --- a/luni/src/main/java/android/system/OsConstants.java +++ b/luni/src/main/java/android/system/OsConstants.java @@ -95,6 +95,7 @@ public final class OsConstants { public static final int AF_INET = placeholder(); public static final int AF_INET6 = placeholder(); + /** @hide */ public static final int AF_NETLINK = placeholder(); public static final int AF_UNIX = placeholder(); public static final int AF_UNSPEC = placeholder(); public static final int AI_ADDRCONFIG = placeholder(); @@ -324,6 +325,7 @@ public final class OsConstants { public static final int MS_ASYNC = placeholder(); public static final int MS_INVALIDATE = placeholder(); public static final int MS_SYNC = placeholder(); + /** @hide */ public static final int NETLINK_ROUTE = placeholder(); public static final int NI_DGRAM = placeholder(); public static final int NI_NAMEREQD = placeholder(); public static final int NI_NOFQDN = placeholder(); @@ -365,6 +367,19 @@ public final class OsConstants { public static final int RT_SCOPE_NOWHERE = placeholder(); public static final int RT_SCOPE_SITE = placeholder(); public static final int RT_SCOPE_UNIVERSE = placeholder(); + /** @hide */ public static final int RTMGRP_IPV4_IFADDR = placeholder(); + /** @hide */ public static final int RTMGRP_IPV4_MROUTE = placeholder(); + /** @hide */ public static final int RTMGRP_IPV4_ROUTE = placeholder(); + /** @hide */ public static final int RTMGRP_IPV4_RULE = placeholder(); + /** @hide */ public static final int RTMGRP_IPV6_IFADDR = placeholder(); + /** @hide */ public static final int RTMGRP_IPV6_IFINFO = placeholder(); + /** @hide */ public static final int RTMGRP_IPV6_MROUTE = placeholder(); + /** @hide */ public static final int RTMGRP_IPV6_PREFIX = placeholder(); + /** @hide */ public static final int RTMGRP_IPV6_ROUTE = placeholder(); + /** @hide */ public static final int RTMGRP_LINK = placeholder(); + /** @hide */ public static final int RTMGRP_NEIGH = placeholder(); + /** @hide */ public static final int RTMGRP_NOTIFY = placeholder(); + /** @hide */ public static final int RTMGRP_TC = placeholder(); public static final int SEEK_CUR = placeholder(); public static final int SEEK_END = placeholder(); public static final int SEEK_SET = placeholder(); |