Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/java.base/unix/native/libnet/net_util_md.h
41119 views
1
/*
2
* Copyright (c) 1997, 2020, 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
#ifndef NET_UTILS_MD_H
27
#define NET_UTILS_MD_H
28
29
#ifdef ANDROID
30
#include <netinet/in.h>
31
#endif
32
#include <netdb.h>
33
#include <poll.h>
34
#include <sys/socket.h>
35
36
/************************************************************************
37
* Macros and constants
38
*/
39
40
#define NET_NSEC_PER_MSEC 1000000
41
#define NET_NSEC_PER_SEC 1000000000
42
#define NET_NSEC_PER_USEC 1000
43
44
/* in case NI_MAXHOST is not defined in netdb.h */
45
#ifndef NI_MAXHOST
46
#define NI_MAXHOST 1025
47
#endif
48
49
/* Defines SO_REUSEPORT */
50
#ifndef SO_REUSEPORT
51
#ifdef __linux__
52
#define SO_REUSEPORT 15
53
#elif defined(AIX) || defined(MACOSX)
54
#define SO_REUSEPORT 0x0200
55
#else
56
#define SO_REUSEPORT 0
57
#endif
58
#endif
59
60
/*
61
* On 64-bit JDKs we use a much larger stack and heap buffer.
62
*/
63
#ifdef _LP64
64
#define MAX_BUFFER_LEN 65536
65
#define MAX_HEAP_BUFFER_LEN 131072
66
#else
67
#define MAX_BUFFER_LEN 8192
68
#define MAX_HEAP_BUFFER_LEN 65536
69
#endif
70
71
typedef union {
72
struct sockaddr sa;
73
struct sockaddr_in sa4;
74
struct sockaddr_in6 sa6;
75
} SOCKETADDRESS;
76
77
/************************************************************************
78
* Functions
79
*/
80
81
int NET_Timeout(JNIEnv *env, int s, long timeout, jlong nanoTimeStamp);
82
int NET_Read(int s, void* buf, size_t len);
83
int NET_NonBlockingRead(int s, void* buf, size_t len);
84
int NET_RecvFrom(int s, void *buf, int len, unsigned int flags,
85
struct sockaddr *from, socklen_t *fromlen);
86
int NET_Send(int s, void *msg, int len, unsigned int flags);
87
int NET_SendTo(int s, const void *msg, int len, unsigned int
88
flags, const struct sockaddr *to, int tolen);
89
int NET_Connect(int s, struct sockaddr *addr, int addrlen);
90
int NET_Accept(int s, struct sockaddr *addr, socklen_t *addrlen);
91
int NET_SocketClose(int s);
92
int NET_Dup2(int oldfd, int newfd);
93
int NET_Poll(struct pollfd *ufds, unsigned int nfds, int timeout);
94
95
void NET_ThrowUnknownHostExceptionWithGaiError(JNIEnv *env,
96
const char* hostname,
97
int gai_error);
98
void NET_ThrowByNameWithLastError(JNIEnv *env, const char *name,
99
const char *defaultDetail);
100
void NET_SetTrafficClass(SOCKETADDRESS *sa, int trafficClass);
101
102
#endif /* NET_UTILS_MD_H */
103
104