Skip to content

Commit 126f2ac

Browse files
committedOct 13, 2023
8318006: remove unused net related coding
Reviewed-by: alanb, lucy
1 parent 4d90420 commit 126f2ac

File tree

3 files changed

+0
-141
lines changed

3 files changed

+0
-141
lines changed
 

‎src/java.base/share/native/libnet/net_util.h

-6
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,6 @@ NET_SetSockOpt(int fd, int level, int opt, const void *arg, int len);
170170
JNIEXPORT int JNICALL
171171
NET_Bind(int fd, SOCKETADDRESS *sa, int len);
172172

173-
JNIEXPORT int JNICALL
174-
NET_MapSocketOption(jint cmd, int *level, int *optname);
175-
176-
JNIEXPORT int JNICALL
177-
NET_MapSocketOptionV6(jint cmd, int *level, int *optname);
178-
179173
JNIEXPORT jint JNICALL
180174
NET_EnableFastTcpLoopback(int fd);
181175

‎src/java.base/unix/native/libnet/net_util_md.c

-66
Original file line numberDiff line numberDiff line change
@@ -314,72 +314,6 @@ int NET_IsZeroAddr(jbyte* caddr) {
314314
return 1;
315315
}
316316

317-
/*
318-
* Map the Java level socket option to the platform specific
319-
* level and option name.
320-
*/
321-
int
322-
NET_MapSocketOption(jint cmd, int *level, int *optname) {
323-
static struct {
324-
jint cmd;
325-
int level;
326-
int optname;
327-
} const opts[] = {
328-
{ java_net_SocketOptions_TCP_NODELAY, IPPROTO_TCP, TCP_NODELAY },
329-
{ java_net_SocketOptions_SO_OOBINLINE, SOL_SOCKET, SO_OOBINLINE },
330-
{ java_net_SocketOptions_SO_LINGER, SOL_SOCKET, SO_LINGER },
331-
{ java_net_SocketOptions_SO_SNDBUF, SOL_SOCKET, SO_SNDBUF },
332-
{ java_net_SocketOptions_SO_RCVBUF, SOL_SOCKET, SO_RCVBUF },
333-
{ java_net_SocketOptions_SO_KEEPALIVE, SOL_SOCKET, SO_KEEPALIVE },
334-
{ java_net_SocketOptions_SO_REUSEADDR, SOL_SOCKET, SO_REUSEADDR },
335-
{ java_net_SocketOptions_SO_REUSEPORT, SOL_SOCKET, SO_REUSEPORT },
336-
{ java_net_SocketOptions_SO_BROADCAST, SOL_SOCKET, SO_BROADCAST },
337-
{ java_net_SocketOptions_IP_TOS, IPPROTO_IP, IP_TOS },
338-
{ java_net_SocketOptions_IP_MULTICAST_IF, IPPROTO_IP, IP_MULTICAST_IF },
339-
{ java_net_SocketOptions_IP_MULTICAST_IF2, IPPROTO_IP, IP_MULTICAST_IF },
340-
{ java_net_SocketOptions_IP_MULTICAST_LOOP, IPPROTO_IP, IP_MULTICAST_LOOP },
341-
};
342-
343-
int i;
344-
345-
if (ipv6_available()) {
346-
switch (cmd) {
347-
// Different multicast options if IPv6 is enabled
348-
case java_net_SocketOptions_IP_MULTICAST_IF:
349-
case java_net_SocketOptions_IP_MULTICAST_IF2:
350-
*level = IPPROTO_IPV6;
351-
*optname = IPV6_MULTICAST_IF;
352-
return 0;
353-
354-
case java_net_SocketOptions_IP_MULTICAST_LOOP:
355-
*level = IPPROTO_IPV6;
356-
*optname = IPV6_MULTICAST_LOOP;
357-
return 0;
358-
#if defined(MACOSX)
359-
// Map IP_TOS request to IPV6_TCLASS
360-
case java_net_SocketOptions_IP_TOS:
361-
*level = IPPROTO_IPV6;
362-
*optname = IPV6_TCLASS;
363-
return 0;
364-
#endif
365-
}
366-
}
367-
368-
/*
369-
* Map the Java level option to the native level
370-
*/
371-
for (i=0; i<(int)(sizeof(opts) / sizeof(opts[0])); i++) {
372-
if (cmd == opts[i].cmd) {
373-
*level = opts[i].level;
374-
*optname = opts[i].optname;
375-
return 0;
376-
}
377-
}
378-
379-
/* not found */
380-
return -1;
381-
}
382-
383317
/*
384318
* Wrapper for getsockopt system routine - does any necessary
385319
* pre/post processing to deal with OS specific oddities :-

‎src/java.base/windows/native/libnet/net_util_md.c

-69
Original file line numberDiff line numberDiff line change
@@ -225,75 +225,6 @@ jint reuseport_supported(int ipv6_available)
225225
return JNI_FALSE;
226226
}
227227

228-
/* call NET_MapSocketOptionV6 for the IPv6 fd only
229-
* and NET_MapSocketOption for the IPv4 fd
230-
*/
231-
JNIEXPORT int JNICALL
232-
NET_MapSocketOptionV6(jint cmd, int *level, int *optname) {
233-
234-
switch (cmd) {
235-
case java_net_SocketOptions_IP_MULTICAST_IF:
236-
case java_net_SocketOptions_IP_MULTICAST_IF2:
237-
*level = IPPROTO_IPV6;
238-
*optname = IPV6_MULTICAST_IF;
239-
return 0;
240-
241-
case java_net_SocketOptions_IP_MULTICAST_LOOP:
242-
*level = IPPROTO_IPV6;
243-
*optname = IPV6_MULTICAST_LOOP;
244-
return 0;
245-
}
246-
return NET_MapSocketOption (cmd, level, optname);
247-
}
248-
249-
/*
250-
* Map the Java level socket option to the platform specific
251-
* level and option name.
252-
*/
253-
254-
JNIEXPORT int JNICALL
255-
NET_MapSocketOption(jint cmd, int *level, int *optname) {
256-
257-
typedef struct {
258-
jint cmd;
259-
int level;
260-
int optname;
261-
} sockopts;
262-
263-
static sockopts opts[] = {
264-
{ java_net_SocketOptions_TCP_NODELAY, IPPROTO_TCP, TCP_NODELAY },
265-
{ java_net_SocketOptions_SO_OOBINLINE, SOL_SOCKET, SO_OOBINLINE },
266-
{ java_net_SocketOptions_SO_LINGER, SOL_SOCKET, SO_LINGER },
267-
{ java_net_SocketOptions_SO_SNDBUF, SOL_SOCKET, SO_SNDBUF },
268-
{ java_net_SocketOptions_SO_RCVBUF, SOL_SOCKET, SO_RCVBUF },
269-
{ java_net_SocketOptions_SO_KEEPALIVE, SOL_SOCKET, SO_KEEPALIVE },
270-
{ java_net_SocketOptions_SO_REUSEADDR, SOL_SOCKET, SO_REUSEADDR },
271-
{ java_net_SocketOptions_SO_BROADCAST, SOL_SOCKET, SO_BROADCAST },
272-
{ java_net_SocketOptions_IP_MULTICAST_IF, IPPROTO_IP, IP_MULTICAST_IF },
273-
{ java_net_SocketOptions_IP_MULTICAST_LOOP, IPPROTO_IP, IP_MULTICAST_LOOP },
274-
{ java_net_SocketOptions_IP_TOS, IPPROTO_IP, IP_TOS },
275-
276-
};
277-
278-
279-
int i;
280-
281-
/*
282-
* Map the Java level option to the native level
283-
*/
284-
for (i=0; i<(int)(sizeof(opts) / sizeof(opts[0])); i++) {
285-
if (cmd == opts[i].cmd) {
286-
*level = opts[i].level;
287-
*optname = opts[i].optname;
288-
return 0;
289-
}
290-
}
291-
292-
/* not found */
293-
return -1;
294-
}
295-
296-
297228
/*
298229
* Wrapper for setsockopt dealing with Windows specific issues :-
299230
*

0 commit comments

Comments
 (0)
Please sign in to comment.