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