提交 dec04050 编写于 作者: C chegar

6729881: Compiler warning in networking native code

Summary: Cleanup compiler warnings
Reviewed-by: alanb, jccollet, michaelm
上级 c4f0d536
...@@ -201,7 +201,6 @@ Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this, ...@@ -201,7 +201,6 @@ Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
} }
if (hp != NULL) { if (hp != NULL) {
struct in_addr **addrp = (struct in_addr **) hp->h_addr_list; struct in_addr **addrp = (struct in_addr **) hp->h_addr_list;
int len = sizeof(struct in_addr);
int i = 0; int i = 0;
while (*addrp != (struct in_addr *) 0) { while (*addrp != (struct in_addr *) 0) {
......
...@@ -143,7 +143,6 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this, ...@@ -143,7 +143,6 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
const char *hostname; const char *hostname;
jobjectArray ret = 0; jobjectArray ret = 0;
int retLen = 0; int retLen = 0;
jclass byteArrayCls;
jboolean preferIPv6Address; jboolean preferIPv6Address;
int error=0; int error=0;
...@@ -219,7 +218,7 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this, ...@@ -219,7 +218,7 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
} else { } else {
int i = 0; int i = 0;
int inetCount = 0, inet6Count = 0, inetIndex, inet6Index; int inetCount = 0, inet6Count = 0, inetIndex, inet6Index;
struct addrinfo *itr, *last, *iterator = res; struct addrinfo *itr, *last = NULL, *iterator = res;
while (iterator != NULL) { while (iterator != NULL) {
int skip = 0; int skip = 0;
itr = resNew; itr = resNew;
...@@ -393,10 +392,7 @@ Java_java_net_Inet6AddressImpl_getHostByAddr(JNIEnv *env, jobject this, ...@@ -393,10 +392,7 @@ Java_java_net_Inet6AddressImpl_getHostByAddr(JNIEnv *env, jobject this,
#ifdef AF_INET6 #ifdef AF_INET6
char host[NI_MAXHOST+1]; char host[NI_MAXHOST+1];
jfieldID fid;
int error = 0; int error = 0;
jint family;
struct sockaddr *him ;
int len = 0; int len = 0;
jbyte caddr[16]; jbyte caddr[16];
...@@ -459,11 +455,10 @@ static jboolean ...@@ -459,11 +455,10 @@ static jboolean
ping6(JNIEnv *env, jint fd, struct sockaddr_in6* him, jint timeout, ping6(JNIEnv *env, jint fd, struct sockaddr_in6* him, jint timeout,
struct sockaddr_in6* netif, jint ttl) { struct sockaddr_in6* netif, jint ttl) {
jint size; jint size;
jint n, len, hlen1, icmplen; jint n, len;
char sendbuf[1500]; char sendbuf[1500];
unsigned char recvbuf[1500]; unsigned char recvbuf[1500];
struct icmp6_hdr *icmp6; struct icmp6_hdr *icmp6;
struct ip6_hdr *ip6;
struct sockaddr_in6 sa_recv; struct sockaddr_in6 sa_recv;
jbyte *caddr, *recv_caddr; jbyte *caddr, *recv_caddr;
jchar pid; jchar pid;
...@@ -561,7 +556,6 @@ Java_java_net_Inet6AddressImpl_isReachable0(JNIEnv *env, jobject this, ...@@ -561,7 +556,6 @@ Java_java_net_Inet6AddressImpl_isReachable0(JNIEnv *env, jobject this,
jbyteArray ifArray, jbyteArray ifArray,
jint ttl, jint if_scope) { jint ttl, jint if_scope) {
#ifdef AF_INET6 #ifdef AF_INET6
jint addr;
jbyte caddr[16]; jbyte caddr[16];
jint fd, sz; jint fd, sz;
struct sockaddr_in6 him6; struct sockaddr_in6 him6;
......
...@@ -398,7 +398,6 @@ jobject createNetworkInterface(JNIEnv *env, netif *ifs) ...@@ -398,7 +398,6 @@ jobject createNetworkInterface(JNIEnv *env, netif *ifs)
jobjectArray addrArr; jobjectArray addrArr;
jobjectArray bindArr; jobjectArray bindArr;
jobjectArray childArr; jobjectArray childArr;
netaddr *addrs;
jint addr_index, addr_count, bind_index; jint addr_index, addr_count, bind_index;
jint child_count, child_index; jint child_count, child_index;
netaddr *addrP; netaddr *addrP;
...@@ -815,8 +814,6 @@ static netif *enumIPv6Interfaces(JNIEnv *env, netif *ifs) { ...@@ -815,8 +814,6 @@ static netif *enumIPv6Interfaces(JNIEnv *env, netif *ifs) {
addr6p[0], addr6p[1], addr6p[2], addr6p[3], addr6p[0], addr6p[1], addr6p[2], addr6p[3],
addr6p[4], addr6p[5], addr6p[6], addr6p[7], addr6p[4], addr6p[5], addr6p[6], addr6p[7],
&if_idx, &plen, &scope, &dad_status, devname) != EOF) { &if_idx, &plen, &scope, &dad_status, devname) != EOF) {
struct netif *ifs_ptr = NULL;
struct netif *last_ptr = NULL;
struct sockaddr_in6 addr; struct sockaddr_in6 addr;
sprintf(addr6, "%s:%s:%s:%s:%s:%s:%s:%s", sprintf(addr6, "%s:%s:%s:%s:%s:%s:%s:%s",
...@@ -852,7 +849,6 @@ static netif *enumIPv6Interfaces(JNIEnv *env, netif *ifs) { ...@@ -852,7 +849,6 @@ static netif *enumIPv6Interfaces(JNIEnv *env, netif *ifs) {
*/ */
void freeif(netif *ifs) { void freeif(netif *ifs) {
netif *currif = ifs; netif *currif = ifs;
netif *child = NULL;
while (currif != NULL) { while (currif != NULL) {
netaddr *addrP = currif->addr; netaddr *addrP = currif->addr;
...@@ -1158,10 +1154,9 @@ static short getFlags(JNIEnv *env, jstring name) { ...@@ -1158,10 +1154,9 @@ static short getFlags(JNIEnv *env, jstring name) {
*/ */
static struct sockaddr *getBroadcast(JNIEnv *env, const char *ifname) { static struct sockaddr *getBroadcast(JNIEnv *env, const char *ifname) {
int sock; int sock;
unsigned int mask;
struct sockaddr *ret = NULL; struct sockaddr *ret = NULL;
struct ifreq if2; struct ifreq if2;
short flag; short flag = 0;
sock = JVM_Socket(AF_INET, SOCK_DGRAM, 0); sock = JVM_Socket(AF_INET, SOCK_DGRAM, 0);
if (sock < 0) { if (sock < 0) {
......
...@@ -89,7 +89,6 @@ static jfieldID pdsi_ttlID; ...@@ -89,7 +89,6 @@ static jfieldID pdsi_ttlID;
static jobject createInteger(JNIEnv *env, int i) { static jobject createInteger(JNIEnv *env, int i) {
static jclass i_class; static jclass i_class;
static jmethodID i_ctrID; static jmethodID i_ctrID;
static jfieldID i_valueID;
if (i_class == NULL) { if (i_class == NULL) {
jclass c = (*env)->FindClass(env, "java/lang/Integer"); jclass c = (*env)->FindClass(env, "java/lang/Integer");
...@@ -109,7 +108,6 @@ static jobject createInteger(JNIEnv *env, int i) { ...@@ -109,7 +108,6 @@ static jobject createInteger(JNIEnv *env, int i) {
static jobject createBoolean(JNIEnv *env, int b) { static jobject createBoolean(JNIEnv *env, int b) {
static jclass b_class; static jclass b_class;
static jmethodID b_ctrID; static jmethodID b_ctrID;
static jfieldID b_valueID;
if (b_class == NULL) { if (b_class == NULL) {
jclass c = (*env)->FindClass(env, "java/lang/Boolean"); jclass c = (*env)->FindClass(env, "java/lang/Boolean");
...@@ -148,8 +146,6 @@ Java_java_net_PlainDatagramSocketImpl_init(JNIEnv *env, jclass cls) { ...@@ -148,8 +146,6 @@ Java_java_net_PlainDatagramSocketImpl_init(JNIEnv *env, jclass cls) {
#ifdef __linux__ #ifdef __linux__
struct utsname sysinfo; struct utsname sysinfo;
#endif #endif
char *s;
pdsi_fdID = (*env)->GetFieldID(env, cls, "fd", pdsi_fdID = (*env)->GetFieldID(env, cls, "fd",
"Ljava/io/FileDescriptor;"); "Ljava/io/FileDescriptor;");
CHECK_NULL(pdsi_fdID); CHECK_NULL(pdsi_fdID);
...@@ -373,7 +369,7 @@ Java_java_net_PlainDatagramSocketImpl_disconnect0(JNIEnv *env, jobject this, jin ...@@ -373,7 +369,7 @@ Java_java_net_PlainDatagramSocketImpl_disconnect0(JNIEnv *env, jobject this, jin
if (JVM_GetSockName(fd, (struct sockaddr *)&addr, &len) == -1) { if (JVM_GetSockName(fd, (struct sockaddr *)&addr, &len) == -1) {
return; return;
} }
localPort = NET_GetPortFromSockaddr(&addr); localPort = NET_GetPortFromSockaddr((struct sockaddr *)&addr);
if (localPort == 0) { if (localPort == 0) {
localPort = (*env)->GetIntField(env, this, pdsi_localPortID); localPort = (*env)->GetIntField(env, this, pdsi_localPortID);
#ifdef AF_INET6 #ifdef AF_INET6
...@@ -416,7 +412,6 @@ Java_java_net_PlainDatagramSocketImpl_send(JNIEnv *env, jobject this, ...@@ -416,7 +412,6 @@ Java_java_net_PlainDatagramSocketImpl_send(JNIEnv *env, jobject this,
/* The fdObj'fd */ /* The fdObj'fd */
jint fd; jint fd;
ssize_t n = -1;
SOCKADDR rmtaddr, *rmtaddrP=&rmtaddr; SOCKADDR rmtaddr, *rmtaddrP=&rmtaddr;
int len; int len;
...@@ -633,9 +628,7 @@ Java_java_net_PlainDatagramSocketImpl_peekData(JNIEnv *env, jobject this, ...@@ -633,9 +628,7 @@ Java_java_net_PlainDatagramSocketImpl_peekData(JNIEnv *env, jobject this,
jint packetBufferOffset, packetBufferLen; jint packetBufferOffset, packetBufferLen;
int fd; int fd;
jbyteArray data;
int datalen;
int n; int n;
SOCKADDR remote_addr; SOCKADDR remote_addr;
int len; int len;
...@@ -812,9 +805,7 @@ Java_java_net_PlainDatagramSocketImpl_receive0(JNIEnv *env, jobject this, ...@@ -812,9 +805,7 @@ Java_java_net_PlainDatagramSocketImpl_receive0(JNIEnv *env, jobject this,
jint packetBufferOffset, packetBufferLen; jint packetBufferOffset, packetBufferLen;
int fd; int fd;
jbyteArray data;
int datalen;
int n; int n;
SOCKADDR remote_addr; SOCKADDR remote_addr;
int len; int len;
...@@ -1059,7 +1050,6 @@ Java_java_net_PlainDatagramSocketImpl_datagramSocketCreate(JNIEnv *env, ...@@ -1059,7 +1050,6 @@ Java_java_net_PlainDatagramSocketImpl_datagramSocketCreate(JNIEnv *env,
jobject fdObj = (*env)->GetObjectField(env, this, pdsi_fdID); jobject fdObj = (*env)->GetObjectField(env, this, pdsi_fdID);
int fd; int fd;
int arg = -1;
int t = 1; int t = 1;
if (IS_NULL(fdObj)) { if (IS_NULL(fdObj)) {
......
...@@ -136,8 +136,6 @@ static int getFD(JNIEnv *env, jobject this) { ...@@ -136,8 +136,6 @@ static int getFD(JNIEnv *env, jobject this) {
*/ */
JNIEXPORT void JNICALL JNIEXPORT void JNICALL
Java_java_net_PlainSocketImpl_initProto(JNIEnv *env, jclass cls) { Java_java_net_PlainSocketImpl_initProto(JNIEnv *env, jclass cls) {
char *s;
psi_fdID = (*env)->GetFieldID(env, cls , "fd", psi_fdID = (*env)->GetFieldID(env, cls , "fd",
"Ljava/io/FileDescriptor;"); "Ljava/io/FileDescriptor;");
CHECK_NULL(psi_fdID); CHECK_NULL(psi_fdID);
...@@ -183,7 +181,6 @@ Java_java_net_PlainSocketImpl_socketCreate(JNIEnv *env, jobject this, ...@@ -183,7 +181,6 @@ Java_java_net_PlainSocketImpl_socketCreate(JNIEnv *env, jobject this,
jboolean stream) { jboolean stream) {
jobject fdObj, ssObj; jobject fdObj, ssObj;
int fd; int fd;
int arg = -1;
if (socketExceptionCls == NULL) { if (socketExceptionCls == NULL) {
jclass c = (*env)->FindClass(env, "java/net/SocketException"); jclass c = (*env)->FindClass(env, "java/net/SocketException");
...@@ -290,7 +287,6 @@ Java_java_net_PlainSocketImpl_socketConnect(JNIEnv *env, jobject this, ...@@ -290,7 +287,6 @@ Java_java_net_PlainSocketImpl_socketConnect(JNIEnv *env, jobject this,
while (1) { while (1) {
#ifndef USE_SELECT #ifndef USE_SELECT
{ {
fprintf(stdout,"\nNATIVE: fd = %d] ", fd);
struct pollfd pfd; struct pollfd pfd;
pfd.fd = fd; pfd.fd = fd;
pfd.events = POLLOUT; pfd.events = POLLOUT;
...@@ -673,8 +669,6 @@ Java_java_net_PlainSocketImpl_socketAccept(JNIEnv *env, jobject this, ...@@ -673,8 +669,6 @@ Java_java_net_PlainSocketImpl_socketAccept(JNIEnv *env, jobject this,
/* accepted fd */ /* accepted fd */
jint newfd; jint newfd;
jthrowable error;
SOCKADDR him; SOCKADDR him;
int len; int len;
...@@ -1087,7 +1081,6 @@ Java_java_net_PlainSocketImpl_socketGetOption(JNIEnv *env, jobject this, ...@@ -1087,7 +1081,6 @@ Java_java_net_PlainSocketImpl_socketGetOption(JNIEnv *env, jobject this,
JNIEXPORT void JNICALL JNIEXPORT void JNICALL
Java_java_net_PlainSocketImpl_socketSendUrgentData(JNIEnv *env, jobject this, Java_java_net_PlainSocketImpl_socketSendUrgentData(JNIEnv *env, jobject this,
jint data) { jint data) {
char *buf;
/* The fd field */ /* The fd field */
jobject fdObj = (*env)->GetObjectField(env, this, psi_fdID); jobject fdObj = (*env)->GetObjectField(env, this, psi_fdID);
int n, fd; int n, fd;
......
...@@ -65,7 +65,6 @@ Java_java_net_SocketInputStream_socketRead0(JNIEnv *env, jobject this, ...@@ -65,7 +65,6 @@ Java_java_net_SocketInputStream_socketRead0(JNIEnv *env, jobject this,
char BUF[MAX_BUFFER_LEN]; char BUF[MAX_BUFFER_LEN];
char *bufP; char *bufP;
jint fd, nread; jint fd, nread;
jint n;
if (IS_NULL(fdObj)) { if (IS_NULL(fdObj)) {
/* should't this be a NullPointerException? -br */ /* should't this be a NullPointerException? -br */
......
...@@ -67,7 +67,6 @@ Java_java_net_SocketOutputStream_socketWrite0(JNIEnv *env, jobject this, ...@@ -67,7 +67,6 @@ Java_java_net_SocketOutputStream_socketWrite0(JNIEnv *env, jobject this,
char BUF[MAX_BUFFER_LEN]; char BUF[MAX_BUFFER_LEN];
int buflen; int buflen;
int fd; int fd;
jint n = 0;
if (IS_NULL(fdObj)) { if (IS_NULL(fdObj)) {
JNU_ThrowByName(env, "java/net/SocketException", "Socket closed"); JNU_ThrowByName(env, "java/net/SocketException", "Socket closed");
......
...@@ -281,7 +281,7 @@ int NET_ReadV(int s, const struct iovec * vector, int count) { ...@@ -281,7 +281,7 @@ int NET_ReadV(int s, const struct iovec * vector, int count) {
int NET_RecvFrom(int s, void *buf, int len, unsigned int flags, int NET_RecvFrom(int s, void *buf, int len, unsigned int flags,
struct sockaddr *from, int *fromlen) { struct sockaddr *from, int *fromlen) {
BLOCKING_IO_RETURN_INT( s, recvfrom(s, buf, len, flags, from, fromlen) ); BLOCKING_IO_RETURN_INT( s, recvfrom(s, buf, len, flags, from, (socklen_t)fromlen) );
} }
int NET_Send(int s, void *msg, int len, unsigned int flags) { int NET_Send(int s, void *msg, int len, unsigned int flags) {
...@@ -298,7 +298,7 @@ int NET_SendTo(int s, const void *msg, int len, unsigned int ...@@ -298,7 +298,7 @@ int NET_SendTo(int s, const void *msg, int len, unsigned int
} }
int NET_Accept(int s, struct sockaddr *addr, int *addrlen) { int NET_Accept(int s, struct sockaddr *addr, int *addrlen) {
BLOCKING_IO_RETURN_INT( s, accept(s, addr, addrlen) ); BLOCKING_IO_RETURN_INT( s, accept(s, addr, (socklen_t)addrlen) );
} }
int NET_Connect(int s, struct sockaddr *addr, int addrlen) { int NET_Connect(int s, struct sockaddr *addr, int addrlen) {
...@@ -323,7 +323,7 @@ int NET_Select(int s, fd_set *readfds, fd_set *writefds, ...@@ -323,7 +323,7 @@ int NET_Select(int s, fd_set *readfds, fd_set *writefds,
* signal other than our wakeup signal. * signal other than our wakeup signal.
*/ */
int NET_Timeout(int s, long timeout) { int NET_Timeout(int s, long timeout) {
long prevtime,newtime; long prevtime = 0, newtime;
struct timeval t; struct timeval t;
fdEntry_t *fdEntry = getFdEntry(s); fdEntry_t *fdEntry = getFdEntry(s);
......
...@@ -229,7 +229,7 @@ jint IPv6_supported() ...@@ -229,7 +229,7 @@ jint IPv6_supported()
int fd; int fd;
void *ipv6_fn; void *ipv6_fn;
SOCKADDR sa; SOCKADDR sa;
int sa_len = sizeof(sa); socklen_t sa_len = sizeof(sa);
fd = JVM_Socket(AF_INET6, SOCK_STREAM, 0) ; fd = JVM_Socket(AF_INET6, SOCK_STREAM, 0) ;
if (fd < 0) { if (fd < 0) {
...@@ -447,7 +447,6 @@ static void initLoopbackRoutes() { ...@@ -447,7 +447,6 @@ static void initLoopbackRoutes() {
char dest_str[40]; char dest_str[40];
struct in6_addr dest_addr; struct in6_addr dest_addr;
char device[16]; char device[16];
jboolean match = JNI_FALSE;
if (loRoutes != 0) { if (loRoutes != 0) {
free (loRoutes); free (loRoutes);
...@@ -525,7 +524,7 @@ static void initLoopbackRoutes() { ...@@ -525,7 +524,7 @@ static void initLoopbackRoutes() {
{ {
/* now find the scope_id for "lo" */ /* now find the scope_id for "lo" */
char addr6[40], devname[20]; char devname[20];
char addr6p[8][5]; char addr6p[8][5];
int plen, scope, dad_status, if_idx; int plen, scope, dad_status, if_idx;
...@@ -1019,7 +1018,7 @@ int getDefaultIPv6Interface(struct in6_addr *target_addr) { ...@@ -1019,7 +1018,7 @@ int getDefaultIPv6Interface(struct in6_addr *target_addr) {
* index. * index.
*/ */
if (match) { if (match) {
char addr6[40], devname[20]; char devname[20];
char addr6p[8][5]; char addr6p[8][5];
int plen, scope, dad_status, if_idx; int plen, scope, dad_status, if_idx;
...@@ -1086,7 +1085,7 @@ NET_GetSockOpt(int fd, int level, int opt, void *result, ...@@ -1086,7 +1085,7 @@ NET_GetSockOpt(int fd, int level, int opt, void *result,
} }
#endif #endif
rv = getsockopt(fd, level, opt, result, len); rv = getsockopt(fd, level, opt, result, (socklen_t)len);
if (rv < 0) { if (rv < 0) {
return rv; return rv;
} }
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <malloc.h> #include <malloc.h>
#include <sys/types.h> #include <sys/types.h>
#include <process.h>
#include "java_net_InetAddress.h" #include "java_net_InetAddress.h"
#include "java_net_Inet4AddressImpl.h" #include "java_net_Inet4AddressImpl.h"
...@@ -141,7 +142,6 @@ Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this, ...@@ -141,7 +142,6 @@ Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
unsigned int addr[4]; unsigned int addr[4];
jobjectArray ret = NULL; jobjectArray ret = NULL;
jclass byteArrayCls;
if (!initialized) { if (!initialized) {
ni_iacls = (*env)->FindClass(env, "java/net/InetAddress"); ni_iacls = (*env)->FindClass(env, "java/net/InetAddress");
...@@ -315,7 +315,7 @@ ping4(JNIEnv *env, jint fd, struct sockaddr_in* him, jint timeout, ...@@ -315,7 +315,7 @@ ping4(JNIEnv *env, jint fd, struct sockaddr_in* him, jint timeout,
seq = ((unsigned short)rand()) >> 1; seq = ((unsigned short)rand()) >> 1;
/* icmp_id is a 16 bit data type, therefore down cast the pid */ /* icmp_id is a 16 bit data type, therefore down cast the pid */
pid = (u_short) getpid(); pid = (u_short) _getpid();
size = 60*1024; size = 60*1024;
setsockopt(fd, SOL_SOCKET, SO_RCVBUF, (const char *) &size, sizeof(size)); setsockopt(fd, SOL_SOCKET, SO_RCVBUF, (const char *) &size, sizeof(size));
/** /**
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <malloc.h> #include <malloc.h>
#include <sys/types.h> #include <sys/types.h>
#include <process.h>
#include "java_net_InetAddress.h" #include "java_net_InetAddress.h"
#include "java_net_Inet4AddressImpl.h" #include "java_net_Inet4AddressImpl.h"
...@@ -307,10 +308,7 @@ Java_java_net_Inet6AddressImpl_getHostByAddr(JNIEnv *env, jobject this, ...@@ -307,10 +308,7 @@ Java_java_net_Inet6AddressImpl_getHostByAddr(JNIEnv *env, jobject this,
jstring ret = NULL; jstring ret = NULL;
char host[NI_MAXHOST+1]; char host[NI_MAXHOST+1];
jfieldID fid;
int error = 0; int error = 0;
jint family;
struct sockaddr *him ;
int len = 0; int len = 0;
jbyte caddr[16]; jbyte caddr[16];
...@@ -374,7 +372,7 @@ static jboolean ...@@ -374,7 +372,7 @@ static jboolean
ping6(JNIEnv *env, jint fd, struct SOCKADDR_IN6* him, jint timeout, ping6(JNIEnv *env, jint fd, struct SOCKADDR_IN6* him, jint timeout,
struct SOCKADDR_IN6* netif, jint ttl) { struct SOCKADDR_IN6* netif, jint ttl) {
jint size; jint size;
jint n, len, hlen1, icmplen, i; jint n, len, i;
char sendbuf[1500]; char sendbuf[1500];
char auxbuf[1500]; char auxbuf[1500];
unsigned char recvbuf[1500]; unsigned char recvbuf[1500];
...@@ -392,7 +390,7 @@ ping6(JNIEnv *env, jint fd, struct SOCKADDR_IN6* him, jint timeout, ...@@ -392,7 +390,7 @@ ping6(JNIEnv *env, jint fd, struct SOCKADDR_IN6* him, jint timeout,
seq = ((unsigned short)rand()) >> 1; seq = ((unsigned short)rand()) >> 1;
/* icmp_id is a 16 bit data type, therefore down cast the pid */ /* icmp_id is a 16 bit data type, therefore down cast the pid */
pid = (unsigned short) getpid(); pid = (unsigned short) _getpid();
size = 60*1024; size = 60*1024;
setsockopt(fd, SOL_SOCKET, SO_RCVBUF, (const char *)&size, sizeof(size)); setsockopt(fd, SOL_SOCKET, SO_RCVBUF, (const char *)&size, sizeof(size));
...@@ -520,7 +518,6 @@ Java_java_net_Inet6AddressImpl_isReachable0(JNIEnv *env, jobject this, ...@@ -520,7 +518,6 @@ Java_java_net_Inet6AddressImpl_isReachable0(JNIEnv *env, jobject this,
jbyteArray ifArray, jbyteArray ifArray,
jint ttl, jint if_scope) { jint ttl, jint if_scope) {
#ifdef AF_INET6 #ifdef AF_INET6
jint addr;
jbyte caddr[16]; jbyte caddr[16];
jint fd, sz; jint fd, sz;
struct sockaddr_in6 him6; struct sockaddr_in6 him6;
......
...@@ -75,7 +75,6 @@ extern int enumInterfaces_win9x(JNIEnv *, netif **); ...@@ -75,7 +75,6 @@ extern int enumInterfaces_win9x(JNIEnv *, netif **);
extern int enumAddresses_win9x(JNIEnv *, netif *, netaddr **); extern int enumAddresses_win9x(JNIEnv *, netif *, netaddr **);
extern int init_win9x(void); extern int init_win9x(void);
#endif #endif
extern int enumInterfaces_win(JNIEnv *env, netif **netifPP);
/* Windows 95/98/ME running */ /* Windows 95/98/ME running */
...@@ -209,7 +208,6 @@ int enumInterfaces_win(JNIEnv *env, netif **netifPP) ...@@ -209,7 +208,6 @@ int enumInterfaces_win(JNIEnv *env, netif **netifPP)
int count; int count;
netif *netifP; netif *netifP;
DWORD i; DWORD i;
wchar_t wName[128];
int lo=0, eth=0, tr=0, fddi=0, ppp=0, sl=0, net=0; int lo=0, eth=0, tr=0, fddi=0, ppp=0, sl=0, net=0;
/* /*
......
...@@ -87,6 +87,8 @@ extern jfieldID ni_ibaddressID; /* InterfaceAddress.address */ ...@@ -87,6 +87,8 @@ extern jfieldID ni_ibaddressID; /* InterfaceAddress.address */
extern jfieldID ni_ibbroadcastID; /* InterfaceAddress.broadcast */ extern jfieldID ni_ibbroadcastID; /* InterfaceAddress.broadcast */
extern jfieldID ni_ibmaskID; /* InterfaceAddress.maskLength */ extern jfieldID ni_ibmaskID; /* InterfaceAddress.maskLength */
int enumInterfaces_win(JNIEnv *env, netif **netifPP);
/* We have included iphlpapi.h which includes iptypes.h which has the definition /* We have included iphlpapi.h which includes iptypes.h which has the definition
* for MAX_ADAPTER_DESCRIPTION_LENGTH (along with the other definitions in this * for MAX_ADAPTER_DESCRIPTION_LENGTH (along with the other definitions in this
* ifndef block). Therefore if MAX_ADAPTER_DESCRIPTION_LENGTH is defined we can * ifndef block). Therefore if MAX_ADAPTER_DESCRIPTION_LENGTH is defined we can
...@@ -379,6 +381,9 @@ typedef struct { ...@@ -379,6 +381,9 @@ typedef struct {
UINT EnableProxy; UINT EnableProxy;
UINT EnableDns; UINT EnableDns;
} FIXED_INFO, *PFIXED_INFO; } FIXED_INFO, *PFIXED_INFO;
#pragma warning(pop)
#endif /*!MAX_ADAPTER_DESCRIPTION_LENGTH*/ #endif /*!MAX_ADAPTER_DESCRIPTION_LENGTH*/
#ifndef IP_INTERFACE_NAME_INFO_DEFINED #ifndef IP_INTERFACE_NAME_INFO_DEFINED
...@@ -397,7 +402,6 @@ typedef struct ip_interface_name_info { ...@@ -397,7 +402,6 @@ typedef struct ip_interface_name_info {
#endif #endif
#pragma warning(pop)
/* from ipifcons.h */ /* from ipifcons.h */
......
...@@ -417,8 +417,8 @@ static int getAdapters(JNIEnv *env, adapter **adapterPP) ...@@ -417,8 +417,8 @@ static int getAdapters(JNIEnv *env, adapter **adapterPP)
return -1; return -1;
} }
curr->index = ++adapterCount; curr->index = ++adapterCount;
curr->name = strdup("lo"); curr->name = _strdup("lo");
curr->displayName = strdup("TCP Loopback interface"); curr->displayName = _strdup("TCP Loopback interface");
curr->next = adapterP; curr->next = adapterP;
*adapterPP = curr; *adapterPP = curr;
...@@ -513,12 +513,11 @@ static int getStaticAddresses(JNIEnv *env, char *reg_key, netaddr **netaddrPP) ...@@ -513,12 +513,11 @@ static int getStaticAddresses(JNIEnv *env, char *reg_key, netaddr **netaddrPP)
HKEY enumKey, bindingKey; HKEY enumKey, bindingKey;
DWORD dwLen; DWORD dwLen;
ULONG ulType; ULONG ulType;
TCHAR driver[MAX_STR_LEN];
char addresses[MAX_STR_LEN]; char addresses[MAX_STR_LEN];
unsigned long addr; /* IPv4 address */ unsigned long addr; /* IPv4 address */
unsigned char byte; unsigned char byte;
netaddr *netaddrP, *curr; netaddr *netaddrP, *curr;
int i, addrCount, if_count; int i, addrCount;
/* /*
* Open the HKEY_LOCAL_MACHINE\Enum\%s\%s\%s key * Open the HKEY_LOCAL_MACHINE\Enum\%s\%s\%s key
...@@ -1055,8 +1054,8 @@ int enumInterfaces_win9x(JNIEnv *env, netif **netifPP) { ...@@ -1055,8 +1054,8 @@ int enumInterfaces_win9x(JNIEnv *env, netif **netifPP) {
return -1; return -1;
} }
ifs->name = strdup(adapterP->name); ifs->name = _strdup(adapterP->name);
ifs->displayName = strdup(adapterP->displayName); ifs->displayName = _strdup(adapterP->displayName);
ifs->dwIndex = adapterP->index; ifs->dwIndex = adapterP->index;
ifs->index = adapterP->index; ifs->index = adapterP->index;
ifs->next = netifP; ifs->next = netifP;
......
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
*/ */
extern int enumAddresses_win(JNIEnv *env, netif *netifP, netaddr **netaddrPP); extern int enumAddresses_win(JNIEnv *env, netif *netifP, netaddr **netaddrPP);
int getAddrsFromAdapter(IP_ADAPTER_ADDRESSES *ptr, netaddr **netaddrPP);
/* IP helper library routines */ /* IP helper library routines */
int (PASCAL FAR *GetIpAddrTable_fn)(); int (PASCAL FAR *GetIpAddrTable_fn)();
...@@ -168,11 +169,10 @@ static int ipinflen = 2048; ...@@ -168,11 +169,10 @@ static int ipinflen = 2048;
*/ */
int getAllInterfacesAndAddresses (JNIEnv *env, netif **netifPP) int getAllInterfacesAndAddresses (JNIEnv *env, netif **netifPP)
{ {
DWORD ret, numInterfaces; DWORD ret;
IP_ADAPTER_ADDRESSES *ptr, *ptr1, *adapters=0; IP_ADAPTER_ADDRESSES *ptr, *adapters=0;
ULONG len=ipinflen, count=0; ULONG len=ipinflen, count=0;
netif *nif=0, *dup_nif, *last=0, *loopif=0; netif *nif=0, *dup_nif, *last=0, *loopif=0;
netaddr *addr, *addr1;
int tun=0, net=0; int tun=0, net=0;
*netifPP = 0; *netifPP = 0;
...@@ -330,7 +330,7 @@ err: ...@@ -330,7 +330,7 @@ err:
static int getAddrsFromAdapter(IP_ADAPTER_ADDRESSES *ptr, netaddr **netaddrPP) { static int getAddrsFromAdapter(IP_ADAPTER_ADDRESSES *ptr, netaddr **netaddrPP) {
LPSOCKADDR sock; LPSOCKADDR sock;
int ret, count = 0; int count = 0;
netaddr *curr, *start=0, *prev=0; netaddr *curr, *start=0, *prev=0;
PIP_ADAPTER_UNICAST_ADDRESS uni_addr; PIP_ADAPTER_UNICAST_ADDRESS uni_addr;
PIP_ADAPTER_ANYCAST_ADDRESS any_addr; PIP_ADAPTER_ANYCAST_ADDRESS any_addr;
...@@ -364,7 +364,7 @@ static int getAddrsFromAdapter(IP_ADAPTER_ADDRESSES *ptr, netaddr **netaddrPP) { ...@@ -364,7 +364,7 @@ static int getAddrsFromAdapter(IP_ADAPTER_ADDRESSES *ptr, netaddr **netaddrPP) {
sock = uni_addr->Address.lpSockaddr; sock = uni_addr->Address.lpSockaddr;
SOCKETADDRESS_COPY (&curr->addr, sock); SOCKETADDRESS_COPY (&curr->addr, sock);
if (prefix != NULL) { if (prefix != NULL) {
curr->mask = prefix->PrefixLength; curr->mask = (short)prefix->PrefixLength;
if (sock->sa_family == AF_INET) { if (sock->sa_family == AF_INET) {
sock = prefix->Address.lpSockaddr; sock = prefix->Address.lpSockaddr;
SOCKETADDRESS_COPY(&curr->brdcast, sock); SOCKETADDRESS_COPY(&curr->brdcast, sock);
......
...@@ -64,7 +64,6 @@ Java_java_net_SocketOutputStream_socketWrite0(JNIEnv *env, jobject this, ...@@ -64,7 +64,6 @@ Java_java_net_SocketOutputStream_socketWrite0(JNIEnv *env, jobject this,
char BUF[MAX_BUFFER_LEN]; char BUF[MAX_BUFFER_LEN];
int buflen; int buflen;
int fd; int fd;
jint n;
if (IS_NULL(fdObj)) { if (IS_NULL(fdObj)) {
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed"); JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed");
......
...@@ -651,7 +651,6 @@ Java_java_net_TwoStacksPlainDatagramSocketImpl_send(JNIEnv *env, jobject this, ...@@ -651,7 +651,6 @@ Java_java_net_TwoStacksPlainDatagramSocketImpl_send(JNIEnv *env, jobject this,
SOCKETADDRESS rmtaddr; SOCKETADDRESS rmtaddr;
SOCKETADDRESS *addrp = &rmtaddr; SOCKETADDRESS *addrp = &rmtaddr;
int addrlen; int addrlen;
int x; /* DELETE ME */
if (IS_NULL(packet)) { if (IS_NULL(packet)) {
...@@ -883,7 +882,7 @@ Java_java_net_TwoStacksPlainDatagramSocketImpl_peek(JNIEnv *env, jobject this, ...@@ -883,7 +882,7 @@ Java_java_net_TwoStacksPlainDatagramSocketImpl_peek(JNIEnv *env, jobject this,
*/ */
if (timeout) { if (timeout) {
jlong newTime = JVM_CurrentTimeMillis(env, 0); jlong newTime = JVM_CurrentTimeMillis(env, 0);
timeout -= (newTime - prevTime); timeout -= (jint)(newTime - prevTime);
if (timeout <= 0) { if (timeout <= 0) {
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketTimeoutException", JNU_ThrowByName(env, JNU_JAVANETPKG "SocketTimeoutException",
"Receive timed out"); "Receive timed out");
...@@ -929,9 +928,8 @@ Java_java_net_TwoStacksPlainDatagramSocketImpl_peekData(JNIEnv *env, jobject thi ...@@ -929,9 +928,8 @@ Java_java_net_TwoStacksPlainDatagramSocketImpl_peekData(JNIEnv *env, jobject thi
int fd, fd1, fduse, nsockets=0, errorCode; int fd, fd1, fduse, nsockets=0, errorCode;
int port; int port;
jbyteArray data;
int checkBoth = 0, datalen; int checkBoth = 0;
int n; int n;
SOCKETADDRESS remote_addr; SOCKETADDRESS remote_addr;
jint remote_addrsize=sizeof(remote_addr); jint remote_addrsize=sizeof(remote_addr);
...@@ -1101,7 +1099,7 @@ Java_java_net_TwoStacksPlainDatagramSocketImpl_peekData(JNIEnv *env, jobject thi ...@@ -1101,7 +1099,7 @@ Java_java_net_TwoStacksPlainDatagramSocketImpl_peekData(JNIEnv *env, jobject thi
*/ */
if (timeout) { if (timeout) {
jlong newTime = JVM_CurrentTimeMillis(env, 0); jlong newTime = JVM_CurrentTimeMillis(env, 0);
timeout -= (newTime - prevTime); timeout -= (jint)(newTime - prevTime);
if (timeout <= 0) { if (timeout <= 0) {
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketTimeoutException", JNU_ThrowByName(env, JNU_JAVANETPKG "SocketTimeoutException",
"Receive timed out"); "Receive timed out");
...@@ -1203,9 +1201,7 @@ Java_java_net_TwoStacksPlainDatagramSocketImpl_receive0(JNIEnv *env, jobject thi ...@@ -1203,9 +1201,7 @@ Java_java_net_TwoStacksPlainDatagramSocketImpl_receive0(JNIEnv *env, jobject thi
* must be called prior to receive() so that fduse can be set. * must be called prior to receive() so that fduse can be set.
*/ */
int fd, fd1, fduse, errorCode; int fd, fd1, fduse, errorCode;
jbyteArray data;
int datalen;
int n, nsockets=0; int n, nsockets=0;
SOCKETADDRESS remote_addr; SOCKETADDRESS remote_addr;
jint remote_addrsize=sizeof(remote_addr); jint remote_addrsize=sizeof(remote_addr);
...@@ -1376,7 +1372,7 @@ Java_java_net_TwoStacksPlainDatagramSocketImpl_receive0(JNIEnv *env, jobject thi ...@@ -1376,7 +1372,7 @@ Java_java_net_TwoStacksPlainDatagramSocketImpl_receive0(JNIEnv *env, jobject thi
if (timeout) { if (timeout) {
int ret; int ret;
jlong newTime = JVM_CurrentTimeMillis(env, 0); jlong newTime = JVM_CurrentTimeMillis(env, 0);
timeout -= (newTime - prevTime); timeout -= (jint)(newTime - prevTime);
prevTime = newTime; prevTime = newTime;
if (timeout <= 0) { if (timeout <= 0) {
......
...@@ -966,7 +966,8 @@ Java_java_net_TwoStacksPlainSocketImpl_socketSetOption(JNIEnv *env, jobject this ...@@ -966,7 +966,8 @@ Java_java_net_TwoStacksPlainSocketImpl_socketSetOption(JNIEnv *env, jobject this
if (on) { if (on) {
optval.ling.l_onoff = 1; optval.ling.l_onoff = 1;
optval.ling.l_linger = (*env)->GetIntField(env, value, fid); optval.ling.l_linger =
(unsigned short)(*env)->GetIntField(env, value, fid);
} else { } else {
optval.ling.l_onoff = 0; optval.ling.l_onoff = 0;
optval.ling.l_linger = 0; optval.ling.l_linger = 0;
......
...@@ -985,7 +985,7 @@ NET_Wait(JNIEnv *env, jint fd, jint flags, jint timeout) ...@@ -985,7 +985,7 @@ NET_Wait(JNIEnv *env, jint fd, jint flags, jint timeout)
read_rv = select(fd+1, &rd, &wr, &ex, &t); read_rv = select(fd+1, &rd, &wr, &ex, &t);
newTime = JVM_CurrentTimeMillis(env, 0); newTime = JVM_CurrentTimeMillis(env, 0);
timeout -= (newTime - prevTime); timeout -= (jint)(newTime - prevTime);
if (timeout <= 0) { if (timeout <= 0) {
return read_rv > 0 ? 0 : -1; return read_rv > 0 ? 0 : -1;
} }
......
...@@ -294,6 +294,15 @@ JNIEXPORT int JNICALL NET_SocketClose(int fd); ...@@ -294,6 +294,15 @@ JNIEXPORT int JNICALL NET_SocketClose(int fd);
JNIEXPORT int JNICALL NET_Timeout(int fd, long timeout); JNIEXPORT int JNICALL NET_Timeout(int fd, long timeout);
int NET_Socket(int domain, int type, int protocol);
void NET_ThrowByNameWithLastError(JNIEnv *env, const char *name,
const char *defaultDetail);
void NET_ThrowSocketException(JNIEnv *env, char* msg);
jboolean NET_addrtransAvailable();
/* /*
* differs from NET_Timeout() as follows: * differs from NET_Timeout() as follows:
* *
......
...@@ -159,7 +159,6 @@ static int loadStaticConfig9x(char *sl, char *ns) { ...@@ -159,7 +159,6 @@ static int loadStaticConfig9x(char *sl, char *ns) {
DWORD dwLen; DWORD dwLen;
ULONG ulType; ULONG ulType;
char result[MAX_STR_LEN]; char result[MAX_STR_LEN];
int index;
int sts = STS_NO_CONFIG; int sts = STS_NO_CONFIG;
ret = RegOpenKeyEx(HKEY_LOCAL_MACHINE, ret = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
...@@ -275,7 +274,7 @@ static int loadConfig95(char *sl, char *ns) { ...@@ -275,7 +274,7 @@ static int loadConfig95(char *sl, char *ns) {
* the DHCP packet - see RFC 2132). * the DHCP packet - see RFC 2132).
*/ */
if (ret == ERROR_SUCCESS) { if (ret == ERROR_SUCCESS) {
int pos = 0; unsigned int pos = 0;
while (pos < dwLen) { while (pos < dwLen) {
int code, len; int code, len;
......
...@@ -40,7 +40,6 @@ ...@@ -40,7 +40,6 @@
#define SECURITY_WIN32 #define SECURITY_WIN32
#include "sspi.h" #include "sspi.h"
#include "issperr.h"
/* /*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册