Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/java.base/share/native/libnio/ch/NativeSocketAddress.c
41153 views
1
/*
2
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
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
7
* published by the Free Software Foundation. Oracle designates this
8
* particular file as subject to the "Classpath" exception as provided
9
* by Oracle in the LICENSE file that accompanied this code.
10
*
11
* This code is distributed in the hope that it will be useful, but WITHOUT
12
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14
* version 2 for more details (a copy is included in the LICENSE file that
15
* accompanied this code).
16
*
17
* You should have received a copy of the GNU General Public License version
18
* 2 along with this work; if not, write to the Free Software Foundation,
19
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20
*
21
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22
* or visit www.oracle.com if you need additional information or have any
23
* questions.
24
*/
25
26
#include "jni.h"
27
#include "net_util.h"
28
29
#include "sun_nio_ch_NativeSocketAddress.h"
30
31
JNIEXPORT jint JNICALL
32
Java_sun_nio_ch_NativeSocketAddress_AFINET(JNIEnv* env, jclass clazz)
33
{
34
return AF_INET;
35
}
36
37
JNIEXPORT jint JNICALL
38
Java_sun_nio_ch_NativeSocketAddress_AFINET6(JNIEnv* env, jclass clazz)
39
{
40
return AF_INET6;
41
}
42
43
JNIEXPORT jint JNICALL
44
Java_sun_nio_ch_NativeSocketAddress_sizeofSockAddr4(JNIEnv* env, jclass clazz)
45
{
46
return sizeof(struct sockaddr_in);
47
}
48
49
JNIEXPORT jint JNICALL
50
Java_sun_nio_ch_NativeSocketAddress_sizeofSockAddr6(JNIEnv* env, jclass clazz)
51
{
52
return sizeof(struct sockaddr_in6);
53
}
54
55
JNIEXPORT jint JNICALL
56
Java_sun_nio_ch_NativeSocketAddress_sizeofFamily(JNIEnv* env, jclass clazz)
57
{
58
// sizeof(struct sockaddr, sa_family)
59
return sizeof(((struct sockaddr *)0)->sa_family);
60
}
61
62
JNIEXPORT jint JNICALL
63
Java_sun_nio_ch_NativeSocketAddress_offsetFamily(JNIEnv* env, jclass clazz)
64
{
65
return offsetof(struct sockaddr, sa_family);
66
}
67
68
JNIEXPORT jint JNICALL
69
Java_sun_nio_ch_NativeSocketAddress_offsetSin4Port(JNIEnv* env, jclass clazz)
70
{
71
return offsetof(struct sockaddr_in, sin_port);
72
}
73
74
JNIEXPORT jint JNICALL
75
Java_sun_nio_ch_NativeSocketAddress_offsetSin4Addr(JNIEnv* env, jclass clazz)
76
{
77
return offsetof(struct sockaddr_in, sin_addr);
78
}
79
80
JNIEXPORT jint JNICALL
81
Java_sun_nio_ch_NativeSocketAddress_offsetSin6Port(JNIEnv* env, jclass clazz)
82
{
83
return offsetof(struct sockaddr_in6, sin6_port);
84
}
85
86
JNIEXPORT jint JNICALL
87
Java_sun_nio_ch_NativeSocketAddress_offsetSin6Addr(JNIEnv* env, jclass clazz)
88
{
89
return offsetof(struct sockaddr_in6, sin6_addr);
90
}
91
92
JNIEXPORT jint JNICALL
93
Java_sun_nio_ch_NativeSocketAddress_offsetSin6ScopeId(JNIEnv* env, jclass clazz)
94
{
95
return offsetof(struct sockaddr_in6, sin6_scope_id);
96
}
97
98
JNIEXPORT jint JNICALL
99
Java_sun_nio_ch_NativeSocketAddress_offsetSin6FlowInfo(JNIEnv* env, jclass clazz)
100
{
101
return offsetof(struct sockaddr_in6, sin6_flowinfo);
102
}
103
104