summaryrefslogtreecommitdiffstats
path: root/luni/src/main/java/android
diff options
context:
space:
mode:
authorLorenzo Colitti <lorenzo@google.com>2015-03-16 11:12:53 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-03-16 11:12:53 +0000
commita4ca7f443a72043b25d1646cd6a77661e09eb63b (patch)
tree8fc5609cbd99ea3ccfcdf7d5d3379042c03c3923 /luni/src/main/java/android
parent357c5b8fdf4ab505bb41ffaa2492da837231dfb8 (diff)
parent1ab902acc995d6ef7a297959d57b6d8715a0bd2a (diff)
downloadlibcore-a4ca7f443a72043b25d1646cd6a77661e09eb63b.zip
libcore-a4ca7f443a72043b25d1646cd6a77661e09eb63b.tar.gz
libcore-a4ca7f443a72043b25d1646cd6a77661e09eb63b.tar.bz2
am 1ab902ac: am 9322c6d2: Merge "Add a PacketSocketAddress class that represents sockaddr_ll."
* commit '1ab902acc995d6ef7a297959d57b6d8715a0bd2a': Add a PacketSocketAddress class that represents sockaddr_ll.
Diffstat (limited to 'luni/src/main/java/android')
-rw-r--r--luni/src/main/java/android/system/PacketSocketAddress.java64
1 files changed, 64 insertions, 0 deletions
diff --git a/luni/src/main/java/android/system/PacketSocketAddress.java b/luni/src/main/java/android/system/PacketSocketAddress.java
new file mode 100644
index 0000000..510771c
--- /dev/null
+++ b/luni/src/main/java/android/system/PacketSocketAddress.java
@@ -0,0 +1,64 @@
+/*
+ * 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;
+
+/**
+ * Packet socket address.
+ *
+ * Corresponds to Linux's {@code struct sockaddr_ll}.
+ *
+ * @hide
+ */
+public final class PacketSocketAddress extends SocketAddress {
+ /** Protocol. An Ethernet protocol type, e.g., {@code ETH_P_IPV6}. */
+ public short sll_protocol;
+
+ /** Interface index. */
+ public int sll_ifindex;
+
+ /** ARP hardware type. One of the {@code ARPHRD_*} constants. */
+ public short sll_hatype;
+
+ /** Packet type. One of the {@code PACKET_*} constants, such as {@code PACKET_OTHERHOST}. */
+ public byte sll_pkttype;
+
+ /** Hardware address. */
+ public byte[] sll_addr;
+
+ /** Constructs a new PacketSocketAddress. */
+ public PacketSocketAddress(short sll_protocol, int sll_ifindex,
+ short sll_hatype, byte sll_pkttype, byte[] sll_addr) {
+ this.sll_protocol = sll_protocol;
+ this.sll_ifindex = sll_ifindex;
+ this.sll_hatype = sll_hatype;
+ this.sll_pkttype = sll_pkttype;
+ this.sll_addr = sll_addr;
+ }
+
+ /** Constructs a new PacketSocketAddress suitable for binding to. */
+ public PacketSocketAddress(short sll_protocol, int sll_ifindex) {
+ this(sll_protocol, sll_ifindex, (short) 0, (byte) 0, null);
+ }
+
+ /** Constructs a new PacketSocketAddress suitable for sending to. */
+ public PacketSocketAddress(int sll_ifindex, byte[] sll_addr) {
+ this((short) 0, sll_ifindex, (short) 0, (byte) 0, sll_addr);
+ }
+}