001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: package org.apache.tomcat.jni;
019:
020: /** Address
021: *
022: * @author Mladen Turk
023: * @version $Revision: 467222 $, $Date: 2006-10-24 05:17:11 +0200 (mar., 24 oct. 2006) $
024: */
025:
026: public class Address {
027:
028: static public String APR_ANYADDR = "0.0.0.0";
029:
030: /**
031: * Fill the Sockaddr class from apr_sockaddr_t
032: * @param info Sockaddr class to fill
033: * @param sa Structure pointer
034: */
035: public static native boolean fill(Sockaddr info, long sa);
036:
037: /**
038: * Create the Sockaddr object from apr_sockaddr_t
039: * @param sa Structure pointer
040: */
041: public static native Sockaddr getInfo(long sa);
042:
043: /**
044: * Create apr_sockaddr_t from hostname, address family, and port.
045: * @param hostname The hostname or numeric address string to resolve/parse, or
046: * NULL to build an address that corresponds to 0.0.0.0 or ::
047: * @param family The address family to use, or APR_UNSPEC if the system should
048: * decide.
049: * @param port The port number.
050: * @param flags Special processing flags:
051: * <PRE>
052: * APR_IPV4_ADDR_OK first query for IPv4 addresses; only look
053: * for IPv6 addresses if the first query failed;
054: * only valid if family is APR_UNSPEC and hostname
055: * isn't NULL; mutually exclusive with
056: * APR_IPV6_ADDR_OK
057: * APR_IPV6_ADDR_OK first query for IPv6 addresses; only look
058: * for IPv4 addresses if the first query failed;
059: * only valid if family is APR_UNSPEC and hostname
060: * isn't NULL and APR_HAVE_IPV6; mutually exclusive
061: * with APR_IPV4_ADDR_OK
062: * </PRE>
063: * @param p The pool for the apr_sockaddr_t and associated storage.
064: * @return The new apr_sockaddr_t.
065: */
066: public static native long info(String hostname, int family,
067: int port, int flags, long p) throws Exception;
068:
069: /**
070: * Look up the host name from an apr_sockaddr_t.
071: * @param sa The apr_sockaddr_t.
072: * @param flags Special processing flags.
073: * @return The hostname.
074: */
075: public static native String getnameinfo(long sa, int flags);
076:
077: /**
078: * Return the IP address (in numeric address string format) in
079: * an APR socket address. APR will allocate storage for the IP address
080: * string from the pool of the apr_sockaddr_t.
081: * @param sa The socket address to reference.
082: * @return The IP address.
083: */
084: public static native String getip(long sa);
085:
086: /**
087: * Given an apr_sockaddr_t and a service name, set the port for the service
088: * @param sockaddr The apr_sockaddr_t that will have its port set
089: * @param servname The name of the service you wish to use
090: * @return APR status code.
091: */
092: public static native int getservbyname(long sockaddr,
093: String servname);
094:
095: /**
096: * Return an apr_sockaddr_t from an apr_socket_t
097: * @param which Which interface do we want the apr_sockaddr_t for?
098: * @param sock The socket to use
099: * @return The returned apr_sockaddr_t.
100: */
101: public static native long get(int which, long sock)
102: throws Exception;
103:
104: /**
105: * See if the IP addresses in two APR socket addresses are
106: * equivalent. Appropriate logic is present for comparing
107: * IPv4-mapped IPv6 addresses with IPv4 addresses.
108: *
109: * @param a One of the APR socket addresses.
110: * @param b The other APR socket address.
111: * The return value will be True if the addresses
112: * are equivalent.
113: */
114: public static native boolean equal(long a, long b);
115:
116: }
|