Elliott Hughes | 1c039d7 | 2011-05-04 16:04:04 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 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 | |
Elliott Hughes | 5d930ca | 2014-04-23 17:53:37 -0700 | [diff] [blame] | 17 | package android.system; |
Elliott Hughes | 1c039d7 | 2011-05-04 16:04:04 -0700 | [diff] [blame] | 18 | |
| 19 | import java.net.InetAddress; |
Elliott Hughes | fe77f81 | 2014-04-29 17:59:30 -0700 | [diff] [blame] | 20 | import libcore.util.Objects; |
Elliott Hughes | 1c039d7 | 2011-05-04 16:04:04 -0700 | [diff] [blame] | 21 | |
| 22 | /** |
| 23 | * Information returned/taken by getaddrinfo(3). Corresponds to C's {@code struct addrinfo} from |
| 24 | * <a href="http://pubs.opengroup.org/onlinepubs/009695399/basedefs/netdb.h.html"><netdb.h></a> |
| 25 | * |
| 26 | * TODO: we currently only _take_ a StructAddrinfo; getaddrinfo returns an InetAddress[]. |
Elliott Hughes | 5d930ca | 2014-04-23 17:53:37 -0700 | [diff] [blame] | 27 | * |
| 28 | * @hide |
Elliott Hughes | 1c039d7 | 2011-05-04 16:04:04 -0700 | [diff] [blame] | 29 | */ |
| 30 | public final class StructAddrinfo { |
Elliott Hughes | fe77f81 | 2014-04-29 17:59:30 -0700 | [diff] [blame] | 31 | /** Flags describing the kind of lookup to be done. (Such as AI_ADDRCONFIG.) */ |
| 32 | public int ai_flags; |
Elliott Hughes | 1c039d7 | 2011-05-04 16:04:04 -0700 | [diff] [blame] | 33 | |
Elliott Hughes | fe77f81 | 2014-04-29 17:59:30 -0700 | [diff] [blame] | 34 | /** Desired address family for results. (Such as AF_INET6 for IPv6. AF_UNSPEC means "any".) */ |
| 35 | public int ai_family; |
Elliott Hughes | 1c039d7 | 2011-05-04 16:04:04 -0700 | [diff] [blame] | 36 | |
Elliott Hughes | fe77f81 | 2014-04-29 17:59:30 -0700 | [diff] [blame] | 37 | /** Socket type. (Such as SOCK_DGRAM. 0 means "any".) */ |
| 38 | public int ai_socktype; |
Elliott Hughes | 1c039d7 | 2011-05-04 16:04:04 -0700 | [diff] [blame] | 39 | |
Elliott Hughes | fe77f81 | 2014-04-29 17:59:30 -0700 | [diff] [blame] | 40 | /** Protocol. (Such as IPPROTO_IPV6 IPv6. 0 means "any".) */ |
| 41 | public int ai_protocol; |
Elliott Hughes | 1c039d7 | 2011-05-04 16:04:04 -0700 | [diff] [blame] | 42 | |
Elliott Hughes | fe77f81 | 2014-04-29 17:59:30 -0700 | [diff] [blame] | 43 | /** Address length. (Not useful in Java.) */ |
| 44 | // public int ai_addrlen; |
Elliott Hughes | 1c039d7 | 2011-05-04 16:04:04 -0700 | [diff] [blame] | 45 | |
Elliott Hughes | fe77f81 | 2014-04-29 17:59:30 -0700 | [diff] [blame] | 46 | /** Address. */ |
| 47 | public InetAddress ai_addr; |
Elliott Hughes | 1c039d7 | 2011-05-04 16:04:04 -0700 | [diff] [blame] | 48 | |
Elliott Hughes | fe77f81 | 2014-04-29 17:59:30 -0700 | [diff] [blame] | 49 | /** Canonical name of service location (if AI_CANONNAME provided in ai_flags). */ |
| 50 | // public String ai_canonname; |
Elliott Hughes | 1c039d7 | 2011-05-04 16:04:04 -0700 | [diff] [blame] | 51 | |
Elliott Hughes | fe77f81 | 2014-04-29 17:59:30 -0700 | [diff] [blame] | 52 | /** Next element in linked list. */ |
| 53 | public StructAddrinfo ai_next; |
| 54 | |
| 55 | @Override public String toString() { |
| 56 | return Objects.toString(this); |
| 57 | } |
Elliott Hughes | 1c039d7 | 2011-05-04 16:04:04 -0700 | [diff] [blame] | 58 | } |