1 /* |
1 /* |
2 * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
80 |
80 |
81 return remote_port; |
81 return remote_port; |
82 } |
82 } |
83 |
83 |
84 JNIEXPORT jint JNICALL |
84 JNIEXPORT jint JNICALL |
|
85 Java_sun_nio_ch_InheritedChannel_addressFamily(JNIEnv *env, jclass cla, jint fd) |
|
86 { |
|
87 SOCKETADDRESS addr; |
|
88 socklen_t addrlen = sizeof(addr); |
|
89 |
|
90 if (getsockname(fd, (struct sockaddr *)&addr, &addrlen) < 0) { |
|
91 return sun_nio_ch_InheritedChannel_AF_UNKNOWN; |
|
92 } |
|
93 if (addr.sa.sa_family == AF_INET) { |
|
94 return sun_nio_ch_InheritedChannel_AF_INET; |
|
95 } |
|
96 if (addr.sa.sa_family == AF_INET6) { |
|
97 return sun_nio_ch_InheritedChannel_AF_INET6; |
|
98 } |
|
99 if (addr.sa.sa_family == AF_UNIX) { |
|
100 return sun_nio_ch_InheritedChannel_AF_UNIX; |
|
101 } |
|
102 return sun_nio_ch_InheritedChannel_AF_UNKNOWN; |
|
103 } |
|
104 |
|
105 JNIEXPORT jboolean JNICALL |
|
106 Java_sun_nio_ch_InheritedChannel_isConnected(JNIEnv *env, jclass cla, jint fd) |
|
107 { |
|
108 SOCKETADDRESS addr; |
|
109 socklen_t addrlen = sizeof(addr); |
|
110 |
|
111 if (getpeername(fd, (struct sockaddr *)&addr, &addrlen) < 0) { |
|
112 return JNI_FALSE; |
|
113 } |
|
114 return JNI_TRUE; |
|
115 } |
|
116 |
|
117 JNIEXPORT jint JNICALL |
85 Java_sun_nio_ch_InheritedChannel_soType0(JNIEnv *env, jclass cla, jint fd) |
118 Java_sun_nio_ch_InheritedChannel_soType0(JNIEnv *env, jclass cla, jint fd) |
86 { |
119 { |
87 int sotype; |
120 int sotype; |
88 socklen_t arglen = sizeof(sotype); |
121 socklen_t arglen = sizeof(sotype); |
89 if (getsockopt(fd, SOL_SOCKET, SO_TYPE, (void *)&sotype, &arglen) == 0) { |
122 if (getsockopt(fd, SOL_SOCKET, SO_TYPE, (void *)&sotype, &arglen) == 0) { |