Skip to content

Commit

Permalink
8318006: remove unused net related coding
Browse files Browse the repository at this point in the history
Reviewed-by: alanb, lucy
  • Loading branch information
MBaesken committed Oct 13, 2023
1 parent 4d90420 commit 126f2ac
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 141 deletions.
6 changes: 0 additions & 6 deletions src/java.base/share/native/libnet/net_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,6 @@ NET_SetSockOpt(int fd, int level, int opt, const void *arg, int len);
JNIEXPORT int JNICALL
NET_Bind(int fd, SOCKETADDRESS *sa, int len);

JNIEXPORT int JNICALL
NET_MapSocketOption(jint cmd, int *level, int *optname);

JNIEXPORT int JNICALL
NET_MapSocketOptionV6(jint cmd, int *level, int *optname);

JNIEXPORT jint JNICALL
NET_EnableFastTcpLoopback(int fd);

Expand Down
66 changes: 0 additions & 66 deletions src/java.base/unix/native/libnet/net_util_md.c
Original file line number Diff line number Diff line change
Expand Up @@ -314,72 +314,6 @@ int NET_IsZeroAddr(jbyte* caddr) {
return 1;
}

/*
* Map the Java level socket option to the platform specific
* level and option name.
*/
int
NET_MapSocketOption(jint cmd, int *level, int *optname) {
static struct {
jint cmd;
int level;
int optname;
} const opts[] = {
{ java_net_SocketOptions_TCP_NODELAY, IPPROTO_TCP, TCP_NODELAY },
{ java_net_SocketOptions_SO_OOBINLINE, SOL_SOCKET, SO_OOBINLINE },
{ java_net_SocketOptions_SO_LINGER, SOL_SOCKET, SO_LINGER },
{ java_net_SocketOptions_SO_SNDBUF, SOL_SOCKET, SO_SNDBUF },
{ java_net_SocketOptions_SO_RCVBUF, SOL_SOCKET, SO_RCVBUF },
{ java_net_SocketOptions_SO_KEEPALIVE, SOL_SOCKET, SO_KEEPALIVE },
{ java_net_SocketOptions_SO_REUSEADDR, SOL_SOCKET, SO_REUSEADDR },
{ java_net_SocketOptions_SO_REUSEPORT, SOL_SOCKET, SO_REUSEPORT },
{ java_net_SocketOptions_SO_BROADCAST, SOL_SOCKET, SO_BROADCAST },
{ java_net_SocketOptions_IP_TOS, IPPROTO_IP, IP_TOS },
{ java_net_SocketOptions_IP_MULTICAST_IF, IPPROTO_IP, IP_MULTICAST_IF },
{ java_net_SocketOptions_IP_MULTICAST_IF2, IPPROTO_IP, IP_MULTICAST_IF },
{ java_net_SocketOptions_IP_MULTICAST_LOOP, IPPROTO_IP, IP_MULTICAST_LOOP },
};

int i;

if (ipv6_available()) {
switch (cmd) {
// Different multicast options if IPv6 is enabled
case java_net_SocketOptions_IP_MULTICAST_IF:
case java_net_SocketOptions_IP_MULTICAST_IF2:
*level = IPPROTO_IPV6;
*optname = IPV6_MULTICAST_IF;
return 0;

case java_net_SocketOptions_IP_MULTICAST_LOOP:
*level = IPPROTO_IPV6;
*optname = IPV6_MULTICAST_LOOP;
return 0;
#if defined(MACOSX)
// Map IP_TOS request to IPV6_TCLASS
case java_net_SocketOptions_IP_TOS:
*level = IPPROTO_IPV6;
*optname = IPV6_TCLASS;
return 0;
#endif
}
}

/*
* Map the Java level option to the native level
*/
for (i=0; i<(int)(sizeof(opts) / sizeof(opts[0])); i++) {
if (cmd == opts[i].cmd) {
*level = opts[i].level;
*optname = opts[i].optname;
return 0;
}
}

/* not found */
return -1;
}

/*
* Wrapper for getsockopt system routine - does any necessary
* pre/post processing to deal with OS specific oddities :-
Expand Down
69 changes: 0 additions & 69 deletions src/java.base/windows/native/libnet/net_util_md.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,75 +225,6 @@ jint reuseport_supported(int ipv6_available)
return JNI_FALSE;
}

/* call NET_MapSocketOptionV6 for the IPv6 fd only
* and NET_MapSocketOption for the IPv4 fd
*/
JNIEXPORT int JNICALL
NET_MapSocketOptionV6(jint cmd, int *level, int *optname) {

switch (cmd) {
case java_net_SocketOptions_IP_MULTICAST_IF:
case java_net_SocketOptions_IP_MULTICAST_IF2:
*level = IPPROTO_IPV6;
*optname = IPV6_MULTICAST_IF;
return 0;

case java_net_SocketOptions_IP_MULTICAST_LOOP:
*level = IPPROTO_IPV6;
*optname = IPV6_MULTICAST_LOOP;
return 0;
}
return NET_MapSocketOption (cmd, level, optname);
}

/*
* Map the Java level socket option to the platform specific
* level and option name.
*/

JNIEXPORT int JNICALL
NET_MapSocketOption(jint cmd, int *level, int *optname) {

typedef struct {
jint cmd;
int level;
int optname;
} sockopts;

static sockopts opts[] = {
{ java_net_SocketOptions_TCP_NODELAY, IPPROTO_TCP, TCP_NODELAY },
{ java_net_SocketOptions_SO_OOBINLINE, SOL_SOCKET, SO_OOBINLINE },
{ java_net_SocketOptions_SO_LINGER, SOL_SOCKET, SO_LINGER },
{ java_net_SocketOptions_SO_SNDBUF, SOL_SOCKET, SO_SNDBUF },
{ java_net_SocketOptions_SO_RCVBUF, SOL_SOCKET, SO_RCVBUF },
{ java_net_SocketOptions_SO_KEEPALIVE, SOL_SOCKET, SO_KEEPALIVE },
{ java_net_SocketOptions_SO_REUSEADDR, SOL_SOCKET, SO_REUSEADDR },
{ java_net_SocketOptions_SO_BROADCAST, SOL_SOCKET, SO_BROADCAST },
{ java_net_SocketOptions_IP_MULTICAST_IF, IPPROTO_IP, IP_MULTICAST_IF },
{ java_net_SocketOptions_IP_MULTICAST_LOOP, IPPROTO_IP, IP_MULTICAST_LOOP },
{ java_net_SocketOptions_IP_TOS, IPPROTO_IP, IP_TOS },

};


int i;

/*
* Map the Java level option to the native level
*/
for (i=0; i<(int)(sizeof(opts) / sizeof(opts[0])); i++) {
if (cmd == opts[i].cmd) {
*level = opts[i].level;
*optname = opts[i].optname;
return 0;
}
}

/* not found */
return -1;
}


/*
* Wrapper for setsockopt dealing with Windows specific issues :-
*
Expand Down

1 comment on commit 126f2ac

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.