11c039d71d3879f39e3a75b8788e656f7b4f88f08Elliott Hughes/*
21c039d71d3879f39e3a75b8788e656f7b4f88f08Elliott Hughes * Copyright (C) 2011 The Android Open Source Project
31c039d71d3879f39e3a75b8788e656f7b4f88f08Elliott Hughes *
41c039d71d3879f39e3a75b8788e656f7b4f88f08Elliott Hughes * Licensed under the Apache License, Version 2.0 (the "License");
51c039d71d3879f39e3a75b8788e656f7b4f88f08Elliott Hughes * you may not use this file except in compliance with the License.
61c039d71d3879f39e3a75b8788e656f7b4f88f08Elliott Hughes * You may obtain a copy of the License at
71c039d71d3879f39e3a75b8788e656f7b4f88f08Elliott Hughes *
81c039d71d3879f39e3a75b8788e656f7b4f88f08Elliott Hughes *      http://www.apache.org/licenses/LICENSE-2.0
91c039d71d3879f39e3a75b8788e656f7b4f88f08Elliott Hughes *
101c039d71d3879f39e3a75b8788e656f7b4f88f08Elliott Hughes * Unless required by applicable law or agreed to in writing, software
111c039d71d3879f39e3a75b8788e656f7b4f88f08Elliott Hughes * distributed under the License is distributed on an "AS IS" BASIS,
121c039d71d3879f39e3a75b8788e656f7b4f88f08Elliott Hughes * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
131c039d71d3879f39e3a75b8788e656f7b4f88f08Elliott Hughes * See the License for the specific language governing permissions and
141c039d71d3879f39e3a75b8788e656f7b4f88f08Elliott Hughes * limitations under the License.
151c039d71d3879f39e3a75b8788e656f7b4f88f08Elliott Hughes */
161c039d71d3879f39e3a75b8788e656f7b4f88f08Elliott Hughes
175d930cadc8f62aee5f18e7921296fe66a54f18abElliott Hughespackage android.system;
181c039d71d3879f39e3a75b8788e656f7b4f88f08Elliott Hughes
191c039d71d3879f39e3a75b8788e656f7b4f88f08Elliott Hughesimport java.net.InetAddress;
20fe77f817b540f2a66c17486a618bb9083a22070eElliott Hughesimport libcore.util.Objects;
211c039d71d3879f39e3a75b8788e656f7b4f88f08Elliott Hughes
221c039d71d3879f39e3a75b8788e656f7b4f88f08Elliott Hughes/**
231c039d71d3879f39e3a75b8788e656f7b4f88f08Elliott Hughes * Information returned/taken by getaddrinfo(3). Corresponds to C's {@code struct addrinfo} from
241c039d71d3879f39e3a75b8788e656f7b4f88f08Elliott Hughes * <a href="http://pubs.opengroup.org/onlinepubs/009695399/basedefs/netdb.h.html">&lt;netdb.h&gt;</a>
251c039d71d3879f39e3a75b8788e656f7b4f88f08Elliott Hughes *
261c039d71d3879f39e3a75b8788e656f7b4f88f08Elliott Hughes * TODO: we currently only _take_ a StructAddrinfo; getaddrinfo returns an InetAddress[].
275d930cadc8f62aee5f18e7921296fe66a54f18abElliott Hughes *
285d930cadc8f62aee5f18e7921296fe66a54f18abElliott Hughes * @hide
291c039d71d3879f39e3a75b8788e656f7b4f88f08Elliott Hughes */
301c039d71d3879f39e3a75b8788e656f7b4f88f08Elliott Hughespublic final class StructAddrinfo {
31fe77f817b540f2a66c17486a618bb9083a22070eElliott Hughes  /** Flags describing the kind of lookup to be done. (Such as AI_ADDRCONFIG.) */
32fe77f817b540f2a66c17486a618bb9083a22070eElliott Hughes  public int ai_flags;
331c039d71d3879f39e3a75b8788e656f7b4f88f08Elliott Hughes
34fe77f817b540f2a66c17486a618bb9083a22070eElliott Hughes  /** Desired address family for results. (Such as AF_INET6 for IPv6. AF_UNSPEC means "any".) */
35fe77f817b540f2a66c17486a618bb9083a22070eElliott Hughes  public int ai_family;
361c039d71d3879f39e3a75b8788e656f7b4f88f08Elliott Hughes
37fe77f817b540f2a66c17486a618bb9083a22070eElliott Hughes  /** Socket type. (Such as SOCK_DGRAM. 0 means "any".) */
38fe77f817b540f2a66c17486a618bb9083a22070eElliott Hughes  public int ai_socktype;
391c039d71d3879f39e3a75b8788e656f7b4f88f08Elliott Hughes
40fe77f817b540f2a66c17486a618bb9083a22070eElliott Hughes  /** Protocol. (Such as IPPROTO_IPV6 IPv6. 0 means "any".) */
41fe77f817b540f2a66c17486a618bb9083a22070eElliott Hughes  public int ai_protocol;
421c039d71d3879f39e3a75b8788e656f7b4f88f08Elliott Hughes
43fe77f817b540f2a66c17486a618bb9083a22070eElliott Hughes  /** Address length. (Not useful in Java.) */
44fe77f817b540f2a66c17486a618bb9083a22070eElliott Hughes  // public int ai_addrlen;
451c039d71d3879f39e3a75b8788e656f7b4f88f08Elliott Hughes
46fe77f817b540f2a66c17486a618bb9083a22070eElliott Hughes  /** Address. */
47fe77f817b540f2a66c17486a618bb9083a22070eElliott Hughes  public InetAddress ai_addr;
481c039d71d3879f39e3a75b8788e656f7b4f88f08Elliott Hughes
49fe77f817b540f2a66c17486a618bb9083a22070eElliott Hughes  /** Canonical name of service location (if AI_CANONNAME provided in ai_flags). */
50fe77f817b540f2a66c17486a618bb9083a22070eElliott Hughes  // public String ai_canonname;
511c039d71d3879f39e3a75b8788e656f7b4f88f08Elliott Hughes
52fe77f817b540f2a66c17486a618bb9083a22070eElliott Hughes  /** Next element in linked list. */
53fe77f817b540f2a66c17486a618bb9083a22070eElliott Hughes  public StructAddrinfo ai_next;
54fe77f817b540f2a66c17486a618bb9083a22070eElliott Hughes
55fe77f817b540f2a66c17486a618bb9083a22070eElliott Hughes  @Override public String toString() {
56fe77f817b540f2a66c17486a618bb9083a22070eElliott Hughes    return Objects.toString(this);
57fe77f817b540f2a66c17486a618bb9083a22070eElliott Hughes  }
581c039d71d3879f39e3a75b8788e656f7b4f88f08Elliott Hughes}
59