Print this page
Split |
Close |
Expand all |
Collapse all |
--- old/src/share/native/java/net/net_util.h
+++ new/src/share/native/java/net/net_util.h
1 1 /*
2 2 * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 4 *
5 5 * This code is free software; you can redistribute it and/or modify it
6 6 * under the terms of the GNU General Public License version 2 only, as
7 7 * published by the Free Software Foundation. Sun designates this
8 8 * particular file as subject to the "Classpath" exception as provided
9 9 * by Sun in the LICENSE file that accompanied this code.
10 10 *
11 11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 14 * version 2 for more details (a copy is included in the LICENSE file that
15 15 * accompanied this code).
16 16 *
17 17 * You should have received a copy of the GNU General Public License version
18 18 * 2 along with this work; if not, write to the Free Software Foundation,
19 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 20 *
21 21 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 22 * CA 95054 USA or visit www.sun.com if you need additional information or
23 23 * have any questions.
24 24 */
25 25
26 26 #ifndef NET_UTILS_H
27 27 #define NET_UTILS_H
28 28
29 29 #include "jvm.h"
30 30 #include "jni_util.h"
31 31 #include "net_util_md.h"
32 32
33 33 /************************************************************************
34 34 * Macros and misc constants
35 35 */
36 36
37 37 #define MAX_PACKET_LEN 65536
38 38
39 39 #define IPv4 1
40 40 #define IPv6 2
41 41
42 42 #define NET_ERROR(env, ex, msg) \
43 43 { if (!(*env)->ExceptionOccurred(env)) JNU_ThrowByName(env, ex, msg) }
44 44
45 45 #define CHECK_NULL(x) if ((x) == NULL) return;
46 46 #define CHECK_NULL_RETURN(x, y) if ((x) == NULL) return y;
47 47
48 48 /************************************************************************
↓ open down ↓ |
48 lines elided |
↑ open up ↑ |
49 49 * Cached field IDs
50 50 *
51 51 * The naming convention for field IDs is
52 52 * <class abbrv>_<fieldName>ID
53 53 * i.e. psi_timeoutID is PlainSocketImpl's timeout field's ID.
54 54 */
55 55 extern jclass ia_class;
56 56 extern jfieldID ia_addressID;
57 57 extern jfieldID ia_familyID;
58 58 extern jfieldID ia_preferIPv6AddressID;
59 +extern jfieldID ia_hostNameID;
59 60
60 61 extern jclass ia4_class;
61 62 extern jmethodID ia4_ctrID;
62 63
63 64 /* NetworkInterface fields */
64 65 extern jclass ni_class;
65 66 extern jfieldID ni_nameID;
66 67 extern jfieldID ni_indexID;
67 68 extern jfieldID ni_addrsID;
68 69 extern jfieldID ni_descID;
69 70 extern jmethodID ni_ctrID;
70 71
71 72 /* PlainSocketImpl fields */
72 73 extern jfieldID psi_timeoutID;
73 74 extern jfieldID psi_fdID;
74 75 extern jfieldID psi_addressID;
75 76 extern jfieldID psi_portID;
76 77 extern jfieldID psi_localportID;
77 78
78 79 /* DatagramPacket fields */
79 80 extern jfieldID dp_addressID;
80 81 extern jfieldID dp_portID;
81 82 extern jfieldID dp_bufID;
82 83 extern jfieldID dp_offsetID;
83 84 extern jfieldID dp_lengthID;
84 85 extern jfieldID dp_bufLengthID;
85 86
86 87 /* Inet6Address fields */
87 88 extern jclass ia6_class;
88 89 extern jfieldID ia6_ipaddressID;
↓ open down ↓ |
20 lines elided |
↑ open up ↑ |
89 90 extern jfieldID ia6_scopeidID;
90 91 extern jfieldID ia6_cachedscopeidID;
91 92 extern jfieldID ia6_scopeidsetID;
92 93 extern jfieldID ia6_scopeifnameID;
93 94 extern jfieldID ia6_scopeifnamesetID;
94 95 extern jmethodID ia6_ctrID;
95 96
96 97 /************************************************************************
97 98 * Utilities
98 99 */
100 +void init(JNIEnv *env);
101 +
99 102 JNIEXPORT void JNICALL Java_java_net_InetAddress_init(JNIEnv *env, jclass cls);
100 103 JNIEXPORT void JNICALL Java_java_net_Inet4Address_init(JNIEnv *env, jclass cls);
101 104 JNIEXPORT void JNICALL Java_java_net_Inet6Address_init(JNIEnv *env, jclass cls);
102 105 JNIEXPORT void JNICALL Java_java_net_NetworkInterface_init(JNIEnv *env, jclass cls);
103 106
104 107 JNIEXPORT void JNICALL NET_ThrowNew(JNIEnv *env, int errorNum, char *msg);
105 108 int NET_GetError();
106 109
107 110 void NET_ThrowCurrent(JNIEnv *env, char *msg);
108 111
109 112 jfieldID NET_GetFileDescriptorID(JNIEnv *env);
110 113
111 114 JNIEXPORT jint JNICALL ipv6_available() ;
112 115
113 116 void
114 117 NET_AllocSockaddr(struct sockaddr **him, int *len);
115 118
116 119 JNIEXPORT int JNICALL
117 120 NET_InetAddressToSockaddr(JNIEnv *env, jobject iaObj, int port, struct sockaddr *him, int *len, jboolean v4MappedAddress);
118 121
119 122 JNIEXPORT jobject JNICALL
120 123 NET_SockaddrToInetAddress(JNIEnv *env, struct sockaddr *him, int *port);
121 124
122 125 void initLocalAddrTable ();
123 126
124 127 void
125 128 NET_SetTrafficClass(struct sockaddr *him, int trafficClass);
126 129
127 130 JNIEXPORT jint JNICALL
128 131 NET_GetPortFromSockaddr(struct sockaddr *him);
129 132
130 133 JNIEXPORT jint JNICALL
131 134 NET_SockaddrEqualsInetAddress(JNIEnv *env,struct sockaddr *him, jobject iaObj);
132 135
133 136 int
134 137 NET_IsIPv4Mapped(jbyte* caddr);
135 138
136 139 int
137 140 NET_IPv4MappedToIPv4(jbyte* caddr);
138 141
139 142 int
140 143 NET_IsEqual(jbyte* caddr1, jbyte* caddr2);
141 144
142 145 /* Socket operations
143 146 *
144 147 * These work just like the JVM_* procedures, except that they may do some
145 148 * platform-specific pre/post processing of the arguments and/or results.
146 149 */
147 150
148 151 JNIEXPORT int JNICALL
149 152 NET_GetSockOpt(int fd, int level, int opt, void *result, int *len);
150 153
151 154 JNIEXPORT int JNICALL
152 155 NET_SetSockOpt(int fd, int level, int opt, const void *arg, int len);
153 156
154 157 JNIEXPORT int JNICALL
155 158 NET_Bind(int fd, struct sockaddr *him, int len);
156 159
157 160 JNIEXPORT int JNICALL
158 161 NET_MapSocketOption(jint cmd, int *level, int *optname);
159 162
160 163 JNIEXPORT int JNICALL
161 164 NET_MapSocketOptionV6(jint cmd, int *level, int *optname);
162 165
163 166 int getScopeID (struct sockaddr *);
164 167
165 168 int cmpScopeID (unsigned int, struct sockaddr *);
166 169
167 170 unsigned short in_cksum(unsigned short *addr, int len);
168 171 #endif /* NET_UTILS_H */
↓ open down ↓ |
60 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX