Skip to content

Commit f4538e2

Browse files
committed
sctp: import internal copy of usrsctp library
There are problems with global shared state and no API stability guarantees, and we can't rely on distros shipping the fixes we need. Both firefox and Chrome bundle their own copies too. Imported from https://github.com/sctplab/usrsctp, commit 547d3b46c64876c0336b9eef297fda58dbe1adaf Date: Thu Jul 23 21:49:32 2020 +0200 Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/issues/870 Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1465>
1 parent fe3a0c2 commit f4538e2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+93498
-0
lines changed

.indentignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ext/sctp/usrsctp/usrsctplib/

ext/sctp/usrsctp/.gitignore

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# Object files
2+
*.o
3+
*.ko
4+
*.obj
5+
*.elf
6+
7+
# Precompiled Headers
8+
*.gch
9+
*.pch
10+
11+
# Libraries
12+
*.lib
13+
*.a
14+
*.la
15+
*.lo
16+
17+
# Shared objects (inc. Windows DLLs)
18+
*.dll
19+
*.so
20+
*.so.*
21+
*.dylib
22+
23+
# Executables
24+
*.exe
25+
*.out
26+
*.app
27+
*.i*86
28+
*.x86_64
29+
*.hex
30+
31+
# Debug files
32+
*.dSYM
33+
34+
# Automake and make releated stuff
35+
Makefile
36+
Makefile.in
37+
.deps
38+
.libs
39+
/autom4te.cache
40+
/aclocal.m4
41+
/compile
42+
/configure
43+
/depcomp
44+
/install-sh
45+
/missing
46+
/stamp-h1
47+
/config.guess
48+
/config.log
49+
/config.status
50+
/config.sub
51+
/libtool
52+
/ltmain.sh
53+
/m4
54+
/usrsctp.pc
55+
.dirstamp
56+
57+
# binaries
58+
programs/chargen_server_upcall
59+
programs/client
60+
programs/client_upcall
61+
programs/daytime_server
62+
programs/daytime_server_upcall
63+
programs/discard_server
64+
programs/discard_server_upcall
65+
programs/echo_server
66+
programs/echo_server_upcall
67+
programs/ekr_client
68+
programs/ekr_loop
69+
programs/ekr_loop_upcall
70+
programs/ekr_peer
71+
programs/ekr_server
72+
programs/http_client
73+
programs/http_client_upcall
74+
programs/rtcweb
75+
programs/st_client
76+
programs/tsctp
77+
programs/test_libmgmt
78+
programs/test_timer
79+
80+
# callgrind
81+
callgrind.out*
82+
83+
# cmake build
84+
/build

ext/sctp/usrsctp/LICENSE.md

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Copyright (c) 2015, Randall Stewart and Michael Tuexen
2+
All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without
5+
modification, are permitted provided that the following conditions are met:
6+
7+
* Redistributions of source code must retain the above copyright notice, this
8+
list of conditions and the following disclaimer.
9+
10+
* Redistributions in binary form must reproduce the above copyright notice,
11+
this list of conditions and the following disclaimer in the documentation
12+
and/or other materials provided with the distribution.
13+
14+
* Neither the name of usrsctp nor the names of its
15+
contributors may be used to endorse or promote products derived from
16+
this software without specific prior written permission.
17+
18+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

ext/sctp/usrsctp/meson.build

+220
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,220 @@
1+
# Project definition
2+
project('usrsctplib', 'c',
3+
version: '1.0.0',
4+
default_options: ['c_std=c99'],
5+
meson_version: '>=0.49.0')
6+
7+
# Set compiler warning flags
8+
compiler = meson.get_compiler('c')
9+
if compiler.get_argument_syntax() == 'msvc'
10+
compiler_args = compiler.get_supported_arguments([
11+
'/wd4100', # 'identifier' : unreferenced formal parameter
12+
'/wd4127', # conditional expression is constant
13+
'/wd4200', # nonstandard extension used : zero-sized array in struct/union
14+
'/wd4214', # bit field types other than int
15+
'/wd4706', # assignment within conditional expression
16+
'/wd4245', # 'conversion' : conversion from 'type1' to 'type2', signed/unsigned mismatch
17+
'/wd4389', # 'operator' : signed/unsigned mismatch
18+
'/wd4702', # unreachable code
19+
'/wd4701', # Potentially uninitialized local variable 'name' used
20+
'/wd4244', # 'conversion' conversion from 'type1' to 'type2', possible loss of data
21+
])
22+
else
23+
compiler_args = compiler.get_supported_arguments([
24+
'-pedantic',
25+
'-Wall',
26+
'-Wextra',
27+
'-Wfloat-equal',
28+
'-Wshadow',
29+
'-Wpointer-arith',
30+
'-Winit-self',
31+
'-Wno-unused-function',
32+
'-Wno-unused-parameter',
33+
'-Wno-unreachable-code',
34+
'-Wstrict-prototypes',
35+
])
36+
endif
37+
add_project_arguments(compiler_args, language: 'c')
38+
39+
# Configuration
40+
compile_args = []
41+
42+
# Dependency: Threads
43+
thread_dep = dependency('threads', required: true)
44+
45+
# Dependencies list
46+
dependencies = [
47+
thread_dep,
48+
]
49+
50+
# Global settings
51+
add_project_arguments([
52+
'-D__Userspace__',
53+
'-DSCTP_SIMPLE_ALLOCATOR',
54+
'-DSCTP_PROCESS_LEVEL_LOCKS',
55+
], language: 'c')
56+
57+
# OS-specific settings
58+
system = host_machine.system()
59+
if system in ['linux', 'android']
60+
add_project_arguments([
61+
'-D_GNU_SOURCE',
62+
], language: 'c')
63+
elif system == 'freebsd'
64+
add_project_arguments(compiler.get_supported_arguments([
65+
'-Wno-address-of-packed-member',
66+
]), language: 'c')
67+
elif system in ['darwin', 'ios']
68+
add_project_arguments([
69+
'-D__APPLE_USE_RFC_2292',
70+
] + compiler.get_supported_arguments([
71+
'-Wno-address-of-packed-member',
72+
'-Wno-deprecated-declarations',
73+
]), language: 'c')
74+
elif system == 'windows'
75+
dependencies += compiler.find_library('ws2_32', required: true)
76+
dependencies += compiler.find_library('iphlpapi', required: true)
77+
if compiler.get_id() == 'gcc'
78+
add_project_arguments(compiler.get_supported_arguments([
79+
'-Wno-format',
80+
'-D_WIN32_WINNT=0x601', # Enables inet_ntop and friends
81+
]), language: 'c')
82+
endif
83+
else
84+
error('Unknown system: @0@'.format(system))
85+
endif
86+
87+
# Feature: sys/queue
88+
if compiler.has_header('sys/queue.h')
89+
add_project_arguments('-DHAVE_SYS_QUEUE_H', language: 'c')
90+
endif
91+
92+
# Feature: sys/socket, linux/ifaddr, linux/rtnetlink
93+
if compiler.has_header('sys/socket.h')
94+
if compiler.has_header('linux/if_addr.h')
95+
add_project_arguments('-DHAVE_LINUX_IF_ADDR_H', language: 'c')
96+
endif
97+
98+
if compiler.has_header('linux/rtnetlink.h')
99+
add_project_arguments('-DHAVE_LINUX_RTNETLINK_H', language: 'c')
100+
endif
101+
endif
102+
103+
# Feature: ICMP
104+
have_sys_types = compiler.has_header('sys/types.h')
105+
have_netinet_in = compiler.has_header('netinet/in.h')
106+
have_netinet_ip = compiler.has_header('netinet/ip.h')
107+
have_netinet_ip_icmp = compiler.has_header('netinet/ip_icmp.h')
108+
if have_sys_types and have_netinet_in and have_netinet_ip and have_netinet_ip_icmp
109+
add_project_arguments('-DHAVE_NETINET_IP_ICMP_H', language: 'c')
110+
endif
111+
112+
# Feature: stdatomic
113+
if compiler.has_header('stdatomic.h')
114+
add_project_arguments('-DHAVE_STDATOMIC_H', language: 'c')
115+
endif
116+
117+
# Feature: sockaddr.sa_len
118+
prefix = '''
119+
#include <sys/types.h>
120+
#include <sys/socket.h>
121+
'''
122+
have_sa_len = compiler.has_member('struct sockaddr', 'sa_len', prefix: prefix)
123+
if have_sa_len
124+
add_project_arguments('-DHAVE_SA_LEN', language: 'c')
125+
endif
126+
127+
# Feature: sockaddr_in.sin_len / sockaddr_in6.sin6_len / sockaddr_conn.sconn_len
128+
prefix = '''
129+
#include <sys/types.h>
130+
#include <netinet/in.h>
131+
'''
132+
have_sin_len = compiler.has_member('struct sockaddr_in', 'sin_len', prefix: prefix)
133+
if have_sin_len
134+
add_project_arguments('-DHAVE_SIN_LEN', language: 'c')
135+
endif
136+
have_sin6_len = compiler.has_member('struct sockaddr_in6', 'sin6_len', prefix: prefix)
137+
if have_sin6_len
138+
add_project_arguments('-DHAVE_SIN6_LEN', language: 'c')
139+
endif
140+
have_sconn_len = compiler.has_member('struct sockaddr_conn', 'sconn_len', prefix: '#include "usrsctp.h"', include_directories: include_directories('usrsctplib'))
141+
if have_sconn_len
142+
add_project_arguments('-DHAVE_SCONN_LEN', language: 'c')
143+
endif
144+
145+
# Options
146+
if get_option('sctp_invariants')
147+
add_project_arguments('-DINVARIANTS', language: 'c')
148+
endif
149+
if get_option('sctp_debug')
150+
add_project_arguments('-DSCTP_DEBUG', language: 'c')
151+
compile_args += '-DSCTP_DEBUG'
152+
endif
153+
if get_option('sctp_inet')
154+
add_project_arguments('-DINET', language: 'c')
155+
endif
156+
if get_option('sctp_inet6')
157+
add_project_arguments('-DINET6', language: 'c')
158+
endif
159+
160+
# Library
161+
subdir('usrsctplib')
162+
163+
# Build library
164+
if compiler.get_id() == 'msvc' and get_option('default_library') == 'shared'
165+
# Needed by usrsctp_def
166+
find_program('dumpbin')
167+
168+
usrsctp_static = static_library('usrsctp-static', sources,
169+
dependencies: dependencies,
170+
include_directories: include_dirs)
171+
172+
usrsctp_def = custom_target('usrsctp.def',
173+
command: [find_program('gen-def.py'), '@INPUT@'],
174+
input: usrsctp_static,
175+
output: 'usrsctp.def',
176+
capture: true)
177+
178+
usrsctp = shared_library('usrsctp',
179+
link_whole: usrsctp_static,
180+
dependencies: dependencies,
181+
vs_module_defs: usrsctp_def,
182+
install: true,
183+
version: meson.project_version())
184+
else
185+
usrsctp = library('usrsctp', sources,
186+
dependencies: dependencies,
187+
include_directories: include_dirs,
188+
install: true,
189+
version: meson.project_version(),
190+
c_args: '-U__APPLE__')
191+
endif
192+
193+
# Declare dependency
194+
usrsctp_dep = declare_dependency(
195+
compile_args: compile_args,
196+
include_directories: include_dirs,
197+
link_with: usrsctp)
198+
199+
# Generate pkg-config file
200+
pkg = import('pkgconfig')
201+
pkg.generate(usrsctp,
202+
name: 'usrsctp',
203+
description: 'A portable SCTP userland stack',
204+
url: 'https://github.com/sctplab/usrsctp',
205+
extra_cflags: compile_args)
206+
207+
# Programs (optional)
208+
if get_option('sctp_build_programs')
209+
subdir('programs')
210+
211+
# Build executables
212+
foreach name, sources : programs
213+
executable(
214+
name,
215+
programs_helper_sources + sources,
216+
dependencies: dependencies,
217+
link_with: usrsctp,
218+
include_directories: include_dirs)
219+
endforeach
220+
endif

ext/sctp/usrsctp/meson_options.txt

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
option('sctp_invariants', type: 'boolean', value: false,
2+
description: 'Add runtime checks')
3+
option('sctp_debug', type: 'boolean', value: false,
4+
description: 'Provide debug information')
5+
option('sctp_inet', type: 'boolean', value: true,
6+
description: 'Support IPv4')
7+
option('sctp_inet6', type: 'boolean', value: true,
8+
description: 'Support IPv6')
9+
option('sctp_build_programs', type: 'boolean', value: true,
10+
description: 'Build example programs')

0 commit comments

Comments
 (0)