提交 e9e27f21 authored 作者: José Luis Millán's avatar José Luis Millán

Update 'usrsctp' dep

上级 474be61c
......@@ -3,6 +3,7 @@
### 3.6.15 (WIP)
* Avoid SRTP leak by deleting invalid SSRCs after STRP decryption (issue #437, thanks to @penguinol for reporting).
* Update `usrsctp` dep.
### 3.6.14
......
......@@ -41,7 +41,6 @@
'conditions': [
['OS in "linux android"', {
'defines': [
'__Userspace_os_Linux',
'_GNU_SOURCE',
],
}],
......@@ -50,7 +49,6 @@
'HAVE_SA_LEN',
'HAVE_SCONN_LEN',
'__APPLE_USE_RFC_2292',
'__Userspace_os_Darwin',
],
'xcode_settings': {
'WARNING_CFLAGS': [
......@@ -60,18 +58,12 @@
'-Wstrict-prototypes',
],
'OTHER_CFLAGS': [
'-U__APPLE__',
'-Wno-deprecated-declarations',
# atomic_init in user_atomic.h is a static function in a header.
'-Wno-unused-function',
],
}
}],
['OS=="win"', {
'defines': [
'__Userspace_os_Windows'
],
}],
['OS!="win"', {
'defines': [
'NON_WINDOWS_DEFINE'
......
name: Build with CMake
on:
push:
branches: [ master, github-actions ]
pull_request:
branches: [ master ]
jobs:
build:
strategy:
matrix:
platform: [ubuntu-latest, macos-latest, windows-latest]
cmake_build_type: [Debug, RelWithDebInfo]
sctp_invariants: [ON, OFF]
sctp_inet6: [ON, OFF]
sctp_inet: [ON, OFF]
sctp_debug: [ON, OFF]
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v2
with:
path: 'usrsctp_source'
- name: Prepare dirs
shell: bash
run: |
mkdir -p cmake_build
mkdir -p cmake_install
- name: Generate CMake project
shell: bash
run: |
cd cmake_build
cmake -DCMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }} \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \
-Dsctp_debug=${{ matrix.sctp_debug }} \
-Dsctp_invariants=${{ matrix.sctp_invariants }} \
-Dsctp_inet6=${{ matrix.sctp_inet6 }} \
-Dsctp_inet=${{ matrix.sctp_inet }} \
-Dsctp_build_programs=ON \
-Dsctp_build_fuzzer=OFF \
-DCMAKE_INSTALL_PREFIX=${GITHUB_WORKSPACE}/cmake_install \
${GITHUB_WORKSPACE}/usrsctp_source
- name: Build and install project
shell: bash
run: |
cmake --build cmake_build \
--parallel 2 \
--config ${{ matrix.cmake_build_type }} \
--target install \
--clean-first
......@@ -66,7 +66,6 @@ programs/echo_server
programs/echo_server_upcall
programs/ekr_client
programs/ekr_loop
programs/ekr_loop_offload
programs/ekr_loop_upcall
programs/ekr_peer
programs/ekr_server
......
......@@ -970,7 +970,7 @@ SCTP\_DEBUG has to be set as a compile flag.
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#if !defined(__Userspace_os_Windows)
#if !defined(_WIN32)
#include <unistd.h>
#include <sys/socket.h>
#include <netinet/in.h>
......@@ -1098,7 +1098,7 @@ main(int argc, char *argv[])
}
while (1) {
if (use_cb) {
#if defined (__Userspace_os_Windows)
#if defined(_WIN32)
Sleep(1*1000);
#else
sleep(1);
......@@ -1133,7 +1133,7 @@ main(int argc, char *argv[])
}
usrsctp_close(sock);
while (usrsctp_finish() != 0) {
#if defined (__Userspace_os_Windows)
#if defined(_WIN32)
Sleep(1000);
#else
sleep(1);
......@@ -1183,11 +1183,11 @@ main(int argc, char *argv[])
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#if !defined(__Userspace_os_Windows)
#if !defined(_WIN32)
#include <unistd.h>
#endif
#include <sys/types.h>
#if !defined(__Userspace_os_Windows)
#if !defined(_WIN32)
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
......@@ -1242,7 +1242,7 @@ main(int argc, char *argv[])
}
memset((void *)&addr4, 0, sizeof(struct sockaddr_in));
memset((void *)&addr6, 0, sizeof(struct sockaddr_in6));
#if !defined(__Userspace_os_Linux) && !defined(__Userspace_os_Windows)
#if !defined(__linux__) && !defined(_WIN32)
addr4.sin_len = sizeof(struct sockaddr_in);
addr6.sin6_len = sizeof(struct sockaddr_in6);
#endif
......@@ -1271,14 +1271,14 @@ main(int argc, char *argv[])
usrsctp_shutdown(sock, SHUT_WR);
}
while (!done) {
#if defined (__Userspace_os_Windows)
#if defined(_WIN32)
Sleep(1*1000);
#else
sleep(1);
#endif
}
while (usrsctp_finish() != 0) {
#if defined (__Userspace_os_Windows)
#if defined(_WIN32)
Sleep(1000);
#else
sleep(1);
......
# usrsctp
[![Coverity Scan Build Status](https://scan.coverity.com/projects/13430/badge.svg)](https://scan.coverity.com/projects/usrsctp)
![GitHub Actions Build Status (CMake-based build only)](https://github.com/sctplab/usrsctp/workflows/Build%20with%20CMake/badge.svg)
This is a userland SCTP stack supporting FreeBSD, Linux, Mac OS X and Windows.
See [manual](Manual.md) for more information.
......
......@@ -46,11 +46,9 @@ APPCFLAGS=""
case $host_os in
darwin*)
CFLAGS="$CFLAGS -std=c99 -Wno-deprecated-declarations -D__APPLE_USE_RFC_2292"
LIBCFLAGS="$LIBCFLAGS -U__APPLE__ -D__Userspace_os_Darwin"
;;
dragonfly*)
CFLAGS="$CFLAGS -std=c99 -pthread"
LIBCFLAGS="$LIBCFLAGS -U__DragonFly__ -D__Userspace_os_DragonFly"
;;
freebsd*)
CFLAGS="$CFLAGS -std=c99 -pthread"
......@@ -58,19 +56,15 @@ freebsd*)
CFLAGS="$CFLAGS -Wno-unknown-warning-option"
LDFLAGS="$LDFLAGS -Qunused-arguments"
fi
LIBCFLAGS="$LIBCFLAGS -U__FreeBSD__ -D__Userspace_os_FreeBSD"
;;
linux*)
CFLAGS="$CFLAGS -std=c99 -pthread -D_GNU_SOURCE -Wno-address-of-packed-member"
LIBCFLAGS="$LIBCFLAGS -D__Userspace_os_Linux"
;;
netbsd*)
CFLAGS="$CFLAGS -std=c99 -pthread"
LIBCFLAGS="$LIBCFLAGS -U__NetBSD__ -D__Userspace_os_NetBSD"
;;
openbsd*)
CFLAGS="$CFLAGS -std=c99 -pthread"
LIBCFLAGS="$LIBCFLAGS -U__OpenBSD__ -D__Userspace_os_OpenBSD"
;;
solaris*)
CFLAGS="$CFLAGS -D_XPG4_2"
......
......@@ -58,41 +58,20 @@ add_project_arguments([
system = host_machine.system()
if system in ['linux', 'android']
add_project_arguments([
'-D__Userspace_os_Linux',
'-D_GNU_SOURCE',
], language: 'c')
elif system == 'freebsd'
add_project_arguments([
'-D__Userspace_os_FreeBSD',
'-U__FreeBSD__',
] + compiler.get_supported_arguments([
'-Wno-address-of-packed-member',
]), language: 'c')
add_project_arguments(compiler.get_supported_arguments([
'-Wno-address-of-packed-member',
]), language: 'c')
elif system in ['darwin', 'ios']
add_project_arguments([
'-D__Userspace_os_Darwin',
'-D__APPLE_USE_RFC_2292',
] + compiler.get_supported_arguments([
'-Wno-address-of-packed-member',
'-Wno-deprecated-declarations',
]), language: 'c')
elif system == 'dragonfly'
add_project_arguments([
'-D__Userspace_os_DragonFly',
'-U__DragonFly__',
], language: 'c')
elif system == 'netbsd'
add_project_arguments([
'-D__Userspace_os_NetBSD',
'-U__NetBSD__',
], language: 'c')
elif system == 'openbsd'
add_project_arguments([
'-D__Userspace_os_OpenBSD',
'-U__OpenBSD__',
], language: 'c')
elif system == 'windows'
add_project_arguments('-D__Userspace_os_Windows', language: 'c')
dependencies += compiler.find_library('ws2_32', required: true)
dependencies += compiler.find_library('iphlpapi', required: true)
if compiler.get_id() == 'gcc'
......@@ -207,8 +186,7 @@ else
dependencies: dependencies,
include_directories: include_dirs,
install: true,
version: meson.project_version(),
c_args: '-U__APPLE__')
version: meson.project_version())
endif
# Declare dependency
......
......@@ -93,7 +93,6 @@ list(APPEND check_programs
echo_server_upcall.c
ekr_client.c
ekr_loop.c
ekr_loop_offload.c
ekr_loop_upcall.c
ekr_peer.c
ekr_server.c
......
......@@ -47,7 +47,6 @@ EXTRA_DIST = \
ekr_client.c \
ekr_server.c \
ekr_loop.c \
ekr_loop_offload.c \
ekr_loop_upcall.c \
ekr_peer.c \
test_libmgmt.c \
......@@ -72,7 +71,6 @@ noinst_PROGRAMS = \
ekr_client \
ekr_server \
ekr_loop \
ekr_loop_offload \
ekr_loop_upcall \
ekr_peer \
test_libmgmt \
......@@ -114,8 +112,6 @@ ekr_peer_SOURCES = programs_helper.c ekr_peer.c
ekr_peer_LDADD = ../usrsctplib/libusrsctp.la
ekr_loop_SOURCES = programs_helper.c ekr_loop.c
ekr_loop_LDADD = ../usrsctplib/libusrsctp.la
ekr_loop_offload_SOURCES = programs_helper.c ekr_loop_offload.c
ekr_loop_offload_LDADD = ../usrsctplib/libusrsctp.la
ekr_loop_upcall_SOURCES = programs_helper.c ekr_loop_upcall.c
ekr_loop_upcall_LDADD = ../usrsctplib/libusrsctp.la
http_client_SOURCES = programs_helper.c http_client.c
......
......@@ -53,7 +53,6 @@ all: \
ekr_server \
ekr_peer \
ekr_loop \
ekr_loop_offload \
ekr_loop_upcall \
test_libmgmt \
http_client \
......@@ -119,10 +118,6 @@ ekr_loop:
$(CC) $(CFLAGS) $(CVARSDLL) -c ekr_loop.c
link -out:ekr_loop.exe ekr_loop.obj programs_helper.obj $(LINKFLAGS)
ekr_loop_offload:
$(CC) $(CFLAGS) $(CVARSDLL) -c ekr_loop_offload.c
link -out:ekr_loop_offload.exe ekr_loop_offload.obj programs_helper.obj $(LINKFLAGS)
ekr_loop_upcall:
$(CC) $(CFLAGS) $(CVARSDLL) -c ekr_loop_upcall.c
link -out:ekr_loop_upcall.exe ekr_loop_upcall.obj programs_helper.obj $(LINKFLAGS)
......@@ -139,9 +134,9 @@ http_client_upcall:
$(CC) $(CFLAGS) $(CVARSDLL) -c http_client_upcall.c
link -out:http_client_upcall.exe http_client_upcall.obj programs_helper.obj $(LINKFLAGS)
st_client:
$(CC) $(CFLAGS) $(CVARSDLL) -c st_client.c
link -out:st_client.exe st_client.obj programs_helper.obj $(LINKFLAGS)
st_client:
$(CC) $(CFLAGS) $(CVARSDLL) -c st_client.c
link -out:st_client.exe st_client.obj programs_helper.obj $(LINKFLAGS)
clean:
del /F client.exe
......@@ -172,8 +167,6 @@ clean:
del /F ekr_peer.obj
del /F ekr_loop.exe
del /F ekr_loop.obj
del /F ekr_loop_offload.exe
del /F ekr_loop_offload.obj
del /F ekr_loop_upcall.exe
del /F ekr_loop_upcall.obj
del /F test_libmgmt.exe
......
......@@ -96,7 +96,7 @@ receive_cb(struct socket *sock, union sctp_sockstore addr, void *data,
port = ntohs(addr.sconn.sconn_port);
break;
default:
name = NULL;
name = "???";
port = 0;
break;
}
......
......@@ -96,7 +96,7 @@ receive_cb(struct socket *sock, union sctp_sockstore addr, void *data,
port = ntohs(addr.sconn.sconn_port);
break;
default:
name = NULL;
name = "???";
port = 0;
break;
}
......
......@@ -78,7 +78,7 @@ typedef char* caddr_t;
static void handle_upcall(struct socket *sock, void *arg, int flgs)
{
int events = usrsctp_get_events(sock);
ssize_t bytesSent = 0;
ssize_t bytesSent;
char *buf;
if ((events & SCTP_EVENT_READ) && !done) {
......@@ -93,7 +93,7 @@ static void handle_upcall(struct socket *sock, void *arg, int flgs)
memset(&rn, 0, sizeof(struct sctp_recvv_rn));
n = usrsctp_recvv(sock, buf, BUFFERSIZE, (struct sockaddr *) &addr, &len, (void *)&rn,
&infolen, &infotype, &flags);
&infolen, &infotype, &flags);
if (n < 0) {
if (errno == ECONNREFUSED) {
......@@ -103,10 +103,10 @@ static void handle_upcall(struct socket *sock, void *arg, int flgs)
} else {
result = RETVAL_CATCHALL;
}
perror("usrsctp_connect");
perror("usrsctp_recvv");
}
if (n <= 0){
if (n <= 0) {
done = 1;
usrsctp_close(sock);
} else {
......@@ -132,7 +132,7 @@ static void handle_upcall(struct socket *sock, void *arg, int flgs)
perror("usrsctp_sendv");
usrsctp_close(sock);
} else {
printf("%d bytes sent\n", (int)bytesSent);
printf("%zd bytes sent\n", bytesSent);
}
}
}
......@@ -309,9 +309,6 @@ main(int argc, char *argv[])
result = RETVAL_CATCHALL;
}
perror("usrsctp_connect");
usrsctp_close(sock);
goto out;
}
}
......
......@@ -15,7 +15,6 @@ programs = {
'echo_server_upcall': files('echo_server_upcall.c'),
'ekr_client': files('ekr_client.c'),
'ekr_loop': files('ekr_loop.c'),
'ekr_loop_offload': files('ekr_loop_offload.c'),
'ekr_loop_upcall': files('ekr_loop_upcall.c'),
'ekr_peer': files('ekr_peer.c'),
'ekr_server': files('ekr_server.c'),
......
......@@ -73,15 +73,15 @@ handle_notification(union sctp_notification *notif, size_t n);
#endif
void
debug_printf_runtime(void);
debug_printf(const char *format, ...);
void
debug_printf_clean(const char *format, ...);
void
debug_printf_stack(const char *format, ...);
#define debug_printf(...) \
do { \
fprintf(stderr, "[P]"); \
debug_printf_runtime(); \
fprintf(stderr, __VA_ARGS__); \
} while (0)
void
debug_set_target(FILE *fp);
#endif /* __PROGRAMS_HELPER_H__ */
......@@ -105,11 +105,29 @@ struct tsctp_meta {
static void
gettimeofday(struct timeval *tv, void *ignore)
{
struct timeb tb;
ftime(&tb);
tv->tv_sec = (long)tb.time;
tv->tv_usec = tb.millitm * 1000;
FILETIME filetime;
ULARGE_INTEGER ularge;
GetSystemTimeAsFileTime(&filetime);
ularge.LowPart = filetime.dwLowDateTime;
ularge.HighPart = filetime.dwHighDateTime;
/* Change base from Jan 1 1601 00:00:00 to Jan 1 1970 00:00:00 */
#if defined(__MINGW32__)
ularge.QuadPart -= 116444736000000000ULL;
#else
ularge.QuadPart -= 116444736000000000UI64;
#endif
/*
* ularge.QuadPart is now the number of 100-nanosecond intervals
* since Jan 1 1970 00:00:00.
*/
#if defined(__MINGW32__)
tv->tv_sec = (long)(ularge.QuadPart / 10000000ULL);
tv->tv_usec = (long)((ularge.QuadPart % 10000000ULL) / 10ULL);
#else
tv->tv_sec = (long)(ularge.QuadPart / 10000000UI64);
tv->tv_usec = (long)((ularge.QuadPart % 10000000UI64) / 10UI64);
#endif
}
#endif
......@@ -190,7 +208,7 @@ handle_accept(struct socket *upcall_socket, void *upcall_data, int upcall_flags)
meta_accepted->par_role = meta_listening->par_role;
meta_accepted->par_stats_human = meta_listening->par_stats_human;
meta_accepted->buffer = malloc(BUFFERSIZE);
if (!meta_accepted->buffer) {
printf("malloc() failed!\n");
exit(EXIT_FAILURE);
......@@ -239,13 +257,13 @@ handle_upcall(struct socket *upcall_socket, void *upcall_data, int upcall_flags)
snp = (union sctp_notification *)tsctp_meta->buffer;
if (snp->sn_header.sn_type == SCTP_PEER_ADDR_CHANGE) {
spc = &snp->sn_paddr_change;
printf("SCTP_PEER_ADDR_CHANGE: state=%d, error=%d\n",spc->spc_state, spc->spc_error);
printf("SCTP_PEER_ADDR_CHANGE: state=%u, error=%u\n",spc->spc_state, spc->spc_error);
}
}
} else {
if (par_very_verbose) {
if (infotype == SCTP_RECVV_RCVINFO) {
printf("Message received - %zd bytes - %s - sid %u - tsn %u %s\n",
printf("Message received - %zd bytes - %s - sid %u - tsn %u %s\n",
n,
(rcvinfo->rcv_flags & SCTP_UNORDERED) ? "unordered" : "ordered",
rcvinfo->rcv_sid,
......
......@@ -46,7 +46,6 @@ set(CMAKE_MACOSX_RPATH 1)
include(CheckCCompilerFlag)
add_definitions(-D__Userspace__)
add_definitions(-D__Userspace_os_${CMAKE_SYSTEM_NAME})
add_definitions(-DSCTP_SIMPLE_ALLOCATOR)
add_definitions(-DSCTP_PROCESS_LEVEL_LOCKS)
......@@ -69,27 +68,10 @@ if (CMAKE_SYSTEM_NAME MATCHES "Linux")
add_definitions(-D_GNU_SOURCE)
endif ()
if (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
add_definitions(-U__FreeBSD__)
endif ()
if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
add_definitions(-U__APPLE__)
add_definitions(-D__APPLE_USE_RFC_2292)
endif ()
if (CMAKE_SYSTEM_NAME MATCHES "DragonFly")
add_definitions(-U__DragonFly__)
endif ()
if (CMAKE_SYSTEM_NAME MATCHES "NetBSD")
add_definitions(-U__NetBSD__)
endif ()
if (CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
add_definitions(-U__OpenBSD__)
endif ()
#################################################
# MISC
#################################################
......
......@@ -31,7 +31,7 @@
CFLAGS=/I. /W3 /WX
CVARSDLL=-DSCTP_DEBUG -DSCTP_SIMPLE_ALLOCATOR -DSCTP_PROCESS_LEVEL_LOCKS
CVARSDLL=$(CVARSDLL) -D__Userspace__ -D__Userspace_os_Windows
CVARSDLL=$(CVARSDLL) -D__Userspace__
CVARSDLL=$(CVARSDLL) -DINET -DINET6
CVARSDLL=$(CVARSDLL) -D_LIB
......
......@@ -32,7 +32,7 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#if defined(__FreeBSD__)
#if defined(__FreeBSD__) && !defined(__Userspace__)
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet/sctp.h 356357 2020-01-04 20:33:12Z tuexen $");
#endif
......@@ -40,14 +40,14 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp.h 356357 2020-01-04 20:33:12Z tuexen $
#ifndef _NETINET_SCTP_H_
#define _NETINET_SCTP_H_
#if (defined(__APPLE__) || defined(__Userspace_os_Linux) || defined(__Userspace_os_Darwin))
#if defined(__APPLE__) || defined(__linux__)
#include <stdint.h>
#endif
#include <sys/types.h>
#if !defined(__Userspace_os_Windows)
#if !defined(_WIN32)
#define SCTP_PACKED __attribute__((packed))
#else
#pragma pack (push, 1)
......@@ -286,11 +286,11 @@ struct sctp_paramhdr {
#define SCTP_PEELOFF 0x0000800a
/* the real worker for sctp_getaddrlen() */
#define SCTP_GET_ADDR_LEN 0x0000800b
#if defined(__APPLE__)
#if defined(__APPLE__) && !defined(__Userspace__)
/* temporary workaround for Apple listen() issue, no args used */
#define SCTP_LISTEN_FIX 0x0000800c
#endif
#if defined(__Windows__)
#if defined(_WIN32) && !defined(__Userspace__)
/* workaround for Cygwin on Windows: returns the SOCKET handle */
#define SCTP_GET_HANDLE 0x0000800d
#endif
......@@ -613,7 +613,7 @@ struct sctp_error_auth_invalid_hmac {
/* Largest PMTU allowed when disabling PMTU discovery */
#define SCTP_LARGEST_PMTU 65536
#if defined(__Userspace_os_Windows)
#if defined(_WIN32)
#pragma pack(pop)
#endif
#undef SCTP_PACKED
......
......@@ -32,9 +32,9 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#if defined(__FreeBSD__)
#if defined(__FreeBSD__) && !defined(__Userspace__)
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet/sctp_asconf.h 359152 2020-03-19 21:01:16Z tuexen $");
__FBSDID("$FreeBSD: head/sys/netinet/sctp_asconf.h 362377 2020-06-19 12:35:29Z tuexen $");
#endif
#ifndef _NETINET_SCTP_ASCONF_H_
......@@ -58,8 +58,8 @@ sctp_handle_asconf_ack(struct mbuf *, int, struct sctp_asconf_ack_chunk *,
struct sctp_tcb *, struct sctp_nets *, int *);
extern uint32_t
sctp_addr_mgmt_ep_sa(struct sctp_inpcb *, struct sockaddr *,
uint32_t, uint32_t, struct sctp_ifa *);
sctp_addr_mgmt_ep_sa(struct sctp_inpcb *, struct sockaddr *, uint32_t,
uint32_t);
extern int sctp_asconf_iterator_ep(struct sctp_inpcb *inp, void *ptr,
......
......@@ -32,9 +32,9 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#if defined(__FreeBSD__)
#if defined(__FreeBSD__) && !defined(__Userspace__)
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet/sctp_auth.c 361895 2020-06-07 14:39:20Z tuexen $");
__FBSDID("$FreeBSD: head/sys/netinet/sctp_auth.c 362054 2020-06-11 13:34:09Z tuexen $");
#endif
#include <netinet/sctp_os.h>
......@@ -567,11 +567,7 @@ sctp_auth_key_acquire(struct sctp_tcb *stcb, uint16_t key_id)
}
void
sctp_auth_key_release(struct sctp_tcb *stcb, uint16_t key_id, int so_locked
#if !defined(__APPLE__)
SCTP_UNUSED
#endif
)
sctp_auth_key_release(struct sctp_tcb *stcb, uint16_t key_id, int so_locked)
{
sctp_sharedkey_t *skey;
......@@ -1749,11 +1745,7 @@ sctp_handle_auth(struct sctp_tcb *stcb, struct sctp_auth_chunk *auth,
*/
void
sctp_notify_authentication(struct sctp_tcb *stcb, uint32_t indication,
uint16_t keyid, uint16_t alt_keyid, int so_locked
#if !defined(__APPLE__)
SCTP_UNUSED
#endif
)
uint16_t keyid, uint16_t alt_keyid, int so_locked)
{
struct mbuf *m_notify;
struct sctp_authkey_event *auth;
......
......@@ -32,7 +32,7 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#if defined(__FreeBSD__)
#if defined(__FreeBSD__) && !defined(__Userspace__)
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet/sctp_auth.h 338749 2018-09-18 10:53:07Z tuexen $");
#endif
......
......@@ -32,7 +32,7 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#if defined(__FreeBSD__)
#if defined(__FreeBSD__) && !defined(__Userspace__)
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet/sctp_bsd_addr.c 358080 2020-02-18 19:41:55Z tuexen $");
#endif
......@@ -50,7 +50,7 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_bsd_addr.c 358080 2020-02-18 19:41:55Z
#include <netinet/sctp_asconf.h>
#include <netinet/sctp_sysctl.h>
#include <netinet/sctp_indata.h>
#if defined(__FreeBSD__)
#if defined(__FreeBSD__) && !defined(__Userspace__)
#include <sys/unistd.h>
#endif
......@@ -79,7 +79,7 @@ MALLOC_DEFINE(SCTP_M_MCORE, "sctp_mcore", "sctp mcore queue");
/* Global NON-VNET structure that controls the iterator */
struct iterator_control sctp_it_ctl;
#if !defined(__FreeBSD__)
#if !(defined(__FreeBSD__) && !defined(__Userspace__))
static void
sctp_cleanup_itqueue(void)
{
......@@ -107,7 +107,7 @@ void
sctp_wakeup_iterator(void)
{
#if defined(SCTP_PROCESS_LEVEL_LOCKS)
#if defined(__Userspace_os_Windows)
#if defined(_WIN32)
WakeAllConditionVariable(&sctp_it_ctl.iterator_wakeup);
#else
pthread_cond_broadcast(&sctp_it_ctl.iterator_wakeup);
......@@ -129,7 +129,7 @@ sctp_iterator_thread(void *v SCTP_UNUSED)
#endif
SCTP_IPI_ITERATOR_WQ_LOCK();
/* In FreeBSD this thread never terminates. */
#if defined(__FreeBSD__)
#if defined(__FreeBSD__) && !defined(__Userspace__)
for (;;) {
#else
while ((sctp_it_ctl.iterator_flags & SCTP_ITERATOR_MUST_EXIT) == 0) {
......@@ -138,25 +138,25 @@ sctp_iterator_thread(void *v SCTP_UNUSED)
msleep(&sctp_it_ctl.iterator_running,
#if defined(__FreeBSD__)
&sctp_it_ctl.ipi_iterator_wq_mtx,
#elif defined(__APPLE__) || defined(__Userspace_os_Darwin)
#elif defined(__APPLE__)
sctp_it_ctl.ipi_iterator_wq_mtx,
#endif
0, "waiting_for_work", 0);
#else
#if defined(__Userspace_os_Windows)
#if defined(_WIN32)
SleepConditionVariableCS(&sctp_it_ctl.iterator_wakeup, &sctp_it_ctl.ipi_iterator_wq_mtx, INFINITE);
#else
pthread_cond_wait(&sctp_it_ctl.iterator_wakeup, &sctp_it_ctl.ipi_iterator_wq_mtx);
#endif
#endif
#if !defined(__FreeBSD__)
#if !(defined(__FreeBSD__) && !defined(__Userspace__))
if (sctp_it_ctl.iterator_flags & SCTP_ITERATOR_MUST_EXIT) {
break;
}
#endif
sctp_iterator_worker();
}
#if !defined(__FreeBSD__)
#if !(defined(__FreeBSD__) && !defined(__Userspace__))
/* Now this thread needs to be terminated */
sctp_cleanup_itqueue();
sctp_it_ctl.iterator_flags |= SCTP_ITERATOR_EXITED;
......@@ -185,7 +185,13 @@ sctp_startup_iterator(void)
SCTP_ITERATOR_LOCK_INIT();
SCTP_IPI_ITERATOR_WQ_INIT();
TAILQ_INIT(&sctp_it_ctl.iteratorhead);
#if defined(__FreeBSD__)
#if defined(__Userspace__)
if (sctp_userspace_thread_create(&sctp_it_ctl.thread_proc, &sctp_iterator_thread)) {
SCTP_PRINTF("ERROR: Creating sctp_iterator_thread failed.\n");
} else {
SCTP_BASE_VAR(iterator_thread_started) = 1;
}
#elif defined(__FreeBSD__)
kproc_create(sctp_iterator_thread,
(void *)NULL,
&sctp_it_ctl.thread_proc,
......@@ -194,12 +200,6 @@ sctp_startup_iterator(void)
SCTP_KTRHEAD_NAME);
#elif defined(__APPLE__)
kernel_thread_start((thread_continue_t)sctp_iterator_thread, NULL, &sctp_it_ctl.thread_proc);
#elif defined(__Userspace__)
if (sctp_userspace_thread_create(&sctp_it_ctl.thread_proc, &sctp_iterator_thread)) {
SCTP_PRINTF("ERROR: Creating sctp_iterator_thread failed.\n");
} else {
SCTP_BASE_VAR(iterator_thread_started) = 1;
}
#endif
}
......@@ -252,7 +252,7 @@ sctp_is_desired_interface_type(struct ifnet *ifn)
int result;
/* check the interface type to see if it's one we care about */
#if defined(__APPLE__)
#if defined(__APPLE__) && !defined(__Userspace__)
switch(ifnet_type(ifn)) {
#else
switch (ifn->if_type) {
......@@ -278,7 +278,7 @@ sctp_is_desired_interface_type(struct ifnet *ifn)
case IFT_GIF:
case IFT_L2VLAN:
case IFT_STF:
#if !defined(__APPLE__)
#if !(defined(__APPLE__) && !defined(__Userspace__))
case IFT_IP:
case IFT_IPOVERCDLC:
case IFT_IPOVERCLAW:
......@@ -295,7 +295,7 @@ sctp_is_desired_interface_type(struct ifnet *ifn)
}
#endif
#if defined(__APPLE__)
#if defined(__APPLE__) && !defined(__Userspace__)
int
sctp_is_vmware_interface(struct ifnet *ifn)
{
......@@ -303,7 +303,7 @@ sctp_is_vmware_interface(struct ifnet *ifn)
}
#endif
#if defined(__Userspace_os_Windows)
#if defined(_WIN32) && defined(__Userspace__)
#ifdef MALLOC
#undef MALLOC
#define MALLOC(x) HeapAlloc(GetProcessHeap(), 0, (x))
......@@ -477,7 +477,7 @@ sctp_init_ifns_for_vrf(int vrfid)
}
#endif
#if defined(__APPLE__)
#if defined(__APPLE__) && !defined(__Userspace__)
static void
sctp_init_ifns_for_vrf(int vrfid)
{
......@@ -556,7 +556,7 @@ sctp_init_ifns_for_vrf(int vrfid)
}
#endif
#if defined(__FreeBSD__)
#if defined(__FreeBSD__) && !defined(__Userspace__)
static void
sctp_init_ifns_for_vrf(int vrfid)
{
......@@ -712,7 +712,7 @@ sctp_addr_change(struct ifaddr *ifa, int cmd)
}
if (cmd == RTM_ADD) {
(void)sctp_add_addr_to_vrf(SCTP_DEFAULT_VRFID, (void *)ifa->ifa_ifp,
#if defined(__APPLE__)
#if defined(__APPLE__) && !defined(__Userspace__)
ifnet_index(ifa->ifa_ifp), ifnet_type(ifa->ifa_ifp), ifnet_name(ifa->ifa_ifp),
#else
ifa->ifa_ifp->if_index, ifa->ifa_ifp->if_type, ifa->ifa_ifp->if_xname,
......@@ -721,7 +721,7 @@ sctp_addr_change(struct ifaddr *ifa, int cmd)
} else {
sctp_del_addr_from_vrf(SCTP_DEFAULT_VRFID, ifa->ifa_addr,
#if defined(__APPLE__)
#if defined(__APPLE__) && !defined(__Userspace__)
ifnet_index(ifa->ifa_ifp),
ifnet_name(ifa->ifa_ifp));
#else
......@@ -736,13 +736,13 @@ sctp_addr_change(struct ifaddr *ifa, int cmd)
#endif
}
#if defined(__FreeBSD__)
#if defined(__FreeBSD__) && !defined(__Userspace__)
void
sctp_addr_change_event_handler(void *arg __unused, struct ifaddr *ifa, int cmd) {
sctp_addr_change(ifa, cmd);
}
#endif
#if defined(__APPLE__)
#if defined(__APPLE__) && !defined(__Userspace__)
void
sctp_add_or_del_interfaces(int (*pred)(struct ifnet *), int add)
{
......
......@@ -32,7 +32,7 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#if defined(__FreeBSD__)
#if defined(__FreeBSD__) && !defined(__Userspace__)
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet/sctp_bsd_addr.h 353480 2019-10-13 18:17:08Z tuexen $");
#endif
......@@ -62,7 +62,7 @@ int sctp_copy_out_packet_log(uint8_t *target, int length);
#endif
void sctp_addr_change(struct ifaddr *ifa, int cmd);
#if defined(__FreeBSD__)
#if defined(__FreeBSD__) && !defined(__Userspace__)
void sctp_addr_change_event_handler(void *, struct ifaddr *, int);
#endif
......
......@@ -34,12 +34,12 @@
#if defined(__Userspace__)
#include <sys/types.h>
#if !defined (__Userspace_os_Windows)
#if !defined(_WIN32)
#include <sys/wait.h>
#include <unistd.h>
#include <pthread.h>
#endif
#if defined(__Userspace_os_NaCl)
#if defined(__native_client__)
#include <sys/select.h>
#endif
#include <stdlib.h>
......@@ -180,7 +180,7 @@ sctp_handle_tick(uint32_t elapsed_ticks)
SCTP_TIMERQ_UNLOCK();
}
#if defined(__APPLE__)
#if defined(__APPLE__) && !defined(__Userspace__)
void
sctp_timeout(void *arg SCTP_UNUSED)
{
......@@ -197,7 +197,7 @@ user_sctp_timer_iterate(void *arg)
{
sctp_userspace_set_threadname("SCTP timer");
for (;;) {
#if defined (__Userspace_os_Windows)
#if defined(_WIN32)
Sleep(TIMEOUT_INTERVAL);
#else
struct timespec amount, remaining;
......@@ -217,7 +217,7 @@ user_sctp_timer_iterate(void *arg)
}
void
sctp_start_timer(void)
sctp_start_timer_thread(void)
{
/*
* No need to do SCTP_TIMERQ_LOCK_INIT();
......@@ -233,4 +233,17 @@ sctp_start_timer(void)
}
}
void
sctp_stop_timer_thread(void)
{
atomic_cmpset_int(&SCTP_BASE_VAR(timer_thread_should_exit), 0, 1);
if (SCTP_BASE_VAR(timer_thread_started)) {
#if defined(_WIN32)
WaitForSingleObject(SCTP_BASE_VAR(timer_thread), INFINITE);
CloseHandle(SCTP_BASE_VAR(timer_thread));
#else
pthread_join(SCTP_BASE_VAR(timer_thread), NULL);
#endif
}
}
#endif
......@@ -30,7 +30,7 @@
* SUCH DAMAGE.
*/
#if defined(__FreeBSD__)
#if defined(__FreeBSD__) && !defined(__Userspace__)
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#endif
......@@ -53,7 +53,7 @@ __FBSDID("$FreeBSD$");
#define SCTP_TICKS_PER_FASTTIMO 20 /* called about every 20ms */
#if defined(__Userspace__)
#if defined(__Userspace_os_Windows)
#if defined(_WIN32)
#define SCTP_TIMERQ_LOCK() EnterCriticalSection(&SCTP_BASE_VAR(timer_mtx))
#define SCTP_TIMERQ_UNLOCK() LeaveCriticalSection(&SCTP_BASE_VAR(timer_mtx))
#define SCTP_TIMERQ_LOCK_INIT() InitializeCriticalSection(&SCTP_BASE_VAR(timer_mtx))
......@@ -95,6 +95,11 @@ int sctp_os_timer_stop(sctp_os_timer_t *);
void sctp_handle_tick(uint32_t);
#define SCTP_OS_TIMER_INIT sctp_os_timer_init
/*
* NOTE: The next two shouldn't be called directly outside of sctp_timer_start()
* and sctp_timer_stop(), since they don't handle incrementing/decrementing
* relevant reference counts.
*/
#define SCTP_OS_TIMER_START sctp_os_timer_start
#define SCTP_OS_TIMER_STOP sctp_os_timer_stop
/* MT FIXME: Is the following correct? */
......@@ -104,9 +109,10 @@ void sctp_handle_tick(uint32_t);
#define SCTP_OS_TIMER_DEACTIVATE(tmr) ((tmr)->c_flags &= ~SCTP_CALLOUT_ACTIVE)
#if defined(__Userspace__)
void sctp_start_timer(void);
void sctp_start_timer_thread(void);
void sctp_stop_timer_thread(void);
#endif
#if defined(__APPLE__)
#if defined(__APPLE__) && !defined(__Userspace__)
void sctp_timeout(void *);
#endif
......
......@@ -32,15 +32,15 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#if defined(__FreeBSD__)
#if defined(__FreeBSD__) && !defined(__Userspace__)
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet/sctp_constants.h 361895 2020-06-07 14:39:20Z tuexen $");
__FBSDID("$FreeBSD: head/sys/netinet/sctp_constants.h 363440 2020-07-23 01:35:24Z tuexen $");
#endif
#ifndef _NETINET_SCTP_CONSTANTS_H_
#define _NETINET_SCTP_CONSTANTS_H_
#if defined(__Userspace_os_Windows)
#if defined(_WIN32) && defined(__Userspace__)
extern void getwintimeofday(struct timeval *tv);
#endif
......@@ -563,7 +563,7 @@ extern void getwintimeofday(struct timeval *tv);
((t) < SCTP_TIMER_TYPE_LAST))
#if defined(__APPLE__)
#if defined(__APPLE__) && !defined(__Userspace__)
/* Number of ticks to run the main timer at in msec */
#define SCTP_MAIN_TIMER_DEFAULT 10
#endif
......@@ -811,6 +811,7 @@ extern void getwintimeofday(struct timeval *tv);
#define SCTP_LOC_34 0x00000022
#define SCTP_LOC_35 0x00000023
#define SCTP_LOC_36 0x00000024
#define SCTP_LOC_37 0x00000025
/* Free assoc codes */
#define SCTP_NORMAL_PROC 0
......@@ -857,7 +858,7 @@ extern void getwintimeofday(struct timeval *tv);
#define SCTP_CHUNKQUEUE_SCALE 10
#endif
#if defined(__FreeBSD__)
#if defined(__FreeBSD__) && !defined(__Userspace__)
/* clock variance is 1 ms */
#define SCTP_CLOCK_GRANULARITY 1
#else
......@@ -995,7 +996,7 @@ extern void getwintimeofday(struct timeval *tv);
#define SCTP_SOCKET_OPTION_LIMIT (64 * 1024)
#if defined(__Userspace__)
#if defined(__Userspace_os_Windows)
#if defined(_WIN32)
#define SCTP_GETTIME_TIMEVAL(x) getwintimeofday(x)
#define SCTP_GETPTIME_TIMEVAL(x) getwintimeofday(x) /* this doesn't seem to ever be used.. */
#else
......@@ -1019,11 +1020,11 @@ do { \
} \
} while (0)
#if defined(__FreeBSD__) || defined(__Windows__) || defined(__Userspace__)
#if defined(__FreeBSD__) || defined(_WIN32) || defined(__Userspace__)
#define sctp_sowwakeup_locked(inp, so) \
do { \
if (inp->sctp_flags & SCTP_PCB_FLAGS_DONT_WAKE) { \
SOCKBUF_UNLOCK(&((so)->so_snd)); \
SOCKBUF_UNLOCK(&((so)->so_snd)); \
inp->sctp_flags |= SCTP_PCB_FLAGS_WAKEOUTPUT; \
} else { \
sowwakeup_locked(so); \
......@@ -1033,7 +1034,7 @@ do { \
#define sctp_sowwakeup_locked(inp, so) \
do { \
if (inp->sctp_flags & SCTP_PCB_FLAGS_DONT_WAKE) { \
SOCKBUF_UNLOCK(&((so)->so_snd)); \
SOCKBUF_UNLOCK(&((so)->so_snd)); \
inp->sctp_flags |= SCTP_PCB_FLAGS_WAKEOUTPUT; \
} else { \
sowwakeup(so); \
......@@ -1050,12 +1051,12 @@ do { \
} \
} while (0)
#if defined(__FreeBSD__) || defined(__Windows__) || defined(__Userspace__)
#if defined(__FreeBSD__) || defined(_WIN32) || defined(__Userspace__)
#define sctp_sorwakeup_locked(inp, so) \
do { \
if (inp->sctp_flags & SCTP_PCB_FLAGS_DONT_WAKE) { \
inp->sctp_flags |= SCTP_PCB_FLAGS_WAKEINPUT; \
SOCKBUF_UNLOCK(&((so)->so_rcv)); \
SOCKBUF_UNLOCK(&((so)->so_rcv)); \
} else { \
sorwakeup_locked(so); \
} \
......@@ -1066,7 +1067,7 @@ do { \
do { \
if (inp->sctp_flags & SCTP_PCB_FLAGS_DONT_WAKE) { \
inp->sctp_flags |= SCTP_PCB_FLAGS_WAKEINPUT; \
SOCKBUF_UNLOCK(&((so)->so_rcv)); \
SOCKBUF_UNLOCK(&((so)->so_rcv)); \
} else { \
sorwakeup(so); \
} \
......
......@@ -32,26 +32,22 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#if defined(__FreeBSD__)
#if defined(__FreeBSD__) && !defined(__Userspace__)
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet/sctp_crc32.c 352361 2019-09-15 18:29:45Z tuexen $");
__FBSDID("$FreeBSD: head/sys/netinet/sctp_crc32.c 362498 2020-06-22 14:36:14Z tuexen $");
#include "opt_sctp.h"
#if defined(__FreeBSD__)
#include <sys/gsb_crc32.h>
#endif
#ifdef SCTP
#include <netinet/sctp_os.h>
#include <netinet/sctp.h>
#include <netinet/sctp_crc32.h>
#include <netinet/sctp_pcb.h>
#else
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/gsb_crc32.h>
#include <sys/mbuf.h>
#include <netinet/sctp.h>
#include <netinet/sctp_crc32.h>
#if defined(SCTP) || defined(SCTP_SUPPORT)
#include <netinet/sctp_os.h>
#include <netinet/sctp_pcb.h>
#endif
#else
#include <netinet/sctp_os.h>
......@@ -60,7 +56,7 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_crc32.c 352361 2019-09-15 18:29:45Z tu
#include <netinet/sctp_pcb.h>
#endif
#if !defined(__FreeBSD__)
#if !(defined(__FreeBSD__) && !defined(__Userspace__))
/**
*
* Routine Description:
......@@ -799,8 +795,11 @@ sctp_calculate_cksum(struct mbuf *m, uint32_t offset)
return (base);
}
#if defined(__FreeBSD__)
#ifdef SCTP
#if defined(__FreeBSD__) && !defined(__Userspace__)
#if defined(SCTP) || defined(SCTP_SUPPORT)
VNET_DEFINE(struct sctp_base_info, system_base_info);
/*
* Compute and insert the SCTP checksum in network byte order for a given
* mbuf chain m which contains an SCTP packet starting at offset.
......
......@@ -32,9 +32,9 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#if defined(__FreeBSD__)
#if defined(__FreeBSD__) && !defined(__Userspace__)
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet/sctp_crc32.h 327200 2017-12-26 12:35:02Z tuexen $");
__FBSDID("$FreeBSD: head/sys/netinet/sctp_crc32.h 362338 2020-06-18 19:32:34Z markj $");
#endif
#ifndef _NETINET_SCTP_CRC32_H_
......@@ -42,8 +42,8 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_crc32.h 327200 2017-12-26 12:35:02Z tu
#if defined(_KERNEL)
uint32_t sctp_calculate_cksum(struct mbuf *, uint32_t);
#if defined(__FreeBSD__)
#ifdef SCTP
#if defined(__FreeBSD__) && !defined(__Userspace__)
#if defined(SCTP) || defined(SCTP_SUPPORT)
void sctp_delayed_cksum(struct mbuf *, uint32_t offset);
#endif
#endif
......
......@@ -32,7 +32,7 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#if defined(__FreeBSD__)
#if defined(__FreeBSD__) && !defined(__Userspace__)
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet/sctp_header.h 309682 2016-12-07 19:30:59Z tuexen $");
#endif
......@@ -40,16 +40,16 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_header.h 309682 2016-12-07 19:30:59Z t
#ifndef _NETINET_SCTP_HEADER_H_
#define _NETINET_SCTP_HEADER_H_
#if defined(__Windows__) && !defined(__Userspace_os_Windows)
#if defined(_WIN32) && !defined(__Userspace__)
#include <packon.h>
#endif
#if !defined(__Userspace_os_Windows)
#if !defined(_WIN32)
#include <sys/time.h>
#endif
#include <netinet/sctp.h>
#include <netinet/sctp_constants.h>
#if !defined(__Userspace_os_Windows)
#if !defined(_WIN32)
#define SCTP_PACKED __attribute__((packed))
#else
#pragma pack (push, 1)
......@@ -601,10 +601,10 @@ struct sctp_auth_chunk {
#define SCTP_MIN_V4_OVERHEAD (sizeof(struct ip) + \
sizeof(struct sctphdr))
#if defined(__Windows__)
#if defined(_WIN32) && !defined(__Userspace__)
#include <packoff.h>
#endif
#if defined(__Userspace_os_Windows)
#if defined(_WIN32) && defined(__Userspace__)
#pragma pack(pop)
#endif
#undef SCTP_PACKED
......
......@@ -32,7 +32,7 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#if defined(__FreeBSD__)
#if defined(__FreeBSD__) && !defined(__Userspace__)
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet/sctp_indata.h 361116 2020-05-16 19:26:39Z tuexen $");
#endif
......
......@@ -32,7 +32,7 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#if defined(__FreeBSD__)
#if defined(__FreeBSD__) && !defined(__Userspace__)
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet/sctp_input.h 326672 2017-12-07 22:19:08Z tuexen $");
#endif
......@@ -47,7 +47,7 @@ sctp_common_input_processing(struct mbuf **, int, int, int,
struct sctphdr *, struct sctp_chunkhdr *,
uint8_t,
uint8_t,
#if defined(__FreeBSD__)
#if defined(__FreeBSD__) && !defined(__Userspace__)
uint8_t, uint32_t, uint16_t,
#endif
uint32_t, uint16_t);
......
......@@ -33,7 +33,7 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#if defined(__FreeBSD__)
#if defined(__FreeBSD__) && !defined(__Userspace__)
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#endif
......@@ -76,6 +76,8 @@ __FBSDID("$FreeBSD$");
#define SCTP_IPI_ADDR_WLOCK()
#define SCTP_IPI_ADDR_RUNLOCK()
#define SCTP_IPI_ADDR_WUNLOCK()
#define SCTP_IPI_ADDR_LOCK_ASSERT()
#define SCTP_IPI_ADDR_WLOCK_ASSERT()
#define SCTP_IPI_ITERATOR_WQ_INIT()
#define SCTP_IPI_ITERATOR_WQ_DESTROY()
......
......@@ -32,7 +32,7 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#if defined(__FreeBSD__)
#if defined(__FreeBSD__) && !defined(__Userspace__)
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet/sctp_os.h 361872 2020-06-06 18:20:09Z tuexen $");
#endif
......@@ -64,7 +64,7 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_os.h 361872 2020-06-06 18:20:09Z tuexe
* SCTP_ZONE_DESTROY(zone)
*/
#if defined(__FreeBSD__)
#if defined(__FreeBSD__) && !defined(__Userspace__)
#include <netinet/sctp_os_bsd.h>
#else
#define MODULE_GLOBAL(_B) (_B)
......@@ -74,11 +74,11 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_os.h 361872 2020-06-06 18:20:09Z tuexe
#include <netinet/sctp_os_userspace.h>
#endif
#if defined(__APPLE__)
#if defined(__APPLE__) && !defined(__Userspace__)
#include <netinet/sctp_os_macosx.h>
#endif
#if defined(__Windows__)
#if defined(_WIN32) && !defined(__Userspace__)
#include <netinet/sctp_os_windows.h>
#endif
......
......@@ -32,9 +32,9 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#if defined(__FreeBSD__)
#if defined(__FreeBSD__) && !defined(__Userspace__)
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet/sctp_output.h 361895 2020-06-07 14:39:20Z tuexen $");
__FBSDID("$FreeBSD: head/sys/netinet/sctp_output.h 362054 2020-06-11 13:34:09Z tuexen $");
#endif
#ifndef _NETINET_SCTP_OUTPUT_H_
......@@ -78,11 +78,7 @@ int
sctp_v4src_match_nexthop(struct sctp_ifa *sifa, sctp_route_t *ro);
#endif
void sctp_send_initiate(struct sctp_inpcb *, struct sctp_tcb *, int
#if !defined(__APPLE__)
SCTP_UNUSED
#endif
);
void sctp_send_initiate(struct sctp_inpcb *, struct sctp_tcb *, int);
void
sctp_send_initiate_ack(struct sctp_inpcb *, struct sctp_tcb *,
......@@ -90,7 +86,7 @@ sctp_send_initiate_ack(struct sctp_inpcb *, struct sctp_tcb *,
int, int,
struct sockaddr *, struct sockaddr *,
struct sctphdr *, struct sctp_init_chunk *,
#if defined(__FreeBSD__)
#if defined(__FreeBSD__) && !defined(__Userspace__)
uint8_t, uint32_t,
#endif
uint32_t, uint16_t);
......@@ -124,7 +120,7 @@ void sctp_send_shutdown_complete(struct sctp_tcb *, struct sctp_nets *, int);
void sctp_send_shutdown_complete2(struct sockaddr *, struct sockaddr *,
struct sctphdr *,
#if defined(__FreeBSD__)
#if defined(__FreeBSD__) && !defined(__Userspace__)
uint8_t, uint32_t, uint16_t,
#endif
uint32_t, uint16_t);
......@@ -148,11 +144,11 @@ void sctp_move_chunks_from_net(struct sctp_tcb *stcb, struct sctp_nets *net);
sizeof(struct sctp_idata_chunk) : \
sizeof(struct sctp_data_chunk))
#if defined(__FreeBSD__)
#if defined(__FreeBSD__) && !defined(__Userspace__)
int
sctp_output(struct sctp_inpcb *, struct mbuf *, struct sockaddr *,
struct mbuf *, struct thread *, int);
#elif defined(__Windows__)
#elif defined(_WIN32) && !defined(__Userspace__)
sctp_output(struct sctp_inpcb *, struct mbuf *, struct sockaddr *,
struct mbuf *, PKTHREAD, int);
#else
......@@ -167,16 +163,9 @@ sctp_output(struct sctp_inpcb *,
struct proc *, int);
#endif
void sctp_chunk_output(struct sctp_inpcb *, struct sctp_tcb *, int, int
#if !defined(__APPLE__)
SCTP_UNUSED
#endif
);
void sctp_send_abort_tcb(struct sctp_tcb *, struct mbuf *, int
#if !defined(__APPLE__)
SCTP_UNUSED
#endif
);
void sctp_chunk_output(struct sctp_inpcb *, struct sctp_tcb *, int, int);
void sctp_send_abort_tcb(struct sctp_tcb *, struct mbuf *, int);
void send_forward_tsn(struct sctp_tcb *, struct sctp_association *);
......@@ -186,7 +175,6 @@ void sctp_send_hb(struct sctp_tcb *, struct sctp_nets *, int);
void sctp_send_ecn_echo(struct sctp_tcb *, struct sctp_nets *, uint32_t);
void
sctp_send_packet_dropped(struct sctp_tcb *, struct sctp_nets *, struct mbuf *,
int, int, int);
......@@ -217,14 +205,14 @@ sctp_send_str_reset_req(struct sctp_tcb *, uint16_t , uint16_t *,
void
sctp_send_abort(struct mbuf *, int, struct sockaddr *, struct sockaddr *,
struct sctphdr *, uint32_t, struct mbuf *,
#if defined(__FreeBSD__)
#if defined(__FreeBSD__) && !defined(__Userspace__)
uint8_t, uint32_t, uint16_t,
#endif
uint32_t, uint16_t);
void sctp_send_operr_to(struct sockaddr *, struct sockaddr *,
struct sctphdr *, uint32_t, struct mbuf *,
#if defined(__FreeBSD__)
#if defined(__FreeBSD__) && !defined(__Userspace__)
uint8_t, uint32_t, uint16_t,
#endif
uint32_t, uint16_t);
......@@ -238,13 +226,13 @@ sctp_sosend(struct socket *so,
struct uio *uio,
struct mbuf *top,
struct mbuf *control,
#if defined(__APPLE__)
#if defined(__APPLE__) && !defined(__Userspace__)
int flags
#else
int flags,
#if defined(__FreeBSD__)
#if defined(__FreeBSD__) && !defined(__Userspace__)
struct thread *p
#elif defined(__Windows__)
#elif defined(_WIN32) && !defined(__Userspace__)
PKTHREAD p
#else
#if defined(__Userspace__)
......
......@@ -32,7 +32,7 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#if defined(__FreeBSD__)
#if defined(__FreeBSD__) && !defined(__Userspace__)
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet/sctp_peeloff.h 309607 2016-12-06 10:21:25Z tuexen $");
#endif
......@@ -42,13 +42,13 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_peeloff.h 309607 2016-12-06 10:21:25Z
#if defined(HAVE_SCTP_PEELOFF_SOCKOPT)
/* socket option peeloff */
struct sctp_peeloff_opt {
#if !defined(__Windows__)
#if !(defined(_WIN32) && !defined(__Userspace__))
int s;
#else
HANDLE s;
#endif
sctp_assoc_t assoc_id;
#if !defined(__Windows__)
#if !(defined(_WIN32) && !defined(__Userspace__))
int new_sd;
#else
HANDLE new_sd;
......
......@@ -84,9 +84,9 @@ sctp_sha1_final(unsigned char *digest, struct sctp_sha1_context *ctx)
#else
#include <string.h>
#if defined(__Userspace_os_Windows)
#if defined(_WIN32) && defined(__Userspace__)
#include <winsock2.h>
#elif !defined(__Windows__)
#elif !(defined(_WIN32) && !defined(__Userspace__))
#include <arpa/inet.h>
#endif
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论