2022-06-11 21:54:11 +00:00
|
|
|
# Copyright (c) 2022 Fantix King https://fantix.pro
|
2022-04-23 18:35:17 +00:00
|
|
|
# kLoop is licensed under Mulan PSL v2.
|
|
|
|
# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
|
|
|
# You may obtain a copy of Mulan PSL v2 at:
|
|
|
|
# http://license.coscl.org.cn/MulanPSL2
|
|
|
|
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
|
|
|
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
|
|
|
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
|
|
|
# See the Mulan PSL v2 for more details.
|
|
|
|
|
|
|
|
|
2022-03-20 22:57:16 +00:00
|
|
|
cdef extern from "sys/syscall.h" nogil:
|
|
|
|
int SYS_io_uring_setup
|
|
|
|
int SYS_io_uring_enter
|
|
|
|
int SYS_io_uring_register
|
|
|
|
|
|
|
|
cdef extern from "unistd.h" nogil:
|
|
|
|
int syscall(int number, ...)
|
|
|
|
|
|
|
|
cdef extern from "signal.h" nogil:
|
|
|
|
int _NSIG
|
|
|
|
|
|
|
|
cdef extern from "sys/socket.h" nogil:
|
2022-05-08 13:55:41 +00:00
|
|
|
enum:
|
|
|
|
SOCK_DGRAM
|
|
|
|
SOCK_STREAM
|
|
|
|
|
2022-03-20 22:57:16 +00:00
|
|
|
ctypedef int socklen_t
|
2022-05-08 13:55:41 +00:00
|
|
|
ctypedef int sa_family_t
|
|
|
|
ctypedef int in_port_t
|
2022-03-20 22:57:16 +00:00
|
|
|
|
2022-05-08 13:55:41 +00:00
|
|
|
int SOL_TLS
|
2022-03-20 22:57:16 +00:00
|
|
|
|
2022-05-08 13:55:41 +00:00
|
|
|
struct sockaddr:
|
|
|
|
sa_family_t sa_family
|
2022-03-20 22:57:16 +00:00
|
|
|
|
|
|
|
struct msghdr:
|
2022-05-08 13:55:41 +00:00
|
|
|
void* msg_name # Optional address
|
|
|
|
socklen_t msg_namelen # Size of address
|
2022-03-20 22:57:16 +00:00
|
|
|
iovec* msg_iov # Scatter/gather array
|
|
|
|
size_t msg_iovlen # Number of elements in msg_iov
|
|
|
|
void* msg_control # ancillary data, see below
|
|
|
|
size_t msg_controllen # ancillary data buffer len
|
|
|
|
int msg_flags # flags on received message
|
|
|
|
|
2022-04-19 22:32:40 +00:00
|
|
|
struct cmsghdr:
|
|
|
|
socklen_t cmsg_len # data byte count, including header
|
|
|
|
int cmsg_level # originating protocol
|
|
|
|
int cmsg_type # protocol-specific type
|
|
|
|
|
|
|
|
size_t CMSG_LEN(size_t length)
|
|
|
|
cmsghdr* CMSG_FIRSTHDR(msghdr* msgh)
|
|
|
|
unsigned char* CMSG_DATA(cmsghdr* cmsg)
|
|
|
|
size_t CMSG_SPACE(size_t length)
|
|
|
|
|
2022-04-25 12:02:28 +00:00
|
|
|
int socket(int domain, int type, int protocol)
|
|
|
|
int setsockopt(
|
|
|
|
int socket,
|
|
|
|
int level,
|
|
|
|
int option_name,
|
|
|
|
const void* option_value,
|
|
|
|
socklen_t option_len,
|
|
|
|
)
|
2022-05-08 13:55:41 +00:00
|
|
|
int bind(int sockfd, const sockaddr* addr, socklen_t addrlen)
|
2022-04-25 12:02:28 +00:00
|
|
|
|
2022-03-20 22:57:16 +00:00
|
|
|
|
|
|
|
cdef extern from "arpa/inet.h" nogil:
|
|
|
|
int inet_pton(int af, char* src, void* dst)
|
|
|
|
int htons(short p)
|
|
|
|
|
|
|
|
cdef extern from "sys/uio.h" nogil:
|
|
|
|
struct iovec:
|
|
|
|
void* iov_base
|
|
|
|
size_t iov_len
|
2022-05-08 13:55:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
cdef extern from "<errno.h>" nogil:
|
|
|
|
enum:
|
|
|
|
ECANCELED
|