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

Update 'usrsctp' dep

上级 474be61c
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
### 3.6.15 (WIP) ### 3.6.15 (WIP)
* Avoid SRTP leak by deleting invalid SSRCs after STRP decryption (issue #437, thanks to @penguinol for reporting). * Avoid SRTP leak by deleting invalid SSRCs after STRP decryption (issue #437, thanks to @penguinol for reporting).
* Update `usrsctp` dep.
### 3.6.14 ### 3.6.14
......
...@@ -41,7 +41,6 @@ ...@@ -41,7 +41,6 @@
'conditions': [ 'conditions': [
['OS in "linux android"', { ['OS in "linux android"', {
'defines': [ 'defines': [
'__Userspace_os_Linux',
'_GNU_SOURCE', '_GNU_SOURCE',
], ],
}], }],
...@@ -50,7 +49,6 @@ ...@@ -50,7 +49,6 @@
'HAVE_SA_LEN', 'HAVE_SA_LEN',
'HAVE_SCONN_LEN', 'HAVE_SCONN_LEN',
'__APPLE_USE_RFC_2292', '__APPLE_USE_RFC_2292',
'__Userspace_os_Darwin',
], ],
'xcode_settings': { 'xcode_settings': {
'WARNING_CFLAGS': [ 'WARNING_CFLAGS': [
...@@ -60,18 +58,12 @@ ...@@ -60,18 +58,12 @@
'-Wstrict-prototypes', '-Wstrict-prototypes',
], ],
'OTHER_CFLAGS': [ 'OTHER_CFLAGS': [
'-U__APPLE__',
'-Wno-deprecated-declarations', '-Wno-deprecated-declarations',
# atomic_init in user_atomic.h is a static function in a header. # atomic_init in user_atomic.h is a static function in a header.
'-Wno-unused-function', '-Wno-unused-function',
], ],
} }
}], }],
['OS=="win"', {
'defines': [
'__Userspace_os_Windows'
],
}],
['OS!="win"', { ['OS!="win"', {
'defines': [ 'defines': [
'NON_WINDOWS_DEFINE' '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 ...@@ -66,7 +66,6 @@ programs/echo_server
programs/echo_server_upcall programs/echo_server_upcall
programs/ekr_client programs/ekr_client
programs/ekr_loop programs/ekr_loop
programs/ekr_loop_offload
programs/ekr_loop_upcall programs/ekr_loop_upcall
programs/ekr_peer programs/ekr_peer
programs/ekr_server programs/ekr_server
......
...@@ -970,7 +970,7 @@ SCTP\_DEBUG has to be set as a compile flag. ...@@ -970,7 +970,7 @@ SCTP\_DEBUG has to be set as a compile flag.
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <sys/types.h> #include <sys/types.h>
#if !defined(__Userspace_os_Windows) #if !defined(_WIN32)
#include <unistd.h> #include <unistd.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <netinet/in.h> #include <netinet/in.h>
...@@ -1098,7 +1098,7 @@ main(int argc, char *argv[]) ...@@ -1098,7 +1098,7 @@ main(int argc, char *argv[])
} }
while (1) { while (1) {
if (use_cb) { if (use_cb) {
#if defined (__Userspace_os_Windows) #if defined(_WIN32)
Sleep(1*1000); Sleep(1*1000);
#else #else
sleep(1); sleep(1);
...@@ -1133,7 +1133,7 @@ main(int argc, char *argv[]) ...@@ -1133,7 +1133,7 @@ main(int argc, char *argv[])
} }
usrsctp_close(sock); usrsctp_close(sock);
while (usrsctp_finish() != 0) { while (usrsctp_finish() != 0) {
#if defined (__Userspace_os_Windows) #if defined(_WIN32)
Sleep(1000); Sleep(1000);
#else #else
sleep(1); sleep(1);
...@@ -1183,11 +1183,11 @@ main(int argc, char *argv[]) ...@@ -1183,11 +1183,11 @@ main(int argc, char *argv[])
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#if !defined(__Userspace_os_Windows) #if !defined(_WIN32)
#include <unistd.h> #include <unistd.h>
#endif #endif
#include <sys/types.h> #include <sys/types.h>
#if !defined(__Userspace_os_Windows) #if !defined(_WIN32)
#include <sys/socket.h> #include <sys/socket.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <arpa/inet.h> #include <arpa/inet.h>
...@@ -1242,7 +1242,7 @@ main(int argc, char *argv[]) ...@@ -1242,7 +1242,7 @@ main(int argc, char *argv[])
} }
memset((void *)&addr4, 0, sizeof(struct sockaddr_in)); memset((void *)&addr4, 0, sizeof(struct sockaddr_in));
memset((void *)&addr6, 0, sizeof(struct sockaddr_in6)); 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); addr4.sin_len = sizeof(struct sockaddr_in);
addr6.sin6_len = sizeof(struct sockaddr_in6); addr6.sin6_len = sizeof(struct sockaddr_in6);
#endif #endif
...@@ -1271,14 +1271,14 @@ main(int argc, char *argv[]) ...@@ -1271,14 +1271,14 @@ main(int argc, char *argv[])
usrsctp_shutdown(sock, SHUT_WR); usrsctp_shutdown(sock, SHUT_WR);
} }
while (!done) { while (!done) {
#if defined (__Userspace_os_Windows) #if defined(_WIN32)
Sleep(1*1000); Sleep(1*1000);
#else #else
sleep(1); sleep(1);
#endif #endif
} }
while (usrsctp_finish() != 0) { while (usrsctp_finish() != 0) {
#if defined (__Userspace_os_Windows) #if defined(_WIN32)
Sleep(1000); Sleep(1000);
#else #else
sleep(1); sleep(1);
......
# usrsctp # usrsctp
[![Coverity Scan Build Status](https://scan.coverity.com/projects/13430/badge.svg)](https://scan.coverity.com/projects/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. This is a userland SCTP stack supporting FreeBSD, Linux, Mac OS X and Windows.
See [manual](Manual.md) for more information. See [manual](Manual.md) for more information.
......
...@@ -46,11 +46,9 @@ APPCFLAGS="" ...@@ -46,11 +46,9 @@ APPCFLAGS=""
case $host_os in case $host_os in
darwin*) darwin*)
CFLAGS="$CFLAGS -std=c99 -Wno-deprecated-declarations -D__APPLE_USE_RFC_2292" CFLAGS="$CFLAGS -std=c99 -Wno-deprecated-declarations -D__APPLE_USE_RFC_2292"
LIBCFLAGS="$LIBCFLAGS -U__APPLE__ -D__Userspace_os_Darwin"
;; ;;
dragonfly*) dragonfly*)
CFLAGS="$CFLAGS -std=c99 -pthread" CFLAGS="$CFLAGS -std=c99 -pthread"
LIBCFLAGS="$LIBCFLAGS -U__DragonFly__ -D__Userspace_os_DragonFly"
;; ;;
freebsd*) freebsd*)
CFLAGS="$CFLAGS -std=c99 -pthread" CFLAGS="$CFLAGS -std=c99 -pthread"
...@@ -58,19 +56,15 @@ freebsd*) ...@@ -58,19 +56,15 @@ freebsd*)
CFLAGS="$CFLAGS -Wno-unknown-warning-option" CFLAGS="$CFLAGS -Wno-unknown-warning-option"
LDFLAGS="$LDFLAGS -Qunused-arguments" LDFLAGS="$LDFLAGS -Qunused-arguments"
fi fi
LIBCFLAGS="$LIBCFLAGS -U__FreeBSD__ -D__Userspace_os_FreeBSD"
;; ;;
linux*) linux*)
CFLAGS="$CFLAGS -std=c99 -pthread -D_GNU_SOURCE -Wno-address-of-packed-member" CFLAGS="$CFLAGS -std=c99 -pthread -D_GNU_SOURCE -Wno-address-of-packed-member"
LIBCFLAGS="$LIBCFLAGS -D__Userspace_os_Linux"
;; ;;
netbsd*) netbsd*)
CFLAGS="$CFLAGS -std=c99 -pthread" CFLAGS="$CFLAGS -std=c99 -pthread"
LIBCFLAGS="$LIBCFLAGS -U__NetBSD__ -D__Userspace_os_NetBSD"
;; ;;
openbsd*) openbsd*)
CFLAGS="$CFLAGS -std=c99 -pthread" CFLAGS="$CFLAGS -std=c99 -pthread"
LIBCFLAGS="$LIBCFLAGS -U__OpenBSD__ -D__Userspace_os_OpenBSD"
;; ;;
solaris*) solaris*)
CFLAGS="$CFLAGS -D_XPG4_2" CFLAGS="$CFLAGS -D_XPG4_2"
......
...@@ -58,41 +58,20 @@ add_project_arguments([ ...@@ -58,41 +58,20 @@ add_project_arguments([
system = host_machine.system() system = host_machine.system()
if system in ['linux', 'android'] if system in ['linux', 'android']
add_project_arguments([ add_project_arguments([
'-D__Userspace_os_Linux',
'-D_GNU_SOURCE', '-D_GNU_SOURCE',
], language: 'c') ], language: 'c')
elif system == 'freebsd' elif system == 'freebsd'
add_project_arguments([ add_project_arguments(compiler.get_supported_arguments([
'-D__Userspace_os_FreeBSD',
'-U__FreeBSD__',
] + compiler.get_supported_arguments([
'-Wno-address-of-packed-member', '-Wno-address-of-packed-member',
]), language: 'c') ]), language: 'c')
elif system in ['darwin', 'ios'] elif system in ['darwin', 'ios']
add_project_arguments([ add_project_arguments([
'-D__Userspace_os_Darwin',
'-D__APPLE_USE_RFC_2292', '-D__APPLE_USE_RFC_2292',
] + compiler.get_supported_arguments([ ] + compiler.get_supported_arguments([
'-Wno-address-of-packed-member', '-Wno-address-of-packed-member',
'-Wno-deprecated-declarations', '-Wno-deprecated-declarations',
]), language: 'c') ]), 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' elif system == 'windows'
add_project_arguments('-D__Userspace_os_Windows', language: 'c')
dependencies += compiler.find_library('ws2_32', required: true) dependencies += compiler.find_library('ws2_32', required: true)
dependencies += compiler.find_library('iphlpapi', required: true) dependencies += compiler.find_library('iphlpapi', required: true)
if compiler.get_id() == 'gcc' if compiler.get_id() == 'gcc'
...@@ -207,8 +186,7 @@ else ...@@ -207,8 +186,7 @@ else
dependencies: dependencies, dependencies: dependencies,
include_directories: include_dirs, include_directories: include_dirs,
install: true, install: true,
version: meson.project_version(), version: meson.project_version())
c_args: '-U__APPLE__')
endif endif
# Declare dependency # Declare dependency
......
...@@ -93,7 +93,6 @@ list(APPEND check_programs ...@@ -93,7 +93,6 @@ list(APPEND check_programs
echo_server_upcall.c echo_server_upcall.c
ekr_client.c ekr_client.c
ekr_loop.c ekr_loop.c
ekr_loop_offload.c
ekr_loop_upcall.c ekr_loop_upcall.c
ekr_peer.c ekr_peer.c
ekr_server.c ekr_server.c
......
...@@ -47,7 +47,6 @@ EXTRA_DIST = \ ...@@ -47,7 +47,6 @@ EXTRA_DIST = \
ekr_client.c \ ekr_client.c \
ekr_server.c \ ekr_server.c \
ekr_loop.c \ ekr_loop.c \
ekr_loop_offload.c \
ekr_loop_upcall.c \ ekr_loop_upcall.c \
ekr_peer.c \ ekr_peer.c \
test_libmgmt.c \ test_libmgmt.c \
...@@ -72,7 +71,6 @@ noinst_PROGRAMS = \ ...@@ -72,7 +71,6 @@ noinst_PROGRAMS = \
ekr_client \ ekr_client \
ekr_server \ ekr_server \
ekr_loop \ ekr_loop \
ekr_loop_offload \
ekr_loop_upcall \ ekr_loop_upcall \
ekr_peer \ ekr_peer \
test_libmgmt \ test_libmgmt \
...@@ -114,8 +112,6 @@ ekr_peer_SOURCES = programs_helper.c ekr_peer.c ...@@ -114,8 +112,6 @@ ekr_peer_SOURCES = programs_helper.c ekr_peer.c
ekr_peer_LDADD = ../usrsctplib/libusrsctp.la ekr_peer_LDADD = ../usrsctplib/libusrsctp.la
ekr_loop_SOURCES = programs_helper.c ekr_loop.c ekr_loop_SOURCES = programs_helper.c ekr_loop.c
ekr_loop_LDADD = ../usrsctplib/libusrsctp.la 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_SOURCES = programs_helper.c ekr_loop_upcall.c
ekr_loop_upcall_LDADD = ../usrsctplib/libusrsctp.la ekr_loop_upcall_LDADD = ../usrsctplib/libusrsctp.la
http_client_SOURCES = programs_helper.c http_client.c http_client_SOURCES = programs_helper.c http_client.c
......
...@@ -53,7 +53,6 @@ all: \ ...@@ -53,7 +53,6 @@ all: \
ekr_server \ ekr_server \
ekr_peer \ ekr_peer \
ekr_loop \ ekr_loop \
ekr_loop_offload \
ekr_loop_upcall \ ekr_loop_upcall \
test_libmgmt \ test_libmgmt \
http_client \ http_client \
...@@ -119,10 +118,6 @@ ekr_loop: ...@@ -119,10 +118,6 @@ ekr_loop:
$(CC) $(CFLAGS) $(CVARSDLL) -c ekr_loop.c $(CC) $(CFLAGS) $(CVARSDLL) -c ekr_loop.c
link -out:ekr_loop.exe ekr_loop.obj programs_helper.obj $(LINKFLAGS) 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: ekr_loop_upcall:
$(CC) $(CFLAGS) $(CVARSDLL) -c ekr_loop_upcall.c $(CC) $(CFLAGS) $(CVARSDLL) -c ekr_loop_upcall.c
link -out:ekr_loop_upcall.exe ekr_loop_upcall.obj programs_helper.obj $(LINKFLAGS) link -out:ekr_loop_upcall.exe ekr_loop_upcall.obj programs_helper.obj $(LINKFLAGS)
...@@ -172,8 +167,6 @@ clean: ...@@ -172,8 +167,6 @@ clean:
del /F ekr_peer.obj del /F ekr_peer.obj
del /F ekr_loop.exe del /F ekr_loop.exe
del /F ekr_loop.obj 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.exe
del /F ekr_loop_upcall.obj del /F ekr_loop_upcall.obj
del /F test_libmgmt.exe del /F test_libmgmt.exe
......
...@@ -96,7 +96,7 @@ receive_cb(struct socket *sock, union sctp_sockstore addr, void *data, ...@@ -96,7 +96,7 @@ receive_cb(struct socket *sock, union sctp_sockstore addr, void *data,
port = ntohs(addr.sconn.sconn_port); port = ntohs(addr.sconn.sconn_port);
break; break;
default: default:
name = NULL; name = "???";
port = 0; port = 0;
break; break;
} }
......
...@@ -96,7 +96,7 @@ receive_cb(struct socket *sock, union sctp_sockstore addr, void *data, ...@@ -96,7 +96,7 @@ receive_cb(struct socket *sock, union sctp_sockstore addr, void *data,
port = ntohs(addr.sconn.sconn_port); port = ntohs(addr.sconn.sconn_port);
break; break;
default: default:
name = NULL; name = "???";
port = 0; port = 0;
break; break;
} }
......
...@@ -78,7 +78,7 @@ typedef char* caddr_t; ...@@ -78,7 +78,7 @@ typedef char* caddr_t;
static void handle_upcall(struct socket *sock, void *arg, int flgs) static void handle_upcall(struct socket *sock, void *arg, int flgs)
{ {
int events = usrsctp_get_events(sock); int events = usrsctp_get_events(sock);
ssize_t bytesSent = 0; ssize_t bytesSent;
char *buf; char *buf;
if ((events & SCTP_EVENT_READ) && !done) { if ((events & SCTP_EVENT_READ) && !done) {
...@@ -103,10 +103,10 @@ static void handle_upcall(struct socket *sock, void *arg, int flgs) ...@@ -103,10 +103,10 @@ static void handle_upcall(struct socket *sock, void *arg, int flgs)
} else { } else {
result = RETVAL_CATCHALL; result = RETVAL_CATCHALL;
} }
perror("usrsctp_connect"); perror("usrsctp_recvv");
} }
if (n <= 0){ if (n <= 0) {
done = 1; done = 1;
usrsctp_close(sock); usrsctp_close(sock);
} else { } else {
...@@ -132,7 +132,7 @@ static void handle_upcall(struct socket *sock, void *arg, int flgs) ...@@ -132,7 +132,7 @@ static void handle_upcall(struct socket *sock, void *arg, int flgs)
perror("usrsctp_sendv"); perror("usrsctp_sendv");
usrsctp_close(sock); usrsctp_close(sock);
} else { } else {
printf("%d bytes sent\n", (int)bytesSent); printf("%zd bytes sent\n", bytesSent);
} }
} }
} }
...@@ -309,9 +309,6 @@ main(int argc, char *argv[]) ...@@ -309,9 +309,6 @@ main(int argc, char *argv[])
result = RETVAL_CATCHALL; result = RETVAL_CATCHALL;
} }
perror("usrsctp_connect"); perror("usrsctp_connect");
usrsctp_close(sock);
goto out;
} }
} }
......
...@@ -15,7 +15,6 @@ programs = { ...@@ -15,7 +15,6 @@ programs = {
'echo_server_upcall': files('echo_server_upcall.c'), 'echo_server_upcall': files('echo_server_upcall.c'),
'ekr_client': files('ekr_client.c'), 'ekr_client': files('ekr_client.c'),
'ekr_loop': files('ekr_loop.c'), 'ekr_loop': files('ekr_loop.c'),
'ekr_loop_offload': files('ekr_loop_offload.c'),
'ekr_loop_upcall': files('ekr_loop_upcall.c'), 'ekr_loop_upcall': files('ekr_loop_upcall.c'),
'ekr_peer': files('ekr_peer.c'), 'ekr_peer': files('ekr_peer.c'),
'ekr_server': files('ekr_server.c'), 'ekr_server': files('ekr_server.c'),
......
...@@ -73,15 +73,15 @@ handle_notification(union sctp_notification *notif, size_t n); ...@@ -73,15 +73,15 @@ handle_notification(union sctp_notification *notif, size_t n);
#endif #endif
void void
debug_printf_runtime(void); debug_printf(const char *format, ...);
void
debug_printf_clean(const char *format, ...);
void void
debug_printf_stack(const char *format, ...); debug_printf_stack(const char *format, ...);
#define debug_printf(...) \ void
do { \ debug_set_target(FILE *fp);
fprintf(stderr, "[P]"); \
debug_printf_runtime(); \
fprintf(stderr, __VA_ARGS__); \
} while (0)
#endif /* __PROGRAMS_HELPER_H__ */ #endif /* __PROGRAMS_HELPER_H__ */
...@@ -105,11 +105,29 @@ struct tsctp_meta { ...@@ -105,11 +105,29 @@ struct tsctp_meta {
static void static void
gettimeofday(struct timeval *tv, void *ignore) gettimeofday(struct timeval *tv, void *ignore)
{ {
struct timeb tb; FILETIME filetime;
ULARGE_INTEGER ularge;
ftime(&tb);
tv->tv_sec = (long)tb.time; GetSystemTimeAsFileTime(&filetime);
tv->tv_usec = tb.millitm * 1000; 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 #endif
...@@ -239,7 +257,7 @@ handle_upcall(struct socket *upcall_socket, void *upcall_data, int upcall_flags) ...@@ -239,7 +257,7 @@ handle_upcall(struct socket *upcall_socket, void *upcall_data, int upcall_flags)
snp = (union sctp_notification *)tsctp_meta->buffer; snp = (union sctp_notification *)tsctp_meta->buffer;
if (snp->sn_header.sn_type == SCTP_PEER_ADDR_CHANGE) { if (snp->sn_header.sn_type == SCTP_PEER_ADDR_CHANGE) {
spc = &snp->sn_paddr_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 { } else {
......
...@@ -46,7 +46,6 @@ set(CMAKE_MACOSX_RPATH 1) ...@@ -46,7 +46,6 @@ set(CMAKE_MACOSX_RPATH 1)
include(CheckCCompilerFlag) include(CheckCCompilerFlag)
add_definitions(-D__Userspace__) add_definitions(-D__Userspace__)
add_definitions(-D__Userspace_os_${CMAKE_SYSTEM_NAME})
add_definitions(-DSCTP_SIMPLE_ALLOCATOR) add_definitions(-DSCTP_SIMPLE_ALLOCATOR)
add_definitions(-DSCTP_PROCESS_LEVEL_LOCKS) add_definitions(-DSCTP_PROCESS_LEVEL_LOCKS)
...@@ -69,27 +68,10 @@ if (CMAKE_SYSTEM_NAME MATCHES "Linux") ...@@ -69,27 +68,10 @@ if (CMAKE_SYSTEM_NAME MATCHES "Linux")
add_definitions(-D_GNU_SOURCE) add_definitions(-D_GNU_SOURCE)
endif () endif ()
if (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
add_definitions(-U__FreeBSD__)
endif ()
if (CMAKE_SYSTEM_NAME MATCHES "Darwin") if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
add_definitions(-U__APPLE__)
add_definitions(-D__APPLE_USE_RFC_2292) add_definitions(-D__APPLE_USE_RFC_2292)
endif () 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 # MISC
################################################# #################################################
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
CFLAGS=/I. /W3 /WX CFLAGS=/I. /W3 /WX
CVARSDLL=-DSCTP_DEBUG -DSCTP_SIMPLE_ALLOCATOR -DSCTP_PROCESS_LEVEL_LOCKS 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) -DINET -DINET6
CVARSDLL=$(CVARSDLL) -D_LIB CVARSDLL=$(CVARSDLL) -D_LIB
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
* THE POSSIBILITY OF SUCH DAMAGE. * THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#if defined(__FreeBSD__) #if defined(__FreeBSD__) && !defined(__Userspace__)
#include <sys/cdefs.h> #include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet/sctp.h 356357 2020-01-04 20:33:12Z tuexen $"); __FBSDID("$FreeBSD: head/sys/netinet/sctp.h 356357 2020-01-04 20:33:12Z tuexen $");
#endif #endif
...@@ -40,14 +40,14 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp.h 356357 2020-01-04 20:33:12Z tuexen $ ...@@ -40,14 +40,14 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp.h 356357 2020-01-04 20:33:12Z tuexen $
#ifndef _NETINET_SCTP_H_ #ifndef _NETINET_SCTP_H_
#define _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> #include <stdint.h>
#endif #endif
#include <sys/types.h> #include <sys/types.h>
#if !defined(__Userspace_os_Windows) #if !defined(_WIN32)
#define SCTP_PACKED __attribute__((packed)) #define SCTP_PACKED __attribute__((packed))
#else #else
#pragma pack (push, 1) #pragma pack (push, 1)
...@@ -286,11 +286,11 @@ struct sctp_paramhdr { ...@@ -286,11 +286,11 @@ struct sctp_paramhdr {
#define SCTP_PEELOFF 0x0000800a #define SCTP_PEELOFF 0x0000800a
/* the real worker for sctp_getaddrlen() */ /* the real worker for sctp_getaddrlen() */
#define SCTP_GET_ADDR_LEN 0x0000800b #define SCTP_GET_ADDR_LEN 0x0000800b
#if defined(__APPLE__) #if defined(__APPLE__) && !defined(__Userspace__)
/* temporary workaround for Apple listen() issue, no args used */ /* temporary workaround for Apple listen() issue, no args used */
#define SCTP_LISTEN_FIX 0x0000800c #define SCTP_LISTEN_FIX 0x0000800c
#endif #endif
#if defined(__Windows__) #if defined(_WIN32) && !defined(__Userspace__)
/* workaround for Cygwin on Windows: returns the SOCKET handle */ /* workaround for Cygwin on Windows: returns the SOCKET handle */
#define SCTP_GET_HANDLE 0x0000800d #define SCTP_GET_HANDLE 0x0000800d
#endif #endif
...@@ -613,7 +613,7 @@ struct sctp_error_auth_invalid_hmac { ...@@ -613,7 +613,7 @@ struct sctp_error_auth_invalid_hmac {
/* Largest PMTU allowed when disabling PMTU discovery */ /* Largest PMTU allowed when disabling PMTU discovery */
#define SCTP_LARGEST_PMTU 65536 #define SCTP_LARGEST_PMTU 65536
#if defined(__Userspace_os_Windows) #if defined(_WIN32)
#pragma pack(pop) #pragma pack(pop)
#endif #endif
#undef SCTP_PACKED #undef SCTP_PACKED
......
...@@ -32,9 +32,9 @@ ...@@ -32,9 +32,9 @@
* THE POSSIBILITY OF SUCH DAMAGE. * THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#if defined(__FreeBSD__) #if defined(__FreeBSD__) && !defined(__Userspace__)
#include <sys/cdefs.h> #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 #endif
#ifndef _NETINET_SCTP_ASCONF_H_ #ifndef _NETINET_SCTP_ASCONF_H_
...@@ -58,8 +58,8 @@ sctp_handle_asconf_ack(struct mbuf *, int, struct sctp_asconf_ack_chunk *, ...@@ -58,8 +58,8 @@ sctp_handle_asconf_ack(struct mbuf *, int, struct sctp_asconf_ack_chunk *,
struct sctp_tcb *, struct sctp_nets *, int *); struct sctp_tcb *, struct sctp_nets *, int *);
extern uint32_t extern uint32_t
sctp_addr_mgmt_ep_sa(struct sctp_inpcb *, struct sockaddr *, sctp_addr_mgmt_ep_sa(struct sctp_inpcb *, struct sockaddr *, uint32_t,
uint32_t, uint32_t, struct sctp_ifa *); uint32_t);
extern int sctp_asconf_iterator_ep(struct sctp_inpcb *inp, void *ptr, extern int sctp_asconf_iterator_ep(struct sctp_inpcb *inp, void *ptr,
......
...@@ -32,9 +32,9 @@ ...@@ -32,9 +32,9 @@
* THE POSSIBILITY OF SUCH DAMAGE. * THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#if defined(__FreeBSD__) #if defined(__FreeBSD__) && !defined(__Userspace__)
#include <sys/cdefs.h> #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 #endif
#include <netinet/sctp_os.h> #include <netinet/sctp_os.h>
...@@ -567,11 +567,7 @@ sctp_auth_key_acquire(struct sctp_tcb *stcb, uint16_t key_id) ...@@ -567,11 +567,7 @@ sctp_auth_key_acquire(struct sctp_tcb *stcb, uint16_t key_id)
} }
void void
sctp_auth_key_release(struct sctp_tcb *stcb, uint16_t key_id, int so_locked sctp_auth_key_release(struct sctp_tcb *stcb, uint16_t key_id, int so_locked)
#if !defined(__APPLE__)
SCTP_UNUSED
#endif
)
{ {
sctp_sharedkey_t *skey; sctp_sharedkey_t *skey;
...@@ -1749,11 +1745,7 @@ sctp_handle_auth(struct sctp_tcb *stcb, struct sctp_auth_chunk *auth, ...@@ -1749,11 +1745,7 @@ sctp_handle_auth(struct sctp_tcb *stcb, struct sctp_auth_chunk *auth,
*/ */
void void
sctp_notify_authentication(struct sctp_tcb *stcb, uint32_t indication, sctp_notify_authentication(struct sctp_tcb *stcb, uint32_t indication,
uint16_t keyid, uint16_t alt_keyid, int so_locked uint16_t keyid, uint16_t alt_keyid, int so_locked)
#if !defined(__APPLE__)
SCTP_UNUSED
#endif
)
{ {
struct mbuf *m_notify; struct mbuf *m_notify;
struct sctp_authkey_event *auth; struct sctp_authkey_event *auth;
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
* THE POSSIBILITY OF SUCH DAMAGE. * THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#if defined(__FreeBSD__) #if defined(__FreeBSD__) && !defined(__Userspace__)
#include <sys/cdefs.h> #include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet/sctp_auth.h 338749 2018-09-18 10:53:07Z tuexen $"); __FBSDID("$FreeBSD: head/sys/netinet/sctp_auth.h 338749 2018-09-18 10:53:07Z tuexen $");
#endif #endif
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
* THE POSSIBILITY OF SUCH DAMAGE. * THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#if defined(__FreeBSD__) #if defined(__FreeBSD__) && !defined(__Userspace__)
#include <sys/cdefs.h> #include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet/sctp_bsd_addr.c 358080 2020-02-18 19:41:55Z tuexen $"); __FBSDID("$FreeBSD: head/sys/netinet/sctp_bsd_addr.c 358080 2020-02-18 19:41:55Z tuexen $");
#endif #endif
...@@ -50,7 +50,7 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_bsd_addr.c 358080 2020-02-18 19:41:55Z ...@@ -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_asconf.h>
#include <netinet/sctp_sysctl.h> #include <netinet/sctp_sysctl.h>
#include <netinet/sctp_indata.h> #include <netinet/sctp_indata.h>
#if defined(__FreeBSD__) #if defined(__FreeBSD__) && !defined(__Userspace__)
#include <sys/unistd.h> #include <sys/unistd.h>
#endif #endif
...@@ -79,7 +79,7 @@ MALLOC_DEFINE(SCTP_M_MCORE, "sctp_mcore", "sctp mcore queue"); ...@@ -79,7 +79,7 @@ MALLOC_DEFINE(SCTP_M_MCORE, "sctp_mcore", "sctp mcore queue");
/* Global NON-VNET structure that controls the iterator */ /* Global NON-VNET structure that controls the iterator */
struct iterator_control sctp_it_ctl; struct iterator_control sctp_it_ctl;
#if !defined(__FreeBSD__) #if !(defined(__FreeBSD__) && !defined(__Userspace__))
static void static void
sctp_cleanup_itqueue(void) sctp_cleanup_itqueue(void)
{ {
...@@ -107,7 +107,7 @@ void ...@@ -107,7 +107,7 @@ void
sctp_wakeup_iterator(void) sctp_wakeup_iterator(void)
{ {
#if defined(SCTP_PROCESS_LEVEL_LOCKS) #if defined(SCTP_PROCESS_LEVEL_LOCKS)
#if defined(__Userspace_os_Windows) #if defined(_WIN32)
WakeAllConditionVariable(&sctp_it_ctl.iterator_wakeup); WakeAllConditionVariable(&sctp_it_ctl.iterator_wakeup);
#else #else
pthread_cond_broadcast(&sctp_it_ctl.iterator_wakeup); pthread_cond_broadcast(&sctp_it_ctl.iterator_wakeup);
...@@ -129,7 +129,7 @@ sctp_iterator_thread(void *v SCTP_UNUSED) ...@@ -129,7 +129,7 @@ sctp_iterator_thread(void *v SCTP_UNUSED)
#endif #endif
SCTP_IPI_ITERATOR_WQ_LOCK(); SCTP_IPI_ITERATOR_WQ_LOCK();
/* In FreeBSD this thread never terminates. */ /* In FreeBSD this thread never terminates. */
#if defined(__FreeBSD__) #if defined(__FreeBSD__) && !defined(__Userspace__)
for (;;) { for (;;) {
#else #else
while ((sctp_it_ctl.iterator_flags & SCTP_ITERATOR_MUST_EXIT) == 0) { while ((sctp_it_ctl.iterator_flags & SCTP_ITERATOR_MUST_EXIT) == 0) {
...@@ -138,25 +138,25 @@ sctp_iterator_thread(void *v SCTP_UNUSED) ...@@ -138,25 +138,25 @@ sctp_iterator_thread(void *v SCTP_UNUSED)
msleep(&sctp_it_ctl.iterator_running, msleep(&sctp_it_ctl.iterator_running,
#if defined(__FreeBSD__) #if defined(__FreeBSD__)
&sctp_it_ctl.ipi_iterator_wq_mtx, &sctp_it_ctl.ipi_iterator_wq_mtx,
#elif defined(__APPLE__) || defined(__Userspace_os_Darwin) #elif defined(__APPLE__)
sctp_it_ctl.ipi_iterator_wq_mtx, sctp_it_ctl.ipi_iterator_wq_mtx,
#endif #endif
0, "waiting_for_work", 0); 0, "waiting_for_work", 0);
#else #else
#if defined(__Userspace_os_Windows) #if defined(_WIN32)
SleepConditionVariableCS(&sctp_it_ctl.iterator_wakeup, &sctp_it_ctl.ipi_iterator_wq_mtx, INFINITE); SleepConditionVariableCS(&sctp_it_ctl.iterator_wakeup, &sctp_it_ctl.ipi_iterator_wq_mtx, INFINITE);
#else #else
pthread_cond_wait(&sctp_it_ctl.iterator_wakeup, &sctp_it_ctl.ipi_iterator_wq_mtx); pthread_cond_wait(&sctp_it_ctl.iterator_wakeup, &sctp_it_ctl.ipi_iterator_wq_mtx);
#endif #endif
#endif #endif
#if !defined(__FreeBSD__) #if !(defined(__FreeBSD__) && !defined(__Userspace__))
if (sctp_it_ctl.iterator_flags & SCTP_ITERATOR_MUST_EXIT) { if (sctp_it_ctl.iterator_flags & SCTP_ITERATOR_MUST_EXIT) {
break; break;
} }
#endif #endif
sctp_iterator_worker(); sctp_iterator_worker();
} }
#if !defined(__FreeBSD__) #if !(defined(__FreeBSD__) && !defined(__Userspace__))
/* Now this thread needs to be terminated */ /* Now this thread needs to be terminated */
sctp_cleanup_itqueue(); sctp_cleanup_itqueue();
sctp_it_ctl.iterator_flags |= SCTP_ITERATOR_EXITED; sctp_it_ctl.iterator_flags |= SCTP_ITERATOR_EXITED;
...@@ -185,7 +185,13 @@ sctp_startup_iterator(void) ...@@ -185,7 +185,13 @@ sctp_startup_iterator(void)
SCTP_ITERATOR_LOCK_INIT(); SCTP_ITERATOR_LOCK_INIT();
SCTP_IPI_ITERATOR_WQ_INIT(); SCTP_IPI_ITERATOR_WQ_INIT();
TAILQ_INIT(&sctp_it_ctl.iteratorhead); 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, kproc_create(sctp_iterator_thread,
(void *)NULL, (void *)NULL,
&sctp_it_ctl.thread_proc, &sctp_it_ctl.thread_proc,
...@@ -194,12 +200,6 @@ sctp_startup_iterator(void) ...@@ -194,12 +200,6 @@ sctp_startup_iterator(void)
SCTP_KTRHEAD_NAME); SCTP_KTRHEAD_NAME);
#elif defined(__APPLE__) #elif defined(__APPLE__)
kernel_thread_start((thread_continue_t)sctp_iterator_thread, NULL, &sctp_it_ctl.thread_proc); 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 #endif
} }
...@@ -252,7 +252,7 @@ sctp_is_desired_interface_type(struct ifnet *ifn) ...@@ -252,7 +252,7 @@ sctp_is_desired_interface_type(struct ifnet *ifn)
int result; int result;
/* check the interface type to see if it's one we care about */ /* 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)) { switch(ifnet_type(ifn)) {
#else #else
switch (ifn->if_type) { switch (ifn->if_type) {
...@@ -278,7 +278,7 @@ sctp_is_desired_interface_type(struct ifnet *ifn) ...@@ -278,7 +278,7 @@ sctp_is_desired_interface_type(struct ifnet *ifn)
case IFT_GIF: case IFT_GIF:
case IFT_L2VLAN: case IFT_L2VLAN:
case IFT_STF: case IFT_STF:
#if !defined(__APPLE__) #if !(defined(__APPLE__) && !defined(__Userspace__))
case IFT_IP: case IFT_IP:
case IFT_IPOVERCDLC: case IFT_IPOVERCDLC:
case IFT_IPOVERCLAW: case IFT_IPOVERCLAW:
...@@ -295,7 +295,7 @@ sctp_is_desired_interface_type(struct ifnet *ifn) ...@@ -295,7 +295,7 @@ sctp_is_desired_interface_type(struct ifnet *ifn)
} }
#endif #endif
#if defined(__APPLE__) #if defined(__APPLE__) && !defined(__Userspace__)
int int
sctp_is_vmware_interface(struct ifnet *ifn) sctp_is_vmware_interface(struct ifnet *ifn)
{ {
...@@ -303,7 +303,7 @@ sctp_is_vmware_interface(struct ifnet *ifn) ...@@ -303,7 +303,7 @@ sctp_is_vmware_interface(struct ifnet *ifn)
} }
#endif #endif
#if defined(__Userspace_os_Windows) #if defined(_WIN32) && defined(__Userspace__)
#ifdef MALLOC #ifdef MALLOC
#undef MALLOC #undef MALLOC
#define MALLOC(x) HeapAlloc(GetProcessHeap(), 0, (x)) #define MALLOC(x) HeapAlloc(GetProcessHeap(), 0, (x))
...@@ -477,7 +477,7 @@ sctp_init_ifns_for_vrf(int vrfid) ...@@ -477,7 +477,7 @@ sctp_init_ifns_for_vrf(int vrfid)
} }
#endif #endif
#if defined(__APPLE__) #if defined(__APPLE__) && !defined(__Userspace__)
static void static void
sctp_init_ifns_for_vrf(int vrfid) sctp_init_ifns_for_vrf(int vrfid)
{ {
...@@ -556,7 +556,7 @@ sctp_init_ifns_for_vrf(int vrfid) ...@@ -556,7 +556,7 @@ sctp_init_ifns_for_vrf(int vrfid)
} }
#endif #endif
#if defined(__FreeBSD__) #if defined(__FreeBSD__) && !defined(__Userspace__)
static void static void
sctp_init_ifns_for_vrf(int vrfid) sctp_init_ifns_for_vrf(int vrfid)
{ {
...@@ -712,7 +712,7 @@ sctp_addr_change(struct ifaddr *ifa, int cmd) ...@@ -712,7 +712,7 @@ sctp_addr_change(struct ifaddr *ifa, int cmd)
} }
if (cmd == RTM_ADD) { if (cmd == RTM_ADD) {
(void)sctp_add_addr_to_vrf(SCTP_DEFAULT_VRFID, (void *)ifa->ifa_ifp, (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), ifnet_index(ifa->ifa_ifp), ifnet_type(ifa->ifa_ifp), ifnet_name(ifa->ifa_ifp),
#else #else
ifa->ifa_ifp->if_index, ifa->ifa_ifp->if_type, ifa->ifa_ifp->if_xname, 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) ...@@ -721,7 +721,7 @@ sctp_addr_change(struct ifaddr *ifa, int cmd)
} else { } else {
sctp_del_addr_from_vrf(SCTP_DEFAULT_VRFID, ifa->ifa_addr, 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_index(ifa->ifa_ifp),
ifnet_name(ifa->ifa_ifp)); ifnet_name(ifa->ifa_ifp));
#else #else
...@@ -736,13 +736,13 @@ sctp_addr_change(struct ifaddr *ifa, int cmd) ...@@ -736,13 +736,13 @@ sctp_addr_change(struct ifaddr *ifa, int cmd)
#endif #endif
} }
#if defined(__FreeBSD__) #if defined(__FreeBSD__) && !defined(__Userspace__)
void void
sctp_addr_change_event_handler(void *arg __unused, struct ifaddr *ifa, int cmd) { sctp_addr_change_event_handler(void *arg __unused, struct ifaddr *ifa, int cmd) {
sctp_addr_change(ifa, cmd); sctp_addr_change(ifa, cmd);
} }
#endif #endif
#if defined(__APPLE__) #if defined(__APPLE__) && !defined(__Userspace__)
void void
sctp_add_or_del_interfaces(int (*pred)(struct ifnet *), int add) sctp_add_or_del_interfaces(int (*pred)(struct ifnet *), int add)
{ {
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
* THE POSSIBILITY OF SUCH DAMAGE. * THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#if defined(__FreeBSD__) #if defined(__FreeBSD__) && !defined(__Userspace__)
#include <sys/cdefs.h> #include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet/sctp_bsd_addr.h 353480 2019-10-13 18:17:08Z tuexen $"); __FBSDID("$FreeBSD: head/sys/netinet/sctp_bsd_addr.h 353480 2019-10-13 18:17:08Z tuexen $");
#endif #endif
...@@ -62,7 +62,7 @@ int sctp_copy_out_packet_log(uint8_t *target, int length); ...@@ -62,7 +62,7 @@ int sctp_copy_out_packet_log(uint8_t *target, int length);
#endif #endif
void sctp_addr_change(struct ifaddr *ifa, int cmd); 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); void sctp_addr_change_event_handler(void *, struct ifaddr *, int);
#endif #endif
......
...@@ -34,12 +34,12 @@ ...@@ -34,12 +34,12 @@
#if defined(__Userspace__) #if defined(__Userspace__)
#include <sys/types.h> #include <sys/types.h>
#if !defined (__Userspace_os_Windows) #if !defined(_WIN32)
#include <sys/wait.h> #include <sys/wait.h>
#include <unistd.h> #include <unistd.h>
#include <pthread.h> #include <pthread.h>
#endif #endif
#if defined(__Userspace_os_NaCl) #if defined(__native_client__)
#include <sys/select.h> #include <sys/select.h>
#endif #endif
#include <stdlib.h> #include <stdlib.h>
...@@ -180,7 +180,7 @@ sctp_handle_tick(uint32_t elapsed_ticks) ...@@ -180,7 +180,7 @@ sctp_handle_tick(uint32_t elapsed_ticks)
SCTP_TIMERQ_UNLOCK(); SCTP_TIMERQ_UNLOCK();
} }
#if defined(__APPLE__) #if defined(__APPLE__) && !defined(__Userspace__)
void void
sctp_timeout(void *arg SCTP_UNUSED) sctp_timeout(void *arg SCTP_UNUSED)
{ {
...@@ -197,7 +197,7 @@ user_sctp_timer_iterate(void *arg) ...@@ -197,7 +197,7 @@ user_sctp_timer_iterate(void *arg)
{ {
sctp_userspace_set_threadname("SCTP timer"); sctp_userspace_set_threadname("SCTP timer");
for (;;) { for (;;) {
#if defined (__Userspace_os_Windows) #if defined(_WIN32)
Sleep(TIMEOUT_INTERVAL); Sleep(TIMEOUT_INTERVAL);
#else #else
struct timespec amount, remaining; struct timespec amount, remaining;
...@@ -217,7 +217,7 @@ user_sctp_timer_iterate(void *arg) ...@@ -217,7 +217,7 @@ user_sctp_timer_iterate(void *arg)
} }
void void
sctp_start_timer(void) sctp_start_timer_thread(void)
{ {
/* /*
* No need to do SCTP_TIMERQ_LOCK_INIT(); * No need to do SCTP_TIMERQ_LOCK_INIT();
...@@ -233,4 +233,17 @@ sctp_start_timer(void) ...@@ -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 #endif
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* SUCH DAMAGE. * SUCH DAMAGE.
*/ */
#if defined(__FreeBSD__) #if defined(__FreeBSD__) && !defined(__Userspace__)
#include <sys/cdefs.h> #include <sys/cdefs.h>
__FBSDID("$FreeBSD$"); __FBSDID("$FreeBSD$");
#endif #endif
...@@ -53,7 +53,7 @@ __FBSDID("$FreeBSD$"); ...@@ -53,7 +53,7 @@ __FBSDID("$FreeBSD$");
#define SCTP_TICKS_PER_FASTTIMO 20 /* called about every 20ms */ #define SCTP_TICKS_PER_FASTTIMO 20 /* called about every 20ms */
#if defined(__Userspace__) #if defined(__Userspace__)
#if defined(__Userspace_os_Windows) #if defined(_WIN32)
#define SCTP_TIMERQ_LOCK() EnterCriticalSection(&SCTP_BASE_VAR(timer_mtx)) #define SCTP_TIMERQ_LOCK() EnterCriticalSection(&SCTP_BASE_VAR(timer_mtx))
#define SCTP_TIMERQ_UNLOCK() LeaveCriticalSection(&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)) #define SCTP_TIMERQ_LOCK_INIT() InitializeCriticalSection(&SCTP_BASE_VAR(timer_mtx))
...@@ -95,6 +95,11 @@ int sctp_os_timer_stop(sctp_os_timer_t *); ...@@ -95,6 +95,11 @@ int sctp_os_timer_stop(sctp_os_timer_t *);
void sctp_handle_tick(uint32_t); void sctp_handle_tick(uint32_t);
#define SCTP_OS_TIMER_INIT sctp_os_timer_init #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_START sctp_os_timer_start
#define SCTP_OS_TIMER_STOP sctp_os_timer_stop #define SCTP_OS_TIMER_STOP sctp_os_timer_stop
/* MT FIXME: Is the following correct? */ /* MT FIXME: Is the following correct? */
...@@ -104,9 +109,10 @@ void sctp_handle_tick(uint32_t); ...@@ -104,9 +109,10 @@ void sctp_handle_tick(uint32_t);
#define SCTP_OS_TIMER_DEACTIVATE(tmr) ((tmr)->c_flags &= ~SCTP_CALLOUT_ACTIVE) #define SCTP_OS_TIMER_DEACTIVATE(tmr) ((tmr)->c_flags &= ~SCTP_CALLOUT_ACTIVE)
#if defined(__Userspace__) #if defined(__Userspace__)
void sctp_start_timer(void); void sctp_start_timer_thread(void);
void sctp_stop_timer_thread(void);
#endif #endif
#if defined(__APPLE__) #if defined(__APPLE__) && !defined(__Userspace__)
void sctp_timeout(void *); void sctp_timeout(void *);
#endif #endif
......
...@@ -32,15 +32,15 @@ ...@@ -32,15 +32,15 @@
* THE POSSIBILITY OF SUCH DAMAGE. * THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#if defined(__FreeBSD__) #if defined(__FreeBSD__) && !defined(__Userspace__)
#include <sys/cdefs.h> #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 #endif
#ifndef _NETINET_SCTP_CONSTANTS_H_ #ifndef _NETINET_SCTP_CONSTANTS_H_
#define _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); extern void getwintimeofday(struct timeval *tv);
#endif #endif
...@@ -563,7 +563,7 @@ extern void getwintimeofday(struct timeval *tv); ...@@ -563,7 +563,7 @@ extern void getwintimeofday(struct timeval *tv);
((t) < SCTP_TIMER_TYPE_LAST)) ((t) < SCTP_TIMER_TYPE_LAST))
#if defined(__APPLE__) #if defined(__APPLE__) && !defined(__Userspace__)
/* Number of ticks to run the main timer at in msec */ /* Number of ticks to run the main timer at in msec */
#define SCTP_MAIN_TIMER_DEFAULT 10 #define SCTP_MAIN_TIMER_DEFAULT 10
#endif #endif
...@@ -811,6 +811,7 @@ extern void getwintimeofday(struct timeval *tv); ...@@ -811,6 +811,7 @@ extern void getwintimeofday(struct timeval *tv);
#define SCTP_LOC_34 0x00000022 #define SCTP_LOC_34 0x00000022
#define SCTP_LOC_35 0x00000023 #define SCTP_LOC_35 0x00000023
#define SCTP_LOC_36 0x00000024 #define SCTP_LOC_36 0x00000024
#define SCTP_LOC_37 0x00000025
/* Free assoc codes */ /* Free assoc codes */
#define SCTP_NORMAL_PROC 0 #define SCTP_NORMAL_PROC 0
...@@ -857,7 +858,7 @@ extern void getwintimeofday(struct timeval *tv); ...@@ -857,7 +858,7 @@ extern void getwintimeofday(struct timeval *tv);
#define SCTP_CHUNKQUEUE_SCALE 10 #define SCTP_CHUNKQUEUE_SCALE 10
#endif #endif
#if defined(__FreeBSD__) #if defined(__FreeBSD__) && !defined(__Userspace__)
/* clock variance is 1 ms */ /* clock variance is 1 ms */
#define SCTP_CLOCK_GRANULARITY 1 #define SCTP_CLOCK_GRANULARITY 1
#else #else
...@@ -995,7 +996,7 @@ extern void getwintimeofday(struct timeval *tv); ...@@ -995,7 +996,7 @@ extern void getwintimeofday(struct timeval *tv);
#define SCTP_SOCKET_OPTION_LIMIT (64 * 1024) #define SCTP_SOCKET_OPTION_LIMIT (64 * 1024)
#if defined(__Userspace__) #if defined(__Userspace__)
#if defined(__Userspace_os_Windows) #if defined(_WIN32)
#define SCTP_GETTIME_TIMEVAL(x) getwintimeofday(x) #define SCTP_GETTIME_TIMEVAL(x) getwintimeofday(x)
#define SCTP_GETPTIME_TIMEVAL(x) getwintimeofday(x) /* this doesn't seem to ever be used.. */ #define SCTP_GETPTIME_TIMEVAL(x) getwintimeofday(x) /* this doesn't seem to ever be used.. */
#else #else
...@@ -1019,7 +1020,7 @@ do { \ ...@@ -1019,7 +1020,7 @@ do { \
} \ } \
} while (0) } while (0)
#if defined(__FreeBSD__) || defined(__Windows__) || defined(__Userspace__) #if defined(__FreeBSD__) || defined(_WIN32) || defined(__Userspace__)
#define sctp_sowwakeup_locked(inp, so) \ #define sctp_sowwakeup_locked(inp, so) \
do { \ do { \
if (inp->sctp_flags & SCTP_PCB_FLAGS_DONT_WAKE) { \ if (inp->sctp_flags & SCTP_PCB_FLAGS_DONT_WAKE) { \
...@@ -1050,7 +1051,7 @@ do { \ ...@@ -1050,7 +1051,7 @@ do { \
} \ } \
} while (0) } while (0)
#if defined(__FreeBSD__) || defined(__Windows__) || defined(__Userspace__) #if defined(__FreeBSD__) || defined(_WIN32) || defined(__Userspace__)
#define sctp_sorwakeup_locked(inp, so) \ #define sctp_sorwakeup_locked(inp, so) \
do { \ do { \
if (inp->sctp_flags & SCTP_PCB_FLAGS_DONT_WAKE) { \ if (inp->sctp_flags & SCTP_PCB_FLAGS_DONT_WAKE) { \
......
...@@ -32,26 +32,22 @@ ...@@ -32,26 +32,22 @@
* THE POSSIBILITY OF SUCH DAMAGE. * THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#if defined(__FreeBSD__) #if defined(__FreeBSD__) && !defined(__Userspace__)
#include <sys/cdefs.h> #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" #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/param.h>
#include <sys/systm.h> #include <sys/systm.h>
#include <sys/gsb_crc32.h>
#include <sys/mbuf.h> #include <sys/mbuf.h>
#include <netinet/sctp.h>
#include <netinet/sctp_crc32.h> #include <netinet/sctp_crc32.h>
#if defined(SCTP) || defined(SCTP_SUPPORT)
#include <netinet/sctp_os.h>
#include <netinet/sctp_pcb.h>
#endif #endif
#else #else
#include <netinet/sctp_os.h> #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 ...@@ -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> #include <netinet/sctp_pcb.h>
#endif #endif
#if !defined(__FreeBSD__) #if !(defined(__FreeBSD__) && !defined(__Userspace__))
/** /**
* *
* Routine Description: * Routine Description:
...@@ -799,8 +795,11 @@ sctp_calculate_cksum(struct mbuf *m, uint32_t offset) ...@@ -799,8 +795,11 @@ sctp_calculate_cksum(struct mbuf *m, uint32_t offset)
return (base); return (base);
} }
#if defined(__FreeBSD__) #if defined(__FreeBSD__) && !defined(__Userspace__)
#ifdef SCTP #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 * Compute and insert the SCTP checksum in network byte order for a given
* mbuf chain m which contains an SCTP packet starting at offset. * mbuf chain m which contains an SCTP packet starting at offset.
......
...@@ -32,9 +32,9 @@ ...@@ -32,9 +32,9 @@
* THE POSSIBILITY OF SUCH DAMAGE. * THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#if defined(__FreeBSD__) #if defined(__FreeBSD__) && !defined(__Userspace__)
#include <sys/cdefs.h> #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 #endif
#ifndef _NETINET_SCTP_CRC32_H_ #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 ...@@ -42,8 +42,8 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_crc32.h 327200 2017-12-26 12:35:02Z tu
#if defined(_KERNEL) #if defined(_KERNEL)
uint32_t sctp_calculate_cksum(struct mbuf *, uint32_t); uint32_t sctp_calculate_cksum(struct mbuf *, uint32_t);
#if defined(__FreeBSD__) #if defined(__FreeBSD__) && !defined(__Userspace__)
#ifdef SCTP #if defined(SCTP) || defined(SCTP_SUPPORT)
void sctp_delayed_cksum(struct mbuf *, uint32_t offset); void sctp_delayed_cksum(struct mbuf *, uint32_t offset);
#endif #endif
#endif #endif
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
* THE POSSIBILITY OF SUCH DAMAGE. * THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#if defined(__FreeBSD__) #if defined(__FreeBSD__) && !defined(__Userspace__)
#include <sys/cdefs.h> #include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet/sctp_header.h 309682 2016-12-07 19:30:59Z tuexen $"); __FBSDID("$FreeBSD: head/sys/netinet/sctp_header.h 309682 2016-12-07 19:30:59Z tuexen $");
#endif #endif
...@@ -40,16 +40,16 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_header.h 309682 2016-12-07 19:30:59Z t ...@@ -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_ #ifndef _NETINET_SCTP_HEADER_H_
#define _NETINET_SCTP_HEADER_H_ #define _NETINET_SCTP_HEADER_H_
#if defined(__Windows__) && !defined(__Userspace_os_Windows) #if defined(_WIN32) && !defined(__Userspace__)
#include <packon.h> #include <packon.h>
#endif #endif
#if !defined(__Userspace_os_Windows) #if !defined(_WIN32)
#include <sys/time.h> #include <sys/time.h>
#endif #endif
#include <netinet/sctp.h> #include <netinet/sctp.h>
#include <netinet/sctp_constants.h> #include <netinet/sctp_constants.h>
#if !defined(__Userspace_os_Windows) #if !defined(_WIN32)
#define SCTP_PACKED __attribute__((packed)) #define SCTP_PACKED __attribute__((packed))
#else #else
#pragma pack (push, 1) #pragma pack (push, 1)
...@@ -601,10 +601,10 @@ struct sctp_auth_chunk { ...@@ -601,10 +601,10 @@ struct sctp_auth_chunk {
#define SCTP_MIN_V4_OVERHEAD (sizeof(struct ip) + \ #define SCTP_MIN_V4_OVERHEAD (sizeof(struct ip) + \
sizeof(struct sctphdr)) sizeof(struct sctphdr))
#if defined(__Windows__) #if defined(_WIN32) && !defined(__Userspace__)
#include <packoff.h> #include <packoff.h>
#endif #endif
#if defined(__Userspace_os_Windows) #if defined(_WIN32) && defined(__Userspace__)
#pragma pack(pop) #pragma pack(pop)
#endif #endif
#undef SCTP_PACKED #undef SCTP_PACKED
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
* THE POSSIBILITY OF SUCH DAMAGE. * THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#if defined(__FreeBSD__) #if defined(__FreeBSD__) && !defined(__Userspace__)
#include <sys/cdefs.h> #include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet/sctp_indata.h 361116 2020-05-16 19:26:39Z tuexen $"); __FBSDID("$FreeBSD: head/sys/netinet/sctp_indata.h 361116 2020-05-16 19:26:39Z tuexen $");
#endif #endif
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
* THE POSSIBILITY OF SUCH DAMAGE. * THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#if defined(__FreeBSD__) #if defined(__FreeBSD__) && !defined(__Userspace__)
#include <sys/cdefs.h> #include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet/sctp_input.h 326672 2017-12-07 22:19:08Z tuexen $"); __FBSDID("$FreeBSD: head/sys/netinet/sctp_input.h 326672 2017-12-07 22:19:08Z tuexen $");
#endif #endif
...@@ -47,7 +47,7 @@ sctp_common_input_processing(struct mbuf **, int, int, int, ...@@ -47,7 +47,7 @@ sctp_common_input_processing(struct mbuf **, int, int, int,
struct sctphdr *, struct sctp_chunkhdr *, struct sctphdr *, struct sctp_chunkhdr *,
uint8_t, uint8_t,
uint8_t, uint8_t,
#if defined(__FreeBSD__) #if defined(__FreeBSD__) && !defined(__Userspace__)
uint8_t, uint32_t, uint16_t, uint8_t, uint32_t, uint16_t,
#endif #endif
uint32_t, uint16_t); uint32_t, uint16_t);
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
* THE POSSIBILITY OF SUCH DAMAGE. * THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#if defined(__FreeBSD__) #if defined(__FreeBSD__) && !defined(__Userspace__)
#include <sys/cdefs.h> #include <sys/cdefs.h>
__FBSDID("$FreeBSD$"); __FBSDID("$FreeBSD$");
#endif #endif
...@@ -76,6 +76,8 @@ __FBSDID("$FreeBSD$"); ...@@ -76,6 +76,8 @@ __FBSDID("$FreeBSD$");
#define SCTP_IPI_ADDR_WLOCK() #define SCTP_IPI_ADDR_WLOCK()
#define SCTP_IPI_ADDR_RUNLOCK() #define SCTP_IPI_ADDR_RUNLOCK()
#define SCTP_IPI_ADDR_WUNLOCK() #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_INIT()
#define SCTP_IPI_ITERATOR_WQ_DESTROY() #define SCTP_IPI_ITERATOR_WQ_DESTROY()
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
* THE POSSIBILITY OF SUCH DAMAGE. * THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#if defined(__FreeBSD__) #if defined(__FreeBSD__) && !defined(__Userspace__)
#include <sys/cdefs.h> #include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet/sctp_os.h 361872 2020-06-06 18:20:09Z tuexen $"); __FBSDID("$FreeBSD: head/sys/netinet/sctp_os.h 361872 2020-06-06 18:20:09Z tuexen $");
#endif #endif
...@@ -64,7 +64,7 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_os.h 361872 2020-06-06 18:20:09Z tuexe ...@@ -64,7 +64,7 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_os.h 361872 2020-06-06 18:20:09Z tuexe
* SCTP_ZONE_DESTROY(zone) * SCTP_ZONE_DESTROY(zone)
*/ */
#if defined(__FreeBSD__) #if defined(__FreeBSD__) && !defined(__Userspace__)
#include <netinet/sctp_os_bsd.h> #include <netinet/sctp_os_bsd.h>
#else #else
#define MODULE_GLOBAL(_B) (_B) #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 ...@@ -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> #include <netinet/sctp_os_userspace.h>
#endif #endif
#if defined(__APPLE__) #if defined(__APPLE__) && !defined(__Userspace__)
#include <netinet/sctp_os_macosx.h> #include <netinet/sctp_os_macosx.h>
#endif #endif
#if defined(__Windows__) #if defined(_WIN32) && !defined(__Userspace__)
#include <netinet/sctp_os_windows.h> #include <netinet/sctp_os_windows.h>
#endif #endif
......
...@@ -32,9 +32,9 @@ ...@@ -32,9 +32,9 @@
* THE POSSIBILITY OF SUCH DAMAGE. * THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#if defined(__FreeBSD__) #if defined(__FreeBSD__) && !defined(__Userspace__)
#include <sys/cdefs.h> #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 #endif
#ifndef _NETINET_SCTP_OUTPUT_H_ #ifndef _NETINET_SCTP_OUTPUT_H_
...@@ -78,11 +78,7 @@ int ...@@ -78,11 +78,7 @@ int
sctp_v4src_match_nexthop(struct sctp_ifa *sifa, sctp_route_t *ro); sctp_v4src_match_nexthop(struct sctp_ifa *sifa, sctp_route_t *ro);
#endif #endif
void sctp_send_initiate(struct sctp_inpcb *, struct sctp_tcb *, int void sctp_send_initiate(struct sctp_inpcb *, struct sctp_tcb *, int);
#if !defined(__APPLE__)
SCTP_UNUSED
#endif
);
void void
sctp_send_initiate_ack(struct sctp_inpcb *, struct sctp_tcb *, sctp_send_initiate_ack(struct sctp_inpcb *, struct sctp_tcb *,
...@@ -90,7 +86,7 @@ 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, int, int,
struct sockaddr *, struct sockaddr *, struct sockaddr *, struct sockaddr *,
struct sctphdr *, struct sctp_init_chunk *, struct sctphdr *, struct sctp_init_chunk *,
#if defined(__FreeBSD__) #if defined(__FreeBSD__) && !defined(__Userspace__)
uint8_t, uint32_t, uint8_t, uint32_t,
#endif #endif
uint32_t, uint16_t); uint32_t, uint16_t);
...@@ -124,7 +120,7 @@ void sctp_send_shutdown_complete(struct sctp_tcb *, struct sctp_nets *, int); ...@@ -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 *, void sctp_send_shutdown_complete2(struct sockaddr *, struct sockaddr *,
struct sctphdr *, struct sctphdr *,
#if defined(__FreeBSD__) #if defined(__FreeBSD__) && !defined(__Userspace__)
uint8_t, uint32_t, uint16_t, uint8_t, uint32_t, uint16_t,
#endif #endif
uint32_t, uint16_t); uint32_t, uint16_t);
...@@ -148,11 +144,11 @@ void sctp_move_chunks_from_net(struct sctp_tcb *stcb, struct sctp_nets *net); ...@@ -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_idata_chunk) : \
sizeof(struct sctp_data_chunk)) sizeof(struct sctp_data_chunk))
#if defined(__FreeBSD__) #if defined(__FreeBSD__) && !defined(__Userspace__)
int int
sctp_output(struct sctp_inpcb *, struct mbuf *, struct sockaddr *, sctp_output(struct sctp_inpcb *, struct mbuf *, struct sockaddr *,
struct mbuf *, struct thread *, int); struct mbuf *, struct thread *, int);
#elif defined(__Windows__) #elif defined(_WIN32) && !defined(__Userspace__)
sctp_output(struct sctp_inpcb *, struct mbuf *, struct sockaddr *, sctp_output(struct sctp_inpcb *, struct mbuf *, struct sockaddr *,
struct mbuf *, PKTHREAD, int); struct mbuf *, PKTHREAD, int);
#else #else
...@@ -167,16 +163,9 @@ sctp_output(struct sctp_inpcb *, ...@@ -167,16 +163,9 @@ sctp_output(struct sctp_inpcb *,
struct proc *, int); struct proc *, int);
#endif #endif
void sctp_chunk_output(struct sctp_inpcb *, struct sctp_tcb *, int, int void sctp_chunk_output(struct sctp_inpcb *, struct sctp_tcb *, int, int);
#if !defined(__APPLE__)
SCTP_UNUSED void sctp_send_abort_tcb(struct sctp_tcb *, struct mbuf *, int);
#endif
);
void sctp_send_abort_tcb(struct sctp_tcb *, struct mbuf *, int
#if !defined(__APPLE__)
SCTP_UNUSED
#endif
);
void send_forward_tsn(struct sctp_tcb *, struct sctp_association *); 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); ...@@ -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_ecn_echo(struct sctp_tcb *, struct sctp_nets *, uint32_t);
void void
sctp_send_packet_dropped(struct sctp_tcb *, struct sctp_nets *, struct mbuf *, sctp_send_packet_dropped(struct sctp_tcb *, struct sctp_nets *, struct mbuf *,
int, int, int); int, int, int);
...@@ -217,14 +205,14 @@ sctp_send_str_reset_req(struct sctp_tcb *, uint16_t , uint16_t *, ...@@ -217,14 +205,14 @@ sctp_send_str_reset_req(struct sctp_tcb *, uint16_t , uint16_t *,
void void
sctp_send_abort(struct mbuf *, int, struct sockaddr *, struct sockaddr *, sctp_send_abort(struct mbuf *, int, struct sockaddr *, struct sockaddr *,
struct sctphdr *, uint32_t, struct mbuf *, struct sctphdr *, uint32_t, struct mbuf *,
#if defined(__FreeBSD__) #if defined(__FreeBSD__) && !defined(__Userspace__)
uint8_t, uint32_t, uint16_t, uint8_t, uint32_t, uint16_t,
#endif #endif
uint32_t, uint16_t); uint32_t, uint16_t);
void sctp_send_operr_to(struct sockaddr *, struct sockaddr *, void sctp_send_operr_to(struct sockaddr *, struct sockaddr *,
struct sctphdr *, uint32_t, struct mbuf *, struct sctphdr *, uint32_t, struct mbuf *,
#if defined(__FreeBSD__) #if defined(__FreeBSD__) && !defined(__Userspace__)
uint8_t, uint32_t, uint16_t, uint8_t, uint32_t, uint16_t,
#endif #endif
uint32_t, uint16_t); uint32_t, uint16_t);
...@@ -238,13 +226,13 @@ sctp_sosend(struct socket *so, ...@@ -238,13 +226,13 @@ sctp_sosend(struct socket *so,
struct uio *uio, struct uio *uio,
struct mbuf *top, struct mbuf *top,
struct mbuf *control, struct mbuf *control,
#if defined(__APPLE__) #if defined(__APPLE__) && !defined(__Userspace__)
int flags int flags
#else #else
int flags, int flags,
#if defined(__FreeBSD__) #if defined(__FreeBSD__) && !defined(__Userspace__)
struct thread *p struct thread *p
#elif defined(__Windows__) #elif defined(_WIN32) && !defined(__Userspace__)
PKTHREAD p PKTHREAD p
#else #else
#if defined(__Userspace__) #if defined(__Userspace__)
......
...@@ -32,9 +32,9 @@ ...@@ -32,9 +32,9 @@
* THE POSSIBILITY OF SUCH DAMAGE. * THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#if defined(__FreeBSD__) #if defined(__FreeBSD__) && !defined(__Userspace__)
#include <sys/cdefs.h> #include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet/sctp_peeloff.c 337708 2018-08-13 13:58:45Z tuexen $"); __FBSDID("$FreeBSD: head/sys/netinet/sctp_peeloff.c 362054 2020-06-11 13:34:09Z tuexen $");
#endif #endif
#include <netinet/sctp_os.h> #include <netinet/sctp_os.h>
...@@ -49,10 +49,6 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_peeloff.c 337708 2018-08-13 13:58:45Z ...@@ -49,10 +49,6 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_peeloff.c 337708 2018-08-13 13:58:45Z
#include <netinet/sctputil.h> #include <netinet/sctputil.h>
#include <netinet/sctp_auth.h> #include <netinet/sctp_auth.h>
#if defined(__APPLE__)
#define APPLE_FILE_NO 5
#endif
int int
sctp_can_peel_off(struct socket *head, sctp_assoc_t assoc_id) sctp_can_peel_off(struct socket *head, sctp_assoc_t assoc_id)
{ {
...@@ -164,7 +160,7 @@ sctp_do_peeloff(struct socket *head, struct socket *so, sctp_assoc_t assoc_id) ...@@ -164,7 +160,7 @@ sctp_do_peeloff(struct socket *head, struct socket *so, sctp_assoc_t assoc_id)
atomic_add_int(&stcb->asoc.refcnt, 1); atomic_add_int(&stcb->asoc.refcnt, 1);
SCTP_TCB_UNLOCK(stcb); SCTP_TCB_UNLOCK(stcb);
#if defined(__FreeBSD__) #if defined(__FreeBSD__) && !defined(__Userspace__)
sctp_pull_off_control_to_new_inp(inp, n_inp, stcb, SBL_WAIT); sctp_pull_off_control_to_new_inp(inp, n_inp, stcb, SBL_WAIT);
#else #else
sctp_pull_off_control_to_new_inp(inp, n_inp, stcb, M_WAITOK); sctp_pull_off_control_to_new_inp(inp, n_inp, stcb, M_WAITOK);
...@@ -197,15 +193,15 @@ sctp_get_peeloff(struct socket *head, sctp_assoc_t assoc_id, int *error) ...@@ -197,15 +193,15 @@ sctp_get_peeloff(struct socket *head, sctp_assoc_t assoc_id, int *error)
} }
atomic_add_int(&stcb->asoc.refcnt, 1); atomic_add_int(&stcb->asoc.refcnt, 1);
SCTP_TCB_UNLOCK(stcb); SCTP_TCB_UNLOCK(stcb);
#if defined(__FreeBSD__) #if defined(__FreeBSD__) && !defined(__Userspace__)
CURVNET_SET(head->so_vnet); CURVNET_SET(head->so_vnet);
#endif #endif
newso = sonewconn(head, SS_ISCONNECTED newso = sonewconn(head, SS_ISCONNECTED
#if defined(__APPLE__) #if defined(__APPLE__) && !defined(__Userspace__)
, NULL , NULL
#endif #endif
); );
#if defined(__FreeBSD__) #if defined(__FreeBSD__) && !defined(__Userspace__)
CURVNET_RESTORE(); CURVNET_RESTORE();
#endif #endif
if (newso == NULL) { if (newso == NULL) {
...@@ -216,7 +212,7 @@ sctp_get_peeloff(struct socket *head, sctp_assoc_t assoc_id, int *error) ...@@ -216,7 +212,7 @@ sctp_get_peeloff(struct socket *head, sctp_assoc_t assoc_id, int *error)
return (NULL); return (NULL);
} }
#if defined(__APPLE__) #if defined(__APPLE__) && !defined(__Userspace__)
else { else {
SCTP_SOCKET_LOCK(newso, 1); SCTP_SOCKET_LOCK(newso, 1);
} }
...@@ -277,7 +273,6 @@ sctp_get_peeloff(struct socket *head, sctp_assoc_t assoc_id, int *error) ...@@ -277,7 +273,6 @@ sctp_get_peeloff(struct socket *head, sctp_assoc_t assoc_id, int *error)
SOCK_UNLOCK(newso); SOCK_UNLOCK(newso);
/* We remove it right away */ /* We remove it right away */
#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) || defined(__Userspace__)
#ifdef SCTP_LOCK_LOGGING #ifdef SCTP_LOCK_LOGGING
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LOCK_LOGGING_ENABLE) { if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LOCK_LOGGING_ENABLE) {
sctp_log_lock(inp, (struct sctp_tcb *)NULL, SCTP_LOG_LOCK_SOCK); sctp_log_lock(inp, (struct sctp_tcb *)NULL, SCTP_LOG_LOCK_SOCK);
...@@ -286,16 +281,6 @@ sctp_get_peeloff(struct socket *head, sctp_assoc_t assoc_id, int *error) ...@@ -286,16 +281,6 @@ sctp_get_peeloff(struct socket *head, sctp_assoc_t assoc_id, int *error)
TAILQ_REMOVE(&head->so_comp, newso, so_list); TAILQ_REMOVE(&head->so_comp, newso, so_list);
head->so_qlen--; head->so_qlen--;
SOCK_UNLOCK(head); SOCK_UNLOCK(head);
#else
newso = TAILQ_FIRST(&head->so_q);
if (soqremque(newso, 1) == 0) {
SCTP_PRINTF("soremque failed, peeloff-fails (invarients would panic)\n");
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PEELOFF, ENOTCONN);
*error = ENOTCONN;
return (NULL);
}
#endif
/* /*
* Now we must move it from one hash table to another and get the * Now we must move it from one hash table to another and get the
* stcb in the right place. * stcb in the right place.
...@@ -307,7 +292,7 @@ sctp_get_peeloff(struct socket *head, sctp_assoc_t assoc_id, int *error) ...@@ -307,7 +292,7 @@ sctp_get_peeloff(struct socket *head, sctp_assoc_t assoc_id, int *error)
* And now the final hack. We move data in the pending side i.e. * And now the final hack. We move data in the pending side i.e.
* head to the new socket buffer. Let the GRUBBING begin :-0 * head to the new socket buffer. Let the GRUBBING begin :-0
*/ */
#if defined(__FreeBSD__) #if defined(__FreeBSD__) && !defined(__Userspace__)
sctp_pull_off_control_to_new_inp(inp, n_inp, stcb, SBL_WAIT); sctp_pull_off_control_to_new_inp(inp, n_inp, stcb, SBL_WAIT);
#else #else
sctp_pull_off_control_to_new_inp(inp, n_inp, stcb, M_WAITOK); sctp_pull_off_control_to_new_inp(inp, n_inp, stcb, M_WAITOK);
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
* THE POSSIBILITY OF SUCH DAMAGE. * THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#if defined(__FreeBSD__) #if defined(__FreeBSD__) && !defined(__Userspace__)
#include <sys/cdefs.h> #include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet/sctp_peeloff.h 309607 2016-12-06 10:21:25Z tuexen $"); __FBSDID("$FreeBSD: head/sys/netinet/sctp_peeloff.h 309607 2016-12-06 10:21:25Z tuexen $");
#endif #endif
...@@ -42,13 +42,13 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_peeloff.h 309607 2016-12-06 10:21:25Z ...@@ -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) #if defined(HAVE_SCTP_PEELOFF_SOCKOPT)
/* socket option peeloff */ /* socket option peeloff */
struct sctp_peeloff_opt { struct sctp_peeloff_opt {
#if !defined(__Windows__) #if !(defined(_WIN32) && !defined(__Userspace__))
int s; int s;
#else #else
HANDLE s; HANDLE s;
#endif #endif
sctp_assoc_t assoc_id; sctp_assoc_t assoc_id;
#if !defined(__Windows__) #if !(defined(_WIN32) && !defined(__Userspace__))
int new_sd; int new_sd;
#else #else
HANDLE new_sd; HANDLE new_sd;
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
/*__Userspace__*/ /*__Userspace__*/
#include <stdlib.h> #include <stdlib.h>
#include <sys/types.h> #include <sys/types.h>
#if !defined (__Userspace_os_Windows) #if !defined(_WIN32)
#include <strings.h> #include <strings.h>
#include <stdint.h> #include <stdint.h>
#else #else
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论