1 /* 2 * Copyright (C) 2015 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 17 package android.system; 18 19 import dalvik.annotation.compat.UnsupportedAppUsage; 20 import libcore.util.Objects; 21 import java.net.SocketAddress; 22 23 /** 24 * Netlink socket address. 25 * 26 * Corresponds to Linux's {@code struct sockaddr_nl} from 27 * <a href="https://github.com/torvalds/linux/blob/master/include/uapi/linux/netlink.h"><linux/netlink.h></a>. 28 * 29 * @hide 30 */ 31 @libcore.api.CorePlatformApi 32 public final class NetlinkSocketAddress extends SocketAddress { 33 /** port ID */ 34 private final int nlPortId; 35 36 /** multicast groups mask */ 37 private final int nlGroupsMask; 38 NetlinkSocketAddress()39 public NetlinkSocketAddress() { 40 this(0, 0); 41 } 42 NetlinkSocketAddress(int nlPortId)43 public NetlinkSocketAddress(int nlPortId) { 44 this(nlPortId, 0); 45 } 46 47 @UnsupportedAppUsage 48 @libcore.api.CorePlatformApi NetlinkSocketAddress(int nlPortId, int nlGroupsMask)49 public NetlinkSocketAddress(int nlPortId, int nlGroupsMask) { 50 this.nlPortId = nlPortId; 51 this.nlGroupsMask = nlGroupsMask; 52 } 53 54 @libcore.api.CorePlatformApi getPortId()55 public int getPortId() { 56 return nlPortId; 57 } 58 59 @libcore.api.CorePlatformApi getGroupsMask()60 public int getGroupsMask() { 61 return nlGroupsMask; 62 } 63 toString()64 @Override public String toString() { 65 return Objects.toString(this); 66 } 67 } 68