michael@0: /* michael@0: * ==================================================================== michael@0: * Licensed to the Apache Software Foundation (ASF) under one michael@0: * or more contributor license agreements. See the NOTICE file michael@0: * distributed with this work for additional information michael@0: * regarding copyright ownership. The ASF licenses this file michael@0: * to you under the Apache License, Version 2.0 (the michael@0: * "License"); you may not use this file except in compliance michael@0: * with the License. You may obtain a copy of the License at michael@0: * michael@0: * http://www.apache.org/licenses/LICENSE-2.0 michael@0: * michael@0: * Unless required by applicable law or agreed to in writing, michael@0: * software distributed under the License is distributed on an michael@0: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY michael@0: * KIND, either express or implied. See the License for the michael@0: * specific language governing permissions and limitations michael@0: * under the License. michael@0: * ==================================================================== michael@0: * michael@0: * This software consists of voluntary contributions made by many michael@0: * individuals on behalf of the Apache Software Foundation. For more michael@0: * information on the Apache Software Foundation, please see michael@0: * . michael@0: * michael@0: */ michael@0: michael@0: package ch.boye.httpclientandroidlib.conn.routing; michael@0: michael@0: import java.net.InetAddress; michael@0: michael@0: import ch.boye.httpclientandroidlib.HttpHost; michael@0: michael@0: /** michael@0: * Read-only interface for route information. michael@0: * michael@0: * @since 4.0 michael@0: */ michael@0: public interface RouteInfo { michael@0: michael@0: /** michael@0: * The tunnelling type of a route. michael@0: * Plain routes are established by connecting to the target or michael@0: * the first proxy. michael@0: * Tunnelled routes are established by connecting to the first proxy michael@0: * and tunnelling through all proxies to the target. michael@0: * Routes without a proxy cannot be tunnelled. michael@0: */ michael@0: public enum TunnelType { PLAIN, TUNNELLED } michael@0: michael@0: /** michael@0: * The layering type of a route. michael@0: * Plain routes are established by connecting or tunnelling. michael@0: * Layered routes are established by layering a protocol such as TLS/SSL michael@0: * over an existing connection. michael@0: * Protocols can only be layered over a tunnel to the target, or michael@0: * or over a direct connection without proxies. michael@0: *
michael@0: * Layering a protocol michael@0: * over a direct connection makes little sense, since the connection michael@0: * could be established with the new protocol in the first place. michael@0: * But we don't want to exclude that use case. michael@0: */ michael@0: public enum LayerType { PLAIN, LAYERED } michael@0: michael@0: /** michael@0: * Obtains the target host. michael@0: * michael@0: * @return the target host michael@0: */ michael@0: HttpHost getTargetHost(); michael@0: michael@0: /** michael@0: * Obtains the local address to connect from. michael@0: * michael@0: * @return the local address, michael@0: * or null michael@0: */ michael@0: InetAddress getLocalAddress(); michael@0: michael@0: /** michael@0: * Obtains the number of hops in this route. michael@0: * A direct route has one hop. A route through a proxy has two hops. michael@0: * A route through a chain of n proxies has n+1 hops. michael@0: * michael@0: * @return the number of hops in this route michael@0: */ michael@0: int getHopCount(); michael@0: michael@0: /** michael@0: * Obtains the target of a hop in this route. michael@0: * The target of the last hop is the {@link #getTargetHost target host}, michael@0: * the target of previous hops is the respective proxy in the chain. michael@0: * For a route through exactly one proxy, target of hop 0 is the proxy michael@0: * and target of hop 1 is the target host. michael@0: * michael@0: * @param hop index of the hop for which to get the target, michael@0: * 0 for first michael@0: * michael@0: * @return the target of the given hop michael@0: * michael@0: * @throws IllegalArgumentException michael@0: * if the argument is negative or not less than michael@0: * {@link #getHopCount getHopCount()} michael@0: */ michael@0: HttpHost getHopTarget(int hop); michael@0: michael@0: /** michael@0: * Obtains the first proxy host. michael@0: * michael@0: * @return the first proxy in the proxy chain, or michael@0: * null if this route is direct michael@0: */ michael@0: HttpHost getProxyHost(); michael@0: michael@0: /** michael@0: * Obtains the tunnel type of this route. michael@0: * If there is a proxy chain, only end-to-end tunnels are considered. michael@0: * michael@0: * @return the tunnelling type michael@0: */ michael@0: TunnelType getTunnelType(); michael@0: michael@0: /** michael@0: * Checks whether this route is tunnelled through a proxy. michael@0: * If there is a proxy chain, only end-to-end tunnels are considered. michael@0: * michael@0: * @return true if tunnelled end-to-end through at least michael@0: * one proxy, michael@0: * false otherwise michael@0: */ michael@0: boolean isTunnelled(); michael@0: michael@0: /** michael@0: * Obtains the layering type of this route. michael@0: * In the presence of proxies, only layering over an end-to-end tunnel michael@0: * is considered. michael@0: * michael@0: * @return the layering type michael@0: */ michael@0: LayerType getLayerType(); michael@0: michael@0: /** michael@0: * Checks whether this route includes a layered protocol. michael@0: * In the presence of proxies, only layering over an end-to-end tunnel michael@0: * is considered. michael@0: * michael@0: * @return true if layered, michael@0: * false otherwise michael@0: */ michael@0: boolean isLayered(); michael@0: michael@0: /** michael@0: * Checks whether this route is secure. michael@0: * michael@0: * @return true if secure, michael@0: * false otherwise michael@0: */ michael@0: boolean isSecure(); michael@0: michael@0: }