1069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project/*
2069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/routing/RouteInfo.java $
3069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project * $Revision: 652200 $
4069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project * $Date: 2008-04-29 17:22:43 -0700 (Tue, 29 Apr 2008) $
5069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project *
6069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project * ====================================================================
7069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project * Licensed to the Apache Software Foundation (ASF) under one
8069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project * or more contributor license agreements.  See the NOTICE file
9069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project * distributed with this work for additional information
10069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project * regarding copyright ownership.  The ASF licenses this file
11069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project * to you under the Apache License, Version 2.0 (the
12069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project * "License"); you may not use this file except in compliance
13069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project * with the License.  You may obtain a copy of the License at
14069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project *
15069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project *   http://www.apache.org/licenses/LICENSE-2.0
16069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project *
17069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project * Unless required by applicable law or agreed to in writing,
18069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project * software distributed under the License is distributed on an
19069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
20069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project * KIND, either express or implied.  See the License for the
21069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project * specific language governing permissions and limitations
22069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project * under the License.
23069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project * ====================================================================
24069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project *
25069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project * This software consists of voluntary contributions made by many
26069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project * individuals on behalf of the Apache Software Foundation.  For more
27069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project * information on the Apache Software Foundation, please see
28069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project * <http://www.apache.org/>.
29069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project *
30069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project */
31069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project
32069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Projectpackage org.apache.http.conn.routing;
33069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project
34069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Projectimport java.net.InetAddress;
35069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project
36069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Projectimport org.apache.http.HttpHost;
37069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project
38069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project
39069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project/**
40069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project * Read-only interface for route information.
41069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project *
42069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project * @author <a href="mailto:rolandw at apache.org">Roland Weber</a>
43069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project *
44069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project *
45069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project * <!-- empty lines to avoid svn diff problems -->
46069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project * @version $Revision: 652200 $
47069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project *
48069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project * @since 4.0
49069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project */
50069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Projectpublic interface RouteInfo {
51069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project
52069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    /**
53069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * The tunnelling type of a route.
54069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * Plain routes are established by connecting to the target or
55069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * the first proxy.
56069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * Tunnelled routes are established by connecting to the first proxy
57069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * and tunnelling through all proxies to the target.
58069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * Routes without a proxy cannot be tunnelled.
59069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     */
60069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    public enum TunnelType { PLAIN, TUNNELLED }
61069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project
62069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    /**
63069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * The layering type of a route.
64069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * Plain routes are established by connecting or tunnelling.
65069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * Layered routes are established by layering a protocol such as TLS/SSL
66069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * over an existing connection.
67069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * Protocols can only be layered over a tunnel to the target, or
68069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * or over a direct connection without proxies.
69069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * <br/>
70069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * Layering a protocol
71069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * over a direct connection makes little sense, since the connection
72069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * could be established with the new protocol in the first place.
73069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * But we don't want to exclude that use case.
74069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     */
75069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    public enum LayerType  { PLAIN, LAYERED }
76069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project
77069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project
78069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project
79069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    /**
80069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * Obtains the target host.
81069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     *
82069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * @return the target host
83069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     */
84069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    HttpHost getTargetHost()
85069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project        ;
86069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project
87069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project
88069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    /**
89069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * Obtains the local address to connect from.
90069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     *
91069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * @return  the local address,
92069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     *          or <code>null</code>
93069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     */
94069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    InetAddress getLocalAddress()
95069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project        ;
96069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project
97069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project
98069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    /**
99069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * Obtains the number of hops in this route.
100069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * A direct route has one hop. A route through a proxy has two hops.
101069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * A route through a chain of <i>n</i> proxies has <i>n+1</i> hops.
102069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     *
103069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * @return  the number of hops in this route
104069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     */
105069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    int getHopCount()
106069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project        ;
107069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project
108069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project
109069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    /**
110069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * Obtains the target of a hop in this route.
111069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * The target of the last hop is the {@link #getTargetHost target host},
112069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * the target of previous hops is the respective proxy in the chain.
113069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * For a route through exactly one proxy, target of hop 0 is the proxy
114069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * and target of hop 1 is the target host.
115069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     *
116069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * @param hop       index of the hop for which to get the target,
117069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     *                  0 for first
118069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     *
119069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * @return  the target of the given hop
120069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     *
121069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * @throws IllegalArgumentException
122069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     *  if the argument is negative or not less than
123069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     *  {@link #getHopCount getHopCount()}
124069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     */
125069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    HttpHost getHopTarget(int hop)
126069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project        ;
127069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project
128069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project
129069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    /**
130069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * Obtains the first proxy host.
131069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     *
132069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * @return the first proxy in the proxy chain, or
133069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     *         <code>null</code> if this route is direct
134069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     */
135069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    HttpHost getProxyHost()
136069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project        ;
137069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project
138069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project
139069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    /**
140069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * Obtains the tunnel type of this route.
141069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * If there is a proxy chain, only end-to-end tunnels are considered.
142069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     *
143069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * @return  the tunnelling type
144069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     */
145069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    TunnelType getTunnelType()
146069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project        ;
147069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project
148069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project
149069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    /**
150069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * Checks whether this route is tunnelled through a proxy.
151069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * If there is a proxy chain, only end-to-end tunnels are considered.
152069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     *
153069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * @return  <code>true</code> if tunnelled end-to-end through at least
154069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     *          one proxy,
155069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     *          <code>false</code> otherwise
156069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     */
157069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    boolean isTunnelled()
158069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project        ;
159069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project
160069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project
161069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    /**
162069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * Obtains the layering type of this route.
163069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * In the presence of proxies, only layering over an end-to-end tunnel
164069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * is considered.
165069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     *
166069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * @return  the layering type
167069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     */
168069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    LayerType getLayerType()
169069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project        ;
170069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project
171069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project
172069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    /**
173069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * Checks whether this route includes a layered protocol.
174069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * In the presence of proxies, only layering over an end-to-end tunnel
175069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * is considered.
176069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     *
177069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * @return  <code>true</code> if layered,
178069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     *          <code>false</code> otherwise
179069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     */
180069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    boolean isLayered()
181069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project        ;
182069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project
183069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project
184069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    /**
185069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * Checks whether this route is secure.
186069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     *
187069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     * @return  <code>true</code> if secure,
188069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     *          <code>false</code> otherwise
189069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project     */
190069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project    boolean isSecure()
191069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project        ;
192069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project
193069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project
194069490a5ca2fd1988d29daf45d892f47ad665115The Android Open Source Project} // interface RouteInfo
195