KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tomcat > jni > Address


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 package org.apache.tomcat.jni;
19
20 /** Address
21  *
22  * @author Mladen Turk
23  * @version $Revision: 467222 $, $Date: 2006-10-24 05:17:11 +0200 (mar., 24 oct. 2006) $
24  */

25
26 public class Address {
27
28     static public String JavaDoc APR_ANYADDR = "0.0.0.0";
29     /**
30      * Fill the Sockaddr class from apr_sockaddr_t
31      * @param info Sockaddr class to fill
32      * @param sa Structure pointer
33      */

34     public static native boolean fill(Sockaddr info, long sa);
35
36     /**
37      * Create the Sockaddr object from apr_sockaddr_t
38      * @param sa Structure pointer
39      */

40     public static native Sockaddr getInfo(long sa);
41
42     /**
43      * Create apr_sockaddr_t from hostname, address family, and port.
44      * @param hostname The hostname or numeric address string to resolve/parse, or
45      * NULL to build an address that corresponds to 0.0.0.0 or ::
46      * @param family The address family to use, or APR_UNSPEC if the system should
47      * decide.
48      * @param port The port number.
49      * @param flags Special processing flags:
50      * <PRE>
51      * APR_IPV4_ADDR_OK first query for IPv4 addresses; only look
52      * for IPv6 addresses if the first query failed;
53      * only valid if family is APR_UNSPEC and hostname
54      * isn't NULL; mutually exclusive with
55      * APR_IPV6_ADDR_OK
56      * APR_IPV6_ADDR_OK first query for IPv6 addresses; only look
57      * for IPv4 addresses if the first query failed;
58      * only valid if family is APR_UNSPEC and hostname
59      * isn't NULL and APR_HAVE_IPV6; mutually exclusive
60      * with APR_IPV4_ADDR_OK
61      * </PRE>
62      * @param p The pool for the apr_sockaddr_t and associated storage.
63      * @return The new apr_sockaddr_t.
64      */

65     public static native long info(String JavaDoc hostname, int family,
66                                    int port, int flags, long p)
67         throws Exception JavaDoc;
68     /**
69      * Look up the host name from an apr_sockaddr_t.
70      * @param sa The apr_sockaddr_t.
71      * @param flags Special processing flags.
72      * @return The hostname.
73      */

74     public static native String JavaDoc getnameinfo(long sa, int flags);
75
76     /**
77      * Return the IP address (in numeric address string format) in
78      * an APR socket address. APR will allocate storage for the IP address
79      * string from the pool of the apr_sockaddr_t.
80      * @param sa The socket address to reference.
81      * @return The IP address.
82      */

83     public static native String JavaDoc getip(long sa);
84
85     /**
86      * Given an apr_sockaddr_t and a service name, set the port for the service
87      * @param sockaddr The apr_sockaddr_t that will have its port set
88      * @param servname The name of the service you wish to use
89      * @return APR status code.
90      */

91     public static native int getservbyname(long sockaddr, String JavaDoc servname);
92
93     /**
94      * Return an apr_sockaddr_t from an apr_socket_t
95      * @param which Which interface do we want the apr_sockaddr_t for?
96      * @param sock The socket to use
97      * @return The returned apr_sockaddr_t.
98      */

99     public static native long get(int which, long sock)
100         throws Exception JavaDoc;
101
102     /**
103      * See if the IP addresses in two APR socket addresses are
104      * equivalent. Appropriate logic is present for comparing
105      * IPv4-mapped IPv6 addresses with IPv4 addresses.
106      *
107      * @param a One of the APR socket addresses.
108      * @param b The other APR socket address.
109      * The return value will be True if the addresses
110      * are equivalent.
111      */

112     public static native boolean equal(long a, long b);
113
114 }
115
Popular Tags