summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Klocek <michal.klocek@qt.io>2020-06-10 08:29:35 +0200
committerMichal Klocek <michal.klocek@qt.io>2020-06-10 14:34:50 +0000
commite7c84adad1b01719c076261aeb2ef01d24cede6d (patch)
treebbb2fc3ea20d97e542b0f0b19f7815d56e47b9c7
parent8d8aa95903c349b1b90316d09a8eb73fc7ba8fec (diff)
downloadqtwebengine-chromium-e7c84adad1b01719c076261aeb2ef01d24cede6d.tar.gz
[Backport] Security bug 1025302
Update usrsctp. Change-Id: I654a8e6521858fb09e90b649b6f694679eac6300 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
-rw-r--r--chromium/third_party/usrsctp/BUILD.gn9
-rw-r--r--chromium/third_party/usrsctp/README.chromium4
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/CMakeLists.txt106
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/Makefile.am6
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/Makefile.nmake90
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/Manual.md44
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/README.md3
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/configure.ac11
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CMakeLists.txt108
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5204536192401408bin0 -> 5728 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5634380847906816bin0 -> 944 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5645105154752512bin0 -> 92 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5649242005176320bin0 -> 85 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5649768725872640bin0 -> 62779 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5676652788449280bin0 -> 255 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5688015225094144bin0 -> 4148 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5722044720742400bin0 -> 4409 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5734997805236224bin0 -> 65532 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5736809862004736bin0 -> 5139 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5741506257747968bin0 -> 5287 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5759310927233024bin0 -> 3255 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_unconnected-5767885871382528bin0 -> 1024642 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-minimized-fuzzer_connect-5631709814456320bin0 -> 242 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-minimized-fuzzer_connect-5638658568224768bin0 -> 35209 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-minimized-fuzzer_connect-5675883720867840bin0 -> 1284 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-minimized-fuzzer_connect-5764087333519360bin0 -> 1271 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-minimized-fuzzer_unconnected-5639391992610816bin0 -> 1020106 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/crash-0a63175dc6b51474dc08197431ec36d11db5e77bbin0 -> 291 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/crash-27ffd53d682a7908bf7569e32d904f049066b5d6bin0 -> 444 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/data-1.binbin0 -> 16 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/init-ack-1.binbin0 -> 444 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/leak-00bd871f5ce0596083fe8642c803c97f424b0c70bin0 -> 1068 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000000bin0 -> 101 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000001bin0 -> 421 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000002bin0 -> 329 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000003bin0 -> 5 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000004bin0 -> 25 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000005bin0 -> 17 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000006bin0 -> 25 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000007bin0 -> 17 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000008bin0 -> 21 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000009bin0 -> 17 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000010bin0 -> 33 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000011bin0 -> 17 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000012bin0 -> 25 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000013bin0 -> 17 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000014bin0 -> 25 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000015bin0 -> 17 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000016bin0 -> 25 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000017bin0 -> 41 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000018bin0 -> 37 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000019bin0 -> 17 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000020bin0 -> 33 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000021bin0 -> 17 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000022bin0 -> 25 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000023bin0 -> 17 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000024bin0 -> 25 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000025bin0 -> 17 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000026bin0 -> 15 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000027bin0 -> 5 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000028bin0 -> 15 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/shutdown-1.binbin0 -> 8 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/shutdown-ack-1.binbin0 -> 4 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/shutdown-complete-1.binbin0 -> 4 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/timeout-00b96dd43f1251438bb44daa0a5a24ae4df5bce5bin0 -> 995 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000000bin0 -> 129 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000001bin0 -> 505 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000002bin0 -> 385 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000003bin0 -> 15 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000004bin0 -> 45 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000005bin0 -> 45 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000006bin0 -> 45 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000007bin0 -> 1041 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000008bin0 -> 1041 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000009bin0 -> 1041 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000010bin0 -> 1041 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000011bin0 -> 1041 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000012bin0 -> 45 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000013bin0 -> 17 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000014bin0 -> 17 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000015bin0 -> 17 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000016bin0 -> 17 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000017bin0 -> 9 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000018bin0 -> 15 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000019bin0 -> 5 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000020bin0 -> 137 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000021bin0 -> 529 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000022bin0 -> 401 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000023bin0 -> 15 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000024bin0 -> 45 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000025bin0 -> 45 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000026bin0 -> 45 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000027bin0 -> 1145 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000028bin0 -> 1361 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000029bin0 -> 929 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000030bin0 -> 45 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000031bin0 -> 1361 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000032bin0 -> 17 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000033bin0 -> 929 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000034bin0 -> 17 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000035bin0 -> 17 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000036bin0 -> 17 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000037bin0 -> 9 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000038bin0 -> 15 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000039bin0 -> 5 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000040bin0 -> 137 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000041bin0 -> 529 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000042bin0 -> 401 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000043bin0 -> 15 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000044bin0 -> 45 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000045bin0 -> 45 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000046bin0 -> 45 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000047bin0 -> 1205 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000048bin0 -> 1381 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000049bin0 -> 45 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000050bin0 -> 1029 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000051bin0 -> 1205 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000052bin0 -> 17 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000053bin0 -> 1205 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000054bin0 -> 17 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000055bin0 -> 17 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000056bin0 -> 9 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000057bin0 -> 15 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000058bin0 -> 5 bytes
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_LISTEN/init-1.binbin0 -> 108 bytes
-rwxr-xr-xchromium/third_party/usrsctp/usrsctplib/fuzzer/build-fuzzer.sh47
-rwxr-xr-xchromium/third_party/usrsctp/usrsctplib/fuzzer/check-input.sh56
-rwxr-xr-xchromium/third_party/usrsctp/usrsctplib/fuzzer/crashtest.py44
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/fuzzer_connect.c478
-rwxr-xr-xchromium/third_party/usrsctp/usrsctplib/fuzzer/fuzzer_connect_multi.sh22
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/fuzzer_listen.c170
-rwxr-xr-xchromium/third_party/usrsctp/usrsctplib/fuzzer/fuzzer_listen.sh5
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/fuzzer/pcap2corpus.c247
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/gen-def.py26
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/meson.build241
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/meson_options.txt10
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/programs/CMakeLists.txt36
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/programs/Makefile.am96
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/programs/Makefile.nmake312
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/programs/chargen_server_upcall.c231
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/programs/client.c215
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/programs/client_upcall.c340
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/programs/daytime_server.c16
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/programs/daytime_server_upcall.c148
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/programs/discard_server.c16
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/programs/discard_server_upcall.c234
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/programs/echo_server.c18
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/programs/echo_server_upcall.c251
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/programs/ekr_client.c13
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/programs/ekr_loop.c122
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/programs/ekr_loop_offload.c32
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/programs/ekr_loop_upcall.c589
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/programs/ekr_peer.c215
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/programs/ekr_server.c13
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/programs/http_client.c205
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/programs/http_client_upcall.c332
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/programs/meson.build29
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/programs/programs_helper.c339
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/programs/programs_helper.h87
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/programs/rtcweb.c31
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/programs/st_client.c379
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/programs/tsctp.c139
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/programs/tsctp_upcall.c760
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/usrsctplib/CMakeLists.txt36
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/usrsctplib/Makefile.nmake358
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/usrsctplib/meson.build20
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/meson.build20
-rwxr-xr-xchromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp.h8
-rwxr-xr-xchromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_asconf.c133
-rwxr-xr-xchromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_auth.c43
-rwxr-xr-xchromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_auth.h4
-rwxr-xr-xchromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_bsd_addr.c16
-rwxr-xr-xchromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_bsd_addr.h6
-rwxr-xr-xchromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_callout.c28
-rwxr-xr-xchromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_callout.h7
-rwxr-xr-xchromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_cc_functions.c16
-rwxr-xr-xchromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_constants.h17
-rwxr-xr-xchromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_crc32.c17
-rwxr-xr-xchromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_indata.c138
-rwxr-xr-xchromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_indata.h3
-rwxr-xr-xchromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_input.c346
-rwxr-xr-xchromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_os_userspace.h25
-rwxr-xr-xchromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_output.c633
-rwxr-xr-xchromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_output.h6
-rwxr-xr-xchromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_pcb.c116
-rwxr-xr-xchromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_pcb.h26
-rwxr-xr-xchromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_peeloff.c6
-rwxr-xr-xchromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_ss_functions.c47
-rwxr-xr-xchromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_structs.h4
-rwxr-xr-xchromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_sysctl.c154
-rwxr-xr-xchromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_sysctl.h49
-rwxr-xr-xchromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_timer.c19
-rwxr-xr-xchromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_uio.h38
-rwxr-xr-xchromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_userspace.c24
-rwxr-xr-xchromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_usrreq.c806
-rwxr-xr-xchromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_var.h2
-rwxr-xr-xchromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctputil.c302
-rwxr-xr-xchromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctputil.h15
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet6/meson.build1
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet6/sctp6_usrreq.c123
-rwxr-xr-xchromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet6/sctp6_var.h2
-rwxr-xr-xchromium/third_party/usrsctp/usrsctplib/usrsctplib/user_environment.c9
-rwxr-xr-xchromium/third_party/usrsctp/usrsctplib/usrsctplib/user_environment.h4
-rwxr-xr-xchromium/third_party/usrsctp/usrsctplib/usrsctplib/user_inpcb.h3
-rwxr-xr-xchromium/third_party/usrsctp/usrsctplib/usrsctplib/user_malloc.h2
-rwxr-xr-xchromium/third_party/usrsctp/usrsctplib/usrsctplib/user_mbuf.c4
-rwxr-xr-xchromium/third_party/usrsctp/usrsctplib/usrsctplib/user_recv_thread.c46
-rwxr-xr-xchromium/third_party/usrsctp/usrsctplib/usrsctplib/user_socket.c253
-rwxr-xr-xchromium/third_party/usrsctp/usrsctplib/usrsctplib/user_socketvar.h24
-rwxr-xr-xchromium/third_party/usrsctp/usrsctplib/usrsctplib/user_uma.h10
-rw-r--r--chromium/third_party/usrsctp/usrsctplib/usrsctplib/usrsctp.h49
211 files changed, 8302 insertions, 2641 deletions
diff --git a/chromium/third_party/usrsctp/BUILD.gn b/chromium/third_party/usrsctp/BUILD.gn
index 94f26786e1d..e8a5b1f9d41 100644
--- a/chromium/third_party/usrsctp/BUILD.gn
+++ b/chromium/third_party/usrsctp/BUILD.gn
@@ -21,6 +21,11 @@ config("usrsctp_warnings") {
# what they did in configure.ac. We can remove this once
# https://github.com/sctplab/usrsctp/issues/177 is fixed.
"-Wno-deprecated-declarations",
+
+ # usrsctp uses timingsafe_bcmp which is not available in all
+ # versions of OS X, however this isn't actually an issue since
+ # usrsctp provides its own implementation.
+ "-Wno-unguarded-availability",
]
}
}
@@ -140,7 +145,5 @@ static_library("usrsctp") {
if (is_fuchsia) {
defines += [ "__Userspace_os_Fuchsia" ]
}
- deps = [
- "//third_party/boringssl",
- ]
+ deps = [ "//third_party/boringssl" ]
}
diff --git a/chromium/third_party/usrsctp/README.chromium b/chromium/third_party/usrsctp/README.chromium
index 24b0bdf45f7..18ebfe0d998 100644
--- a/chromium/third_party/usrsctp/README.chromium
+++ b/chromium/third_party/usrsctp/README.chromium
@@ -1,8 +1,8 @@
Name: usrsctp
URL: http://github.com/sctplab/usrsctp
Version: 0
-Date: Jun 22, 2018
-Revision: 7a8bc9a90ca96634aa56ee712856d97f27d903f8
+Date: Feb 2, 2020
+Revision: bee946a606752a443bd70bca1cb296527fed706d
License: New BSD
License File: LICENSE
Security Critical: yes
diff --git a/chromium/third_party/usrsctp/usrsctplib/CMakeLists.txt b/chromium/third_party/usrsctp/usrsctplib/CMakeLists.txt
index acf5055a4e2..ba3b594eef2 100644
--- a/chromium/third_party/usrsctp/usrsctplib/CMakeLists.txt
+++ b/chromium/third_party/usrsctp/usrsctplib/CMakeLists.txt
@@ -1,6 +1,6 @@
#
# Copyright (C) 2015-2015 Oleg Alexeenkov
-# Copyright (C) 2015-2017 Felix Weinrank
+# Copyright (C) 2015-2019 Felix Weinrank
#
# All rights reserved.
#
@@ -29,7 +29,7 @@
# SUCH DAMAGE.
#
-project(usrsctplib)
+project(usrsctplib C)
cmake_minimum_required(VERSION 3.0)
# Debug build type as default
@@ -77,6 +77,8 @@ option(sctp_sanitizer_address "Compile with address sanitizer" 0)
option(sctp_sanitizer_memory "Compile with memory sanitizer" 0)
+option(sctp_build_fuzzer "Compile in clang fuzzing mode" 0)
+
if (sctp_sanitizer_address AND sctp_sanitizer_memory)
message(FATAL_ERROR "Can not compile with both sanitizer options")
endif ()
@@ -122,7 +124,7 @@ endif ()
# CHECK STRUCT MEMBERS
#################################################
-set(CMAKE_REQUIRED_INCLUDES "${CMAKE_SOURCE_DIR}/usrsctplib")
+set(CMAKE_REQUIRED_INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}/usrsctplib")
check_include_file(usrsctp.h have_usrsctp_h)
if (NOT have_usrsctp_h)
@@ -158,94 +160,112 @@ endif ()
# COMPILER SETTINGS
#################################################
+# Determine if compiler is Visual Studio compiler or Clang in MSVC compatible mode
+if (CMAKE_C_COMPILER_ID MATCHES "MSVC" OR CMAKE_C_SIMULATE_ID MATCHES "MSVC")
+ set(C_COMPILER_IS_MSVC_LIKE TRUE)
+endif()
+
+# SETTINGS FOR VISUAL STUDIO COMPILER
+if (C_COMPILER_IS_MSVC_LIKE)
+ if (CMAKE_C_FLAGS MATCHES "/W[0-4]")
+ string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
+ else ()
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4")
+ endif ()
+
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4100") # 'identifier' : unreferenced formal parameter
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4127") # conditional expression is constant
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4200") # nonstandard extension used : zero-sized array in struct/union
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4214") # bit field types other than int
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4706") # assignment within conditional expression
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4245") # 'conversion' : conversion from 'type1' to 'type2', signed/unsigned mismatch
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4389") # 'operator' : signed/unsigned mismatch
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4702") # unreachable code
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4701") # Potentially uninitialized local variable 'name' used
+
+ # ToDo
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4244") # 'conversion' conversion from 'type1' to 'type2', possible loss of data
+
+ if (sctp_werror)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX")
+
+ if (CMAKE_C_COMPILER_ID MATCHES "Clang")
+ # temporary disable exta clang warnings preventing compilation
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /clang:-Wno-unused-function")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /clang:-Wno-missing-field-initializers")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /clang:-Wno-sign-compare")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /clang:-Wno-format")
+ endif()
+ endif ()
# SETTINGS FOR UNIX COMPILER
-if ("${CMAKE_C_COMPILER_ID}" MATCHES "Clang" OR "${CMAKE_C_COMPILER_ID}" MATCHES "AppleClang" OR "${CMAKE_C_COMPILER_ID}" MATCHES "GNU")
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -pedantic -Wall -Wextra")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c99 -pedantic -Wall -Wextra")
+elseif (CMAKE_C_COMPILER_ID MATCHES "Clang" OR CMAKE_C_COMPILER_ID MATCHES "AppleClang" OR CMAKE_C_COMPILER_ID MATCHES "GNU")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -pedantic -Wall -Wextra")
check_c_compiler_flag(-Wfloat-equal has_wfloat_equal)
if (has_wfloat_equal)
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wfloat-equal")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wfloat-equal")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wfloat-equal")
endif ()
check_c_compiler_flag(-Wshadow has_wshadow)
if (has_wshadow)
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wshadow")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wshadow")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wshadow")
endif ()
check_c_compiler_flag(-Wpointer-arith has_wpointer_aritih)
if (has_wpointer_aritih)
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wpointer-arith")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wpointer-arith")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wpointer-arith")
endif ()
check_c_compiler_flag(-Wunreachable-code has_wunreachable_code)
if (has_wunreachable_code)
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wunreachable-code")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wunreachable-code")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wunreachable-code")
endif ()
check_c_compiler_flag(-Winit-self has_winit_self)
if (has_winit_self)
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Winit-self")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Winit-self")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Winit-self")
endif ()
check_c_compiler_flag(-Wno-unused-function has_wno_unused_function)
if (has_wno_unused_function)
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-function")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function")
endif ()
check_c_compiler_flag(-Wno-unused-parameter has_wno_unused_parameter)
if (has_wno_unused_parameter)
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-parameter")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-parameter")
endif ()
check_c_compiler_flag(-Wno-unreachable-code has_wno_unreachable_code)
if (has_wno_unreachable_code)
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unreachable-code")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unreachable-code")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unreachable-code")
endif ()
check_c_compiler_flag(-Wstrict-prototypes has_wstrict_prototypes)
if (has_wstrict_prototypes)
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wstrict-prototypes")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wstrict-prototypes")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wstrict-prototypes")
endif ()
if (sctp_werror)
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
endif ()
if (sctp_sanitizer_address)
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fno-omit-frame-pointer -g")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer -g")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address,undefined,signed-integer-overflow -fno-omit-frame-pointer -fno-sanitize-recover=all -fsanitize-address-use-after-scope ")
endif ()
if (sctp_sanitizer_memory)
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=memory -fno-omit-frame-pointer -g -fsanitize-memory-track-origins")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=memory -fno-omit-frame-pointer -g -fsanitize-memory-track-origins")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=memory -fno-omit-frame-pointer -fsanitize-memory-track-origins -fPIE")
endif ()
-endif ()
-# SETTINGS FOR VISUAL STUDIO COMPILER
-if ("x${CMAKE_C_COMPILER_ID}" STREQUAL "xMSVC")
- if (CMAKE_C_FLAGS MATCHES "/W[0-4]")
- string(REGEX REPLACE "/W[0-4]" "/W3" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
- else ()
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W3")
- endif ()
-
- if (WERROR)
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX")
+ if (sctp_build_fuzzer)
+ add_definitions(-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=fuzzer-no-link")
endif ()
endif ()
+message(STATUS "Compiler flags (CMAKE_C_FLAGS): ${CMAKE_C_FLAGS}")
+
#################################################
# INCLUDE SUBDIRS
@@ -256,3 +276,7 @@ add_subdirectory(usrsctplib)
if (sctp_build_programs)
add_subdirectory(programs)
endif ()
+
+if (sctp_build_fuzzer)
+ add_subdirectory(fuzzer)
+endif ()
diff --git a/chromium/third_party/usrsctp/usrsctplib/Makefile.am b/chromium/third_party/usrsctp/usrsctplib/Makefile.am
index e9e17e22c4f..4bd998fbe70 100644
--- a/chromium/third_party/usrsctp/usrsctplib/Makefile.am
+++ b/chromium/third_party/usrsctp/usrsctplib/Makefile.am
@@ -28,7 +28,11 @@
# SUCH DAMAGE.
#
-SUBDIRS = usrsctplib programs
+if COND_PROGRAMS
+MAYBEPROGRAMS = programs
+endif
+
+SUBDIRS = usrsctplib $(MAYBEPROGRAMS)
EXTRA_DIST = bootstrap Makefile.nmake
ACLOCAL_AMFLAGS = -I m4
# pkgconfig_DATA = usrsctp.pc
diff --git a/chromium/third_party/usrsctp/usrsctplib/Makefile.nmake b/chromium/third_party/usrsctp/usrsctplib/Makefile.nmake
index c439c8b3a71..6f9d7014784 100644
--- a/chromium/third_party/usrsctp/usrsctplib/Makefile.nmake
+++ b/chromium/third_party/usrsctp/usrsctplib/Makefile.nmake
@@ -1,45 +1,45 @@
-#
-# Copyright (C) 2011-2012 Michael Tuexen
-#
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-# 1. Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# 2. Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in the
-# documentation and/or other materials provided with the distribution.
-# 3. Neither the name of the project nor the names of its contributors
-# may be used to endorse or promote products derived from this software
-# without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
-# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-# ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
-# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-# SUCH DAMAGE.
-#
-
-all:
- cd usrsctplib
- nmake -f Makefile.nmake
- cd ..
- cd programs
- nmake all -f Makefile.nmake
- cd ..
-
-clean:
- cd usrsctplib
- nmake clean -f Makefile.nmake
- cd ..
- cd programs
- nmake clean -f Makefile.nmake
- cd ..
+#
+# Copyright (C) 2011-2012 Michael Tuexen
+#
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of the project nor the names of its contributors
+# may be used to endorse or promote products derived from this software
+# without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+
+all:
+ cd usrsctplib
+ nmake -f Makefile.nmake
+ cd ..
+ cd programs
+ nmake all -f Makefile.nmake
+ cd ..
+
+clean:
+ cd usrsctplib
+ nmake clean -f Makefile.nmake
+ cd ..
+ cd programs
+ nmake clean -f Makefile.nmake
+ cd ..
diff --git a/chromium/third_party/usrsctp/usrsctplib/Manual.md b/chromium/third_party/usrsctp/usrsctplib/Manual.md
index 7057368844d..e52fad748a9 100644
--- a/chromium/third_party/usrsctp/usrsctplib/Manual.md
+++ b/chromium/third_party/usrsctp/usrsctplib/Manual.md
@@ -4,7 +4,7 @@ SCTP is a message oriented, reliable transport protocol with direct support for
Like TCP, SCTP provides reliable, connection oriented data delivery with congestion control. Unlike TCP, SCTP also provides message boundary preservation, ordered and unordered message delivery, multi-streaming and multi-homing. Detection of data corruption, loss of data and duplication of data is achieved by using checksums and sequence numbers. A selective retransmission mechanism is applied to correct loss or corruption of data.
-In this manual the socket API for the SCTP User-land implementation will be described. It is based on [RFC 6458](http://tools.ietf.org/html/rfc6458). The main focus of this document is on pointing out the differences to the SCTP Sockets API. For all aspects of the sockets API that are not mentioned in this document, please refer to [RFC 6458](http://tools.ietf.org/html/rfc6458). Questions about SCTP itself can hopefully be answered by [RFC 4960](http://tools.ietf.org/html/rfc4960).
+In this manual the socket API for the SCTP User-land implementation will be described. It is based on [RFC 6458](https://tools.ietf.org/html/rfc6458). The main focus of this document is on pointing out the differences to the SCTP Sockets API. For all aspects of the sockets API that are not mentioned in this document, please refer to [RFC 6458](https://tools.ietf.org/html/rfc6458). Questions about SCTP itself can hopefully be answered by [RFC 4960](https://tools.ietf.org/html/rfc4960).
## Getting Started
The user-land stack has been tested on FreeBSD 10.0, Ubuntu 11.10, Windows 7, Mac OS X 10.6, and Mac OS X 10.7. The current version of the user-land stack is provided on [github](https://github.com/sctplab/usrsctp). Download the tarball and untar it in a folder of your choice. The tarball contains all the sources to build the libusrsctp, which has to be linked to the object file of an example program. In addition there are two applications in the folder `programs` that can be built and run.
@@ -133,12 +133,12 @@ usrsctp_socket(int domain,
void *ulp_info)
```
-The arguments taken from [RFC 6458](http://tools.ietf.org/html/rfc6458) are:
+The arguments taken from [RFC 6458](https://tools.ietf.org/html/rfc6458) are:
* domain: PF_INET or PF_INET6 can be used.
* type: In case of a one-to-many style socket it is SOCK_SEQPACKET, in case of a one-to-one style
socket it is SOCK_STREAM. For an explanation of the differences between the socket types please
-refer to [RFC 6458](http://tools.ietf.org/html/rfc6458).
+refer to [RFC 6458](https://tools.ietf.org/html/rfc6458).
* protocol: Set IPPROTO_SCTP.
In usrsctp, a callback API can be used.
@@ -161,7 +161,7 @@ Thus the only difference is the absence of a return code.
## Same Functionality as RFC 6458
The following functions have the same functionality as their kernel pendants. There prototypes
-are described in the following subsections. For a detailed description please refer to [RFC 6458](http://tools.ietf.org/html/rfc6458).
+are described in the following subsections. For a detailed description please refer to [RFC 6458](https://tools.ietf.org/html/rfc6458).
### usrsctp_bind()
@@ -237,7 +237,7 @@ usrsctp_shutdown(struct socket *so, int how)
`usrsctp_shutdown()` returns 0 on success and -1 in case of an error.
## Sending and Receiving Data
-Since the publication of [RFC 6458](http://tools.ietf.org/html/rfc6458) there is only one function for sending and one for receiving
+Since the publication of [RFC 6458](https://tools.ietf.org/html/rfc6458) there is only one function for sending and one for receiving
that is not deprecated. Therefore, only these two are described here.
### usrsctp_sendv()
@@ -260,14 +260,14 @@ usrsctp_sendv(struct socket *so,
* len: Length of the data.
* addrs: In this version of usrsctp at most one destination address is supported. In the case of a connected socket, the parameter `addrs` can be set to NULL.
* addrcnt: Number of addresses. As at most one address is supported, addrcnt is 0 if addrs is NULL and 1 otherwise.
-* info: Additional information for a message is stored in `void *info`. The data types `struct sctp_sndinfo`, `struct sctp_prinfo`, and `struct sctp_sendv_spa` are supported as defined in [RFC 6458](http://tools.ietf.org/html/rfc6458). Support for `struct sctp_authinfo` is not implemented yet, therefore, errno is set EINVAL and -1 will be returned, if it is used.
+* info: Additional information for a message is stored in `void *info`. The data types `struct sctp_sndinfo`, `struct sctp_prinfo`, and `struct sctp_sendv_spa` are supported as defined in [RFC 6458](https://tools.ietf.org/html/rfc6458). Support for `struct sctp_authinfo` is not implemented yet, therefore, errno is set EINVAL and -1 will be returned, if it is used.
* infolen: Length of info in bytes.
* infotype: Identifies the type of the information provided in info. Possible values are
* SCTP_SENDV_NOINFO
* SCTP_SENDV_SNDINFO
* SCTP_SENDV_PRINFO
- * SCTP_SENDV_SPA (For additional information please refer to [RFC 6458](http://tools.ietf.org/html/rfc6458).)
-* flags: Flags as described in [RFC 6458](http://tools.ietf.org/html/rfc6458).
+ * SCTP_SENDV_SPA (For additional information please refer to [RFC 6458](https://tools.ietf.org/html/rfc6458).)
+* flags: Flags as described in [RFC 6458](https://tools.ietf.org/html/rfc6458).
`usrsctp_sendv()` returns the number of bytes sent, or -1 if an error occurred. The variable errno is then set appropriately.
@@ -291,20 +291,20 @@ usrsctp_recvv(struct socket *so,
* len: Length of the buffer in bytes.
* from: A pointer to an address to be filled with the sender of the received message's address.
* fromlen: An in/out parameter describing the from length.
-* info: A pointer to the buffer to hold the attributes of the received message. The structure type of info is determined by the infotype parameter. The attributes returned in `info` have to be handled in the same way as specified in [RFC 6458](http://tools.ietf.org/html/rfc6458).
+* info: A pointer to the buffer to hold the attributes of the received message. The structure type of info is determined by the infotype parameter. The attributes returned in `info` have to be handled in the same way as specified in [RFC 6458](https://tools.ietf.org/html/rfc6458).
* infolen: An in/out parameter describing the size of the info buffer.
* infotype: On return, `*infotype` is set to the type of the info buffer. The current defined values are
* SCTP_RECVV_NOINFO
* SCTP_RECVV_RCVINFO
* SCTP_RECVV_NXTINFO
- * SCTP_RECVV_RN (A detailed description is given in [RFC 6458](http://tools.ietf.org/html/rfc6458))
+ * SCTP_RECVV_RN (A detailed description is given in [RFC 6458](https://tools.ietf.org/html/rfc6458))
* flags: A pointer to an integer to be filled with any message flags (e.g., `MSG_NOTIFICATION`). Note that this field is an in/out parameter. Options for the receive may also be passed into the value (e.g., `MSG_EOR`). Returning from the call, the flags' value will differ from its original value.
-`usrsctp_recvv()` returns the number of bytes sent, or -1 if an error occurred. The variable errno is then set appropriately.
+`usrsctp_recvv()` returns the number of bytes received, or -1 if an error occurred. The variable errno is then set appropriately.
## Socket Options
Socket options are used to change the default behavior of socket calls.
-Their behavior is specified in [RFC 6458](http://tools.ietf.org/html/rfc6458). The functions to get or set them are
+Their behavior is specified in [RFC 6458](https://tools.ietf.org/html/rfc6458). The functions to get or set them are
```c
int
@@ -375,7 +375,7 @@ SCTP_RESET_STREAMS | struct sctp_reset_streams | w
SCTP_RESET_ASSOC | struct sctp_assoc_t | w
SCTP_ADD_STREAMS | struct sctp_add_streams | w
-Further usage details are described in [RFC 6458](tools.ietf.org/html/rfc6458), [RFC 6525](tools.ietf.org/html/rfc6525), and [draft-ietf-tsvwg-sctp-udp-encaps-03](https://tools.ietf.org/html/draft-ietf-tsvwg-sctp-udp-encaps-03) (work in progress).
+Further usage details are described in [RFC 6458](https://tools.ietf.org/html/rfc6458), [RFC 6525](https://tools.ietf.org/html/rfc6525), and [draft-ietf-tsvwg-sctp-udp-encaps-03](https://tools.ietf.org/html/draft-ietf-tsvwg-sctp-udp-encaps-03) (work in progress).
## Sysctl variables
@@ -563,7 +563,7 @@ The congestion control should protect the network against fast senders.
Explicit congestion notifications are turned on by default.
#### usrsctp_sysctl_set_sctp_default_cc_module()
-This parameter sets the default algorithm for the congestion control. Default is 0, i.e. the one specified in [RFC 4960](http://tools.ietf.org/html/rfc4960).
+This parameter sets the default algorithm for the congestion control. Default is 0, i.e. the one specified in [RFC 4960](https://tools.ietf.org/html/rfc4960).
#### usrsctp_sysctl_set_sctp_initial_cwnd()
Set the initial congestion window in MTUs. The default is 3.
@@ -578,7 +578,7 @@ How many the sames it takes to try step down of cwnd. Default: 20
## Configure AUTH and ADD-IP
-An important extension of SCTP is the dynamic address reconfiguration (see [RFC 5061](http://tools.ietf.org/html/rfc5061)), also known as ADD-IP, which allows the changing of addresses during the lifetime of an association. For this feature the AUTH extension (see [RFC 4895](http://tools.ietf.org/html/rfc4895)) is necessary.
+An important extension of SCTP is the dynamic address reconfiguration (see [RFC 5061](https://tools.ietf.org/html/rfc5061)), also known as ADD-IP, which allows the changing of addresses during the lifetime of an association. For this feature the AUTH extension (see [RFC 4895](https://tools.ietf.org/html/rfc4895)) is necessary.
#### usrsctp_sysctl_set_sctp_auto_asconf()
If SCTP Auto-ASCONF is enabled, the peer is informed automatically when a new address
@@ -587,8 +587,8 @@ is added or removed. This feature is enabled by default.
#### usrsctp_sysctl_set_sctp_multiple_asconfs()
By default the sending of multiple ASCONFs is disabled.
-#### usrsctp_sysctl_set_sctp_auth_disable()
-The use of AUTH, which is normally turned on, can be disabled by setting this parameter to 1.
+#### usrsctp_sysctl_set_sctp_auth_enable()
+The use of AUTH, which is normally turned on, can be disabled by setting this parameter to 0.
#### usrsctp_sysctl_set_sctp_asconf_auth_nochk()
It is also possible to disable the requirement to use AUTH in conjunction with ADD-IP by setting this parameter
@@ -752,27 +752,27 @@ See https://github.com/sctplab/usrsctp/tree/master/programs
#### SCTP
R. Stewart:</br>
`Stream Control Transmission Protocol`.</br>
-[RFC 4960](http://tools.ietf.org/html/rfc4960), September 2007.
+[RFC 4960](https://tools.ietf.org/html/rfc4960), September 2007.
#### auth
M. Tüxen, R. Stewart, P. Lei, and E. Rescorla:</br>
`Authenticated Chunks for the Stream Control Transmission Protocol (SCTP)`.</br>
-[RFC 4895](http://tools.ietf.org/html/rfc4895), August 2007.
+[RFC 4895](https://tools.ietf.org/html/rfc4895), August 2007.
#### addip
R. Stewart, Q. Xie, M. Tüxen, S. Maruyama, and M. Kozuka:</br>
`Stream Control Transmission Protocol (SCTP) Dynamic Address Reconfiguration`.</br>
-[RFC 5061](http://tools.ietf.org/html/rfc5061), September 2007.
+[RFC 5061](https://tools.ietf.org/html/rfc5061), September 2007.
#### socketAPI
R. Stewart, M. Tüxen, K. Poon, and V. Yasevich:</br>
`Sockets API Extensions for the Stream Control Transmission Protocol (SCTP)`.</br>
-[RFC 6458](http://tools.ietf.org/html/rfc6458), Dezember 2011.
+[RFC 6458](https://tools.ietf.org/html/rfc6458), Dezember 2011.
#### streamReset
R. Stewart, M. Tüxen, and P. Lei:</br>
`Stream Control Transmission Protocol (SCTP) Stream Reconfiguration`.</br>
-[RFC 6525](http://tools.ietf.org/html/rfc6525), February 2012.
+[RFC 6525](https://tools.ietf.org/html/rfc6525), February 2012.
#### udpencaps
M. Tüxen and R. Stewart</br>
diff --git a/chromium/third_party/usrsctp/usrsctplib/README.md b/chromium/third_party/usrsctp/usrsctplib/README.md
index 0f0f8b16c51..1eea55eb25d 100644
--- a/chromium/third_party/usrsctp/usrsctplib/README.md
+++ b/chromium/third_party/usrsctp/usrsctplib/README.md
@@ -5,5 +5,4 @@ This is a userland SCTP stack supporting FreeBSD, Linux, Mac OS X and Windows.
See [manual](Manual.md) for more information.
-The status of continuous integration testing is available from [grid](http://212.201.121.110:18010/grid) and [waterfall](http://212.201.121.110:18010/waterfall).
-If you are only interested in a single branch, just append `?branch=BRANCHNAME` to the URL, for example [waterfall](http://212.201.121.110:18010/waterfall?branch=master).
+The status of continuous integration testing is available from our [Buildbot](http://buildbot.nplab.de:18010/#/console).
diff --git a/chromium/third_party/usrsctp/usrsctplib/configure.ac b/chromium/third_party/usrsctp/usrsctplib/configure.ac
index a6bfbd93d79..e24c37cb746 100644
--- a/chromium/third_party/usrsctp/usrsctplib/configure.ac
+++ b/chromium/third_party/usrsctp/usrsctplib/configure.ac
@@ -29,7 +29,7 @@ dnl SUCH DAMAGE.
dnl
AC_INIT([libusrsctp], [0.9.3.0])
-AM_INIT_AUTOMAKE
+AM_INIT_AUTOMAKE([foreign])
AC_PROG_CC
AC_PROG_LIBTOOL
@@ -61,7 +61,7 @@ freebsd*)
LIBCFLAGS="$LIBCFLAGS -U__FreeBSD__ -D__Userspace_os_FreeBSD"
;;
linux*)
- CFLAGS="$CFLAGS -std=c99 -pthread -D_GNU_SOURCE"
+ CFLAGS="$CFLAGS -std=c99 -pthread -D_GNU_SOURCE -Wno-address-of-packed-member"
LIBCFLAGS="$LIBCFLAGS -D__Userspace_os_Linux"
;;
netbsd*)
@@ -136,9 +136,7 @@ AC_ARG_ENABLE(programs,
AC_HELP_STRING( [--enable-programs],
[build example programs @<:@default=yes@:>@]),
enable_programs=$enableval,enable_programs=yes)
-if test x$enable_programs = xyes; then
- AC_CONFIG_FILES(programs/Makefile)
-fi
+AM_CONDITIONAL([COND_PROGRAMS], [test "$enable_programs" = yes])
AC_CHECK_TYPE(size_t)
AC_CHECK_TYPE(ssize_t)
@@ -192,4 +190,5 @@ AC_C_BIGENDIAN
AC_SUBST([LIBCFLAGS])
AC_SUBST([APPCFLAGS])
dnl AC_CONFIG_FILES([usrsctp.pc])
-AC_OUTPUT(Makefile usrsctplib/Makefile)
+AC_CONFIG_FILES(usrsctplib/Makefile programs/Makefile Makefile)
+AC_OUTPUT
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CMakeLists.txt b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CMakeLists.txt
new file mode 100644
index 00000000000..d60eb5dc87f
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CMakeLists.txt
@@ -0,0 +1,108 @@
+#
+# Copyright (C) 2015-2019 Felix Weinrank
+#
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of the project nor the names of its contributors
+# may be used to endorse or promote products derived from this software
+# without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+
+#project(usrsctp-fuzzer C)
+
+#################################################
+# INCLUDE MODULES
+#################################################
+
+include(CheckIncludeFile)
+
+
+#################################################
+# CHECK INCLUDES
+#################################################
+
+include_directories(${CMAKE_SOURCE_DIR}/usrsctplib)
+
+
+#################################################
+# OS DEPENDENT
+#################################################
+
+if (CMAKE_SYSTEM_NAME MATCHES "Linux")
+ add_definitions(-D_GNU_SOURCE)
+endif ()
+
+if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
+ add_definitions(-D__APPLE_USE_RFC_2292)
+endif ()
+
+#################################################
+# COMPILER FLAGS
+#################################################
+
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-gnu-zero-variadic-macro-arguments -Wno-unused-variable")
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=fuzzer")
+
+
+#################################################
+# PROGRAMS
+#################################################
+
+# FUZZING_STAGE LEVELS
+# 0 - MULTI - based on input
+# 1 - COOKIE_WAIT
+# 2 - COOKIE_ECHO
+# 3 - ESTABLISHED
+# 4 - DATA SENT
+# 5 - DATA RECEIVED
+
+add_executable(fuzzer_listen fuzzer_listen.c ../programs/programs_helper.c)
+target_link_libraries(fuzzer_listen usrsctp-static)
+
+add_executable(fuzzer_connect_multi fuzzer_connect.c ../programs/programs_helper.c)
+target_compile_definitions(fuzzer_connect_multi PRIVATE FUZZING_STAGE=0)
+target_link_libraries(fuzzer_connect_multi usrsctp-static)
+
+add_executable(fuzzer_connect_multi_verbose fuzzer_connect.c ../programs/programs_helper.c)
+target_compile_definitions(fuzzer_connect_multi_verbose PRIVATE FUZZING_STAGE=0 FUZZ_VERBOSE)
+target_link_libraries(fuzzer_connect_multi_verbose usrsctp-static)
+
+# add_executable(fuzzer_connect_cookie_wait fuzzer_connect.c)
+# target_compile_definitions(fuzzer_connect_cookie_wait PRIVATE FUZZING_STAGE=1)
+# target_link_libraries(fuzzer_connect_cookie_wait usrsctp-static)
+
+# add_executable(fuzzer_connect_cookie_echoed fuzzer_connect.c)
+# target_compile_definitions(fuzzer_connect_cookie_echoed PRIVATE FUZZING_STAGE=2)
+# target_link_libraries(fuzzer_connect_cookie_echoed usrsctp-static)
+
+# add_executable(fuzzer_connect_established fuzzer_connect.c)
+# target_compile_definitions(fuzzer_connect_established PRIVATE FUZZING_STAGE=3)
+# target_link_libraries(fuzzer_connect_established usrsctp-static)
+
+# add_executable(fuzzer_connect_data_sent fuzzer_connect.c)
+# target_compile_definitions(fuzzer_connect_data_sent PRIVATE FUZZING_STAGE=4)
+# target_link_libraries(fuzzer_connect_data_sent usrsctp-static)
+
+# add_executable(fuzzer_connect_data_received fuzzer_connect.c)
+# target_compile_definitions(fuzzer_connect_data_received PRIVATE FUZZING_STAGE=5)
+# target_link_libraries(fuzzer_connect_data_received usrsctp-static)
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5204536192401408 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5204536192401408
new file mode 100644
index 00000000000..d2ceb962fa2
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5204536192401408
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5634380847906816 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5634380847906816
new file mode 100644
index 00000000000..8c1eb515fb0
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5634380847906816
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5645105154752512 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5645105154752512
new file mode 100644
index 00000000000..0428a9dc927
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5645105154752512
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5649242005176320 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5649242005176320
new file mode 100644
index 00000000000..c6491cca312
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5649242005176320
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5649768725872640 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5649768725872640
new file mode 100644
index 00000000000..882b8a066e9
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5649768725872640
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5676652788449280 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5676652788449280
new file mode 100644
index 00000000000..fc85d8b818a
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5676652788449280
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5688015225094144 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5688015225094144
new file mode 100644
index 00000000000..918270eb29d
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5688015225094144
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5722044720742400 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5722044720742400
new file mode 100644
index 00000000000..79fd18eeb67
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5722044720742400
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5734997805236224 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5734997805236224
new file mode 100644
index 00000000000..74c273e75a2
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5734997805236224
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5736809862004736 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5736809862004736
new file mode 100644
index 00000000000..f5ef7a7b6e8
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5736809862004736
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5741506257747968 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5741506257747968
new file mode 100644
index 00000000000..ec037b34871
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5741506257747968
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5759310927233024 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5759310927233024
new file mode 100644
index 00000000000..bbe106608fe
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_connect-5759310927233024
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_unconnected-5767885871382528 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_unconnected-5767885871382528
new file mode 100644
index 00000000000..a082503f231
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-fuzzer_unconnected-5767885871382528
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-minimized-fuzzer_connect-5631709814456320 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-minimized-fuzzer_connect-5631709814456320
new file mode 100644
index 00000000000..6091098260a
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-minimized-fuzzer_connect-5631709814456320
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-minimized-fuzzer_connect-5638658568224768 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-minimized-fuzzer_connect-5638658568224768
new file mode 100644
index 00000000000..b7687888d7a
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-minimized-fuzzer_connect-5638658568224768
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-minimized-fuzzer_connect-5675883720867840 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-minimized-fuzzer_connect-5675883720867840
new file mode 100644
index 00000000000..2a19f47da5c
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-minimized-fuzzer_connect-5675883720867840
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-minimized-fuzzer_connect-5764087333519360 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-minimized-fuzzer_connect-5764087333519360
new file mode 100644
index 00000000000..6196fd6f652
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-minimized-fuzzer_connect-5764087333519360
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-minimized-fuzzer_unconnected-5639391992610816 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-minimized-fuzzer_unconnected-5639391992610816
new file mode 100644
index 00000000000..50cfe2a101b
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/clusterfuzz-testcase-minimized-fuzzer_unconnected-5639391992610816
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/crash-0a63175dc6b51474dc08197431ec36d11db5e77b b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/crash-0a63175dc6b51474dc08197431ec36d11db5e77b
new file mode 100644
index 00000000000..d90d892a497
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/crash-0a63175dc6b51474dc08197431ec36d11db5e77b
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/crash-27ffd53d682a7908bf7569e32d904f049066b5d6 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/crash-27ffd53d682a7908bf7569e32d904f049066b5d6
new file mode 100644
index 00000000000..640bdb9ff45
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/crash-27ffd53d682a7908bf7569e32d904f049066b5d6
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/data-1.bin b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/data-1.bin
new file mode 100644
index 00000000000..eea64c935de
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/data-1.bin
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/init-ack-1.bin b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/init-ack-1.bin
new file mode 100644
index 00000000000..89abce3ee75
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/init-ack-1.bin
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/leak-00bd871f5ce0596083fe8642c803c97f424b0c70 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/leak-00bd871f5ce0596083fe8642c803c97f424b0c70
new file mode 100644
index 00000000000..0ed6e7b5422
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/leak-00bd871f5ce0596083fe8642c803c97f424b0c70
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000000 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000000
new file mode 100644
index 00000000000..fd2da797fc8
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000000
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000001 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000001
new file mode 100644
index 00000000000..45b146bf4a1
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000001
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000002 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000002
new file mode 100644
index 00000000000..33e104dcb6a
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000002
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000003 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000003
new file mode 100644
index 00000000000..72b58fb68c5
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000003
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000004 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000004
new file mode 100644
index 00000000000..f2b4c32eca1
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000004
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000005 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000005
new file mode 100644
index 00000000000..1d90724b5f8
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000005
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000006 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000006
new file mode 100644
index 00000000000..dba0fb24237
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000006
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000007 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000007
new file mode 100644
index 00000000000..154b6f0a627
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000007
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000008 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000008
new file mode 100644
index 00000000000..820eadefb96
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000008
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000009 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000009
new file mode 100644
index 00000000000..5b06d525544
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000009
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000010 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000010
new file mode 100644
index 00000000000..31c58311366
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000010
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000011 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000011
new file mode 100644
index 00000000000..d43bd7ddbcf
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000011
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000012 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000012
new file mode 100644
index 00000000000..adea816bb77
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000012
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000013 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000013
new file mode 100644
index 00000000000..9e4a585f532
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000013
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000014 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000014
new file mode 100644
index 00000000000..f9b46492bcb
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000014
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000015 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000015
new file mode 100644
index 00000000000..3fedd69ae21
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000015
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000016 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000016
new file mode 100644
index 00000000000..dcb85000cdc
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000016
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000017 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000017
new file mode 100644
index 00000000000..5c32e8fd553
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000017
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000018 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000018
new file mode 100644
index 00000000000..cad34eb5969
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000018
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000019 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000019
new file mode 100644
index 00000000000..47925c52910
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000019
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000020 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000020
new file mode 100644
index 00000000000..c01b3cb2309
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000020
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000021 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000021
new file mode 100644
index 00000000000..7d12252c7e2
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000021
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000022 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000022
new file mode 100644
index 00000000000..1ca33f62ee2
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000022
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000023 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000023
new file mode 100644
index 00000000000..378395b1fef
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000023
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000024 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000024
new file mode 100644
index 00000000000..03e955a5d38
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000024
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000025 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000025
new file mode 100644
index 00000000000..572f005c1e0
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000025
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000026 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000026
new file mode 100644
index 00000000000..be5d773d6db
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000026
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000027 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000027
new file mode 100644
index 00000000000..a1da0f94b22
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000027
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000028 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000028
new file mode 100644
index 00000000000..8ff6e498647
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/rtcweb-000028
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/shutdown-1.bin b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/shutdown-1.bin
new file mode 100644
index 00000000000..27a757fba9f
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/shutdown-1.bin
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/shutdown-ack-1.bin b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/shutdown-ack-1.bin
new file mode 100644
index 00000000000..307a4f9d3c8
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/shutdown-ack-1.bin
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/shutdown-complete-1.bin b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/shutdown-complete-1.bin
new file mode 100644
index 00000000000..d1e11efca0b
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/shutdown-complete-1.bin
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/timeout-00b96dd43f1251438bb44daa0a5a24ae4df5bce5 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/timeout-00b96dd43f1251438bb44daa0a5a24ae4df5bce5
new file mode 100644
index 00000000000..0a8a27101ab
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/timeout-00b96dd43f1251438bb44daa0a5a24ae4df5bce5
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000000 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000000
new file mode 100644
index 00000000000..63a01fc4f99
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000000
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000001 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000001
new file mode 100644
index 00000000000..2db572e9e4c
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000001
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000002 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000002
new file mode 100644
index 00000000000..336a4481333
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000002
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000003 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000003
new file mode 100644
index 00000000000..737a802318a
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000003
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000004 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000004
new file mode 100644
index 00000000000..840eedf30e5
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000004
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000005 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000005
new file mode 100644
index 00000000000..e540d44eb18
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000005
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000006 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000006
new file mode 100644
index 00000000000..00019dc491c
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000006
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000007 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000007
new file mode 100644
index 00000000000..c7f499d34e6
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000007
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000008 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000008
new file mode 100644
index 00000000000..94d5c0bd002
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000008
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000009 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000009
new file mode 100644
index 00000000000..4d49f378e3f
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000009
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000010 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000010
new file mode 100644
index 00000000000..2829bb6aea8
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000010
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000011 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000011
new file mode 100644
index 00000000000..a39993144b1
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000011
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000012 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000012
new file mode 100644
index 00000000000..c81a1768b4a
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000012
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000013 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000013
new file mode 100644
index 00000000000..9457b75de69
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000013
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000014 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000014
new file mode 100644
index 00000000000..777f11b5a51
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000014
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000015 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000015
new file mode 100644
index 00000000000..e749a26e054
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000015
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000016 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000016
new file mode 100644
index 00000000000..ed8f9fc0a63
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000016
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000017 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000017
new file mode 100644
index 00000000000..1b15ab1999b
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000017
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000018 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000018
new file mode 100644
index 00000000000..634f886604e
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000018
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000019 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000019
new file mode 100644
index 00000000000..9f51d75c3e7
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000019
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000020 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000020
new file mode 100644
index 00000000000..69d60102b3d
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000020
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000021 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000021
new file mode 100644
index 00000000000..1c09a6b57b5
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000021
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000022 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000022
new file mode 100644
index 00000000000..22317e0ca15
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000022
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000023 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000023
new file mode 100644
index 00000000000..737a802318a
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000023
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000024 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000024
new file mode 100644
index 00000000000..b12abccdec7
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000024
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000025 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000025
new file mode 100644
index 00000000000..9afda34a7fd
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000025
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000026 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000026
new file mode 100644
index 00000000000..85ddaf14b49
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000026
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000027 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000027
new file mode 100644
index 00000000000..ce9027d9aa3
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000027
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000028 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000028
new file mode 100644
index 00000000000..be158357317
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000028
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000029 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000029
new file mode 100644
index 00000000000..e7338b70bbe
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000029
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000030 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000030
new file mode 100644
index 00000000000..21ee7c2f767
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000030
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000031 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000031
new file mode 100644
index 00000000000..bb605880b38
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000031
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000032 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000032
new file mode 100644
index 00000000000..77e2e6bdb84
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000032
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000033 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000033
new file mode 100644
index 00000000000..b6d636be8c7
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000033
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000034 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000034
new file mode 100644
index 00000000000..9ab1e1c797b
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000034
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000035 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000035
new file mode 100644
index 00000000000..8fb42d35a91
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000035
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000036 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000036
new file mode 100644
index 00000000000..cdd9e2b5c30
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000036
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000037 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000037
new file mode 100644
index 00000000000..e9db8bb4e78
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000037
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000038 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000038
new file mode 100644
index 00000000000..634f886604e
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000038
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000039 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000039
new file mode 100644
index 00000000000..9f51d75c3e7
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000039
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000040 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000040
new file mode 100644
index 00000000000..2e9f0c11aed
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000040
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000041 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000041
new file mode 100644
index 00000000000..25d1d45bf99
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000041
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000042 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000042
new file mode 100644
index 00000000000..5584a88fb6e
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000042
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000043 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000043
new file mode 100644
index 00000000000..737a802318a
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000043
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000044 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000044
new file mode 100644
index 00000000000..4c05e6ea138
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000044
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000045 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000045
new file mode 100644
index 00000000000..702654ceff4
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000045
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000046 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000046
new file mode 100644
index 00000000000..768a67182c5
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000046
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000047 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000047
new file mode 100644
index 00000000000..66de2ee5546
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000047
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000048 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000048
new file mode 100644
index 00000000000..6d54d1a8837
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000048
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000049 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000049
new file mode 100644
index 00000000000..8a3102f7990
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000049
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000050 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000050
new file mode 100644
index 00000000000..248cc34bc3a
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000050
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000051 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000051
new file mode 100644
index 00000000000..ae52418261a
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000051
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000052 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000052
new file mode 100644
index 00000000000..df60fbebe10
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000052
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000053 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000053
new file mode 100644
index 00000000000..2463c07b4b0
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000053
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000054 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000054
new file mode 100644
index 00000000000..443a1af192d
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000054
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000055 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000055
new file mode 100644
index 00000000000..fa44635c596
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000055
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000056 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000056
new file mode 100644
index 00000000000..077e89de83c
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000056
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000057 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000057
new file mode 100644
index 00000000000..634f886604e
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000057
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000058 b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000058
new file mode 100644
index 00000000000..9f51d75c3e7
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_CONNECT/tsctp-000058
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_LISTEN/init-1.bin b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_LISTEN/init-1.bin
new file mode 100644
index 00000000000..1bda440ebe4
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/CORPUS_LISTEN/init-1.bin
Binary files differ
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/build-fuzzer.sh b/chromium/third_party/usrsctp/usrsctplib/fuzzer/build-fuzzer.sh
new file mode 100755
index 00000000000..e6cb6bc7147
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/build-fuzzer.sh
@@ -0,0 +1,47 @@
+#!/usr/bin/env bash
+set -e
+
+NPROC=1
+
+# OS detection
+if [ "$(uname)" = "Linux" ]; then
+ NPROC=$(nproc)
+ CC=clang-9
+elif [ "$(uname)" = "Darwin" ]; then
+ NPROC=$(sysctl -n hw.ncpu)
+ CC=/usr/local/opt/llvm/bin/clang
+elif [ "$(uname)" = "FreeBSD" ]; then
+ NPROC=$(sysctl -n hw.ncpu)
+ CC=clang-devel
+else
+ echo "Error: $(uname) not supported, sorry!"
+ exit 1
+fi
+
+# Check if we have a compiler
+if ! [ -x "$(command -v $CC)" ]; then
+ echo "Error: $CC is not installed!" >&2
+ exit 1
+fi
+
+echo "OS :" $(uname)
+echo "CC :" $CC
+echo "NP :" $NPROC
+
+# Go to script directory
+SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
+cd "$SCRIPT_DIR"
+cd ".."
+
+pwd
+
+# Find and then delete all files under current directory (.) that:
+# 1. contains "cmake" (case-&insensitive) in its path (wholename)
+# 2. name is not CMakeLists.txt
+find . -iwholename '*cmake*' -not -name CMakeLists.txt -delete
+
+# Build with ASAN / MSAN
+cmake -Dsctp_build_fuzzer=1 -Dsctp_build_programs=0 -Dsctp_invariants=1 -Dsctp_sanitizer_address=1 -DCMAKE_LINKER="$CC" -DCMAKE_C_COMPILER="$CC" -DCMAKE_BUILD_TYPE=Debug .
+#cmake -Dsctp_build_fuzzer=1 -Dsctp_build_programs=0 -Dsctp_invariants=1 -Dsctp_sanitizer_memory=1 -DCMAKE_LINKER="$CC" -DCMAKE_C_COMPILER="$CC" -DCMAKE_BUILD_TYPE=RelWithDebInfo .
+
+make -j"$NPROC"
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/check-input.sh b/chromium/third_party/usrsctp/usrsctplib/fuzzer/check-input.sh
new file mode 100755
index 00000000000..31f117a0f55
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/check-input.sh
@@ -0,0 +1,56 @@
+#!/usr/bin/env bash
+
+#
+# usage: check-input.sh input_data
+#
+
+set -e # stop on error
+set -u # uinitialized variables -> error!
+
+#make
+
+C_RED='\033[0;31m' # RED
+C_GRN='\033[0;32m' # RED
+C_NOC='\033[0m' # No Color
+
+echo "Fuzzer Input: $1"
+echo "########## Beginning Fuzzer Chain"
+echo ""
+
+set +e
+./fuzzer_connect_multi_verbose -timeout=30 $1 > $1.log 2>&1
+FUZZER_RETVAL=$?
+set -e
+
+echo "Fuzzer returncode: $FUZZER_RETVAL"
+
+if [ "$FUZZER_RETVAL" -eq "0" ]; then
+ echo -e "$C_RED"
+ echo "$1 - NOT REPRODUCABLE"
+ echo -e "$C_NOC"
+elif [ "$FUZZER_RETVAL" -eq "77" ]; then
+ echo -e "$C_GRN"
+ echo "$1 - REPRODUCABLE"
+ echo -e "$C_NOC"
+else
+ echo "Unexpected return code: $FUZZER_RETVAL - handle with care..!"
+ #exit
+fi
+
+grep "# SCTP_PACKET" $1.log > $1.pcap-log
+text2pcap -n -l 248 -D -t "%H:%M:%S." $1.pcap-log $1.pcapng
+rm $1.pcap-log
+
+echo ""
+echo "LOG: $1.log"
+echo "PCAP: $1.pcapng"
+echo ""
+
+# Open Wireshark if we have an X session
+#if [ -z ${DISPLAY+x} ]; then
+ #echo "\$DISPLAY unset, skipping wireshark"
+#else
+ #wireshark $1.pcapng
+#fi
+
+exit $FUZZER_RETVAL
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/crashtest.py b/chromium/third_party/usrsctp/usrsctplib/fuzzer/crashtest.py
new file mode 100755
index 00000000000..ce51e0af061
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/crashtest.py
@@ -0,0 +1,44 @@
+#!/usr/bin/env python3
+import glob
+import subprocess
+import os
+import re
+
+reportdir = "reports/"
+fuzzer = "./fuzzer_connect_multi"
+
+class bcolors:
+ HEADER = '\033[95m'
+ OKBLUE = '\033[94m'
+ OKGREEN = '\033[92m'
+ WARNING = '\033[93m'
+ FAIL = '\033[91m'
+ ENDC = '\033[0m'
+ BOLD = '\033[1m'
+ UNDERLINE = '\033[4m'
+
+
+print("Testing crashfiles")
+
+FNULL = open(os.devnull, "w")
+crashfiles = []
+crashfiles.extend(glob.glob("*"))
+pattern = re.compile("^(leak-|timeout-|crash-)\w+$")
+
+filecounter = 1
+
+FNULL = open(os.devnull, 'w')
+
+for filename in crashfiles:
+
+ if not pattern.match(filename):
+ continue
+
+ fuzzer_retval = subprocess.call(["./check-input.sh", filename, "batchmode"], stdout=FNULL, stderr=subprocess.STDOUT)
+
+ if fuzzer_retval == 0:
+ print(bcolors.FAIL, "[", filecounter, "]", filename,"- not reproducable", bcolors.ENDC)
+ else:
+ print(bcolors.OKGREEN, "[", filecounter, "]", filename, "- reproducable", bcolors.ENDC)
+
+ filecounter = filecounter + 1
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/fuzzer_connect.c b/chromium/third_party/usrsctp/usrsctplib/fuzzer/fuzzer_connect.c
new file mode 100644
index 00000000000..79505db6e49
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/fuzzer_connect.c
@@ -0,0 +1,478 @@
+/*
+ * Copyright (C) 2017-2019 Felix Weinrank
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+#include <assert.h>
+#include <sys/time.h>
+#include <usrsctp.h>
+#include "../programs/programs_helper.h"
+
+//#define FUZZ_VERBOSE
+#define FUZZ_INTERLEAVING
+//#define FUZZ_EXPLICIT_EOR
+#define FUZZ_STREAM_RESET
+#define FUZZ_DISABLE_LINGER
+
+#define BUFFER_SIZE 4096
+#define COMMON_HEADER_SIZE 12
+
+static uint32_t assoc_vtag = 0;
+
+#ifdef FUZZ_VERBOSE
+#define fuzzer_printf(...) \
+ do { \
+ fprintf(stderr, "[P]"); \
+ debug_printf_runtime(); \
+ fprintf(stderr, __VA_ARGS__); \
+ } while (0)
+#else
+#define fuzzer_printf(...)
+#endif
+
+static void
+dump_packet(const void *buffer, size_t bufferlen, int inout) {
+#ifdef FUZZ_VERBOSE
+ static char *dump_buf;
+ if ((dump_buf = usrsctp_dumppacket(buffer, bufferlen, inout)) != NULL) {
+ fprintf(stderr, "%s", dump_buf);
+ usrsctp_freedumpbuffer(dump_buf);
+ }
+#endif // FUZZ_VERBOSE
+}
+
+static int
+conn_output(void *addr, void *buf, size_t length, uint8_t tos, uint8_t set_df)
+{
+ struct sctp_init_chunk *init_chunk;
+ const char *init_chunk_first_bytes = "\x13\x88\x13\x89\x00\x00\x00\x00\x00\x00\x00\x00\x01";
+ // Looking for the outgoing VTAG.
+ // length >= (COMMON_HEADER_SIZE + 16 (min size of INIT))
+ // If the common header has no VTAG (all zero), we're assuming it carries an INIT
+ if ((length >= (COMMON_HEADER_SIZE + 16)) && (memcmp(buf, init_chunk_first_bytes, COMMON_HEADER_SIZE) == 0)) {
+ init_chunk = (struct sctp_init_chunk*) ((char *)buf + sizeof(struct sctp_common_header));
+ fuzzer_printf("Found outgoing INIT, extracting VTAG : %u\n", init_chunk->initiate_tag);
+ assoc_vtag = init_chunk->initiate_tag;
+ }
+
+ dump_packet(buf, length, SCTP_DUMP_OUTBOUND);
+ return (0);
+}
+
+
+static void
+handle_upcall(struct socket *sock, void *arg, int flgs)
+{
+ fuzzer_printf("handle_upcall()\n");
+ int events = usrsctp_get_events(sock);
+
+ while (events & SCTP_EVENT_READ) {
+ struct sctp_recvv_rn rn;
+ ssize_t n;
+ struct sockaddr_in addr;
+ char *buf = calloc(1, BUFFER_SIZE);
+ int flags = 0;
+ socklen_t len = (socklen_t)sizeof(struct sockaddr_in);
+ unsigned int infotype = 0;
+ socklen_t infolen = sizeof(struct sctp_recvv_rn);
+ memset(&rn, 0, sizeof(struct sctp_recvv_rn));
+ n = usrsctp_recvv(sock, buf, BUFFER_SIZE, (struct sockaddr *) &addr, &len, (void *)&rn, &infolen, &infotype, &flags);
+ fuzzer_printf("usrsctp_recvv() - returned %zd\n", n);
+
+ if (flags & MSG_NOTIFICATION) {
+ fuzzer_printf("NOTIFICATION received\n");
+#ifdef FUZZ_VERBOSE
+ handle_notification((union sctp_notification *)buf, n);
+#endif // FUZZ_VERBOSE
+ } else {
+ fuzzer_printf("DATA received\n");
+ }
+
+ free(buf);
+
+ if (n <= 0) {
+ break;
+ }
+
+ events = usrsctp_get_events(sock);
+ }
+}
+
+
+int
+initialize_fuzzer(void) {
+#ifdef FUZZ_VERBOSE
+ usrsctp_init(0, conn_output, debug_printf_stack);
+#else // FUZZ_VERBOSE
+ usrsctp_init(0, conn_output, NULL);
+#endif // FUZZ_VERBOSE
+
+ usrsctp_enable_crc32c_offload();
+
+#ifdef SCTP_DEBUG
+ usrsctp_sysctl_set_sctp_debug_on(SCTP_DEBUG_ALL);
+#endif // SCTP_DEBUG
+
+ usrsctp_register_address((void *)1);
+
+ fuzzer_printf("usrsctp initialized\n");
+ return (1);
+}
+
+
+int
+LLVMFuzzerTestOneInput(const uint8_t* data, size_t data_size)
+{
+ static int initialized;
+ char *fuzz_packet_buffer;
+ struct sockaddr_in6 bind6;
+ struct sockaddr_conn sconn;
+ struct socket *socket_client;
+ struct linger so_linger;
+ struct sctp_event event;
+ unsigned long i;
+ struct sctp_common_header* common_header;
+ uint16_t event_types[] = {
+ SCTP_ASSOC_CHANGE,
+ SCTP_PEER_ADDR_CHANGE,
+ SCTP_REMOTE_ERROR,
+ SCTP_SEND_FAILED,
+ SCTP_SHUTDOWN_EVENT,
+ SCTP_ADAPTATION_INDICATION,
+ SCTP_PARTIAL_DELIVERY_EVENT,
+ SCTP_AUTHENTICATION_EVENT,
+ SCTP_STREAM_RESET_EVENT,
+ SCTP_SENDER_DRY_EVENT,
+ SCTP_ASSOC_RESET_EVENT,
+ SCTP_STREAM_CHANGE_EVENT,
+ SCTP_SEND_FAILED_EVENT
+ };
+ int enable;
+ int result;
+ struct sctp_initmsg initmsg;
+#if defined(FUZZ_STREAM_RESET) || defined(FUZZ_INTERLEAVING)
+ struct sctp_assoc_value assoc_val;
+#endif // defined(FUZZ_STREAM_RESET) || defined(FUZZ_INTERLEAVING)
+
+ // WITH COMMON HEADER!
+ char fuzz_init_ack[] = "\x13\x89\x13\x88\x54\xc2\x7c\x46\x00\x00\x00\x00\x02\x00\x01\xf8" \
+ "\xc7\xa1\xb0\x4d\x00\x1c\x71\xc7\x00\x0a\xff\xff\x03\x91\x94\x1b" \
+ "\x80\x00\x00\x04\xc0\x00\x00\x04\x80\x08\x00\x09\xc0\x0f\xc1\x80" \
+ "\x82\x00\x00\x00\x80\x02\x00\x24\x61\x6c\x7e\x52\x2a\xdb\xe0\xa2" \
+ "\xaa\x78\x25\x1e\x12\xc5\x01\x9e\x4c\x60\x16\xdf\x01\x6d\xa1\xd5" \
+ "\xcd\xbe\xa7\x5d\xa2\x73\xf4\x1b\x80\x04\x00\x08\x00\x03\x00\x01" \
+ "\x80\x03\x00\x07\x00\x80\xc1\x00\x00\x06\x00\x14\x2a\x02\xc6\xa0" \
+ "\x40\x15\x00\x11\x00\x00\x00\x00\x00\x00\x00\x83\x00\x05\x00\x08" \
+ "\xd4\xc9\x79\x53\x00\x07\x01\x80\x4b\x41\x4d\x45\x2d\x42\x53\x44" \
+ "\x20\x31\x2e\x31\x00\x00\x00\x00\x64\x11\x49\x00\x00\x00\x00\x00" \
+ "\xac\xde\x0c\x00\x00\x00\x00\x00\x60\xea\x00\x00\x00\x00\x00\x00" \
+ "\x00\x00\x00\x00\xb2\xd4\x38\x45\xc7\xa1\xb0\x4d\xd4\xc9\x79\x52" \
+ "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x05\x00\x00\x00" \
+ "\xd4\xc9\x79\x53\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" \
+ "\x05\x00\x00\x00\x00\x00\x00\x00\xd9\x05\x13\x89\x01\x01\x00\x00" \
+ "\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x80\x45\x38\xd4\xb2" \
+ "\x00\x1c\x71\xc7\x00\x01\xff\xff\xac\x40\x9b\x94\x80\x00\x00\x04" \
+ "\xc0\x00\x00\x04\x80\x08\x00\x09\xc0\x0f\xc1\x80\x82\x00\x00\x00" \
+ "\x80\x02\x00\x24\xc8\x24\x46\x8c\x7e\x88\x2e\xb7\x88\x8b\xdd\xa1" \
+ "\x55\x8b\xb4\xc0\x26\xe3\x21\xbb\xb0\x66\xfd\xb2\xd4\xde\xf9\x77" \
+ "\x4f\xe4\x7c\xbf\x80\x04\x00\x08\x00\x03\x00\x01\x80\x03\x00\x07" \
+ "\x00\x80\xc1\x00\x00\x0c\x00\x08\x00\x05\x00\x06\x00\x06\x00\x14" \
+ "\x2a\x02\xc6\xa0\x40\x15\x00\x11\x00\x00\x00\x00\x00\x00\x00\x82" \
+ "\x00\x05\x00\x08\xd4\xc9\x79\x52\x02\x00\x01\xf8\xc7\xa1\xb0\x4d" \
+ "\x00\x1c\x71\xc7\x00\x01\xff\xff\x03\x91\x94\x1b\x80\x00\x00\x04" \
+ "\xc0\x00\x00\x04\x80\x08\x00\x09\xc0\x0f\xc1\x80\x82\x00\x00\x00" \
+ "\x80\x02\x00\x24\x61\x6c\x7e\x52\x2a\xdb\xe0\xa2\xaa\x78\x25\x1e" \
+ "\x12\xc5\x01\x9e\x4c\x60\x16\xdf\x01\x6d\xa1\xd5\xcd\xbe\xa7\x5d" \
+ "\xa2\x73\xf4\x1b\x80\x04\x00\x08\x00\x03\x00\x01\x80\x03\x00\x07" \
+ "\x00\x80\xc1\x00\x00\x06\x00\x14\x2a\x02\xc6\xa0\x40\x15\x00\x11" \
+ "\x00\x00\x00\x00\x00\x00\x00\x83\x00\x05\x00\x08\xd4\xc9\x79\x53" \
+ "\x64\x30\x8a\xb9\x7c\xe5\x93\x69\x52\xa9\xc8\xd5\xa1\x1b\x7d\xef" \
+ "\xea\xfa\x23\x32";
+
+ // WITH COMMON HEADER!
+ char fuzz_cookie_ack[] = "\x13\x89\x13\x88\x54\xc2\x7c\x46\x00\x00\x00\x00\x0b\x00\x00\x04";
+
+ // WITH COMMON HEADER!
+ char fuzz_abort[] = "\x13\x89\x13\x88\x54\xc2\x7c\x46\x00\x00\x00\x00\x06\x00\x00\x08\x00\x0c\x00\x04";
+
+ // WITH COMMON HEADER!
+ char fuzz_i_data[] = "\x13\x89\x13\x88\x54\xc2\x7c\x46\x00\x00\x00\x00" \
+ "\x00\x1b\x04\x42\xa3\x58\x90\xe2\xba\x9e\x8c\xfc\x08\x00\x45\x02" \
+ "\x04\x34\x00\x00\x40\x00\x40\x84\x9a\x0b\xd4\xc9\x79\x52\xd4\xc9" \
+ "\x79\x53\x65\x75\x13\x89\x11\x97\x93\x37\x26\x6c\xb7\x65\x40\x02" \
+ "\x04\x14\x96\xff\xad\xc1\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" \
+ "\x00\x27\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \
+ "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \
+ "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \
+ "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \
+ "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \
+ "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \
+ "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \
+ "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \
+ "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \
+ "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \
+ "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \
+ "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \
+ "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \
+ "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \
+ "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \
+ "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \
+ "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \
+ "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \
+ "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \
+ "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \
+ "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \
+ "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \
+ "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \
+ "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \
+ "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \
+ "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \
+ "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \
+ "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \
+ "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \
+ "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \
+ "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \
+ "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \
+ "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \
+ "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \
+ "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \
+ "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \
+ "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \
+ "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \
+ "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \
+ "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \
+ "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \
+ "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \
+ "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \
+ "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \
+ "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \
+ "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \
+ "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \
+ "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \
+ "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \
+ "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \
+ "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \
+ "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \
+ "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \
+ "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \
+ "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \
+ "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \
+ "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \
+ "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \
+ "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \
+ "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \
+ "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \
+ "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \
+ "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \
+ "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41" \
+ "\x41\x41";
+
+ char fuzz_common_header[] = "\x13\x89\x13\x88\x54\xc2\x7c\x46\x00\x00\x00\x00";
+
+ fuzzer_printf("LLVMFuzzerTestOneInput()\n");
+
+ if (!initialized) {
+ initialized = initialize_fuzzer();
+ }
+
+ if (data_size < 5 || data_size > 65535) {
+ // Skip too small and too large packets
+ fuzzer_printf("data_size %zu makes no sense, skipping\n", data_size);
+ return (0);
+ }
+
+ socket_client = usrsctp_socket(AF_CONN, SOCK_STREAM, IPPROTO_SCTP, NULL, NULL, 0, 0);
+ assert(socket_client != NULL);
+
+ usrsctp_set_non_blocking(socket_client, 1);
+
+ // all max!
+ memset(&initmsg, 1, sizeof(struct sctp_initmsg));
+ result = usrsctp_setsockopt(socket_client, IPPROTO_SCTP, SCTP_INITMSG, &initmsg, sizeof(struct sctp_initmsg));
+ assert(result == 0);
+
+ so_linger.l_onoff = 1;
+ so_linger.l_linger = 0;
+ result = usrsctp_setsockopt(socket_client, SOL_SOCKET, SO_LINGER, &so_linger, sizeof(struct linger));
+ assert(result == 0);
+
+ memset(&event, 0, sizeof(event));
+ event.se_assoc_id = SCTP_ALL_ASSOC;
+ event.se_on = 1;
+ for (i = 0; i < (sizeof(event_types) / sizeof(uint16_t)); i++) {
+ event.se_type = event_types[i];
+ result = usrsctp_setsockopt(socket_client, IPPROTO_SCTP, SCTP_EVENT, &event, sizeof(event));
+ assert(result == 0);
+ }
+
+ enable = 1;
+ result = usrsctp_setsockopt(socket_client, IPPROTO_SCTP, SCTP_RECVRCVINFO, &enable, sizeof(enable));
+ assert(result == 0);
+
+ enable = 1;
+ result = usrsctp_setsockopt(socket_client, IPPROTO_SCTP, SCTP_RECVNXTINFO, &enable, sizeof(enable));
+ assert(result == 0);
+
+#if defined(FUZZ_EXPLICIT_EOR)
+ enable = 1;
+ result = usrsctp_setsockopt(socket_client, IPPROTO_SCTP, SCTP_EXPLICIT_EOR, &enable, sizeof(enable));
+ assert(result == 0);
+#endif // defined(FUZZ_EXPLICIT_EOR)
+
+#if defined(FUZZ_STREAM_RESET)
+ assoc_val.assoc_id = SCTP_ALL_ASSOC;
+ assoc_val.assoc_value = SCTP_ENABLE_RESET_STREAM_REQ | SCTP_ENABLE_RESET_ASSOC_REQ | SCTP_ENABLE_CHANGE_ASSOC_REQ;
+ result = usrsctp_setsockopt(socket_client, IPPROTO_SCTP, SCTP_ENABLE_STREAM_RESET, &assoc_val, sizeof(struct sctp_assoc_value));
+ assert(result == 0);
+#endif // defined(FUZZ_STREAM_RESET)
+
+#if defined(FUZZ_INTERLEAVING)
+#if !defined(SCTP_INTERLEAVING_SUPPORTED)
+#define SCTP_INTERLEAVING_SUPPORTED 0x00001206
+#endif // !defined(SCTP_INTERLEAVING_SUPPORTED)
+ enable = 2;
+ result = usrsctp_setsockopt(socket_client, IPPROTO_SCTP, SCTP_FRAGMENT_INTERLEAVE, &enable, sizeof(enable));
+ assert(result == 0);
+
+ memset(&assoc_val, 0, sizeof(assoc_val));
+ assoc_val.assoc_value = 1;
+ result = usrsctp_setsockopt(socket_client, IPPROTO_SCTP, SCTP_INTERLEAVING_SUPPORTED, &assoc_val, sizeof(assoc_val));
+ assert(result == 0);
+#endif // defined(FUZZ_INTERLEAVING)
+
+ memset((void *)&bind6, 0, sizeof(struct sockaddr_in6));
+#ifdef HAVE_SIN_LEN
+ bind6.sin6_len = sizeof(struct sockaddr_in6);
+#endif // HAVE_SIN_LEN
+ bind6.sin6_family = AF_INET6;
+ bind6.sin6_port = htons(5000);
+ bind6.sin6_addr = in6addr_any;
+
+ result = usrsctp_bind(socket_client, (struct sockaddr *)&bind6, sizeof(bind6));
+ assert(result == 0);
+
+ usrsctp_set_upcall(socket_client, handle_upcall, NULL);
+
+ memset(&sconn, 0, sizeof(struct sockaddr_conn));
+ sconn.sconn_family = AF_CONN;
+#ifdef HAVE_SCONN_LEN
+ sconn.sconn_len = sizeof(struct sockaddr_conn);
+#endif // HAVE_SCONN_LEN
+ sconn.sconn_port = htons(5001);
+ sconn.sconn_addr = (void *)1;
+
+ fuzzer_printf("Calling usrsctp_connect()\n");
+ result = usrsctp_connect(socket_client, (struct sockaddr *)&sconn, sizeof(struct sockaddr_conn));
+ assert(result == 0 || errno == EINPROGRESS);
+
+ if (data[0] & (1 << 0)) {
+ fuzzer_printf("Injecting INIT-ACK\n");
+
+ common_header = (struct sctp_common_header*) fuzz_init_ack;
+ common_header->verification_tag = assoc_vtag;
+
+ dump_packet(fuzz_init_ack, 516, SCTP_DUMP_INBOUND);
+ usrsctp_conninput((void *)1, fuzz_init_ack, 516, 0);
+ }
+
+ if (data[0] & (1 << 1)) {
+ fuzzer_printf("Injecting COOKIE-ACK\n");
+
+ common_header = (struct sctp_common_header*) fuzz_cookie_ack;
+ common_header->verification_tag = assoc_vtag;
+
+ dump_packet(fuzz_cookie_ack, 16, SCTP_DUMP_INBOUND);
+ usrsctp_conninput((void *)1, fuzz_cookie_ack, 16, 0);
+ }
+
+ // Required: INIT-ACK and COOKIE-ACK
+ if (data[0] & (1 << 0) &&
+ data[0] & (1 << 1) &&
+ data[0] & (1 << 2)) {
+ const char *sendbuffer = "Geologie ist keine richtige Wissenschaft!";
+ fuzzer_printf("Calling usrsctp_sendv()\n");
+ usrsctp_sendv(socket_client, sendbuffer, strlen(sendbuffer), NULL, 0, NULL, 0, SCTP_SENDV_NOINFO, 0);
+ }
+
+ // Required: INIT-ACK and COOKIE-ACK
+ if (data[0] & (1 << 0) &&
+ data[0] & (1 << 1) &&
+ data[0] & (1 << 3)) {
+ fuzzer_printf("Injecting I-DATA\n");
+
+ common_header = (struct sctp_common_header*) fuzz_i_data;
+ common_header->verification_tag = assoc_vtag;
+
+ dump_packet(fuzz_i_data, 1102, SCTP_DUMP_INBOUND);
+ usrsctp_conninput((void *)1, fuzz_i_data, 1102, 0);
+ }
+
+ // Required: INIT-ACK and COOKIE-ACK
+ if (data[0] & (1 << 0) &&
+ data[0] & (1 << 1) &&
+ data[0] & (1 << 4)) {
+ fuzzer_printf("Sending Stream Reset for all streams\n");
+
+ struct sctp_reset_streams srs;
+ memset(&srs, 0, sizeof(struct sctp_reset_streams));
+ srs.srs_flags = SCTP_STREAM_RESET_INCOMING | SCTP_STREAM_RESET_OUTGOING;
+ result = usrsctp_setsockopt(socket_client, IPPROTO_SCTP, SCTP_RESET_STREAMS, &srs, sizeof(struct sctp_reset_streams));
+ assert(result == 0);
+ }
+
+ fuzz_packet_buffer = malloc(data_size - 1 + COMMON_HEADER_SIZE);
+ memcpy(fuzz_packet_buffer, fuzz_common_header, COMMON_HEADER_SIZE); // common header
+ memcpy(fuzz_packet_buffer + COMMON_HEADER_SIZE, data + 1, data_size - 1);
+
+ common_header = (struct sctp_common_header*) fuzz_packet_buffer;
+ common_header->verification_tag = assoc_vtag;
+
+ fuzzer_printf("Injecting FUZZER-Packet\n");
+ dump_packet(fuzz_packet_buffer, data_size - 1 + COMMON_HEADER_SIZE, SCTP_DUMP_INBOUND);
+ usrsctp_conninput((void *)1, fuzz_packet_buffer, data_size - 1 + COMMON_HEADER_SIZE, 0);
+
+ free(fuzz_packet_buffer);
+
+ fuzzer_printf("Calling usrsctp_close()\n");
+ usrsctp_close(socket_client);
+#if 0
+ fuzzer_printf("Calling usrsctp_finish()\n");
+ while (usrsctp_finish() != 0) {
+ }
+ fuzzer_printf("Done!\n");
+#endif
+
+ return (0);
+}
+
+
+
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/fuzzer_connect_multi.sh b/chromium/third_party/usrsctp/usrsctplib/fuzzer/fuzzer_connect_multi.sh
new file mode 100755
index 00000000000..4e2f92011a1
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/fuzzer_connect_multi.sh
@@ -0,0 +1,22 @@
+#!/usr/bin/env bash
+
+export ASAN_OPTIONS=abort_on_error=1:disable_core=0:unmap_shadow_on_exit=1:disable_coredump=0:detect_leaks=1
+ulimit -c unlimited
+mkdir -p CORPUS_CONNECT
+
+NPROC=1
+
+if [[ "$OSTYPE" == "linux-gnu" ]]; then
+ NPROC=$(nproc)
+elif [[ "$OSTYPE" == "darwin"* ]]; then
+ NPROC=$(sysctl -n hw.ncpu)
+elif [[ "$OSTYPE" == "freebsd"* ]]; then
+ NPROC=$(sysctl -n hw.ncpu)
+else
+ exit 1
+fi
+
+echo "$NPROC"
+
+
+./fuzzer_connect_multi -jobs=64 -timeout=10 -max_len=32000 CORPUS_CONNECT
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/fuzzer_listen.c b/chromium/third_party/usrsctp/usrsctplib/fuzzer/fuzzer_listen.c
new file mode 100644
index 00000000000..e6e873c06e7
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/fuzzer_listen.c
@@ -0,0 +1,170 @@
+/*
+ * Copyright (C) 2017-2019 Felix Weinrank
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <usrsctp.h>
+#include "../programs/programs_helper.h"
+
+#define FUZZ_FAST 1
+
+#ifdef FUZZ_VERBOSE
+#define fuzzer_printf(...) \
+ do { \
+ fprintf(stderr, "[P]"); \
+ debug_printf_runtime(); \
+ fprintf(stderr, __VA_ARGS__); \
+ } while (0)
+#else
+#define fuzzer_printf(...)
+#endif
+
+struct sockaddr_conn sconn;
+struct socket *s_l;
+
+static int
+conn_output(void *addr, void *buf, size_t length, uint8_t tos, uint8_t set_df)
+{
+#if 0
+ char *dump_buf;
+ if ((dump_buf = usrsctp_dumppacket(buf, length, SCTP_DUMP_OUTBOUND)) != NULL) {
+ fprintf(stderr, "%s", dump_buf);
+ usrsctp_freedumpbuffer(dump_buf);
+ }
+#endif
+ return (0);
+}
+
+static void
+handle_upcall(struct socket *sock, void *arg, int flgs)
+{
+ fuzzer_printf("Listening socket established, implement logic!\n");
+ exit(EXIT_FAILURE);
+}
+
+int
+init_fuzzer(void) {
+ static uint8_t initialized = 0;
+ struct sctp_event event;
+ uint16_t event_types[] = {
+ SCTP_ASSOC_CHANGE,
+ SCTP_PEER_ADDR_CHANGE,
+ SCTP_SEND_FAILED_EVENT,
+ SCTP_REMOTE_ERROR,
+ SCTP_SHUTDOWN_EVENT,
+ SCTP_ADAPTATION_INDICATION,
+ SCTP_PARTIAL_DELIVERY_EVENT};
+ unsigned long i;
+
+#if defined(FUZZ_FAST)
+ if (initialized) {
+ return 0;
+ }
+#endif
+
+#ifdef FUZZ_VERBOSE
+ usrsctp_init(0, conn_output, debug_printf_stack);
+#else
+ usrsctp_init(0, conn_output, NULL);
+#endif
+
+ usrsctp_enable_crc32c_offload();
+
+#ifdef SCTP_DEBUG
+ usrsctp_sysctl_set_sctp_debug_on(SCTP_DEBUG_ALL);
+#endif
+ usrsctp_register_address((void *)1);
+
+ if ((s_l = usrsctp_socket(AF_CONN, SOCK_STREAM, IPPROTO_SCTP, NULL, NULL, 0, 0)) == NULL) {
+ perror("usrsctp_socket");
+ exit(EXIT_FAILURE);
+ }
+ usrsctp_set_non_blocking(s_l, 1);
+
+ /* Bind the server side. */
+ memset(&sconn, 0, sizeof(struct sockaddr_conn));
+ sconn.sconn_family = AF_CONN;
+#ifdef HAVE_SCONN_LEN
+ sconn.sconn_len = sizeof(struct sockaddr_conn);
+#endif
+ sconn.sconn_port = htons(5001);
+ sconn.sconn_addr = (void *)1;
+ if (usrsctp_bind(s_l, (struct sockaddr *)&sconn, sizeof(struct sockaddr_conn)) < 0) {
+ perror("usrsctp_bind");
+ exit(EXIT_FAILURE);
+ }
+
+ memset(&event, 0, sizeof(event));
+ event.se_assoc_id = SCTP_FUTURE_ASSOC;
+ event.se_on = 1;
+ for (i = 0; i < sizeof(event_types)/sizeof(uint16_t); i++) {
+ event.se_type = event_types[i];
+ if (usrsctp_setsockopt(s_l, IPPROTO_SCTP, SCTP_EVENT, &event, sizeof(event)) < 0) {
+ perror("setsockopt SCTP_EVENT s_l");
+ exit(EXIT_FAILURE);
+ }
+ }
+
+ /* Make server side passive... */
+ if (usrsctp_listen(s_l, 1) < 0) {
+ perror("usrsctp_listen");
+ exit(EXIT_FAILURE);
+ }
+
+ usrsctp_set_upcall(s_l, handle_upcall, NULL);
+
+ initialized = 1;
+
+ return (0);
+}
+
+int
+LLVMFuzzerTestOneInput(const uint8_t* data, size_t data_size)
+{
+ init_fuzzer();
+
+ if (data_size < 8 || data_size > 65535) {
+ // Skip too small and too large packets
+ return (0);
+ }
+ usrsctp_conninput((void *)1, data, data_size, 0);
+
+#if !defined(FUZZ_FAST)
+ usrsctp_close(s_l);
+ while (usrsctp_finish() != 0) {
+ //sleep(1);
+ }
+#endif
+
+ return (0);
+}
+
+
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/fuzzer_listen.sh b/chromium/third_party/usrsctp/usrsctplib/fuzzer/fuzzer_listen.sh
new file mode 100755
index 00000000000..4a70dec2e33
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/fuzzer_listen.sh
@@ -0,0 +1,5 @@
+#!/usr/bin/env bash
+export ASAN_OPTIONS=abort_on_error=1:disable_core=0:unmap_shadow_on_exit=1:disable_coredump=0
+ulimit -c unlimited
+mkdir -p CORPUS_LISTEN
+./fuzzer_listen -jobs=32 -timeout=10 -max_len=4086 CORPUS_LISTEN
diff --git a/chromium/third_party/usrsctp/usrsctplib/fuzzer/pcap2corpus.c b/chromium/third_party/usrsctp/usrsctplib/fuzzer/pcap2corpus.c
new file mode 100644
index 00000000000..ba178d2442d
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/fuzzer/pcap2corpus.c
@@ -0,0 +1,247 @@
+/*-
+ * Copyright (c) 2017 Michael Tuexen
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+
+/*
+ * Compile: cc -Wall -Werror -pedantic pcap2corpus.c -lpcap -o pcap2corpus
+ *
+ * Usage: pcap2corpus infile outfile_prefix [expression]
+ * if no expression, a pcap filter, is provided, sctp is used.
+ */
+#define _GNU_SOURCE
+#include <sys/types.h>
+#include <net/ethernet.h>
+#include <netinet/in.h>
+#include <netinet/ip.h>
+#include <netinet/ip6.h>
+#include <pcap/pcap.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+static unsigned long nr_read = 0;
+static unsigned long nr_decaps = 0;
+
+#define PRE_PADDING 1
+
+struct args {
+ struct bpf_program bpf_prog;
+ char *filename_prefix;
+ int (*is_ipv4)(const void *);
+ int (*is_ipv6)(const void *);
+ int linktype;
+ unsigned int offset;
+};
+
+/*
+ * SCTP protocol - RFC4960.
+ */
+struct sctphdr {
+ uint16_t src_port; /* source port */
+ uint16_t dest_port; /* destination port */
+ uint32_t v_tag; /* verification tag of packet */
+ uint32_t checksum; /* CRC32C checksum */
+ /* chunks follow... */
+} __attribute__((packed));
+
+static int
+loopback_is_ipv4(const void *bytes)
+{
+ uint32_t family;
+
+ family = *(const uint32_t *)bytes;
+ return (family == 2);
+}
+
+static int
+loopback_is_ipv6(const void *bytes)
+{
+ uint32_t family;
+
+ family = *(const uint32_t *)bytes;
+ return (family == 24 || family == 28 || family == 30);
+}
+
+static int
+ethernet_is_ipv4(const void *bytes)
+{
+ const struct ether_header *ether_hdr;
+
+ ether_hdr = (const struct ether_header *)bytes;
+ return (ntohs(ether_hdr->ether_type) == ETHERTYPE_IP);
+}
+
+static int
+ethernet_is_ipv6(const void *bytes)
+{
+ const struct ether_header *ether_hdr;
+
+ ether_hdr = (const struct ether_header *)bytes;
+ return (ntohs(ether_hdr->ether_type) == ETHERTYPE_IPV6);
+}
+
+static void
+packet_handler(u_char *user, const struct pcap_pkthdr *pkthdr, const u_char *bytes_in)
+{
+ struct args *args;
+ const u_char *bytes_out;
+ FILE *file;
+ char *filename;
+ const struct ip *ip4_hdr_in;
+ const struct ip6_hdr *ip6_hdr_in;
+ size_t offset, length;
+ int null = 0;
+
+ args = (struct args *)(void *)user;
+ bytes_out = NULL;
+ if (pcap_offline_filter(&args->bpf_prog, pkthdr, bytes_in) == 0) {
+ goto out;
+ }
+ if (pkthdr->caplen < args->offset) {
+ goto out;
+ }
+ if (args->is_ipv4(bytes_in)) {
+ offset = args->offset + sizeof(struct ip) + sizeof(struct sctphdr);
+ if (pkthdr->caplen < offset) {
+ goto out;
+ }
+ ip4_hdr_in = (const struct ip *)(const void *)(bytes_in + args->offset);
+ if (ip4_hdr_in->ip_p == IPPROTO_SCTP) {
+ unsigned int ip4_hdr_len;
+
+ ip4_hdr_len = ip4_hdr_in->ip_hl << 2;
+ offset = args->offset + ip4_hdr_len + sizeof(struct sctphdr);
+ if (pkthdr->caplen < offset) {
+ goto out;
+ }
+ bytes_out = bytes_in + offset;
+ length = pkthdr->caplen - offset;
+ }
+ }
+ if (args->is_ipv6(bytes_in)) {
+ offset = args->offset + sizeof(struct ip6_hdr) + sizeof(struct sctphdr);
+ if (pkthdr->caplen < offset) {
+ goto out;
+ }
+ ip6_hdr_in = (const struct ip6_hdr *)(bytes_in + args->offset);
+ if (ip6_hdr_in->ip6_nxt == IPPROTO_SCTP) {
+ bytes_out = bytes_in + offset;
+ length = pkthdr->caplen - offset;
+ }
+ }
+out:
+ nr_read++;
+ if (bytes_out != NULL) {
+ asprintf(&filename, "%s-%06lu", args->filename_prefix, nr_decaps);
+ file = fopen(filename, "w");
+ fwrite(&null, 1, PRE_PADDING, file);
+ fwrite(bytes_out, length, 1, file);
+ fclose(file);
+ free(filename);
+ nr_decaps++;
+ }
+}
+
+static char *
+get_filter(int argc, char *argv[])
+{
+ char *result, *c;
+ size_t len;
+ int i;
+
+ if (argc == 3) {
+ asprintf(&result, "%s", "sctp");
+ } else {
+ len = 0;
+ for (i = 3; i < argc; i++) {
+ len += strlen(argv[i]) + 1;
+ }
+ len -= 1;
+ result = malloc(len);
+ c = result;
+ for (i = 3; i < argc; i++) {
+ size_t arg_len;
+
+ arg_len = strlen(argv[i]);
+ memcpy(c, argv[i], arg_len);
+ c += arg_len;
+ if (i < argc - 1) {
+ *c++ = ' ';
+ }
+ }
+ }
+ return (result);
+}
+
+int
+main(int argc, char *argv[])
+{
+ char errbuf[PCAP_ERRBUF_SIZE];
+ pcap_t *pcap_reader;
+ char *filter;
+ struct args args;
+
+ if (argc < 3) {
+ fprintf(stderr, "Usage: %s infile outfile_prefix [expression]\n", argv[0]);
+ return (-1);
+ }
+ args.filename_prefix = argv[2];
+ pcap_reader = pcap_open_offline(argv[1], errbuf);
+ if (pcap_reader == NULL) {
+ fprintf(stderr, "Can't open input file %s: %s\n", argv[1], errbuf);
+ return (-1);
+ }
+ args.linktype = pcap_datalink(pcap_reader);
+ switch (args.linktype) {
+ case DLT_NULL:
+ args.is_ipv4 = loopback_is_ipv4;
+ args.is_ipv6 = loopback_is_ipv6;
+ args.offset = sizeof(uint32_t);
+ break;
+ case DLT_EN10MB:
+ args.is_ipv4 = ethernet_is_ipv4;
+ args.is_ipv6 = ethernet_is_ipv6;
+ args.offset = sizeof(struct ether_header);
+ break;
+ default:
+ fprintf(stderr, "Datalink type %d not supported\n", args.linktype);
+ pcap_close(pcap_reader);
+ return (-1);
+ }
+ filter = get_filter(argc, argv);
+ if (pcap_compile(pcap_reader, &args.bpf_prog, filter, 0, PCAP_NETMASK_UNKNOWN) < 0) {
+ fprintf(stderr, "Can't compile filter %s: %s\n", filter, pcap_geterr(pcap_reader));
+ free(filter);
+ pcap_close(pcap_reader);
+ return (-1);
+ }
+ free(filter);
+ pcap_dispatch(pcap_reader, 0, packet_handler, (u_char *)&args);
+ pcap_close(pcap_reader);
+ fprintf(stderr, "%lu packets processed\n", nr_read);
+ fprintf(stderr, "%lu packets decapsulated\n", nr_decaps);
+ return (0);
+}
diff --git a/chromium/third_party/usrsctp/usrsctplib/gen-def.py b/chromium/third_party/usrsctp/usrsctplib/gen-def.py
new file mode 100644
index 00000000000..55c02854428
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/gen-def.py
@@ -0,0 +1,26 @@
+#!/usr/bin/env python3
+#
+# gen-def.py usrsctp.lib
+import re
+import sys
+import subprocess
+from shutil import which
+
+try:
+ lib_file = sys.argv[1]
+except:
+ print('Usage: gen-def.py LIB-FILE')
+ exit(-1)
+
+print('EXPORTS')
+
+if which('dumpbin'):
+ dumpbin_cmd = subprocess.run(['dumpbin', '/linkermember:1', lib_file],
+ stdout=subprocess.PIPE)
+
+ pattern = re.compile('\s*[0-9a-fA-F]+ _?(?P<functionname>usrsctp_[^\s]*)')
+
+ for line in dumpbin_cmd.stdout.decode('utf-8').splitlines():
+ match = pattern.match(line)
+ if match:
+ print(match.group('functionname'))
diff --git a/chromium/third_party/usrsctp/usrsctplib/meson.build b/chromium/third_party/usrsctp/usrsctplib/meson.build
new file mode 100644
index 00000000000..28a1490d7c2
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/meson.build
@@ -0,0 +1,241 @@
+# Project definition
+project('usrsctplib', 'c',
+ version: '1.0.0',
+ default_options: ['c_std=c99'],
+ meson_version: '>=0.49.0')
+
+# Set compiler warning flags
+compiler = meson.get_compiler('c')
+if compiler.get_argument_syntax() == 'msvc'
+ compiler_args = compiler.get_supported_arguments([
+ '/wd4100', # 'identifier' : unreferenced formal parameter
+ '/wd4127', # conditional expression is constant
+ '/wd4200', # nonstandard extension used : zero-sized array in struct/union
+ '/wd4214', # bit field types other than int
+ '/wd4706', # assignment within conditional expression
+ '/wd4245', # 'conversion' : conversion from 'type1' to 'type2', signed/unsigned mismatch
+ '/wd4389', # 'operator' : signed/unsigned mismatch
+ '/wd4702', # unreachable code
+ '/wd4701', # Potentially uninitialized local variable 'name' used
+ '/wd4244', # 'conversion' conversion from 'type1' to 'type2', possible loss of data
+ ])
+else
+ compiler_args = compiler.get_supported_arguments([
+ '-pedantic',
+ '-Wall',
+ '-Wextra',
+ '-Wfloat-equal',
+ '-Wshadow',
+ '-Wpointer-arith',
+ '-Winit-self',
+ '-Wno-unused-function',
+ '-Wno-unused-parameter',
+ '-Wno-unreachable-code',
+ '-Wstrict-prototypes',
+ ])
+endif
+add_project_arguments(compiler_args, language: 'c')
+
+# Configuration
+compile_args = []
+
+# Dependency: Threads
+thread_dep = dependency('threads', required: true)
+
+# Dependencies list
+dependencies = [
+ thread_dep,
+]
+
+# Global settings
+add_project_arguments([
+ '-D__Userspace__',
+ '-DSCTP_SIMPLE_ALLOCATOR',
+ '-DSCTP_PROCESS_LEVEL_LOCKS',
+], language: 'c')
+
+# OS-specific settings
+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')
+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'
+ add_project_arguments(compiler.get_supported_arguments([
+ '-Wno-format',
+ '-D_WIN32_WINNT=0x601', # Enables inet_ntop and friends
+ ]), language: 'c')
+ endif
+else
+ error('Unknown system: @0@'.format(system))
+endif
+
+# Feature: sys/queue
+if compiler.has_header('sys/queue.h')
+ add_project_arguments('-DHAVE_SYS_QUEUE_H', language: 'c')
+endif
+
+# Feature: sys/socket, linux/ifaddr, linux/rtnetlink
+if compiler.has_header('sys/socket.h')
+ if compiler.has_header('linux/if_addr.h')
+ add_project_arguments('-DHAVE_LINUX_IF_ADDR_H', language: 'c')
+ endif
+
+ if compiler.has_header('linux/rtnetlink.h')
+ add_project_arguments('-DHAVE_LINUX_RTNETLINK_H', language: 'c')
+ endif
+endif
+
+# Feature: ICMP
+have_sys_types = compiler.has_header('sys/types.h')
+have_netinet_in = compiler.has_header('netinet/in.h')
+have_netinet_ip = compiler.has_header('netinet/ip.h')
+have_netinet_ip_icmp = compiler.has_header('netinet/ip_icmp.h')
+if have_sys_types and have_netinet_in and have_netinet_ip and have_netinet_ip_icmp
+ add_project_arguments('-DHAVE_NETINET_IP_ICMP_H', language: 'c')
+endif
+
+# Feature: stdatomic
+if compiler.has_header('stdatomic.h')
+ add_project_arguments('-DHAVE_STDATOMIC_H', language: 'c')
+endif
+
+# Feature: sockaddr.sa_len
+prefix = '''
+#include <sys/types.h>
+#include <sys/socket.h>
+'''
+have_sa_len = compiler.has_member('struct sockaddr', 'sa_len', prefix: prefix)
+if have_sa_len
+ add_project_arguments('-DHAVE_SA_LEN', language: 'c')
+endif
+
+# Feature: sockaddr_in.sin_len / sockaddr_in6.sin6_len / sockaddr_conn.sconn_len
+prefix = '''
+#include <sys/types.h>
+#include <netinet/in.h>
+'''
+have_sin_len = compiler.has_member('struct sockaddr_in', 'sin_len', prefix: prefix)
+if have_sin_len
+ add_project_arguments('-DHAVE_SIN_LEN', language: 'c')
+endif
+have_sin6_len = compiler.has_member('struct sockaddr_in6', 'sin6_len', prefix: prefix)
+if have_sin6_len
+ add_project_arguments('-DHAVE_SIN6_LEN', language: 'c')
+endif
+have_sconn_len = compiler.has_member('struct sockaddr_conn', 'sconn_len', prefix: '#include "usrsctp.h"', include_directories: include_directories('usrsctplib'))
+if have_sconn_len
+ add_project_arguments('-DHAVE_SCONN_LEN', language: 'c')
+endif
+
+# Options
+if get_option('sctp_invariants')
+ add_project_arguments('-DINVARIANTS', language: 'c')
+endif
+if get_option('sctp_debug')
+ add_project_arguments('-DSCTP_DEBUG', language: 'c')
+ compile_args += '-DSCTP_DEBUG'
+endif
+if get_option('sctp_inet')
+ add_project_arguments('-DINET', language: 'c')
+endif
+if get_option('sctp_inet6')
+ add_project_arguments('-DINET6', language: 'c')
+endif
+
+# Library
+subdir('usrsctplib')
+
+# Build library
+if compiler.get_id() == 'msvc' and get_option('default_library') == 'shared'
+ # Needed by usrsctp_def
+ find_program('dumpbin')
+
+ usrsctp_static = static_library('usrsctp-static', sources,
+ dependencies: dependencies,
+ include_directories: include_dirs)
+
+ usrsctp_def = custom_target('usrsctp.def',
+ command: [find_program('gen-def.py'), '@INPUT@'],
+ input: usrsctp_static,
+ output: 'usrsctp.def',
+ capture: true)
+
+ usrsctp = shared_library('usrsctp',
+ link_whole: usrsctp_static,
+ dependencies: dependencies,
+ vs_module_defs: usrsctp_def,
+ install: true,
+ version: meson.project_version())
+else
+ usrsctp = library('usrsctp', sources,
+ dependencies: dependencies,
+ include_directories: include_dirs,
+ install: true,
+ version: meson.project_version(),
+ c_args: '-U__APPLE__')
+endif
+
+# Declare dependency
+usrsctp_dep = declare_dependency(
+ compile_args: compile_args,
+ include_directories: include_dirs,
+ link_with: usrsctp)
+
+# Generate pkg-config file
+pkg = import('pkgconfig')
+pkg.generate(usrsctp,
+ name: 'usrsctp',
+ description: 'A portable SCTP userland stack',
+ url: 'https://github.com/sctplab/usrsctp',
+ extra_cflags: compile_args)
+
+# Programs (optional)
+if get_option('sctp_build_programs')
+ subdir('programs')
+
+ # Build executables
+ foreach name, sources : programs
+ executable(
+ name,
+ programs_helper_sources + sources,
+ dependencies: dependencies,
+ link_with: usrsctp,
+ include_directories: include_dirs)
+ endforeach
+endif
diff --git a/chromium/third_party/usrsctp/usrsctplib/meson_options.txt b/chromium/third_party/usrsctp/usrsctplib/meson_options.txt
new file mode 100644
index 00000000000..56d95061215
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/meson_options.txt
@@ -0,0 +1,10 @@
+option('sctp_invariants', type: 'boolean', value: false,
+ description: 'Add runtime checks')
+option('sctp_debug', type: 'boolean', value: false,
+ description: 'Provide debug information')
+option('sctp_inet', type: 'boolean', value: true,
+ description: 'Support IPv4')
+option('sctp_inet6', type: 'boolean', value: true,
+ description: 'Support IPv6')
+option('sctp_build_programs', type: 'boolean', value: true,
+ description: 'Build example programs')
diff --git a/chromium/third_party/usrsctp/usrsctplib/programs/CMakeLists.txt b/chromium/third_party/usrsctp/usrsctplib/programs/CMakeLists.txt
index ab4c7fda39b..d9b89d82389 100644
--- a/chromium/third_party/usrsctp/usrsctplib/programs/CMakeLists.txt
+++ b/chromium/third_party/usrsctp/usrsctplib/programs/CMakeLists.txt
@@ -1,6 +1,6 @@
#
# Copyright (C) 2015-2015 Oleg Alexeenkov
-# Copyright (C) 2015-2017 Felix Weinrank
+# Copyright (C) 2015-2019 Felix Weinrank
#
# All rights reserved.
#
@@ -48,14 +48,27 @@ include_directories(${CMAKE_SOURCE_DIR}/usrsctplib)
# OS DEPENDENT
#################################################
-if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
+if (CMAKE_SYSTEM_NAME MATCHES "Linux")
add_definitions(-D_GNU_SOURCE)
endif ()
-if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
+if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
add_definitions(-D__APPLE_USE_RFC_2292)
endif ()
+if (MSYS OR MINGW)
+ message(STATUS "MSYS / MINGW")
+ add_definitions(-D__USE_MINGW_ANSI_STDIO)
+ # 0x0601 = Windows 7 API
+ add_definitions(-DWINVER=0x0601)
+ add_definitions(-D_WIN32_WINNT=0x0601)
+
+ if (CMAKE_C_COMPILER_ID MATCHES "GNU")
+ message(STATUS "MSYS / MINGW + GCC")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-format")
+ endif ()
+endif ()
+
#################################################
# MISC
@@ -68,21 +81,30 @@ find_package(Threads)
# PROGRAMS
#################################################
-set(check_programs
+list(APPEND check_programs
+ chargen_server_upcall.c
client.c
+ client_upcall.c
daytime_server.c
+ daytime_server_upcall.c
discard_server.c
+ discard_server_upcall.c
echo_server.c
+ echo_server_upcall.c
ekr_client.c
- ekr_loop_offload.c
ekr_loop.c
+ ekr_loop_offload.c
+ ekr_loop_upcall.c
ekr_peer.c
ekr_server.c
http_client.c
+ http_client_upcall.c
rtcweb.c
+ st_client.c
test_libmgmt.c
test_timer.c
tsctp.c
+ tsctp_upcall.c
)
foreach (source_file ${check_programs})
@@ -90,9 +112,11 @@ foreach (source_file ${check_programs})
add_executable(
${source_file_we}
${source_file}
+ programs_helper.c
)
- target_link_libraries(${source_file_we}
+ target_link_libraries(
+ ${source_file_we}
${programs_link_library}
${CMAKE_THREAD_LIBS_INIT}
)
diff --git a/chromium/third_party/usrsctp/usrsctplib/programs/Makefile.am b/chromium/third_party/usrsctp/usrsctplib/programs/Makefile.am
index 45c248fba3e..794c32e1944 100644
--- a/chromium/third_party/usrsctp/usrsctplib/programs/Makefile.am
+++ b/chromium/third_party/usrsctp/usrsctplib/programs/Makefile.am
@@ -29,34 +29,98 @@
#
AM_CPPFLAGS = -I$(srcdir)/../usrsctplib
-EXTRA_DIST = Makefile.nmake tsctp.c daytime_server.c discard_server.c echo_server.c client.c rtcweb.c ekr_client.c ekr_server.c ekr_loop.c ekr_loop_offload.c test_libmgmt.c http_client.c
+EXTRA_DIST = \
+ Makefile.nmake \
+ test_libmgmt.c \
+ test_timer.c \
+ tsctp.c \
+ chargen_server_upcall.c \
+ daytime_server.c \
+ daytime_server_upcall.c \
+ discard_server.c \
+ discard_server_upcall.c \
+ echo_server.c \
+ echo_server_upcall.c \
+ client.c \
+ client_upcall.c \
+ rtcweb.c \
+ ekr_client.c \
+ ekr_server.c \
+ ekr_loop.c \
+ ekr_loop_offload.c \
+ ekr_loop_upcall.c \
+ ekr_peer.c \
+ test_libmgmt.c \
+ http_client.c \
+ http_client_upcall.c \
+ st_client.c
-noinst_PROGRAMS = tsctp daytime_server discard_server echo_server client rtcweb ekr_client ekr_server ekr_peer ekr_loop ekr_loop_offload test_libmgmt test_timer http_client
-test_libmgmt_SOURCES = test_libmgmt.c
+noinst_PROGRAMS = \
+ test_libmgmt \
+ test_timer \
+ tsctp \
+ chargen_server_upcall \
+ daytime_server \
+ daytime_server_upcall \
+ discard_server \
+ discard_server_upcall \
+ echo_server \
+ echo_server_upcall \
+ client \
+ client_upcall \
+ rtcweb \
+ ekr_client \
+ ekr_server \
+ ekr_loop \
+ ekr_loop_offload \
+ ekr_loop_upcall \
+ ekr_peer \
+ test_libmgmt \
+ http_client \
+ http_client_upcall \
+ st_client
+
+test_libmgmt_SOURCES = programs_helper.c test_libmgmt.c
test_libmgmt_LDADD = ../usrsctplib/libusrsctp.la
-test_timer_SOURCES = test_timer.c
+test_timer_SOURCES = programs_helper.c test_timer.c
test_timer_LDADD = ../usrsctplib/libusrsctp.la
-tsctp_SOURCES = tsctp.c
+tsctp_SOURCES = programs_helper.c tsctp.c
tsctp_LDADD = ../usrsctplib/libusrsctp.la
-daytime_server_SOURCES = daytime_server.c
+chargen_server_upcall_SOURCES = programs_helper.c chargen_server_upcall.c
+chargen_server_upcall_LDADD = ../usrsctplib/libusrsctp.la
+daytime_server_SOURCES = programs_helper.c daytime_server.c
daytime_server_LDADD = ../usrsctplib/libusrsctp.la
-discard_server_SOURCES = discard_server.c
+daytime_server_upcall_SOURCES = programs_helper.c daytime_server_upcall.c
+daytime_server_upcall_LDADD = ../usrsctplib/libusrsctp.la
+discard_server_SOURCES = programs_helper.c discard_server.c
discard_server_LDADD = ../usrsctplib/libusrsctp.la
-echo_server_SOURCES = echo_server.c
+discard_server_upcall_SOURCES = programs_helper.c discard_server_upcall.c
+discard_server_upcall_LDADD = ../usrsctplib/libusrsctp.la
+echo_server_SOURCES = programs_helper.c echo_server.c
echo_server_LDADD = ../usrsctplib/libusrsctp.la
-client_SOURCES = client.c
+echo_server_upcall_SOURCES = programs_helper.c echo_server_upcall.c
+echo_server_upcall_LDADD = ../usrsctplib/libusrsctp.la
+client_SOURCES = programs_helper.c client.c
client_LDADD = ../usrsctplib/libusrsctp.la
-rtcweb_SOURCES = rtcweb.c
+client_upcall_SOURCES = programs_helper.c client_upcall.c
+client_upcall_LDADD = ../usrsctplib/libusrsctp.la
+rtcweb_SOURCES = programs_helper.c rtcweb.c
rtcweb_LDADD = ../usrsctplib/libusrsctp.la
-ekr_server_SOURCES = ekr_server.c
+ekr_server_SOURCES = programs_helper.c ekr_server.c
ekr_server_LDADD = ../usrsctplib/libusrsctp.la
-ekr_client_SOURCES = ekr_client.c
+ekr_client_SOURCES = programs_helper.c ekr_client.c
ekr_client_LDADD = ../usrsctplib/libusrsctp.la
-ekr_peer_SOURCES = ekr_peer.c
+ekr_peer_SOURCES = programs_helper.c ekr_peer.c
ekr_peer_LDADD = ../usrsctplib/libusrsctp.la
-ekr_loop_SOURCES = ekr_loop.c
+ekr_loop_SOURCES = programs_helper.c ekr_loop.c
ekr_loop_LDADD = ../usrsctplib/libusrsctp.la
-ekr_loop_offload_SOURCES = ekr_loop_offload.c
+ekr_loop_offload_SOURCES = programs_helper.c ekr_loop_offload.c
ekr_loop_offload_LDADD = ../usrsctplib/libusrsctp.la
-http_client_SOURCES = http_client.c
+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
http_client_LDADD = ../usrsctplib/libusrsctp.la
+http_client_upcall_SOURCES = programs_helper.c http_client_upcall.c
+http_client_upcall_LDADD = ../usrsctplib/libusrsctp.la
+st_client_SOURCES = programs_helper.c st_client.c
+st_client_LDADD = ../usrsctplib/libusrsctp.la
diff --git a/chromium/third_party/usrsctp/usrsctplib/programs/Makefile.nmake b/chromium/third_party/usrsctp/usrsctplib/programs/Makefile.nmake
index f3800e22e5d..24e9695ecfa 100644
--- a/chromium/third_party/usrsctp/usrsctplib/programs/Makefile.nmake
+++ b/chromium/third_party/usrsctp/usrsctplib/programs/Makefile.nmake
@@ -1,126 +1,186 @@
-#
-# Copyright (C) 2011-2012 Michael Tuexen
-#
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-# 1. Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# 2. Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in the
-# documentation and/or other materials provided with the distribution.
-# 3. Neither the name of the project nor the names of its contributors
-# may be used to endorse or promote products derived from this software
-# without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
-# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-# ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
-# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-# SUCH DAMAGE.
-#
-
-CFLAGS=/W3 /WX /I..\usrsctplib
-
-CVARSDLL=-DINET -DINET6
-
-LINKFLAGS=/LIBPATH:..\usrsctplib usrsctp.lib
-
-.c.obj::
- $(CC) $(CVARSDLL) $(CFLAGS) -Fd.\ -c $<
-
-all: \
- client \
- daytime_server \
- discard_server \
- echo_server \
- tsctp \
- rtcweb \
- ekr_client \
- ekr_server \
- ekr_peer \
- ekr_loop \
- test_libmgmt \
- http_client
-
-client:
- $(CC) $(CFLAGS) $(CVARSDLL) -c client.c
- link -out:client.exe client.obj $(LINKFLAGS)
-
-daytime_server:
- $(CC) $(CFLAGS) $(CVARSDLL) -c daytime_server.c
- link -out:daytime_server.exe daytime_server.obj $(LINKFLAGS)
-
-discard_server:
- $(CC) $(CFLAGS) $(CVARSDLL) -c discard_server.c
- link -out:discard_server.exe discard_server.obj $(LINKFLAGS)
-
-echo_server:
- $(CC) $(CFLAGS) $(CVARSDLL) -c echo_server.c
- link -out:echo_server.exe echo_server.obj $(LINKFLAGS)
-
-tsctp:
- $(CC) $(CFLAGS) $(CVARSDLL) -c tsctp.c
- link -out:tsctp.exe tsctp.obj $(LINKFLAGS)
-
-rtcweb:
- $(CC) $(CFLAGS) $(CVARSDLL) -c rtcweb.c
- link -out:rtcweb.exe rtcweb.obj $(LINKFLAGS)
-
-ekr_client:
- $(CC) $(CFLAGS) $(CVARSDLL) -c ekr_client.c
- link -out:ekr_client.exe ekr_client.obj $(LINKFLAGS)
-
-ekr_server:
- $(CC) $(CFLAGS) $(CVARSDLL) -c ekr_server.c
- link -out:ekr_server.exe ekr_server.obj $(LINKFLAGS)
-
-ekr_peer:
- $(CC) $(CFLAGS) $(CVARSDLL) -c ekr_peer.c
- link -out:ekr_peer.exe ekr_peer.obj $(LINKFLAGS)
-
-ekr_loop:
- $(CC) $(CFLAGS) $(CVARSDLL) -c ekr_loop.c
- link -out:ekr_loop.exe ekr_loop.obj $(LINKFLAGS)
-
-test_libmgmt:
- $(CC) $(CFLAGS) $(CVARSDLL) -c test_libmgmt.c
- link -out:test_libmgmt.exe test_libmgmt.obj $(LINKFLAGS)
-
-http_client:
- $(CC) $(CFLAGS) $(CVARSDLL) -c http_client.c
- link -out:http_client.exe http_client.obj $(LINKFLAGS)
-
-clean:
- del /F client.exe
- del /F client.obj
- del /F daytime_server.exe
- del /F daytime_server.obj
- del /F discard_server.exe
- del /F discard_server.obj
- del /F echo_server.exe
- del /F echo_server.obj
- del /F tsctp.exe
- del /F tsctp.obj
- del /F rtcweb.exe
- del /F rtcweb.obj
- del /F ekr_client.exe
- del /F ekr_client.obj
- del /F ekr_server.exe
- del /F ekr_server.obj
- del /F ekr_peer.exe
- del /F ekr_peer.obj
- del /F ekr_loop.exe
- del /F ekr_loop.obj
- del /F test_libmgmt.exe
- del /F test_libmgmt.obj
- del /F http_client.exe
- del /F http_client.obj
+#
+# Copyright (C) 2011-2012 Michael Tuexen
+#
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of the project nor the names of its contributors
+# may be used to endorse or promote products derived from this software
+# without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+
+CFLAGS=/W3 /WX /I..\usrsctplib
+
+CVARSDLL=-DINET -DINET6
+
+LINKFLAGS=/LIBPATH:..\usrsctplib usrsctp.lib
+
+.c.obj::
+ $(CC) $(CVARSDLL) $(CFLAGS) -Fd.\ -c $<
+
+all: \
+ programs_helper.obj \
+ client \
+ client_upcall \
+ daytime_server \
+ daytime_server_upcall \
+ discard_server \
+ discard_server_upcall \
+ echo_server \
+ echo_server_upcall \
+ tsctp \
+ rtcweb \
+ ekr_client \
+ ekr_server \
+ ekr_peer \
+ ekr_loop \
+ ekr_loop_offload \
+ ekr_loop_upcall \
+ test_libmgmt \
+ http_client \
+ http_client_upcall \
+ st_client
+
+programs_helper.obj : programs_helper.c programs_helper.h
+ cl $(CVARSDLL) $(CFLAGS) -c programs_helper.c
+
+client:
+ $(CC) $(CFLAGS) $(CVARSDLL) -c client.c
+ link -out:client.exe client.obj programs_helper.obj $(LINKFLAGS)
+
+client_upcall:
+ $(CC) $(CFLAGS) $(CVARSDLL) -c client_upcall.c
+ link -out:client_upcall.exe client_upcall.obj programs_helper.obj $(LINKFLAGS)
+
+daytime_server:
+ $(CC) $(CFLAGS) $(CVARSDLL) -c daytime_server.c
+ link -out:daytime_server.exe daytime_server.obj programs_helper.obj $(LINKFLAGS)
+
+daytime_server_upcall:
+ $(CC) $(CFLAGS) $(CVARSDLL) -c daytime_server_upcall.c
+ link -out:daytime_server_upcall.exe daytime_server_upcall.obj programs_helper.obj $(LINKFLAGS)
+
+discard_server:
+ $(CC) $(CFLAGS) $(CVARSDLL) -c discard_server.c
+ link -out:discard_server.exe discard_server.obj programs_helper.obj $(LINKFLAGS)
+
+discard_server_upcall:
+ $(CC) $(CFLAGS) $(CVARSDLL) -c discard_server_upcall.c
+ link -out:discard_server_upcall.exe discard_server_upcall.obj programs_helper.obj $(LINKFLAGS)
+
+echo_server:
+ $(CC) $(CFLAGS) $(CVARSDLL) -c echo_server.c
+ link -out:echo_server.exe echo_server.obj programs_helper.obj $(LINKFLAGS)
+
+echo_server_upcall:
+ $(CC) $(CFLAGS) $(CVARSDLL) -c echo_server_upcall.c
+ link -out:echo_server_upcall.exe echo_server_upcall.obj programs_helper.obj $(LINKFLAGS)
+
+tsctp:
+ $(CC) $(CFLAGS) $(CVARSDLL) -c tsctp.c
+ link -out:tsctp.exe tsctp.obj programs_helper.obj $(LINKFLAGS)
+
+rtcweb:
+ $(CC) $(CFLAGS) $(CVARSDLL) -c rtcweb.c
+ link -out:rtcweb.exe rtcweb.obj programs_helper.obj $(LINKFLAGS)
+
+ekr_client:
+ $(CC) $(CFLAGS) $(CVARSDLL) -c ekr_client.c
+ link -out:ekr_client.exe ekr_client.obj programs_helper.obj $(LINKFLAGS)
+
+ekr_server:
+ $(CC) $(CFLAGS) $(CVARSDLL) -c ekr_server.c
+ link -out:ekr_server.exe ekr_server.obj programs_helper.obj $(LINKFLAGS)
+
+ekr_peer:
+ $(CC) $(CFLAGS) $(CVARSDLL) -c ekr_peer.c
+ link -out:ekr_peer.exe ekr_peer.obj programs_helper.obj $(LINKFLAGS)
+
+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)
+
+test_libmgmt:
+ $(CC) $(CFLAGS) $(CVARSDLL) -c test_libmgmt.c
+ link -out:test_libmgmt.exe test_libmgmt.obj programs_helper.obj $(LINKFLAGS)
+
+http_client:
+ $(CC) $(CFLAGS) $(CVARSDLL) -c http_client.c
+ link -out:http_client.exe http_client.obj programs_helper.obj $(LINKFLAGS)
+
+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)
+
+clean:
+ del /F client.exe
+ del /F client.obj
+ del /F client_upcall.exe
+ del /F client_upcall.obj
+ del /F daytime_server.exe
+ del /F daytime_server.obj
+ del /F daytime_server_upcall.exe
+ del /F daytime_server_upcall.obj
+ del /F discard_server.exe
+ del /F discard_server.obj
+ del /F discard_server_upcall.exe
+ del /F discard_server_upcall.obj
+ del /F echo_server.exe
+ del /F echo_server.obj
+ del /F echo_server_upcall.exe
+ del /F echo_server_upcall.obj
+ del /F tsctp.exe
+ del /F tsctp.obj
+ del /F rtcweb.exe
+ del /F rtcweb.obj
+ del /F ekr_client.exe
+ del /F ekr_client.obj
+ del /F ekr_server.exe
+ del /F ekr_server.obj
+ del /F ekr_peer.exe
+ 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
+ del /F test_libmgmt.obj
+ del /F http_client.exe
+ del /F http_client.obj
+ del /F http_client_upcall.exe
+ del /F http_client_upcall.obj
+ del /F st_client.exe
+ del /F st_client.obj
diff --git a/chromium/third_party/usrsctp/usrsctplib/programs/chargen_server_upcall.c b/chromium/third_party/usrsctp/usrsctplib/programs/chargen_server_upcall.c
new file mode 100644
index 00000000000..263bd206c75
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/programs/chargen_server_upcall.c
@@ -0,0 +1,231 @@
+/*
+ * Copyright (C) 2012-2013 Michael Tuexen
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * Usage: chargen_server_upcall [local_encaps_port] [remote_encaps_port]
+ */
+
+#ifdef _WIN32
+#define _CRT_SECURE_NO_WARNINGS
+#endif
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+#include <sys/types.h>
+#ifndef _WIN32
+#include <unistd.h>
+#include <time.h>
+#include <sys/socket.h>
+#include <sys/errno.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#endif
+#include <usrsctp.h>
+#include "programs_helper.h"
+
+#define BUFFERSIZE 10240
+#define PORT 19
+
+char buffer[95];
+int done = 0;
+int send_done = 0;
+
+static void
+initBuffer(void) {
+ int i, j;
+ for (i = 32, j = 0; i < 126; i++, j++) {
+ buffer[j] = i;
+ }
+}
+
+unsigned int signCounter = 0;
+static void
+handle_upcall(struct socket *upcall_socket, void *upcall_data, int upcall_flags);
+
+static void
+handle_accept(struct socket *upcall_socket, void *upcall_data, int upcall_flags)
+{
+ struct socket *conn_sock;
+
+ if (((conn_sock = usrsctp_accept(upcall_socket, NULL, NULL)) == NULL)
+ && (errno != EINPROGRESS)) {
+ perror("usrsctp_accept");
+ return;
+ }
+ done = 0;
+ printf("connection accepted from socket %p\n", (void *)conn_sock);
+ usrsctp_set_upcall(conn_sock, handle_upcall, NULL);
+}
+
+static void
+handle_upcall(struct socket *upcall_socket, void *upcall_data, int upcall_flags)
+{
+ int events = usrsctp_get_events(upcall_socket);
+
+ if (events & SCTP_EVENT_READ && !send_done) {
+ char *buf;
+ struct sctp_recvv_rn rn;
+ ssize_t n;
+ struct sockaddr_storage addr;
+ buf = malloc(BUFFERSIZE);
+ int recv_flags = 0;
+ socklen_t len = (socklen_t)sizeof(struct sockaddr_storage);
+ unsigned int infotype = 0;
+ socklen_t infolen = sizeof(struct sctp_recvv_rn);
+ memset(&rn, 0, sizeof(struct sctp_recvv_rn));
+
+ n = usrsctp_recvv(upcall_socket, buf, BUFFERSIZE, (struct sockaddr *) &addr, &len, (void *)&rn,
+ &infolen, &infotype, &recv_flags);
+ if (n < 0) {
+ perror("usrsctp_recvv");
+ done = 1;
+ usrsctp_close(upcall_socket);
+ printf("client socket %p closed\n", (void *)upcall_socket);
+ upcall_socket = NULL;
+ return;
+ }
+ if (n == 0) {
+ done = 1;
+ usrsctp_close(upcall_socket);
+ printf("client socket %p closed\n", (void *)upcall_socket);
+ upcall_socket = NULL;
+ return;
+ }
+ if (n > 0) {
+ if (recv_flags & MSG_NOTIFICATION) {
+ printf("Notification of length %d received.\n", (int)n);
+ } else {
+ printf("data of size %d received\n", (int)n);
+ }
+ }
+ free(buf);
+ }
+
+ if ((events & SCTP_EVENT_WRITE) && !done) {
+ struct sctp_sndinfo snd_info;
+ snd_info.snd_sid = 0;
+ snd_info.snd_flags = 0;
+ snd_info.snd_ppid = 0;
+ snd_info.snd_context = 0;
+ snd_info.snd_assoc_id = 0;
+ if (usrsctp_sendv(upcall_socket, buffer, strlen(buffer), NULL, 0, &snd_info, (socklen_t)sizeof(struct sctp_sndinfo), SCTP_SENDV_SNDINFO, 0) < 0) {
+ if (errno != EAGAIN && errno != EWOULDBLOCK) {
+ send_done = 1;
+ usrsctp_close(upcall_socket);
+ printf("client socket %p closed\n", (void *)upcall_socket);
+ return;
+ }
+ }
+ }
+
+ return;
+}
+
+int
+main(int argc, char *argv[])
+{
+ struct socket *listening_socket;
+ struct sockaddr_in6 addr;
+ struct sctp_udpencaps encaps;
+ struct sctp_assoc_value av;
+ const int on = 1;
+
+ if (argc > 1) {
+ usrsctp_init(atoi(argv[1]), NULL, debug_printf_stack);
+ } else {
+ usrsctp_init(9899, NULL, debug_printf_stack);
+ }
+#ifdef SCTP_DEBUG
+ usrsctp_sysctl_set_sctp_debug_on(SCTP_DEBUG_NONE);
+#endif
+ usrsctp_sysctl_set_sctp_blackhole(2);
+ usrsctp_sysctl_set_sctp_no_csum_on_loopback(0);
+
+ if ((listening_socket = usrsctp_socket(AF_INET6, SOCK_STREAM, IPPROTO_SCTP, NULL, NULL, 0, NULL)) == NULL) {
+ perror("usrsctp_socket");
+ }
+ usrsctp_set_non_blocking(listening_socket, 1);
+ if (usrsctp_setsockopt(listening_socket, IPPROTO_SCTP, SCTP_I_WANT_MAPPED_V4_ADDR, (const void*)&on, (socklen_t)sizeof(int)) < 0) {
+ perror("usrsctp_setsockopt SCTP_I_WANT_MAPPED_V4_ADDR");
+ }
+ memset(&av, 0, sizeof(struct sctp_assoc_value));
+ av.assoc_id = SCTP_ALL_ASSOC;
+ av.assoc_value = 47;
+
+ if (usrsctp_setsockopt(listening_socket, IPPROTO_SCTP, SCTP_CONTEXT, (const void*)&av, (socklen_t)sizeof(struct sctp_assoc_value)) < 0) {
+ perror("usrsctp_setsockopt SCTP_CONTEXT");
+ }
+ if (usrsctp_setsockopt(listening_socket, IPPROTO_SCTP, SCTP_RECVRCVINFO, &on, sizeof(int)) < 0) {
+ perror("usrsctp_setsockopt SCTP_RECVRCVINFO");
+ }
+ if (argc > 2) {
+ memset(&encaps, 0, sizeof(struct sctp_udpencaps));
+ encaps.sue_address.ss_family = AF_INET6;
+ encaps.sue_port = htons(atoi(argv[2]));
+ if (usrsctp_setsockopt(listening_socket, IPPROTO_SCTP, SCTP_REMOTE_UDP_ENCAPS_PORT, (const void*)&encaps, (socklen_t)sizeof(struct sctp_udpencaps)) < 0) {
+ perror("usrsctp_setsockopt SCTP_REMOTE_UDP_ENCAPS_PORT");
+ }
+ }
+
+ initBuffer();
+
+ memset((void *)&addr, 0, sizeof(struct sockaddr_in6));
+#ifdef HAVE_SIN6_LEN
+ addr.sin6_len = sizeof(struct sockaddr_in6);
+#endif
+ addr.sin6_family = AF_INET6;
+ addr.sin6_port = htons(PORT);
+ addr.sin6_addr = in6addr_any;
+ if (usrsctp_bind(listening_socket, (struct sockaddr *)&addr, sizeof(struct sockaddr_in6)) < 0) {
+ perror("usrsctp_bind");
+ }
+ if (usrsctp_listen(listening_socket, 1) < 0) {
+ perror("usrsctp_listen");
+ }
+ usrsctp_set_upcall(listening_socket, handle_accept, NULL);
+
+ while (1) {
+#ifdef _WIN32
+ Sleep(1*1000);
+#else
+ sleep(1);
+#endif
+ }
+ usrsctp_close(listening_socket);
+ while (usrsctp_finish() != 0) {
+#ifdef _WIN32
+ Sleep(1000);
+#else
+ sleep(1);
+#endif
+ }
+ return (0);
+}
diff --git a/chromium/third_party/usrsctp/usrsctplib/programs/client.c b/chromium/third_party/usrsctp/usrsctplib/programs/client.c
index 1fe75791de2..8a15a7be82d 100644
--- a/chromium/third_party/usrsctp/usrsctplib/programs/client.c
+++ b/chromium/third_party/usrsctp/usrsctplib/programs/client.c
@@ -51,6 +51,7 @@
#include <io.h>
#endif
#include <usrsctp.h>
+#include "programs_helper.h"
int done = 0;
@@ -58,205 +59,7 @@ int done = 0;
typedef char* caddr_t;
#endif
-static void
-handle_association_change_event(struct sctp_assoc_change *sac)
-{
- unsigned int i, n;
- printf("Association change ");
- switch (sac->sac_state) {
- case SCTP_COMM_UP:
- printf("SCTP_COMM_UP");
- break;
- case SCTP_COMM_LOST:
- printf("SCTP_COMM_LOST");
- break;
- case SCTP_RESTART:
- printf("SCTP_RESTART");
- break;
- case SCTP_SHUTDOWN_COMP:
- printf("SCTP_SHUTDOWN_COMP");
- break;
- case SCTP_CANT_STR_ASSOC:
- printf("SCTP_CANT_STR_ASSOC");
- break;
- default:
- printf("UNKNOWN");
- break;
- }
- printf(", streams (in/out) = (%u/%u)",
- sac->sac_inbound_streams, sac->sac_outbound_streams);
- n = sac->sac_length - sizeof(struct sctp_assoc_change);
- if (((sac->sac_state == SCTP_COMM_UP) ||
- (sac->sac_state == SCTP_RESTART)) && (n > 0)) {
- printf(", supports");
- for (i = 0; i < n; i++) {
- switch (sac->sac_info[i]) {
- case SCTP_ASSOC_SUPPORTS_PR:
- printf(" PR");
- break;
- case SCTP_ASSOC_SUPPORTS_AUTH:
- printf(" AUTH");
- break;
- case SCTP_ASSOC_SUPPORTS_ASCONF:
- printf(" ASCONF");
- break;
- case SCTP_ASSOC_SUPPORTS_MULTIBUF:
- printf(" MULTIBUF");
- break;
- case SCTP_ASSOC_SUPPORTS_RE_CONFIG:
- printf(" RE-CONFIG");
- break;
- default:
- printf(" UNKNOWN(0x%02x)", sac->sac_info[i]);
- break;
- }
- }
- } else if (((sac->sac_state == SCTP_COMM_LOST) ||
- (sac->sac_state == SCTP_CANT_STR_ASSOC)) && (n > 0)) {
- printf(", ABORT =");
- for (i = 0; i < n; i++) {
- printf(" 0x%02x", sac->sac_info[i]);
- }
- }
- printf(".\n");
- if ((sac->sac_state == SCTP_CANT_STR_ASSOC) ||
- (sac->sac_state == SCTP_SHUTDOWN_COMP) ||
- (sac->sac_state == SCTP_COMM_LOST)) {
- exit(0);
- }
- return;
-}
-
-static void
-handle_peer_address_change_event(struct sctp_paddr_change *spc)
-{
- char addr_buf[INET6_ADDRSTRLEN];
- const char *addr;
- struct sockaddr_in *sin;
- struct sockaddr_in6 *sin6;
- struct sockaddr_conn *sconn;
-
- switch (spc->spc_aaddr.ss_family) {
- case AF_INET:
- sin = (struct sockaddr_in *)&spc->spc_aaddr;
- addr = inet_ntop(AF_INET, &sin->sin_addr, addr_buf, INET_ADDRSTRLEN);
- break;
- case AF_INET6:
- sin6 = (struct sockaddr_in6 *)&spc->spc_aaddr;
- addr = inet_ntop(AF_INET6, &sin6->sin6_addr, addr_buf, INET6_ADDRSTRLEN);
- break;
- case AF_CONN:
- sconn = (struct sockaddr_conn *)&spc->spc_aaddr;
-#ifdef _WIN32
- _snprintf(addr_buf, INET6_ADDRSTRLEN, "%p", sconn->sconn_addr);
-#else
- snprintf(addr_buf, INET6_ADDRSTRLEN, "%p", sconn->sconn_addr);
-#endif
- addr = addr_buf;
- break;
- default:
-#ifdef _WIN32
- _snprintf(addr_buf, INET6_ADDRSTRLEN, "Unknown family %d", spc->spc_aaddr.ss_family);
-#else
- snprintf(addr_buf, INET6_ADDRSTRLEN, "Unknown family %d", spc->spc_aaddr.ss_family);
-#endif
- addr = addr_buf;
- break;
- }
- printf("Peer address %s is now ", addr);
- switch (spc->spc_state) {
- case SCTP_ADDR_AVAILABLE:
- printf("SCTP_ADDR_AVAILABLE");
- break;
- case SCTP_ADDR_UNREACHABLE:
- printf("SCTP_ADDR_UNREACHABLE");
- break;
- case SCTP_ADDR_REMOVED:
- printf("SCTP_ADDR_REMOVED");
- break;
- case SCTP_ADDR_ADDED:
- printf("SCTP_ADDR_ADDED");
- break;
- case SCTP_ADDR_MADE_PRIM:
- printf("SCTP_ADDR_MADE_PRIM");
- break;
- case SCTP_ADDR_CONFIRMED:
- printf("SCTP_ADDR_CONFIRMED");
- break;
- default:
- printf("UNKNOWN");
- break;
- }
- printf(" (error = 0x%08x).\n", spc->spc_error);
- return;
-}
-
-static void
-handle_send_failed_event(struct sctp_send_failed_event *ssfe)
-{
- size_t i, n;
-
- if (ssfe->ssfe_flags & SCTP_DATA_UNSENT) {
- printf("Unsent ");
- }
- if (ssfe->ssfe_flags & SCTP_DATA_SENT) {
- printf("Sent ");
- }
- if (ssfe->ssfe_flags & ~(SCTP_DATA_SENT | SCTP_DATA_UNSENT)) {
- printf("(flags = %x) ", ssfe->ssfe_flags);
- }
- printf("message with PPID = %u, SID = %u, flags: 0x%04x due to error = 0x%08x",
- ntohl(ssfe->ssfe_info.snd_ppid), ssfe->ssfe_info.snd_sid,
- ssfe->ssfe_info.snd_flags, ssfe->ssfe_error);
- n = ssfe->ssfe_length - sizeof(struct sctp_send_failed_event);
- for (i = 0; i < n; i++) {
- printf(" 0x%02x", ssfe->ssfe_data[i]);
- }
- printf(".\n");
- return;
-}
-
-static void
-handle_notification(union sctp_notification *notif, size_t n)
-{
- if (notif->sn_header.sn_length != (uint32_t)n) {
- return;
- }
- switch (notif->sn_header.sn_type) {
- case SCTP_ASSOC_CHANGE:
- handle_association_change_event(&(notif->sn_assoc_change));
- break;
- case SCTP_PEER_ADDR_CHANGE:
- handle_peer_address_change_event(&(notif->sn_paddr_change));
- break;
- case SCTP_REMOTE_ERROR:
- break;
- case SCTP_SHUTDOWN_EVENT:
- break;
- case SCTP_ADAPTATION_INDICATION:
- break;
- case SCTP_PARTIAL_DELIVERY_EVENT:
- break;
- case SCTP_AUTHENTICATION_EVENT:
- break;
- case SCTP_SENDER_DRY_EVENT:
- break;
- case SCTP_NOTIFICATIONS_STOPPED_EVENT:
- break;
- case SCTP_SEND_FAILED_EVENT:
- handle_send_failed_event(&(notif->sn_send_failed_event));
- break;
- case SCTP_STREAM_RESET_EVENT:
- break;
- case SCTP_ASSOC_RESET_EVENT:
- break;
- case SCTP_STREAM_CHANGE_EVENT:
- break;
- default:
- break;
- }
-}
static int
receive_cb(struct socket *sock, union sctp_sockstore addr, void *data,
@@ -282,16 +85,6 @@ receive_cb(struct socket *sock, union sctp_sockstore addr, void *data,
return (1);
}
-void
-debug_printf(const char *format, ...)
-{
- va_list ap;
-
- va_start(ap, format);
- vprintf(format, ap);
- va_end(ap);
-}
-
int
main(int argc, char *argv[])
{
@@ -314,14 +107,16 @@ main(int argc, char *argv[])
return (-1);
}
if (argc > 4) {
- usrsctp_init(atoi(argv[4]), NULL, debug_printf);
+ usrsctp_init(atoi(argv[4]), NULL, debug_printf_stack);
} else {
- usrsctp_init(9899, NULL, debug_printf);
+ usrsctp_init(9899, NULL, debug_printf_stack);
}
#ifdef SCTP_DEBUG
usrsctp_sysctl_set_sctp_debug_on(SCTP_DEBUG_NONE);
#endif
usrsctp_sysctl_set_sctp_blackhole(2);
+ usrsctp_sysctl_set_sctp_no_csum_on_loopback(0);
+
if ((sock = usrsctp_socket(AF_INET6, SOCK_STREAM, IPPROTO_SCTP, receive_cb, NULL, 0, NULL)) == NULL) {
perror("usrsctp_socket");
}
diff --git a/chromium/third_party/usrsctp/usrsctplib/programs/client_upcall.c b/chromium/third_party/usrsctp/usrsctplib/programs/client_upcall.c
new file mode 100644
index 00000000000..9d55a385a6c
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/programs/client_upcall.c
@@ -0,0 +1,340 @@
+/*
+ * Copyright (C) 2011-2013 Michael Tuexen
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * Usage: client_upcall remote_addr remote_port [local_port] [local_encaps_port] [remote_encaps_port]
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+
+#if !defined(_WIN32)
+#include <unistd.h>
+#include <sys/time.h>
+#endif /* !defined(_WIN32) */
+
+#include <sys/types.h>
+
+#if !defined(_WIN32)
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#else /* !defined(_WIN32) */
+#include <io.h>
+#endif
+
+#include <usrsctp.h>
+#include "programs_helper.h"
+#include <fcntl.h>
+
+#define BUFFERSIZE (1<<16)
+
+int done = 0, input_done = 0, connected = 0;
+
+#ifdef _WIN32
+typedef char* caddr_t;
+#endif
+
+int inputAvailable(void)
+{
+ struct timeval tv;
+ fd_set fds;
+ tv.tv_sec = 0;
+ tv.tv_usec = 0;
+ FD_ZERO(&fds);
+#if defined(_WIN32) && !defined(__MINGW32__)
+ FD_SET(_fileno(stdin), &fds);
+ select(_fileno(stdin) + 1, &fds, NULL, NULL, &tv);
+#else
+ FD_SET(STDIN_FILENO, &fds);
+ select(STDIN_FILENO+1, &fds, NULL, NULL, &tv);
+#endif
+ return (FD_ISSET(0, &fds));
+}
+
+static void
+handle_upcall(struct socket *sock, void *arg, int flgs)
+{
+ int events = usrsctp_get_events(sock);
+
+ if (events & SCTP_EVENT_WRITE && !done && !connected) {
+ connected = 1;
+ printf("socket connected\n");
+ return;
+ }
+
+ while (events & SCTP_EVENT_READ && !done && connected) {
+ struct sctp_recvv_rn rn;
+ ssize_t n;
+ struct sockaddr_in addr;
+ char *buf = calloc(1, BUFFERSIZE);
+ int flags = 0;
+ socklen_t len = (socklen_t)sizeof(struct sockaddr_in);
+ unsigned int infotype = 0;
+ socklen_t infolen = sizeof(struct sctp_recvv_rn);
+ memset(&rn, 0, sizeof(struct sctp_recvv_rn));
+ n = usrsctp_recvv(sock, buf, BUFFERSIZE, (struct sockaddr *) &addr, &len, (void *)&rn,
+ &infolen, &infotype, &flags);
+
+ if (n > 0) {
+#ifdef _WIN32
+ _write(_fileno(stdout), buf, (unsigned int)n);
+#else
+ if (write(fileno(stdout), buf, n) < 0) {
+ perror("write");
+ }
+#endif
+ } else if (n == 0) {
+ done = 1;
+ input_done = 1;
+ free(buf);
+ break;
+ } else {
+ perror("\nusrsctp_recvv");
+ free (buf);
+ break;
+ }
+ free(buf);
+ events = usrsctp_get_events(sock);
+ }
+ return;
+}
+
+int
+main(int argc, char *argv[])
+{
+ struct socket *sock;
+ struct sockaddr *addr, *addrs;
+ struct sockaddr_in addr4;
+ struct sockaddr_in6 addr6;
+ struct sctp_udpencaps encaps;
+ struct sctpstat stat;
+ char buffer[200];
+ int i, n;
+
+ if (argc > 4) {
+ usrsctp_init(atoi(argv[4]), NULL, debug_printf_stack);
+ } else {
+ usrsctp_init(9899, NULL, debug_printf_stack);
+ }
+#ifdef SCTP_DEBUG
+ usrsctp_sysctl_set_sctp_debug_on(SCTP_DEBUG_NONE);
+#endif
+ usrsctp_sysctl_set_sctp_blackhole(2);
+ usrsctp_sysctl_set_sctp_no_csum_on_loopback(0);
+
+ if ((sock = usrsctp_socket(AF_INET6, SOCK_STREAM, IPPROTO_SCTP, NULL, NULL, 0, NULL)) == NULL) {
+ perror("usrsctp_socket");
+ exit(1);
+ }
+
+ usrsctp_set_non_blocking(sock, 1);
+
+ if (argc > 3) {
+ memset((void *)&addr6, 0, sizeof(struct sockaddr_in6));
+#ifdef HAVE_SIN6_LEN
+ addr6.sin6_len = sizeof(struct sockaddr_in6);
+#endif
+ addr6.sin6_family = AF_INET6;
+ addr6.sin6_port = htons(atoi(argv[3]));
+ addr6.sin6_addr = in6addr_any;
+ if (usrsctp_bind(sock, (struct sockaddr *)&addr6, sizeof(struct sockaddr_in6)) < 0) {
+ perror("bind");
+ usrsctp_close(sock);
+ exit(1);
+ }
+ }
+ if (argc > 5) {
+ memset(&encaps, 0, sizeof(struct sctp_udpencaps));
+ encaps.sue_address.ss_family = AF_INET6;
+ encaps.sue_port = htons(atoi(argv[5]));
+ if (usrsctp_setsockopt(sock, IPPROTO_SCTP, SCTP_REMOTE_UDP_ENCAPS_PORT, (const void*)&encaps, (socklen_t)sizeof(struct sctp_udpencaps)) < 0) {
+ perror("setsockopt");
+ usrsctp_close(sock);
+ exit(1);
+ }
+ }
+
+ memset((void *)&addr4, 0, sizeof(struct sockaddr_in));
+ memset((void *)&addr6, 0, sizeof(struct sockaddr_in6));
+#ifdef HAVE_SIN_LEN
+ addr4.sin_len = sizeof(struct sockaddr_in);
+#endif
+#ifdef HAVE_SIN6_LEN
+ addr6.sin6_len = sizeof(struct sockaddr_in6);
+#endif
+ addr4.sin_family = AF_INET;
+ addr6.sin6_family = AF_INET6;
+ addr4.sin_port = htons(atoi(argv[2]));
+ addr6.sin6_port = htons(atoi(argv[2]));
+ if (inet_pton(AF_INET6, argv[1], &addr6.sin6_addr) == 1) {
+ if (usrsctp_connect(sock, (struct sockaddr *)&addr6, sizeof(struct sockaddr_in6)) < 0) {
+ perror("usrsctp_connect");
+ }
+ } else if (inet_pton(AF_INET, argv[1], &addr4.sin_addr) == 1) {
+ if (usrsctp_connect(sock, (struct sockaddr *)&addr4, sizeof(struct sockaddr_in)) < 0) {
+ perror("usrsctp_connect");
+ }
+ } else {
+ printf("Illegal destination address.\n");
+ }
+
+ usrsctp_set_upcall(sock, handle_upcall, NULL);
+ if ((n = usrsctp_getladdrs(sock, 0, &addrs)) < 0) {
+ perror("usrsctp_getladdrs");
+ } else {
+ addr = addrs;
+ printf("Local addresses: ");
+ for (i = 0; i < n; i++) {
+ if (i > 0) {
+ printf("%s", ", ");
+ }
+ switch (addr->sa_family) {
+ case AF_INET:
+ {
+ struct sockaddr_in *sin;
+ char buf[INET_ADDRSTRLEN];
+ const char *name;
+
+ sin = (struct sockaddr_in *)addr;
+ name = inet_ntop(AF_INET, &sin->sin_addr, buf, INET_ADDRSTRLEN);
+ printf("%s", name);
+#ifndef HAVE_SA_LEN
+ addr = (struct sockaddr *)((caddr_t)addr + sizeof(struct sockaddr_in));
+#endif
+ break;
+ }
+ case AF_INET6:
+ {
+ struct sockaddr_in6 *sin6;
+ char buf[INET6_ADDRSTRLEN];
+ const char *name;
+
+ sin6 = (struct sockaddr_in6 *)addr;
+ name = inet_ntop(AF_INET6, &sin6->sin6_addr, buf, INET6_ADDRSTRLEN);
+ printf("%s", name);
+#ifndef HAVE_SA_LEN
+ addr = (struct sockaddr *)((caddr_t)addr + sizeof(struct sockaddr_in6));
+#endif
+ break;
+ }
+ default:
+ break;
+ }
+#ifdef HAVE_SA_LEN
+ addr = (struct sockaddr *)((caddr_t)addr + addr->sa_len);
+#endif
+ }
+ printf(".\n");
+ usrsctp_freeladdrs(addrs);
+ }
+ if ((n = usrsctp_getpaddrs(sock, 0, &addrs)) < 0) {
+ perror("usrsctp_getpaddrs");
+ } else {
+ addr = addrs;
+ printf("Peer addresses: ");
+ for (i = 0; i < n; i++) {
+ if (i > 0) {
+ printf("%s", ", ");
+ }
+ switch (addr->sa_family) {
+ case AF_INET:
+ {
+ struct sockaddr_in *sin;
+ char buf[INET_ADDRSTRLEN];
+ const char *name;
+
+ sin = (struct sockaddr_in *)addr;
+ name = inet_ntop(AF_INET, &sin->sin_addr, buf, INET_ADDRSTRLEN);
+ printf("%s", name);
+#ifndef HAVE_SA_LEN
+ addr = (struct sockaddr *)((caddr_t)addr + sizeof(struct sockaddr_in));
+#endif
+ break;
+ }
+ case AF_INET6:
+ {
+ struct sockaddr_in6 *sin6;
+ char buf[INET6_ADDRSTRLEN];
+ const char *name;
+
+ sin6 = (struct sockaddr_in6 *)addr;
+ name = inet_ntop(AF_INET6, &sin6->sin6_addr, buf, INET6_ADDRSTRLEN);
+ printf("%s", name);
+#ifndef HAVE_SA_LEN
+ addr = (struct sockaddr *)((caddr_t)addr + sizeof(struct sockaddr_in6));
+#endif
+ break;
+ }
+ default:
+ break;
+ }
+#ifdef HAVE_SA_LEN
+ addr = (struct sockaddr *)((caddr_t)addr + addr->sa_len);
+#endif
+ }
+ printf(".\n");
+ usrsctp_freepaddrs(addrs);
+ }
+ while (!done && !input_done) {
+ if (inputAvailable()) {
+ if (fgets(buffer, sizeof(buffer), stdin) != NULL) {
+ buffer[strlen(buffer)] = '\0';
+ usrsctp_sendv(sock, buffer, strlen(buffer), NULL, 0, NULL, 0, SCTP_SENDV_NOINFO, 0);
+ } else {
+ if (usrsctp_shutdown(sock, SHUT_WR) < 0) {
+ perror("usrsctp_shutdown");
+ }
+ break;
+ }
+ }
+ }
+#ifdef _WIN32
+ Sleep(1000);
+#else
+ sleep(1);
+#endif
+ usrsctp_close(sock);
+
+ usrsctp_get_stat(&stat);
+ printf("Number of packets (sent/received): (%u/%u).\n",
+ stat.sctps_outpackets, stat.sctps_inpackets);
+ while (usrsctp_finish() != 0) {
+#ifdef _WIN32
+ Sleep(1000);
+#else
+ sleep(1);
+#endif
+ }
+ printf("Client finished\n");
+ return(0);
+}
diff --git a/chromium/third_party/usrsctp/usrsctplib/programs/daytime_server.c b/chromium/third_party/usrsctp/usrsctplib/programs/daytime_server.c
index 35cadf53d11..3e03dc1fbf3 100644
--- a/chromium/third_party/usrsctp/usrsctplib/programs/daytime_server.c
+++ b/chromium/third_party/usrsctp/usrsctplib/programs/daytime_server.c
@@ -52,21 +52,12 @@
#include <arpa/inet.h>
#endif
#include <usrsctp.h>
+#include "programs_helper.h"
#define PORT 13
#define DAYTIME_PPID 40
#define SLEEP 1
-void
-debug_printf(const char *format, ...)
-{
- va_list ap;
-
- va_start(ap, format);
- vprintf(format, ap);
- va_end(ap);
-}
-
int
main(int argc, char *argv[])
{
@@ -79,14 +70,15 @@ main(int argc, char *argv[])
struct sctp_sndinfo sndinfo;
if (argc > 1) {
- usrsctp_init(atoi(argv[1]), NULL, debug_printf);
+ usrsctp_init(atoi(argv[1]), NULL, debug_printf_stack);
} else {
- usrsctp_init(9899, NULL, debug_printf);
+ usrsctp_init(9899, NULL, debug_printf_stack);
}
#ifdef SCTP_DEBUG
usrsctp_sysctl_set_sctp_debug_on(SCTP_DEBUG_NONE);
#endif
usrsctp_sysctl_set_sctp_blackhole(2);
+ usrsctp_sysctl_set_sctp_no_csum_on_loopback(0);
if ((sock = usrsctp_socket(AF_INET, SOCK_STREAM, IPPROTO_SCTP, NULL, NULL, 0, NULL)) == NULL) {
perror("usrsctp_socket");
diff --git a/chromium/third_party/usrsctp/usrsctplib/programs/daytime_server_upcall.c b/chromium/third_party/usrsctp/usrsctplib/programs/daytime_server_upcall.c
new file mode 100644
index 00000000000..b85cb256776
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/programs/daytime_server_upcall.c
@@ -0,0 +1,148 @@
+/*
+ * Copyright (C) 2012-2013 Michael Tuexen
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * Usage: daytime_server_upcall [local_encaps_port] [remote_encaps_port]
+ */
+
+#ifdef _WIN32
+#define _CRT_SECURE_NO_WARNINGS
+#endif
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+#include <sys/types.h>
+#include <time.h>
+#ifndef _WIN32
+#include <unistd.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#endif
+#include <usrsctp.h>
+#include "programs_helper.h"
+
+#define DAYTIME_PPID 40
+#define PORT 13
+
+static void
+handle_accept(struct socket *sock, void *data, int flags)
+{
+ struct socket *conn_sock;
+ char buffer[80];
+ time_t now;
+ socklen_t addr_len = 0;
+ struct sctp_sndinfo sndinfo;
+
+ if (((conn_sock = usrsctp_accept(sock, NULL, &addr_len)) == NULL)
+ && (errno != EINPROGRESS)) {
+ perror("usrsctp_accept");
+ return;
+ }
+ time(&now);
+#ifdef _WIN32
+ _snprintf(buffer, sizeof(buffer), "%s", ctime(&now));
+#else
+ snprintf(buffer, sizeof(buffer), "%s", ctime(&now));
+#endif
+ sndinfo.snd_sid = 0;
+ sndinfo.snd_flags = 0;
+ sndinfo.snd_ppid = htonl(DAYTIME_PPID);
+ sndinfo.snd_context = 0;
+ sndinfo.snd_assoc_id = 0;
+ usrsctp_sendv(conn_sock, buffer, strlen(buffer), NULL, 0, (void *)&sndinfo,
+ (socklen_t)sizeof(struct sctp_sndinfo), SCTP_SENDV_SNDINFO, 0);
+ usrsctp_close(conn_sock);
+}
+
+int
+main(int argc, char *argv[])
+{
+ struct socket *sock;
+ struct sockaddr_in addr;
+ struct sctp_udpencaps encaps;
+
+ if (argc > 1) {
+ usrsctp_init(atoi(argv[1]), NULL, debug_printf_stack);
+ } else {
+ usrsctp_init(9899, NULL, debug_printf_stack);
+ }
+#ifdef SCTP_DEBUG
+ usrsctp_sysctl_set_sctp_debug_on(SCTP_DEBUG_NONE);
+#endif
+ usrsctp_sysctl_set_sctp_blackhole(2);
+ usrsctp_sysctl_set_sctp_no_csum_on_loopback(0);
+
+ if ((sock = usrsctp_socket(AF_INET, SOCK_STREAM, IPPROTO_SCTP, NULL, NULL, 0, NULL)) == NULL) {
+ perror("usrsctp_socket");
+ }
+ usrsctp_set_non_blocking(sock, 1);
+ if (argc > 2) {
+ memset(&encaps, 0, sizeof(struct sctp_udpencaps));
+ encaps.sue_address.ss_family = AF_INET;
+ encaps.sue_port = htons(atoi(argv[2]));
+ if (usrsctp_setsockopt(sock, IPPROTO_SCTP, SCTP_REMOTE_UDP_ENCAPS_PORT, (const void*)&encaps, (socklen_t)sizeof(struct sctp_udpencaps)) < 0) {
+ perror("setsockopt");
+ }
+ }
+ memset((void *)&addr, 0, sizeof(struct sockaddr_in));
+#ifdef HAVE_SIN_LEN
+ addr.sin_len = sizeof(struct sockaddr_in);
+#endif
+ addr.sin_family = AF_INET;
+ addr.sin_port = htons(PORT);
+ addr.sin_addr.s_addr = htonl(INADDR_ANY);
+ if (usrsctp_bind(sock, (struct sockaddr *)&addr, sizeof(struct sockaddr_in)) < 0) {
+ perror("usrsctp_bind");
+ }
+ if (usrsctp_listen(sock, 1) < 0) {
+ perror("usrsctp_listen");
+ }
+
+ usrsctp_set_upcall(sock, handle_accept, NULL);
+
+ while (1) {
+#ifdef _WIN32
+ Sleep(1*1000);
+#else
+ sleep(1);
+#endif
+ }
+ usrsctp_close(sock);
+ while (usrsctp_finish() != 0) {
+#ifdef _WIN32
+ Sleep(1000);
+#else
+ sleep(1);
+#endif
+ }
+ return (0);
+}
diff --git a/chromium/third_party/usrsctp/usrsctplib/programs/discard_server.c b/chromium/third_party/usrsctp/usrsctplib/programs/discard_server.c
index 39846dded04..e469b363e35 100644
--- a/chromium/third_party/usrsctp/usrsctplib/programs/discard_server.c
+++ b/chromium/third_party/usrsctp/usrsctplib/programs/discard_server.c
@@ -51,6 +51,7 @@
#include <arpa/inet.h>
#endif
#include <usrsctp.h>
+#include "programs_helper.h"
#define PORT 9
#define BUFFER_SIZE 10240
@@ -112,16 +113,6 @@ receive_cb(struct socket *sock, union sctp_sockstore addr, void *data,
return (1);
}
-void
-debug_printf(const char *format, ...)
-{
- va_list ap;
-
- va_start(ap, format);
- vprintf(format, ap);
- va_end(ap);
-}
-
int
main(int argc, char *argv[])
{
@@ -148,14 +139,15 @@ main(int argc, char *argv[])
unsigned int infotype;
if (argc > 1) {
- usrsctp_init(atoi(argv[1]), NULL, debug_printf);
+ usrsctp_init(atoi(argv[1]), NULL, debug_printf_stack);
} else {
- usrsctp_init(9899, NULL, debug_printf);
+ usrsctp_init(9899, NULL, debug_printf_stack);
}
#ifdef SCTP_DEBUG
usrsctp_sysctl_set_sctp_debug_on(SCTP_DEBUG_ALL);
#endif
usrsctp_sysctl_set_sctp_blackhole(2);
+ usrsctp_sysctl_set_sctp_no_csum_on_loopback(0);
if ((sock = usrsctp_socket(AF_INET6, SOCK_SEQPACKET, IPPROTO_SCTP, use_cb?receive_cb:NULL, NULL, 0, NULL)) == NULL) {
perror("usrsctp_socket");
diff --git a/chromium/third_party/usrsctp/usrsctplib/programs/discard_server_upcall.c b/chromium/third_party/usrsctp/usrsctplib/programs/discard_server_upcall.c
new file mode 100644
index 00000000000..881bf0d94ee
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/programs/discard_server_upcall.c
@@ -0,0 +1,234 @@
+/*
+ * Copyright (C) 2011-2013 Michael Tuexen
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * Usage: discard_server_upcall [local_encaps_port] [remote_encaps_port]
+ */
+
+#ifdef _WIN32
+#define _CRT_SECURE_NO_WARNINGS
+#endif
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+#include <sys/types.h>
+#ifndef _WIN32
+#include <unistd.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#endif
+#include <usrsctp.h>
+#include "programs_helper.h"
+
+#define BUFFERSIZE 10240
+#define PORT 9
+
+
+static void
+handle_upcall(struct socket *sock, void *data, int flgs)
+{
+ char namebuf[INET6_ADDRSTRLEN];
+ const char *name;
+ uint16_t port;
+ char *buf;
+ int events;
+
+ while ((events = usrsctp_get_events(sock)) && (events & SCTP_EVENT_READ)) {
+ struct sctp_recvv_rn rn;
+ ssize_t n;
+ struct sockaddr_storage addr;
+ buf = malloc(BUFFERSIZE);
+ int flags = 0;
+ socklen_t len = (socklen_t)sizeof(struct sockaddr_storage);
+ unsigned int infotype = 0;
+ socklen_t infolen = sizeof(struct sctp_recvv_rn);
+ memset(&rn, 0, sizeof(struct sctp_recvv_rn));
+ n = usrsctp_recvv(sock, buf, BUFFERSIZE, (struct sockaddr *) &addr, &len, (void *)&rn,
+ &infolen, &infotype, &flags);
+ if (n < 0) {
+ perror("usrsctp_recvv");
+ }
+ if (n > 0) {
+ if (flags & MSG_NOTIFICATION) {
+ printf("Notification of length %d received.\n", (int)n);
+ } else {
+/*
+#ifdef _WIN32
+ _write(_fileno(stdout), buf, (unsigned int)n);
+#else
+ if (write(fileno(stdout), buf, n) < 0) {
+ perror("write");
+ }
+#endif
+*/
+ switch (addr.ss_family) {
+#ifdef INET
+ case AF_INET: {
+ struct sockaddr_in addr4;
+ memcpy(&addr4, (struct sockaddr_in *)&addr, sizeof(struct sockaddr_in));
+ name = inet_ntop(AF_INET, &addr4.sin_addr, namebuf, INET_ADDRSTRLEN);
+ port = ntohs(addr4.sin_port);
+ break;
+ }
+#endif
+#ifdef INET6
+ case AF_INET6: {
+ struct sockaddr_in6 addr6;
+ memcpy(&addr6, (struct sockaddr_in6 *)&addr, sizeof(struct sockaddr_in6));
+ name = inet_ntop(AF_INET6, &addr6.sin6_addr, namebuf, INET6_ADDRSTRLEN),
+ port = ntohs(addr6.sin6_port);
+ break;
+ }
+#endif
+ default:
+ name = NULL;
+ port = 0;
+ break;
+ }
+
+ if (name == NULL) {
+ printf("inet_ntop failed\n");
+ free(buf);
+ return;
+ }
+
+ printf("Msg of length %d received from %s:%u on stream %d with SSN %u and TSN %u, PPID %u, context %u.\n",
+ (int)n,
+ namebuf,
+ port,
+ rn.recvv_rcvinfo.rcv_sid,
+ rn.recvv_rcvinfo.rcv_ssn,
+ rn.recvv_rcvinfo.rcv_tsn,
+ ntohl(rn.recvv_rcvinfo.rcv_ppid),
+ rn.recvv_rcvinfo.rcv_context);
+ }
+ }
+ free(buf);
+ }
+ return;
+}
+
+int
+main(int argc, char *argv[])
+{
+ struct socket *sock;
+ struct sockaddr_in6 addr;
+ struct sctp_udpencaps encaps;
+ struct sctp_event event;
+ uint16_t event_types[] = {SCTP_ASSOC_CHANGE,
+ SCTP_PEER_ADDR_CHANGE,
+ SCTP_REMOTE_ERROR,
+ SCTP_SHUTDOWN_EVENT,
+ SCTP_ADAPTATION_INDICATION,
+ SCTP_PARTIAL_DELIVERY_EVENT};
+ unsigned int i;
+ struct sctp_assoc_value av;
+ const int on = 1;
+
+ if (argc > 1) {
+ usrsctp_init(atoi(argv[1]), NULL, debug_printf_stack);
+ } else {
+ usrsctp_init(9899, NULL, debug_printf_stack);
+ }
+#ifdef SCTP_DEBUG
+ usrsctp_sysctl_set_sctp_debug_on(SCTP_DEBUG_NONE);
+#endif
+ usrsctp_sysctl_set_sctp_blackhole(2);
+ usrsctp_sysctl_set_sctp_no_csum_on_loopback(0);
+
+ if ((sock = usrsctp_socket(AF_INET6, SOCK_SEQPACKET, IPPROTO_SCTP, NULL, NULL, 0, NULL)) == NULL) {
+ perror("usrsctp_socket");
+ }
+ usrsctp_set_non_blocking(sock, 1);
+ if (usrsctp_setsockopt(sock, IPPROTO_SCTP, SCTP_I_WANT_MAPPED_V4_ADDR, (const void*)&on, (socklen_t)sizeof(int)) < 0) {
+ perror("usrsctp_setsockopt SCTP_I_WANT_MAPPED_V4_ADDR");
+ }
+ memset(&av, 0, sizeof(struct sctp_assoc_value));
+ av.assoc_id = SCTP_ALL_ASSOC;
+ av.assoc_value = 47;
+
+ if (usrsctp_setsockopt(sock, IPPROTO_SCTP, SCTP_CONTEXT, (const void*)&av, (socklen_t)sizeof(struct sctp_assoc_value)) < 0) {
+ perror("usrsctp_setsockopt SCTP_CONTEXT");
+ }
+ if (usrsctp_setsockopt(sock, IPPROTO_SCTP, SCTP_RECVRCVINFO, &on, sizeof(int)) < 0) {
+ perror("usrsctp_setsockopt SCTP_RECVRCVINFO");
+ }
+ if (argc > 2) {
+ memset(&encaps, 0, sizeof(struct sctp_udpencaps));
+ encaps.sue_address.ss_family = AF_INET6;
+ encaps.sue_port = htons(atoi(argv[2]));
+ if (usrsctp_setsockopt(sock, IPPROTO_SCTP, SCTP_REMOTE_UDP_ENCAPS_PORT, (const void*)&encaps, (socklen_t)sizeof(struct sctp_udpencaps)) < 0) {
+ perror("usrsctp_setsockopt SCTP_REMOTE_UDP_ENCAPS_PORT");
+ }
+ }
+ memset(&event, 0, sizeof(event));
+ event.se_assoc_id = SCTP_FUTURE_ASSOC;
+ event.se_on = 1;
+ for (i = 0; i < (unsigned int)(sizeof(event_types)/sizeof(uint16_t)); i++) {
+ event.se_type = event_types[i];
+ if (usrsctp_setsockopt(sock, IPPROTO_SCTP, SCTP_EVENT, &event, sizeof(struct sctp_event)) < 0) {
+ perror("usrsctp_setsockopt SCTP_EVENT");
+ }
+ }
+
+ usrsctp_set_upcall(sock, handle_upcall, NULL);
+
+ memset((void *)&addr, 0, sizeof(struct sockaddr_in6));
+#ifdef HAVE_SIN6_LEN
+ addr.sin6_len = sizeof(struct sockaddr_in6);
+#endif
+ addr.sin6_family = AF_INET6;
+ addr.sin6_port = htons(PORT);
+ addr.sin6_addr = in6addr_any;
+ if (usrsctp_bind(sock, (struct sockaddr *)&addr, sizeof(struct sockaddr_in6)) < 0) {
+ perror("usrsctp_bind");
+ }
+ if (usrsctp_listen(sock, 1) < 0) {
+ perror("usrsctp_listen");
+ }
+ while (1) {
+#ifdef _WIN32
+ Sleep(1*1000);
+#else
+ sleep(1);
+#endif
+ }
+ usrsctp_close(sock);
+ while (usrsctp_finish() != 0) {
+#ifdef _WIN32
+ Sleep(1000);
+#else
+ sleep(1);
+#endif
+ }
+ return (0);
+}
diff --git a/chromium/third_party/usrsctp/usrsctplib/programs/echo_server.c b/chromium/third_party/usrsctp/usrsctplib/programs/echo_server.c
index 64f12c56d99..f59a99c8073 100644
--- a/chromium/third_party/usrsctp/usrsctplib/programs/echo_server.c
+++ b/chromium/third_party/usrsctp/usrsctplib/programs/echo_server.c
@@ -30,7 +30,7 @@
/*
* Usage: echo_server [local_encaps_port] [remote_encaps_port]
- *
+ *
* Example
* Server: $ ./echo_server 11111 22222
* Client: $ ./client 127.0.0.1 7 0 22222 11111
@@ -51,6 +51,7 @@
#include <arpa/inet.h>
#endif
#include <usrsctp.h>
+#include "programs_helper.h"
#define PORT 7
#define BUFFER_SIZE 10240
@@ -127,16 +128,6 @@ receive_cb(struct socket *sock, union sctp_sockstore addr, void *data,
return (1);
}
-void
-debug_printf(const char *format, ...)
-{
- va_list ap;
-
- va_start(ap, format);
- vprintf(format, ap);
- va_end(ap);
-}
-
int
main(int argc, char *argv[])
{
@@ -163,14 +154,15 @@ main(int argc, char *argv[])
unsigned int infotype;
if (argc > 1) {
- usrsctp_init(atoi(argv[1]), NULL, debug_printf);
+ usrsctp_init(atoi(argv[1]), NULL, debug_printf_stack);
} else {
- usrsctp_init(9899, NULL, debug_printf);
+ usrsctp_init(9899, NULL, debug_printf_stack);
}
#ifdef SCTP_DEBUG
usrsctp_sysctl_set_sctp_debug_on(SCTP_DEBUG_NONE);
#endif
usrsctp_sysctl_set_sctp_blackhole(2);
+ usrsctp_sysctl_set_sctp_no_csum_on_loopback(0);
if ((sock = usrsctp_socket(AF_INET6, SOCK_SEQPACKET, IPPROTO_SCTP, use_cb?receive_cb:NULL, NULL, 0, NULL)) == NULL) {
perror("usrsctp_socket");
diff --git a/chromium/third_party/usrsctp/usrsctplib/programs/echo_server_upcall.c b/chromium/third_party/usrsctp/usrsctplib/programs/echo_server_upcall.c
new file mode 100644
index 00000000000..8ecdfe4c937
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/programs/echo_server_upcall.c
@@ -0,0 +1,251 @@
+/*
+ * Copyright (C) 2011-2013 Michael Tuexen
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * Usage: discard_server_upcall [local_encaps_port] [remote_encaps_port]
+ */
+
+#ifdef _WIN32
+#define _CRT_SECURE_NO_WARNINGS
+#include <io.h>
+#endif
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+#include <sys/types.h>
+#ifndef _WIN32
+#include <unistd.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#endif
+#include <usrsctp.h>
+#include "programs_helper.h"
+
+#define BUFFERSIZE 10240
+#define PORT 7
+
+static void
+handle_upcall(struct socket *sock, void *data, int flgs)
+{
+ char namebuf[INET6_ADDRSTRLEN];
+ const char *name;
+ uint16_t port;
+ char *buf;
+ int events;
+
+ while ((events = usrsctp_get_events(sock)) && (events & SCTP_EVENT_READ)) {
+ struct sctp_recvv_rn rn;
+ ssize_t n;
+ struct sockaddr_storage addr;
+ buf = malloc(BUFFERSIZE);
+ int flags = 0;
+ socklen_t len = (socklen_t)sizeof(struct sockaddr_storage);
+ unsigned int infotype = 0;
+ socklen_t infolen = sizeof(struct sctp_recvv_rn);
+ memset(&rn, 0, sizeof(struct sctp_recvv_rn));
+ n = usrsctp_recvv(sock, buf, BUFFERSIZE, (struct sockaddr *) &addr, &len, (void *)&rn,
+ &infolen, &infotype, &flags);
+ if (n < 0) {
+ perror("usrsctp_recvv");
+ }
+ if (n == 0) {
+ usrsctp_close(sock);
+ return;
+ }
+ if (n > 0) {
+ if (flags & MSG_NOTIFICATION) {
+ printf("Notification of length %d received.\n", (int)n);
+ } else {
+#ifdef _WIN32
+ _write(_fileno(stdout), buf, (unsigned int)n);
+#else
+ if (write(fileno(stdout), buf, n) < 0) {
+ perror("write");
+ }
+#endif
+ switch (addr.ss_family) {
+#ifdef INET
+ case AF_INET: {
+ struct sockaddr_in addr4;
+ memcpy(&addr4, (struct sockaddr_in *)&addr, sizeof(struct sockaddr_in));
+ name = inet_ntop(AF_INET, &addr4.sin_addr, namebuf, INET_ADDRSTRLEN);
+ port = ntohs(addr4.sin_port);
+ break;
+ }
+#endif
+#ifdef INET6
+ case AF_INET6: {
+ struct sockaddr_in6 addr6;
+ memcpy(&addr6, (struct sockaddr_in6 *)&addr, sizeof(struct sockaddr_in6));
+ name = inet_ntop(AF_INET6, &addr6.sin6_addr, namebuf, INET6_ADDRSTRLEN),
+ port = ntohs(addr6.sin6_port);
+ break;
+ }
+#endif
+ default:
+ name = NULL;
+ port = 0;
+ break;
+ }
+
+ if (name == NULL) {
+ printf("inet_ntop failed\n");
+ free(buf);
+ return;
+ }
+
+ printf("Msg of length %d received from %s:%u on stream %d with SSN %u and TSN %u, PPID %u, context %u.\n",
+ (int)n,
+ namebuf,
+ port,
+ rn.recvv_rcvinfo.rcv_sid,
+ rn.recvv_rcvinfo.rcv_ssn,
+ rn.recvv_rcvinfo.rcv_tsn,
+ ntohl(rn.recvv_rcvinfo.rcv_ppid),
+ rn.recvv_rcvinfo.rcv_context);
+ if (flags & MSG_EOR) {
+ struct sctp_sndinfo snd_info;
+
+ snd_info.snd_sid = rn.recvv_rcvinfo.rcv_sid;
+ snd_info.snd_flags = 0;
+ if (rn.recvv_rcvinfo.rcv_flags & SCTP_UNORDERED) {
+ snd_info.snd_flags |= SCTP_UNORDERED;
+ }
+ snd_info.snd_ppid = rn.recvv_rcvinfo.rcv_ppid;
+ snd_info.snd_context = 0;
+ snd_info.snd_assoc_id = rn.recvv_rcvinfo.rcv_assoc_id;
+ if (usrsctp_sendv(sock, buf, (size_t) n, NULL, 0, &snd_info, sizeof(struct sctp_sndinfo), SCTP_SENDV_SNDINFO, 0) < 0) {
+ perror("sctp_sendv");
+ }
+ }
+ }
+ }
+ free(buf);
+ }
+ return;
+}
+
+int
+main(int argc, char *argv[])
+{
+ struct socket *sock;
+ struct sockaddr_in6 addr;
+ struct sctp_udpencaps encaps;
+ struct sctp_event event;
+ uint16_t event_types[] = {SCTP_ASSOC_CHANGE,
+ SCTP_PEER_ADDR_CHANGE,
+ SCTP_REMOTE_ERROR,
+ SCTP_SHUTDOWN_EVENT,
+ SCTP_ADAPTATION_INDICATION,
+ SCTP_PARTIAL_DELIVERY_EVENT};
+ unsigned int i;
+ struct sctp_assoc_value av;
+ const int on = 1;
+
+ if (argc > 1) {
+ usrsctp_init(atoi(argv[1]), NULL, debug_printf_stack);
+ } else {
+ usrsctp_init(9899, NULL, debug_printf_stack);
+ }
+#ifdef SCTP_DEBUG
+ usrsctp_sysctl_set_sctp_debug_on(SCTP_DEBUG_NONE);
+#endif
+ usrsctp_sysctl_set_sctp_blackhole(2);
+ usrsctp_sysctl_set_sctp_no_csum_on_loopback(0);
+
+ if ((sock = usrsctp_socket(AF_INET6, SOCK_SEQPACKET, IPPROTO_SCTP, NULL, NULL, 0, NULL)) == NULL) {
+ perror("usrsctp_socket");
+ }
+ usrsctp_set_non_blocking(sock, 1);
+ if (usrsctp_setsockopt(sock, IPPROTO_SCTP, SCTP_I_WANT_MAPPED_V4_ADDR, (const void*)&on, (socklen_t)sizeof(int)) < 0) {
+ perror("usrsctp_setsockopt SCTP_I_WANT_MAPPED_V4_ADDR");
+ }
+ memset(&av, 0, sizeof(struct sctp_assoc_value));
+ av.assoc_id = SCTP_ALL_ASSOC;
+ av.assoc_value = 47;
+
+ if (usrsctp_setsockopt(sock, IPPROTO_SCTP, SCTP_CONTEXT, (const void*)&av, (socklen_t)sizeof(struct sctp_assoc_value)) < 0) {
+ perror("usrsctp_setsockopt SCTP_CONTEXT");
+ }
+ if (usrsctp_setsockopt(sock, IPPROTO_SCTP, SCTP_RECVRCVINFO, &on, sizeof(int)) < 0) {
+ perror("usrsctp_setsockopt SCTP_RECVRCVINFO");
+ }
+ if (argc > 2) {
+ memset(&encaps, 0, sizeof(struct sctp_udpencaps));
+ encaps.sue_address.ss_family = AF_INET6;
+ encaps.sue_port = htons(atoi(argv[2]));
+ if (usrsctp_setsockopt(sock, IPPROTO_SCTP, SCTP_REMOTE_UDP_ENCAPS_PORT, (const void*)&encaps, (socklen_t)sizeof(struct sctp_udpencaps)) < 0) {
+ perror("usrsctp_setsockopt SCTP_REMOTE_UDP_ENCAPS_PORT");
+ }
+ }
+ memset(&event, 0, sizeof(event));
+ event.se_assoc_id = SCTP_FUTURE_ASSOC;
+ event.se_on = 1;
+ for (i = 0; i < (unsigned int)(sizeof(event_types)/sizeof(uint16_t)); i++) {
+ event.se_type = event_types[i];
+ if (usrsctp_setsockopt(sock, IPPROTO_SCTP, SCTP_EVENT, &event, sizeof(struct sctp_event)) < 0) {
+ perror("usrsctp_setsockopt SCTP_EVENT");
+ }
+ }
+
+ usrsctp_set_upcall(sock, handle_upcall, NULL);
+
+ memset((void *)&addr, 0, sizeof(struct sockaddr_in6));
+#ifdef HAVE_SIN6_LEN
+ addr.sin6_len = sizeof(struct sockaddr_in6);
+#endif
+ addr.sin6_family = AF_INET6;
+ addr.sin6_port = htons(PORT);
+ addr.sin6_addr = in6addr_any;
+ if (usrsctp_bind(sock, (struct sockaddr *)&addr, sizeof(struct sockaddr_in6)) < 0) {
+ perror("usrsctp_bind");
+ }
+ if (usrsctp_listen(sock, 1) < 0) {
+ perror("usrsctp_listen");
+ }
+ while (1) {
+#ifdef _WIN32
+ Sleep(1*1000);
+#else
+ sleep(1);
+#endif
+ }
+ usrsctp_close(sock);
+ while (usrsctp_finish() != 0) {
+#ifdef _WIN32
+ Sleep(1000);
+#else
+ sleep(1);
+#endif
+ }
+ return (0);
+}
diff --git a/chromium/third_party/usrsctp/usrsctplib/programs/ekr_client.c b/chromium/third_party/usrsctp/usrsctplib/programs/ekr_client.c
index 1e5e7e32ed6..6aa045dc5af 100644
--- a/chromium/third_party/usrsctp/usrsctplib/programs/ekr_client.c
+++ b/chromium/third_party/usrsctp/usrsctplib/programs/ekr_client.c
@@ -48,6 +48,7 @@
#include <ws2tcpip.h>
#endif
#include <usrsctp.h>
+#include "programs_helper.h"
#define MAX_PACKET_SIZE (1<<16)
#define BUFFER_SIZE 80
@@ -152,16 +153,6 @@ receive_cb(struct socket *sock, union sctp_sockstore addr, void *data,
return (1);
}
-void
-debug_printf(const char *format, ...)
-{
- va_list ap;
-
- va_start(ap, format);
- vprintf(format, ap);
- va_end(ap);
-}
-
int
main(int argc, char *argv[])
{
@@ -195,7 +186,7 @@ main(int argc, char *argv[])
exit (EXIT_FAILURE);
}
#endif
- usrsctp_init(0, conn_output, debug_printf);
+ usrsctp_init(0, conn_output, debug_printf_stack);
/* set up a connected UDP socket */
#ifdef _WIN32
if ((fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == INVALID_SOCKET) {
diff --git a/chromium/third_party/usrsctp/usrsctplib/programs/ekr_loop.c b/chromium/third_party/usrsctp/usrsctplib/programs/ekr_loop.c
index 77e72c5b84f..d198beda40c 100644
--- a/chromium/third_party/usrsctp/usrsctplib/programs/ekr_loop.c
+++ b/chromium/third_party/usrsctp/usrsctplib/programs/ekr_loop.c
@@ -48,10 +48,12 @@
#include <ws2tcpip.h>
#endif
#include <usrsctp.h>
+#include "programs_helper.h"
#define MAX_PACKET_SIZE (1<<16)
#define LINE_LENGTH (1<<20)
#define DISCARD_PPID 39
+#define NUMBER_OF_STEPS 10
#ifdef _WIN32
static DWORD WINAPI
@@ -81,7 +83,7 @@ handle_packets(void *arg)
length = recv(*fdp, buf, MAX_PACKET_SIZE, 0);
if (length > 0) {
if ((dump_buf = usrsctp_dumppacket(buf, (size_t)length, SCTP_DUMP_INBOUND)) != NULL) {
- //fprintf(stderr, "%s", dump_buf);
+ /* fprintf(stderr, "%s", dump_buf); */
usrsctp_freedumpbuffer(dump_buf);
}
usrsctp_conninput(fdp, buf, (size_t)length, 0);
@@ -110,7 +112,7 @@ conn_output(void *addr, void *buf, size_t length, uint8_t tos, uint8_t set_df)
fdp = (int *)addr;
#endif
if ((dump_buf = usrsctp_dumppacket(buf, length, SCTP_DUMP_OUTBOUND)) != NULL) {
- //fprintf(stderr, "%s", dump_buf);
+ /* fprintf(stderr, "%s", dump_buf); */
usrsctp_freedumpbuffer(dump_buf);
}
#ifdef _WIN32
@@ -129,10 +131,10 @@ static int
receive_cb(struct socket *sock, union sctp_sockstore addr, void *data,
size_t datalen, struct sctp_rcvinfo rcv, int flags, void *ulp_info)
{
- printf("Message %p received on sock = %p.\n", data, (void *)sock);
+ debug_printf("MSG RCV: %p received on sock = %p.\n", data, (void *)sock);
if (data) {
if ((flags & MSG_NOTIFICATION) == 0) {
- printf("Messsage of length %d received via %p:%u on stream %u with SSN %u and TSN %u, PPID %u, context %u, flags %x.\n",
+ debug_printf("MSG RCV: length %d, addr %p:%u, stream %u, SSN %u, TSN %u, PPID %u, context %u, %s%s.\n",
(int)datalen,
addr.sconn.sconn_addr,
ntohs(addr.sconn.sconn_port),
@@ -141,7 +143,8 @@ receive_cb(struct socket *sock, union sctp_sockstore addr, void *data,
rcv.rcv_tsn,
ntohl(rcv.rcv_ppid),
rcv.rcv_context,
- flags);
+ (rcv.rcv_flags & SCTP_UNORDERED) ? "unordered" : "ordered",
+ (flags & MSG_EOR) ? ", EOR" : "");
}
free(data);
} else {
@@ -170,7 +173,7 @@ print_addresses(struct socket *sock)
sin = (struct sockaddr_in *)addr;
name = inet_ntop(AF_INET, &sin->sin_addr, buf, INET_ADDRSTRLEN);
- printf("%s:%d", name, ntohs(sin->sin_port));
+ debug_printf("%s:%d", name, ntohs(sin->sin_port));
break;
}
case AF_INET6:
@@ -181,7 +184,7 @@ print_addresses(struct socket *sock)
sin6 = (struct sockaddr_in6 *)addr;
name = inet_ntop(AF_INET6, &sin6->sin6_addr, buf, INET6_ADDRSTRLEN);
- printf("%s:%d", name, ntohs(sin6->sin6_port));
+ debug_printf("%s:%d", name, ntohs(sin6->sin6_port));
break;
}
case AF_CONN:
@@ -189,22 +192,22 @@ print_addresses(struct socket *sock)
struct sockaddr_conn *sconn;
sconn = (struct sockaddr_conn *)addr;
- printf("%p:%d", sconn->sconn_addr, ntohs(sconn->sconn_port));
+ debug_printf("%p:%d", sconn->sconn_addr, ntohs(sconn->sconn_port));
break;
}
default:
- printf("Unknown family: %d", addr->sa_family);
+ debug_printf("Unknown family: %d", addr->sa_family);
break;
}
addr = (struct sockaddr *)((caddr_t)addr + addr->sa_len);
if (i != n - 1) {
- printf(",");
+ debug_printf(",");
}
}
if (n > 0) {
usrsctp_freeladdrs(addrs);
}
- printf("<->");
+ debug_printf("<->");
n = usrsctp_getpaddrs(sock, 0, &addrs);
addr = addrs;
for (i = 0; i < n; i++) {
@@ -217,7 +220,7 @@ print_addresses(struct socket *sock)
sin = (struct sockaddr_in *)addr;
name = inet_ntop(AF_INET, &sin->sin_addr, buf, INET_ADDRSTRLEN);
- printf("%s:%d", name, ntohs(sin->sin_port));
+ debug_printf("%s:%d", name, ntohs(sin->sin_port));
break;
}
case AF_INET6:
@@ -228,7 +231,7 @@ print_addresses(struct socket *sock)
sin6 = (struct sockaddr_in6 *)addr;
name = inet_ntop(AF_INET6, &sin6->sin6_addr, buf, INET6_ADDRSTRLEN);
- printf("%s:%d", name, ntohs(sin6->sin6_port));
+ debug_printf("%s:%d", name, ntohs(sin6->sin6_port));
break;
}
case AF_CONN:
@@ -236,37 +239,27 @@ print_addresses(struct socket *sock)
struct sockaddr_conn *sconn;
sconn = (struct sockaddr_conn *)addr;
- printf("%p:%d", sconn->sconn_addr, ntohs(sconn->sconn_port));
+ debug_printf("%p:%d", sconn->sconn_addr, ntohs(sconn->sconn_port));
break;
}
default:
- printf("Unknown family: %d", addr->sa_family);
+ debug_printf("Unknown family: %d", addr->sa_family);
break;
}
addr = (struct sockaddr *)((caddr_t)addr + addr->sa_len);
if (i != n - 1) {
- printf(",");
+ debug_printf(",");
}
}
if (n > 0) {
usrsctp_freepaddrs(addrs);
}
- printf("\n");
+ debug_printf("\n");
}
#endif
-void
-debug_printf(const char *format, ...)
-{
- va_list ap;
-
- va_start(ap, format);
- vprintf(format, ap);
- va_end(ap);
-}
-
int
-main(void)
+main(int argc, char *argv[])
{
struct sockaddr_in sin_s, sin_c;
struct sockaddr_conn sconn;
@@ -281,13 +274,22 @@ main(void)
#else
pthread_t tid_c, tid_s;
#endif
- int cur_buf_size, snd_buf_size, rcv_buf_size;
+ int i, j, cur_buf_size, snd_buf_size, rcv_buf_size;
socklen_t opt_len;
struct sctp_sndinfo sndinfo;
char *line;
#ifdef _WIN32
WSADATA wsaData;
#endif
+ uint16_t client_port = 9900;
+ uint16_t server_port = 9901;
+
+ if (argc == 3) {
+ client_port = atoi(argv[1]);
+ server_port = atoi(argv[2]);
+ }
+
+ debug_printf("starting program\n");
#ifdef _WIN32
if (WSAStartup(MAKEWORD(2,2), &wsaData) != 0) {
@@ -295,7 +297,7 @@ main(void)
exit (EXIT_FAILURE);
}
#endif
- usrsctp_init(0, conn_output, debug_printf);
+ usrsctp_init(0, conn_output, debug_printf_stack);
/* set up a connected UDP socket */
#ifdef _WIN32
if ((fd_c = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == INVALID_SOCKET) {
@@ -321,14 +323,14 @@ main(void)
#ifdef HAVE_SIN_LEN
sin_c.sin_len = sizeof(struct sockaddr_in);
#endif
- sin_c.sin_port = htons(9900);
+ sin_c.sin_port = htons(client_port);
sin_c.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
memset(&sin_s, 0, sizeof(struct sockaddr_in));
sin_s.sin_family = AF_INET;
#ifdef HAVE_SIN_LEN
sin_s.sin_len = sizeof(struct sockaddr_in);
#endif
- sin_s.sin_port = htons(9901);
+ sin_s.sin_port = htons(server_port);
sin_s.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
#ifdef _WIN32
if (bind(fd_c, (struct sockaddr *)&sin_c, sizeof(struct sockaddr_in)) == SOCKET_ERROR) {
@@ -351,11 +353,11 @@ main(void)
#endif
#ifdef _WIN32
if (connect(fd_c, (struct sockaddr *)&sin_s, sizeof(struct sockaddr_in)) == SOCKET_ERROR) {
- printf("connect() failed with error: %d\n", WSAGetLastError());
+ debug_printf("connect() failed with error: %d\n", WSAGetLastError());
exit(EXIT_FAILURE);
}
if (connect(fd_s, (struct sockaddr *)&sin_c, sizeof(struct sockaddr_in)) == SOCKET_ERROR) {
- printf("connect() failed with error: %d\n", WSAGetLastError());
+ debug_printf("connect() failed with error: %d\n", WSAGetLastError());
exit(EXIT_FAILURE);
}
#else
@@ -398,7 +400,7 @@ main(void)
perror("usrsctp_getsockopt");
exit(EXIT_FAILURE);
}
- printf("Change send socket buffer size from %d ", cur_buf_size);
+ debug_printf("Change send socket buffer size from %d ", cur_buf_size);
snd_buf_size = 1<<22; /* 4 MB */
if (usrsctp_setsockopt(s_c, SOL_SOCKET, SO_SNDBUF, &snd_buf_size, sizeof(int)) < 0) {
perror("usrsctp_setsockopt");
@@ -410,7 +412,7 @@ main(void)
perror("usrsctp_getsockopt");
exit(EXIT_FAILURE);
}
- printf("to %d.\n", cur_buf_size);
+ debug_printf("to %d.\n", cur_buf_size);
if ((s_l = usrsctp_socket(AF_CONN, SOCK_STREAM, IPPROTO_SCTP, receive_cb, NULL, 0, &fd_s)) == NULL) {
perror("usrsctp_socket");
exit(EXIT_FAILURE);
@@ -421,7 +423,7 @@ main(void)
perror("usrsctp_getsockopt");
exit(EXIT_FAILURE);
}
- printf("Change receive socket buffer size from %d ", cur_buf_size);
+ debug_printf("Change receive socket buffer size from %d ", cur_buf_size);
rcv_buf_size = 1<<16; /* 64 KB */
if (usrsctp_setsockopt(s_l, SOL_SOCKET, SO_RCVBUF, &rcv_buf_size, sizeof(int)) < 0) {
perror("usrsctp_setsockopt");
@@ -433,7 +435,7 @@ main(void)
perror("usrsctp_getsockopt");
exit(EXIT_FAILURE);
}
- printf("to %d.\n", cur_buf_size);
+ debug_printf("to %d.\n", cur_buf_size);
/* Bind the client side. */
memset(&sconn, 0, sizeof(struct sockaddr_conn));
sconn.sconn_family = AF_CONN;
@@ -485,21 +487,37 @@ main(void)
}
memset(line, 'A', LINE_LENGTH);
sndinfo.snd_sid = 1;
- sndinfo.snd_flags = 0;
sndinfo.snd_ppid = htonl(DISCARD_PPID);
sndinfo.snd_context = 0;
sndinfo.snd_assoc_id = 0;
- /* Send a 1 MB ordered message */
- if (usrsctp_sendv(s_c, line, LINE_LENGTH, NULL, 0, (void *)&sndinfo,
- (socklen_t)sizeof(struct sctp_sndinfo), SCTP_SENDV_SNDINFO, 0) < 0) {
- perror("usrsctp_sendv");
- exit(EXIT_FAILURE);
- }
- /* Send a 1 MB ordered message */
- if (usrsctp_sendv(s_c, line, LINE_LENGTH, NULL, 0, (void *)&sndinfo,
- (socklen_t)sizeof(struct sctp_sndinfo), SCTP_SENDV_SNDINFO, 0) < 0) {
- perror("usrsctp_sendv");
- exit(EXIT_FAILURE);
+
+ for (i = 0; i < NUMBER_OF_STEPS; i++) {
+ j = 0;
+ if (i % 2) {
+ sndinfo.snd_flags = SCTP_UNORDERED;
+ } else {
+ sndinfo.snd_flags = 0;
+ }
+ /* Send a 1 MB message */
+ debug_printf("usrscp_sendv - step %d - call %d flags %x\n", i, ++j, sndinfo.snd_flags);
+ if (usrsctp_sendv(s_c, line, LINE_LENGTH, NULL, 0, (void *)&sndinfo,
+ (socklen_t)sizeof(struct sctp_sndinfo), SCTP_SENDV_SNDINFO, 0) < 0) {
+ perror("usrsctp_sendv");
+ exit(EXIT_FAILURE);
+ }
+ /* Send a 1 MB message */
+ debug_printf("usrscp_sendv - step %d - call %d flags %x\n", i, ++j, sndinfo.snd_flags);
+ if (usrsctp_sendv(s_c, line, LINE_LENGTH, NULL, 0, (void *)&sndinfo,
+ (socklen_t)sizeof(struct sctp_sndinfo), SCTP_SENDV_SNDINFO, 0) < 0) {
+ perror("usrsctp_sendv");
+ exit(EXIT_FAILURE);
+ }
+ debug_printf("Sending done, sleeping\n");
+#ifdef _WIN32
+ Sleep(10000);
+#else
+ sleep(10);
+#endif
}
free(line);
usrsctp_shutdown(s_c, SHUT_WR);
@@ -517,11 +535,11 @@ main(void)
TerminateThread(tid_s, 0);
WaitForSingleObject(tid_s, INFINITE);
if (closesocket(fd_c) == SOCKET_ERROR) {
- printf("closesocket() failed with error: %d\n", WSAGetLastError());
+ debug_printf("closesocket() failed with error: %d\n", WSAGetLastError());
exit(EXIT_FAILURE);
}
if (closesocket(fd_s) == SOCKET_ERROR) {
- printf("closesocket() failed with error: %d\n", WSAGetLastError());
+ debug_printf("closesocket() failed with error: %d\n", WSAGetLastError());
exit(EXIT_FAILURE);
}
WSACleanup();
diff --git a/chromium/third_party/usrsctp/usrsctplib/programs/ekr_loop_offload.c b/chromium/third_party/usrsctp/usrsctplib/programs/ekr_loop_offload.c
index 55f7d7fc694..5184bef1d08 100644
--- a/chromium/third_party/usrsctp/usrsctplib/programs/ekr_loop_offload.c
+++ b/chromium/third_party/usrsctp/usrsctplib/programs/ekr_loop_offload.c
@@ -48,6 +48,7 @@
#include <ws2tcpip.h>
#endif
#include <usrsctp.h>
+#include "programs_helper.h"
#define MAX_PACKET_SIZE (1<<16)
#define LINE_LENGTH (1<<20)
@@ -83,7 +84,7 @@ handle_packets(void *arg)
length = recv(*fdp, buffer, MAX_PACKET_SIZE, 0);
if (length > 0) {
if ((dump_buffer = usrsctp_dumppacket(buffer, (size_t)length, SCTP_DUMP_INBOUND)) != NULL) {
- //fprintf(stderr, "%s", dump_buffer);
+ /* fprintf(stderr, "%s", dump_buffer); */
usrsctp_freedumpbuffer(dump_buffer);
}
if ((size_t)length >= sizeof(struct sctp_common_header)) {
@@ -131,7 +132,7 @@ conn_output(void *addr, void *buffer, size_t length, uint8_t tos, uint8_t set_df
hdr->crc32c = usrsctp_crc32c(buffer, (size_t)length);
}
if ((dump_buffer = usrsctp_dumppacket(buffer, length, SCTP_DUMP_OUTBOUND)) != NULL) {
- //fprintf(stderr, "%s", dump_buffer);
+ /* fprintf(stderr, "%s", dump_buffer); */
usrsctp_freedumpbuffer(dump_buffer);
}
#ifdef _WIN32
@@ -153,7 +154,7 @@ receive_cb(struct socket *sock, union sctp_sockstore addr, void *data,
printf("Message %p received on sock = %p.\n", data, (void *)sock);
if (data) {
if ((flags & MSG_NOTIFICATION) == 0) {
- printf("Messsage of length %d received via %p:%u on stream %u with SSN %u and TSN %u, PPID %u, context %u, flags %x.\n",
+ printf("Message of length %d received via %p:%u on stream %u with SSN %u and TSN %u, PPID %u, context %u, flags %x.\n",
(int)datalen,
addr.sconn.sconn_addr,
ntohs(addr.sconn.sconn_port),
@@ -276,18 +277,8 @@ print_addresses(struct socket *sock)
}
#endif
-void
-debug_printf(const char *format, ...)
-{
- va_list ap;
-
- va_start(ap, format);
- vprintf(format, ap);
- va_end(ap);
-}
-
int
-main(void)
+main(int argc, char *argv[])
{
struct sockaddr_in sin_s, sin_c;
struct sockaddr_conn sconn;
@@ -309,6 +300,13 @@ main(void)
#ifdef _WIN32
WSADATA wsaData;
#endif
+ uint16_t client_port = 9900;
+ uint16_t server_port = 9901;
+
+ if (argc == 3) {
+ client_port = atoi(argv[1]);
+ server_port = atoi(argv[2]);
+ }
#ifdef _WIN32
if (WSAStartup(MAKEWORD(2,2), &wsaData) != 0) {
@@ -316,7 +314,7 @@ main(void)
exit (EXIT_FAILURE);
}
#endif
- usrsctp_init(0, conn_output, debug_printf);
+ usrsctp_init(0, conn_output, debug_printf_stack);
usrsctp_enable_crc32c_offload();
/* set up a connected UDP socket */
#ifdef _WIN32
@@ -343,14 +341,14 @@ main(void)
#ifdef HAVE_SIN_LEN
sin_c.sin_len = sizeof(struct sockaddr_in);
#endif
- sin_c.sin_port = htons(9899);
+ sin_c.sin_port = htons(client_port);
sin_c.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
memset(&sin_s, 0, sizeof(struct sockaddr_in));
sin_s.sin_family = AF_INET;
#ifdef HAVE_SIN_LEN
sin_s.sin_len = sizeof(struct sockaddr_in);
#endif
- sin_s.sin_port = htons(9901);
+ sin_s.sin_port = htons(server_port);
sin_s.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
#ifdef _WIN32
if (bind(fd_c, (struct sockaddr *)&sin_c, sizeof(struct sockaddr_in)) == SOCKET_ERROR) {
diff --git a/chromium/third_party/usrsctp/usrsctplib/programs/ekr_loop_upcall.c b/chromium/third_party/usrsctp/usrsctplib/programs/ekr_loop_upcall.c
new file mode 100644
index 00000000000..d225fee9776
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/programs/ekr_loop_upcall.c
@@ -0,0 +1,589 @@
+/*
+ * Copyright (C) 2011-2013 Michael Tuexen
+ * Copyright (C) 2018-2018 Felix Weinrank
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifdef _WIN32
+#define _CRT_SECURE_NO_WARNINGS
+#endif
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+#include <sys/types.h>
+#ifndef _WIN32
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <errno.h>
+#include <pthread.h>
+#include <unistd.h>
+#else
+#include <winsock2.h>
+#include <ws2tcpip.h>
+#endif
+#include <usrsctp.h>
+#include "programs_helper.h"
+
+#define MAX_PACKET_SIZE (1<<16)
+#define LINE_LENGTH (1<<20)
+#define DISCARD_PPID 39
+/* #define DUMP_PKTS_TO_FILE */
+
+#ifdef _WIN32
+static DWORD WINAPI
+#else
+static void *
+#endif
+handle_packets(void *arg)
+{
+#ifdef _WIN32
+ SOCKET *fdp;
+#else
+ int *fdp;
+#endif
+ char *dump_buf;
+ ssize_t length;
+ char buf[MAX_PACKET_SIZE];
+
+#ifdef _WIN32
+ fdp = (SOCKET *)arg;
+#else
+ fdp = (int *)arg;
+#endif
+ for (;;) {
+#if defined(__NetBSD__)
+ pthread_testcancel();
+#endif
+ length = recv(*fdp, buf, MAX_PACKET_SIZE, 0);
+ if (length > 0) {
+ if ((dump_buf = usrsctp_dumppacket(buf, (size_t)length, SCTP_DUMP_INBOUND)) != NULL) {
+ /* fprintf(stderr, "%s", dump_buf); */
+ usrsctp_freedumpbuffer(dump_buf);
+ }
+ usrsctp_conninput(fdp, buf, (size_t)length, 0);
+ }
+ }
+#ifdef _WIN32
+ return 0;
+#else
+ return (NULL);
+#endif
+}
+
+static int
+conn_output(void *addr, void *buf, size_t length, uint8_t tos, uint8_t set_df)
+{
+ char *dump_buf;
+#ifdef _WIN32
+ SOCKET *fdp;
+#else
+ int *fdp;
+#endif
+
+#ifdef _WIN32
+ fdp = (SOCKET *)addr;
+#else
+ fdp = (int *)addr;
+#endif
+ if ((dump_buf = usrsctp_dumppacket(buf, length, SCTP_DUMP_OUTBOUND)) != NULL) {
+ /* fprintf(stderr, "%s", dump_buf); */
+ usrsctp_freedumpbuffer(dump_buf);
+ }
+
+#ifdef DUMP_PKTS_TO_FILE
+ FILE *fp;
+ char fname[128];
+ static int pktnum = 0;
+ snprintf(fname, sizeof(fname), "pkt-%d", pktnum++);
+ fp = fopen(fname, "wb");
+ fwrite((char *)buf + 12, 1, length - 12, fp);
+ fclose(fp);
+#endif
+
+#ifdef _WIN32
+ if (send(*fdp, buf, (int)length, 0) == SOCKET_ERROR) {
+ return (WSAGetLastError());
+#else
+ if (send(*fdp, buf, length, 0) < 0) {
+ return (errno);
+#endif
+ } else {
+ return (0);
+ }
+}
+
+static void
+handle_upcall(struct socket *sock, void *data, int flgs)
+{
+ char *buf;
+ int events;
+
+ buf = malloc(MAX_PACKET_SIZE);
+
+ while ((events = usrsctp_get_events(sock)) && (events & SCTP_EVENT_READ)) {
+ struct sctp_recvv_rn rn;
+ ssize_t n;
+ union sctp_sockstore addr;
+ int flags = 0;
+ socklen_t len = (socklen_t)sizeof(addr);
+ unsigned int infotype = 0;
+ socklen_t infolen = sizeof(struct sctp_recvv_rn);
+ memset(&rn, 0, sizeof(struct sctp_recvv_rn));
+ n = usrsctp_recvv(sock, buf, MAX_PACKET_SIZE, (struct sockaddr *) &addr, &len, (void *)&rn, &infolen, &infotype, &flags);
+ if (n < 0) {
+ perror("usrsctp_recvv");
+ break;
+ } else if (n > 0) {
+ if (flags & MSG_NOTIFICATION) {
+ printf("Notification of length %d received.\n", (int)n);
+ } else {
+ printf("Message of length %d received via %p:%u on stream %u with SSN %u and TSN %u, PPID %u, context %u, flags %x.\n",
+ (int)n,
+ addr.sconn.sconn_addr,
+ ntohs(addr.sconn.sconn_port),
+ rn.recvv_rcvinfo.rcv_sid,
+ rn.recvv_rcvinfo.rcv_ssn,
+ rn.recvv_rcvinfo.rcv_tsn,
+ ntohl(rn.recvv_rcvinfo.rcv_ppid),
+ rn.recvv_rcvinfo.rcv_context,
+ flags);
+ }
+ } else {
+ usrsctp_deregister_address(data);
+ usrsctp_close(sock);
+ break;
+ }
+ }
+ free(buf);
+
+ return;
+}
+
+#if 0
+static void
+print_addresses(struct socket *sock)
+{
+ int i, n;
+ struct sockaddr *addrs, *addr;
+
+ n = usrsctp_getladdrs(sock, 0, &addrs);
+ addr = addrs;
+ for (i = 0; i < n; i++) {
+ switch (addr->sa_family) {
+ case AF_INET:
+ {
+ struct sockaddr_in *sin;
+ char buf[INET_ADDRSTRLEN];
+ const char *name;
+
+ sin = (struct sockaddr_in *)addr;
+ name = inet_ntop(AF_INET, &sin->sin_addr, buf, INET_ADDRSTRLEN);
+ printf("%s:%d", name, ntohs(sin->sin_port));
+ break;
+ }
+ case AF_INET6:
+ {
+ struct sockaddr_in6 *sin6;
+ char buf[INET6_ADDRSTRLEN];
+ const char *name;
+
+ sin6 = (struct sockaddr_in6 *)addr;
+ name = inet_ntop(AF_INET6, &sin6->sin6_addr, buf, INET6_ADDRSTRLEN);
+ printf("%s:%d", name, ntohs(sin6->sin6_port));
+ break;
+ }
+ case AF_CONN:
+ {
+ struct sockaddr_conn *sconn;
+
+ sconn = (struct sockaddr_conn *)addr;
+ printf("%p:%d", sconn->sconn_addr, ntohs(sconn->sconn_port));
+ break;
+ }
+ default:
+ printf("Unknown family: %d", addr->sa_family);
+ break;
+ }
+ addr = (struct sockaddr *)((caddr_t)addr + addr->sa_len);
+ if (i != n - 1) {
+ printf(",");
+ }
+ }
+ if (n > 0) {
+ usrsctp_freeladdrs(addrs);
+ }
+ printf("<->");
+ n = usrsctp_getpaddrs(sock, 0, &addrs);
+ addr = addrs;
+ for (i = 0; i < n; i++) {
+ switch (addr->sa_family) {
+ case AF_INET:
+ {
+ struct sockaddr_in *sin;
+ char buf[INET_ADDRSTRLEN];
+ const char *name;
+
+ sin = (struct sockaddr_in *)addr;
+ name = inet_ntop(AF_INET, &sin->sin_addr, buf, INET_ADDRSTRLEN);
+ printf("%s:%d", name, ntohs(sin->sin_port));
+ break;
+ }
+ case AF_INET6:
+ {
+ struct sockaddr_in6 *sin6;
+ char buf[INET6_ADDRSTRLEN];
+ const char *name;
+
+ sin6 = (struct sockaddr_in6 *)addr;
+ name = inet_ntop(AF_INET6, &sin6->sin6_addr, buf, INET6_ADDRSTRLEN);
+ printf("%s:%d", name, ntohs(sin6->sin6_port));
+ break;
+ }
+ case AF_CONN:
+ {
+ struct sockaddr_conn *sconn;
+
+ sconn = (struct sockaddr_conn *)addr;
+ printf("%p:%d", sconn->sconn_addr, ntohs(sconn->sconn_port));
+ break;
+ }
+ default:
+ printf("Unknown family: %d", addr->sa_family);
+ break;
+ }
+ addr = (struct sockaddr *)((caddr_t)addr + addr->sa_len);
+ if (i != n - 1) {
+ printf(",");
+ }
+ }
+ if (n > 0) {
+ usrsctp_freepaddrs(addrs);
+ }
+ printf("\n");
+}
+#endif
+
+int
+main(int argc, char *argv[])
+{
+ struct sockaddr_in sin_s, sin_c;
+ struct sockaddr_conn sconn;
+#ifdef _WIN32
+ SOCKET fd_c, fd_s;
+#else
+ int fd_c, fd_s;
+#endif
+ struct socket *s_c, *s_s, *s_l;
+#ifdef _WIN32
+ HANDLE tid_c, tid_s;
+#else
+ pthread_t tid_c, tid_s;
+#endif
+ int cur_buf_size, snd_buf_size, rcv_buf_size, on;
+ socklen_t opt_len;
+ struct sctp_sndinfo sndinfo;
+ char *line;
+#ifdef _WIN32
+ WSADATA wsaData;
+#endif
+ uint16_t client_port = 9900;
+ uint16_t server_port = 9901;
+
+ if (argc == 3) {
+ client_port = atoi(argv[1]);
+ server_port = atoi(argv[2]);
+ }
+
+#ifdef _WIN32
+ if (WSAStartup(MAKEWORD(2,2), &wsaData) != 0) {
+ printf("WSAStartup failed\n");
+ exit (EXIT_FAILURE);
+ }
+#endif
+ usrsctp_init(0, conn_output, debug_printf_stack);
+ /* set up a connected UDP socket */
+#ifdef _WIN32
+ if ((fd_c = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == INVALID_SOCKET) {
+ printf("socket() failed with error: %d\n", WSAGetLastError());
+ exit(EXIT_FAILURE);
+ }
+ if ((fd_s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == INVALID_SOCKET) {
+ printf("socket() failed with error: %d\n", WSAGetLastError());
+ exit(EXIT_FAILURE);
+ }
+#else
+ if ((fd_c = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
+ perror("socket");
+ exit(EXIT_FAILURE);
+ }
+ if ((fd_s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
+ perror("socket");
+ exit(EXIT_FAILURE);
+ }
+#endif
+ memset(&sin_c, 0, sizeof(struct sockaddr_in));
+ sin_c.sin_family = AF_INET;
+#ifdef HAVE_SIN_LEN
+ sin_c.sin_len = sizeof(struct sockaddr_in);
+#endif
+ sin_c.sin_port = htons(client_port);
+ sin_c.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
+ memset(&sin_s, 0, sizeof(struct sockaddr_in));
+ sin_s.sin_family = AF_INET;
+#ifdef HAVE_SIN_LEN
+ sin_s.sin_len = sizeof(struct sockaddr_in);
+#endif
+ sin_s.sin_port = htons(server_port);
+ sin_s.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
+#ifdef _WIN32
+ if (bind(fd_c, (struct sockaddr *)&sin_c, sizeof(struct sockaddr_in)) == SOCKET_ERROR) {
+ printf("bind() failed with error: %d\n", WSAGetLastError());
+ exit(EXIT_FAILURE);
+ }
+ if (bind(fd_s, (struct sockaddr *)&sin_s, sizeof(struct sockaddr_in)) == SOCKET_ERROR) {
+ printf("bind() failed with error: %d\n", WSAGetLastError());
+ exit(EXIT_FAILURE);
+ }
+#else
+ if (bind(fd_c, (struct sockaddr *)&sin_c, sizeof(struct sockaddr_in)) < 0) {
+ perror("bind");
+ exit(EXIT_FAILURE);
+ }
+ if (bind(fd_s, (struct sockaddr *)&sin_s, sizeof(struct sockaddr_in)) < 0) {
+ perror("bind");
+ exit(EXIT_FAILURE);
+ }
+#endif
+#ifdef _WIN32
+ if (connect(fd_c, (struct sockaddr *)&sin_s, sizeof(struct sockaddr_in)) == SOCKET_ERROR) {
+ printf("connect() failed with error: %d\n", WSAGetLastError());
+ exit(EXIT_FAILURE);
+ }
+ if (connect(fd_s, (struct sockaddr *)&sin_c, sizeof(struct sockaddr_in)) == SOCKET_ERROR) {
+ printf("connect() failed with error: %d\n", WSAGetLastError());
+ exit(EXIT_FAILURE);
+ }
+#else
+ if (connect(fd_c, (struct sockaddr *)&sin_s, sizeof(struct sockaddr_in)) < 0) {
+ perror("connect");
+ exit(EXIT_FAILURE);
+ }
+ if (connect(fd_s, (struct sockaddr *)&sin_c, sizeof(struct sockaddr_in)) < 0) {
+ perror("connect");
+ exit(EXIT_FAILURE);
+ }
+#endif
+#ifdef _WIN32
+ tid_c = CreateThread(NULL, 0, &handle_packets, (void *)&fd_c, 0, NULL);
+ tid_s = CreateThread(NULL, 0, &handle_packets, (void *)&fd_s, 0, NULL);
+#else
+ if (pthread_create(&tid_c, NULL, &handle_packets, (void *)&fd_c)) {
+ perror("pthread_create tid_c");
+ exit(EXIT_FAILURE);
+ }
+
+ if (pthread_create(&tid_s, NULL, &handle_packets, (void *)&fd_s)) {
+ perror("pthread_create tid_s");
+ exit(EXIT_FAILURE);
+ };
+#endif
+#ifdef SCTP_DEBUG
+ usrsctp_sysctl_set_sctp_debug_on(SCTP_DEBUG_NONE);
+#endif
+ usrsctp_sysctl_set_sctp_ecn_enable(0);
+ usrsctp_register_address((void *)&fd_c);
+ usrsctp_register_address((void *)&fd_s);
+
+ if ((s_c = usrsctp_socket(AF_CONN, SOCK_STREAM, IPPROTO_SCTP, NULL, NULL, 0, NULL)) == NULL) {
+ perror("usrsctp_socket");
+ exit(EXIT_FAILURE);
+ }
+ usrsctp_set_upcall(s_c, handle_upcall, &fd_c);
+
+ opt_len = (socklen_t)sizeof(int);
+ cur_buf_size = 0;
+ if (usrsctp_getsockopt(s_c, SOL_SOCKET, SO_SNDBUF, &cur_buf_size, &opt_len) < 0) {
+ perror("usrsctp_getsockopt");
+ exit(EXIT_FAILURE);
+ }
+ printf("Change send socket buffer size from %d ", cur_buf_size);
+ snd_buf_size = 1<<22; /* 4 MB */
+ if (usrsctp_setsockopt(s_c, SOL_SOCKET, SO_SNDBUF, &snd_buf_size, sizeof(int)) < 0) {
+ perror("usrsctp_setsockopt");
+ exit(EXIT_FAILURE);
+ }
+ opt_len = (socklen_t)sizeof(int);
+ cur_buf_size = 0;
+ if (usrsctp_getsockopt(s_c, SOL_SOCKET, SO_SNDBUF, &cur_buf_size, &opt_len) < 0) {
+ perror("usrsctp_getsockopt");
+ exit(EXIT_FAILURE);
+ }
+ printf("to %d.\n", cur_buf_size);
+ if ((s_l = usrsctp_socket(AF_CONN, SOCK_STREAM, IPPROTO_SCTP, NULL, NULL, 0, NULL)) == NULL) {
+ perror("usrsctp_socket");
+ exit(EXIT_FAILURE);
+ }
+
+ opt_len = (socklen_t)sizeof(int);
+ cur_buf_size = 0;
+ if (usrsctp_getsockopt(s_l, SOL_SOCKET, SO_RCVBUF, &cur_buf_size, &opt_len) < 0) {
+ perror("usrsctp_getsockopt");
+ exit(EXIT_FAILURE);
+ }
+ printf("Change receive socket buffer size from %d ", cur_buf_size);
+ rcv_buf_size = 1<<16; /* 64 KB */
+ if (usrsctp_setsockopt(s_l, SOL_SOCKET, SO_RCVBUF, &rcv_buf_size, sizeof(int)) < 0) {
+ perror("usrsctp_setsockopt");
+ exit(EXIT_FAILURE);
+ }
+ opt_len = (socklen_t)sizeof(int);
+ cur_buf_size = 0;
+ if (usrsctp_getsockopt(s_l, SOL_SOCKET, SO_RCVBUF, &cur_buf_size, &opt_len) < 0) {
+ perror("usrsctp_getsockopt");
+ exit(EXIT_FAILURE);
+ }
+ printf("to %d.\n", cur_buf_size);
+
+ on = 1;
+ if (usrsctp_setsockopt(s_l, IPPROTO_SCTP, SCTP_RECVRCVINFO, &on, sizeof(int)) < 0) {
+ perror("usrsctp_setsockopt");
+ exit(EXIT_FAILURE);
+ }
+ /* Bind the client side. */
+ memset(&sconn, 0, sizeof(struct sockaddr_conn));
+ sconn.sconn_family = AF_CONN;
+#ifdef HAVE_SCONN_LEN
+ sconn.sconn_len = sizeof(struct sockaddr_conn);
+#endif
+ sconn.sconn_port = htons(5001);
+ sconn.sconn_addr = &fd_c;
+ if (usrsctp_bind(s_c, (struct sockaddr *)&sconn, sizeof(struct sockaddr_conn)) < 0) {
+ perror("usrsctp_bind");
+ exit(EXIT_FAILURE);
+ }
+ /* Bind the server side. */
+ memset(&sconn, 0, sizeof(struct sockaddr_conn));
+ sconn.sconn_family = AF_CONN;
+#ifdef HAVE_SCONN_LEN
+ sconn.sconn_len = sizeof(struct sockaddr_conn);
+#endif
+ sconn.sconn_port = htons(5001);
+ sconn.sconn_addr = &fd_s;
+ if (usrsctp_bind(s_l, (struct sockaddr *)&sconn, sizeof(struct sockaddr_conn)) < 0) {
+ perror("usrsctp_bind");
+ exit(EXIT_FAILURE);
+ }
+ /* Make server side passive... */
+ if (usrsctp_listen(s_l, 1) < 0) {
+ perror("usrsctp_listen");
+ exit(EXIT_FAILURE);
+ }
+ /* Initiate the handshake */
+ memset(&sconn, 0, sizeof(struct sockaddr_conn));
+ sconn.sconn_family = AF_CONN;
+#ifdef HAVE_SCONN_LEN
+ sconn.sconn_len = sizeof(struct sockaddr_conn);
+#endif
+ sconn.sconn_port = htons(5001);
+ sconn.sconn_addr = &fd_c;
+ if (usrsctp_connect(s_c, (struct sockaddr *)&sconn, sizeof(struct sockaddr_conn)) < 0) {
+ perror("usrsctp_connect");
+ exit(EXIT_FAILURE);
+ }
+
+ if ((s_s = usrsctp_accept(s_l, NULL, NULL)) == NULL) {
+ perror("usrsctp_accept");
+ exit(EXIT_FAILURE);
+ }
+
+ usrsctp_set_upcall(s_s, handle_upcall, &fd_s);
+
+ usrsctp_close(s_l);
+ if ((line = malloc(LINE_LENGTH)) == NULL) {
+ exit(EXIT_FAILURE);
+ }
+ memset(line, 'A', LINE_LENGTH);
+ sndinfo.snd_sid = 1;
+ sndinfo.snd_flags = SCTP_UNORDERED;
+ sndinfo.snd_ppid = htonl(DISCARD_PPID);
+ sndinfo.snd_context = 0;
+ sndinfo.snd_assoc_id = 0;
+ /* Send a 1 MB ordered message */
+ if (usrsctp_sendv(s_c, line, LINE_LENGTH, NULL, 0, (void *)&sndinfo,
+ (socklen_t)sizeof(struct sctp_sndinfo), SCTP_SENDV_SNDINFO, 0) < 0) {
+ perror("usrsctp_sendv");
+ exit(EXIT_FAILURE);
+ }
+ /* Send a 1 MB ordered message */
+ if (usrsctp_sendv(s_c, line, LINE_LENGTH, NULL, 0, (void *)&sndinfo,
+ (socklen_t)sizeof(struct sctp_sndinfo), SCTP_SENDV_SNDINFO, 0) < 0) {
+ perror("usrsctp_sendv");
+ exit(EXIT_FAILURE);
+ }
+ free(line);
+ usrsctp_shutdown(s_c, SHUT_WR);
+
+ while (usrsctp_finish() != 0) {
+#ifdef _WIN32
+ Sleep(1000);
+#else
+ sleep(1);
+#endif
+ }
+#ifdef _WIN32
+ TerminateThread(tid_c, 0);
+ WaitForSingleObject(tid_c, INFINITE);
+ TerminateThread(tid_s, 0);
+ WaitForSingleObject(tid_s, INFINITE);
+ if (closesocket(fd_c) == SOCKET_ERROR) {
+ printf("closesocket() failed with error: %d\n", WSAGetLastError());
+ exit(EXIT_FAILURE);
+ }
+ if (closesocket(fd_s) == SOCKET_ERROR) {
+ printf("closesocket() failed with error: %d\n", WSAGetLastError());
+ exit(EXIT_FAILURE);
+ }
+ WSACleanup();
+#else
+ pthread_cancel(tid_c);
+ pthread_join(tid_c, NULL);
+ pthread_cancel(tid_s);
+ pthread_join(tid_s, NULL);
+ if (close(fd_c) < 0) {
+ perror("close");
+ exit(EXIT_FAILURE);
+ }
+ if (close(fd_s) < 0) {
+ perror("close");
+ exit(EXIT_FAILURE);
+ }
+#endif
+ return (0);
+}
diff --git a/chromium/third_party/usrsctp/usrsctplib/programs/ekr_peer.c b/chromium/third_party/usrsctp/usrsctplib/programs/ekr_peer.c
index ca0c64d6dad..f278d5bc75c 100644
--- a/chromium/third_party/usrsctp/usrsctplib/programs/ekr_peer.c
+++ b/chromium/third_party/usrsctp/usrsctplib/programs/ekr_peer.c
@@ -49,6 +49,7 @@
#include <ws2tcpip.h>
#endif
#include <usrsctp.h>
+#include "programs_helper.h"
#define MAX_PACKET_SIZE (1<<16)
#define LINE_LENGTH 80
@@ -116,206 +117,6 @@ conn_output(void *addr, void *buffer, size_t length, uint8_t tos, uint8_t set_df
}
}
-static void
-handle_association_change_event(struct sctp_assoc_change *sac)
-{
- unsigned int i, n;
-
- printf("Association change ");
- switch (sac->sac_state) {
- case SCTP_COMM_UP:
- printf("SCTP_COMM_UP");
- break;
- case SCTP_COMM_LOST:
- printf("SCTP_COMM_LOST");
- break;
- case SCTP_RESTART:
- printf("SCTP_RESTART");
- break;
- case SCTP_SHUTDOWN_COMP:
- printf("SCTP_SHUTDOWN_COMP");
- break;
- case SCTP_CANT_STR_ASSOC:
- printf("SCTP_CANT_STR_ASSOC");
- break;
- default:
- printf("UNKNOWN");
- break;
- }
- printf(", streams (in/out) = (%u/%u)",
- sac->sac_inbound_streams, sac->sac_outbound_streams);
- n = sac->sac_length - sizeof(struct sctp_assoc_change);
- if (((sac->sac_state == SCTP_COMM_UP) ||
- (sac->sac_state == SCTP_RESTART)) && (n > 0)) {
- printf(", supports");
- for (i = 0; i < n; i++) {
- switch (sac->sac_info[i]) {
- case SCTP_ASSOC_SUPPORTS_PR:
- printf(" PR");
- break;
- case SCTP_ASSOC_SUPPORTS_AUTH:
- printf(" AUTH");
- break;
- case SCTP_ASSOC_SUPPORTS_ASCONF:
- printf(" ASCONF");
- break;
- case SCTP_ASSOC_SUPPORTS_MULTIBUF:
- printf(" MULTIBUF");
- break;
- case SCTP_ASSOC_SUPPORTS_RE_CONFIG:
- printf(" RE-CONFIG");
- break;
- default:
- printf(" UNKNOWN(0x%02x)", sac->sac_info[i]);
- break;
- }
- }
- } else if (((sac->sac_state == SCTP_COMM_LOST) ||
- (sac->sac_state == SCTP_CANT_STR_ASSOC)) && (n > 0)) {
- printf(", ABORT =");
- for (i = 0; i < n; i++) {
- printf(" 0x%02x", sac->sac_info[i]);
- }
- }
- printf(".\n");
- if ((sac->sac_state == SCTP_CANT_STR_ASSOC) ||
- (sac->sac_state == SCTP_SHUTDOWN_COMP) ||
- (sac->sac_state == SCTP_COMM_LOST)) {
- exit(0);
- }
- return;
-}
-
-static void
-handle_peer_address_change_event(struct sctp_paddr_change *spc)
-{
- char addr_buf[INET6_ADDRSTRLEN];
- const char *addr;
- struct sockaddr_in *sin;
- struct sockaddr_in6 *sin6;
- struct sockaddr_conn *sconn;
-
- switch (spc->spc_aaddr.ss_family) {
- case AF_INET:
- sin = (struct sockaddr_in *)&spc->spc_aaddr;
- addr = inet_ntop(AF_INET, &sin->sin_addr, addr_buf, INET_ADDRSTRLEN);
- break;
- case AF_INET6:
- sin6 = (struct sockaddr_in6 *)&spc->spc_aaddr;
- addr = inet_ntop(AF_INET6, &sin6->sin6_addr, addr_buf, INET6_ADDRSTRLEN);
- break;
- case AF_CONN:
- sconn = (struct sockaddr_conn *)&spc->spc_aaddr;
-#ifdef _WIN32
- _snprintf(addr_buf, INET6_ADDRSTRLEN, "%p", sconn->sconn_addr);
-#else
- snprintf(addr_buf, INET6_ADDRSTRLEN, "%p", sconn->sconn_addr);
-#endif
- addr = addr_buf;
- break;
- default:
-#ifdef _WIN32
- _snprintf(addr_buf, INET6_ADDRSTRLEN, "Unknown family %d", spc->spc_aaddr.ss_family);
-#else
- snprintf(addr_buf, INET6_ADDRSTRLEN, "Unknown family %d", spc->spc_aaddr.ss_family);
-#endif
- addr = addr_buf;
- break;
- }
- printf("Peer address %s is now ", addr);
- switch (spc->spc_state) {
- case SCTP_ADDR_AVAILABLE:
- printf("SCTP_ADDR_AVAILABLE");
- break;
- case SCTP_ADDR_UNREACHABLE:
- printf("SCTP_ADDR_UNREACHABLE");
- break;
- case SCTP_ADDR_REMOVED:
- printf("SCTP_ADDR_REMOVED");
- break;
- case SCTP_ADDR_ADDED:
- printf("SCTP_ADDR_ADDED");
- break;
- case SCTP_ADDR_MADE_PRIM:
- printf("SCTP_ADDR_MADE_PRIM");
- break;
- case SCTP_ADDR_CONFIRMED:
- printf("SCTP_ADDR_CONFIRMED");
- break;
- default:
- printf("UNKNOWN");
- break;
- }
- printf(" (error = 0x%08x).\n", spc->spc_error);
- return;
-}
-
-static void
-handle_send_failed_event(struct sctp_send_failed_event *ssfe)
-{
- size_t i, n;
-
- if (ssfe->ssfe_flags & SCTP_DATA_UNSENT) {
- printf("Unsent ");
- }
- if (ssfe->ssfe_flags & SCTP_DATA_SENT) {
- printf("Sent ");
- }
- if (ssfe->ssfe_flags & ~(SCTP_DATA_SENT | SCTP_DATA_UNSENT)) {
- printf("(flags = %x) ", ssfe->ssfe_flags);
- }
- printf("message with PPID = %u, SID = %u, flags: 0x%04x due to error = 0x%08x",
- ntohl(ssfe->ssfe_info.snd_ppid), ssfe->ssfe_info.snd_sid,
- ssfe->ssfe_info.snd_flags, ssfe->ssfe_error);
- n = ssfe->ssfe_length - sizeof(struct sctp_send_failed_event);
- for (i = 0; i < n; i++) {
- printf(" 0x%02x", ssfe->ssfe_data[i]);
- }
- printf(".\n");
- return;
-}
-
-static void
-handle_notification(union sctp_notification *notif, size_t n)
-{
- if (notif->sn_header.sn_length != (uint32_t)n) {
- return;
- }
- switch (notif->sn_header.sn_type) {
- case SCTP_ASSOC_CHANGE:
- handle_association_change_event(&(notif->sn_assoc_change));
- break;
- case SCTP_PEER_ADDR_CHANGE:
- handle_peer_address_change_event(&(notif->sn_paddr_change));
- break;
- case SCTP_REMOTE_ERROR:
- break;
- case SCTP_SHUTDOWN_EVENT:
- break;
- case SCTP_ADAPTATION_INDICATION:
- break;
- case SCTP_PARTIAL_DELIVERY_EVENT:
- break;
- case SCTP_AUTHENTICATION_EVENT:
- break;
- case SCTP_SENDER_DRY_EVENT:
- break;
- case SCTP_NOTIFICATIONS_STOPPED_EVENT:
- break;
- case SCTP_SEND_FAILED_EVENT:
- handle_send_failed_event(&(notif->sn_send_failed_event));
- break;
- case SCTP_STREAM_RESET_EVENT:
- break;
- case SCTP_ASSOC_RESET_EVENT:
- break;
- case SCTP_STREAM_CHANGE_EVENT:
- break;
- default:
- break;
- }
-}
-
static int
receive_cb(struct socket *sock, union sctp_sockstore addr, void *data,
size_t datalen, struct sctp_rcvinfo rcv, int flags, void *ulp_info)
@@ -342,16 +143,6 @@ receive_cb(struct socket *sock, union sctp_sockstore addr, void *data,
return (1);
}
-void
-debug_printf(const char *format, ...)
-{
- va_list ap;
-
- va_start(ap, format);
- vprintf(format, ap);
- va_end(ap);
-}
-
int
main(int argc, char *argv[])
{
@@ -390,7 +181,7 @@ main(int argc, char *argv[])
exit(EXIT_FAILURE);
}
#endif
- usrsctp_init(0, conn_output, debug_printf);
+ usrsctp_init(0, conn_output, debug_printf_stack);
/* set up a connected UDP socket */
#ifdef _WIN32
if ((fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == INVALID_SOCKET) {
@@ -492,7 +283,7 @@ main(int argc, char *argv[])
perror("usrsctp_connect");
}
for (;;) {
-#ifdef _WIN32
+#if defined(_WIN32) && !defined(__MINGW32__)
if (gets_s(line, LINE_LENGTH) == NULL) {
#else
if (fgets(line, LINE_LENGTH, stdin) == NULL) {
diff --git a/chromium/third_party/usrsctp/usrsctplib/programs/ekr_server.c b/chromium/third_party/usrsctp/usrsctplib/programs/ekr_server.c
index 5545abb3265..2fdfcc2fcfe 100644
--- a/chromium/third_party/usrsctp/usrsctplib/programs/ekr_server.c
+++ b/chromium/third_party/usrsctp/usrsctplib/programs/ekr_server.c
@@ -49,6 +49,7 @@
#include <ws2tcpip.h>
#endif
#include <usrsctp.h>
+#include "programs_helper.h"
#define PORT 5001
#define MAX_PACKET_SIZE (1<<16)
@@ -152,16 +153,6 @@ receive_cb(struct socket *s, union sctp_sockstore addr, void *data,
return (1);
}
-void
-debug_printf(const char *format, ...)
-{
- va_list ap;
-
- va_start(ap, format);
- vprintf(format, ap);
- va_end(ap);
-}
-
int
main(int argc, char *argv[])
{
@@ -193,7 +184,7 @@ main(int argc, char *argv[])
exit (EXIT_FAILURE);
}
#endif
- usrsctp_init(0, conn_output, debug_printf);
+ usrsctp_init(0, conn_output, debug_printf_stack);
/* set up a connected UDP socket */
#ifdef _WIN32
if ((fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == INVALID_SOCKET) {
diff --git a/chromium/third_party/usrsctp/usrsctplib/programs/http_client.c b/chromium/third_party/usrsctp/usrsctplib/programs/http_client.c
index 4dc197f0137..def038498a8 100644
--- a/chromium/third_party/usrsctp/usrsctplib/programs/http_client.c
+++ b/chromium/third_party/usrsctp/usrsctplib/programs/http_client.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016 Felix Weinrank
+ * Copyright (C) 2016-2019 Felix Weinrank
*
* All rights reserved.
*
@@ -30,7 +30,7 @@
/*
* Usage: http_client remote_addr remote_port [local_port] [local_encaps_port] [remote_encaps_port] [uri]
- *
+ *
* Example
* Client: $ ./http_client 212.201.121.100 80 0 9899 9899 /cgi-bin/he
* ./http_client 2a02:c6a0:4015:10::100 80 0 9899 9899 /cgi-bin/he
@@ -51,10 +51,18 @@
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
+#include <sys/time.h>
#else
#include <io.h>
+#include <sys/types.h>
+#include <sys/timeb.h>
#endif
#include <usrsctp.h>
+#include "programs_helper.h"
+
+#define RETVAL_CATCHALL 50
+#define RETVAL_TIMEOUT 60
+#define RETVAL_ECONNREFUSED 61
int done = 0;
static const char *request_prefix = "GET";
@@ -73,6 +81,9 @@ receive_cb(struct socket *sock, union sctp_sockstore addr, void *data,
done = 1;
usrsctp_close(sock);
} else {
+ if (flags & MSG_NOTIFICATION) {
+ handle_notification((union sctp_notification *)data, datalen);
+ } else {
#ifdef _WIN32
_write(_fileno(stdout), data, (unsigned int)datalen);
#else
@@ -80,41 +91,77 @@ receive_cb(struct socket *sock, union sctp_sockstore addr, void *data,
perror("write");
}
#endif
+ }
free(data);
}
return (1);
}
-void
-debug_printf(const char *format, ...)
-{
- va_list ap;
-
- va_start(ap, format);
- vprintf(format, ap);
- va_end(ap);
-}
-
int
main(int argc, char *argv[])
{
struct socket *sock;
+ struct sockaddr *addr;
+ socklen_t addr_len;
struct sockaddr_in addr4;
struct sockaddr_in6 addr6;
+ struct sockaddr_in bind4;
+ struct sockaddr_in6 bind6;
struct sctp_udpencaps encaps;
struct sctp_sndinfo sndinfo;
- int result;
+ struct sctp_rtoinfo rtoinfo;
+ struct sctp_initmsg initmsg;
+ struct sctp_event event;
+ int result = 0;
+ unsigned int i;
+ uint8_t address_family = 0;
+ uint16_t event_types[] = {SCTP_ASSOC_CHANGE,
+ SCTP_PEER_ADDR_CHANGE,
+ SCTP_SEND_FAILED_EVENT,
+ SCTP_REMOTE_ERROR,
+ SCTP_SHUTDOWN_EVENT,
+ SCTP_ADAPTATION_INDICATION,
+ SCTP_PARTIAL_DELIVERY_EVENT
+ };
+
+ if (argc < 3) {
+ printf("Usage: http_client remote_addr remote_port [local_port] [local_encaps_port] [remote_encaps_port] [uri]\n");
+ return(EXIT_FAILURE);
+ }
+
+ memset((void *)&addr4, 0, sizeof(struct sockaddr_in));
+ memset((void *)&addr6, 0, sizeof(struct sockaddr_in6));
+
+ if (inet_pton(AF_INET, argv[1], &addr4.sin_addr) == 1) {
+ address_family = AF_INET;
- if (argc < 3) {
- printf("Usage: http_client remote_addr remote_port [local_port] [local_encaps_port] [remote_encaps_port] [uri]\n");
- return(EXIT_FAILURE);
- }
+ addr = (struct sockaddr *)&addr4;
+ addr_len = sizeof(addr4);
+#ifdef HAVE_SIN_LEN
+ addr4.sin_len = sizeof(struct sockaddr_in);
+#endif
+ addr4.sin_family = AF_INET;
+ addr4.sin_port = htons(atoi(argv[2]));
+ } else if (inet_pton(AF_INET6, argv[1], &addr6.sin6_addr) == 1) {
+ address_family = AF_INET6;
+
+ addr = (struct sockaddr *)&addr6;
+ addr_len = sizeof(addr6);
+#ifdef HAVE_SIN6_LEN
+ addr6.sin6_len = sizeof(struct sockaddr_in6);
+#endif
+ addr6.sin6_family = AF_INET6;
+ addr6.sin6_port = htons(atoi(argv[2]));
+ } else {
+ printf("Unsupported destination address - use IPv4 or IPv6 address\n");
+ result = RETVAL_CATCHALL;
+ goto out;
+ }
- result = 0;
if (argc > 4) {
- usrsctp_init(atoi(argv[4]), NULL, debug_printf);
+ usrsctp_init(atoi(argv[4]), NULL, debug_printf_stack);
} else {
- usrsctp_init(9899, NULL, debug_printf);
+ usrsctp_init(9899, NULL, debug_printf_stack);
}
#ifdef SCTP_DEBUG
@@ -122,37 +169,87 @@ main(int argc, char *argv[])
#endif
usrsctp_sysctl_set_sctp_blackhole(2);
+ usrsctp_sysctl_set_sctp_no_csum_on_loopback(0);
- if ((sock = usrsctp_socket(AF_INET6, SOCK_STREAM, IPPROTO_SCTP, receive_cb, NULL, 0, NULL)) == NULL) {
+ if ((sock = usrsctp_socket(address_family, SOCK_STREAM, IPPROTO_SCTP, receive_cb, NULL, 0, NULL)) == NULL) {
perror("usrsctp_socket");
- result = 1;
+ result = RETVAL_CATCHALL;
+ goto out;
+ }
+
+ memset(&event, 0, sizeof(event));
+ event.se_assoc_id = SCTP_ALL_ASSOC;
+ event.se_on = 1;
+ for (i = 0; i < sizeof(event_types) / sizeof(uint16_t); i++) {
+ event.se_type = event_types[i];
+ if (usrsctp_setsockopt(sock, IPPROTO_SCTP, SCTP_EVENT, &event, sizeof(event)) < 0) {
+ perror("setsockopt SCTP_EVENT");
+ }
+ }
+
+ rtoinfo.srto_assoc_id = 0;
+ rtoinfo.srto_initial = 1000;
+ rtoinfo.srto_min = 1000;
+ rtoinfo.srto_max = 8000;
+ if (usrsctp_setsockopt(sock, IPPROTO_SCTP, SCTP_RTOINFO, (const void *)&rtoinfo, (socklen_t)sizeof(struct sctp_rtoinfo)) < 0) {
+ perror("setsockopt");
+ usrsctp_close(sock);
+ result = RETVAL_CATCHALL;
+ goto out;
+ }
+ initmsg.sinit_num_ostreams = 1;
+ initmsg.sinit_max_instreams = 1;
+ initmsg.sinit_max_attempts = 5;
+ initmsg.sinit_max_init_timeo = 4000;
+ if (usrsctp_setsockopt(sock, IPPROTO_SCTP, SCTP_INITMSG, (const void *)&initmsg, (socklen_t)sizeof(struct sctp_initmsg)) < 0) {
+ perror("setsockopt");
+ usrsctp_close(sock);
+ result = RETVAL_CATCHALL;
goto out;
}
if (argc > 3) {
- memset((void *)&addr6, 0, sizeof(struct sockaddr_in6));
+
+ if (address_family == AF_INET) {
+ memset((void *)&bind4, 0, sizeof(struct sockaddr_in));
+#ifdef HAVE_SIN_LEN
+ bind4.sin_len = sizeof(struct sockaddr_in6);
+#endif
+ bind4.sin_family = AF_INET;
+ bind4.sin_port = htons(atoi(argv[3]));
+ bind4.sin_addr.s_addr = htonl(INADDR_ANY);
+
+ if (usrsctp_bind(sock, (struct sockaddr *)&bind4, sizeof(bind4)) < 0) {
+ perror("bind");
+ usrsctp_close(sock);
+ result = RETVAL_CATCHALL;
+ goto out;
+ }
+ } else {
+ memset((void *)&bind6, 0, sizeof(struct sockaddr_in6));
#ifdef HAVE_SIN6_LEN
- addr6.sin6_len = sizeof(struct sockaddr_in6);
+ bind6.sin6_len = sizeof(struct sockaddr_in6);
#endif
- addr6.sin6_family = AF_INET6;
- addr6.sin6_port = htons(atoi(argv[3]));
- addr6.sin6_addr = in6addr_any;
- if (usrsctp_bind(sock, (struct sockaddr *)&addr6, sizeof(struct sockaddr_in6)) < 0) {
- perror("bind");
- usrsctp_close(sock);
- result = 2;
- goto out;
+ bind6.sin6_family = AF_INET6;
+ bind6.sin6_port = htons(atoi(argv[3]));
+ bind6.sin6_addr = in6addr_any;
+ if (usrsctp_bind(sock, (struct sockaddr *)&bind6, sizeof(bind6)) < 0) {
+ perror("bind");
+ usrsctp_close(sock);
+ result = RETVAL_CATCHALL;
+ goto out;
+ }
}
}
if (argc > 5) {
memset(&encaps, 0, sizeof(struct sctp_udpencaps));
- encaps.sue_address.ss_family = AF_INET6;
+ encaps.sue_address.ss_family = address_family;
encaps.sue_port = htons(atoi(argv[5]));
if (usrsctp_setsockopt(sock, IPPROTO_SCTP, SCTP_REMOTE_UDP_ENCAPS_PORT, (const void *)&encaps, (socklen_t)sizeof(struct sctp_udpencaps)) < 0) {
perror("setsockopt");
usrsctp_close(sock);
- result = 3;
+ result = RETVAL_CATCHALL;
goto out;
}
}
@@ -174,36 +271,17 @@ main(int argc, char *argv[])
printf("\nHTTP request:\n%s\n", request);
printf("\nHTTP response:\n");
- memset((void *)&addr4, 0, sizeof(struct sockaddr_in));
- memset((void *)&addr6, 0, sizeof(struct sockaddr_in6));
-#ifdef HAVE_SIN_LEN
- addr4.sin_len = sizeof(struct sockaddr_in);
-#endif
-#ifdef HAVE_SIN6_LEN
- addr6.sin6_len = sizeof(struct sockaddr_in6);
-#endif
- addr4.sin_family = AF_INET;
- addr6.sin6_family = AF_INET6;
- addr4.sin_port = htons(atoi(argv[2]));
- addr6.sin6_port = htons(atoi(argv[2]));
- if (inet_pton(AF_INET6, argv[1], &addr6.sin6_addr) == 1) {
- if (usrsctp_connect(sock, (struct sockaddr *)&addr6, sizeof(struct sockaddr_in6)) < 0) {
- perror("usrsctp_connect");
- usrsctp_close(sock);
- result = 4;
- goto out;
- }
- } else if (inet_pton(AF_INET, argv[1], &addr4.sin_addr) == 1) {
- if (usrsctp_connect(sock, (struct sockaddr *)&addr4, sizeof(struct sockaddr_in)) < 0) {
- perror("usrsctp_connect");
- usrsctp_close(sock);
- result = 5;
- goto out;
+ if (usrsctp_connect(sock, addr, addr_len) < 0) {
+ if (errno == ECONNREFUSED) {
+ result = RETVAL_ECONNREFUSED;
+ } else if (errno == ETIMEDOUT) {
+ result = RETVAL_TIMEOUT;
+ } else {
+ result = RETVAL_CATCHALL;
}
- } else {
- printf("Illegal destination address\n");
+ perror("usrsctp_connect");
usrsctp_close(sock);
- result = 6;
+
goto out;
}
@@ -213,7 +291,7 @@ main(int argc, char *argv[])
if (usrsctp_sendv(sock, request, strlen(request), NULL, 0, &sndinfo, sizeof(struct sctp_sndinfo), SCTP_SENDV_SNDINFO, 0) < 0) {
perror("usrsctp_sendv");
usrsctp_close(sock);
- result = 6;
+ result = RETVAL_CATCHALL;
goto out;
}
@@ -232,5 +310,6 @@ out:
sleep(1);
#endif
}
+ printf("Finished, returning with %d\n", result);
return (result);
}
diff --git a/chromium/third_party/usrsctp/usrsctplib/programs/http_client_upcall.c b/chromium/third_party/usrsctp/usrsctplib/programs/http_client_upcall.c
new file mode 100644
index 00000000000..5583b54c298
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/programs/http_client_upcall.c
@@ -0,0 +1,332 @@
+/*
+ * Copyright (C) 2016-2019 Felix Weinrank
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * Usage: http_client_upcall remote_addr remote_port [local_port] [local_encaps_port] [remote_encaps_port] [uri]
+ */
+
+#ifdef _WIN32
+#define _CRT_SECURE_NO_WARNINGS
+#endif
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+#ifndef _WIN32
+#include <unistd.h>
+#endif
+#include <sys/types.h>
+#ifndef _WIN32
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <sys/time.h>
+#else
+#include <sys/types.h>
+#include <sys/timeb.h>
+#include <io.h>
+#endif
+#include <usrsctp.h>
+#include "programs_helper.h"
+
+
+#define RETVAL_CATCHALL 50
+#define RETVAL_TIMEOUT 60
+#define RETVAL_ECONNREFUSED 61
+
+int done = 0;
+int writePending = 1;
+int result = 0;
+
+static const char *request_prefix = "GET";
+static const char *request_postfix = "HTTP/1.0\r\nUser-agent: libusrsctp\r\nConnection: close\r\n\r\n";
+char request[512];
+
+#ifdef _WIN32
+typedef char* caddr_t;
+#endif
+
+#define BUFFERSIZE (1<<16)
+
+static void handle_upcall(struct socket *sock, void *arg, int flgs)
+{
+ int events = usrsctp_get_events(sock);
+ ssize_t bytesSent = 0;
+ char *buf;
+
+ if ((events & SCTP_EVENT_READ) && !done) {
+ struct sctp_recvv_rn rn;
+ ssize_t n;
+ struct sockaddr_in addr;
+ buf = malloc(BUFFERSIZE);
+ int flags = 0;
+ socklen_t len = (socklen_t)sizeof(struct sockaddr_in);
+ unsigned int infotype = 0;
+ socklen_t infolen = sizeof(struct sctp_recvv_rn);
+
+ memset(&rn, 0, sizeof(struct sctp_recvv_rn));
+ n = usrsctp_recvv(sock, buf, BUFFERSIZE, (struct sockaddr *) &addr, &len, (void *)&rn,
+ &infolen, &infotype, &flags);
+
+ if (n < 0) {
+ if (errno == ECONNREFUSED) {
+ result = RETVAL_ECONNREFUSED;
+ } else if (errno == ETIMEDOUT) {
+ result = RETVAL_TIMEOUT;
+ } else {
+ result = RETVAL_CATCHALL;
+ }
+ perror("usrsctp_connect");
+ }
+
+ if (n <= 0){
+ done = 1;
+ usrsctp_close(sock);
+ } else {
+#ifdef _WIN32
+ _write(_fileno(stdout), buf, (unsigned int)n);
+#else
+ if (write(fileno(stdout), buf, n) < 0) {
+ perror("write");
+ }
+#endif
+ }
+ free(buf);
+ }
+
+ if ((events & SCTP_EVENT_WRITE) && writePending && !done) {
+ writePending = 0;
+ printf("\nHTTP request:\n%s\n", request);
+ printf("\nHTTP response:\n");
+
+ /* send GET request */
+ bytesSent = usrsctp_sendv(sock, request, strlen(request), NULL, 0, NULL, 0, SCTP_SENDV_NOINFO, 0);
+ if (bytesSent < 0) {
+ perror("usrsctp_sendv");
+ usrsctp_close(sock);
+ } else {
+ printf("%d bytes sent\n", (int)bytesSent);
+ }
+ }
+}
+
+int
+main(int argc, char *argv[])
+{
+ struct socket *sock;
+ struct sockaddr *addr;
+ socklen_t addr_len;
+ struct sockaddr_in addr4;
+ struct sockaddr_in6 addr6;
+ struct sockaddr_in bind4;
+ struct sockaddr_in6 bind6;
+ struct sctp_udpencaps encaps;
+ struct sctp_rtoinfo rtoinfo;
+ struct sctp_initmsg initmsg;
+ uint8_t address_family = 0;
+
+ if (argc < 3) {
+ printf("Usage: http_client_upcall remote_addr remote_port [local_port] [local_encaps_port] [remote_encaps_port] [uri]\n");
+ return(EXIT_FAILURE);
+ }
+
+ memset((void *)&addr4, 0, sizeof(struct sockaddr_in));
+ memset((void *)&addr6, 0, sizeof(struct sockaddr_in6));
+
+ if (inet_pton(AF_INET, argv[1], &addr4.sin_addr) == 1) {
+ address_family = AF_INET;
+
+ addr = (struct sockaddr *)&addr4;
+ addr_len = sizeof(addr4);
+#ifdef HAVE_SIN_LEN
+ addr4.sin_len = sizeof(struct sockaddr_in);
+#endif
+ addr4.sin_family = AF_INET;
+ addr4.sin_port = htons(atoi(argv[2]));
+ } else if (inet_pton(AF_INET6, argv[1], &addr6.sin6_addr) == 1) {
+ address_family = AF_INET6;
+
+ addr = (struct sockaddr *)&addr6;
+ addr_len = sizeof(addr6);
+#ifdef HAVE_SIN6_LEN
+ addr6.sin6_len = sizeof(struct sockaddr_in6);
+#endif
+ addr6.sin6_family = AF_INET6;
+ addr6.sin6_port = htons(atoi(argv[2]));
+ } else {
+ printf("Unsupported destination address - use IPv4 or IPv6 address\n");
+ result = RETVAL_CATCHALL;
+ goto out;
+ }
+
+ if (argc > 4) {
+ usrsctp_init(atoi(argv[4]), NULL, debug_printf_stack);
+ } else {
+ usrsctp_init(9899, NULL, debug_printf_stack);
+ }
+
+#ifdef SCTP_DEBUG
+ usrsctp_sysctl_set_sctp_debug_on(SCTP_DEBUG_ALL);
+#endif
+
+ usrsctp_sysctl_set_sctp_blackhole(2);
+ usrsctp_sysctl_set_sctp_no_csum_on_loopback(0);
+
+ if ((sock = usrsctp_socket(address_family, SOCK_STREAM, IPPROTO_SCTP, NULL, NULL, 0, NULL)) == NULL) {
+ perror("usrsctp_socket");
+ result = RETVAL_CATCHALL;
+ goto out;
+ }
+
+ /* usrsctp_set_non_blocking(sock, 1); */
+
+ rtoinfo.srto_assoc_id = 0;
+ rtoinfo.srto_initial = 1000;
+ rtoinfo.srto_min = 1000;
+ rtoinfo.srto_max = 8000;
+ if (usrsctp_setsockopt(sock, IPPROTO_SCTP, SCTP_RTOINFO, (const void *)&rtoinfo, (socklen_t)sizeof(struct sctp_rtoinfo)) < 0) {
+ perror("setsockopt");
+ usrsctp_close(sock);
+ result = RETVAL_CATCHALL;
+ goto out;
+ }
+ initmsg.sinit_num_ostreams = 1;
+ initmsg.sinit_max_instreams = 1;
+ initmsg.sinit_max_attempts = 5;
+ initmsg.sinit_max_init_timeo = 4000;
+ if (usrsctp_setsockopt(sock, IPPROTO_SCTP, SCTP_INITMSG, (const void *)&initmsg, (socklen_t)sizeof(struct sctp_initmsg)) < 0) {
+ perror("setsockopt");
+ usrsctp_close(sock);
+ result = RETVAL_CATCHALL;
+ goto out;
+ }
+
+ if (argc > 3) {
+
+ if (address_family == AF_INET) {
+ memset((void *)&bind4, 0, sizeof(struct sockaddr_in));
+#ifdef HAVE_SIN_LEN
+ bind4.sin_len = sizeof(struct sockaddr_in6);
+#endif
+ bind4.sin_family = AF_INET;
+ bind4.sin_port = htons(atoi(argv[3]));
+ bind4.sin_addr.s_addr = htonl(INADDR_ANY);
+
+ if (usrsctp_bind(sock, (struct sockaddr *)&bind4, sizeof(bind4)) < 0) {
+ perror("bind");
+ usrsctp_close(sock);
+ result = RETVAL_CATCHALL;
+ goto out;
+ }
+ } else {
+ memset((void *)&bind6, 0, sizeof(struct sockaddr_in6));
+#ifdef HAVE_SIN6_LEN
+ bind6.sin6_len = sizeof(struct sockaddr_in6);
+#endif
+ bind6.sin6_family = AF_INET6;
+ bind6.sin6_port = htons(atoi(argv[3]));
+ bind6.sin6_addr = in6addr_any;
+ if (usrsctp_bind(sock, (struct sockaddr *)&bind6, sizeof(bind6)) < 0) {
+ perror("bind");
+ usrsctp_close(sock);
+ result = RETVAL_CATCHALL;
+ goto out;
+ }
+ }
+ }
+
+ if (argc > 5) {
+ memset(&encaps, 0, sizeof(struct sctp_udpencaps));
+ encaps.sue_address.ss_family = address_family;
+ encaps.sue_port = htons(atoi(argv[5]));
+ if (usrsctp_setsockopt(sock, IPPROTO_SCTP, SCTP_REMOTE_UDP_ENCAPS_PORT, (const void *)&encaps, (socklen_t)sizeof(struct sctp_udpencaps)) < 0) {
+ perror("setsockopt");
+ usrsctp_close(sock);
+ result = RETVAL_CATCHALL;
+ goto out;
+ }
+ }
+
+ if (argc > 6) {
+#ifdef _WIN32
+ _snprintf(request, sizeof(request), "%s %s %s", request_prefix, argv[6], request_postfix);
+#else
+ snprintf(request, sizeof(request), "%s %s %s", request_prefix, argv[6], request_postfix);
+#endif
+ } else {
+#ifdef _WIN32
+ _snprintf(request, sizeof(request), "%s %s %s", request_prefix, "/", request_postfix);
+#else
+ snprintf(request, sizeof(request), "%s %s %s", request_prefix, "/", request_postfix);
+#endif
+ }
+
+ printf("\nHTTP request:\n%s\n", request);
+ printf("\nHTTP response:\n");
+
+
+ usrsctp_set_upcall(sock, handle_upcall, NULL);
+ usrsctp_set_non_blocking(sock, 1);
+
+ if (usrsctp_connect(sock, addr, addr_len) < 0) {
+ if (errno != EINPROGRESS) {
+ if (errno == ECONNREFUSED) {
+ result = RETVAL_ECONNREFUSED;
+ } else if (errno == ETIMEDOUT) {
+ result = RETVAL_TIMEOUT;
+ } else {
+ result = RETVAL_CATCHALL;
+ }
+ perror("usrsctp_connect");
+ usrsctp_close(sock);
+
+ goto out;
+ }
+ }
+
+ while (!done) {
+#ifdef _WIN32
+ Sleep(1*1000);
+#else
+ sleep(1);
+#endif
+ }
+out:
+ while (usrsctp_finish() != 0) {
+#ifdef _WIN32
+ Sleep(1000);
+#else
+ sleep(1);
+#endif
+ }
+
+ printf("Finished, returning with %d\n", result);
+ return (result);
+}
diff --git a/chromium/third_party/usrsctp/usrsctplib/programs/meson.build b/chromium/third_party/usrsctp/usrsctplib/programs/meson.build
new file mode 100644
index 00000000000..9cbb0fb2e82
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/programs/meson.build
@@ -0,0 +1,29 @@
+# Helper sources for all programs
+programs_helper_sources = files('programs_helper.c')
+
+# Programs and their sources
+programs = {
+ 'chargen_server_upcall': files('chargen_server_upcall.c'),
+ 'client': files('client.c'),
+ 'st_client': files('st_client.c'),
+ 'client_upcall': files('client_upcall.c'),
+ 'daytime_server': files('daytime_server.c'),
+ 'daytime_server_upcall': files('daytime_server_upcall.c'),
+ 'discard_server': files('discard_server.c'),
+ 'discard_server_upcall': files('discard_server_upcall.c'),
+ 'echo_server': files('echo_server.c'),
+ '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'),
+ 'http_client': files('http_client.c'),
+ 'http_client_upcall': files('http_client_upcall.c'),
+ 'rtcweb': files('rtcweb.c'),
+ 'test_libmgmt': files('test_libmgmt.c'),
+ 'test_timer': files('test_timer.c'),
+ 'tsctp': files('tsctp.c'),
+}
+
diff --git a/chromium/third_party/usrsctp/usrsctplib/programs/programs_helper.c b/chromium/third_party/usrsctp/usrsctplib/programs/programs_helper.c
new file mode 100644
index 00000000000..49185c254bb
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/programs/programs_helper.c
@@ -0,0 +1,339 @@
+
+#ifdef _WIN32
+#define _CRT_SECURE_NO_WARNINGS
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <usrsctp.h>
+
+#ifndef _WIN32
+#include <sys/time.h>
+#include <arpa/inet.h>
+#else
+#include <sys/types.h>
+#include <sys/timeb.h>
+#include <io.h>
+#endif
+
+#include "programs_helper.h"
+
+#ifdef _WIN32
+static void
+gettimeofday(struct timeval *tv, void *ignore)
+{
+ struct timeb tb;
+
+ ftime(&tb);
+ tv->tv_sec = (long)tb.time;
+ tv->tv_usec = (long)(tb.millitm) * 1000L;
+}
+#endif
+
+void
+debug_printf_runtime(void) {
+ static struct timeval time_main;
+ struct timeval time_now;
+ struct timeval time_delta;
+
+ if (time_main.tv_sec == 0 && time_main.tv_usec == 0) {
+ gettimeofday(&time_main, NULL);
+ }
+
+ gettimeofday(&time_now, NULL);
+ timersub(&time_now, &time_main, &time_delta);
+
+ fprintf(stderr, "[%u.%03u] ", (unsigned int) time_delta.tv_sec, (unsigned int) time_delta.tv_usec / 1000);
+}
+
+
+void
+debug_printf_stack(const char *format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ vprintf(format, ap);
+ va_end(ap);
+}
+
+static void
+handle_association_change_event(struct sctp_assoc_change *sac)
+{
+ unsigned int i, n;
+
+ fprintf(stderr, "Association change ");
+ switch (sac->sac_state) {
+ case SCTP_COMM_UP:
+ fprintf(stderr, "SCTP_COMM_UP");
+ break;
+ case SCTP_COMM_LOST:
+ fprintf(stderr, "SCTP_COMM_LOST");
+ break;
+ case SCTP_RESTART:
+ fprintf(stderr, "SCTP_RESTART");
+ break;
+ case SCTP_SHUTDOWN_COMP:
+ fprintf(stderr, "SCTP_SHUTDOWN_COMP");
+ break;
+ case SCTP_CANT_STR_ASSOC:
+ fprintf(stderr, "SCTP_CANT_STR_ASSOC");
+ break;
+ default:
+ fprintf(stderr, "UNKNOWN");
+ break;
+ }
+ fprintf(stderr, ", streams (in/out) = (%u/%u)",
+ sac->sac_inbound_streams, sac->sac_outbound_streams);
+ n = sac->sac_length - sizeof(struct sctp_assoc_change);
+ if (((sac->sac_state == SCTP_COMM_UP) ||
+ (sac->sac_state == SCTP_RESTART)) && (n > 0)) {
+ fprintf(stderr, ", supports");
+ for (i = 0; i < n; i++) {
+ switch (sac->sac_info[i]) {
+ case SCTP_ASSOC_SUPPORTS_PR:
+ fprintf(stderr, " PR");
+ break;
+ case SCTP_ASSOC_SUPPORTS_AUTH:
+ fprintf(stderr, " AUTH");
+ break;
+ case SCTP_ASSOC_SUPPORTS_ASCONF:
+ fprintf(stderr, " ASCONF");
+ break;
+ case SCTP_ASSOC_SUPPORTS_MULTIBUF:
+ fprintf(stderr, " MULTIBUF");
+ break;
+ case SCTP_ASSOC_SUPPORTS_RE_CONFIG:
+ fprintf(stderr, " RE-CONFIG");
+ break;
+ default:
+ fprintf(stderr, " UNKNOWN(0x%02x)", sac->sac_info[i]);
+ break;
+ }
+ }
+ } else if (((sac->sac_state == SCTP_COMM_LOST) ||
+ (sac->sac_state == SCTP_CANT_STR_ASSOC)) && (n > 0)) {
+ fprintf(stderr, ", ABORT =");
+ for (i = 0; i < n; i++) {
+ fprintf(stderr, " 0x%02x", sac->sac_info[i]);
+ }
+ }
+ fprintf(stderr, ".\n");
+ return;
+}
+
+static void
+handle_peer_address_change_event(struct sctp_paddr_change *spc)
+{
+ char addr_buf[INET6_ADDRSTRLEN];
+ const char *addr;
+ struct sockaddr_in *sin;
+ struct sockaddr_in6 *sin6;
+ struct sockaddr_conn *sconn;
+
+ switch (spc->spc_aaddr.ss_family) {
+ case AF_INET:
+ sin = (struct sockaddr_in *)&spc->spc_aaddr;
+ addr = inet_ntop(AF_INET, &sin->sin_addr, addr_buf, INET_ADDRSTRLEN);
+ break;
+ case AF_INET6:
+ sin6 = (struct sockaddr_in6 *)&spc->spc_aaddr;
+ addr = inet_ntop(AF_INET6, &sin6->sin6_addr, addr_buf, INET6_ADDRSTRLEN);
+ break;
+ case AF_CONN:
+ sconn = (struct sockaddr_conn *)&spc->spc_aaddr;
+#ifdef _WIN32
+ _snprintf(addr_buf, INET6_ADDRSTRLEN, "%p", sconn->sconn_addr);
+#else
+ snprintf(addr_buf, INET6_ADDRSTRLEN, "%p", sconn->sconn_addr);
+#endif
+ addr = addr_buf;
+ break;
+ default:
+#ifdef _WIN32
+ _snprintf(addr_buf, INET6_ADDRSTRLEN, "Unknown family %d", spc->spc_aaddr.ss_family);
+#else
+ snprintf(addr_buf, INET6_ADDRSTRLEN, "Unknown family %d", spc->spc_aaddr.ss_family);
+#endif
+ addr = addr_buf;
+ break;
+ }
+ fprintf(stderr, "Peer address %s is now ", addr);
+ switch (spc->spc_state) {
+ case SCTP_ADDR_AVAILABLE:
+ fprintf(stderr, "SCTP_ADDR_AVAILABLE");
+ break;
+ case SCTP_ADDR_UNREACHABLE:
+ fprintf(stderr, "SCTP_ADDR_UNREACHABLE");
+ break;
+ case SCTP_ADDR_REMOVED:
+ fprintf(stderr, "SCTP_ADDR_REMOVED");
+ break;
+ case SCTP_ADDR_ADDED:
+ fprintf(stderr, "SCTP_ADDR_ADDED");
+ break;
+ case SCTP_ADDR_MADE_PRIM:
+ fprintf(stderr, "SCTP_ADDR_MADE_PRIM");
+ break;
+ case SCTP_ADDR_CONFIRMED:
+ fprintf(stderr, "SCTP_ADDR_CONFIRMED");
+ break;
+ default:
+ fprintf(stderr, "UNKNOWN");
+ break;
+ }
+ fprintf(stderr, " (error = 0x%08x).\n", spc->spc_error);
+ return;
+}
+
+static void
+handle_send_failed_event(struct sctp_send_failed_event *ssfe)
+{
+ size_t i, n;
+
+ if (ssfe->ssfe_flags & SCTP_DATA_UNSENT) {
+ fprintf(stderr, "Unsent ");
+ }
+ if (ssfe->ssfe_flags & SCTP_DATA_SENT) {
+ fprintf(stderr, "Sent ");
+ }
+ if (ssfe->ssfe_flags & ~(SCTP_DATA_SENT | SCTP_DATA_UNSENT)) {
+ fprintf(stderr, "(flags = %x) ", ssfe->ssfe_flags);
+ }
+ fprintf(stderr, "message with PPID = %u, SID = %u, flags: 0x%04x due to error = 0x%08x",
+ ntohl(ssfe->ssfe_info.snd_ppid), ssfe->ssfe_info.snd_sid,
+ ssfe->ssfe_info.snd_flags, ssfe->ssfe_error);
+ n = ssfe->ssfe_length - sizeof(struct sctp_send_failed_event);
+ for (i = 0; i < n; i++) {
+ fprintf(stderr, " 0x%02x", ssfe->ssfe_data[i]);
+ }
+ fprintf(stderr, ".\n");
+ return;
+}
+
+static void
+handle_adaptation_indication(struct sctp_adaptation_event *sai)
+{
+ fprintf(stderr, "Adaptation indication: %x.\n", sai-> sai_adaptation_ind);
+ return;
+}
+
+static void
+handle_shutdown_event(struct sctp_shutdown_event *sse)
+{
+ fprintf(stderr, "Shutdown event.\n");
+ /* XXX: notify all channels. */
+ return;
+}
+
+static void
+handle_stream_reset_event(struct sctp_stream_reset_event *strrst)
+{
+ uint32_t n, i;
+
+ n = (strrst->strreset_length - sizeof(struct sctp_stream_reset_event)) / sizeof(uint16_t);
+ fprintf(stderr, "Stream reset event: flags = %x, ", strrst->strreset_flags);
+ if (strrst->strreset_flags & SCTP_STREAM_RESET_INCOMING_SSN) {
+ if (strrst->strreset_flags & SCTP_STREAM_RESET_OUTGOING_SSN) {
+ fprintf(stderr, "incoming/");
+ }
+ fprintf(stderr, "incoming ");
+ }
+ if (strrst->strreset_flags & SCTP_STREAM_RESET_OUTGOING_SSN) {
+ fprintf(stderr, "outgoing ");
+ }
+ fprintf(stderr, "stream ids = ");
+ for (i = 0; i < n; i++) {
+ if (i > 0) {
+ fprintf(stderr, ", ");
+ }
+ fprintf(stderr, "%d", strrst->strreset_stream_list[i]);
+ }
+ fprintf(stderr, ".\n");
+ return;
+}
+
+static void
+handle_stream_change_event(struct sctp_stream_change_event *strchg)
+{
+ fprintf(stderr, "Stream change event: streams (in/out) = (%u/%u), flags = %x.\n",
+ strchg->strchange_instrms, strchg->strchange_outstrms, strchg->strchange_flags);
+ return;
+}
+
+static void
+handle_remote_error_event(struct sctp_remote_error *sre)
+{
+ size_t i, n;
+
+ n = sre->sre_length - sizeof(struct sctp_remote_error);
+ fprintf(stderr, "Remote Error (error = 0x%04x): ", sre->sre_error);
+ for (i = 0; i < n; i++) {
+ fprintf(stderr, " 0x%02x", sre-> sre_data[i]);
+ }
+ fprintf(stderr, ".\n");
+ return;
+}
+
+void
+handle_notification(union sctp_notification *notif, size_t n)
+{
+ if (notif->sn_header.sn_length != (uint32_t)n) {
+ return;
+ }
+
+ fprintf(stderr, "handle_notification : ");
+
+ switch (notif->sn_header.sn_type) {
+ case SCTP_ASSOC_CHANGE:
+ fprintf(stderr, "SCTP_ASSOC_CHANGE\n");
+ handle_association_change_event(&(notif->sn_assoc_change));
+ break;
+ case SCTP_PEER_ADDR_CHANGE:
+ fprintf(stderr, "SCTP_PEER_ADDR_CHANGE\n");
+ handle_peer_address_change_event(&(notif->sn_paddr_change));
+ break;
+ case SCTP_REMOTE_ERROR:
+ fprintf(stderr, "SCTP_REMOTE_ERROR\n");
+ handle_remote_error_event(&(notif->sn_remote_error));
+ break;
+ case SCTP_SHUTDOWN_EVENT:
+ fprintf(stderr, "SCTP_SHUTDOWN_EVENT\n");
+ handle_shutdown_event(&(notif->sn_shutdown_event));
+ break;
+ case SCTP_ADAPTATION_INDICATION:
+ fprintf(stderr, "SCTP_ADAPTATION_INDICATION\n");
+ handle_adaptation_indication(&(notif->sn_adaptation_event));
+ break;
+ case SCTP_PARTIAL_DELIVERY_EVENT:
+ fprintf(stderr, "SCTP_PARTIAL_DELIVERY_EVENT\n");
+ break;
+ case SCTP_AUTHENTICATION_EVENT:
+ fprintf(stderr, "SCTP_AUTHENTICATION_EVENT\n");
+ break;
+ case SCTP_SENDER_DRY_EVENT:
+ fprintf(stderr, "SCTP_SENDER_DRY_EVENT\n");
+ break;
+ case SCTP_NOTIFICATIONS_STOPPED_EVENT:
+ fprintf(stderr, "SCTP_NOTIFICATIONS_STOPPED_EVENT\n");
+ break;
+ case SCTP_SEND_FAILED_EVENT:
+ fprintf(stderr, "SCTP_SEND_FAILED_EVENT\n");
+ handle_send_failed_event(&(notif->sn_send_failed_event));
+ break;
+ case SCTP_STREAM_RESET_EVENT:
+ fprintf(stderr, "SCTP_STREAM_RESET_EVENT\n");
+ handle_stream_reset_event(&(notif->sn_strreset_event));
+ break;
+ case SCTP_ASSOC_RESET_EVENT:
+ fprintf(stderr, "SCTP_ASSOC_RESET_EVENT\n");
+ break;
+ case SCTP_STREAM_CHANGE_EVENT:
+ fprintf(stderr, "SCTP_STREAM_CHANGE_EVENT\n");
+ handle_stream_change_event(&(notif->sn_strchange_event));
+ break;
+ default:
+ break;
+ }
+}
diff --git a/chromium/third_party/usrsctp/usrsctplib/programs/programs_helper.h b/chromium/third_party/usrsctp/usrsctplib/programs/programs_helper.h
new file mode 100644
index 00000000000..2a1da5f5d05
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/programs/programs_helper.h
@@ -0,0 +1,87 @@
+/*-
+ * Copyright (c) 2019 Felix Weinrank
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef __PROGRAMS_HELPER_H__
+#define __PROGRAMS_HELPER_H__
+
+#ifndef _WIN32
+#define SCTP_PACKED __attribute__((packed))
+#else
+#pragma pack (push, 1)
+#define SCTP_PACKED
+#endif
+
+struct sctp_chunk_header {
+ uint8_t chunk_type; /* chunk type */
+ uint8_t chunk_flags; /* chunk flags */
+ uint16_t chunk_length; /* chunk length */
+ /* optional params follow */
+} SCTP_PACKED;
+
+struct sctp_init_chunk {
+ struct sctp_chunk_header ch;
+ uint32_t initiate_tag; /* initiate tag */
+ uint32_t a_rwnd; /* a_rwnd */
+ uint16_t num_outbound_streams; /* OS */
+ uint16_t num_inbound_streams; /* MIS */
+ uint32_t initial_tsn; /* I-TSN */
+ /* optional param's follow */
+} SCTP_PACKED;
+
+#ifdef _WIN32
+#pragma pack(pop)
+#endif
+
+#undef SCTP_PACKED
+
+void
+handle_notification(union sctp_notification *notif, size_t n);
+#ifndef timersub
+#define timersub(tvp, uvp, vvp) \
+ do { \
+ (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \
+ (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \
+ if ((vvp)->tv_usec < 0) { \
+ (vvp)->tv_sec--; \
+ (vvp)->tv_usec += 1000000; \
+ } \
+ } while (0)
+#endif
+
+void
+debug_printf_runtime(void);
+
+void
+debug_printf_stack(const char *format, ...);
+
+#define debug_printf(...) \
+ do { \
+ fprintf(stderr, "[P]"); \
+ debug_printf_runtime(); \
+ fprintf(stderr, __VA_ARGS__); \
+ } while (0)
+#endif /* __PROGRAMS_HELPER_H__ */
diff --git a/chromium/third_party/usrsctp/usrsctplib/programs/rtcweb.c b/chromium/third_party/usrsctp/usrsctplib/programs/rtcweb.c
index 5c5908d8556..1bf3b1827d1 100644
--- a/chromium/third_party/usrsctp/usrsctplib/programs/rtcweb.c
+++ b/chromium/third_party/usrsctp/usrsctplib/programs/rtcweb.c
@@ -56,6 +56,7 @@
#include <string.h>
#include <errno.h>
#include <usrsctp.h>
+#include "programs_helper.h"
#define LINE_LENGTH (1024)
#define BUFFER_SIZE (1<<16)
@@ -119,6 +120,10 @@ struct peer_connection {
#define SCTP_PACKED
#endif
+#if defined(_WIN32) && !defined(__MINGW32__)
+#pragma warning( push )
+#pragma warning( disable : 4200 )
+#endif /* defined(_WIN32) && !defined(__MINGW32__) */
struct rtcweb_datachannel_open_request {
uint8_t msg_type; /* DATA_CHANNEL_OPEN_REQUEST */
uint8_t channel_type;
@@ -127,6 +132,9 @@ struct rtcweb_datachannel_open_request {
int16_t priority;
char label[];
} SCTP_PACKED;
+#if defined(_WIN32) && !defined(__MINGW32__)
+#pragma warning( pop )
+#endif /* defined(_WIN32) && !defined(__MINGW32__) */
struct rtcweb_datachannel_open_response {
uint8_t msg_type; /* DATA_CHANNEL_OPEN_RESPONSE */
@@ -1123,7 +1131,7 @@ handle_send_failed_event(struct sctp_send_failed_event *ssfe)
}
static void
-handle_notification(struct peer_connection *pc, union sctp_notification *notif, size_t n)
+handle_notification_rtcweb(struct peer_connection *pc, union sctp_notification *notif, size_t n)
{
if (notif->sn_header.sn_length != (uint32_t)n) {
return;
@@ -1268,7 +1276,7 @@ print_status(struct peer_connection *pc)
printf("unreliable (max. %u rtx).\n", channel->pr_value);
break;
default:
- printf("unkown policy %u.\n", channel->pr_policy);
+ printf("unknown policy %u.\n", channel->pr_policy);
break;
}
}
@@ -1285,7 +1293,7 @@ receive_cb(struct socket *sock, union sctp_sockstore addr, void *data,
if (data) {
lock_peer_connection(pc);
if (flags & MSG_NOTIFICATION) {
- handle_notification(pc, (union sctp_notification *)data, datalen);
+ handle_notification_rtcweb(pc, (union sctp_notification *)data, datalen);
} else {
handle_message(pc, data, datalen, ntohl(rcv.rcv_ppid), rcv.rcv_sid);
}
@@ -1294,16 +1302,6 @@ receive_cb(struct socket *sock, union sctp_sockstore addr, void *data,
return (1);
}
-void
-debug_printf(const char *format, ...)
-{
- va_list ap;
-
- va_start(ap, format);
- vprintf(format, ap);
- va_end(ap);
-}
-
int
main(int argc, char *argv[])
{
@@ -1330,14 +1328,15 @@ main(int argc, char *argv[])
char addrbuf[INET_ADDRSTRLEN];
if (argc > 1) {
- usrsctp_init(atoi(argv[1]), NULL, debug_printf);
+ usrsctp_init(atoi(argv[1]), NULL, debug_printf_stack);
} else {
- usrsctp_init(9899, NULL, debug_printf);
+ usrsctp_init(9899, NULL, debug_printf_stack);
}
#ifdef SCTP_DEBUG
usrsctp_sysctl_set_sctp_debug_on(SCTP_DEBUG_NONE);
#endif
usrsctp_sysctl_set_sctp_blackhole(2);
+ usrsctp_sysctl_set_sctp_no_csum_on_loopback(0);
if ((sock = usrsctp_socket(AF_INET, SOCK_STREAM, IPPROTO_SCTP, receive_cb, NULL, 0, &peer_connection)) == NULL) {
perror("socket");
@@ -1434,7 +1433,7 @@ main(int argc, char *argv[])
unlock_peer_connection(&peer_connection);
for (;;) {
-#ifdef _WIN32
+#if defined(_WIN32) && !defined(__MINGW32__)
if (gets_s(line, LINE_LENGTH) == NULL) {
#else
if (fgets(line, LINE_LENGTH, stdin) == NULL) {
diff --git a/chromium/third_party/usrsctp/usrsctplib/programs/st_client.c b/chromium/third_party/usrsctp/usrsctplib/programs/st_client.c
new file mode 100644
index 00000000000..da5c53bca2d
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/programs/st_client.c
@@ -0,0 +1,379 @@
+/*
+ * Copyright (C) 2011-2013 Michael Tuexen
+ * Copyright (C) 2011-2015 Colin Caughie
+ * Copyright (C) 2011-2019 Felix Weinrank
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * Usage: st_client local_addr local_port remote_addr remote_port remote_sctp_port
+ */
+
+#ifdef _WIN32
+#define _CRT_SECURE_NO_WARNINGS
+#endif
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+#include <sys/types.h>
+#ifndef _WIN32
+#include <sys/socket.h>
+#include <sys/time.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <errno.h>
+#include <pthread.h>
+#include <unistd.h>
+#else
+#include <winsock2.h>
+#include <ws2tcpip.h>
+#endif
+#include <usrsctp.h>
+#include "programs_helper.h"
+
+#define MAX_PACKET_SIZE (1<<16)
+#define BUFFER_SIZE 80
+#define DISCARD_PPID 39
+#define HTTP_PPID 63
+
+#define TIMER_INTERVAL_MSECS 10
+
+static int connecting = 0;
+static int finish = 0;
+
+static unsigned int
+get_tick_count(void)
+{
+#ifdef _WIN32
+ return GetTickCount();
+#else
+ struct timeval tv;
+ unsigned int milliseconds;
+
+ gettimeofday(&tv, NULL); /* get current time */
+ milliseconds = tv.tv_sec*1000LL + tv.tv_usec/1000; /* calculate milliseconds */
+ return (milliseconds);
+#endif
+}
+
+static void
+handle_events(int sock, struct socket* s, void* sconn_addr)
+{
+ char *dump_buf;
+ ssize_t length;
+ char buf[MAX_PACKET_SIZE];
+
+ fd_set rfds;
+ struct timeval tv;
+
+ unsigned next_fire_time = get_tick_count();
+ unsigned last_fire_time = next_fire_time;
+ unsigned now = get_tick_count();
+ int wait_time;
+
+ while (!finish) {
+ if ((int) (now - next_fire_time) > 0) {
+ usrsctp_handle_timers(now - last_fire_time);
+ last_fire_time = now;
+ next_fire_time = now + TIMER_INTERVAL_MSECS;
+ }
+
+ wait_time = next_fire_time - now;
+ tv.tv_sec = wait_time / 1000;
+ tv.tv_usec = (wait_time % 1000) * 1000;
+
+ FD_ZERO(&rfds);
+ FD_SET(sock, &rfds);
+
+ select(sock + 1, &rfds, NULL, NULL, &tv);
+
+ if (FD_ISSET(sock, &rfds)) {
+ length = recv(sock, buf, MAX_PACKET_SIZE, 0);
+
+ if (length > 0) {
+ if ((dump_buf = usrsctp_dumppacket(buf, (size_t)length, SCTP_DUMP_INBOUND)) != NULL) {
+ fprintf(stderr, "%s", dump_buf);
+ usrsctp_freedumpbuffer(dump_buf);
+ }
+ usrsctp_conninput(sconn_addr, buf, (size_t)length, 0);
+ }
+ }
+ }
+}
+
+static void
+on_connect(struct socket* s)
+{
+ struct sctp_sndinfo sndinfo;
+ char buffer[BUFFER_SIZE];
+ int bufferlen;
+
+ /* memset(buffer, 'A', BUFFER_SIZE); */
+ /* bufferlen = BUFFER_SIZE; */
+ bufferlen = snprintf(buffer, BUFFER_SIZE, "GET / HTTP/1.0\r\nUser-agent: libusrsctp\r\nConnection: close\r\n\r\n");
+ sndinfo.snd_sid = 0;
+ sndinfo.snd_flags = 0;
+ sndinfo.snd_ppid = htonl(DISCARD_PPID);
+ sndinfo.snd_context = 0;
+ sndinfo.snd_assoc_id = 0;
+ if (usrsctp_sendv(s, buffer, bufferlen, NULL, 0, (void *)&sndinfo,
+ (socklen_t)sizeof(struct sctp_sndinfo), SCTP_SENDV_SNDINFO, 0) < 0) {
+ perror("usrsctp_sendv");
+ }
+}
+
+static void
+on_socket_readable(struct socket* s) {
+ char buffer[BUFFER_SIZE];
+ union sctp_sockstore addr;
+ socklen_t fromlen = sizeof(addr);
+ struct sctp_rcvinfo rcv_info;
+ socklen_t infolen = sizeof(rcv_info);
+ unsigned int infotype = 0;
+ int flags = 0;
+ ssize_t retval;
+
+ /* Keep reading until there is no more data */
+ for (;;) {
+ retval = usrsctp_recvv(s, buffer, sizeof(buffer), (struct sockaddr*) &addr,
+ &fromlen, &rcv_info, &infolen, &infotype, &flags);
+
+ if (retval < 0) {
+ if (errno != EWOULDBLOCK) {
+ perror("usrsctp_recvv");
+ finish = 1;
+ }
+ return;
+ } else if (retval == 0) {
+ printf("socket was disconnected\n");
+ finish = 1;
+ return;
+ }
+
+ if (flags & MSG_NOTIFICATION) {
+ printf("Notification of length %d received.\n", (int)retval);
+ } else {
+ printf("Msg of length %d received via %p:%u on stream %d with SSN %u and TSN %u, PPID %d, context %u.\n",
+ (int)retval,
+ addr.sconn.sconn_addr,
+ ntohs(addr.sconn.sconn_port),
+ rcv_info.rcv_sid,
+ rcv_info.rcv_ssn,
+ rcv_info.rcv_tsn,
+ ntohl(rcv_info.rcv_ppid),
+ rcv_info.rcv_context);
+ }
+ }
+}
+
+static void
+handle_upcall(struct socket *s, void *arg, int flags)
+{
+ int events = usrsctp_get_events(s);
+
+ if (connecting) {
+ if (events & SCTP_EVENT_ERROR) {
+ connecting = 0;
+ finish = 1;
+ } else if (events & SCTP_EVENT_WRITE) {
+ connecting = 0;
+ on_connect(s);
+ }
+
+ return;
+ }
+
+ if (events & SCTP_EVENT_READ) {
+ on_socket_readable(s);
+ }
+}
+
+static int
+conn_output(void *addr, void *buf, size_t length, uint8_t tos, uint8_t set_df)
+{
+ char *dump_buf;
+#ifdef _WIN32
+ SOCKET *fdp;
+#else
+ int *fdp;
+#endif
+
+#ifdef _WIN32
+ fdp = (SOCKET *)addr;
+#else
+ fdp = (int *)addr;
+#endif
+ if ((dump_buf = usrsctp_dumppacket(buf, length, SCTP_DUMP_OUTBOUND)) != NULL) {
+ fprintf(stderr, "%s", dump_buf);
+ usrsctp_freedumpbuffer(dump_buf);
+ }
+#ifdef _WIN32
+ if (send(*fdp, buf, (int)length, 0) == SOCKET_ERROR) {
+ return (WSAGetLastError());
+#else
+ if (send(*fdp, buf, length, 0) < 0) {
+ return (errno);
+#endif
+ } else {
+ return (0);
+ }
+}
+
+/* Usage: st_client local_addr local_port remote_addr remote_port remote_sctp_port */
+int
+main(int argc, char *argv[])
+{
+ struct sockaddr_in sin;
+ struct sockaddr_conn sconn;
+#ifdef _WIN32
+ SOCKET fd;
+#else
+ int fd;
+#endif
+ struct socket *s;
+ int retval;
+#ifdef _WIN32
+ WSADATA wsaData;
+#endif
+ const int on = 1;
+
+ if (argc < 6) {
+ printf("Usage: st_client local_addr local_port remote_addr remote_port remote_sctp_port\n");
+ return (-1);
+ }
+
+#ifdef _WIN32
+ if (WSAStartup(MAKEWORD(2,2), &wsaData) != 0) {
+ printf("WSAStartup failed\n");
+ return (-1);
+ }
+#endif
+ usrsctp_init_nothreads(0, conn_output, debug_printf_stack);
+ /* set up a connected UDP socket */
+#ifdef _WIN32
+ if ((fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == INVALID_SOCKET) {
+ printf("socket() failed with error: %ld\n", WSAGetLastError());
+ return (-1);
+ }
+#else
+ if ((fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
+ perror("socket");
+ return (-1);
+ }
+#endif
+ memset(&sin, 0, sizeof(struct sockaddr_in));
+ sin.sin_family = AF_INET;
+#ifdef HAVE_SIN_LEN
+ sin.sin_len = sizeof(struct sockaddr_in);
+#endif
+ sin.sin_port = htons(atoi(argv[2]));
+ if (!inet_pton(AF_INET, argv[1], &sin.sin_addr.s_addr)){
+ printf("error: invalid address\n");
+ return (-1);
+ }
+#ifdef _WIN32
+ if (bind(fd, (struct sockaddr *)&sin, sizeof(struct sockaddr_in)) == SOCKET_ERROR) {
+ printf("bind() failed with error: %ld\n", WSAGetLastError());
+ return (-1);
+ }
+#else
+ if (bind(fd, (struct sockaddr *)&sin, sizeof(struct sockaddr_in)) < 0) {
+ perror("bind");
+ return (-1);
+ }
+#endif
+ memset(&sin, 0, sizeof(struct sockaddr_in));
+ sin.sin_family = AF_INET;
+#ifdef HAVE_SIN_LEN
+ sin.sin_len = sizeof(struct sockaddr_in);
+#endif
+ sin.sin_port = htons(atoi(argv[4]));
+ if (!inet_pton(AF_INET, argv[3], &sin.sin_addr.s_addr)){
+ printf("error: invalid address\n");
+ return (-1);
+ }
+#ifdef _WIN32
+ if (connect(fd, (struct sockaddr *)&sin, sizeof(struct sockaddr_in)) == SOCKET_ERROR) {
+ printf("connect() failed with error: %ld\n", WSAGetLastError());
+ return (-1);
+ }
+#else
+ if (connect(fd, (struct sockaddr *)&sin, sizeof(struct sockaddr_in)) < 0) {
+ perror("connect");
+ return (-1);
+ }
+#endif
+#ifdef SCTP_DEBUG
+ usrsctp_sysctl_set_sctp_debug_on(SCTP_DEBUG_NONE);
+#endif
+ usrsctp_sysctl_set_sctp_ecn_enable(0);
+ usrsctp_register_address((void *)&fd);
+
+ if ((s = usrsctp_socket(AF_CONN, SOCK_STREAM, IPPROTO_SCTP, NULL, NULL, 0, NULL)) == NULL) {
+ perror("usrsctp_socket");
+ return (-1);
+ }
+
+ usrsctp_setsockopt(s, IPPROTO_SCTP, SCTP_RECVRCVINFO, &on, sizeof(int));
+ usrsctp_set_non_blocking(s, 1);
+ usrsctp_set_upcall(s, handle_upcall, NULL);
+
+ memset(&sconn, 0, sizeof(struct sockaddr_conn));
+ sconn.sconn_family = AF_CONN;
+#ifdef HAVE_SCONN_LEN
+ sconn.sconn_len = sizeof(struct sockaddr_conn);
+#endif
+ sconn.sconn_port = htons(0);
+ sconn.sconn_addr = NULL;
+ if (usrsctp_bind(s, (struct sockaddr *)&sconn, sizeof(struct sockaddr_conn)) < 0) {
+ perror("usrsctp_bind");
+ return (-1);
+ }
+
+ memset(&sconn, 0, sizeof(struct sockaddr_conn));
+ sconn.sconn_family = AF_CONN;
+#ifdef HAVE_SCONN_LEN
+ sconn.sconn_len = sizeof(struct sockaddr_conn);
+#endif
+ sconn.sconn_port = htons(atoi(argv[5]));
+ sconn.sconn_addr = &fd;
+
+ retval = usrsctp_connect(s, (struct sockaddr *)&sconn, sizeof(struct sockaddr_conn));
+
+ if (retval < 0 && errno != EWOULDBLOCK && errno != EINPROGRESS) {
+ perror("usrsctp_connect");
+ return (-1);
+ }
+
+ connecting = 1;
+
+ handle_events(fd, s, sconn.sconn_addr);
+
+ return (0);
+}
diff --git a/chromium/third_party/usrsctp/usrsctplib/programs/tsctp.c b/chromium/third_party/usrsctp/usrsctplib/programs/tsctp.c
index c85da22b188..c2fa4aedd31 100644
--- a/chromium/third_party/usrsctp/usrsctplib/programs/tsctp.c
+++ b/chromium/third_party/usrsctp/usrsctplib/programs/tsctp.c
@@ -54,6 +54,7 @@
#include <getopt.h>
#endif
#include <usrsctp.h>
+#include "programs_helper.h"
/* global for the send callback, but used in kernel version as well */
static unsigned long number_of_messages;
@@ -66,21 +67,21 @@ struct socket *psock = NULL;
static struct timeval start_time;
unsigned int runtime = 0;
-static unsigned long messages = 0;
-static unsigned long long first_length = 0;
-static unsigned long long sum = 0;
+static unsigned long cb_messages = 0;
+static unsigned long long cb_first_length = 0;
+static unsigned long long cb_sum = 0;
static unsigned int use_cb = 0;
-#ifndef timersub
-#define timersub(tvp, uvp, vvp) \
- do { \
- (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \
- (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \
- if ((vvp)->tv_usec < 0) { \
- (vvp)->tv_sec--; \
- (vvp)->tv_usec += 1000000; \
- } \
- } while (0)
+#ifdef _WIN32
+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;
+}
#endif
@@ -91,7 +92,7 @@ char Usage[] =
" -c use callback API\n"
" -E local UDP encapsulation port (default 9899)\n"
" -f fragmentation point\n"
-" -l size of send/receive buffer\n"
+" -l message length\n"
" -L bind to local IP (default INADDR_ANY)\n"
" -n number of messages sent (0 means infinite)/received\n"
" -D turns Nagle off\n"
@@ -110,7 +111,7 @@ char Usage[] =
#define BUFFERSIZE (1<<16)
static int verbose, very_verbose;
-static unsigned int done;
+static unsigned int done;
void stop_sender(int sig)
{
@@ -118,18 +119,6 @@ void stop_sender(int sig)
}
#ifdef _WIN32
-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;
-}
-#endif
-
-#ifdef _WIN32
static DWORD WINAPI
#else
static void *
@@ -138,9 +127,8 @@ handle_connection(void *arg)
{
ssize_t n;
char *buf;
-#ifdef _WIN32
- HANDLE tid;
-#else
+
+#if !defined(_WIN32)
pthread_t tid;
#endif
struct socket *conn_sock;
@@ -157,11 +145,13 @@ handle_connection(void *arg)
unsigned int infotype;
struct sctp_recvv_rn rn;
socklen_t infolen = sizeof(struct sctp_recvv_rn);
+ unsigned long messages = 0;
+ unsigned long long first_length = 0;
+ unsigned long long sum = 0;
conn_sock = *(struct socket **)arg;
-#ifdef _WIN32
- tid = GetCurrentThread();
-#else
+
+#if !defined(_WIN32)
tid = pthread_self();
pthread_detach(tid);
#endif
@@ -182,8 +172,7 @@ handle_connection(void *arg)
gettimeofday(&note_time, NULL);
printf("notification arrived at %f\n", note_time.tv_sec+(double)note_time.tv_usec/1000000.0);
snp = (union sctp_notification *)buf;
- 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;
printf("SCTP_PEER_ADDR_CHANGE: state=%d, error=%d\n",spc->spc_state, spc->spc_error);
}
@@ -194,8 +183,9 @@ handle_connection(void *arg)
sum += n;
if (flags & MSG_EOR) {
messages++;
- if (first_length == 0)
+ if (first_length == 0) {
first_length = sum;
+ }
}
}
flags = 0;
@@ -206,13 +196,14 @@ handle_connection(void *arg)
n = usrsctp_recvv(conn_sock, (void *) buf, BUFFERSIZE, (struct sockaddr *) &addr, &len, (void *)&rn,
&infolen, &infotype, &flags);
}
- if (n < 0)
+ if (n < 0) {
perror("sctp_recvv");
+ }
gettimeofday(&time_now, NULL);
timersub(&time_now, &time_start, &time_diff);
seconds = time_diff.tv_sec + (double)time_diff.tv_usec/1000000.0;
- printf("%llu, %lu, %lu, %lu, %llu, %f, %f\n",
- first_length, messages, recv_calls, notifications, sum, seconds, (double)first_length * (double)messages / seconds);
+ printf("%llu, %lu, %lu, %llu, %f, %f, %lu\n",
+ first_length, messages, recv_calls, sum, seconds, (double)first_length * (double)messages / seconds, notifications);
fflush(stdout);
usrsctp_close(conn_sock);
free(buf);
@@ -227,7 +218,7 @@ static int
send_cb(struct socket *sock, uint32_t sb_free) {
struct sctp_sndinfo sndinfo;
- if ((messages == 0) & verbose) {
+ if ((cb_messages == 0) & verbose) {
printf("Start sending ");
if (number_of_messages > 0) {
printf("%ld messages ", (long)number_of_messages);
@@ -248,9 +239,9 @@ send_cb(struct socket *sock, uint32_t sb_free) {
sndinfo.snd_context = 0;
sndinfo.snd_assoc_id = 0;
- while (!done && ((number_of_messages == 0) || (messages < (number_of_messages - 1)))) {
+ while (!done && ((number_of_messages == 0) || (cb_messages < (number_of_messages - 1)))) {
if (very_verbose) {
- printf("Sending message number %lu.\n", messages + 1);
+ printf("Sending message number %lu.\n", cb_messages + 1);
}
if (usrsctp_sendv(psock, buffer, length,
@@ -262,17 +253,18 @@ send_cb(struct socket *sock, uint32_t sb_free) {
exit(1);
} else {
if (very_verbose){
- printf("EWOULDBLOCK or EAGAIN for message number %lu - will retry\n", messages + 1);
+ printf("EWOULDBLOCK or EAGAIN for message number %lu - will retry\n", cb_messages + 1);
}
/* send until EWOULDBLOCK then exit callback. */
return (1);
}
}
- messages++;
+ cb_messages++;
}
- if ((done == 1) || (messages == (number_of_messages - 1))) {
- if (very_verbose)
- printf("Sending final message number %lu.\n", messages + 1);
+ if ((done == 1) || (cb_messages == (number_of_messages - 1))) {
+ if (very_verbose) {
+ printf("Sending final message number %lu.\n", cb_messages + 1);
+ }
sndinfo.snd_flags |= SCTP_EOF;
if (usrsctp_sendv(psock, buffer, length, (struct sockaddr *) &remote_addr, 1,
@@ -283,13 +275,13 @@ send_cb(struct socket *sock, uint32_t sb_free) {
exit(1);
} else {
if (very_verbose){
- printf("EWOULDBLOCK or EAGAIN for final message number %lu - will retry\n", messages + 1);
+ printf("EWOULDBLOCK or EAGAIN for final message number %lu - will retry\n", cb_messages + 1);
}
/* send until EWOULDBLOCK then exit callback. */
return (1);
}
}
- messages++;
+ cb_messages++;
done = 2;
}
@@ -306,21 +298,21 @@ server_receive_cb(struct socket *sock, union sctp_sockstore addr, void *data,
if (data == NULL) {
gettimeofday(&now, NULL);
timersub(&now, &start_time, &diff_time);
- seconds = diff_time.tv_sec + (double)diff_time.tv_usec/1000000.0;
+ seconds = diff_time.tv_sec + (double)diff_time.tv_usec / 1000000.0;
printf("%llu, %lu, %llu, %f, %f\n",
- first_length, messages, sum, seconds, (double)first_length * (double)messages / seconds);
+ cb_first_length, cb_messages, cb_sum, seconds, (double)cb_first_length * (double)cb_messages / seconds);
usrsctp_close(sock);
- first_length = 0;
- sum = 0;
- messages = 0;
+ cb_first_length = 0;
+ cb_sum = 0;
+ cb_messages = 0;
return (1);
}
- if (first_length == 0) {
- first_length = (unsigned int)datalen;
+ if (cb_first_length == 0) {
+ cb_first_length = (unsigned int)datalen;
gettimeofday(&start_time, NULL);
}
- sum += datalen;
- messages++;
+ cb_sum += datalen;
+ cb_messages++;
free(data);
return (1);
@@ -334,16 +326,6 @@ client_receive_cb(struct socket *sock, union sctp_sockstore addr, void *data,
return (1);
}
-void
-debug_printf(const char *format, ...)
-{
- va_list ap;
-
- va_start(ap, format);
- vprintf(format, ap);
- va_end(ap);
-}
-
int main(int argc, char **argv)
{
#ifndef _WIN32
@@ -362,9 +344,9 @@ int main(int argc, char **argv)
struct sctp_assoc_value av;
struct sctp_udpencaps encaps;
struct sctp_sndinfo sndinfo;
+ unsigned long messages = 0;
#ifdef _WIN32
unsigned long srcAddr;
- HANDLE tid;
#else
in_addr_t srcAddr;
pthread_t tid;
@@ -582,11 +564,12 @@ int main(int argc, char **argv)
local_addr.sin_port = htons(local_port);
local_addr.sin_addr.s_addr = srcAddr;
- usrsctp_init(local_udp_port, NULL, debug_printf);
+ usrsctp_init(local_udp_port, NULL, debug_printf_stack);
#ifdef SCTP_DEBUG
usrsctp_sysctl_set_sctp_debug_on(SCTP_DEBUG_ALL);
#endif
usrsctp_sysctl_set_sctp_blackhole(2);
+ usrsctp_sysctl_set_sctp_no_csum_on_loopback(0);
usrsctp_sysctl_set_sctp_enable_sack_immediately(1);
if (client) {
@@ -650,32 +633,32 @@ int main(int argc, char **argv)
if (use_cb) {
struct socket *conn_sock;
- if ((conn_sock = usrsctp_accept(psock, (struct sockaddr *) &remote_addr, &addr_len))== NULL) {
+ if ((conn_sock = usrsctp_accept(psock, (struct sockaddr *) &remote_addr, &addr_len)) == NULL) {
perror("usrsctp_accept");
continue;
}
} else {
struct socket **conn_sock;
- conn_sock = (struct socket **)malloc(sizeof(struct socket *));
- if ((*conn_sock = usrsctp_accept(psock, (struct sockaddr *) &remote_addr, &addr_len))== NULL) {
+ conn_sock = (struct socket **) malloc(sizeof(struct socket *));
+ if ((*conn_sock = usrsctp_accept(psock, (struct sockaddr *) &remote_addr, &addr_len)) == NULL) {
perror("usrsctp_accept");
continue;
}
#ifdef _WIN32
- tid = CreateThread(NULL, 0, &handle_connection, (void *)conn_sock, 0, NULL);
+ CreateThread(NULL, 0, &handle_connection, (void *)conn_sock, 0, NULL);
#else
pthread_create(&tid, NULL, &handle_connection, (void *)conn_sock);
#endif
}
if (verbose) {
- // const char *inet_ntop(int af, const void *src, char *dst, socklen_t size)
- //inet_ntoa(remote_addr.sin_addr)
+ /* const char *inet_ntop(int af, const void *src, char *dst, socklen_t size)
+ inet_ntoa(remote_addr.sin_addr) */
char addrbuf[INET_ADDRSTRLEN];
printf("Connection accepted from %s:%d\n", inet_ntop(AF_INET, &(remote_addr.sin_addr), addrbuf, INET_ADDRSTRLEN), ntohs(remote_addr.sin_port));
}
}
- //usrsctp_close(psock); // unreachable
+ /* usrsctp_close(psock); unreachable */
} else {
memset(&encaps, 0, sizeof(struct sctp_udpencaps));
encaps.sue_address.ss_family = AF_INET;
@@ -747,7 +730,7 @@ int main(int argc, char **argv)
}
if (use_cb) {
- while (done < 2 && (messages < (number_of_messages - 1))) {
+ while (done < 2 && (cb_messages < (number_of_messages - 1))) {
#ifdef _WIN32
Sleep(1000);
#else
diff --git a/chromium/third_party/usrsctp/usrsctplib/programs/tsctp_upcall.c b/chromium/third_party/usrsctp/usrsctplib/programs/tsctp_upcall.c
new file mode 100644
index 00000000000..fab56891d02
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/programs/tsctp_upcall.c
@@ -0,0 +1,760 @@
+/*
+ * Copyright (C) 2005-2013 Michael Tuexen
+ * Copyright (C) 2011-2013 Irene Ruengeler
+ * Copyright (C) 2014-2019 Felix Weinrank
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+#ifdef _WIN32
+#include <winsock2.h>
+#include <ws2tcpip.h>
+#include <stdlib.h>
+#include <crtdbg.h>
+#include <sys/timeb.h>
+#else
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <sys/time.h>
+#include <unistd.h>
+#include <pthread.h>
+#endif
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <signal.h>
+#include <errno.h>
+#include <inttypes.h>
+#ifdef LINUX
+#include <getopt.h>
+#endif
+#include <usrsctp.h>
+#include "programs_helper.h"
+
+#define TSCTP_CLIENT 1
+#define TSCTP_SERVER 2
+
+#define DEFAULT_LENGTH 1024
+#define DEFAULT_NUMBER_OF_MESSAGES 1024
+#define DEFAULT_PORT 5001
+#define BUFFERSIZE (1<<16)
+
+static int par_verbose = 0;
+static int par_very_verbose = 0;
+static unsigned int done = 0;
+
+struct tsctp_meta {
+ uint8_t par_role;
+ uint8_t par_stats_human;
+ uint8_t par_ordered;
+ uint64_t par_messages;
+ uint64_t par_message_length;
+ uint64_t par_runtime;
+
+ uint64_t stat_messages;
+ uint64_t stat_message_length;
+ uint64_t stat_notifications;
+ uint64_t stat_recv_calls;
+ struct timeval stat_start;
+
+ uint64_t stat_fragment_sum;
+
+ char *buffer;
+};
+
+#ifndef timersub
+#define timersub(tvp, uvp, vvp) \
+ do { \
+ (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \
+ (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \
+ if ((vvp)->tv_usec < 0) { \
+ (vvp)->tv_sec--; \
+ (vvp)->tv_usec += 1000000; \
+ } \
+ } while (0)
+#endif
+
+#ifdef _WIN32
+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;
+}
+#endif
+
+
+char Usage[] =
+"Usage: tsctp [options] [address]\n"
+"Options:\n"
+" -a set adaptation layer indication\n"
+" -E local UDP encapsulation port (default 9899)\n"
+" -f fragmentation point\n"
+" -H human readable statistics"
+" -l message length\n"
+" -L bind to local IP (default INADDR_ANY)\n"
+" -n number of messages sent (0 means infinite)/received\n"
+" -D turns Nagle off\n"
+" -R socket recv buffer\n"
+" -S socket send buffer\n"
+" -T time to send messages\n"
+" -u use unordered user messages\n"
+" -U remote UDP encapsulation port\n"
+" -v verbose\n"
+" -V very verbose\n"
+;
+
+static void handle_upcall(struct socket *upcall_socket, void *upcall_data, int upcall_flags);
+
+static const char *bytes2human(uint64_t bytes)
+{
+ char *suffix[] = {"", "K", "M", "G", "T"};
+ char suffix_length = sizeof(suffix) / sizeof(suffix[0]);
+ int i = 0;
+ double human_size = bytes;
+ static char output[200];
+
+ if (bytes > 1024) {
+ for (i = 0; (bytes / 1024) > 0 && i < suffix_length - 1; i++) {
+ human_size = bytes / 1024.0;
+ bytes /= 1024;
+ }
+ }
+
+ snprintf(output, sizeof(output), "%.02lf %s", human_size, suffix[i]);
+ return output;
+}
+
+
+static void
+handle_accept(struct socket *upcall_socket, void *upcall_data, int upcall_flags)
+{
+ struct socket *conn_sock;
+ struct sockaddr_in remote_addr;
+ socklen_t addr_len = sizeof(struct sockaddr_in);
+ struct tsctp_meta *meta_listening, *meta_accepted;
+ char addrbuf[INET_ADDRSTRLEN];
+
+ meta_listening = (struct tsctp_meta *) upcall_data;
+
+ memset(&remote_addr, 0, sizeof(struct sockaddr_in));
+ if (((conn_sock = usrsctp_accept(upcall_socket, (struct sockaddr *) &remote_addr, &addr_len)) == NULL) && (errno != EINPROGRESS)) {
+ perror("usrsctp_accept");
+ exit(EXIT_FAILURE);
+ }
+
+ if (par_verbose) {
+ printf("Connection accepted from %s:%d\n", inet_ntop(AF_INET, &(remote_addr.sin_addr), addrbuf, INET_ADDRSTRLEN), ntohs(remote_addr.sin_port));
+ }
+
+ meta_accepted = malloc(sizeof(struct tsctp_meta));
+ if (!meta_accepted) {
+ printf("malloc() failed!\n");
+ exit(EXIT_FAILURE);
+ }
+
+ memset(meta_accepted, 0, sizeof(struct tsctp_meta));
+
+ 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);
+ }
+
+ usrsctp_set_upcall(conn_sock, handle_upcall, meta_accepted);
+}
+
+static void
+handle_upcall(struct socket *upcall_socket, void *upcall_data, int upcall_flags)
+{
+ int events = usrsctp_get_events(upcall_socket);
+ struct tsctp_meta* tsctp_meta = (struct tsctp_meta*) upcall_data;
+
+ struct sctp_recvv_rn rn;
+ ssize_t n;
+ struct sockaddr_storage addr;
+ int recv_flags = 0;
+ socklen_t len = (socklen_t)sizeof(struct sockaddr_storage);
+ unsigned int infotype = 0;
+ socklen_t infolen = sizeof(struct sctp_recvv_rn);
+ struct sctp_rcvinfo *rcvinfo = (struct sctp_rcvinfo *) &rn;
+ memset(&rn, 0, sizeof(struct sctp_recvv_rn));
+ struct timeval note_time;
+ union sctp_notification *snp;
+ struct sctp_paddr_change *spc;
+ struct timeval time_now;
+ struct timeval time_diff;
+ float seconds;
+ struct sctp_sndinfo snd_info;
+
+ if (events & SCTP_EVENT_READ) {
+ while ((n = usrsctp_recvv(upcall_socket, tsctp_meta->buffer, BUFFERSIZE, (struct sockaddr *) &addr, &len, (void *)&rn, &infolen, &infotype, &recv_flags)) > 0) {
+
+ if (!tsctp_meta->stat_recv_calls) {
+ gettimeofday(&tsctp_meta->stat_start, NULL);
+ }
+ tsctp_meta->stat_recv_calls++;
+
+ if (recv_flags & MSG_NOTIFICATION) {
+ tsctp_meta->stat_notifications++;
+ gettimeofday(&note_time, NULL);
+ if (par_verbose) {
+ printf("notification arrived at %f\n", note_time.tv_sec + (double)note_time.tv_usec / 1000000.0);
+
+ 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);
+ }
+ }
+ } else {
+ if (par_very_verbose) {
+ if (infotype == SCTP_RECVV_RCVINFO) {
+ printf("Message received - %zd bytes - %s - sid %u - tsn %u %s\n",
+ n,
+ (rcvinfo->rcv_flags & SCTP_UNORDERED) ? "unordered" : "ordered",
+ rcvinfo->rcv_sid,
+ rcvinfo->rcv_tsn,
+ (recv_flags & MSG_EOR) ? "- EOR" : ""
+ );
+
+ } else {
+ printf("Message received - %zd bytes %s\n", n, (recv_flags & MSG_EOR) ? "- EOR" : "");
+ }
+ }
+ tsctp_meta->stat_fragment_sum += n;
+ if (recv_flags & MSG_EOR) {
+ tsctp_meta->stat_messages++;
+ if (tsctp_meta->stat_message_length == 0) {
+ tsctp_meta->stat_message_length = tsctp_meta->stat_fragment_sum;
+ }
+ }
+ }
+ }
+
+ if (n < 0 && errno != EAGAIN && errno != EWOULDBLOCK) {
+ perror("usrsctp_recvv");
+ exit(EXIT_FAILURE);
+ }
+
+ if (n == 0) {
+ done = 1;
+
+ gettimeofday(&time_now, NULL);
+ timersub(&time_now, &tsctp_meta->stat_start, &time_diff);
+ seconds = time_diff.tv_sec + (double)time_diff.tv_usec / 1000000.0;
+
+ if (tsctp_meta->par_stats_human) {
+ printf("Connection closed - statistics\n");
+
+ printf("\tmessage size : %" PRIu64 "\n", tsctp_meta->stat_message_length);
+ printf("\tmessages : %" PRIu64 "\n", tsctp_meta->stat_messages);
+ printf("\trecv() calls : %" PRIu64 "\n", tsctp_meta->stat_recv_calls);
+ printf("\tnotifications : %" PRIu64 "\n", tsctp_meta->stat_notifications);
+ printf("\ttransferred : %sByte\n", bytes2human(tsctp_meta->stat_message_length * tsctp_meta->stat_messages));
+ printf("\truntime : %.2f s\n", seconds);
+ printf("\tgoodput : %sBit/s\n", bytes2human((double) tsctp_meta->stat_message_length * (double) tsctp_meta->stat_messages / seconds * 8));
+
+ } else {
+ printf("%" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %f, %f, %" PRIu64 "\n",
+ tsctp_meta->stat_message_length,
+ tsctp_meta->stat_messages,
+ tsctp_meta->stat_recv_calls,
+ tsctp_meta->stat_message_length * tsctp_meta->stat_messages,
+ seconds,
+ (double) tsctp_meta->stat_message_length * (double) tsctp_meta->stat_messages / seconds,
+ tsctp_meta->stat_notifications);
+ }
+ fflush(stdout);
+ usrsctp_close(upcall_socket);
+
+ free(tsctp_meta->buffer);
+ free(tsctp_meta);
+ return;
+ }
+ }
+
+ if ((events & SCTP_EVENT_WRITE) && tsctp_meta->par_role == TSCTP_CLIENT && !done) {
+
+ memset(&snd_info, 0, sizeof(struct sctp_sndinfo));
+ if (tsctp_meta->par_ordered == 0) {
+ snd_info.snd_flags |= SCTP_UNORDERED;
+ }
+
+ while ((n = usrsctp_sendv(upcall_socket, tsctp_meta->buffer, tsctp_meta->par_message_length, NULL, 0, &snd_info, (socklen_t)sizeof(struct sctp_sndinfo), SCTP_SENDV_SNDINFO, 0)) > 0) {
+ if (tsctp_meta->stat_messages == 0) {
+ gettimeofday(&tsctp_meta->stat_start, NULL);
+ }
+ tsctp_meta->stat_messages++;
+
+ if (par_very_verbose) {
+ printf("Message #%" PRIu64 " sent\n", tsctp_meta->stat_messages);
+ }
+
+ if (tsctp_meta->par_messages && tsctp_meta->par_messages == tsctp_meta->stat_messages) {
+ break;
+ }
+ }
+
+ if (errno != EAGAIN && errno != EWOULDBLOCK) {
+ done = 1;
+ usrsctp_close(upcall_socket);
+ printf("client socket %p closed\n", (void *)upcall_socket);
+ free(tsctp_meta->buffer);
+ free(tsctp_meta);
+ return;
+ }
+
+ gettimeofday(&time_now, NULL);
+ timersub(&time_now, &tsctp_meta->stat_start, &time_diff);
+ seconds = time_diff.tv_sec + (double)time_diff.tv_usec / 1000000.0;
+
+ if ((tsctp_meta->par_messages && tsctp_meta->par_messages == tsctp_meta->stat_messages) ||
+ (tsctp_meta->par_runtime && tsctp_meta->par_runtime <= seconds)) {
+
+ if (par_verbose) {
+ printf("Runtime or max messages reached - finishing...\n");
+ }
+
+ done = 1;
+ usrsctp_close(upcall_socket);
+ free(tsctp_meta->buffer);
+ free(tsctp_meta);
+ return;
+ }
+ }
+
+ return;
+}
+
+int main(int argc, char **argv)
+{
+#ifndef _WIN32
+ int c;
+#endif
+ struct socket *psock = NULL;
+ struct sockaddr_in local_addr;
+ struct sockaddr_in remote_addr;
+ int optval;
+ uint16_t local_port;
+ uint16_t remote_port;
+ uint16_t local_udp_port;
+ uint16_t remote_udp_port;
+ int rcvbufsize = 0;
+ int sndbufsize = 0;
+ socklen_t intlen;
+ int nodelay = 0;
+ struct sctp_assoc_value av;
+ struct sctp_udpencaps encaps;
+ struct tsctp_meta *meta;
+
+ uint16_t par_port = DEFAULT_PORT;
+ uint8_t par_stats_human = 0;
+ int par_ordered = 1;
+ int par_message_length = DEFAULT_LENGTH;
+ int par_messages = DEFAULT_NUMBER_OF_MESSAGES;
+ int par_runtime = 0;
+
+#ifdef _WIN32
+ unsigned long src_addr;
+#else
+ in_addr_t src_addr;
+#endif
+ int fragpoint = 0;
+ struct sctp_setadaptation ind = {0};
+#ifdef _WIN32
+ char *opt;
+ int optind;
+#endif
+
+ remote_udp_port = 0;
+ local_udp_port = 9899;
+ src_addr = htonl(INADDR_ANY);
+
+ memset((void *) &remote_addr, 0, sizeof(struct sockaddr_in));
+ memset((void *) &local_addr, 0, sizeof(struct sockaddr_in));
+
+#ifndef _WIN32
+ while ((c = getopt(argc, argv, "a:DE:f:Hl:L:n:p:R:S:T:uU:vV")) != -1)
+ switch(c) {
+ case 'a':
+ ind.ssb_adaptation_ind = atoi(optarg);
+ break;
+ case 'D':
+ nodelay = 1;
+ break;
+ case 'E':
+ local_udp_port = atoi(optarg);
+ break;
+ case 'f':
+ fragpoint = atoi(optarg);
+ break;
+ case 'H':
+ par_stats_human = 1;
+ break;
+ case 'l':
+ par_message_length = atoi(optarg);
+ break;
+ case 'L':
+ if (inet_pton(AF_INET, optarg, &src_addr) != 1) {
+ printf("Can't parse %s\n", optarg);
+ exit(EXIT_FAILURE);
+ }
+ break;
+ case 'n':
+ par_messages = atoi(optarg);
+ break;
+ case 'p':
+ par_port = atoi(optarg);
+ break;
+ case 'R':
+ rcvbufsize = atoi(optarg);
+ break;
+ case 'S':
+ sndbufsize = atoi(optarg);
+ break;
+ case 'T':
+ par_runtime = atoi(optarg);
+ par_messages = 0;
+ break;
+ case 'u':
+ par_ordered = 0;
+ break;
+ case 'U':
+ remote_udp_port = atoi(optarg);
+ break;
+ case 'v':
+ par_verbose = 1;
+ break;
+ case 'V':
+ par_verbose = 1;
+ par_very_verbose = 1;
+ break;
+ default:
+ fprintf(stderr, "%s", Usage);
+ exit(1);
+ }
+#else
+ for (optind = 1; optind < argc; optind++) {
+ if (argv[optind][0] == '-') {
+ switch (argv[optind][1]) {
+ case 'a':
+ if (++optind >= argc) {
+ printf("%s", Usage);
+ exit(1);
+ }
+ opt = argv[optind];
+ ind.ssb_adaptation_ind = atoi(opt);
+ break;
+ case 'D':
+ nodelay = 1;
+ break;
+ case 'E':
+ if (++optind >= argc) {
+ printf("%s", Usage);
+ exit(1);
+ }
+ opt = argv[optind];
+ local_udp_port = atoi(opt);
+ break;
+ case 'f':
+ if (++optind >= argc) {
+ printf("%s", Usage);
+ exit(1);
+ }
+ opt = argv[optind];
+ fragpoint = atoi(opt);
+ break;
+ case 'H':
+ par_stats_human = 1;
+ break;
+ case 'l':
+ if (++optind >= argc) {
+ printf("%s", Usage);
+ exit(1);
+ }
+ opt = argv[optind];
+ par_message_length = atoi(opt);
+ break;
+ case 'L':
+ if (++optind >= argc) {
+ printf("%s", Usage);
+ exit(1);
+ }
+ opt = argv[optind];
+ inet_pton(AF_INET, opt, &src_addr);
+ break;
+ case 'n':
+ if (++optind >= argc) {
+ printf("%s", Usage);
+ exit(1);
+ }
+ opt = argv[optind];
+ par_messages = atoi(opt);
+ break;
+ case 'p':
+ if (++optind >= argc) {
+ printf("%s", Usage);
+ exit(1);
+ }
+ opt = argv[optind];
+ par_port = atoi(opt);
+ break;
+ case 'R':
+ if (++optind >= argc) {
+ printf("%s", Usage);
+ exit(1);
+ }
+ opt = argv[optind];
+ rcvbufsize = atoi(opt);
+ break;
+ case 'S':
+ if (++optind >= argc) {
+ printf("%s", Usage);
+ exit(1);
+ }
+ opt = argv[optind];
+ sndbufsize = atoi(opt);
+ break;
+ case 'T':
+ if (++optind >= argc) {
+ printf("%s", Usage);
+ exit(1);
+ }
+ opt = argv[optind];
+ par_runtime = atoi(opt);
+ par_messages = 0;
+ break;
+ case 'u':
+ par_ordered = 0;
+ break;
+ case 'U':
+ if (++optind >= argc) {
+ printf("%s", Usage);
+ exit(1);
+ }
+ opt = argv[optind];
+ remote_udp_port = atoi(opt);
+ break;
+ case 'v':
+ par_verbose = 1;
+ break;
+ case 'V':
+ par_verbose = 1;
+ par_very_verbose = 1;
+ break;
+ default:
+ printf("%s", Usage);
+ exit(1);
+ }
+ } else {
+ break;
+ }
+ }
+#endif
+
+ meta = malloc(sizeof(struct tsctp_meta));
+ if (!meta) {
+ printf("malloc() failed!\n");
+ exit(EXIT_FAILURE);
+ }
+
+ memset(meta, 0, sizeof(struct tsctp_meta));
+
+ meta->buffer = malloc(BUFFERSIZE);
+ if (!meta->buffer) {
+ printf("malloc() failed!\n");
+ exit(EXIT_FAILURE);
+ }
+
+ meta->par_stats_human = par_stats_human;
+ meta->par_message_length = par_message_length;
+ meta->par_messages = par_messages;
+ meta->par_ordered = par_ordered;
+ meta->par_runtime = par_runtime;
+
+ if (optind == argc) {
+ meta->par_role = TSCTP_SERVER;
+ local_port = par_port;
+ remote_port = 0;
+ } else {
+ meta->par_role = TSCTP_CLIENT;
+ local_port = 0;
+ remote_port = par_port;
+ }
+ local_addr.sin_family = AF_INET;
+#ifdef HAVE_SIN_LEN
+ local_addr.sin_len = sizeof(struct sockaddr_in);
+#endif
+ local_addr.sin_port = htons(local_port);
+ local_addr.sin_addr.s_addr = src_addr;
+
+ usrsctp_init(local_udp_port, NULL, debug_printf_stack);
+#ifdef SCTP_DEBUG
+ usrsctp_sysctl_set_sctp_debug_on(SCTP_DEBUG_ALL);
+#endif
+ usrsctp_sysctl_set_sctp_blackhole(2);
+ usrsctp_sysctl_set_sctp_no_csum_on_loopback(0);
+ usrsctp_sysctl_set_sctp_enable_sack_immediately(1);
+
+ if (!(psock = usrsctp_socket(AF_INET, SOCK_STREAM, IPPROTO_SCTP, NULL, NULL, 0, NULL))) {
+ perror("user_socket");
+ exit(EXIT_FAILURE);
+ }
+
+ optval = 1;
+ if (usrsctp_setsockopt(psock, IPPROTO_SCTP, SCTP_RECVRCVINFO, &optval, sizeof(optval)) < 0) {
+ perror("usrsctp_setsockopt SCTP_RECVRCVINFO");
+ }
+
+ usrsctp_set_non_blocking(psock, 1);
+
+ if (usrsctp_bind(psock, (struct sockaddr *) &local_addr, sizeof(struct sockaddr_in)) == -1) {
+ perror("usrsctp_bind");
+ exit(1);
+ }
+
+ if (usrsctp_setsockopt(psock, IPPROTO_SCTP, SCTP_ADAPTATION_LAYER, (const void*)&ind, (socklen_t)sizeof(struct sctp_setadaptation)) < 0) {
+ perror("setsockopt");
+ }
+
+ if (meta->par_role == TSCTP_SERVER) {
+ if (rcvbufsize) {
+ if (usrsctp_setsockopt(psock, SOL_SOCKET, SO_RCVBUF, &rcvbufsize, sizeof(int)) < 0) {
+ perror("setsockopt: rcvbuf");
+ }
+ }
+ if (par_verbose) {
+ intlen = sizeof(int);
+ if (usrsctp_getsockopt(psock, SOL_SOCKET, SO_RCVBUF, &rcvbufsize, (socklen_t *)&intlen) < 0) {
+ perror("getsockopt: rcvbuf");
+ } else {
+ fprintf(stdout, "Receive buffer size: %d.\n", rcvbufsize);
+ }
+ }
+
+ if (usrsctp_listen(psock, 1) < 0) {
+ perror("usrsctp_listen");
+ exit(EXIT_FAILURE);
+ }
+
+ usrsctp_set_upcall(psock, handle_accept, meta);
+
+ while (1) {
+#ifdef _WIN32
+ Sleep(1000);
+#else
+ sleep(1);
+#endif
+ }
+
+ } else {
+ memset(&encaps, 0, sizeof(struct sctp_udpencaps));
+ encaps.sue_address.ss_family = AF_INET;
+ encaps.sue_port = htons(remote_udp_port);
+ if (usrsctp_setsockopt(psock, IPPROTO_SCTP, SCTP_REMOTE_UDP_ENCAPS_PORT, (const void*)&encaps, (socklen_t)sizeof(struct sctp_udpencaps)) < 0) {
+ perror("setsockopt");
+ }
+
+ remote_addr.sin_family = AF_INET;
+#ifdef HAVE_SIN_LEN
+ remote_addr.sin_len = sizeof(struct sockaddr_in);
+#endif
+ if (!inet_pton(AF_INET, argv[optind], &remote_addr.sin_addr.s_addr)){
+ printf("error: invalid destination address\n");
+ exit(EXIT_FAILURE);
+ }
+ remote_addr.sin_port = htons(remote_port);
+
+ memset(meta->buffer, 'X', BUFFERSIZE);
+
+ usrsctp_set_upcall(psock, handle_upcall, meta);
+
+ usrsctp_setsockopt(psock, IPPROTO_SCTP, SCTP_NODELAY, &nodelay, sizeof(nodelay));
+
+ if (fragpoint) {
+ av.assoc_id = 0;
+ av.assoc_value = fragpoint;
+ if (usrsctp_setsockopt(psock, IPPROTO_SCTP, SCTP_MAXSEG, &av, sizeof(struct sctp_assoc_value)) < 0) {
+ perror("setsockopt: SCTP_MAXSEG");
+ }
+ }
+
+ if (sndbufsize) {
+ if (usrsctp_setsockopt(psock, SOL_SOCKET, SO_SNDBUF, &sndbufsize, sizeof(int)) < 0) {
+ perror("setsockopt: sndbuf");
+ }
+ }
+
+ if (par_verbose) {
+ intlen = sizeof(int);
+ if (usrsctp_getsockopt(psock, SOL_SOCKET, SO_SNDBUF, &sndbufsize, (socklen_t *)&intlen) < 0) {
+ perror("setsockopt: SO_SNDBUF");
+ } else {
+ fprintf(stdout,"Send buffer size: %d.\n", sndbufsize);
+ }
+ }
+
+ if (usrsctp_connect(psock, (struct sockaddr *) &remote_addr, sizeof(struct sockaddr_in)) == -1 ) {
+ if (errno != EINPROGRESS) {
+ perror("usrsctp_connect");
+ exit(EXIT_FAILURE);
+ }
+ }
+
+ while (!done) {
+#ifdef _WIN32
+ Sleep(1000);
+#else
+ sleep(1);
+#endif
+ }
+
+ if (par_verbose) {
+ printf("Finished... \n");
+ }
+ }
+
+ while (usrsctp_finish() != 0) {
+#ifdef _WIN32
+ Sleep(1000);
+#else
+ sleep(1);
+#endif
+ }
+
+ return 0;
+}
diff --git a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/CMakeLists.txt b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/CMakeLists.txt
index c5b72296b65..d6652c1cd34 100644
--- a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/CMakeLists.txt
+++ b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/CMakeLists.txt
@@ -1,6 +1,6 @@
#
# Copyright (C) 2015-2015 Oleg Alexeenkov
-# Copyright (C) 2015-2017 Felix Weinrank
+# Copyright (C) 2015-2019 Felix Weinrank
#
# All rights reserved.
#
@@ -53,35 +53,42 @@ add_definitions(-DSCTP_PROCESS_LEVEL_LOCKS)
# OS DEPENDENT
#################################################
-if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
+check_c_compiler_flag(-Wno-address-of-packed-member has_wno_address_of_packet_member)
+if (has_wno_address_of_packet_member)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-address-of-packed-member")
+endif ()
+
+if (CMAKE_SYSTEM_NAME MATCHES "Linux")
add_definitions(-D_GNU_SOURCE)
endif ()
-if (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
+if (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
add_definitions(-U__FreeBSD__)
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-address-of-packed-member")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-address-of-packed-member")
endif ()
-if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
+if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
add_definitions(-U__APPLE__)
add_definitions(-D__APPLE_USE_RFC_2292)
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-address-of-packed-member -Wno-deprecated-declarations")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-address-of-packed-member -Wno-deprecated-declarations")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-deprecated-declarations")
endif ()
-if (${CMAKE_SYSTEM_NAME} MATCHES "DragonFly")
+if (CMAKE_SYSTEM_NAME MATCHES "DragonFly")
add_definitions(-U__DragonFly__)
endif ()
-if (${CMAKE_SYSTEM_NAME} MATCHES "NetBSD")
+if (CMAKE_SYSTEM_NAME MATCHES "NetBSD")
add_definitions(-U__NetBSD__)
endif ()
-if (${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
+if (CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
add_definitions(-U__OpenBSD__)
endif ()
+#################################################
+# MISC
+#################################################
+
+
#################################################
# LIBRARY FILES
@@ -171,10 +178,13 @@ list(APPEND usrsctp_sources
add_library(usrsctp SHARED ${usrsctp_sources} ${usrsctp_headers})
add_library(usrsctp-static STATIC ${usrsctp_sources} ${usrsctp_headers})
+target_include_directories(usrsctp PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
+target_include_directories(usrsctp-static PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
+
if (WIN32)
message(STATUS "link library: ws2_32")
- target_link_libraries(usrsctp ws2_32)
- target_link_libraries(usrsctp-static ws2_32)
+ target_link_libraries(usrsctp ws2_32 iphlpapi.lib)
+ target_link_libraries(usrsctp-static ws2_32 iphlpapi.lib)
endif ()
set_target_properties(usrsctp-static PROPERTIES OUTPUT_NAME "usrsctp")
diff --git a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/Makefile.nmake b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/Makefile.nmake
index e16dc1e7875..48d2bd110c7 100644
--- a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/Makefile.nmake
+++ b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/Makefile.nmake
@@ -1,179 +1,179 @@
-#
-# Copyright (C) 2011-2012 Michael Tuexen
-#
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-# 1. Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# 2. Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in the
-# documentation and/or other materials provided with the distribution.
-# 3. Neither the name of the project nor the names of its contributors
-# may be used to endorse or promote products derived from this software
-# without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
-# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-# ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
-# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-# SUCH DAMAGE.
-#
-
-CFLAGS=/I. /W3 /WX
-
-CVARSDLL=-DSCTP_DEBUG -DSCTP_SIMPLE_ALLOCATOR -DSCTP_PROCESS_LEVEL_LOCKS
-CVARSDLL=$(CVARSDLL) -D__Userspace__ -D__Userspace_os_Windows
-CVARSDLL=$(CVARSDLL) -DINET -DINET6
-CVARSDLL=$(CVARSDLL) -D_LIB
-
-LINKFLAGS=/LIBPATH:. Ws2_32.lib
-
-usrsctp_OBJECTS = \
- user_environment.obj \
- user_mbuf.obj \
- user_recv_thread.obj \
- user_socket.obj \
- sctp_asconf.obj \
- sctp_auth.obj \
- sctp_bsd_addr.obj \
- sctp_callout.obj \
- sctp_cc_functions.obj \
- sctp_crc32.obj \
- sctp_indata.obj \
- sctp_input.obj \
- sctp_output.obj \
- sctp_pcb.obj \
- sctp_peeloff.obj \
- sctp_sha1.obj \
- sctp_ss_functions.obj \
- sctp_sysctl.obj \
- sctp_timer.obj \
- sctp_userspace.obj \
- sctp_usrreq.obj \
- sctputil.obj \
- sctp6_usrreq.obj
-
-usrsctp_HEADERS = \
- user_atomic.h \
- user_environment.h \
- user_inpcb.h \
- user_ip6_var.h \
- user_malloc.h \
- user_mbuf.h \
- user_recv_thread.h \
- user_route.h \
- user_socketvar.h \
- user_uma.h \
- user_queue.h \
- user_ip_icmp.h \
- user_ip6_var.h \
- netinet\sctp.h \
- netinet\sctp_asconf.h \
- netinet\sctp_auth.h \
- netinet\sctp_bsd_addr.h \
- netinet\sctp_callout.h \
- netinet\sctp_constants.h \
- netinet\sctp_crc32.h \
- netinet\sctp_header.h \
- netinet\sctp_indata.h \
- netinet\sctp_input.h \
- netinet\sctp_lock_userspace.h \
- netinet\sctp_os.h \
- netinet\sctp_os_userspace.h \
- netinet\sctp_output.h \
- netinet\sctp_pcb.h \
- netinet\sctp_peeloff.h \
- netinet\sctp_process_lock.h \
- netinet\sctp_sha1.h \
- netinet\sctp_structs.h \
- netinet\sctp_sysctl.h \
- netinet\sctp_timer.h \
- netinet\sctp_uio.h \
- netinet\sctp_var.h \
- netinet\sctputil.h \
- netinet6\sctp6_var.h
-
-usrsctp.lib : $(usrsctp_OBJECTS)
- lib /out:usrsctp.lib $(LINKFLAGS) $(usrsctp_OBJECTS)
-
-user_environment.obj : user_environment.c $(usrsctp_HEADERS)
- cl $(CVARSDLL) $(CFLAGS) -c user_environment.c
-
-user_mbuf.obj : user_mbuf.c $(usrsctp_HEADERS)
- cl $(CVARSDLL) $(CFLAGS) -c user_mbuf.c
-
-user_recv_thread.obj: user_recv_thread.c $(usrsctp_HEADERS)
- cl $(CVARSDLL) $(CFLAGS) -c user_recv_thread.c
-
-user_socket.obj : user_socket.c $(usrsctp_HEADERS)
- cl $(CVARSDLL) $(CFLAGS) -c user_socket.c
-
-sctp_asconf.obj : netinet\sctp_asconf.c $(usrsctp_HEADERS)
- cl $(CVARSDLL) $(CFLAGS) -c netinet\sctp_asconf.c
-
-sctp_auth.obj : netinet\sctp_auth.c $(usrsctp_HEADERS)
- cl $(CVARSDLL) $(CFLAGS) -c netinet\sctp_auth.c
-
-sctp_bsd_addr.obj : netinet\sctp_bsd_addr.c $(usrsctp_HEADERS)
- cl $(CVARSDLL) $(CFLAGS) -c netinet\sctp_bsd_addr.c
-
-sctp_callout.obj : netinet\sctp_callout.c $(usrsctp_HEADERS)
- cl $(CVARSDLL) $(CFLAGS) -c netinet\sctp_callout.c
-
-sctp_cc_functions.obj : netinet\sctp_cc_functions.c $(usrsctp_HEADERS)
- cl $(CVARSDLL) $(CFLAGS) -c netinet\sctp_cc_functions.c
-
-sctp_crc32.obj : netinet\sctp_crc32.c $(usrsctp_HEADERS)
- cl $(CVARSDLL) $(CFLAGS) -c netinet\sctp_crc32.c
-
-sctp_indata.obj : netinet\sctp_indata.c $(usrsctp_HEADERS)
- cl $(CVARSDLL) $(CFLAGS) -c netinet\sctp_indata.c
-
-sctp_input.obj : netinet\sctp_input.c $(usrsctp_HEADERS)
- cl $(CVARSDLL) $(CFLAGS) -c netinet\sctp_input.c
-
-sctp_output.obj : netinet\sctp_output.c $(usrsctp_HEADERS)
- cl $(CVARSDLL) $(CFLAGS) -c netinet\sctp_output.c
-
-sctp_pcb.obj : netinet\sctp_pcb.c $(usrsctp_HEADERS)
- cl $(CVARSDLL) $(CFLAGS) -c netinet\sctp_pcb.c
-
-sctp_peeloff.obj : netinet\sctp_peeloff.c $(usrsctp_HEADERS)
- cl $(CVARSDLL) $(CFLAGS) -c netinet\sctp_peeloff.c
-
-sctp_sha1.obj : netinet\sctp_sha1.c $(usrsctp_HEADERS)
- cl $(CVARSDLL) $(CFLAGS) -c netinet\sctp_sha1.c
-
-sctp_ss_functions.obj : netinet\sctp_ss_functions.c $(usrsctp_HEADERS)
- cl $(CVARSDLL) $(CFLAGS) -c netinet\sctp_ss_functions.c
-
-sctp_sysctl.obj : netinet\sctp_sysctl.c $(usrsctp_HEADERS)
- cl $(CVARSDLL) $(CFLAGS) -c netinet\sctp_sysctl.c
-
-sctp_timer.obj : netinet\sctp_timer.c $(usrsctp_HEADERS)
- cl $(CVARSDLL) $(CFLAGS) -c netinet\sctp_timer.c
-
-sctp_userspace.obj : netinet\sctp_userspace.c $(usrsctp_HEADERS)
- cl $(CVARSDLL) $(CFLAGS) -c netinet\sctp_userspace.c
-
-sctp_usrreq.obj : netinet\sctp_usrreq.c $(usrsctp_HEADERS)
- cl $(CVARSDLL) $(CFLAGS) -c netinet\sctp_usrreq.c
-
-sctputil.obj : netinet\sctputil.c $(usrsctp_HEADERS)
- cl $(CVARSDLL) $(CFLAGS) -c netinet\sctputil.c
-
-sctp6_usrreq.obj : netinet6\sctp6_usrreq.c $(usrsctp_HEADERS)
- cl $(CVARSDLL) $(CFLAGS) -c netinet6\sctp6_usrreq.c
-
-clean:
- del *.obj
- del usrsctp.lib
+#
+# Copyright (C) 2011-2012 Michael Tuexen
+#
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of the project nor the names of its contributors
+# may be used to endorse or promote products derived from this software
+# without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+
+CFLAGS=/I. /W3 /WX
+
+CVARSDLL=-DSCTP_DEBUG -DSCTP_SIMPLE_ALLOCATOR -DSCTP_PROCESS_LEVEL_LOCKS
+CVARSDLL=$(CVARSDLL) -D__Userspace__ -D__Userspace_os_Windows
+CVARSDLL=$(CVARSDLL) -DINET -DINET6
+CVARSDLL=$(CVARSDLL) -D_LIB
+
+LINKFLAGS=/LIBPATH:. Ws2_32.lib
+
+usrsctp_OBJECTS = \
+ user_environment.obj \
+ user_mbuf.obj \
+ user_recv_thread.obj \
+ user_socket.obj \
+ sctp_asconf.obj \
+ sctp_auth.obj \
+ sctp_bsd_addr.obj \
+ sctp_callout.obj \
+ sctp_cc_functions.obj \
+ sctp_crc32.obj \
+ sctp_indata.obj \
+ sctp_input.obj \
+ sctp_output.obj \
+ sctp_pcb.obj \
+ sctp_peeloff.obj \
+ sctp_sha1.obj \
+ sctp_ss_functions.obj \
+ sctp_sysctl.obj \
+ sctp_timer.obj \
+ sctp_userspace.obj \
+ sctp_usrreq.obj \
+ sctputil.obj \
+ sctp6_usrreq.obj
+
+usrsctp_HEADERS = \
+ user_atomic.h \
+ user_environment.h \
+ user_inpcb.h \
+ user_ip6_var.h \
+ user_malloc.h \
+ user_mbuf.h \
+ user_recv_thread.h \
+ user_route.h \
+ user_socketvar.h \
+ user_uma.h \
+ user_queue.h \
+ user_ip_icmp.h \
+ user_ip6_var.h \
+ netinet\sctp.h \
+ netinet\sctp_asconf.h \
+ netinet\sctp_auth.h \
+ netinet\sctp_bsd_addr.h \
+ netinet\sctp_callout.h \
+ netinet\sctp_constants.h \
+ netinet\sctp_crc32.h \
+ netinet\sctp_header.h \
+ netinet\sctp_indata.h \
+ netinet\sctp_input.h \
+ netinet\sctp_lock_userspace.h \
+ netinet\sctp_os.h \
+ netinet\sctp_os_userspace.h \
+ netinet\sctp_output.h \
+ netinet\sctp_pcb.h \
+ netinet\sctp_peeloff.h \
+ netinet\sctp_process_lock.h \
+ netinet\sctp_sha1.h \
+ netinet\sctp_structs.h \
+ netinet\sctp_sysctl.h \
+ netinet\sctp_timer.h \
+ netinet\sctp_uio.h \
+ netinet\sctp_var.h \
+ netinet\sctputil.h \
+ netinet6\sctp6_var.h
+
+usrsctp.lib : $(usrsctp_OBJECTS)
+ lib /out:usrsctp.lib $(LINKFLAGS) $(usrsctp_OBJECTS)
+
+user_environment.obj : user_environment.c $(usrsctp_HEADERS)
+ cl $(CVARSDLL) $(CFLAGS) -c user_environment.c
+
+user_mbuf.obj : user_mbuf.c $(usrsctp_HEADERS)
+ cl $(CVARSDLL) $(CFLAGS) -c user_mbuf.c
+
+user_recv_thread.obj: user_recv_thread.c $(usrsctp_HEADERS)
+ cl $(CVARSDLL) $(CFLAGS) -c user_recv_thread.c
+
+user_socket.obj : user_socket.c $(usrsctp_HEADERS)
+ cl $(CVARSDLL) $(CFLAGS) -c user_socket.c
+
+sctp_asconf.obj : netinet\sctp_asconf.c $(usrsctp_HEADERS)
+ cl $(CVARSDLL) $(CFLAGS) -c netinet\sctp_asconf.c
+
+sctp_auth.obj : netinet\sctp_auth.c $(usrsctp_HEADERS)
+ cl $(CVARSDLL) $(CFLAGS) -c netinet\sctp_auth.c
+
+sctp_bsd_addr.obj : netinet\sctp_bsd_addr.c $(usrsctp_HEADERS)
+ cl $(CVARSDLL) $(CFLAGS) -c netinet\sctp_bsd_addr.c
+
+sctp_callout.obj : netinet\sctp_callout.c $(usrsctp_HEADERS)
+ cl $(CVARSDLL) $(CFLAGS) -c netinet\sctp_callout.c
+
+sctp_cc_functions.obj : netinet\sctp_cc_functions.c $(usrsctp_HEADERS)
+ cl $(CVARSDLL) $(CFLAGS) -c netinet\sctp_cc_functions.c
+
+sctp_crc32.obj : netinet\sctp_crc32.c $(usrsctp_HEADERS)
+ cl $(CVARSDLL) $(CFLAGS) -c netinet\sctp_crc32.c
+
+sctp_indata.obj : netinet\sctp_indata.c $(usrsctp_HEADERS)
+ cl $(CVARSDLL) $(CFLAGS) -c netinet\sctp_indata.c
+
+sctp_input.obj : netinet\sctp_input.c $(usrsctp_HEADERS)
+ cl $(CVARSDLL) $(CFLAGS) -c netinet\sctp_input.c
+
+sctp_output.obj : netinet\sctp_output.c $(usrsctp_HEADERS)
+ cl $(CVARSDLL) $(CFLAGS) -c netinet\sctp_output.c
+
+sctp_pcb.obj : netinet\sctp_pcb.c $(usrsctp_HEADERS)
+ cl $(CVARSDLL) $(CFLAGS) -c netinet\sctp_pcb.c
+
+sctp_peeloff.obj : netinet\sctp_peeloff.c $(usrsctp_HEADERS)
+ cl $(CVARSDLL) $(CFLAGS) -c netinet\sctp_peeloff.c
+
+sctp_sha1.obj : netinet\sctp_sha1.c $(usrsctp_HEADERS)
+ cl $(CVARSDLL) $(CFLAGS) -c netinet\sctp_sha1.c
+
+sctp_ss_functions.obj : netinet\sctp_ss_functions.c $(usrsctp_HEADERS)
+ cl $(CVARSDLL) $(CFLAGS) -c netinet\sctp_ss_functions.c
+
+sctp_sysctl.obj : netinet\sctp_sysctl.c $(usrsctp_HEADERS)
+ cl $(CVARSDLL) $(CFLAGS) -c netinet\sctp_sysctl.c
+
+sctp_timer.obj : netinet\sctp_timer.c $(usrsctp_HEADERS)
+ cl $(CVARSDLL) $(CFLAGS) -c netinet\sctp_timer.c
+
+sctp_userspace.obj : netinet\sctp_userspace.c $(usrsctp_HEADERS)
+ cl $(CVARSDLL) $(CFLAGS) -c netinet\sctp_userspace.c
+
+sctp_usrreq.obj : netinet\sctp_usrreq.c $(usrsctp_HEADERS)
+ cl $(CVARSDLL) $(CFLAGS) -c netinet\sctp_usrreq.c
+
+sctputil.obj : netinet\sctputil.c $(usrsctp_HEADERS)
+ cl $(CVARSDLL) $(CFLAGS) -c netinet\sctputil.c
+
+sctp6_usrreq.obj : netinet6\sctp6_usrreq.c $(usrsctp_HEADERS)
+ cl $(CVARSDLL) $(CFLAGS) -c netinet6\sctp6_usrreq.c
+
+clean:
+ del *.obj
+ del usrsctp.lib
diff --git a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/meson.build b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/meson.build
new file mode 100644
index 00000000000..c1a6656f1da
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/meson.build
@@ -0,0 +1,20 @@
+# Includes
+include_dirs = include_directories(
+ '.',
+ 'netinet',
+ 'netinet6',
+)
+
+# Sources
+sources = files([
+ 'user_environment.c',
+ 'user_mbuf.c',
+ 'user_recv_thread.c',
+ 'user_socket.c',
+])
+
+subdir('netinet')
+subdir('netinet6')
+
+# Install usrsctp.h
+install_headers('usrsctp.h')
diff --git a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/meson.build b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/meson.build
new file mode 100644
index 00000000000..4a86615bcd4
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/meson.build
@@ -0,0 +1,20 @@
+sources += files([
+ 'sctp_asconf.c',
+ 'sctp_auth.c',
+ 'sctp_bsd_addr.c',
+ 'sctp_callout.c',
+ 'sctp_cc_functions.c',
+ 'sctp_crc32.c',
+ 'sctp_indata.c',
+ 'sctp_input.c',
+ 'sctp_output.c',
+ 'sctp_pcb.c',
+ 'sctp_peeloff.c',
+ 'sctp_sha1.c',
+ 'sctp_ss_functions.c',
+ 'sctp_sysctl.c',
+ 'sctp_timer.c',
+ 'sctp_userspace.c',
+ 'sctp_usrreq.c',
+ 'sctputil.c',
+])
diff --git a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp.h b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp.h
index f5b1d828902..98476246576 100755
--- a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp.h
+++ b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp.h
@@ -34,7 +34,7 @@
#ifdef __FreeBSD__
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/netinet/sctp.h 323657 2017-09-16 21:26:06Z tuexen $");
+__FBSDID("$FreeBSD: head/sys/netinet/sctp.h 356357 2020-01-04 20:33:12Z tuexen $");
#endif
#ifndef _NETINET_SCTP_H_
@@ -530,6 +530,7 @@ struct sctp_error_auth_invalid_hmac {
#define SCTP_PCB_FLAGS_BOUNDALL 0x00000004
#define SCTP_PCB_FLAGS_ACCEPTING 0x00000008
#define SCTP_PCB_FLAGS_UNBOUND 0x00000010
+#define SCTP_PCB_FLAGS_SND_ITERATOR_UP 0x00000020
#define SCTP_PCB_FLAGS_CLOSE_IP 0x00040000
#define SCTP_PCB_FLAGS_WAS_CONNECTED 0x00080000
#define SCTP_PCB_FLAGS_WAS_ABORTED 0x00100000
@@ -607,7 +608,10 @@ struct sctp_error_auth_invalid_hmac {
#define SCTP_MOBILITY_PRIM_DELETED 0x00000004
-#define SCTP_SMALLEST_PMTU 512 /* smallest pmtu allowed when disabling PMTU discovery */
+/* Smallest PMTU allowed when disabling PMTU discovery */
+#define SCTP_SMALLEST_PMTU 512
+/* Largest PMTU allowed when disabling PMTU discovery */
+#define SCTP_LARGEST_PMTU 65536
#if defined(__Userspace_os_Windows)
#pragma pack(pop)
diff --git a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_asconf.c b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_asconf.c
index 704dfde010c..19f6fe6156f 100755
--- a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_asconf.c
+++ b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_asconf.c
@@ -34,7 +34,7 @@
#ifdef __FreeBSD__
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/netinet/sctp_asconf.c 324056 2017-09-27 13:05:23Z tuexen $");
+__FBSDID("$FreeBSD: head/sys/netinet/sctp_asconf.c 357197 2020-01-28 10:09:05Z tuexen $");
#endif
#include <netinet/sctp_os.h>
@@ -105,47 +105,52 @@ sctp_asconf_success_response(uint32_t id)
static struct mbuf *
sctp_asconf_error_response(uint32_t id, uint16_t cause, uint8_t *error_tlv,
- uint16_t tlv_length)
+ uint16_t tlv_length)
{
struct mbuf *m_reply = NULL;
struct sctp_asconf_paramhdr *aph;
struct sctp_error_cause *error;
+ uint32_t buf_len;
+ uint16_t i, param_length, cause_length, padding_length;
uint8_t *tlv;
- m_reply = sctp_get_mbuf_for_msg((sizeof(struct sctp_asconf_paramhdr) +
- tlv_length +
- sizeof(struct sctp_error_cause)),
- 0, M_NOWAIT, 1, MT_DATA);
+ if (error_tlv == NULL) {
+ tlv_length = 0;
+ }
+ cause_length = sizeof(struct sctp_error_cause) + tlv_length;
+ param_length = sizeof(struct sctp_asconf_paramhdr) + cause_length;
+ padding_length = tlv_length % 4;
+ if (padding_length != 0) {
+ padding_length = 4 - padding_length;
+ }
+ buf_len = param_length + padding_length;
+ if (buf_len > MLEN) {
+ SCTPDBG(SCTP_DEBUG_ASCONF1,
+ "asconf_error_response: tlv_length (%xh) too big\n",
+ tlv_length);
+ return (NULL);
+ }
+ m_reply = sctp_get_mbuf_for_msg(buf_len, 0, M_NOWAIT, 1, MT_DATA);
if (m_reply == NULL) {
SCTPDBG(SCTP_DEBUG_ASCONF1,
"asconf_error_response: couldn't get mbuf!\n");
return (NULL);
}
aph = mtod(m_reply, struct sctp_asconf_paramhdr *);
- error = (struct sctp_error_cause *)(aph + 1);
-
- aph->correlation_id = id;
aph->ph.param_type = htons(SCTP_ERROR_CAUSE_IND);
+ aph->ph.param_length = htons(param_length);
+ aph->correlation_id = id;
+ error = (struct sctp_error_cause *)(aph + 1);
error->code = htons(cause);
- error->length = tlv_length + sizeof(struct sctp_error_cause);
- aph->ph.param_length = error->length +
- sizeof(struct sctp_asconf_paramhdr);
-
- if (aph->ph.param_length > MLEN) {
- SCTPDBG(SCTP_DEBUG_ASCONF1,
- "asconf_error_response: tlv_length (%xh) too big\n",
- tlv_length);
- sctp_m_freem(m_reply); /* discard */
- return (NULL);
- }
+ error->length = htons(cause_length);
if (error_tlv != NULL) {
tlv = (uint8_t *) (error + 1);
memcpy(tlv, error_tlv, tlv_length);
+ for (i = 0; i < padding_length; i++) {
+ tlv[tlv_length + i] = 0;
+ }
}
- SCTP_BUF_LEN(m_reply) = aph->ph.param_length;
- error->length = htons(error->length);
- aph->ph.param_length = htons(aph->ph.param_length);
-
+ SCTP_BUF_LEN(m_reply) = buf_len;
return (m_reply);
}
@@ -174,10 +179,16 @@ sctp_process_asconf_add_ip(struct sockaddr *src, struct sctp_asconf_paramhdr *ap
#endif
aparam_length = ntohs(aph->ph.param_length);
+ if (aparam_length < sizeof(struct sctp_asconf_paramhdr) + sizeof(struct sctp_paramhdr)) {
+ return (NULL);
+ }
ph = (struct sctp_paramhdr *)(aph + 1);
param_type = ntohs(ph->param_type);
#if defined(INET) || defined(INET6)
param_length = ntohs(ph->param_length);
+ if (param_length + sizeof(struct sctp_asconf_paramhdr) != aparam_length) {
+ return (NULL);
+ }
#endif
sa = &store.sa;
switch (param_type) {
@@ -245,6 +256,7 @@ sctp_process_asconf_add_ip(struct sockaddr *src, struct sctp_asconf_paramhdr *ap
"process_asconf_add_ip: using source addr ");
SCTPDBG_ADDR(SCTP_DEBUG_ASCONF1, src);
}
+ net = NULL;
/* add the address */
if (bad_address) {
m_reply = sctp_asconf_error_response(aph->correlation_id,
@@ -259,17 +271,19 @@ sctp_process_asconf_add_ip(struct sockaddr *src, struct sctp_asconf_paramhdr *ap
SCTP_CAUSE_RESOURCE_SHORTAGE, (uint8_t *) aph,
aparam_length);
} else {
- /* notify upper layer */
- sctp_ulp_notify(SCTP_NOTIFY_ASCONF_ADD_IP, stcb, 0, sa, SCTP_SO_NOT_LOCKED);
if (response_required) {
m_reply =
sctp_asconf_success_response(aph->correlation_id);
}
- sctp_timer_start(SCTP_TIMER_TYPE_PATHMTURAISE, stcb->sctp_ep, stcb, net);
- sctp_timer_start(SCTP_TIMER_TYPE_HEARTBEAT, stcb->sctp_ep,
- stcb, net);
- if (send_hb) {
- sctp_send_hb(stcb, net, SCTP_SO_NOT_LOCKED);
+ if (net != NULL) {
+ /* notify upper layer */
+ sctp_ulp_notify(SCTP_NOTIFY_ASCONF_ADD_IP, stcb, 0, sa, SCTP_SO_NOT_LOCKED);
+ sctp_timer_start(SCTP_TIMER_TYPE_PATHMTURAISE, stcb->sctp_ep, stcb, net);
+ sctp_timer_start(SCTP_TIMER_TYPE_HEARTBEAT, stcb->sctp_ep,
+ stcb, net);
+ if (send_hb) {
+ sctp_send_hb(stcb, net, SCTP_SO_NOT_LOCKED);
+ }
}
}
return (m_reply);
@@ -278,7 +292,7 @@ sctp_process_asconf_add_ip(struct sockaddr *src, struct sctp_asconf_paramhdr *ap
static int
sctp_asconf_del_remote_addrs_except(struct sctp_tcb *stcb, struct sockaddr *src)
{
- struct sctp_nets *src_net, *net;
+ struct sctp_nets *src_net, *net, *nnet;
/* make sure the source address exists as a destination net */
src_net = sctp_findnet(stcb, src);
@@ -288,10 +302,9 @@ sctp_asconf_del_remote_addrs_except(struct sctp_tcb *stcb, struct sockaddr *src)
}
/* delete all destination addresses except the source */
- TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) {
+ TAILQ_FOREACH_SAFE(net, &stcb->asoc.nets, sctp_next, nnet) {
if (net != src_net) {
/* delete this address */
- sctp_remove_net(stcb, net);
SCTPDBG(SCTP_DEBUG_ASCONF1,
"asconf_del_remote_addrs_except: deleting ");
SCTPDBG_ADDR(SCTP_DEBUG_ASCONF1,
@@ -299,6 +312,7 @@ sctp_asconf_del_remote_addrs_except(struct sctp_tcb *stcb, struct sockaddr *src)
/* notify upper layer */
sctp_ulp_notify(SCTP_NOTIFY_ASCONF_DELETE_IP, stcb, 0,
(struct sockaddr *)&net->ro._l_addr, SCTP_SO_NOT_LOCKED);
+ sctp_remove_net(stcb, net);
}
}
return (0);
@@ -329,10 +343,16 @@ sctp_process_asconf_delete_ip(struct sockaddr *src,
#endif
aparam_length = ntohs(aph->ph.param_length);
+ if (aparam_length < sizeof(struct sctp_asconf_paramhdr) + sizeof(struct sctp_paramhdr)) {
+ return (NULL);
+ }
ph = (struct sctp_paramhdr *)(aph + 1);
param_type = ntohs(ph->param_type);
#if defined(INET) || defined(INET6)
param_length = ntohs(ph->param_length);
+ if (param_length + sizeof(struct sctp_asconf_paramhdr) != aparam_length) {
+ return (NULL);
+ }
#endif
sa = &store.sa;
switch (param_type) {
@@ -464,10 +484,16 @@ sctp_process_asconf_set_primary(struct sockaddr *src,
#endif
aparam_length = ntohs(aph->ph.param_length);
+ if (aparam_length < sizeof(struct sctp_asconf_paramhdr) + sizeof(struct sctp_paramhdr)) {
+ return (NULL);
+ }
ph = (struct sctp_paramhdr *)(aph + 1);
param_type = ntohs(ph->param_type);
#if defined(INET) || defined(INET6)
param_length = ntohs(ph->param_length);
+ if (param_length + sizeof(struct sctp_asconf_paramhdr) != aparam_length) {
+ return (NULL);
+ }
#endif
sa = &store.sa;
switch (param_type) {
@@ -687,10 +713,11 @@ sctp_handle_asconf(struct mbuf *m, unsigned int offset,
SCTPDBG(SCTP_DEBUG_ASCONF1,
"handle_asconf: couldn't get lookup addr!\n");
/* respond with a missing/invalid mandatory parameter error */
+ sctp_m_freem(m_ack);
return;
}
- /* param_length is already validated in process_control... */
- offset += ntohs(p_addr->ph.param_length); /* skip lookup addr */
+ /* skip lookup addr */
+ offset += SCTP_SIZE32(ntohs(p_addr->ph.param_length));
/* get pointer to first asconf param in ASCONF */
aph = (struct sctp_asconf_paramhdr *)sctp_m_getptr(m, offset, sizeof(struct sctp_asconf_paramhdr), (uint8_t *)&aparam_buf);
if (aph == NULL) {
@@ -719,6 +746,7 @@ sctp_handle_asconf(struct mbuf *m, unsigned int offset,
if (param_length <= sizeof(struct sctp_paramhdr)) {
SCTPDBG(SCTP_DEBUG_ASCONF1, "handle_asconf: param length (%u) too short\n", param_length);
sctp_m_freem(m_ack);
+ return;
}
/* get the entire parameter */
aph = (struct sctp_asconf_paramhdr *)sctp_m_getptr(m, offset, param_length, aparam_buf);
@@ -774,8 +802,6 @@ sctp_handle_asconf(struct mbuf *m, unsigned int offset,
if (m_result != NULL) {
SCTP_BUF_NEXT(m_tail) = m_result;
m_tail = m_result;
- /* update lengths, make sure it's aligned too */
- SCTP_BUF_LEN(m_result) = SCTP_SIZE32(SCTP_BUF_LEN(m_result));
ack_cp->ch.chunk_length += SCTP_BUF_LEN(m_result);
/* set flag to force success reports */
error = 1;
@@ -1380,7 +1406,7 @@ sctp_asconf_queue_add(struct sctp_tcb *stcb, struct sctp_ifa *ifa,
if (sctp_asconf_queue_mgmt(stcb,
stcb->asoc.asconf_addr_del_pending,
SCTP_DEL_IP_ADDRESS) == 0) {
- SCTPDBG(SCTP_DEBUG_ASCONF2, "asconf_queue_add: queing pending delete\n");
+ SCTPDBG(SCTP_DEBUG_ASCONF2, "asconf_queue_add: queuing pending delete\n");
pending_delete_queued = 1;
/* clear out the pending delete info */
stcb->asoc.asconf_del_pending = 0;
@@ -1971,12 +1997,10 @@ sctp_addr_mgmt_assoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
case AF_INET:
{
struct sockaddr_in *sin;
- struct in6pcb *inp6;
- inp6 = (struct in6pcb *)&inp->ip_inp.inp;
/* invalid if we are a v6 only endpoint */
if ((inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) &&
- SCTP_IPV6_V6ONLY(inp6))
+ SCTP_IPV6_V6ONLY(inp))
return;
sin = &ifa->address.sin;
@@ -2009,8 +2033,8 @@ sctp_addr_mgmt_assoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
* sent when the state goes open.
*/
if (status == 0 &&
- ((SCTP_GET_STATE(&stcb->asoc) == SCTP_STATE_OPEN) ||
- (SCTP_GET_STATE(&stcb->asoc) == SCTP_STATE_SHUTDOWN_RECEIVED))) {
+ ((SCTP_GET_STATE(stcb) == SCTP_STATE_OPEN) ||
+ (SCTP_GET_STATE(stcb) == SCTP_STATE_SHUTDOWN_RECEIVED))) {
#ifdef SCTP_TIMER_BASED_ASCONF
sctp_timer_start(SCTP_TIMER_TYPE_ASCONF, inp,
stcb, stcb->asoc.primary_destination);
@@ -2049,10 +2073,8 @@ sctp_asconf_iterator_ep(struct sctp_inpcb *inp, void *ptr, uint32_t val SCTP_UNU
case AF_INET:
{
/* invalid if we are a v6 only endpoint */
- struct in6pcb *inp6;
- inp6 = (struct in6pcb *)&inp->ip_inp.inp;
if ((inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) &&
- SCTP_IPV6_V6ONLY(inp6)) {
+ SCTP_IPV6_V6ONLY(inp)) {
cnt_invalid++;
if (asc->cnt == cnt_invalid)
return (1);
@@ -2165,13 +2187,11 @@ sctp_asconf_iterator_stcb(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
case AF_INET:
{
/* invalid if we are a v6 only endpoint */
- struct in6pcb *inp6;
struct sockaddr_in *sin;
- inp6 = (struct in6pcb *)&inp->ip_inp.inp;
/* invalid if we are a v6 only endpoint */
if ((inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) &&
- SCTP_IPV6_V6ONLY(inp6))
+ SCTP_IPV6_V6ONLY(inp))
continue;
sin = &ifa->address.sin;
@@ -2190,7 +2210,7 @@ sctp_asconf_iterator_stcb(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
continue;
}
if ((inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) &&
- SCTP_IPV6_V6ONLY(inp6)) {
+ SCTP_IPV6_V6ONLY(inp)) {
cnt_invalid++;
if (asc->cnt == cnt_invalid)
return;
@@ -2262,8 +2282,8 @@ sctp_asconf_iterator_stcb(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
* count of queued params. If in the non-open state,
* these get sent when the assoc goes open.
*/
- if ((SCTP_GET_STATE(&stcb->asoc) == SCTP_STATE_OPEN) ||
- (SCTP_GET_STATE(&stcb->asoc) == SCTP_STATE_SHUTDOWN_RECEIVED)) {
+ if ((SCTP_GET_STATE(stcb) == SCTP_STATE_OPEN) ||
+ (SCTP_GET_STATE(stcb) == SCTP_STATE_SHUTDOWN_RECEIVED)) {
if (status >= 0) {
num_queued++;
}
@@ -2324,8 +2344,8 @@ sctp_set_primary_ip_address_sa(struct sctp_tcb *stcb, struct sockaddr *sa)
"set_primary_ip_address_sa: queued on tcb=%p, ",
(void *)stcb);
SCTPDBG_ADDR(SCTP_DEBUG_ASCONF1, sa);
- if ((SCTP_GET_STATE(&stcb->asoc) == SCTP_STATE_OPEN) ||
- (SCTP_GET_STATE(&stcb->asoc) == SCTP_STATE_SHUTDOWN_RECEIVED)) {
+ if ((SCTP_GET_STATE(stcb) == SCTP_STATE_OPEN) ||
+ (SCTP_GET_STATE(stcb) == SCTP_STATE_SHUTDOWN_RECEIVED)) {
#ifdef SCTP_TIMER_BASED_ASCONF
sctp_timer_start(SCTP_TIMER_TYPE_ASCONF,
stcb->sctp_ep, stcb,
@@ -2860,8 +2880,7 @@ sctp_process_initack_addresses(struct sctp_tcb *stcb, struct mbuf *m,
* out the ASCONF.
*/
if (status == 0 &&
- SCTP_GET_STATE(&stcb->asoc) ==
- SCTP_STATE_OPEN) {
+ SCTP_GET_STATE(stcb) == SCTP_STATE_OPEN) {
#ifdef SCTP_TIMER_BASED_ASCONF
sctp_timer_start(SCTP_TIMER_TYPE_ASCONF,
stcb->sctp_ep, stcb,
diff --git a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_auth.c b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_auth.c
index bc645b36d90..65571df2d0b 100755
--- a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_auth.c
+++ b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_auth.c
@@ -525,7 +525,7 @@ sctp_insert_sharedkey(struct sctp_keyhead *shared_keys,
} else if (new_skey->keyid == skey->keyid) {
/* replace the existing key */
/* verify this key *can* be replaced */
- if ((skey->deactivated) && (skey->refcount > 1)) {
+ if ((skey->deactivated) || (skey->refcount > 1)) {
SCTPDBG(SCTP_DEBUG_AUTH1,
"can't replace shared key id %u\n",
new_skey->keyid);
@@ -1084,40 +1084,6 @@ sctp_hmac_m(uint16_t hmac_algo, uint8_t *key, uint32_t keylen,
return (digestlen);
}
-/*-
- * verify the HMAC digest using the desired hash key, text, and HMAC
- * algorithm.
- * Returns -1 on error, 0 on success.
- */
-int
-sctp_verify_hmac(uint16_t hmac_algo, uint8_t *key, uint32_t keylen,
- uint8_t *text, uint32_t textlen,
- uint8_t *digest, uint32_t digestlen)
-{
- uint32_t len;
- uint8_t temp[SCTP_AUTH_DIGEST_LEN_MAX];
-
- /* sanity check the material and length */
- if ((key == NULL) || (keylen == 0) ||
- (text == NULL) || (textlen == 0) || (digest == NULL)) {
- /* can't do HMAC with empty key or text or digest */
- return (-1);
- }
- len = sctp_get_hmac_digest_len(hmac_algo);
- if ((len == 0) || (digestlen != len))
- return (-1);
-
- /* compute the expected hash */
- if (sctp_hmac(hmac_algo, key, keylen, text, textlen, temp) != len)
- return (-1);
-
- if (memcmp(digest, temp, digestlen) != 0)
- return (-1);
- else
- return (0);
-}
-
-
/*
* computes the requested HMAC using a key struct (which may be modified if
* the keylen exceeds the HMAC block len).
@@ -1764,8 +1730,13 @@ sctp_handle_auth(struct sctp_tcb *stcb, struct sctp_auth_chunk *auth,
(void)sctp_compute_hmac_m(hmac_id, stcb->asoc.authinfo.recv_key,
m, offset, computed_digest);
+#if defined(__Userspace__)
+#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
+ return (0);
+#endif
+#endif
/* compare the computed digest with the one in the AUTH chunk */
- if (memcmp(digest, computed_digest, digestlen) != 0) {
+ if (timingsafe_bcmp(digest, computed_digest, digestlen) != 0) {
SCTP_STAT_INCR(sctps_recvauthfailed);
SCTPDBG(SCTP_DEBUG_AUTH1,
"SCTP Auth: HMAC digest check failed\n");
diff --git a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_auth.h b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_auth.h
index c1f82d8825a..9005ccb2381 100755
--- a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_auth.h
+++ b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_auth.h
@@ -34,7 +34,7 @@
#ifdef __FreeBSD__
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/netinet/sctp_auth.h 310590 2016-12-26 11:06:41Z tuexen $");
+__FBSDID("$FreeBSD: head/sys/netinet/sctp_auth.h 338749 2018-09-18 10:53:07Z tuexen $");
#endif
#ifndef _NETINET_SCTP_AUTH_H_
@@ -170,8 +170,6 @@ extern uint32_t sctp_get_auth_chunk_len(uint16_t hmac_algo);
extern uint32_t sctp_get_hmac_digest_len(uint16_t hmac_algo);
extern uint32_t sctp_hmac(uint16_t hmac_algo, uint8_t *key, uint32_t keylen,
uint8_t *text, uint32_t textlen, uint8_t *digest);
-extern int sctp_verify_hmac(uint16_t hmac_algo, uint8_t *key, uint32_t keylen,
- uint8_t *text, uint32_t textlen, uint8_t *digest, uint32_t digestlen);
extern uint32_t sctp_compute_hmac(uint16_t hmac_algo, sctp_key_t *key,
uint8_t *text, uint32_t textlen, uint8_t *digest);
extern int sctp_auth_is_supported_hmac(sctp_hmaclist_t *list, uint16_t id);
diff --git a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_bsd_addr.c b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_bsd_addr.c
index e3b6e1b6de7..8547f447cc5 100755
--- a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_bsd_addr.c
+++ b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_bsd_addr.c
@@ -34,7 +34,7 @@
#ifdef __FreeBSD__
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/netinet/sctp_bsd_addr.c 333813 2018-05-18 20:13:34Z mmacy $");
+__FBSDID("$FreeBSD: head/sys/netinet/sctp_bsd_addr.c 353480 2019-10-13 18:17:08Z tuexen $");
#endif
#include <netinet/sctp_os.h>
@@ -569,6 +569,7 @@ sctp_init_ifns_for_vrf(int vrfid)
* any IFA that exists as we float through the
* list of IFA's
*/
+ struct epoch_tracker et;
struct ifnet *ifn;
struct ifaddr *ifa;
struct sctp_ifa *sctp_ifa;
@@ -578,12 +579,12 @@ sctp_init_ifns_for_vrf(int vrfid)
#endif
IFNET_RLOCK();
- TAILQ_FOREACH(ifn, &MODULE_GLOBAL(ifnet), if_link) {
+ NET_EPOCH_ENTER(et);
+ CK_STAILQ_FOREACH(ifn, &MODULE_GLOBAL(ifnet), if_link) {
if (sctp_is_desired_interface_type(ifn) == 0) {
/* non desired type */
continue;
}
- IF_ADDR_RLOCK(ifn);
CK_STAILQ_FOREACH(ifa, &ifn->if_addrhead, ifa_link) {
if (ifa->ifa_addr == NULL) {
continue;
@@ -636,8 +637,8 @@ sctp_init_ifns_for_vrf(int vrfid)
sctp_ifa->localifa_flags &= ~SCTP_ADDR_DEFER_USE;
}
}
- IF_ADDR_RUNLOCK(ifn);
}
+ NET_EPOCH_EXIT(et);
IFNET_RUNLOCK();
}
#endif
@@ -741,13 +742,18 @@ sctp_addr_change(struct ifaddr *ifa, int cmd)
#if defined(__FreeBSD__)
void
+sctp_addr_change_event_handler(void *arg __unused, struct ifaddr *ifa, int cmd) {
+ sctp_addr_change(ifa, cmd);
+}
+
+void
sctp_add_or_del_interfaces(int (*pred)(struct ifnet *), int add)
{
struct ifnet *ifn;
struct ifaddr *ifa;
IFNET_RLOCK();
- TAILQ_FOREACH(ifn, &MODULE_GLOBAL(ifnet), if_link) {
+ CK_STAILQ_FOREACH(ifn, &MODULE_GLOBAL(ifnet), if_link) {
if (!(*pred)(ifn)) {
continue;
}
diff --git a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_bsd_addr.h b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_bsd_addr.h
index a83c0ec4c76..c43823cb265 100755
--- a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_bsd_addr.h
+++ b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_bsd_addr.h
@@ -34,7 +34,7 @@
#ifdef __FreeBSD__
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/netinet/sctp_bsd_addr.h 310590 2016-12-26 11:06:41Z tuexen $");
+__FBSDID("$FreeBSD: head/sys/netinet/sctp_bsd_addr.h 353480 2019-10-13 18:17:08Z tuexen $");
#endif
#ifndef _NETINET_SCTP_BSD_ADDR_H_
@@ -64,6 +64,10 @@ int sctp_copy_out_packet_log(uint8_t *target, int length);
#if !defined(__Panda__)
void sctp_addr_change(struct ifaddr *ifa, int cmd);
#endif
+#if defined(__FreeBSD__)
+
+void sctp_addr_change_event_handler(void *, struct ifaddr *, int);
+#endif
void sctp_add_or_del_interfaces(int (*pred)(struct ifnet *), int add);
diff --git a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_callout.c b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_callout.c
index 8fc57c7aff0..c6cffc783b1 100755
--- a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_callout.c
+++ b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_callout.c
@@ -59,13 +59,13 @@
* Callout/Timer routines for OS that doesn't have them
*/
#if defined(__APPLE__) || defined(__Userspace__)
-static int ticks = 0;
+static uint32_t ticks = 0;
#else
extern int ticks;
#endif
-int sctp_get_tick_count(void) {
- int ret;
+uint32_t sctp_get_tick_count(void) {
+ uint32_t ret;
SCTP_TIMERQ_LOCK();
ret = ticks;
@@ -87,7 +87,7 @@ sctp_os_timer_init(sctp_os_timer_t *c)
}
void
-sctp_os_timer_start(sctp_os_timer_t *c, int to_ticks, void (*ftn) (void *),
+sctp_os_timer_start(sctp_os_timer_t *c, uint32_t to_ticks, void (*ftn) (void *),
void *arg)
{
/* paranoia */
@@ -113,7 +113,7 @@ sctp_os_timer_start(sctp_os_timer_t *c, int to_ticks, void (*ftn) (void *),
* We could unlock/splx here and lock/spl at the TAILQ_INSERT_TAIL,
* but there's no point since doing this setup doesn't take much time.
*/
- if (to_ticks <= 0)
+ if (to_ticks == 0)
to_ticks = 1;
c->c_arg = arg;
@@ -145,8 +145,8 @@ sctp_os_timer_stop(sctp_os_timer_t *c)
return (1);
}
-static void
-sctp_handle_tick(int delta)
+void
+sctp_handle_tick(uint32_t elapsed_ticks)
{
sctp_os_timer_t *c;
void (*c_func)(void *);
@@ -154,10 +154,10 @@ sctp_handle_tick(int delta)
SCTP_TIMERQ_LOCK();
/* update our tick count */
- ticks += delta;
+ ticks += elapsed_ticks;
c = TAILQ_FIRST(&SCTP_BASE_INFO(callqueue));
while (c) {
- if (c->c_time <= ticks) {
+ if (SCTP_UINT32_GE(ticks, c->c_time)) {
sctp_os_timer_next = TAILQ_NEXT(c, tqe);
TAILQ_REMOVE(&SCTP_BASE_INFO(callqueue), c, tqe);
c_func = c->c_func;
@@ -195,11 +195,13 @@ user_sctp_timer_iterate(void *arg)
#if defined (__Userspace_os_Windows)
Sleep(TIMEOUT_INTERVAL);
#else
- struct timeval timeout;
+ struct timespec amount, remaining;
- timeout.tv_sec = 0;
- timeout.tv_usec = 1000 * TIMEOUT_INTERVAL;
- select(0, NULL, NULL, NULL, &timeout);
+ remaining.tv_sec = 0;
+ remaining.tv_nsec = TIMEOUT_INTERVAL * 1000 * 1000;
+ do {
+ amount = remaining;
+ } while (nanosleep(&amount, &remaining) == -1);
#endif
if (atomic_cmpset_int(&SCTP_BASE_VAR(timer_thread_should_exit), 1, 1)) {
break;
diff --git a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_callout.h b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_callout.h
index 765f966bd1c..13279da053a 100755
--- a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_callout.h
+++ b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_callout.h
@@ -71,13 +71,13 @@ __FBSDID("$FreeBSD$");
#endif
#endif
-int sctp_get_tick_count(void);
+uint32_t sctp_get_tick_count(void);
TAILQ_HEAD(calloutlist, sctp_callout);
struct sctp_callout {
TAILQ_ENTRY(sctp_callout) tqe;
- int c_time; /* ticks to the event */
+ uint32_t c_time; /* ticks to the event */
void *c_arg; /* function argument */
void (*c_func)(void *); /* function to call */
int c_flags; /* state of this entry */
@@ -88,8 +88,9 @@ typedef struct sctp_callout sctp_os_timer_t;
#define SCTP_CALLOUT_PENDING 0x0004 /* callout is waiting for timeout */
void sctp_os_timer_init(sctp_os_timer_t *tmr);
-void sctp_os_timer_start(sctp_os_timer_t *, int, void (*)(void *), void *);
+void sctp_os_timer_start(sctp_os_timer_t *, uint32_t, void (*)(void *), void *);
int sctp_os_timer_stop(sctp_os_timer_t *);
+void sctp_handle_tick(uint32_t);
#define SCTP_OS_TIMER_INIT sctp_os_timer_init
#define SCTP_OS_TIMER_START sctp_os_timer_start
diff --git a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_cc_functions.c b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_cc_functions.c
index e53e4d747f3..01390579396 100755
--- a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_cc_functions.c
+++ b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_cc_functions.c
@@ -34,7 +34,7 @@
#ifdef __FreeBSD__
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/netinet/sctp_cc_functions.c 310590 2016-12-26 11:06:41Z tuexen $");
+__FBSDID("$FreeBSD: head/sys/netinet/sctp_cc_functions.c 356660 2020-01-12 15:45:27Z tuexen $");
#endif
#include <netinet/sctp_os.h>
@@ -50,8 +50,8 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_cc_functions.c 310590 2016-12-26 11:06
#include <netinet/sctp_timer.h>
#include <netinet/sctp_auth.h>
#include <netinet/sctp_asconf.h>
-#if defined(__FreeBSD__) && __FreeBSD_version >= 803000
-#include <netinet/sctp_dtrace_declare.h>
+#if defined(__FreeBSD__)
+#include <netinet/sctp_kdtrace.h>
#endif
#define SHIFT_MPTCP_MULTI_N 40
@@ -1962,7 +1962,7 @@ htcp_cong_time(struct htcp *ca)
static inline uint32_t
htcp_ccount(struct htcp *ca)
{
- return (htcp_cong_time(ca)/ca->minRTT);
+ return (ca->minRTT == 0 ? htcp_cong_time(ca) : htcp_cong_time(ca)/ca->minRTT);
}
static inline void
@@ -2410,7 +2410,7 @@ sctp_htcp_cwnd_update_after_ecn_echo(struct sctp_tcb *stcb,
const struct sctp_cc_functions sctp_cc_functions[] = {
{
-#if defined(__Windows__) || defined(__Userspace_os_Windows)
+#if defined(__Windows__) || (defined(__Userspace_os_Windows) && !defined(__MINGW32__))
sctp_set_initial_cc_param,
sctp_cwnd_update_after_sack,
sctp_cwnd_update_exit_pf_common,
@@ -2431,7 +2431,7 @@ const struct sctp_cc_functions sctp_cc_functions[] = {
#endif
},
{
-#if defined(__Windows__) || defined(__Userspace_os_Windows)
+#if defined(__Windows__) || (defined(__Userspace_os_Windows) && !defined(__MINGW32__))
sctp_set_initial_cc_param,
sctp_hs_cwnd_update_after_sack,
sctp_cwnd_update_exit_pf_common,
@@ -2452,7 +2452,7 @@ const struct sctp_cc_functions sctp_cc_functions[] = {
#endif
},
{
-#if defined(__Windows__) || defined(__Userspace_os_Windows)
+#if defined(__Windows__) || (defined(__Userspace_os_Windows) && !defined(__MINGW32__))
sctp_htcp_set_initial_cc_param,
sctp_htcp_cwnd_update_after_sack,
sctp_cwnd_update_exit_pf_common,
@@ -2473,7 +2473,7 @@ const struct sctp_cc_functions sctp_cc_functions[] = {
#endif
},
{
-#if defined(__Windows__) || defined(__Userspace_os_Windows)
+#if defined(__Windows__) || (defined(__Userspace_os_Windows) && !defined(__MINGW32__))
sctp_set_rtcc_initial_cc_param,
sctp_cwnd_update_rtcc_after_sack,
sctp_cwnd_update_exit_pf_common,
diff --git a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_constants.h b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_constants.h
index f9a87a47b2a..038a3402463 100755
--- a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_constants.h
+++ b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_constants.h
@@ -34,7 +34,7 @@
#ifdef __FreeBSD__
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/netinet/sctp_constants.h 328478 2018-01-27 13:46:55Z tuexen $");
+__FBSDID("$FreeBSD: head/sys/netinet/sctp_constants.h 343089 2019-01-16 11:33:47Z tuexen $");
#endif
#ifndef _NETINET_SCTP_CONSTANTS_H_
@@ -478,10 +478,14 @@ extern void getwintimeofday(struct timeval *tv);
#define SCTP_STATE_IN_ACCEPT_QUEUE 0x1000
#define SCTP_STATE_MASK 0x007f
-#define SCTP_GET_STATE(asoc) ((asoc)->state & SCTP_STATE_MASK)
-#define SCTP_SET_STATE(asoc, newstate) ((asoc)->state = ((asoc)->state & ~SCTP_STATE_MASK) | newstate)
-#define SCTP_CLEAR_SUBSTATE(asoc, substate) ((asoc)->state &= ~substate)
-#define SCTP_ADD_SUBSTATE(asoc, substate) ((asoc)->state |= substate)
+#define SCTP_GET_STATE(_stcb) \
+ ((_stcb)->asoc.state & SCTP_STATE_MASK)
+#define SCTP_SET_STATE(_stcb, _state) \
+ sctp_set_state(_stcb, _state)
+#define SCTP_CLEAR_SUBSTATE(_stcb, _substate) \
+ (_stcb)->asoc.state &= ~(_substate)
+#define SCTP_ADD_SUBSTATE(_stcb, _substate) \
+ sctp_add_substate(_stcb, _substate)
/* SCTP reachability state for each address */
#define SCTP_ADDR_REACHABLE 0x001
@@ -1004,6 +1008,9 @@ extern void getwintimeofday(struct timeval *tv);
((((uint8_t *)&(a)->s_addr)[0] == 169) && \
(((uint8_t *)&(a)->s_addr)[1] == 254))
+/* Maximum size of optval for IPPROTO_SCTP level socket options. */
+#define SCTP_SOCKET_OPTION_LIMIT (64 * 1024)
+
#if defined(__Userspace__)
#if defined(__Userspace_os_Windows)
#define SCTP_GETTIME_TIMEVAL(x) getwintimeofday(x)
diff --git a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_crc32.c b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_crc32.c
index 0be0795cf2a..c08392a7aac 100755
--- a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_crc32.c
+++ b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_crc32.c
@@ -34,10 +34,13 @@
#ifdef __FreeBSD__
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/netinet/sctp_crc32.c 327200 2017-12-26 12:35:02Z tuexen $");
+__FBSDID("$FreeBSD: head/sys/netinet/sctp_crc32.c 352361 2019-09-15 18:29:45Z 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>
@@ -812,17 +815,17 @@ sctp_delayed_cksum(struct mbuf *m, uint32_t offset)
SCTP_STAT_INCR(sctps_sendswcrc);
offset += offsetof(struct sctphdr, checksum);
- if (offset + sizeof(uint32_t) > (uint32_t)(m->m_len)) {
+ if (offset + sizeof(uint32_t) > (uint32_t)(m->m_pkthdr.len)) {
#ifdef INVARIANTS
- panic("sctp_delayed_cksum(): m->m_len: %d, offset: %u.",
- m->m_len, offset);
+ panic("sctp_delayed_cksum(): m->m_pkthdr.len: %d, offset: %u.",
+ m->m_pkthdr.len, offset);
#else
- SCTP_PRINTF("sctp_delayed_cksum(): m->m_len: %d, offset: %u.\n",
- m->m_len, offset);
+ SCTP_PRINTF("sctp_delayed_cksum(): m->m_pkthdr.len: %d, offset: %u.\n",
+ m->m_pkthdr.len, offset);
#endif
return;
}
- *(uint32_t *)(m->m_data + offset) = checksum;
+ m_copyback(m, (int)offset, (int)sizeof(uint32_t), (caddr_t)&checksum);
}
#endif
#endif
diff --git a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_indata.c b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_indata.c
index 2fbac2ff0bf..8b332355a5b 100755
--- a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_indata.c
+++ b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_indata.c
@@ -34,7 +34,7 @@
#ifdef __FreeBSD__
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/netinet/sctp_indata.c 333979 2018-05-21 14:51:20Z tuexen $");
+__FBSDID("$FreeBSD: head/sys/netinet/sctp_indata.c 353145 2019-10-06 08:47:10Z tuexen $");
#endif
#include <netinet/sctp_os.h>
@@ -487,7 +487,12 @@ sctp_clean_up_control(struct sctp_tcb *stcb, struct sctp_queued_to_read *control
chk->data = NULL;
sctp_free_a_chunk(stcb, chk, SCTP_SO_NOT_LOCKED);
}
- sctp_free_a_readq(stcb, control);
+ sctp_free_remote_addr(control->whoFrom);
+ if (control->data) {
+ sctp_m_freem(control->data);
+ control->data = NULL;
+ }
+ sctp_free_a_readq(stcb, control);
}
/*
@@ -726,6 +731,7 @@ sctp_add_to_tail_pointer(struct sctp_queued_to_read *control, struct mbuf *m, ui
}
if (control->tail_mbuf == NULL) {
/* TSNH */
+ sctp_m_freem(control->data);
control->data = m;
sctp_setup_tail_pointer(control);
return;
@@ -928,6 +934,12 @@ restart:
break;
}
}
+ if (cnt_added && strm->pd_api_started) {
+#if defined(__Userspace__)
+ sctp_invoke_recv_callback(stcb->sctp_ep, stcb, control, SCTP_READ_LOCK_NOT_HELD);
+#endif
+ sctp_wakeup_the_read_socket(stcb->sctp_ep, stcb, SCTP_SO_NOT_LOCKED);
+ }
if ((control->length > pd_point) && (strm->pd_api_started == 0)) {
strm->pd_api_started = 1;
control->pdapi_started = 1;
@@ -959,6 +971,16 @@ sctp_inject_old_unordered_data(struct sctp_tcb *stcb,
SCTPDBG(SCTP_DEBUG_XXX,
"chunk is a first fsn: %u becomes fsn_included\n",
chk->rec.data.fsn);
+ at = TAILQ_FIRST(&control->reasm);
+ if (at && SCTP_TSN_GT(chk->rec.data.fsn, at->rec.data.fsn)) {
+ /*
+ * The first chunk in the reassembly is
+ * a smaller TSN than this one, even though
+ * this has a first, it must be from a subsequent
+ * msg.
+ */
+ goto place_chunk;
+ }
if (control->first_frag_seen) {
/*
* In old un-ordered we can reassembly on
@@ -1463,6 +1485,16 @@ sctp_queue_data_for_reasm(struct sctp_tcb *stcb, struct sctp_association *asoc,
"The last fsn is now in place fsn: %u\n",
chk->rec.data.fsn);
control->last_frag_seen = 1;
+ if (SCTP_TSN_GT(control->top_fsn, chk->rec.data.fsn)) {
+ SCTPDBG(SCTP_DEBUG_XXX,
+ "New fsn: %u is not at top_fsn: %u -- abort\n",
+ chk->rec.data.fsn,
+ control->top_fsn);
+ sctp_abort_in_reasm(stcb, control, chk,
+ abort_flag,
+ SCTP_FROM_SCTP_INDATA + SCTP_LOC_9);
+ return;
+ }
}
if (asoc->idata_supported || control->first_frag_seen) {
/*
@@ -1475,7 +1507,7 @@ sctp_queue_data_for_reasm(struct sctp_tcb *stcb, struct sctp_association *asoc,
/* We have already delivered up to this so its a dup */
sctp_abort_in_reasm(stcb, control, chk,
abort_flag,
- SCTP_FROM_SCTP_INDATA + SCTP_LOC_9);
+ SCTP_FROM_SCTP_INDATA + SCTP_LOC_10);
return;
}
}
@@ -1487,7 +1519,7 @@ sctp_queue_data_for_reasm(struct sctp_tcb *stcb, struct sctp_association *asoc,
chk->rec.data.fsn, control->top_fsn);
sctp_abort_in_reasm(stcb, control,
chk, abort_flag,
- SCTP_FROM_SCTP_INDATA + SCTP_LOC_10);
+ SCTP_FROM_SCTP_INDATA + SCTP_LOC_11);
return;
}
if (asoc->idata_supported || control->first_frag_seen) {
@@ -1505,7 +1537,7 @@ sctp_queue_data_for_reasm(struct sctp_tcb *stcb, struct sctp_association *asoc,
chk->rec.data.fsn, control->fsn_included);
sctp_abort_in_reasm(stcb, control, chk,
abort_flag,
- SCTP_FROM_SCTP_INDATA + SCTP_LOC_11);
+ SCTP_FROM_SCTP_INDATA + SCTP_LOC_12);
return;
}
}
@@ -1517,7 +1549,7 @@ sctp_queue_data_for_reasm(struct sctp_tcb *stcb, struct sctp_association *asoc,
control->top_fsn);
sctp_abort_in_reasm(stcb, control, chk,
abort_flag,
- SCTP_FROM_SCTP_INDATA + SCTP_LOC_12);
+ SCTP_FROM_SCTP_INDATA + SCTP_LOC_13);
return;
}
}
@@ -1557,7 +1589,7 @@ sctp_queue_data_for_reasm(struct sctp_tcb *stcb, struct sctp_association *asoc,
at->rec.data.fsn);
sctp_abort_in_reasm(stcb, control,
chk, abort_flag,
- SCTP_FROM_SCTP_INDATA + SCTP_LOC_13);
+ SCTP_FROM_SCTP_INDATA + SCTP_LOC_14);
return;
}
}
@@ -2072,10 +2104,13 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc,
struct mbuf *mm;
control->data = dmbuf;
+ control->tail_mbuf = NULL;
for (mm = control->data; mm; mm = mm->m_next) {
control->length += SCTP_BUF_LEN(mm);
+ if (SCTP_BUF_NEXT(mm) == NULL) {
+ control->tail_mbuf = mm;
+ }
}
- control->tail_mbuf = NULL;
control->end_added = 1;
control->last_frag_seen = 1;
control->first_frag_seen = 1;
@@ -2554,7 +2589,7 @@ sctp_sack_check(struct sctp_tcb *stcb, int was_a_gap)
* Now we need to see if we need to queue a sack or just start the
* timer (if allowed).
*/
- if (SCTP_GET_STATE(asoc) == SCTP_STATE_SHUTDOWN_SENT) {
+ if (SCTP_GET_STATE(stcb) == SCTP_STATE_SHUTDOWN_SENT) {
/*
* Ok special case, in SHUTDOWN-SENT case. here we
* maker sure SACK timer is off and instead send a
@@ -2911,7 +2946,7 @@ sctp_process_data(struct mbuf **mm, int iphlen, int *offset, int length,
(void)SCTP_GETTIME_TIMEVAL(&stcb->asoc.time_last_rcvd);
}
/* now service all of the reassm queue if needed */
- if (SCTP_GET_STATE(asoc) == SCTP_STATE_SHUTDOWN_SENT) {
+ if (SCTP_GET_STATE(stcb) == SCTP_STATE_SHUTDOWN_SENT) {
/* Assure that we ack right away */
stcb->asoc.send_sack = 1;
}
@@ -3059,7 +3094,7 @@ sctp_process_segment_range(struct sctp_tcb *stcb, struct sctp_tmit_chunk **p_tp1
tp1->whoTo->net_ack += tp1->send_size;
if (tp1->snd_count < 2) {
/*-
- * True non-retransmited chunk
+ * True non-retransmitted chunk
*/
tp1->whoTo->net_ack2 += tp1->send_size;
@@ -3067,13 +3102,12 @@ sctp_process_segment_range(struct sctp_tcb *stcb, struct sctp_tmit_chunk **p_tp1
* update RTO too ?
*/
if (tp1->do_rtt) {
- if (*rto_ok) {
- tp1->whoTo->RTO =
- sctp_calculate_rto(stcb,
- &stcb->asoc,
- tp1->whoTo,
- &tp1->sent_rcv_time,
- SCTP_RTT_FROM_DATA);
+ if (*rto_ok &&
+ sctp_calculate_rto(stcb,
+ &stcb->asoc,
+ tp1->whoTo,
+ &tp1->sent_rcv_time,
+ SCTP_RTT_FROM_DATA)) {
*rto_ok = 0;
}
if (tp1->whoTo->rto_needed == 0) {
@@ -4019,7 +4053,7 @@ sctp_express_handle_sack(struct sctp_tcb *stcb, uint32_t cumack,
tp1->whoTo->net_ack += tp1->send_size;
if (tp1->snd_count < 2) {
/*
- * True non-retransmited
+ * True non-retransmitted
* chunk
*/
tp1->whoTo->net_ack2 +=
@@ -4027,16 +4061,12 @@ sctp_express_handle_sack(struct sctp_tcb *stcb, uint32_t cumack,
/* update RTO too? */
if (tp1->do_rtt) {
- if (rto_ok) {
- tp1->whoTo->RTO =
- /*
- * sa_ignore
- * NO_NULL_CHK
- */
- sctp_calculate_rto(stcb,
- asoc, tp1->whoTo,
- &tp1->sent_rcv_time,
- SCTP_RTT_FROM_DATA);
+ if (rto_ok &&
+ sctp_calculate_rto(stcb,
+ &stcb->asoc,
+ tp1->whoTo,
+ &tp1->sent_rcv_time,
+ SCTP_RTT_FROM_DATA)) {
rto_ok = 0;
}
if (tp1->whoTo->rto_needed == 0) {
@@ -4311,12 +4341,12 @@ again:
/* clean up */
if ((asoc->stream_queue_cnt == 1) &&
((asoc->state & SCTP_STATE_SHUTDOWN_PENDING) ||
- (asoc->state & SCTP_STATE_SHUTDOWN_RECEIVED)) &&
+ (SCTP_GET_STATE(stcb) == SCTP_STATE_SHUTDOWN_RECEIVED)) &&
((*asoc->ss_functions.sctp_ss_is_user_msgs_incomplete)(stcb, asoc))) {
- asoc->state |= SCTP_STATE_PARTIAL_MSG_LEFT;
+ SCTP_ADD_SUBSTATE(stcb, SCTP_STATE_PARTIAL_MSG_LEFT);
}
if (((asoc->state & SCTP_STATE_SHUTDOWN_PENDING) ||
- (SCTP_GET_STATE(asoc) == SCTP_STATE_SHUTDOWN_RECEIVED)) &&
+ (SCTP_GET_STATE(stcb) == SCTP_STATE_SHUTDOWN_RECEIVED)) &&
(asoc->stream_queue_cnt == 1) &&
(asoc->state & SCTP_STATE_PARTIAL_MSG_LEFT)) {
struct mbuf *op_err;
@@ -4332,12 +4362,11 @@ again:
(asoc->stream_queue_cnt == 0)) {
struct sctp_nets *netp;
- if ((SCTP_GET_STATE(asoc) == SCTP_STATE_OPEN) ||
- (SCTP_GET_STATE(asoc) == SCTP_STATE_SHUTDOWN_RECEIVED)) {
+ if ((SCTP_GET_STATE(stcb) == SCTP_STATE_OPEN) ||
+ (SCTP_GET_STATE(stcb) == SCTP_STATE_SHUTDOWN_RECEIVED)) {
SCTP_STAT_DECR_GAUGE32(sctps_currestab);
}
- SCTP_SET_STATE(asoc, SCTP_STATE_SHUTDOWN_SENT);
- SCTP_CLEAR_SUBSTATE(asoc, SCTP_STATE_SHUTDOWN_PENDING);
+ SCTP_SET_STATE(stcb, SCTP_STATE_SHUTDOWN_SENT);
sctp_stop_timers_for_shutdown(stcb);
if (asoc->alternate) {
netp = asoc->alternate;
@@ -4349,13 +4378,12 @@ again:
stcb->sctp_ep, stcb, netp);
sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD,
stcb->sctp_ep, stcb, netp);
- } else if ((SCTP_GET_STATE(asoc) == SCTP_STATE_SHUTDOWN_RECEIVED) &&
+ } else if ((SCTP_GET_STATE(stcb) == SCTP_STATE_SHUTDOWN_RECEIVED) &&
(asoc->stream_queue_cnt == 0)) {
struct sctp_nets *netp;
SCTP_STAT_DECR_GAUGE32(sctps_currestab);
- SCTP_SET_STATE(asoc, SCTP_STATE_SHUTDOWN_ACK_SENT);
- SCTP_CLEAR_SUBSTATE(asoc, SCTP_STATE_SHUTDOWN_PENDING);
+ SCTP_SET_STATE(stcb, SCTP_STATE_SHUTDOWN_ACK_SENT);
sctp_stop_timers_for_shutdown(stcb);
if (asoc->alternate) {
netp = asoc->alternate;
@@ -4657,7 +4685,7 @@ sctp_handle_sack(struct mbuf *m, int offset_seg, int offset_dup,
if (tp1->snd_count < 2) {
/*
- * True non-retransmited
+ * True non-retransmitted
* chunk
*/
tp1->whoTo->net_ack2 +=
@@ -4665,12 +4693,12 @@ sctp_handle_sack(struct mbuf *m, int offset_seg, int offset_dup,
/* update RTO too? */
if (tp1->do_rtt) {
- if (rto_ok) {
- tp1->whoTo->RTO =
- sctp_calculate_rto(stcb,
- asoc, tp1->whoTo,
- &tp1->sent_rcv_time,
- SCTP_RTT_FROM_DATA);
+ if (rto_ok &&
+ sctp_calculate_rto(stcb,
+ &stcb->asoc,
+ tp1->whoTo,
+ &tp1->sent_rcv_time,
+ SCTP_RTT_FROM_DATA)) {
rto_ok = 0;
}
if (tp1->whoTo->rto_needed == 0) {
@@ -5029,12 +5057,12 @@ sctp_handle_sack(struct mbuf *m, int offset_seg, int offset_dup,
/* clean up */
if ((asoc->stream_queue_cnt == 1) &&
((asoc->state & SCTP_STATE_SHUTDOWN_PENDING) ||
- (asoc->state & SCTP_STATE_SHUTDOWN_RECEIVED)) &&
+ (SCTP_GET_STATE(stcb) == SCTP_STATE_SHUTDOWN_RECEIVED)) &&
((*asoc->ss_functions.sctp_ss_is_user_msgs_incomplete)(stcb, asoc))) {
- asoc->state |= SCTP_STATE_PARTIAL_MSG_LEFT;
+ SCTP_ADD_SUBSTATE(stcb, SCTP_STATE_PARTIAL_MSG_LEFT);
}
if (((asoc->state & SCTP_STATE_SHUTDOWN_PENDING) ||
- (SCTP_GET_STATE(asoc) == SCTP_STATE_SHUTDOWN_RECEIVED)) &&
+ (SCTP_GET_STATE(stcb) == SCTP_STATE_SHUTDOWN_RECEIVED)) &&
(asoc->stream_queue_cnt == 1) &&
(asoc->state & SCTP_STATE_PARTIAL_MSG_LEFT)) {
struct mbuf *op_err;
@@ -5050,12 +5078,11 @@ sctp_handle_sack(struct mbuf *m, int offset_seg, int offset_dup,
(asoc->stream_queue_cnt == 0)) {
struct sctp_nets *netp;
- if ((SCTP_GET_STATE(asoc) == SCTP_STATE_OPEN) ||
- (SCTP_GET_STATE(asoc) == SCTP_STATE_SHUTDOWN_RECEIVED)) {
+ if ((SCTP_GET_STATE(stcb) == SCTP_STATE_OPEN) ||
+ (SCTP_GET_STATE(stcb) == SCTP_STATE_SHUTDOWN_RECEIVED)) {
SCTP_STAT_DECR_GAUGE32(sctps_currestab);
}
- SCTP_SET_STATE(asoc, SCTP_STATE_SHUTDOWN_SENT);
- SCTP_CLEAR_SUBSTATE(asoc, SCTP_STATE_SHUTDOWN_PENDING);
+ SCTP_SET_STATE(stcb, SCTP_STATE_SHUTDOWN_SENT);
sctp_stop_timers_for_shutdown(stcb);
if (asoc->alternate) {
netp = asoc->alternate;
@@ -5068,13 +5095,12 @@ sctp_handle_sack(struct mbuf *m, int offset_seg, int offset_dup,
sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD,
stcb->sctp_ep, stcb, netp);
return;
- } else if ((SCTP_GET_STATE(asoc) == SCTP_STATE_SHUTDOWN_RECEIVED) &&
+ } else if ((SCTP_GET_STATE(stcb) == SCTP_STATE_SHUTDOWN_RECEIVED) &&
(asoc->stream_queue_cnt == 0)) {
struct sctp_nets *netp;
SCTP_STAT_DECR_GAUGE32(sctps_currestab);
- SCTP_SET_STATE(asoc, SCTP_STATE_SHUTDOWN_ACK_SENT);
- SCTP_CLEAR_SUBSTATE(asoc, SCTP_STATE_SHUTDOWN_PENDING);
+ SCTP_SET_STATE(stcb, SCTP_STATE_SHUTDOWN_ACK_SENT);
sctp_stop_timers_for_shutdown(stcb);
if (asoc->alternate) {
netp = asoc->alternate;
diff --git a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_indata.h b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_indata.h
index bdba1148b68..96c8bff4ed6 100755
--- a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_indata.h
+++ b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_indata.h
@@ -34,7 +34,7 @@
#ifdef __FreeBSD__
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/netinet/sctp_indata.h 310590 2016-12-26 11:06:41Z tuexen $");
+__FBSDID("$FreeBSD: head/sys/netinet/sctp_indata.h 351655 2019-09-01 10:39:16Z tuexen $");
#endif
#ifndef _NETINET_SCTP_INDATA_H_
@@ -63,7 +63,6 @@ sctp_build_readq_entry(struct sctp_tcb *stcb,
(_ctl)->sinfo_ppid = ppid; \
(_ctl)->sinfo_context = context; \
(_ctl)->fsn_included = 0xffffffff; \
- (_ctl)->top_fsn = 0xffffffff; \
(_ctl)->sinfo_tsn = tsn; \
(_ctl)->sinfo_cumtsn = tsn; \
(_ctl)->sinfo_assoc_id = sctp_get_associd((in_it)); \
diff --git a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_input.c b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_input.c
index c62bb8506dc..b7e4aea1361 100755
--- a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_input.c
+++ b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_input.c
@@ -34,7 +34,7 @@
#ifdef __FreeBSD__
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/netinet/sctp_input.c 334725 2018-06-06 19:27:06Z tuexen $");
+__FBSDID("$FreeBSD: head/sys/netinet/sctp_input.c 355135 2019-11-27 19:32:29Z tuexen $");
#endif
#include <netinet/sctp_os.h>
@@ -51,6 +51,9 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_input.c 334725 2018-06-06 19:27:06Z tu
#include <netinet/sctp_bsd_addr.h>
#include <netinet/sctp_timer.h>
#include <netinet/sctp_crc32.h>
+#if defined(__FreeBSD__)
+#include <netinet/sctp_kdtrace.h>
+#endif
#if defined(INET) || defined(INET6)
#if !defined(__Userspace_os_Windows)
#include <netinet/udp.h>
@@ -215,7 +218,7 @@ sctp_handle_init(struct mbuf *m, int iphlen, int offset,
goto outnow;
}
if ((stcb != NULL) &&
- (SCTP_GET_STATE(&stcb->asoc) == SCTP_STATE_SHUTDOWN_ACK_SENT)) {
+ (SCTP_GET_STATE(stcb) == SCTP_STATE_SHUTDOWN_ACK_SENT)) {
SCTPDBG(SCTP_DEBUG_INPUT3, "sctp_handle_init: sending SHUTDOWN-ACK\n");
sctp_send_shutdown_ack(stcb, NULL);
sctp_chunk_output(inp, stcb, SCTP_OUTPUT_FROM_CONTROL_PROC, SCTP_SO_NOT_LOCKED);
@@ -470,27 +473,62 @@ sctp_process_init_ack(struct mbuf *m, int iphlen, int offset,
{
struct sctp_association *asoc;
struct mbuf *op_err;
- int retval, abort_flag;
- uint32_t initack_limit;
+ int retval, abort_flag, cookie_found;
+ int initack_limit;
int nat_friendly = 0;
/* First verify that we have no illegal param's */
abort_flag = 0;
+ cookie_found = 0;
op_err = sctp_arethere_unrecognized_parameters(m,
(offset + sizeof(struct sctp_init_chunk)),
- &abort_flag, (struct sctp_chunkhdr *)cp, &nat_friendly);
+ &abort_flag, (struct sctp_chunkhdr *)cp,
+ &nat_friendly, &cookie_found);
if (abort_flag) {
/* Send an abort and notify peer */
sctp_abort_an_association(stcb->sctp_ep, stcb, op_err, SCTP_SO_NOT_LOCKED);
*abort_no_unlock = 1;
return (-1);
}
+ if (!cookie_found) {
+ uint16_t len;
+
+ /* Only report the missing cookie parameter */
+ if (op_err != NULL) {
+ sctp_m_freem(op_err);
+ }
+ len = (uint16_t)(sizeof(struct sctp_error_missing_param) + sizeof(uint16_t));
+ /* We abort with an error of missing mandatory param */
+ op_err = sctp_get_mbuf_for_msg(len, 0, M_NOWAIT, 1, MT_DATA);
+ if (op_err != NULL) {
+ struct sctp_error_missing_param *cause;
+
+ SCTP_BUF_LEN(op_err) = len;
+ cause = mtod(op_err, struct sctp_error_missing_param *);
+ /* Subtract the reserved param */
+ cause->cause.code = htons(SCTP_CAUSE_MISSING_PARAM);
+ cause->cause.length = htons(len);
+ cause->num_missing_params = htonl(1);
+ cause->type[0] = htons(SCTP_STATE_COOKIE);
+ }
+ sctp_abort_association(stcb->sctp_ep, stcb, m, iphlen,
+ src, dst, sh, op_err,
+#if defined(__FreeBSD__)
+ mflowtype, mflowid,
+#endif
+ vrf_id, net->port);
+ *abort_no_unlock = 1;
+ return (-3);
+ }
asoc = &stcb->asoc;
asoc->peer_supports_nat = (uint8_t)nat_friendly;
/* process the peer's parameters in the INIT-ACK */
retval = sctp_process_init((struct sctp_init_chunk *)cp, stcb);
if (retval < 0) {
+ if (op_err != NULL) {
+ sctp_m_freem(op_err);
+ }
return (retval);
}
initack_limit = offset + ntohs(cp->ch.chunk_length);
@@ -498,6 +536,9 @@ sctp_process_init_ack(struct mbuf *m, int iphlen, int offset,
if ((retval = sctp_load_addresses_from_init(stcb, m,
(offset + sizeof(struct sctp_init_chunk)), initack_limit,
src, dst, NULL, stcb->asoc.port))) {
+ if (op_err != NULL) {
+ sctp_m_freem(op_err);
+ }
op_err = sctp_generate_cause(SCTP_BASE_SYSCTL(sctp_diag_info_code),
"Problem with address parameters");
SCTPDBG(SCTP_DEBUG_INPUT1,
@@ -550,8 +591,8 @@ sctp_process_init_ack(struct mbuf *m, int iphlen, int offset,
asoc->primary_destination, SCTP_FROM_SCTP_INPUT + SCTP_LOC_3);
/* calculate the RTO */
- net->RTO = sctp_calculate_rto(stcb, asoc, net, &asoc->time_entered,
- SCTP_RTT_FROM_NON_DATA);
+ sctp_calculate_rto(stcb, asoc, net, &asoc->time_entered,
+ SCTP_RTT_FROM_NON_DATA);
#if defined(__Userspace__)
if (stcb->sctp_ep->recv_callback) {
if (stcb->sctp_socket) {
@@ -577,42 +618,8 @@ sctp_process_init_ack(struct mbuf *m, int iphlen, int offset,
}
}
#endif
- retval = sctp_send_cookie_echo(m, offset, stcb, net);
- if (retval < 0) {
- /*
- * No cookie, we probably should send a op error. But in any
- * case if there is no cookie in the INIT-ACK, we can
- * abandon the peer, its broke.
- */
- if (retval == -3) {
- uint16_t len;
-
- len = (uint16_t)(sizeof(struct sctp_error_missing_param) + sizeof(uint16_t));
- /* We abort with an error of missing mandatory param */
- op_err = sctp_get_mbuf_for_msg(len, 0, M_NOWAIT, 1, MT_DATA);
- if (op_err != NULL) {
- struct sctp_error_missing_param *cause;
-
- SCTP_BUF_LEN(op_err) = len;
- cause = mtod(op_err, struct sctp_error_missing_param *);
- /* Subtract the reserved param */
- cause->cause.code = htons(SCTP_CAUSE_MISSING_PARAM);
- cause->cause.length = htons(len);
- cause->num_missing_params = htonl(1);
- cause->type[0] = htons(SCTP_STATE_COOKIE);
- }
- sctp_abort_association(stcb->sctp_ep, stcb, m, iphlen,
- src, dst, sh, op_err,
-#if defined(__FreeBSD__)
- mflowtype, mflowid,
-#endif
- vrf_id, net->port);
- *abort_no_unlock = 1;
- }
- return (retval);
- }
-
- return (0);
+ retval = sctp_send_cookie_echo(m, offset, initack_limit, stcb, net);
+ return (retval);
}
static void
@@ -726,8 +733,8 @@ sctp_handle_heartbeat_ack(struct sctp_heartbeat_chunk *cp,
tv.tv_sec = cp->heartbeat.hb_info.time_value_1;
tv.tv_usec = cp->heartbeat.hb_info.time_value_2;
/* Now lets do a RTO with this */
- r_net->RTO = sctp_calculate_rto(stcb, &stcb->asoc, r_net, &tv,
- SCTP_RTT_FROM_NON_DATA);
+ sctp_calculate_rto(stcb, &stcb->asoc, r_net, &tv,
+ SCTP_RTT_FROM_NON_DATA);
if (!(r_net->dest_state & SCTP_ADDR_REACHABLE)) {
r_net->dest_state |= SCTP_ADDR_REACHABLE;
sctp_ulp_notify(SCTP_NOTIFY_INTERFACE_UP, stcb,
@@ -780,31 +787,35 @@ sctp_handle_heartbeat_ack(struct sctp_heartbeat_chunk *cp,
static int
sctp_handle_nat_colliding_state(struct sctp_tcb *stcb)
{
- /* return 0 means we want you to proceed with the abort
- * non-zero means no abort processing
- */
+ /*
+ * Return 0 means we want you to proceed with the abort
+ * non-zero means no abort processing.
+ */
+ uint32_t new_vtag;
struct sctpasochead *head;
- if ((SCTP_GET_STATE(&stcb->asoc) == SCTP_STATE_COOKIE_WAIT) ||
- (SCTP_GET_STATE(&stcb->asoc) == SCTP_STATE_COOKIE_ECHOED)) {
+ if ((SCTP_GET_STATE(stcb) == SCTP_STATE_COOKIE_WAIT) ||
+ (SCTP_GET_STATE(stcb) == SCTP_STATE_COOKIE_ECHOED)) {
+ new_vtag = sctp_select_a_tag(stcb->sctp_ep, stcb->sctp_ep->sctp_lport, stcb->rport, 1);
atomic_add_int(&stcb->asoc.refcnt, 1);
SCTP_TCB_UNLOCK(stcb);
SCTP_INP_INFO_WLOCK();
SCTP_TCB_LOCK(stcb);
atomic_subtract_int(&stcb->asoc.refcnt, 1);
+ } else {
+ return (0);
}
- if (SCTP_GET_STATE(&stcb->asoc) == SCTP_STATE_COOKIE_WAIT) {
+ if (SCTP_GET_STATE(stcb) == SCTP_STATE_COOKIE_WAIT) {
/* generate a new vtag and send init */
LIST_REMOVE(stcb, sctp_asocs);
- stcb->asoc.my_vtag = sctp_select_a_tag(stcb->sctp_ep, stcb->sctp_ep->sctp_lport, stcb->rport, 1);
+ stcb->asoc.my_vtag = new_vtag;
head = &SCTP_BASE_INFO(sctp_asochash)[SCTP_PCBHASH_ASOC(stcb->asoc.my_vtag, SCTP_BASE_INFO(hashasocmark))];
/* put it in the bucket in the vtag hash of assoc's for the system */
LIST_INSERT_HEAD(head, stcb, sctp_asocs);
- sctp_send_initiate(stcb->sctp_ep, stcb, SCTP_SO_NOT_LOCKED);
SCTP_INP_INFO_WUNLOCK();
+ sctp_send_initiate(stcb->sctp_ep, stcb, SCTP_SO_NOT_LOCKED);
return (1);
- }
- if (SCTP_GET_STATE(&stcb->asoc) == SCTP_STATE_COOKIE_ECHOED) {
+ } else {
/* treat like a case where the cookie expired i.e.:
* - dump current cookie.
* - generate a new vtag.
@@ -812,16 +823,15 @@ sctp_handle_nat_colliding_state(struct sctp_tcb *stcb)
*/
/* generate a new vtag and send init */
LIST_REMOVE(stcb, sctp_asocs);
- stcb->asoc.state &= ~SCTP_STATE_COOKIE_ECHOED;
- stcb->asoc.state |= SCTP_STATE_COOKIE_WAIT;
+ SCTP_SET_STATE(stcb, SCTP_STATE_COOKIE_WAIT);
sctp_stop_all_cookie_timers(stcb);
sctp_toss_old_cookies(stcb, &stcb->asoc);
- stcb->asoc.my_vtag = sctp_select_a_tag(stcb->sctp_ep, stcb->sctp_ep->sctp_lport, stcb->rport, 1);
+ stcb->asoc.my_vtag = new_vtag;
head = &SCTP_BASE_INFO(sctp_asochash)[SCTP_PCBHASH_ASOC(stcb->asoc.my_vtag, SCTP_BASE_INFO(hashasocmark))];
/* put it in the bucket in the vtag hash of assoc's for the system */
LIST_INSERT_HEAD(head, stcb, sctp_asocs);
- sctp_send_initiate(stcb->sctp_ep, stcb, SCTP_SO_NOT_LOCKED);
SCTP_INP_INFO_WUNLOCK();
+ sctp_send_initiate(stcb->sctp_ep, stcb, SCTP_SO_NOT_LOCKED);
return (1);
}
return (0);
@@ -891,8 +901,8 @@ sctp_handle_abort(struct sctp_abort_chunk *abort,
sctp_abort_notification(stcb, 1, error, abort, SCTP_SO_NOT_LOCKED);
/* free the tcb */
SCTP_STAT_INCR_COUNTER32(sctps_aborted);
- if ((SCTP_GET_STATE(&stcb->asoc) == SCTP_STATE_OPEN) ||
- (SCTP_GET_STATE(&stcb->asoc) == SCTP_STATE_SHUTDOWN_RECEIVED)) {
+ if ((SCTP_GET_STATE(stcb) == SCTP_STATE_OPEN) ||
+ (SCTP_GET_STATE(stcb) == SCTP_STATE_SHUTDOWN_RECEIVED)) {
SCTP_STAT_DECR_GAUGE32(sctps_currestab);
}
#ifdef SCTP_ASOCLOG_OF_TSNS
@@ -906,7 +916,7 @@ sctp_handle_abort(struct sctp_abort_chunk *abort,
SCTP_TCB_LOCK(stcb);
atomic_subtract_int(&stcb->asoc.refcnt, 1);
#endif
- stcb->asoc.state |= SCTP_STATE_WAS_ABORTED;
+ SCTP_ADD_SUBSTATE(stcb, SCTP_STATE_WAS_ABORTED);
(void)sctp_free_assoc(stcb->sctp_ep, stcb, SCTP_NORMAL_PROC,
SCTP_FROM_SCTP_INPUT + SCTP_LOC_8);
#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING)
@@ -963,15 +973,15 @@ sctp_handle_shutdown(struct sctp_shutdown_chunk *cp,
if (stcb == NULL)
return;
asoc = &stcb->asoc;
- if ((SCTP_GET_STATE(asoc) == SCTP_STATE_COOKIE_WAIT) ||
- (SCTP_GET_STATE(asoc) == SCTP_STATE_COOKIE_ECHOED)) {
+ if ((SCTP_GET_STATE(stcb) == SCTP_STATE_COOKIE_WAIT) ||
+ (SCTP_GET_STATE(stcb) == SCTP_STATE_COOKIE_ECHOED)) {
return;
}
if (ntohs(cp->ch.chunk_length) != sizeof(struct sctp_shutdown_chunk)) {
/* Shutdown NOT the expected size */
return;
}
- old_state = SCTP_GET_STATE(asoc);
+ old_state = SCTP_GET_STATE(stcb);
sctp_update_acked(stcb, cp, abort_flag);
if (*abort_flag) {
return;
@@ -1027,11 +1037,10 @@ sctp_handle_shutdown(struct sctp_shutdown_chunk *cp,
}
/* goto SHUTDOWN_RECEIVED state to block new requests */
if (stcb->sctp_socket) {
- if ((SCTP_GET_STATE(asoc) != SCTP_STATE_SHUTDOWN_RECEIVED) &&
- (SCTP_GET_STATE(asoc) != SCTP_STATE_SHUTDOWN_ACK_SENT) &&
- (SCTP_GET_STATE(asoc) != SCTP_STATE_SHUTDOWN_SENT)) {
- SCTP_SET_STATE(asoc, SCTP_STATE_SHUTDOWN_RECEIVED);
- SCTP_CLEAR_SUBSTATE(asoc, SCTP_STATE_SHUTDOWN_PENDING);
+ if ((SCTP_GET_STATE(stcb) != SCTP_STATE_SHUTDOWN_RECEIVED) &&
+ (SCTP_GET_STATE(stcb) != SCTP_STATE_SHUTDOWN_ACK_SENT) &&
+ (SCTP_GET_STATE(stcb) != SCTP_STATE_SHUTDOWN_SENT)) {
+ SCTP_SET_STATE(stcb, SCTP_STATE_SHUTDOWN_RECEIVED);
/* notify upper layer that peer has initiated a shutdown */
sctp_ulp_notify(SCTP_NOTIFY_PEER_SHUTDOWN, stcb, 0, NULL, SCTP_SO_NOT_LOCKED);
@@ -1039,7 +1048,7 @@ sctp_handle_shutdown(struct sctp_shutdown_chunk *cp,
(void)SCTP_GETTIME_TIMEVAL(&asoc->time_entered);
}
}
- if (SCTP_GET_STATE(asoc) == SCTP_STATE_SHUTDOWN_SENT) {
+ if (SCTP_GET_STATE(stcb) == SCTP_STATE_SHUTDOWN_SENT) {
/*
* stop the shutdown timer, since we WILL move to
* SHUTDOWN-ACK-SENT.
@@ -1059,13 +1068,12 @@ sctp_handle_shutdown(struct sctp_shutdown_chunk *cp,
/* no outstanding data to send, so move on... */
/* send SHUTDOWN-ACK */
/* move to SHUTDOWN-ACK-SENT state */
- if ((SCTP_GET_STATE(asoc) == SCTP_STATE_OPEN) ||
- (SCTP_GET_STATE(asoc) == SCTP_STATE_SHUTDOWN_RECEIVED)) {
+ if ((SCTP_GET_STATE(stcb) == SCTP_STATE_OPEN) ||
+ (SCTP_GET_STATE(stcb) == SCTP_STATE_SHUTDOWN_RECEIVED)) {
SCTP_STAT_DECR_GAUGE32(sctps_currestab);
}
- SCTP_CLEAR_SUBSTATE(asoc, SCTP_STATE_SHUTDOWN_PENDING);
- if (SCTP_GET_STATE(asoc) != SCTP_STATE_SHUTDOWN_ACK_SENT) {
- SCTP_SET_STATE(asoc, SCTP_STATE_SHUTDOWN_ACK_SENT);
+ if (SCTP_GET_STATE(stcb) != SCTP_STATE_SHUTDOWN_ACK_SENT) {
+ SCTP_SET_STATE(stcb, SCTP_STATE_SHUTDOWN_ACK_SENT);
sctp_stop_timers_for_shutdown(stcb);
sctp_send_shutdown_ack(stcb, net);
sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNACK,
@@ -1094,15 +1102,15 @@ sctp_handle_shutdown_ack(struct sctp_shutdown_ack_chunk *cp SCTP_UNUSED,
asoc = &stcb->asoc;
/* process according to association state */
- if ((SCTP_GET_STATE(asoc) == SCTP_STATE_COOKIE_WAIT) ||
- (SCTP_GET_STATE(asoc) == SCTP_STATE_COOKIE_ECHOED)) {
+ if ((SCTP_GET_STATE(stcb) == SCTP_STATE_COOKIE_WAIT) ||
+ (SCTP_GET_STATE(stcb) == SCTP_STATE_COOKIE_ECHOED)) {
/* unexpected SHUTDOWN-ACK... do OOTB handling... */
sctp_send_shutdown_complete(stcb, net, 1);
SCTP_TCB_UNLOCK(stcb);
return;
}
- if ((SCTP_GET_STATE(asoc) != SCTP_STATE_SHUTDOWN_SENT) &&
- (SCTP_GET_STATE(asoc) != SCTP_STATE_SHUTDOWN_ACK_SENT)) {
+ if ((SCTP_GET_STATE(stcb) != SCTP_STATE_SHUTDOWN_SENT) &&
+ (SCTP_GET_STATE(stcb) != SCTP_STATE_SHUTDOWN_ACK_SENT)) {
/* unexpected SHUTDOWN-ACK... so ignore... */
SCTP_TCB_UNLOCK(stcb);
return;
@@ -1298,7 +1306,7 @@ sctp_handle_error(struct sctp_chunkhdr *ch,
* waiting.
*/
if ((cause_length >= sizeof(struct sctp_error_stale_cookie)) &&
- (SCTP_GET_STATE(asoc) == SCTP_STATE_COOKIE_ECHOED)) {
+ (SCTP_GET_STATE(stcb) == SCTP_STATE_COOKIE_ECHOED)) {
struct sctp_error_stale_cookie *stale_cookie;
stale_cookie = (struct sctp_error_stale_cookie *)cause;
@@ -1331,8 +1339,7 @@ sctp_handle_error(struct sctp_chunkhdr *ch,
}
/* blast back to INIT state */
sctp_toss_old_cookies(stcb, &stcb->asoc);
- asoc->state &= ~SCTP_STATE_COOKIE_ECHOED;
- asoc->state |= SCTP_STATE_COOKIE_WAIT;
+ SCTP_SET_STATE(stcb, SCTP_STATE_COOKIE_WAIT);
sctp_stop_all_cookie_timers(stcb);
sctp_send_initiate(stcb->sctp_ep, stcb, SCTP_SO_NOT_LOCKED);
}
@@ -1495,7 +1502,7 @@ sctp_handle_init_ack(struct mbuf *m, int iphlen, int offset,
return (-1);
}
/* process according to association state... */
- switch (stcb->asoc.state & SCTP_STATE_MASK) {
+ switch (SCTP_GET_STATE(stcb)) {
case SCTP_STATE_COOKIE_WAIT:
/* this is the expected state for this chunk */
/* process the INIT-ACK parameters */
@@ -1523,7 +1530,7 @@ sctp_handle_init_ack(struct mbuf *m, int iphlen, int offset,
}
/* update our state */
SCTPDBG(SCTP_DEBUG_INPUT2, "moving to COOKIE-ECHOED state\n");
- SCTP_SET_STATE(&stcb->asoc, SCTP_STATE_COOKIE_ECHOED);
+ SCTP_SET_STATE(stcb, SCTP_STATE_COOKIE_ECHOED);
/* reset the RTO calc */
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_THRESHOLD_LOGGING) {
@@ -1621,7 +1628,7 @@ sctp_process_cookie_existing(struct mbuf *m, int iphlen, int offset,
if (how_indx < sizeof(asoc->cookie_how)) {
asoc->cookie_how[how_indx] = 1;
}
- if (SCTP_GET_STATE(asoc) == SCTP_STATE_SHUTDOWN_ACK_SENT) {
+ if (SCTP_GET_STATE(stcb) == SCTP_STATE_SHUTDOWN_ACK_SENT) {
/* SHUTDOWN came in after sending INIT-ACK */
sctp_send_shutdown_ack(stcb, stcb->asoc.primary_destination);
op_err = sctp_generate_cause(SCTP_CAUSE_COOKIE_IN_SHUTDOWN, "");
@@ -1692,7 +1699,7 @@ sctp_process_cookie_existing(struct mbuf *m, int iphlen, int offset,
return (NULL);
}
- switch (SCTP_GET_STATE(asoc)) {
+ switch (SCTP_GET_STATE(stcb)) {
case SCTP_STATE_COOKIE_WAIT:
case SCTP_STATE_COOKIE_ECHOED:
/*
@@ -1716,12 +1723,12 @@ sctp_process_cookie_existing(struct mbuf *m, int iphlen, int offset,
stcb, net,
SCTP_FROM_SCTP_INPUT + SCTP_LOC_14);
/* update current state */
- if (SCTP_GET_STATE(asoc) == SCTP_STATE_COOKIE_ECHOED)
+ if (SCTP_GET_STATE(stcb) == SCTP_STATE_COOKIE_ECHOED)
SCTP_STAT_INCR_COUNTER32(sctps_activeestab);
else
SCTP_STAT_INCR_COUNTER32(sctps_collisionestab);
- SCTP_SET_STATE(asoc, SCTP_STATE_OPEN);
+ SCTP_SET_STATE(stcb, SCTP_STATE_OPEN);
if (asoc->state & SCTP_STATE_SHUTDOWN_PENDING) {
sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD,
stcb->sctp_ep, stcb, asoc->primary_destination);
@@ -1768,9 +1775,8 @@ sctp_process_cookie_existing(struct mbuf *m, int iphlen, int offset,
old.tv_sec = cookie->time_entered.tv_sec;
old.tv_usec = cookie->time_entered.tv_usec;
net->hb_responded = 1;
- net->RTO = sctp_calculate_rto(stcb, asoc, net,
- &old,
- SCTP_RTT_FROM_NON_DATA);
+ sctp_calculate_rto(stcb, asoc, net, &old,
+ SCTP_RTT_FROM_NON_DATA);
if (stcb->asoc.sctp_autoclose_ticks &&
(sctp_is_feature_on(inp, SCTP_PCB_FLAGS_AUTOCLOSE))) {
@@ -1820,7 +1826,7 @@ sctp_process_cookie_existing(struct mbuf *m, int iphlen, int offset,
/* If nat support, and the below and stcb is established,
* send back a ABORT(colliding state) if we are established.
*/
- if ((SCTP_GET_STATE(asoc) == SCTP_STATE_OPEN) &&
+ if ((SCTP_GET_STATE(stcb) == SCTP_STATE_OPEN) &&
(asoc->peer_supports_nat) &&
((ntohl(initack_cp->init.initiate_tag) == asoc->my_vtag) &&
((ntohl(init_cp->init.initiate_tag) != asoc->peer_vtag) ||
@@ -1923,8 +1929,8 @@ sctp_process_cookie_existing(struct mbuf *m, int iphlen, int offset,
asoc->cookie_how[how_indx] = 10;
return (NULL);
}
- if ((asoc->state & SCTP_STATE_COOKIE_WAIT) ||
- (asoc->state & SCTP_STATE_COOKIE_ECHOED)) {
+ if ((SCTP_GET_STATE(stcb) == SCTP_STATE_COOKIE_WAIT) ||
+ (SCTP_GET_STATE(stcb) == SCTP_STATE_COOKIE_ECHOED)) {
*notification = SCTP_NOTIFY_ASSOC_UP;
if (((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
@@ -1952,17 +1958,17 @@ sctp_process_cookie_existing(struct mbuf *m, int iphlen, int offset,
SCTP_SOCKET_UNLOCK(so, 1);
#endif
}
- if (SCTP_GET_STATE(asoc) == SCTP_STATE_COOKIE_ECHOED)
+ if (SCTP_GET_STATE(stcb) == SCTP_STATE_COOKIE_ECHOED)
SCTP_STAT_INCR_COUNTER32(sctps_activeestab);
else
SCTP_STAT_INCR_COUNTER32(sctps_collisionestab);
SCTP_STAT_INCR_GAUGE32(sctps_currestab);
- } else if (SCTP_GET_STATE(asoc) == SCTP_STATE_OPEN) {
+ } else if (SCTP_GET_STATE(stcb) == SCTP_STATE_OPEN) {
SCTP_STAT_INCR_COUNTER32(sctps_restartestab);
} else {
SCTP_STAT_INCR_COUNTER32(sctps_collisionestab);
}
- SCTP_SET_STATE(asoc, SCTP_STATE_OPEN);
+ SCTP_SET_STATE(stcb, SCTP_STATE_OPEN);
if (asoc->state & SCTP_STATE_SHUTDOWN_PENDING) {
sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD,
stcb->sctp_ep, stcb, asoc->primary_destination);
@@ -2023,24 +2029,24 @@ sctp_process_cookie_existing(struct mbuf *m, int iphlen, int offset,
/* notify upper layer */
*notification = SCTP_NOTIFY_ASSOC_RESTART;
atomic_add_int(&stcb->asoc.refcnt, 1);
- if ((SCTP_GET_STATE(asoc) != SCTP_STATE_OPEN) &&
- (SCTP_GET_STATE(asoc) != SCTP_STATE_SHUTDOWN_RECEIVED) &&
- (SCTP_GET_STATE(asoc) != SCTP_STATE_SHUTDOWN_SENT)) {
+ if ((SCTP_GET_STATE(stcb) != SCTP_STATE_OPEN) &&
+ (SCTP_GET_STATE(stcb) != SCTP_STATE_SHUTDOWN_RECEIVED) &&
+ (SCTP_GET_STATE(stcb) != SCTP_STATE_SHUTDOWN_SENT)) {
SCTP_STAT_INCR_GAUGE32(sctps_currestab);
}
- if (SCTP_GET_STATE(asoc) == SCTP_STATE_OPEN) {
+ if (SCTP_GET_STATE(stcb) == SCTP_STATE_OPEN) {
SCTP_STAT_INCR_GAUGE32(sctps_restartestab);
- } else if (SCTP_GET_STATE(asoc) != SCTP_STATE_SHUTDOWN_SENT) {
+ } else if (SCTP_GET_STATE(stcb) != SCTP_STATE_SHUTDOWN_SENT) {
SCTP_STAT_INCR_GAUGE32(sctps_collisionestab);
}
if (asoc->state & SCTP_STATE_SHUTDOWN_PENDING) {
- SCTP_SET_STATE(asoc, SCTP_STATE_OPEN);
+ SCTP_SET_STATE(stcb, SCTP_STATE_OPEN);
sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD,
stcb->sctp_ep, stcb, asoc->primary_destination);
- } else if (!(asoc->state & SCTP_STATE_SHUTDOWN_SENT)) {
+ } else if (SCTP_GET_STATE(stcb) != SCTP_STATE_SHUTDOWN_SENT) {
/* move to OPEN state, if not in SHUTDOWN_SENT */
- SCTP_SET_STATE(asoc, SCTP_STATE_OPEN);
+ SCTP_SET_STATE(stcb, SCTP_STATE_OPEN);
}
asoc->pre_open_streams =
ntohs(initack_cp->init.num_outbound_streams);
@@ -2178,7 +2184,7 @@ sctp_process_cookie_new(struct mbuf *m, int iphlen, int offset,
int init_offset, initack_offset, initack_limit;
int retval;
int error = 0;
- uint8_t auth_chunk_buf[SCTP_PARAM_BUFFER_SIZE];
+ uint8_t auth_chunk_buf[SCTP_CHUNK_BUFFER_SIZE];
#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING)
struct socket *so;
@@ -2244,13 +2250,13 @@ sctp_process_cookie_new(struct mbuf *m, int iphlen, int offset,
ntohs(initack_cp->init.num_outbound_streams),
port,
#if defined(__FreeBSD__) && __FreeBSD_version >= 500000
- (struct thread *)NULL
+ (struct thread *)NULL,
#elif defined(__Windows__)
- (PKTHREAD)NULL
+ (PKTHREAD)NULL,
#else
- (struct proc *)NULL
+ (struct proc *)NULL,
#endif
- );
+ SCTP_DONT_INITIALIZE_AUTH_PARAMS);
if (stcb == NULL) {
struct mbuf *op_err;
@@ -2373,8 +2379,11 @@ sctp_process_cookie_new(struct mbuf *m, int iphlen, int offset,
if (auth_skipped) {
struct sctp_auth_chunk *auth;
- auth = (struct sctp_auth_chunk *)
- sctp_m_getptr(m, auth_offset, auth_len, auth_chunk_buf);
+ if (auth_len <= SCTP_CHUNK_BUFFER_SIZE) {
+ auth = (struct sctp_auth_chunk *)sctp_m_getptr(m, auth_offset, auth_len, auth_chunk_buf);
+ } else {
+ auth = NULL;
+ }
if ((auth == NULL) || sctp_handle_auth(stcb, auth, m, auth_offset)) {
/* auth HMAC failed, dump the assoc and packet */
SCTPDBG(SCTP_DEBUG_AUTH1,
@@ -2462,7 +2471,7 @@ sctp_process_cookie_new(struct mbuf *m, int iphlen, int offset,
/* update current state */
SCTPDBG(SCTP_DEBUG_INPUT2, "moving to OPEN state\n");
- SCTP_SET_STATE(asoc, SCTP_STATE_OPEN);
+ SCTP_SET_STATE(stcb, SCTP_STATE_OPEN);
if (asoc->state & SCTP_STATE_SHUTDOWN_PENDING) {
sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD,
stcb->sctp_ep, stcb, asoc->primary_destination);
@@ -2524,8 +2533,7 @@ sctp_process_cookie_new(struct mbuf *m, int iphlen, int offset,
/* calculate the RTT and set the encaps port */
old.tv_sec = cookie->time_entered.tv_sec;
old.tv_usec = cookie->time_entered.tv_usec;
- (*netp)->RTO = sctp_calculate_rto(stcb, asoc, *netp,
- &old, SCTP_RTT_FROM_NON_DATA);
+ sctp_calculate_rto(stcb, asoc, *netp, &old, SCTP_RTT_FROM_NON_DATA);
}
/* respond with a COOKIE-ACK */
sctp_send_cookie_ack(stcb);
@@ -2678,7 +2686,7 @@ sctp_handle_cookie_echo(struct mbuf *m, int iphlen, int offset,
return (NULL);
}
/* compare the received digest with the computed digest */
- if (memcmp(calc_sig, sig, SCTP_SIGNATURE_SIZE) != 0) {
+ if (timingsafe_bcmp(calc_sig, sig, SCTP_SIGNATURE_SIZE) != 0) {
/* try the old cookie? */
if ((cookie->time_entered.tv_sec == (long)ep->time_of_secret_change) &&
(ep->current_secret_number != ep->last_secret_number)) {
@@ -2687,7 +2695,7 @@ sctp_handle_cookie_echo(struct mbuf *m, int iphlen, int offset,
(uint8_t *)ep->secret_key[(int)ep->last_secret_number],
SCTP_SECRET_SIZE, m, cookie_offset, calc_sig, 0);
/* compare */
- if (memcmp(calc_sig, sig, SCTP_SIGNATURE_SIZE) == 0)
+ if (timingsafe_bcmp(calc_sig, sig, SCTP_SIGNATURE_SIZE) == 0)
cookie_ok = 1;
}
} else {
@@ -3067,7 +3075,7 @@ sctp_handle_cookie_echo(struct mbuf *m, int iphlen, int offset,
* the accept state waiting for the accept!
*/
if (*stcb) {
- (*stcb)->asoc.state |= SCTP_STATE_IN_ACCEPT_QUEUE;
+ SCTP_ADD_SUBSTATE(*stcb, SCTP_STATE_IN_ACCEPT_QUEUE);
}
sctp_move_pcb_and_assoc(*inp_p, inp, *stcb);
@@ -3154,10 +3162,10 @@ sctp_handle_cookie_ack(struct sctp_cookie_ack_chunk *cp SCTP_UNUSED,
asoc->overall_error_count = 0;
sctp_stop_all_cookie_timers(stcb);
/* process according to association state */
- if (SCTP_GET_STATE(asoc) == SCTP_STATE_COOKIE_ECHOED) {
+ if (SCTP_GET_STATE(stcb) == SCTP_STATE_COOKIE_ECHOED) {
/* state change only needed when I am in right state */
SCTPDBG(SCTP_DEBUG_INPUT2, "moving to OPEN state\n");
- SCTP_SET_STATE(asoc, SCTP_STATE_OPEN);
+ SCTP_SET_STATE(stcb, SCTP_STATE_OPEN);
sctp_start_net_timers(stcb);
if (asoc->state & SCTP_STATE_SHUTDOWN_PENDING) {
sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD,
@@ -3168,9 +3176,8 @@ sctp_handle_cookie_ack(struct sctp_cookie_ack_chunk *cp SCTP_UNUSED,
SCTP_STAT_INCR_COUNTER32(sctps_activeestab);
SCTP_STAT_INCR_GAUGE32(sctps_currestab);
if (asoc->overall_error_count == 0) {
- net->RTO = sctp_calculate_rto(stcb, asoc, net,
- &asoc->time_entered,
- SCTP_RTT_FROM_NON_DATA);
+ sctp_calculate_rto(stcb, asoc, net, &asoc->time_entered,
+ SCTP_RTT_FROM_NON_DATA);
}
(void)SCTP_GETTIME_TIMEVAL(&asoc->time_entered);
sctp_ulp_notify(SCTP_NOTIFY_ASSOC_UP, stcb, 0, NULL, SCTP_SO_NOT_LOCKED);
@@ -3411,7 +3418,6 @@ static void
sctp_handle_shutdown_complete(struct sctp_shutdown_complete_chunk *cp SCTP_UNUSED,
struct sctp_tcb *stcb, struct sctp_nets *net)
{
- struct sctp_association *asoc;
#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING)
struct socket *so;
#endif
@@ -3421,9 +3427,8 @@ sctp_handle_shutdown_complete(struct sctp_shutdown_complete_chunk *cp SCTP_UNUSE
if (stcb == NULL)
return;
- asoc = &stcb->asoc;
/* process according to association state */
- if (SCTP_GET_STATE(asoc) != SCTP_STATE_SHUTDOWN_ACK_SENT) {
+ if (SCTP_GET_STATE(stcb) != SCTP_STATE_SHUTDOWN_ACK_SENT) {
/* unexpected SHUTDOWN-COMPLETE... so ignore... */
SCTPDBG(SCTP_DEBUG_INPUT2,
"sctp_handle_shutdown_complete: not in SCTP_STATE_SHUTDOWN_ACK_SENT --- ignore\n");
@@ -3435,8 +3440,8 @@ sctp_handle_shutdown_complete(struct sctp_shutdown_complete_chunk *cp SCTP_UNUSE
sctp_ulp_notify(SCTP_NOTIFY_ASSOC_DOWN, stcb, 0, NULL, SCTP_SO_NOT_LOCKED);
}
#ifdef INVARIANTS
- if (!TAILQ_EMPTY(&asoc->send_queue) ||
- !TAILQ_EMPTY(&asoc->sent_queue) ||
+ if (!TAILQ_EMPTY(&stcb->asoc.send_queue) ||
+ !TAILQ_EMPTY(&stcb->asoc.sent_queue) ||
sctp_is_there_unsent_data(stcb, SCTP_SO_NOT_LOCKED)) {
panic("Queues are not empty when handling SHUTDOWN-COMPLETE");
}
@@ -4846,11 +4851,13 @@ sctp_process_control(struct mbuf *m, int iphlen, int *offset, int length,
if (auth_skipped && (stcb != NULL)) {
struct sctp_auth_chunk *auth;
- auth = (struct sctp_auth_chunk *)
- sctp_m_getptr(m, auth_offset,
- auth_len, chunk_buf);
- got_auth = 1;
- auth_skipped = 0;
+ if (auth_len <= SCTP_CHUNK_BUFFER_SIZE) {
+ auth = (struct sctp_auth_chunk *)sctp_m_getptr(m, auth_offset, auth_len, chunk_buf);
+ got_auth = 1;
+ auth_skipped = 0;
+ } else {
+ auth = NULL;
+ }
if ((auth == NULL) || sctp_handle_auth(stcb, auth, m,
auth_offset)) {
/* auth HMAC failed so dump it */
@@ -4940,7 +4947,7 @@ sctp_process_control(struct mbuf *m, int iphlen, int *offset, int length,
if (((ch->chunk_type == SCTP_SELECTIVE_ACK) ||
(ch->chunk_type == SCTP_NR_SELECTIVE_ACK) ||
(ch->chunk_type == SCTP_HEARTBEAT_REQUEST)) &&
- (SCTP_GET_STATE(&stcb->asoc) == SCTP_STATE_COOKIE_ECHOED)) {
+ (SCTP_GET_STATE(stcb) == SCTP_STATE_COOKIE_ECHOED)) {
/* implied cookie-ack.. we must have lost the ack */
sctp_handle_cookie_ack((struct sctp_cookie_ack_chunk *)ch, stcb,
*netp);
@@ -5140,7 +5147,7 @@ sctp_process_control(struct mbuf *m, int iphlen, int *offset, int length,
break;
}
}
- if (SCTP_GET_STATE(&stcb->asoc) == SCTP_STATE_SHUTDOWN_ACK_SENT) {
+ if (SCTP_GET_STATE(stcb) == SCTP_STATE_SHUTDOWN_ACK_SENT) {
/*-
* If we have sent a shutdown-ack, we will pay no
* attention to a sack sent in to us since
@@ -5731,6 +5738,9 @@ sctp_common_input_processing(struct mbuf **mm, int iphlen, int offset, int lengt
struct sctp_inpcb *inp = NULL, *inp_decr = NULL;
struct sctp_tcb *stcb = NULL;
struct sctp_nets *net = NULL;
+#if defined(__Userspace__)
+ struct socket *upcall_socket = NULL;
+#endif
SCTP_STAT_INCR(sctps_recvdatagrams);
#ifdef SCTP_AUDITING_ENABLED
@@ -5771,6 +5781,7 @@ sctp_common_input_processing(struct mbuf **mm, int iphlen, int offset, int lengt
net->flowtype = mflowtype;
net->flowid = mflowid;
}
+ SCTP_PROBE5(receive, NULL, stcb, m, stcb, sh);
#endif
if ((inp != NULL) && (stcb != NULL)) {
sctp_send_packet_dropped(stcb, net, m, length, iphlen, 1);
@@ -5814,6 +5825,9 @@ sctp_common_input_processing(struct mbuf **mm, int iphlen, int offset, int lengt
}
#endif
if (inp == NULL) {
+#if defined(__FreeBSD__)
+ SCTP_PROBE5(receive, NULL, stcb, m, stcb, sh);
+#endif
SCTP_STAT_INCR(sctps_noport);
#if defined(__FreeBSD__) && (((__FreeBSD_version < 900000) && (__FreeBSD_version >= 804000)) || (__FreeBSD_version > 900000))
if (badport_bandlim(BANDLIM_SCTP_OOTB) < 0) {
@@ -5868,6 +5882,9 @@ sctp_common_input_processing(struct mbuf **mm, int iphlen, int offset, int lengt
*/
SCTP_TCB_UNLOCK(stcb);
stcb = NULL;
+#if defined(__FreeBSD__)
+ SCTP_PROBE5(receive, NULL, stcb, m, stcb, sh);
+#endif
snprintf(msg, sizeof(msg), "OOTB, %s:%d at %s", __FILE__, __LINE__, __func__);
op_err = sctp_generate_cause(SCTP_BASE_SYSCTL(sctp_diag_info_code),
msg);
@@ -5878,8 +5895,21 @@ sctp_common_input_processing(struct mbuf **mm, int iphlen, int offset, int lengt
vrf_id, port);
goto out;
}
-
}
+#if defined(__Userspace__)
+ if ((stcb != NULL) &&
+ !(stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) &&
+ (stcb->sctp_socket != NULL)) {
+ if (stcb->sctp_socket->so_head != NULL) {
+ upcall_socket = stcb->sctp_socket->so_head;
+ } else {
+ upcall_socket = stcb->sctp_socket;
+ }
+ SOCK_LOCK(upcall_socket);
+ soref(upcall_socket);
+ SOCK_UNLOCK(upcall_socket);
+ }
+#endif
if (IS_SCTP_CONTROL(ch)) {
/* process the control portion of the SCTP packet */
/* sa_ignore NO_NULL_CHK */
@@ -5927,11 +5957,17 @@ sctp_common_input_processing(struct mbuf **mm, int iphlen, int offset, int lengt
if ((stcb != NULL) &&
sctp_auth_is_required_chunk(SCTP_DATA, stcb->asoc.local_auth_chunks)) {
/* "silently" ignore */
+#if defined(__FreeBSD__)
+ SCTP_PROBE5(receive, NULL, stcb, m, stcb, sh);
+#endif
SCTP_STAT_INCR(sctps_recvauthmissing);
goto out;
}
if (stcb == NULL) {
/* out of the blue DATA chunk */
+#if defined(__FreeBSD__)
+ SCTP_PROBE5(receive, NULL, NULL, m, NULL, sh);
+#endif
snprintf(msg, sizeof(msg), "OOTB, %s:%d at %s", __FILE__, __LINE__, __func__);
op_err = sctp_generate_cause(SCTP_BASE_SYSCTL(sctp_diag_info_code),
msg);
@@ -5944,11 +5980,17 @@ sctp_common_input_processing(struct mbuf **mm, int iphlen, int offset, int lengt
}
if (stcb->asoc.my_vtag != ntohl(sh->v_tag)) {
/* v_tag mismatch! */
+#if defined(__FreeBSD__)
+ SCTP_PROBE5(receive, NULL, stcb, m, stcb, sh);
+#endif
SCTP_STAT_INCR(sctps_badvtag);
goto out;
}
}
+#if defined(__FreeBSD__)
+ SCTP_PROBE5(receive, NULL, stcb, m, stcb, sh);
+#endif
if (stcb == NULL) {
/*
* no valid TCB for this packet, or we found it's a bad
@@ -5957,6 +5999,20 @@ sctp_common_input_processing(struct mbuf **mm, int iphlen, int offset, int lengt
*/
goto out;
}
+#if defined(__Userspace__)
+ if ((upcall_socket == NULL) &&
+ !(stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) &&
+ (stcb->sctp_socket != NULL)) {
+ if (stcb->sctp_socket->so_head != NULL) {
+ upcall_socket = stcb->sctp_socket->so_head;
+ } else {
+ upcall_socket = stcb->sctp_socket;
+ }
+ SOCK_LOCK(upcall_socket);
+ soref(upcall_socket);
+ SOCK_UNLOCK(upcall_socket);
+ }
+#endif
/*
* DATA chunk processing
@@ -5985,7 +6041,7 @@ sctp_common_input_processing(struct mbuf **mm, int iphlen, int offset, int lengt
* not get here unless we really did have a tag, so we don't
* abort if this happens, just dump the chunk silently.
*/
- switch (SCTP_GET_STATE(&stcb->asoc)) {
+ switch (SCTP_GET_STATE(stcb)) {
case SCTP_STATE_COOKIE_ECHOED:
/*
* we consider data with valid tags in this state
@@ -6095,6 +6151,20 @@ trigger_send:
if (stcb != NULL) {
SCTP_TCB_UNLOCK(stcb);
}
+#if defined(__Userspace__)
+ if (upcall_socket != NULL) {
+ if (upcall_socket->so_upcall != NULL) {
+ if (soreadable(upcall_socket) ||
+ sowriteable(upcall_socket) ||
+ upcall_socket->so_error) {
+ (*upcall_socket->so_upcall)(upcall_socket, upcall_socket->so_upcallarg, M_NOWAIT);
+ }
+ }
+ ACCEPT_LOCK();
+ SOCK_LOCK(upcall_socket);
+ sorele(upcall_socket);
+ }
+#endif
if (inp_decr != NULL) {
/* reduce ref-count */
SCTP_INP_WLOCK(inp_decr);
diff --git a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_os_userspace.h b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_os_userspace.h
index 8613301ab08..f09cb8da257 100755
--- a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_os_userspace.h
+++ b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_os_userspace.h
@@ -47,8 +47,8 @@
#include <winsock2.h>
#include <ws2tcpip.h>
#include <iphlpapi.h>
-#include <Mswsock.h>
-#include <Windows.h>
+#include <mswsock.h>
+#include <windows.h>
#include "user_environment.h"
typedef CRITICAL_SECTION userland_mutex_t;
#if WINVER < 0x0600
@@ -80,7 +80,7 @@ typedef HANDLE userland_thread_t;
#define IPVERSION 4
#define MAXTTL 255
/* VS2010 comes with stdint.h */
-#if _MSC_VER >= 1600
+#if !defined(_MSC_VER) || (_MSC_VER >= 1600)
#include <stdint.h>
#else
#define uint64_t unsigned __int64
@@ -105,8 +105,9 @@ typedef HANDLE userland_thread_t;
#define n_time unsigned __int32
#define sa_family_t unsigned __int8
#define ssize_t __int64
+#if !defined(__MINGW32__)
#define __func__ __FUNCTION__
-
+#endif
#ifndef EWOULDBLOCK
#define EWOULDBLOCK WSAEWOULDBLOCK
#endif
@@ -220,7 +221,7 @@ typedef char* caddr_t;
#define bzero(buf, len) memset(buf, 0, len)
#define bcopy(srcKey, dstKey, len) memcpy(dstKey, srcKey, len)
-#if _MSC_VER < 1900
+#if defined(_MSC_VER) && (_MSC_VER < 1900) && !defined(__MINGW32__)
#define snprintf(data, size, format, ...) _snprintf_s(data, size, _TRUNCATE, format, __VA_ARGS__)
#endif
#define inline __inline
@@ -562,11 +563,6 @@ struct sx {int dummy;};
SCTP_BASE_VAR(debug_printf)(__VA_ARGS__); \
}
-#if defined(__FreeBSD__)
-#ifndef in6pcb
-#define in6pcb inpcb
-#endif
-#endif
/* Declare all the malloc names for all the various mallocs */
MALLOC_DECLARE(SCTP_M_MAP);
MALLOC_DECLARE(SCTP_M_STRMI);
@@ -969,7 +965,7 @@ int sctp_userspace_get_mtu_from_ifn(uint32_t if_index, int af);
#define IPv6_HOP_LIMIT 128
/* is the endpoint v6only? */
-#define SCTP_IPV6_V6ONLY(inp) (((struct inpcb *)inp)->inp_flags & IN6P_IPV6_V6ONLY)
+#define SCTP_IPV6_V6ONLY(sctp_inpcb) ((sctp_inpcb)->ip_inp.inp.inp_flags & IN6P_IPV6_V6ONLY)
/* is the socket non-blocking? */
#define SCTP_SO_IS_NBIO(so) ((so)->so_state & SS_NBIO)
#define SCTP_SET_SO_NBIO(so) ((so)->so_state |= SS_NBIO)
@@ -1077,7 +1073,7 @@ extern void sctp_userspace_ip6_output(int *result, struct mbuf *o_pak,
{ \
if (stcb && stcb->sctp_ep) \
result = ip6_output(o_pak, \
- ((struct in6pcb *)(stcb->sctp_ep))->in6p_outputopts, \
+ ((struct inpcb *)(stcb->sctp_ep))->in6p_outputopts, \
(ro), 0, 0, ifp, NULL); \
else \
result = ip6_output(o_pak, NULL, (ro), 0, 0, ifp, NULL); \
@@ -1159,4 +1155,9 @@ sctp_get_mbuf_for_msg(unsigned int space_needed, int want_header, int how, int a
#define SCTP_IS_LISTENING(inp) ((inp->sctp_flags & SCTP_PCB_FLAGS_ACCEPTING) != 0)
+#if defined(__Userspace_os_Darwin) || defined(__Userspace_os_DragonFly) || defined(__Userspace_os_Linux) || defined(__Userspace_os_NaCl) || defined(__Userspace_os_NetBSD) || defined(__Userspace_os_Windows) || defined(__Userspace_os_Fuchsia)
+int
+timingsafe_bcmp(const void *, const void *, size_t);
+#endif
+
#endif
diff --git a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_output.c b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_output.c
index e29a727fadd..acc7307b9a4 100755
--- a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_output.c
+++ b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_output.c
@@ -34,7 +34,7 @@
#ifdef __FreeBSD__
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/netinet/sctp_output.c 335179 2018-06-14 21:30:52Z tuexen $");
+__FBSDID("$FreeBSD: head/sys/netinet/sctp_output.c 357197 2020-01-28 10:09:05Z tuexen $");
#endif
#include <netinet/sctp_os.h>
@@ -56,6 +56,9 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_output.c 335179 2018-06-14 21:30:52Z t
#include <netinet/sctp_bsd_addr.h>
#include <netinet/sctp_input.h>
#include <netinet/sctp_crc32.h>
+#if defined(__FreeBSD__)
+#include <netinet/sctp_kdtrace.h>
+#endif
#if defined(__Userspace_os_Linux)
#define __FAVOR_BSD /* (on Ubuntu at least) enables UDP header field names like BSD in RFC 768 */
#endif
@@ -3673,7 +3676,6 @@ sctp_process_cmsgs_for_init(struct sctp_tcb *stcb, struct mbuf *control, int *er
#else
struct cmsghdr cmh;
#endif
- int tlen, at;
struct sctp_initmsg initmsg;
#ifdef INET
struct sockaddr_in sin;
@@ -3681,34 +3683,37 @@ sctp_process_cmsgs_for_init(struct sctp_tcb *stcb, struct mbuf *control, int *er
#ifdef INET6
struct sockaddr_in6 sin6;
#endif
+ int tot_len, rem_len, cmsg_data_len, cmsg_data_off, off;
- tlen = SCTP_BUF_LEN(control);
- at = 0;
- while (at < tlen) {
- if ((tlen - at) < (int)CMSG_ALIGN(sizeof(cmh))) {
+ tot_len = SCTP_BUF_LEN(control);
+ for (off = 0; off < tot_len; off += CMSG_ALIGN(cmh.cmsg_len)) {
+ rem_len = tot_len - off;
+ if (rem_len < (int)CMSG_ALIGN(sizeof(cmh))) {
/* There is not enough room for one more. */
*error = EINVAL;
return (1);
}
- m_copydata(control, at, sizeof(cmh), (caddr_t)&cmh);
+ m_copydata(control, off, sizeof(cmh), (caddr_t)&cmh);
if (cmh.cmsg_len < CMSG_ALIGN(sizeof(cmh))) {
/* We dont't have a complete CMSG header. */
*error = EINVAL;
return (1);
}
- if (((int)cmh.cmsg_len + at) > tlen) {
+ if ((cmh.cmsg_len > INT_MAX) || ((int)cmh.cmsg_len > rem_len)) {
/* We don't have the complete CMSG. */
*error = EINVAL;
return (1);
}
+ cmsg_data_len = (int)cmh.cmsg_len - CMSG_ALIGN(sizeof(cmh));
+ cmsg_data_off = off + CMSG_ALIGN(sizeof(cmh));
if (cmh.cmsg_level == IPPROTO_SCTP) {
switch (cmh.cmsg_type) {
case SCTP_INIT:
- if ((size_t)(cmh.cmsg_len - CMSG_ALIGN(sizeof(cmh))) < sizeof(struct sctp_initmsg)) {
+ if (cmsg_data_len < (int)sizeof(struct sctp_initmsg)) {
*error = EINVAL;
return (1);
}
- m_copydata(control, at + CMSG_ALIGN(sizeof(cmh)), sizeof(struct sctp_initmsg), (caddr_t)&initmsg);
+ m_copydata(control, cmsg_data_off, sizeof(struct sctp_initmsg), (caddr_t)&initmsg);
if (initmsg.sinit_max_attempts)
stcb->asoc.max_init_times = initmsg.sinit_max_attempts;
if (initmsg.sinit_num_ostreams)
@@ -3763,7 +3768,7 @@ sctp_process_cmsgs_for_init(struct sctp_tcb *stcb, struct mbuf *control, int *er
break;
#ifdef INET
case SCTP_DSTADDRV4:
- if ((size_t)(cmh.cmsg_len - CMSG_ALIGN(sizeof(cmh))) < sizeof(struct in_addr)) {
+ if (cmsg_data_len < (int)sizeof(struct in_addr)) {
*error = EINVAL;
return (1);
}
@@ -3773,7 +3778,7 @@ sctp_process_cmsgs_for_init(struct sctp_tcb *stcb, struct mbuf *control, int *er
sin.sin_len = sizeof(struct sockaddr_in);
#endif
sin.sin_port = stcb->rport;
- m_copydata(control, at + CMSG_ALIGN(sizeof(cmh)), sizeof(struct in_addr), (caddr_t)&sin.sin_addr);
+ m_copydata(control, cmsg_data_off, sizeof(struct in_addr), (caddr_t)&sin.sin_addr);
if ((sin.sin_addr.s_addr == INADDR_ANY) ||
(sin.sin_addr.s_addr == INADDR_BROADCAST) ||
IN_MULTICAST(ntohl(sin.sin_addr.s_addr))) {
@@ -3789,7 +3794,7 @@ sctp_process_cmsgs_for_init(struct sctp_tcb *stcb, struct mbuf *control, int *er
#endif
#ifdef INET6
case SCTP_DSTADDRV6:
- if ((size_t)(cmh.cmsg_len - CMSG_ALIGN(sizeof(cmh))) < sizeof(struct in6_addr)) {
+ if (cmsg_data_len < (int)sizeof(struct in6_addr)) {
*error = EINVAL;
return (1);
}
@@ -3799,7 +3804,7 @@ sctp_process_cmsgs_for_init(struct sctp_tcb *stcb, struct mbuf *control, int *er
sin6.sin6_len = sizeof(struct sockaddr_in6);
#endif
sin6.sin6_port = stcb->rport;
- m_copydata(control, at + CMSG_ALIGN(sizeof(cmh)), sizeof(struct in6_addr), (caddr_t)&sin6.sin6_addr);
+ m_copydata(control, cmsg_data_off, sizeof(struct in6_addr), (caddr_t)&sin6.sin6_addr);
if (IN6_IS_ADDR_UNSPECIFIED(&sin6.sin6_addr) ||
IN6_IS_ADDR_MULTICAST(&sin6.sin6_addr)) {
*error = EINVAL;
@@ -3832,11 +3837,11 @@ sctp_process_cmsgs_for_init(struct sctp_tcb *stcb, struct mbuf *control, int *er
break;
}
}
- at += CMSG_ALIGN(cmh.cmsg_len);
}
return (0);
}
+#if defined(INET) || defined(INET6)
static struct sctp_tcb *
sctp_findassociation_cmsgs(struct sctp_inpcb **inp_p,
uint16_t port,
@@ -3849,7 +3854,6 @@ sctp_findassociation_cmsgs(struct sctp_inpcb **inp_p,
#else
struct cmsghdr cmh;
#endif
- int tlen, at;
struct sctp_tcb *stcb;
struct sockaddr *addr;
#ifdef INET
@@ -3858,31 +3862,34 @@ sctp_findassociation_cmsgs(struct sctp_inpcb **inp_p,
#ifdef INET6
struct sockaddr_in6 sin6;
#endif
+ int tot_len, rem_len, cmsg_data_len, cmsg_data_off, off;
- tlen = SCTP_BUF_LEN(control);
- at = 0;
- while (at < tlen) {
- if ((tlen - at) < (int)CMSG_ALIGN(sizeof(cmh))) {
+ tot_len = SCTP_BUF_LEN(control);
+ for (off = 0; off < tot_len; off += CMSG_ALIGN(cmh.cmsg_len)) {
+ rem_len = tot_len - off;
+ if (rem_len < (int)CMSG_ALIGN(sizeof(cmh))) {
/* There is not enough room for one more. */
*error = EINVAL;
return (NULL);
}
- m_copydata(control, at, sizeof(cmh), (caddr_t)&cmh);
+ m_copydata(control, off, sizeof(cmh), (caddr_t)&cmh);
if (cmh.cmsg_len < CMSG_ALIGN(sizeof(cmh))) {
/* We dont't have a complete CMSG header. */
*error = EINVAL;
return (NULL);
}
- if (((int)cmh.cmsg_len + at) > tlen) {
+ if ((cmh.cmsg_len > INT_MAX) || ((int)cmh.cmsg_len > rem_len)) {
/* We don't have the complete CMSG. */
*error = EINVAL;
return (NULL);
}
+ cmsg_data_len = (int)cmh.cmsg_len - CMSG_ALIGN(sizeof(cmh));
+ cmsg_data_off = off + CMSG_ALIGN(sizeof(cmh));
if (cmh.cmsg_level == IPPROTO_SCTP) {
switch (cmh.cmsg_type) {
#ifdef INET
case SCTP_DSTADDRV4:
- if ((size_t)(cmh.cmsg_len - CMSG_ALIGN(sizeof(cmh))) < sizeof(struct in_addr)) {
+ if (cmsg_data_len < (int)sizeof(struct in_addr)) {
*error = EINVAL;
return (NULL);
}
@@ -3892,13 +3899,13 @@ sctp_findassociation_cmsgs(struct sctp_inpcb **inp_p,
sin.sin_len = sizeof(struct sockaddr_in);
#endif
sin.sin_port = port;
- m_copydata(control, at + CMSG_ALIGN(sizeof(cmh)), sizeof(struct in_addr), (caddr_t)&sin.sin_addr);
+ m_copydata(control, cmsg_data_off, sizeof(struct in_addr), (caddr_t)&sin.sin_addr);
addr = (struct sockaddr *)&sin;
break;
#endif
#ifdef INET6
case SCTP_DSTADDRV6:
- if ((size_t)(cmh.cmsg_len - CMSG_ALIGN(sizeof(cmh))) < sizeof(struct in6_addr)) {
+ if (cmsg_data_len < (int)sizeof(struct in6_addr)) {
*error = EINVAL;
return (NULL);
}
@@ -3908,7 +3915,7 @@ sctp_findassociation_cmsgs(struct sctp_inpcb **inp_p,
sin6.sin6_len = sizeof(struct sockaddr_in6);
#endif
sin6.sin6_port = port;
- m_copydata(control, at + CMSG_ALIGN(sizeof(cmh)), sizeof(struct in6_addr), (caddr_t)&sin6.sin6_addr);
+ m_copydata(control, cmsg_data_off, sizeof(struct in6_addr), (caddr_t)&sin6.sin6_addr);
#ifdef INET
if (IN6_IS_ADDR_V4MAPPED(&sin6.sin6_addr)) {
in6_sin6_2_sin(&sin, &sin6);
@@ -3929,10 +3936,10 @@ sctp_findassociation_cmsgs(struct sctp_inpcb **inp_p,
}
}
}
- at += CMSG_ALIGN(cmh.cmsg_len);
}
return (NULL);
}
+#endif
static struct mbuf *
sctp_add_cookie(struct mbuf *init, int init_offset,
@@ -4447,6 +4454,9 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp,
SCTP_SOCKET_UNLOCK(so, 0);
}
#endif
+#if defined(__FreeBSD__)
+ SCTP_PROBE5(send, NULL, stcb, ip, stcb, sctphdr);
+#endif
SCTP_IP_OUTPUT(ret, o_pak, ro, stcb, vrf_id);
#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING)
if ((SCTP_BASE_SYSCTL(sctp_output_unlocked)) && (so_locked)) {
@@ -4457,6 +4467,11 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp,
atomic_subtract_int(&stcb->asoc.refcnt, 1);
}
#endif
+#if defined(__FreeBSD__)
+ if (port) {
+ UDPSTAT_INC(udps_opackets);
+ }
+#endif
SCTP_STAT_INCR(sctps_sendpackets);
SCTP_STAT_INCR_COUNTER64(sctps_outpackets);
if (ret)
@@ -4483,10 +4498,12 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp,
if (net->port) {
mtu -= sizeof(struct udphdr);
}
- if ((stcb != NULL) && (stcb->asoc.smallest_mtu > mtu)) {
- sctp_mtu_size_reset(inp, &stcb->asoc, mtu);
+ if (mtu < net->mtu) {
+ if ((stcb != NULL) && (stcb->asoc.smallest_mtu > mtu)) {
+ sctp_mtu_size_reset(inp, &stcb->asoc, mtu);
+ }
+ net->mtu = mtu;
}
- net->mtu = mtu;
}
} else if (ro->ro_rt == NULL) {
/* route was freed */
@@ -4534,7 +4551,7 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp,
#if defined(__APPLE__) && (!defined(APPLE_LEOPARD) && !defined(APPLE_SNOWLEOPARD) && !defined(APPLE_LION) && !defined(APPLE_MOUNTAINLION))
flowlabel = ntohl(inp->ip_inp.inp.inp_flow);
#else
- flowlabel = ntohl(((struct in6pcb *)inp)->in6p_flowinfo);
+ flowlabel = ntohl(((struct inpcb *)inp)->inp_flow);
#endif
}
flowlabel &= 0x000fffff;
@@ -4584,6 +4601,7 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp,
#endif
{
SCTP_LTRACE_ERR_RET_PKT(m, inp, stcb, net, SCTP_FROM_SCTP_OUTPUT, EINVAL);
+ sctp_m_freem(m);
return (EINVAL);
}
#endif /* SCTP_EMBEDDED_V6_SCOPE */
@@ -4611,7 +4629,7 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp,
#if defined(__APPLE__) && (!defined(APPLE_LEOPARD) && !defined(APPLE_SNOWLEOPARD) && !defined(APPLE_LION) && !defined(APPLE_MOUNTAINLION))
tos_value = (ntohl(inp->ip_inp.inp.inp_flow) >> 20) & 0xff;
#else
- tos_value = (ntohl(((struct in6pcb *)inp)->in6p_flowinfo) >> 20) & 0xff;
+ tos_value = (ntohl(((struct inpcb *)inp)->inp_flow) >> 20) & 0xff;
#endif
#endif
}
@@ -4630,7 +4648,7 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp,
} else {
ip6h->ip6_nxt = IPPROTO_SCTP;
}
- ip6h->ip6_plen = htons(packet_length - sizeof(struct ip6_hdr));
+ ip6h->ip6_plen = htons((uint16_t)(packet_length - sizeof(struct ip6_hdr)));
ip6h->ip6_dst = sin6->sin6_addr;
/*
@@ -4671,6 +4689,7 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp,
#endif
{
SCTP_LTRACE_ERR_RET_PKT(m, inp, stcb, net, SCTP_FROM_SCTP_OUTPUT, EINVAL);
+ sctp_m_freem(m);
return (EINVAL);
}
#endif /* SCTP_EMBEDDED_V6_SCOPE */
@@ -4716,6 +4735,7 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp,
#endif
{
SCTP_LTRACE_ERR_RET_PKT(m, inp, stcb, net, SCTP_FROM_SCTP_OUTPUT, EINVAL);
+ sctp_m_freem(m);
return (EINVAL);
}
#endif /* SCTP_EMBEDDED_V6_SCOPE */
@@ -4891,6 +4911,9 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp,
sctp_packet_log(o_pak);
#endif
#if !(defined(__Panda__) || defined(__Userspace__))
+#if defined(__FreeBSD__)
+ SCTP_PROBE5(send, NULL, stcb, ip6h, stcb, sctphdr);
+#endif
SCTP_IP6_OUTPUT(ret, o_pak, (struct route_in6 *)ro, &ifp, stcb, vrf_id);
#else
SCTP_IP6_OUTPUT(ret, o_pak, (struct route_in6 *)ro, NULL, stcb, vrf_id);
@@ -4910,6 +4933,11 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp,
sin6->sin6_port = prev_port;
}
SCTPDBG(SCTP_DEBUG_OUTPUT3, "return from send is %d\n", ret);
+#if defined(__FreeBSD__)
+ if (port) {
+ UDPSTAT_INC(udps_opackets);
+ }
+#endif
SCTP_STAT_INCR(sctps_sendpackets);
SCTP_STAT_INCR_COUNTER64(sctps_outpackets);
if (ret) {
@@ -4945,10 +4973,12 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp,
if (net->port) {
mtu -= sizeof(struct udphdr);
}
- if ((stcb != NULL) && (stcb->asoc.smallest_mtu > mtu)) {
- sctp_mtu_size_reset(inp, &stcb->asoc, mtu);
+ if (mtu < net->mtu) {
+ if ((stcb != NULL) && (stcb->asoc.smallest_mtu > mtu)) {
+ sctp_mtu_size_reset(inp, &stcb->asoc, mtu);
+ }
+ net->mtu = mtu;
}
- net->mtu = mtu;
}
}
#if !defined(__Panda__) && !defined(__Userspace__)
@@ -5330,7 +5360,10 @@ sctp_send_initiate(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int so_locked
struct mbuf *
sctp_arethere_unrecognized_parameters(struct mbuf *in_initpkt,
- int param_offset, int *abort_processing, struct sctp_chunkhdr *cp, int *nat_friendly)
+ int param_offset, int *abort_processing,
+ struct sctp_chunkhdr *cp,
+ int *nat_friendly,
+ int *cookie_found)
{
/*
* Given a mbuf containing an INIT or INIT-ACK with the param_offset
@@ -5348,18 +5381,20 @@ sctp_arethere_unrecognized_parameters(struct mbuf *in_initpkt,
*/
struct sctp_paramhdr *phdr, params;
- struct mbuf *mat, *op_err;
- char tempbuf[SCTP_PARAM_BUFFER_SIZE];
+ struct mbuf *mat, *m_tmp, *op_err, *op_err_last;
int at, limit, pad_needed;
uint16_t ptype, plen, padded_size;
- int err_at;
*abort_processing = 0;
+ if (cookie_found != NULL) {
+ *cookie_found = 0;
+ }
mat = in_initpkt;
- err_at = 0;
limit = ntohs(cp->chunk_length) - sizeof(struct sctp_init_chunk);
at = param_offset;
op_err = NULL;
+ op_err_last = NULL;
+ pad_needed = 0;
SCTPDBG(SCTP_DEBUG_OUTPUT1, "Check for unrecognized param's\n");
phdr = sctp_get_next_param(mat, at, &params, sizeof(params));
while ((phdr != NULL) && ((size_t)limit >= sizeof(struct sctp_paramhdr))) {
@@ -5382,12 +5417,17 @@ sctp_arethere_unrecognized_parameters(struct mbuf *in_initpkt,
switch (ptype) {
/* Param's with variable size */
case SCTP_HEARTBEAT_INFO:
- case SCTP_STATE_COOKIE:
case SCTP_UNRECOG_PARAM:
case SCTP_ERROR_CAUSE_IND:
/* ok skip fwd */
at += padded_size;
break;
+ case SCTP_STATE_COOKIE:
+ if (cookie_found != NULL) {
+ *cookie_found = 1;
+ }
+ at += padded_size;
+ break;
/* Param's with variable size within a range */
case SCTP_CHUNK_LIST:
case SCTP_SUPPORTED_CHUNK_EXT:
@@ -5476,67 +5516,45 @@ sctp_arethere_unrecognized_parameters(struct mbuf *in_initpkt,
break;
case SCTP_HOSTNAME_ADDRESS:
{
- /* We can NOT handle HOST NAME addresses!! */
+ /* Hostname parameters are deprecated. */
+ struct sctp_gen_error_cause *cause;
int l_len;
SCTPDBG(SCTP_DEBUG_OUTPUT1, "Can't handle hostname addresses.. abort processing\n");
*abort_processing = 1;
- if (op_err == NULL) {
- /* Ok need to try to get a mbuf */
+ sctp_m_freem(op_err);
+ op_err = NULL;
+ op_err_last = NULL;
#ifdef INET6
- l_len = SCTP_MIN_OVERHEAD;
+ l_len = SCTP_MIN_OVERHEAD;
#else
- l_len = SCTP_MIN_V4_OVERHEAD;
-#endif
- l_len += sizeof(struct sctp_chunkhdr);
- l_len += plen;
- l_len += sizeof(struct sctp_paramhdr);
- op_err = sctp_get_mbuf_for_msg(l_len, 0, M_NOWAIT, 1, MT_DATA);
- if (op_err) {
- SCTP_BUF_LEN(op_err) = 0;
- /*
- * pre-reserve space for ip and sctp
- * header and chunk hdr
- */
+ l_len = SCTP_MIN_V4_OVERHEAD;
+#endif
+ l_len += sizeof(struct sctp_chunkhdr);
+ l_len += sizeof(struct sctp_gen_error_cause);
+ op_err = sctp_get_mbuf_for_msg(l_len, 0, M_NOWAIT, 1, MT_DATA);
+ if (op_err != NULL) {
+ /*
+ * Pre-reserve space for IP, SCTP, and
+ * chunk header.
+ */
#ifdef INET6
- SCTP_BUF_RESV_UF(op_err, sizeof(struct ip6_hdr));
+ SCTP_BUF_RESV_UF(op_err, sizeof(struct ip6_hdr));
#else
- SCTP_BUF_RESV_UF(op_err, sizeof(struct ip));
-#endif
- SCTP_BUF_RESV_UF(op_err, sizeof(struct sctphdr));
- SCTP_BUF_RESV_UF(op_err, sizeof(struct sctp_chunkhdr));
- }
- }
- if (op_err) {
- /* If we have space */
- struct sctp_paramhdr s;
-
- if (err_at % 4) {
- uint32_t cpthis = 0;
-
- pad_needed = 4 - (err_at % 4);
- m_copyback(op_err, err_at, pad_needed, (caddr_t)&cpthis);
- err_at += pad_needed;
- }
- s.param_type = htons(SCTP_CAUSE_UNRESOLVABLE_ADDR);
- s.param_length = htons(sizeof(s) + plen);
- m_copyback(op_err, err_at, sizeof(s), (caddr_t)&s);
- err_at += sizeof(s);
- if (plen > sizeof(tempbuf)) {
- plen = sizeof(tempbuf);
- }
- phdr = sctp_get_next_param(mat, at, (struct sctp_paramhdr *)tempbuf, plen);
- if (phdr == NULL) {
+ SCTP_BUF_RESV_UF(op_err, sizeof(struct ip));
+#endif
+ SCTP_BUF_RESV_UF(op_err, sizeof(struct sctphdr));
+ SCTP_BUF_RESV_UF(op_err, sizeof(struct sctp_chunkhdr));
+ SCTP_BUF_LEN(op_err) = sizeof(struct sctp_gen_error_cause);
+ cause = mtod(op_err, struct sctp_gen_error_cause *);
+ cause->code = htons(SCTP_CAUSE_UNRESOLVABLE_ADDR);
+ cause->length = htons((uint16_t)(sizeof(struct sctp_gen_error_cause) + plen));
+ SCTP_BUF_NEXT(op_err) = SCTP_M_COPYM(mat, at, plen, M_NOWAIT);
+ if (SCTP_BUF_NEXT(op_err) == NULL) {
sctp_m_freem(op_err);
- /*
- * we are out of memory but we still
- * need to have a look at what to do
- * (the system is in trouble
- * though).
- */
- return (NULL);
+ op_err = NULL;
+ op_err_last = NULL;
}
- m_copyback(op_err, err_at, plen, (caddr_t)phdr);
}
return (op_err);
break;
@@ -5559,7 +5577,6 @@ sctp_arethere_unrecognized_parameters(struct mbuf *in_initpkt,
l_len = SCTP_MIN_V4_OVERHEAD;
#endif
l_len += sizeof(struct sctp_chunkhdr);
- l_len += plen;
l_len += sizeof(struct sctp_paramhdr);
op_err = sctp_get_mbuf_for_msg(l_len, 0, M_NOWAIT, 1, MT_DATA);
if (op_err) {
@@ -5571,41 +5588,55 @@ sctp_arethere_unrecognized_parameters(struct mbuf *in_initpkt,
#endif
SCTP_BUF_RESV_UF(op_err, sizeof(struct sctphdr));
SCTP_BUF_RESV_UF(op_err, sizeof(struct sctp_chunkhdr));
+ op_err_last = op_err;
}
}
- if (op_err) {
+ if (op_err != NULL) {
/* If we have space */
- struct sctp_paramhdr s;
-
- if (err_at % 4) {
- uint32_t cpthis = 0;
+ struct sctp_paramhdr *param;
- pad_needed = 4 - (err_at % 4);
- m_copyback(op_err, err_at, pad_needed, (caddr_t)&cpthis);
- err_at += pad_needed;
+ if (pad_needed > 0) {
+ op_err_last = sctp_add_pad_tombuf(op_err_last, pad_needed);
+ }
+ if (op_err_last == NULL) {
+ sctp_m_freem(op_err);
+ op_err = NULL;
+ op_err_last = NULL;
+ goto more_processing;
}
- s.param_type = htons(SCTP_UNRECOG_PARAM);
- s.param_length = htons(sizeof(s) + plen);
- m_copyback(op_err, err_at, sizeof(s), (caddr_t)&s);
- err_at += sizeof(s);
- if (plen > sizeof(tempbuf)) {
- plen = sizeof(tempbuf);
+ if (M_TRAILINGSPACE(op_err_last) < (int)sizeof(struct sctp_paramhdr)) {
+ m_tmp = sctp_get_mbuf_for_msg(sizeof(struct sctp_paramhdr), 0, M_NOWAIT, 1, MT_DATA);
+ if (m_tmp == NULL) {
+ sctp_m_freem(op_err);
+ op_err = NULL;
+ op_err_last = NULL;
+ goto more_processing;
+ }
+ SCTP_BUF_LEN(m_tmp) = 0;
+ SCTP_BUF_NEXT(m_tmp) = NULL;
+ SCTP_BUF_NEXT(op_err_last) = m_tmp;
+ op_err_last = m_tmp;
}
- phdr = sctp_get_next_param(mat, at, (struct sctp_paramhdr *)tempbuf, plen);
- if (phdr == NULL) {
+ param = (struct sctp_paramhdr *)(mtod(op_err_last, caddr_t) + SCTP_BUF_LEN(op_err_last));
+ param->param_type = htons(SCTP_UNRECOG_PARAM);
+ param->param_length = htons((uint16_t)sizeof(struct sctp_paramhdr) + plen);
+ SCTP_BUF_LEN(op_err_last) += sizeof(struct sctp_paramhdr);
+ SCTP_BUF_NEXT(op_err_last) = SCTP_M_COPYM(mat, at, plen, M_NOWAIT);
+ if (SCTP_BUF_NEXT(op_err_last) == NULL) {
sctp_m_freem(op_err);
- /*
- * we are out of memory but
- * we still need to have a
- * look at what to do (the
- * system is in trouble
- * though).
- */
op_err = NULL;
+ op_err_last = NULL;
goto more_processing;
+ } else {
+ while (SCTP_BUF_NEXT(op_err_last) != NULL) {
+ op_err_last = SCTP_BUF_NEXT(op_err_last);
+ }
+ }
+ if (plen % 4 != 0) {
+ pad_needed = 4 - (plen % 4);
+ } else {
+ pad_needed = 0;
}
- m_copyback(op_err, err_at, plen, (caddr_t)phdr);
- err_at += plen;
}
}
more_processing:
@@ -5626,7 +5657,11 @@ sctp_arethere_unrecognized_parameters(struct mbuf *in_initpkt,
invalid_size:
SCTPDBG(SCTP_DEBUG_OUTPUT1, "abort flag set\n");
*abort_processing = 1;
- if ((op_err == NULL) && phdr) {
+ sctp_m_freem(op_err);
+ op_err = NULL;
+ op_err_last = NULL;
+ if (phdr != NULL) {
+ struct sctp_paramhdr *param;
int l_len;
#ifdef INET6
l_len = SCTP_MIN_OVERHEAD;
@@ -5645,25 +5680,15 @@ sctp_arethere_unrecognized_parameters(struct mbuf *in_initpkt,
#endif
SCTP_BUF_RESV_UF(op_err, sizeof(struct sctphdr));
SCTP_BUF_RESV_UF(op_err, sizeof(struct sctp_chunkhdr));
+ SCTP_BUF_LEN(op_err) = 2 * sizeof(struct sctp_paramhdr);
+ param = mtod(op_err, struct sctp_paramhdr *);
+ param->param_type = htons(SCTP_CAUSE_PROTOCOL_VIOLATION);
+ param->param_length = htons(2 * sizeof(struct sctp_paramhdr));
+ param++;
+ param->param_type = htons(ptype);
+ param->param_length = htons(plen);
}
}
- if ((op_err) && phdr) {
- struct sctp_paramhdr s;
-
- if (err_at % 4) {
- uint32_t cpthis = 0;
-
- pad_needed = 4 - (err_at % 4);
- m_copyback(op_err, err_at, pad_needed, (caddr_t)&cpthis);
- err_at += pad_needed;
- }
- s.param_type = htons(SCTP_CAUSE_PROTOCOL_VIOLATION);
- s.param_length = htons(sizeof(s) + sizeof(struct sctp_paramhdr));
- m_copyback(op_err, err_at, sizeof(s), (caddr_t)&s);
- err_at += sizeof(s);
- /* Only copy back the p-hdr that caused the issue */
- m_copyback(op_err, err_at, sizeof(struct sctp_paramhdr), (caddr_t)phdr);
- }
return (op_err);
}
@@ -5939,7 +5964,7 @@ sctp_send_initiate_ack(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
asoc = NULL;
}
if ((asoc != NULL) &&
- (SCTP_GET_STATE(asoc) != SCTP_STATE_COOKIE_WAIT)) {
+ (SCTP_GET_STATE(stcb) != SCTP_STATE_COOKIE_WAIT)) {
if (sctp_are_there_new_addresses(asoc, init_pkt, offset, src)) {
/*
* new addresses, out of here in non-cookie-wait states
@@ -5978,8 +6003,10 @@ sctp_send_initiate_ack(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
}
abort_flag = 0;
op_err = sctp_arethere_unrecognized_parameters(init_pkt,
- (offset + sizeof(struct sctp_init_chunk)),
- &abort_flag, (struct sctp_chunkhdr *)init_chk, &nat_friendly);
+ (offset + sizeof(struct sctp_init_chunk)),
+ &abort_flag,
+ (struct sctp_chunkhdr *)init_chk,
+ &nat_friendly, NULL);
if (abort_flag) {
do_a_abort:
if (op_err == NULL) {
@@ -6000,8 +6027,7 @@ sctp_send_initiate_ack(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
m = sctp_get_mbuf_for_msg(MCLBYTES, 0, M_NOWAIT, 1, MT_DATA);
if (m == NULL) {
/* No memory, INIT timer will re-attempt. */
- if (op_err)
- sctp_m_freem(op_err);
+ sctp_m_freem(op_err);
return;
}
chunk_len = (uint16_t)sizeof(struct sctp_init_ack_chunk);
@@ -6228,8 +6254,11 @@ sctp_send_initiate_ack(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
net->ro._s_addr = sctp_source_address_selection(inp,
stcb, (sctp_route_t *)&net->ro,
net, 0, vrf_id);
- if (net->ro._s_addr == NULL)
+ if (net->ro._s_addr == NULL) {
+ sctp_m_freem(op_err);
+ sctp_m_freem(m);
return;
+ }
net->src_addr_selected = 1;
@@ -6258,8 +6287,11 @@ sctp_send_initiate_ack(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
net->ro._s_addr = sctp_source_address_selection(inp,
stcb, (sctp_route_t *)&net->ro,
net, 0, vrf_id);
- if (net->ro._s_addr == NULL)
+ if (net->ro._s_addr == NULL) {
+ sctp_m_freem(op_err);
+ sctp_m_freem(m);
return;
+ }
net->src_addr_selected = 1;
}
@@ -6303,9 +6335,9 @@ sctp_send_initiate_ack(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
initack->ch.chunk_length = 0;
/* place in my tag */
if ((asoc != NULL) &&
- ((SCTP_GET_STATE(asoc) == SCTP_STATE_COOKIE_WAIT) ||
- (SCTP_GET_STATE(asoc) == SCTP_STATE_INUSE) ||
- (SCTP_GET_STATE(asoc) == SCTP_STATE_COOKIE_ECHOED))) {
+ ((SCTP_GET_STATE(stcb) == SCTP_STATE_COOKIE_WAIT) ||
+ (SCTP_GET_STATE(stcb) == SCTP_STATE_INUSE) ||
+ (SCTP_GET_STATE(stcb) == SCTP_STATE_COOKIE_ECHOED))) {
/* re-use the v-tags and init-seq here */
initack->init.initiate_tag = htonl(asoc->my_vtag);
initack->init.initial_tsn = htonl(asoc->init_seq_number);
@@ -6347,6 +6379,7 @@ sctp_send_initiate_ack(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
so = inp->sctp_socket;
if (so == NULL) {
/* memory problem */
+ sctp_m_freem(op_err);
sctp_m_freem(m);
return;
} else {
@@ -6847,9 +6880,9 @@ sctp_msg_append(struct sctp_tcb *stcb,
}
strm = &stcb->asoc.strmout[srcv->sinfo_stream];
/* Now can we send this? */
- if ((SCTP_GET_STATE(&stcb->asoc) == SCTP_STATE_SHUTDOWN_SENT) ||
- (SCTP_GET_STATE(&stcb->asoc) == SCTP_STATE_SHUTDOWN_ACK_SENT) ||
- (SCTP_GET_STATE(&stcb->asoc) == SCTP_STATE_SHUTDOWN_RECEIVED) ||
+ if ((SCTP_GET_STATE(stcb) == SCTP_STATE_SHUTDOWN_SENT) ||
+ (SCTP_GET_STATE(stcb) == SCTP_STATE_SHUTDOWN_ACK_SENT) ||
+ (SCTP_GET_STATE(stcb) == SCTP_STATE_SHUTDOWN_RECEIVED) ||
(stcb->asoc.state & SCTP_STATE_SHUTDOWN_PENDING)) {
/* got data while shutting down */
SCTP_LTRACE_ERR_RET(NULL, stcb, NULL, SCTP_FROM_SCTP_OUTPUT, ECONNRESET);
@@ -7176,15 +7209,14 @@ sctp_sendall_iterator(struct sctp_inpcb *inp, struct sctp_tcb *stcb, void *ptr,
goto abort_anyway;
}
/* there is nothing queued to send, so I'm done... */
- if ((SCTP_GET_STATE(asoc) != SCTP_STATE_SHUTDOWN_SENT) &&
- (SCTP_GET_STATE(asoc) != SCTP_STATE_SHUTDOWN_RECEIVED) &&
- (SCTP_GET_STATE(asoc) != SCTP_STATE_SHUTDOWN_ACK_SENT)) {
+ if ((SCTP_GET_STATE(stcb) != SCTP_STATE_SHUTDOWN_SENT) &&
+ (SCTP_GET_STATE(stcb) != SCTP_STATE_SHUTDOWN_RECEIVED) &&
+ (SCTP_GET_STATE(stcb) != SCTP_STATE_SHUTDOWN_ACK_SENT)) {
/* only send SHUTDOWN the first time through */
- if (SCTP_GET_STATE(asoc) == SCTP_STATE_OPEN) {
+ if (SCTP_GET_STATE(stcb) == SCTP_STATE_OPEN) {
SCTP_STAT_DECR_GAUGE32(sctps_currestab);
}
- SCTP_SET_STATE(asoc, SCTP_STATE_SHUTDOWN_SENT);
- SCTP_CLEAR_SUBSTATE(asoc, SCTP_STATE_SHUTDOWN_PENDING);
+ SCTP_SET_STATE(stcb, SCTP_STATE_SHUTDOWN_SENT);
sctp_stop_timers_for_shutdown(stcb);
sctp_send_shutdown(stcb, net);
sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWN, stcb->sctp_ep, stcb,
@@ -7205,13 +7237,13 @@ sctp_sendall_iterator(struct sctp_inpcb *inp, struct sctp_tcb *stcb, void *ptr,
* data to be sent first and move to
* SHUTDOWN-PENDING
*/
- if ((SCTP_GET_STATE(asoc) != SCTP_STATE_SHUTDOWN_SENT) &&
- (SCTP_GET_STATE(asoc) != SCTP_STATE_SHUTDOWN_RECEIVED) &&
- (SCTP_GET_STATE(asoc) != SCTP_STATE_SHUTDOWN_ACK_SENT)) {
+ if ((SCTP_GET_STATE(stcb) != SCTP_STATE_SHUTDOWN_SENT) &&
+ (SCTP_GET_STATE(stcb) != SCTP_STATE_SHUTDOWN_RECEIVED) &&
+ (SCTP_GET_STATE(stcb) != SCTP_STATE_SHUTDOWN_ACK_SENT)) {
if ((*asoc->ss_functions.sctp_ss_is_user_msgs_incomplete)(stcb, asoc)) {
- asoc->state |= SCTP_STATE_PARTIAL_MSG_LEFT;
+ SCTP_ADD_SUBSTATE(stcb, SCTP_STATE_PARTIAL_MSG_LEFT);
}
- asoc->state |= SCTP_STATE_SHUTDOWN_PENDING;
+ SCTP_ADD_SUBSTATE(stcb, SCTP_STATE_SHUTDOWN_PENDING);
if (TAILQ_EMPTY(&asoc->send_queue) &&
TAILQ_EMPTY(&asoc->sent_queue) &&
(asoc->state & SCTP_STATE_PARTIAL_MSG_LEFT)) {
@@ -7279,15 +7311,19 @@ sctp_sendall_completes(void *ptr, uint32_t val SCTP_UNUSED)
*/
/* now free everything */
+ if (ca->inp) {
+ /* Lets clear the flag to allow others to run. */
+ ca->inp->sctp_flags &= ~SCTP_PCB_FLAGS_SND_ITERATOR_UP;
+ }
sctp_m_freem(ca->m);
SCTP_FREE(ca, SCTP_M_COPYAL);
}
static struct mbuf *
-sctp_copy_out_all(struct uio *uio, int len)
+sctp_copy_out_all(struct uio *uio, ssize_t len)
{
struct mbuf *ret, *at;
- int left, willcpy, cancpy, error;
+ ssize_t left, willcpy, cancpy, error;
ret = sctp_get_mbuf_for_msg(MCLBYTES, 0, M_WAITOK, 1, MT_DATA);
if (ret == NULL) {
@@ -7302,17 +7338,17 @@ sctp_copy_out_all(struct uio *uio, int len)
at = ret;
while (left > 0) {
/* Align data to the end */
- error = uiomove(mtod(at, caddr_t), willcpy, uio);
+ error = uiomove(mtod(at, caddr_t), (int)willcpy, uio);
if (error) {
err_out_now:
sctp_m_freem(at);
return (NULL);
}
- SCTP_BUF_LEN(at) = willcpy;
+ SCTP_BUF_LEN(at) = (int)willcpy;
SCTP_BUF_NEXT_PKT(at) = SCTP_BUF_NEXT(at) = 0;
left -= willcpy;
if (left > 0) {
- SCTP_BUF_NEXT(at) = sctp_get_mbuf_for_msg(left, 0, M_WAITOK, 1, MT_DATA);
+ SCTP_BUF_NEXT(at) = sctp_get_mbuf_for_msg((unsigned int)left, 0, M_WAITOK, 1, MT_DATA);
if (SCTP_BUF_NEXT(at) == NULL) {
goto err_out_now;
}
@@ -7332,6 +7368,22 @@ sctp_sendall(struct sctp_inpcb *inp, struct uio *uio, struct mbuf *m,
int ret;
struct sctp_copy_all *ca;
+ if (inp->sctp_flags & SCTP_PCB_FLAGS_SND_ITERATOR_UP) {
+ /* There is another. */
+ return (EBUSY);
+ }
+#if defined(__APPLE__)
+#if defined(APPLE_LEOPARD)
+ if (uio->uio_resid > SCTP_BASE_SYSCTL(sctp_sendall_limit)) {
+#else
+ if (uio_resid(uio) > SCTP_BASE_SYSCTL(sctp_sendall_limit)) {
+#endif
+#else
+ if (uio->uio_resid > (ssize_t)SCTP_BASE_SYSCTL(sctp_sendall_limit)) {
+#endif
+ /* You must not be larger than the limit! */
+ return (EMSGSIZE);
+ }
SCTP_MALLOC(ca, struct sctp_copy_all *, sizeof(struct sctp_copy_all),
SCTP_M_COPYAL);
if (ca == NULL) {
@@ -7359,7 +7411,7 @@ sctp_sendall(struct sctp_inpcb *inp, struct uio *uio, struct mbuf *m,
ca->sndlen = uio_resid(uio);
#endif
#else
- ca->sndlen = (int)uio->uio_resid;
+ ca->sndlen = uio->uio_resid;
#endif
#if defined(__APPLE__)
SCTP_SOCKET_UNLOCK(SCTP_INP_SO(inp), 0);
@@ -7382,13 +7434,14 @@ sctp_sendall(struct sctp_inpcb *inp, struct uio *uio, struct mbuf *m,
ca->sndlen += SCTP_BUF_LEN(mat);
}
}
+ inp->sctp_flags |= SCTP_PCB_FLAGS_SND_ITERATOR_UP;
ret = sctp_initiate_iterator(NULL, sctp_sendall_iterator, NULL,
SCTP_PCB_ANY_FLAGS, SCTP_PCB_ANY_FEATURES,
SCTP_ASOC_ANY_STATE,
(void *)ca, 0,
sctp_sendall_completes, inp, 1);
if (ret) {
- SCTP_PRINTF("Failed to initiate iterator for sendall\n");
+ inp->sctp_flags &= ~SCTP_PCB_FLAGS_SND_ITERATOR_UP;
SCTP_FREE(ca, SCTP_M_COPYAL);
SCTP_LTRACE_ERR_RET_PKT(m, inp, NULL, NULL, SCTP_FROM_SCTP_OUTPUT, EFAULT);
return (EFAULT);
@@ -7694,7 +7747,7 @@ one_more_time:
}
if ((sp->msg_is_complete) && (sp->length == 0)) {
if (sp->sender_all_done) {
- /* We are doing differed cleanup. Last
+ /* We are doing deferred cleanup. Last
* time through when we took all the data
* the sender_all_done was not set.
*/
@@ -8326,8 +8379,8 @@ sctp_med_chunk_output(struct sctp_inpcb *inp,
int bundle_at, ctl_cnt, no_data_chunks, eeor_mode;
unsigned int mtu, r_mtu, omtu, mx_mtu, to_out;
int tsns_sent = 0;
- uint32_t auth_offset = 0;
- struct sctp_auth_chunk *auth = NULL;
+ uint32_t auth_offset;
+ struct sctp_auth_chunk *auth;
uint16_t auth_keyid;
int override_ok = 1;
int skip_fill_up = 0;
@@ -8347,7 +8400,7 @@ sctp_med_chunk_output(struct sctp_inpcb *inp,
*reason_code = 0;
auth_keyid = stcb->asoc.authinfo.active_keyid;
if ((asoc->state & SCTP_STATE_SHUTDOWN_PENDING) ||
- (asoc->state & SCTP_STATE_SHUTDOWN_RECEIVED) ||
+ (SCTP_GET_STATE(stcb) == SCTP_STATE_SHUTDOWN_RECEIVED) ||
(sctp_is_feature_on(inp, SCTP_PCB_FLAGS_EXPLICIT_EOR))) {
eeor_mode = 1;
} else {
@@ -8525,6 +8578,8 @@ again_one_more_time:
}
bundle_at = 0;
endoutchain = outchain = NULL;
+ auth = NULL;
+ auth_offset = 0;
no_fragmentflg = 1;
one_chunk = 0;
if (net->dest_state & SCTP_ADDR_UNCONFIRMED) {
@@ -9117,8 +9172,8 @@ again_one_more_time:
omtu = 0;
break;
}
- if ((((SCTP_GET_STATE(asoc) == SCTP_STATE_OPEN) ||
- (SCTP_GET_STATE(asoc) == SCTP_STATE_SHUTDOWN_RECEIVED)) &&
+ if ((((SCTP_GET_STATE(stcb) == SCTP_STATE_OPEN) ||
+ (SCTP_GET_STATE(stcb) == SCTP_STATE_SHUTDOWN_RECEIVED)) &&
(skip_data_for_this_net == 0)) ||
(cookie)) {
TAILQ_FOREACH_SAFE(chk, &asoc->send_queue, sctp_next, nchk) {
@@ -9167,7 +9222,7 @@ again_one_more_time:
chk->flags |= CHUNK_FLAGS_FRAGMENT_OK;
}
if (SCTP_BASE_SYSCTL(sctp_enable_sack_immediately) &&
- ((asoc->state & SCTP_STATE_SHUTDOWN_PENDING) == SCTP_STATE_SHUTDOWN_PENDING)) {
+ (asoc->state & SCTP_STATE_SHUTDOWN_PENDING)) {
struct sctp_data_chunk *dchkh;
dchkh = mtod(chk->data, struct sctp_data_chunk *);
@@ -9454,14 +9509,15 @@ sctp_queue_op_err(struct sctp_tcb *stcb, struct mbuf *op_err)
return;
}
chk->copy_by_ref = 0;
+ chk->rec.chunk_id.id = SCTP_OPERATION_ERROR;
+ chk->rec.chunk_id.can_take_data = 0;
+ chk->flags = 0;
chk->send_size = (uint16_t)chunk_length;
chk->sent = SCTP_DATAGRAM_UNSENT;
chk->snd_count = 0;
chk->asoc = &stcb->asoc;
chk->data = op_err;
chk->whoTo = NULL;
- chk->rec.chunk_id.id = SCTP_OPERATION_ERROR;
- chk->rec.chunk_id.can_take_data = 0;
hdr = mtod(op_err, struct sctp_chunkhdr *);
hdr->chunk_type = SCTP_OPERATION_ERROR;
hdr->chunk_flags = 0;
@@ -9472,7 +9528,7 @@ sctp_queue_op_err(struct sctp_tcb *stcb, struct mbuf *op_err)
int
sctp_send_cookie_echo(struct mbuf *m,
- int offset,
+ int offset, int limit,
struct sctp_tcb *stcb,
struct sctp_nets *net)
{
@@ -9498,18 +9554,29 @@ sctp_send_cookie_echo(struct mbuf *m,
}
ptype = ntohs(phdr->param_type);
plen = ntohs(phdr->param_length);
+ if (plen < sizeof(struct sctp_paramhdr)) {
+ return (-6);
+ }
if (ptype == SCTP_STATE_COOKIE) {
int pad;
/* found the cookie */
- if ((pad = (plen % 4))) {
- plen += 4 - pad;
+ if (at + plen > limit) {
+ return (-7);
}
cookie = SCTP_M_COPYM(m, at, plen, M_NOWAIT);
if (cookie == NULL) {
/* No memory */
return (-2);
}
+ if ((pad = (plen % 4)) > 0) {
+ pad = 4 - pad;
+ }
+ if (pad > 0) {
+ if (sctp_pad_lastmbuf(cookie, pad, NULL) == NULL) {
+ return (-8);
+ }
+ }
#ifdef SCTP_MBUF_LOGGING
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) {
sctp_log_mbc(cookie, SCTP_MBUF_ICOPY);
@@ -9535,7 +9602,7 @@ sctp_send_cookie_echo(struct mbuf *m,
chk->rec.chunk_id.id = SCTP_COOKIE_ECHO;
chk->rec.chunk_id.can_take_data = 0;
chk->flags = CHUNK_FLAGS_FRAGMENT_OK;
- chk->send_size = plen;
+ chk->send_size = SCTP_SIZE32(plen);
chk->sent = SCTP_DATAGRAM_UNSENT;
chk->snd_count = 0;
chk->asoc = &stcb->asoc;
@@ -9561,7 +9628,6 @@ sctp_send_heartbeat_ack(struct sctp_tcb *stcb,
struct sctp_chunkhdr *chdr;
struct sctp_tmit_chunk *chk;
-
if (net == NULL)
/* must have a net pointer */
return;
@@ -9579,13 +9645,8 @@ sctp_send_heartbeat_ack(struct sctp_tcb *stcb,
chdr = mtod(outchain, struct sctp_chunkhdr *);
chdr->chunk_type = SCTP_HEARTBEAT_ACK;
chdr->chunk_flags = 0;
- if (chk_length % 4) {
- /* need pad */
- uint32_t cpthis = 0;
- int padlen;
-
- padlen = 4 - (chk_length % 4);
- m_copyback(outchain, chk_length, padlen, (caddr_t)&cpthis);
+ if (chk_length % 4 != 0) {
+ sctp_pad_lastmbuf(outchain, 4 - (chk_length % 4), NULL);
}
sctp_alloc_a_chunk(stcb, chk);
if (chk == NULL) {
@@ -9683,7 +9744,6 @@ sctp_send_shutdown_ack(struct sctp_tcb *stcb, struct sctp_nets *net)
chk->send_size = sizeof(struct sctp_chunkhdr);
chk->sent = SCTP_DATAGRAM_UNSENT;
chk->snd_count = 0;
- chk->flags = 0;
chk->asoc = &stcb->asoc;
chk->data = m_shutdown_ack;
chk->whoTo = net;
@@ -9738,7 +9798,6 @@ sctp_send_shutdown(struct sctp_tcb *stcb, struct sctp_nets *net)
chk->send_size = sizeof(struct sctp_shutdown_chunk);
chk->sent = SCTP_DATAGRAM_UNSENT;
chk->snd_count = 0;
- chk->flags = 0;
chk->asoc = &stcb->asoc;
chk->data = m_shutdown;
chk->whoTo = net;
@@ -10066,8 +10125,8 @@ sctp_chunk_retransmission(struct sctp_inpcb *inp,
if (TAILQ_EMPTY(&asoc->sent_queue)) {
return (SCTP_RETRAN_DONE);
}
- if ((SCTP_GET_STATE(asoc) == SCTP_STATE_COOKIE_ECHOED) ||
- (SCTP_GET_STATE(asoc) == SCTP_STATE_COOKIE_WAIT)) {
+ if ((SCTP_GET_STATE(stcb) == SCTP_STATE_COOKIE_ECHOED) ||
+ (SCTP_GET_STATE(stcb) == SCTP_STATE_COOKIE_WAIT)) {
/* not yet open, resend the cookie and that is it */
return (1);
}
@@ -11893,13 +11952,16 @@ sctp_send_resp_msg(struct sockaddr *src, struct sockaddr *dst,
ro.ro_rt = NULL;
}
#else
+#if defined(__FreeBSD__)
+ SCTP_PROBE5(send, NULL, NULL, ip, NULL, shout);
+#endif
SCTP_IP_OUTPUT(ret, o_pak, NULL, NULL, vrf_id);
#endif
break;
#endif
#ifdef INET6
case AF_INET6:
- ip6->ip6_plen = htons(len - sizeof(struct ip6_hdr));
+ ip6->ip6_plen = htons((uint16_t)(len - sizeof(struct ip6_hdr)));
if (port) {
shout->checksum = sctp_calculate_cksum(mout, sizeof(struct ip6_hdr) + sizeof(struct udphdr));
SCTP_STAT_INCR(sctps_sendswcrc);
@@ -11929,6 +11991,9 @@ sctp_send_resp_msg(struct sockaddr *src, struct sockaddr *dst,
sctp_packet_log(o_pak);
}
#endif
+#if defined(__FreeBSD__)
+ SCTP_PROBE5(send, NULL, NULL, ip6, NULL, shout);
+#endif
SCTP_IP6_OUTPUT(ret, o_pak, NULL, NULL, NULL, vrf_id);
break;
#endif
@@ -11970,6 +12035,11 @@ sctp_send_resp_msg(struct sockaddr *src, struct sockaddr *dst,
return;
}
SCTPDBG(SCTP_DEBUG_OUTPUT3, "return from send is %d\n", ret);
+#if defined(__FreeBSD__)
+ if (port) {
+ UDPSTAT_INC(udps_opackets);
+ }
+#endif
SCTP_STAT_INCR(sctps_sendpackets);
SCTP_STAT_INCR_COUNTER64(sctps_outpackets);
SCTP_STAT_INCR_COUNTER64(sctps_outcontrolchunks);
@@ -12240,7 +12310,7 @@ sctp_send_packet_dropped(struct sctp_tcb *stcb, struct sctp_nets *net,
chk->flags = 0;
len -= iphlen;
chk->send_size = len;
- /* Validate that we do not have an ABORT in here. */
+ /* Validate that we do not have an ABORT in here. */
offset = iphlen + sizeof(struct sctphdr);
ch = (struct sctp_chunkhdr *)sctp_m_getptr(m, offset,
sizeof(*ch), (uint8_t *) & chunk_buf);
@@ -12866,7 +12936,6 @@ sctp_send_str_reset_req(struct sctp_tcb *stcb,
chk->book_size = sizeof(struct sctp_chunkhdr);
chk->send_size = SCTP_SIZE32(chk->book_size);
chk->book_size_scale = 0;
-
chk->data = sctp_get_mbuf_for_msg(MCLBYTES, 0, M_NOWAIT, 1, MT_DATA);
if (chk->data == NULL) {
sctp_free_a_chunk(stcb, chk, SCTP_SO_LOCKED);
@@ -13232,7 +13301,7 @@ sctp_copy_it_in(struct sctp_tcb *stcb,
struct sctp_sndrcvinfo *srcv,
struct uio *uio,
struct sctp_nets *net,
- int max_send_len,
+ ssize_t max_send_len,
int user_marks_eor,
int *error)
@@ -13249,9 +13318,9 @@ sctp_copy_it_in(struct sctp_tcb *stcb,
*error = 0;
/* Now can we send this? */
- if ((SCTP_GET_STATE(asoc) == SCTP_STATE_SHUTDOWN_SENT) ||
- (SCTP_GET_STATE(asoc) == SCTP_STATE_SHUTDOWN_ACK_SENT) ||
- (SCTP_GET_STATE(asoc) == SCTP_STATE_SHUTDOWN_RECEIVED) ||
+ if ((SCTP_GET_STATE(stcb) == SCTP_STATE_SHUTDOWN_SENT) ||
+ (SCTP_GET_STATE(stcb) == SCTP_STATE_SHUTDOWN_ACK_SENT) ||
+ (SCTP_GET_STATE(stcb) == SCTP_STATE_SHUTDOWN_RECEIVED) ||
(asoc->state & SCTP_STATE_SHUTDOWN_PENDING)) {
/* got data while shutting down */
SCTP_LTRACE_ERR_RET(NULL, stcb, NULL, SCTP_FROM_SCTP_OUTPUT, ECONNRESET);
@@ -13461,7 +13530,7 @@ sctp_lower_sosend(struct socket *so,
#endif
)
{
- unsigned int sndlen = 0, max_len;
+ ssize_t sndlen = 0, max_len, local_add_more;
int error, len;
struct mbuf *top = NULL;
#ifdef __Panda__
@@ -13486,7 +13555,7 @@ sctp_lower_sosend(struct socket *so,
int got_all_of_the_send = 0;
int hold_tcblock = 0;
int non_blocking = 0;
- uint32_t local_add_more, local_soresv = 0;
+ ssize_t local_soresv = 0;
uint16_t port;
uint16_t sinfo_flags;
sctp_assoc_t sinfo_assoc_id;
@@ -13529,12 +13598,12 @@ sctp_lower_sosend(struct socket *so,
}
#if defined(__APPLE__)
#if defined(APPLE_LEOPARD)
- sndlen = (unsigned int)uio->uio_resid;
+ sndlen = uio->uio_resid;
#else
- sndlen = (unsigned int)uio_resid(uio);
+ sndlen = uio_resid(uio);
#endif
#else
- sndlen = (unsigned int)uio->uio_resid;
+ sndlen = uio->uio_resid;
#endif
} else {
top = SCTP_HEADER_TO_CHAIN(i_pak);
@@ -13563,7 +13632,7 @@ sctp_lower_sosend(struct socket *so,
sndlen = SCTP_HEADER_LEN(i_pak);
#endif
}
- SCTPDBG(SCTP_DEBUG_OUTPUT1, "Send called addr:%p send length %d\n",
+ SCTPDBG(SCTP_DEBUG_OUTPUT1, "Send called addr:%p send length %zu\n",
(void *)addr,
sndlen);
#ifdef __Panda__
@@ -13644,6 +13713,14 @@ sctp_lower_sosend(struct socket *so,
sinfo_flags = inp->def_send.sinfo_flags;
sinfo_assoc_id = inp->def_send.sinfo_assoc_id;
}
+#if defined(__FreeBSD__)
+ if (flags & MSG_EOR) {
+ sinfo_flags |= SCTP_EOR;
+ }
+ if (flags & MSG_EOF) {
+ sinfo_flags |= SCTP_EOF;
+ }
+#endif
if (sinfo_flags & SCTP_SENDALL) {
/* its a sendall */
error = sctp_sendall(inp, uio, top, srcv);
@@ -13711,9 +13788,11 @@ sctp_lower_sosend(struct socket *so,
SCTP_INP_WUNLOCK(inp);
/* With the lock applied look again */
stcb = sctp_findassociation_ep_addr(&t_inp, addr, &net, NULL, NULL);
+#if defined(INET) || defined(INET6)
if ((stcb == NULL) && (control != NULL) && (port > 0)) {
stcb = sctp_findassociation_cmsgs(&t_inp, port, control, &net, &error);
}
+#endif
if (stcb == NULL) {
SCTP_INP_WLOCK(inp);
SCTP_INP_DECR_REF(inp);
@@ -13760,10 +13839,11 @@ sctp_lower_sosend(struct socket *so,
inp->sctp_ep.pre_open_stream_count,
inp->sctp_ep.port,
#if !(defined( __Panda__) || defined(__Userspace__))
- p);
+ p,
#else
- (struct proc *)NULL);
+ (struct proc *)NULL,
#endif
+ SCTP_INITIALIZE_AUTH_PARAMS);
if (stcb == NULL) {
/* Error is setup for us in the call */
goto out_unlocked;
@@ -13783,12 +13863,9 @@ sctp_lower_sosend(struct socket *so,
/* Turn on queue only flag to prevent data from being sent */
queue_only = 1;
asoc = &stcb->asoc;
- SCTP_SET_STATE(asoc, SCTP_STATE_COOKIE_WAIT);
+ SCTP_SET_STATE(stcb, SCTP_STATE_COOKIE_WAIT);
(void)SCTP_GETTIME_TIMEVAL(&asoc->time_entered);
- /* initialize authentication params for the assoc */
- sctp_initialize_auth_params(inp, stcb);
-
if (control) {
if (sctp_process_cmsgs_for_init(stcb, control, &error)) {
sctp_free_assoc(inp, stcb, SCTP_PCBFREE_FORCE,
@@ -13809,9 +13886,19 @@ sctp_lower_sosend(struct socket *so,
}
} else
asoc = &stcb->asoc;
- if (srcv == NULL)
+ if (srcv == NULL) {
srcv = (struct sctp_sndrcvinfo *)&asoc->def_send;
- if (srcv->sinfo_flags & SCTP_ADDR_OVER) {
+ sinfo_flags = srcv->sinfo_flags;
+#if defined(__FreeBSD__)
+ if (flags & MSG_EOR) {
+ sinfo_flags |= SCTP_EOR;
+ }
+ if (flags & MSG_EOF) {
+ sinfo_flags |= SCTP_EOF;
+ }
+#endif
+ }
+ if (sinfo_flags & SCTP_ADDR_OVER) {
if (addr)
net = sctp_findnet(stcb, addr);
else
@@ -13835,7 +13922,7 @@ sctp_lower_sosend(struct socket *so,
free_cnt_applied = 1;
if (sctp_is_feature_on(inp, SCTP_PCB_FLAGS_NO_FRAGMENT)) {
- if (sndlen > asoc->smallest_mtu) {
+ if (sndlen > (ssize_t)asoc->smallest_mtu) {
SCTP_LTRACE_ERR_RET(inp, stcb, net, SCTP_FROM_SCTP_OUTPUT, EMSGSIZE);
error = EMSGSIZE;
goto out_unlocked;
@@ -13848,14 +13935,14 @@ sctp_lower_sosend(struct socket *so,
#endif
if (SCTP_SO_IS_NBIO(so)
#if defined(__FreeBSD__) && __FreeBSD_version >= 500000
- || (flags & MSG_NBIO)
+ || (flags & (MSG_NBIO | MSG_DONTWAIT)) != 0
#endif
) {
non_blocking = 1;
}
/* would we block? */
if (non_blocking) {
- uint32_t amount;
+ ssize_t amount;
if (hold_tcblock == 0) {
SCTP_TCB_LOCK(stcb);
@@ -13870,13 +13957,13 @@ sctp_lower_sosend(struct socket *so,
if ((SCTP_SB_LIMIT_SND(so) < (amount + inqueue_bytes + stcb->asoc.sb_send_resv)) ||
(stcb->asoc.chunks_on_out_queue >= SCTP_BASE_SYSCTL(sctp_max_chunks_on_queue))) {
SCTP_LTRACE_ERR_RET(inp, stcb, net, SCTP_FROM_SCTP_OUTPUT, EWOULDBLOCK);
- if (sndlen > SCTP_SB_LIMIT_SND(so))
+ if (sndlen > (ssize_t)SCTP_SB_LIMIT_SND(so))
error = EMSGSIZE;
else
error = EWOULDBLOCK;
goto out_unlocked;
}
- stcb->asoc.sb_send_resv += sndlen;
+ stcb->asoc.sb_send_resv += (uint32_t)sndlen;
SCTP_TCB_UNLOCK(stcb);
hold_tcblock = 0;
} else {
@@ -13912,8 +13999,8 @@ sctp_lower_sosend(struct socket *so,
SCTP_LTRACE_ERR_RET(inp, stcb, net, SCTP_FROM_SCTP_OUTPUT, error);
goto out_unlocked;
}
- if ((SCTP_GET_STATE(asoc) == SCTP_STATE_COOKIE_WAIT) ||
- (SCTP_GET_STATE(asoc) == SCTP_STATE_COOKIE_ECHOED)) {
+ if ((SCTP_GET_STATE(stcb) == SCTP_STATE_COOKIE_WAIT) ||
+ (SCTP_GET_STATE(stcb) == SCTP_STATE_COOKIE_ECHOED)) {
queue_only = 1;
}
/* we are now done with all control */
@@ -13921,11 +14008,11 @@ sctp_lower_sosend(struct socket *so,
sctp_m_freem(control);
control = NULL;
}
- if ((SCTP_GET_STATE(asoc) == SCTP_STATE_SHUTDOWN_SENT) ||
- (SCTP_GET_STATE(asoc) == SCTP_STATE_SHUTDOWN_RECEIVED) ||
- (SCTP_GET_STATE(asoc) == SCTP_STATE_SHUTDOWN_ACK_SENT) ||
+ if ((SCTP_GET_STATE(stcb) == SCTP_STATE_SHUTDOWN_SENT) ||
+ (SCTP_GET_STATE(stcb) == SCTP_STATE_SHUTDOWN_RECEIVED) ||
+ (SCTP_GET_STATE(stcb) == SCTP_STATE_SHUTDOWN_ACK_SENT) ||
(asoc->state & SCTP_STATE_SHUTDOWN_PENDING)) {
- if (srcv->sinfo_flags & SCTP_ABORT) {
+ if (sinfo_flags & SCTP_ABORT) {
;
} else {
SCTP_LTRACE_ERR_RET(NULL, stcb, NULL, SCTP_FROM_SCTP_OUTPUT, ECONNRESET);
@@ -13946,13 +14033,13 @@ sctp_lower_sosend(struct socket *so,
}
#endif
/* Are we aborting? */
- if (srcv->sinfo_flags & SCTP_ABORT) {
+ if (sinfo_flags & SCTP_ABORT) {
struct mbuf *mm;
- int tot_demand, tot_out = 0, max_out;
+ ssize_t tot_demand, tot_out = 0, max_out;
SCTP_STAT_INCR(sctps_sends_with_abort);
- if ((SCTP_GET_STATE(asoc) == SCTP_STATE_COOKIE_WAIT) ||
- (SCTP_GET_STATE(asoc) == SCTP_STATE_COOKIE_ECHOED)) {
+ if ((SCTP_GET_STATE(stcb) == SCTP_STATE_COOKIE_WAIT) ||
+ (SCTP_GET_STATE(stcb) == SCTP_STATE_COOKIE_ECHOED)) {
/* It has to be up before we abort */
/* how big is the user initiated abort? */
SCTP_LTRACE_ERR_RET(inp, stcb, net, SCTP_FROM_SCTP_OUTPUT, EINVAL);
@@ -13982,7 +14069,7 @@ sctp_lower_sosend(struct socket *so,
error = EMSGSIZE;
goto out;
}
- mm = sctp_get_mbuf_for_msg(tot_demand, 0, M_WAITOK, 1, MT_DATA);
+ mm = sctp_get_mbuf_for_msg((unsigned int)tot_demand, 0, M_WAITOK, 1, MT_DATA);
}
if (mm == NULL) {
SCTP_LTRACE_ERR_RET(NULL, stcb, net, SCTP_FROM_SCTP_OUTPUT, ENOMEM);
@@ -14002,7 +14089,7 @@ sctp_lower_sosend(struct socket *so,
ph->param_type = htons(SCTP_CAUSE_USER_INITIATED_ABT);
ph->param_length = htons((uint16_t)(sizeof(struct sctp_paramhdr) + tot_out));
ph++;
- SCTP_BUF_LEN(mm) = tot_out + sizeof(struct sctp_paramhdr);
+ SCTP_BUF_LEN(mm) = (int)(tot_out + sizeof(struct sctp_paramhdr));
if (top == NULL) {
#if defined(__APPLE__)
SCTP_SOCKET_UNLOCK(so, 0);
@@ -14049,12 +14136,7 @@ sctp_lower_sosend(struct socket *so,
/* Calculate the maximum we can send */
inqueue_bytes = stcb->asoc.total_output_queue_size - (stcb->asoc.chunks_on_out_queue * SCTP_DATA_CHUNK_OVERHEAD(stcb));
if (SCTP_SB_LIMIT_SND(so) > inqueue_bytes) {
- if (non_blocking) {
- /* we already checked for non-blocking above. */
- max_len = sndlen;
- } else {
- max_len = SCTP_SB_LIMIT_SND(so) - inqueue_bytes;
- }
+ max_len = SCTP_SB_LIMIT_SND(so) - inqueue_bytes;
} else {
max_len = 0;
}
@@ -14071,7 +14153,7 @@ sctp_lower_sosend(struct socket *so,
/* Unless E_EOR mode is on, we must make a send FIT in one call. */
if ((user_marks_eor == 0) &&
- (sndlen > SCTP_SB_LIMIT_SND(stcb->sctp_socket))) {
+ (sndlen > (ssize_t)SCTP_SB_LIMIT_SND(stcb->sctp_socket))) {
/* It will NEVER fit */
SCTP_LTRACE_ERR_RET(NULL, stcb, net, SCTP_FROM_SCTP_OUTPUT, EMSGSIZE);
error = EMSGSIZE;
@@ -14088,7 +14170,7 @@ sctp_lower_sosend(struct socket *so,
}
if (user_marks_eor) {
- local_add_more = min(SCTP_SB_LIMIT_SND(so), SCTP_BASE_SYSCTL(sctp_add_more_threshold));
+ local_add_more = (ssize_t)min(SCTP_SB_LIMIT_SND(so), SCTP_BASE_SYSCTL(sctp_add_more_threshold));
} else {
/*-
* For non-eeor the whole message must fit in
@@ -14101,15 +14183,15 @@ sctp_lower_sosend(struct socket *so,
goto skip_preblock;
}
if (((max_len <= local_add_more) &&
- (SCTP_SB_LIMIT_SND(so) >= local_add_more)) ||
+ ((ssize_t)SCTP_SB_LIMIT_SND(so) >= local_add_more)) ||
(max_len == 0) ||
((stcb->asoc.chunks_on_out_queue+stcb->asoc.stream_queue_cnt) >= SCTP_BASE_SYSCTL(sctp_max_chunks_on_queue))) {
/* No room right now ! */
SOCKBUF_LOCK(&so->so_snd);
inqueue_bytes = stcb->asoc.total_output_queue_size - (stcb->asoc.chunks_on_out_queue * SCTP_DATA_CHUNK_OVERHEAD(stcb));
while ((SCTP_SB_LIMIT_SND(so) < (inqueue_bytes + local_add_more)) ||
- ((stcb->asoc.stream_queue_cnt+stcb->asoc.chunks_on_out_queue) >= SCTP_BASE_SYSCTL(sctp_max_chunks_on_queue))) {
- SCTPDBG(SCTP_DEBUG_OUTPUT1,"pre_block limit:%u <(inq:%d + %d) || (%d+%d > %d)\n",
+ ((stcb->asoc.stream_queue_cnt + stcb->asoc.chunks_on_out_queue) >= SCTP_BASE_SYSCTL(sctp_max_chunks_on_queue))) {
+ SCTPDBG(SCTP_DEBUG_OUTPUT1,"pre_block limit:%u <(inq:%d + %zd) || (%d+%d > %d)\n",
(unsigned int)SCTP_SB_LIMIT_SND(so),
inqueue_bytes,
local_add_more,
@@ -14166,7 +14248,7 @@ skip_preblock:
* NOTE: uio will be null when top/mbuf is passed
*/
if (sndlen == 0) {
- if (srcv->sinfo_flags & SCTP_EOF) {
+ if (sinfo_flags & SCTP_EOF) {
got_all_of_the_send = 1;
goto dataless_eof;
} else {
@@ -14214,7 +14296,7 @@ skip_preblock:
}
sctp_snd_sb_alloc(stcb, sp->length);
atomic_add_int(&asoc->stream_queue_cnt, 1);
- if (srcv->sinfo_flags & SCTP_UNORDERED) {
+ if (sinfo_flags & SCTP_UNORDERED) {
SCTP_STAT_INCR(sctps_sends_with_unord);
}
TAILQ_INSERT_TAIL(&strm->outqueue, sp, next);
@@ -14254,16 +14336,16 @@ skip_preblock:
else
max_len = 0;
- if ((max_len > SCTP_BASE_SYSCTL(sctp_add_more_threshold)) ||
+ if ((max_len > (ssize_t)SCTP_BASE_SYSCTL(sctp_add_more_threshold)) ||
(max_len && (SCTP_SB_LIMIT_SND(so) < SCTP_BASE_SYSCTL(sctp_add_more_threshold))) ||
#if defined(__APPLE__)
#if defined(APPLE_LEOPARD)
- (uio->uio_resid && (uio->uio_resid <= (int)max_len))) {
+ (uio->uio_resid && (uio->uio_resid <= max_len))) {
#else
- (uio_resid(uio) && (uio_resid(uio) <= (int)max_len))) {
+ (uio_resid(uio) && (uio_resid(uio) <= max_len))) {
#endif
#else
- (uio->uio_resid && (uio->uio_resid <= (int)max_len))) {
+ (uio->uio_resid && (uio->uio_resid <= max_len))) {
#endif
sndout = 0;
new_tail = NULL;
@@ -14275,9 +14357,9 @@ skip_preblock:
SCTP_SOCKET_UNLOCK(so, 0);
#endif
#if (defined(__FreeBSD__) && __FreeBSD_version > 602000) || defined(__Userspace__)
- mm = sctp_copy_resume(uio, max_len, user_marks_eor, &error, &sndout, &new_tail);
+ mm = sctp_copy_resume(uio, (int)max_len, user_marks_eor, &error, &sndout, &new_tail);
#else
- mm = sctp_copy_resume(uio, max_len, &error, &sndout, &new_tail);
+ mm = sctp_copy_resume(uio, (int)max_len, &error, &sndout, &new_tail);
#endif
#if defined(__APPLE__)
SCTP_SOCKET_LOCK(so, 0);
@@ -14314,7 +14396,7 @@ skip_preblock:
sctp_snd_sb_alloc(stcb, sndout);
atomic_add_int(&sp->length, sndout);
len += sndout;
- if (srcv->sinfo_flags & SCTP_SACK_IMMEDIATELY) {
+ if (sinfo_flags & SCTP_SACK_IMMEDIATELY) {
sp->sinfo_flags |= SCTP_SACK_IMMEDIATELY;
}
@@ -14329,8 +14411,8 @@ skip_preblock:
if ((uio->uio_resid == 0) &&
#endif
((user_marks_eor == 0) ||
- (srcv->sinfo_flags & SCTP_EOF) ||
- (user_marks_eor && (srcv->sinfo_flags & SCTP_EOR)))) {
+ (sinfo_flags & SCTP_EOF) ||
+ (user_marks_eor && (sinfo_flags & SCTP_EOR)))) {
sp->msg_is_complete = 1;
} else {
sp->msg_is_complete = 0;
@@ -14356,7 +14438,7 @@ skip_preblock:
SCTP_TCB_LOCK(stcb);
hold_tcblock = 1;
}
- sctp_prune_prsctp(stcb, asoc, srcv, sndlen);
+ sctp_prune_prsctp(stcb, asoc, srcv, (int)sndlen);
inqueue_bytes = stcb->asoc.total_output_queue_size - (stcb->asoc.chunks_on_out_queue * SCTP_DATA_CHUNK_OVERHEAD(stcb));
if (SCTP_SB_LIMIT_SND(so) > inqueue_bytes)
max_len = SCTP_SB_LIMIT_SND(so) - inqueue_bytes;
@@ -14379,12 +14461,12 @@ skip_preblock:
SCTP_TCB_LOCK(stcb);
hold_tcblock = 1;
}
- if (SCTP_GET_STATE(&stcb->asoc) == SCTP_STATE_OPEN) {
+ if (SCTP_GET_STATE(stcb) == SCTP_STATE_OPEN) {
/* a collision took us forward? */
queue_only = 0;
} else {
sctp_send_initiate(inp, stcb, SCTP_SO_LOCKED);
- SCTP_SET_STATE(asoc, SCTP_STATE_COOKIE_WAIT);
+ SCTP_SET_STATE(stcb, SCTP_STATE_COOKIE_WAIT);
queue_only = 1;
}
}
@@ -14453,10 +14535,10 @@ skip_preblock:
stcb,
SCTP_OUTPUT_FROM_USR_SEND, SCTP_SO_LOCKED);
}
- if (hold_tcblock == 1) {
- SCTP_TCB_UNLOCK(stcb);
- hold_tcblock = 0;
- }
+ }
+ if (hold_tcblock == 1) {
+ SCTP_TCB_UNLOCK(stcb);
+ hold_tcblock = 0;
}
SOCKBUF_LOCK(&so->so_snd);
/*-
@@ -14487,7 +14569,7 @@ skip_preblock:
#endif
#else
sctp_log_block(SCTP_BLOCK_LOG_INTO_BLK,
- asoc, (size_t)uio->uio_resid);
+ asoc, uio->uio_resid);
#endif
}
be.error = 0;
@@ -14563,7 +14645,7 @@ skip_preblock:
/* We send in a 0, since we do NOT have any locks */
error = sctp_msg_append(stcb, net, top, srcv, 0);
top = NULL;
- if (srcv->sinfo_flags & SCTP_EOF) {
+ if (sinfo_flags & SCTP_EOF) {
/*
* This should only happen for Panda for the mbuf
* send case, which does NOT yet support EEOR mode.
@@ -14578,7 +14660,7 @@ skip_preblock:
}
dataless_eof:
/* EOF thing ? */
- if ((srcv->sinfo_flags & SCTP_EOF) &&
+ if ((sinfo_flags & SCTP_EOF) &&
(got_all_of_the_send == 1)) {
SCTP_STAT_INCR(sctps_sends_with_eof);
error = 0;
@@ -14593,17 +14675,16 @@ dataless_eof:
goto abort_anyway;
}
/* there is nothing queued to send, so I'm done... */
- if ((SCTP_GET_STATE(asoc) != SCTP_STATE_SHUTDOWN_SENT) &&
- (SCTP_GET_STATE(asoc) != SCTP_STATE_SHUTDOWN_RECEIVED) &&
- (SCTP_GET_STATE(asoc) != SCTP_STATE_SHUTDOWN_ACK_SENT)) {
+ if ((SCTP_GET_STATE(stcb) != SCTP_STATE_SHUTDOWN_SENT) &&
+ (SCTP_GET_STATE(stcb) != SCTP_STATE_SHUTDOWN_RECEIVED) &&
+ (SCTP_GET_STATE(stcb) != SCTP_STATE_SHUTDOWN_ACK_SENT)) {
struct sctp_nets *netp;
/* only send SHUTDOWN the first time through */
- if (SCTP_GET_STATE(asoc) == SCTP_STATE_OPEN) {
+ if (SCTP_GET_STATE(stcb) == SCTP_STATE_OPEN) {
SCTP_STAT_DECR_GAUGE32(sctps_currestab);
}
- SCTP_SET_STATE(asoc, SCTP_STATE_SHUTDOWN_SENT);
- SCTP_CLEAR_SUBSTATE(asoc, SCTP_STATE_SHUTDOWN_PENDING);
+ SCTP_SET_STATE(stcb, SCTP_STATE_SHUTDOWN_SENT);
sctp_stop_timers_for_shutdown(stcb);
if (stcb->asoc.alternate) {
netp = stcb->asoc.alternate;
@@ -14627,17 +14708,17 @@ dataless_eof:
* data to be sent first and move to
* SHUTDOWN-PENDING
*/
- if ((SCTP_GET_STATE(asoc) != SCTP_STATE_SHUTDOWN_SENT) &&
- (SCTP_GET_STATE(asoc) != SCTP_STATE_SHUTDOWN_RECEIVED) &&
- (SCTP_GET_STATE(asoc) != SCTP_STATE_SHUTDOWN_ACK_SENT)) {
+ if ((SCTP_GET_STATE(stcb) != SCTP_STATE_SHUTDOWN_SENT) &&
+ (SCTP_GET_STATE(stcb) != SCTP_STATE_SHUTDOWN_RECEIVED) &&
+ (SCTP_GET_STATE(stcb) != SCTP_STATE_SHUTDOWN_ACK_SENT)) {
if (hold_tcblock == 0) {
SCTP_TCB_LOCK(stcb);
hold_tcblock = 1;
}
if ((*asoc->ss_functions.sctp_ss_is_user_msgs_incomplete)(stcb, asoc)) {
- asoc->state |= SCTP_STATE_PARTIAL_MSG_LEFT;
+ SCTP_ADD_SUBSTATE(stcb, SCTP_STATE_PARTIAL_MSG_LEFT);
}
- asoc->state |= SCTP_STATE_SHUTDOWN_PENDING;
+ SCTP_ADD_SUBSTATE(stcb, SCTP_STATE_SHUTDOWN_PENDING);
if (TAILQ_EMPTY(&asoc->send_queue) &&
TAILQ_EMPTY(&asoc->sent_queue) &&
(asoc->state & SCTP_STATE_PARTIAL_MSG_LEFT)) {
@@ -14675,12 +14756,12 @@ skip_out_eof:
SCTP_TCB_LOCK(stcb);
hold_tcblock = 1;
}
- if (SCTP_GET_STATE(&stcb->asoc) == SCTP_STATE_OPEN) {
+ if (SCTP_GET_STATE(stcb) == SCTP_STATE_OPEN) {
/* a collision took us forward? */
queue_only = 0;
} else {
sctp_send_initiate(inp, stcb, SCTP_SO_LOCKED);
- SCTP_SET_STATE(&stcb->asoc, SCTP_STATE_COOKIE_WAIT);
+ SCTP_SET_STATE(stcb, SCTP_STATE_COOKIE_WAIT);
queue_only = 1;
}
}
diff --git a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_output.h b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_output.h
index 597ddc3bf3a..cc5872725a6 100755
--- a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_output.h
+++ b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_output.h
@@ -34,7 +34,7 @@
#ifdef __FreeBSD__
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/netinet/sctp_output.h 323861 2017-09-21 11:56:31Z tuexen $");
+__FBSDID("$FreeBSD: head/sys/netinet/sctp_output.h 351654 2019-09-01 10:09:53Z tuexen $");
#endif
#ifndef _NETINET_SCTP_OUTPUT_H_
@@ -97,11 +97,11 @@ sctp_send_initiate_ack(struct sctp_inpcb *, struct sctp_tcb *,
struct mbuf *
sctp_arethere_unrecognized_parameters(struct mbuf *, int, int *,
- struct sctp_chunkhdr *, int *);
+ struct sctp_chunkhdr *, int *, int *);
void sctp_queue_op_err(struct sctp_tcb *, struct mbuf *);
int
-sctp_send_cookie_echo(struct mbuf *, int, struct sctp_tcb *,
+sctp_send_cookie_echo(struct mbuf *, int, int, struct sctp_tcb *,
struct sctp_nets *);
void sctp_send_cookie_ack(struct sctp_tcb *);
diff --git a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_pcb.c b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_pcb.c
index 355686fb904..02779e536c1 100755
--- a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_pcb.c
+++ b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_pcb.c
@@ -34,7 +34,7 @@
#ifdef __FreeBSD__
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/netinet/sctp_pcb.c 355931 2019-12-20 15:25:08Z tuexen $");
+__FBSDID("$FreeBSD: head/sys/netinet/sctp_pcb.c 356377 2020-01-05 14:06:40Z tuexen $");
#endif
#include <netinet/sctp_os.h>
@@ -51,9 +51,6 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_pcb.c 355931 2019-12-20 15:25:08Z tuex
#include <netinet/sctp_output.h>
#include <netinet/sctp_timer.h>
#include <netinet/sctp_bsd_addr.h>
-#if defined(__FreeBSD__) && __FreeBSD_version >= 1000000
-#include <netinet/sctp_dtrace_define.h>
-#endif
#if defined(INET) || defined(INET6)
#if !defined(__Userspace_os_Windows)
#include <netinet/udp.h>
@@ -73,6 +70,7 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_pcb.c 355931 2019-12-20 15:25:08Z tuex
#endif
#if defined(__Userspace__)
#include <user_socketvar.h>
+#include <user_atomic.h>
#if !defined(__Userspace_os_Windows)
#include <netdb.h>
#endif
@@ -3268,7 +3266,7 @@ sctp_inpcb_bind(struct socket *so, struct sockaddr *addr,
/* bind a ep to a socket address */
struct sctppcbhead *head;
struct sctp_inpcb *inp, *inp_tmp;
-#if defined(INET) || (defined(INET6) && defined(__APPLE__)) || defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__)
struct inpcb *ip_inp;
#endif
int port_reuse_active = 0;
@@ -3283,7 +3281,7 @@ sctp_inpcb_bind(struct socket *so, struct sockaddr *addr,
lport = 0;
bindall = 1;
inp = (struct sctp_inpcb *)so->so_pcb;
-#if defined(INET) || (defined(INET6) && defined(__APPLE__)) || defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__APPLE__)
ip_inp = (struct inpcb *)so->so_pcb;
#endif
#ifdef SCTP_DEBUG
@@ -3313,7 +3311,7 @@ sctp_inpcb_bind(struct socket *so, struct sockaddr *addr,
struct sockaddr_in *sin;
/* IPV6_V6ONLY socket? */
- if (SCTP_IPV6_V6ONLY(ip_inp)) {
+ if (SCTP_IPV6_V6ONLY(inp)) {
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
return (EINVAL);
}
@@ -3961,14 +3959,14 @@ sctp_inpcb_free(struct sctp_inpcb *inp, int immediate, int from)
* timer on the asoc due to it was not
* closed. So go ahead and start it now.
*/
- asoc->asoc.state &= ~SCTP_STATE_IN_ACCEPT_QUEUE;
+ SCTP_CLEAR_SUBSTATE(asoc, SCTP_STATE_IN_ACCEPT_QUEUE);
sctp_timer_start(SCTP_TIMER_TYPE_ASOCKILL, inp, asoc, NULL);
}
SCTP_TCB_UNLOCK(asoc);
continue;
}
- if (((SCTP_GET_STATE(&asoc->asoc) == SCTP_STATE_COOKIE_WAIT) ||
- (SCTP_GET_STATE(&asoc->asoc) == SCTP_STATE_COOKIE_ECHOED)) &&
+ if (((SCTP_GET_STATE(asoc) == SCTP_STATE_COOKIE_WAIT) ||
+ (SCTP_GET_STATE(asoc) == SCTP_STATE_COOKIE_ECHOED)) &&
(asoc->asoc.total_output_queue_size == 0)) {
/* If we have data in queue, we don't want to just
* free since the app may have done, send()/close
@@ -3984,7 +3982,7 @@ sctp_inpcb_free(struct sctp_inpcb *inp, int immediate, int from)
}
/* Disconnect the socket please */
asoc->sctp_socket = NULL;
- asoc->asoc.state |= SCTP_STATE_CLOSED_SOCKET;
+ SCTP_ADD_SUBSTATE(asoc, SCTP_STATE_CLOSED_SOCKET);
if ((asoc->asoc.size_on_reasm_queue > 0) ||
(asoc->asoc.control_pdapi) ||
(asoc->asoc.size_on_all_streams > 0) ||
@@ -3996,8 +3994,8 @@ sctp_inpcb_free(struct sctp_inpcb *inp, int immediate, int from)
asoc->sctp_ep->last_abort_code = SCTP_FROM_SCTP_PCB + SCTP_LOC_3;
sctp_send_abort_tcb(asoc, op_err, SCTP_SO_LOCKED);
SCTP_STAT_INCR_COUNTER32(sctps_aborted);
- if ((SCTP_GET_STATE(&asoc->asoc) == SCTP_STATE_OPEN) ||
- (SCTP_GET_STATE(&asoc->asoc) == SCTP_STATE_SHUTDOWN_RECEIVED)) {
+ if ((SCTP_GET_STATE(asoc) == SCTP_STATE_OPEN) ||
+ (SCTP_GET_STATE(asoc) == SCTP_STATE_SHUTDOWN_RECEIVED)) {
SCTP_STAT_DECR_GAUGE32(sctps_currestab);
}
if (sctp_free_assoc(inp, asoc,
@@ -4011,20 +4009,19 @@ sctp_inpcb_free(struct sctp_inpcb *inp, int immediate, int from)
if ((*asoc->asoc.ss_functions.sctp_ss_is_user_msgs_incomplete)(asoc, &asoc->asoc)) {
goto abort_anyway;
}
- if ((SCTP_GET_STATE(&asoc->asoc) != SCTP_STATE_SHUTDOWN_SENT) &&
- (SCTP_GET_STATE(&asoc->asoc) != SCTP_STATE_SHUTDOWN_ACK_SENT)) {
+ if ((SCTP_GET_STATE(asoc) != SCTP_STATE_SHUTDOWN_SENT) &&
+ (SCTP_GET_STATE(asoc) != SCTP_STATE_SHUTDOWN_ACK_SENT)) {
struct sctp_nets *netp;
/*
* there is nothing queued to send,
* so I send shutdown
*/
- if ((SCTP_GET_STATE(&asoc->asoc) == SCTP_STATE_OPEN) ||
- (SCTP_GET_STATE(&asoc->asoc) == SCTP_STATE_SHUTDOWN_RECEIVED)) {
+ if ((SCTP_GET_STATE(asoc) == SCTP_STATE_OPEN) ||
+ (SCTP_GET_STATE(asoc) == SCTP_STATE_SHUTDOWN_RECEIVED)) {
SCTP_STAT_DECR_GAUGE32(sctps_currestab);
}
- SCTP_SET_STATE(&asoc->asoc, SCTP_STATE_SHUTDOWN_SENT);
- SCTP_CLEAR_SUBSTATE(&asoc->asoc, SCTP_STATE_SHUTDOWN_PENDING);
+ SCTP_SET_STATE(asoc, SCTP_STATE_SHUTDOWN_SENT);
sctp_stop_timers_for_shutdown(asoc);
if (asoc->asoc.alternate) {
netp = asoc->asoc.alternate;
@@ -4040,11 +4037,11 @@ sctp_inpcb_free(struct sctp_inpcb *inp, int immediate, int from)
}
} else {
/* mark into shutdown pending */
- asoc->asoc.state |= SCTP_STATE_SHUTDOWN_PENDING;
+ SCTP_ADD_SUBSTATE(asoc, SCTP_STATE_SHUTDOWN_PENDING);
sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, asoc->sctp_ep, asoc,
asoc->asoc.primary_destination);
if ((*asoc->asoc.ss_functions.sctp_ss_is_user_msgs_incomplete)(asoc, &asoc->asoc)) {
- asoc->asoc.state |= SCTP_STATE_PARTIAL_MSG_LEFT;
+ SCTP_ADD_SUBSTATE(asoc, SCTP_STATE_PARTIAL_MSG_LEFT);
}
if (TAILQ_EMPTY(&asoc->asoc.send_queue) &&
TAILQ_EMPTY(&asoc->asoc.sent_queue) &&
@@ -4055,8 +4052,8 @@ sctp_inpcb_free(struct sctp_inpcb *inp, int immediate, int from)
asoc->sctp_ep->last_abort_code = SCTP_FROM_SCTP_PCB + SCTP_LOC_5;
sctp_send_abort_tcb(asoc, op_err, SCTP_SO_LOCKED);
SCTP_STAT_INCR_COUNTER32(sctps_aborted);
- if ((SCTP_GET_STATE(&asoc->asoc) == SCTP_STATE_OPEN) ||
- (SCTP_GET_STATE(&asoc->asoc) == SCTP_STATE_SHUTDOWN_RECEIVED)) {
+ if ((SCTP_GET_STATE(asoc) == SCTP_STATE_OPEN) ||
+ (SCTP_GET_STATE(asoc) == SCTP_STATE_SHUTDOWN_RECEIVED)) {
SCTP_STAT_DECR_GAUGE32(sctps_currestab);
}
if (sctp_free_assoc(inp, asoc,
@@ -4106,7 +4103,7 @@ sctp_inpcb_free(struct sctp_inpcb *inp, int immediate, int from)
SCTP_TCB_LOCK(asoc);
if (asoc->asoc.state & SCTP_STATE_ABOUT_TO_BE_FREED) {
if (asoc->asoc.state & SCTP_STATE_IN_ACCEPT_QUEUE) {
- asoc->asoc.state &= ~SCTP_STATE_IN_ACCEPT_QUEUE;
+ SCTP_CLEAR_SUBSTATE(asoc, SCTP_STATE_IN_ACCEPT_QUEUE);
sctp_timer_start(SCTP_TIMER_TYPE_ASOCKILL, inp, asoc, NULL);
}
cnt++;
@@ -4114,7 +4111,7 @@ sctp_inpcb_free(struct sctp_inpcb *inp, int immediate, int from)
continue;
}
/* Free associations that are NOT killing us */
- if ((SCTP_GET_STATE(&asoc->asoc) != SCTP_STATE_COOKIE_WAIT) &&
+ if ((SCTP_GET_STATE(asoc) != SCTP_STATE_COOKIE_WAIT) &&
((asoc->asoc.state & SCTP_STATE_ABOUT_TO_BE_FREED) == 0)) {
struct mbuf *op_err;
@@ -4127,8 +4124,8 @@ sctp_inpcb_free(struct sctp_inpcb *inp, int immediate, int from)
SCTP_TCB_UNLOCK(asoc);
continue;
}
- if ((SCTP_GET_STATE(&asoc->asoc) == SCTP_STATE_OPEN) ||
- (SCTP_GET_STATE(&asoc->asoc) == SCTP_STATE_SHUTDOWN_RECEIVED)) {
+ if ((SCTP_GET_STATE(asoc) == SCTP_STATE_OPEN) ||
+ (SCTP_GET_STATE(asoc) == SCTP_STATE_SHUTDOWN_RECEIVED)) {
SCTP_STAT_DECR_GAUGE32(sctps_currestab);
}
if (sctp_free_assoc(inp, asoc, SCTP_PCBFREE_FORCE,
@@ -4261,10 +4258,7 @@ sctp_inpcb_free(struct sctp_inpcb *inp, int immediate, int from)
#else
if (inp->inp_vflag & INP_IPV6) {
#endif
- struct in6pcb *in6p;
-
- in6p = (struct in6pcb *)inp;
- ip6_freepcbopts(in6p->in6p_outputopts);
+ ip6_freepcbopts(ip_pcb->in6p_outputopts);
}
#endif
#endif /* INET6 */
@@ -4883,11 +4877,9 @@ sctp_aloc_a_assoc_id(struct sctp_inpcb *inp, struct sctp_tcb *stcb)
struct sctpasochead *head;
struct sctp_tcb *lstcb;
- SCTP_INP_WLOCK(inp);
try_again:
if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) {
/* TSNH */
- SCTP_INP_WUNLOCK(inp);
return (0);
}
/*
@@ -4906,8 +4898,7 @@ sctp_aloc_a_assoc_id(struct sctp_inpcb *inp, struct sctp_tcb *stcb)
head = &inp->sctp_asocidhash[SCTP_PCBHASH_ASOC(id, inp->hashasocidmark)];
LIST_INSERT_HEAD(head, stcb, sctp_tcbasocidhash);
stcb->asoc.in_asocid_hash = 1;
- SCTP_INP_WUNLOCK(inp);
- return id;
+ return (id);
}
/*
@@ -4920,16 +4911,16 @@ sctp_aloc_assoc(struct sctp_inpcb *inp, struct sockaddr *firstaddr,
int *error, uint32_t override_tag, uint32_t vrf_id,
uint16_t o_streams, uint16_t port,
#if defined(__FreeBSD__) && __FreeBSD_version >= 500000
- struct thread *p
+ struct thread *p,
#elif defined(__Windows__)
- PKTHREAD p
+ PKTHREAD p,
#else
#if defined(__Userspace__)
/* __Userspace__ NULL proc is going to be passed here. See sctp_lower_sosend */
#endif
- struct proc *p
+ struct proc *p,
#endif
-)
+ int initialize_auth_params)
{
/* note the p argument is only valid in unbound sockets */
@@ -5107,7 +5098,6 @@ sctp_aloc_assoc(struct sctp_inpcb *inp, struct sockaddr *firstaddr,
memset(stcb, 0, sizeof(*stcb));
asoc = &stcb->asoc;
- asoc->assoc_id = sctp_aloc_a_assoc_id(inp, stcb);
SCTP_TCB_LOCK_INIT(stcb);
SCTP_TCB_SEND_LOCK_INIT(stcb);
stcb->rport = rport;
@@ -5118,7 +5108,6 @@ sctp_aloc_assoc(struct sctp_inpcb *inp, struct sockaddr *firstaddr,
/* failed */
SCTP_TCB_LOCK_DESTROY(stcb);
SCTP_TCB_SEND_LOCK_DESTROY(stcb);
- LIST_REMOVE(stcb, sctp_tcbasocidhash);
SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_asoc), stcb);
SCTP_DECR_ASOC_COUNT();
*error = err;
@@ -5131,7 +5120,6 @@ sctp_aloc_assoc(struct sctp_inpcb *inp, struct sockaddr *firstaddr,
/* inpcb freed while alloc going on */
SCTP_TCB_LOCK_DESTROY(stcb);
SCTP_TCB_SEND_LOCK_DESTROY(stcb);
- LIST_REMOVE(stcb, sctp_tcbasocidhash);
SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_asoc), stcb);
SCTP_INP_WUNLOCK(inp);
SCTP_INP_INFO_WUNLOCK();
@@ -5142,6 +5130,7 @@ sctp_aloc_assoc(struct sctp_inpcb *inp, struct sockaddr *firstaddr,
}
SCTP_TCB_LOCK(stcb);
+ asoc->assoc_id = sctp_aloc_a_assoc_id(inp, stcb);
/* now that my_vtag is set, add it to the hash */
head = &SCTP_BASE_INFO(sctp_asochash)[SCTP_PCBHASH_ASOC(stcb->asoc.my_vtag, SCTP_BASE_INFO(hashasocmark))];
/* put it in the bucket in the vtag hash of assoc's for the system */
@@ -5189,6 +5178,9 @@ sctp_aloc_assoc(struct sctp_inpcb *inp, struct sockaddr *firstaddr,
inp->sctp_hashmark)];
LIST_INSERT_HEAD(head, stcb, sctp_tcbhash);
}
+ if (initialize_auth_params == SCTP_INITIALIZE_AUTH_PARAMS) {
+ sctp_initialize_auth_params(inp, stcb);
+ }
SCTP_INP_WUNLOCK(inp);
SCTPDBG(SCTP_DEBUG_PCB1, "Association %p now allocated\n", (void *)stcb);
return (stcb);
@@ -5574,7 +5566,7 @@ sctp_free_assoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int from_inpcbfre
}
/* Now the read queue needs to be cleaned up (only once) */
if ((stcb->asoc.state & SCTP_STATE_ABOUT_TO_BE_FREED) == 0) {
- stcb->asoc.state |= SCTP_STATE_ABOUT_TO_BE_FREED;
+ SCTP_ADD_SUBSTATE(stcb, SCTP_STATE_ABOUT_TO_BE_FREED);
SCTP_INP_READ_LOCK(inp);
TAILQ_FOREACH(sq, &inp->read_queue, next) {
if (sq->stcb == stcb) {
@@ -5621,7 +5613,7 @@ sctp_free_assoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int from_inpcbfre
if ((stcb->asoc.refcnt) ||
(inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) ||
(inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE)) {
- stcb->asoc.state &= ~SCTP_STATE_IN_ACCEPT_QUEUE;
+ SCTP_CLEAR_SUBSTATE(stcb, SCTP_STATE_IN_ACCEPT_QUEUE);
sctp_timer_start(SCTP_TIMER_TYPE_ASOCKILL, inp, stcb, NULL);
}
SCTP_TCB_UNLOCK(stcb);
@@ -5684,12 +5676,11 @@ sctp_free_assoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int from_inpcbfre
inp->sctp_flags |= SCTP_PCB_FLAGS_WAS_CONNECTED;
if (so) {
SOCKBUF_LOCK(&so->so_rcv);
- if (so->so_rcv.sb_cc == 0) {
- so->so_state &= ~(SS_ISCONNECTING |
- SS_ISDISCONNECTING |
- SS_ISCONFIRMING |
- SS_ISCONNECTED);
- }
+ so->so_state &= ~(SS_ISCONNECTING |
+ SS_ISDISCONNECTING |
+ SS_ISCONFIRMING |
+ SS_ISCONNECTED);
+ so->so_state |= SS_ISDISCONNECTED;
#if defined(__APPLE__)
socantrcvmore(so);
#else
@@ -5711,7 +5702,7 @@ sctp_free_assoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int from_inpcbfre
atomic_add_int(&stcb->asoc.refcnt, -1);
}
if (stcb->asoc.refcnt) {
- stcb->asoc.state &= ~SCTP_STATE_IN_ACCEPT_QUEUE;
+ SCTP_CLEAR_SUBSTATE(stcb, SCTP_STATE_IN_ACCEPT_QUEUE);
sctp_timer_start(SCTP_TIMER_TYPE_ASOCKILL, inp, stcb, NULL);
if (from_inpcbfree == SCTP_NORMAL_PROC) {
SCTP_INP_INFO_WUNLOCK();
@@ -5760,6 +5751,7 @@ sctp_free_assoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int from_inpcbfre
* in case.
*/
/* anything on the wheel needs to be removed */
+ SCTP_TCB_SEND_LOCK(stcb);
for (i = 0; i < asoc->streamoutcnt; i++) {
struct sctp_stream_out *outs;
@@ -5768,7 +5760,7 @@ sctp_free_assoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int from_inpcbfre
TAILQ_FOREACH_SAFE(sp, &outs->outqueue, next, nsp) {
atomic_subtract_int(&asoc->stream_queue_cnt, 1);
TAILQ_REMOVE(&outs->outqueue, sp, next);
- stcb->asoc.ss_functions.sctp_ss_remove_from_stream(stcb, asoc, outs, sp, 0);
+ stcb->asoc.ss_functions.sctp_ss_remove_from_stream(stcb, asoc, outs, sp, 1);
sctp_free_spbufspace(stcb, asoc, sp);
if (sp->data) {
if (so) {
@@ -5790,6 +5782,7 @@ sctp_free_assoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int from_inpcbfre
sctp_free_a_strmoq(stcb, sp, SCTP_SO_LOCKED);
}
}
+ SCTP_TCB_SEND_UNLOCK(stcb);
/*sa_ignore FREED_MEMORY*/
TAILQ_FOREACH_SAFE(strrst, &asoc->resetHead, next_resp, nstrrst) {
TAILQ_REMOVE(&asoc->resetHead, strrst, next_resp);
@@ -6606,7 +6599,7 @@ sctp_startup_mcore_threads(void)
}
}
#endif
-#if defined(__FreeBSD__) && __FreeBSD_cc_version >= 1300000
+#if defined(__FreeBSD__) && __FreeBSD_cc_version >= 1400000
static struct mbuf *
sctp_netisr_hdlr(struct mbuf *m, uintptr_t source)
{
@@ -6639,7 +6632,11 @@ sctp_netisr_hdlr(struct mbuf *m, uintptr_t source)
#endif
void
-sctp_pcb_init()
+#if defined(__Userspace__)
+sctp_pcb_init(int start_threads)
+#else
+sctp_pcb_init(void)
+#endif
{
/*
* SCTP initialization for the PCB structures should be called by
@@ -6840,7 +6837,7 @@ sctp_pcb_init()
*/
sctp_init_vrf_list(SCTP_DEFAULT_VRF);
#endif
-#if defined(__FreeBSD__) && __FreeBSD_cc_version >= 1300000
+#if defined(__FreeBSD__) && __FreeBSD_cc_version >= 1400000
if (ip_register_flow_handler(sctp_netisr_hdlr, IPPROTO_SCTP)) {
SCTP_PRINTF("***SCTP- Error can't register netisr handler***\n");
}
@@ -6854,7 +6851,8 @@ sctp_pcb_init()
mbuf_initialize(NULL);
atomic_init();
#if defined(INET) || defined(INET6)
- recv_thread_init();
+ if (start_threads)
+ recv_thread_init();
#endif
#endif
}
@@ -7315,7 +7313,7 @@ sctp_load_addresses_from_init(struct sctp_tcb *stcb, struct mbuf *m,
* assoc? straighten out locks.
*/
if (stcb_tmp) {
- if (SCTP_GET_STATE(&stcb_tmp->asoc) & SCTP_STATE_COOKIE_WAIT) {
+ if (SCTP_GET_STATE(stcb_tmp) == SCTP_STATE_COOKIE_WAIT) {
struct mbuf *op_err;
char msg[SCTP_DIAG_INFO_LEN];
@@ -7409,7 +7407,7 @@ sctp_load_addresses_from_init(struct sctp_tcb *stcb, struct mbuf *m,
* assoc? straighten out locks.
*/
if (stcb_tmp) {
- if (SCTP_GET_STATE(&stcb_tmp->asoc) & SCTP_STATE_COOKIE_WAIT) {
+ if (SCTP_GET_STATE(stcb_tmp) == SCTP_STATE_COOKIE_WAIT) {
struct mbuf *op_err;
char msg[SCTP_DIAG_INFO_LEN];
@@ -8179,7 +8177,7 @@ sctp_initiate_iterator(inp_func inpf,
SCTP_M_ITER);
if (it == NULL) {
SCTP_LTRACE_ERR_RET(NULL, NULL, NULL, SCTP_FROM_SCTP_PCB, ENOMEM);
- return (ENOMEM);
+ return (-1);
}
memset(it, 0, sizeof(*it));
it->function_assoc = af;
diff --git a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_pcb.h b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_pcb.h
index 34881863ffa..551bbfb8e98 100755
--- a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_pcb.h
+++ b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_pcb.h
@@ -34,7 +34,7 @@
#ifdef __FreeBSD__
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/netinet/sctp_pcb.h 325370 2017-11-03 20:46:12Z tuexen $");
+__FBSDID("$FreeBSD: head/sys/netinet/sctp_pcb.h 354018 2019-10-24 09:22:23Z tuexen $");
#endif
#ifndef _NETINET_SCTP_PCB_H_
@@ -305,6 +305,9 @@ struct sctp_base_info {
int packet_log_end;
uint8_t packet_log_buffer[SCTP_PACKET_LOG_SIZE];
#endif
+#if defined(__FreeBSD__)
+ eventhandler_tag eh_tag;
+#endif
#if defined(__APPLE__)
int sctp_main_timer_ticks;
#endif
@@ -320,7 +323,7 @@ struct sctp_base_info {
#endif
#endif
#ifdef INET
-#if defined(__Userspace_os_Windows)
+#if defined(__Userspace_os_Windows) && !defined(__MINGW32__)
SOCKET userspace_rawsctp;
SOCKET userspace_udpsctp;
#else
@@ -331,7 +334,7 @@ struct sctp_base_info {
userland_thread_t recvthreadudp;
#endif
#ifdef INET6
-#if defined(__Userspace_os_Windows)
+#if defined(__Userspace_os_Windows) && !defined(__MINGW32__)
SOCKET userspace_rawsctp6;
SOCKET userspace_udpsctp6;
#else
@@ -448,7 +451,7 @@ struct sctp_inpcb {
*/
union {
struct inpcb inp;
- char align[(sizeof(struct in6pcb) + SCTP_ALIGNM1) &
+ char align[(sizeof(struct inpcb) + SCTP_ALIGNM1) &
~SCTP_ALIGNM1];
} ip_inp;
@@ -803,19 +806,24 @@ int sctp_is_address_on_local_host(struct sockaddr *addr, uint32_t vrf_id);
void sctp_inpcb_free(struct sctp_inpcb *, int, int);
+#define SCTP_DONT_INITIALIZE_AUTH_PARAMS 0
+#define SCTP_INITIALIZE_AUTH_PARAMS 1
+
#if defined(__FreeBSD__) && __FreeBSD_version >= 500000
struct sctp_tcb *
sctp_aloc_assoc(struct sctp_inpcb *, struct sockaddr *,
- int *, uint32_t, uint32_t, uint16_t, uint16_t, struct thread *);
+ int *, uint32_t, uint32_t, uint16_t, uint16_t, struct thread *,
+ int);
#elif defined(__Windows__)
struct sctp_tcb *
sctp_aloc_assoc(struct sctp_inpcb *, struct sockaddr *,
- int *, uint32_t, uint32_t, uint16_t, uint16_t, PKTHREAD);
+ int *, uint32_t, uint32_t, uint16_t, uint16_t, PKTHREAD, int);
#else
/* proc will be NULL for __Userspace__ */
struct sctp_tcb *
sctp_aloc_assoc(struct sctp_inpcb *, struct sockaddr *,
- int *, uint32_t, uint32_t, uint16_t, uint16_t, struct proc *);
+ int *, uint32_t, uint32_t, uint16_t, uint16_t, struct proc *,
+ int);
#endif
int sctp_free_assoc(struct sctp_inpcb *, struct sctp_tcb *, int, int);
@@ -838,7 +846,11 @@ void sctp_remove_net(struct sctp_tcb *, struct sctp_nets *);
int sctp_del_remote_addr(struct sctp_tcb *, struct sockaddr *);
+#if defined(__Userspace__)
+void sctp_pcb_init(int);
+#else
void sctp_pcb_init(void);
+#endif
void sctp_pcb_finish(void);
diff --git a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_peeloff.c b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_peeloff.c
index 391b4f5446b..8e81065a4d3 100755
--- a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_peeloff.c
+++ b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_peeloff.c
@@ -34,7 +34,7 @@
#ifdef __FreeBSD__
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/netinet/sctp_peeloff.c 279859 2015-03-10 19:49:25Z tuexen $");
+__FBSDID("$FreeBSD: head/sys/netinet/sctp_peeloff.c 337708 2018-08-13 13:58:45Z tuexen $");
#endif
#include <netinet/sctp_os.h>
@@ -79,7 +79,7 @@ sctp_can_peel_off(struct socket *head, sctp_assoc_t assoc_id)
SCTP_LTRACE_ERR_RET(inp, stcb, NULL, SCTP_FROM_SCTP_PEELOFF, ENOENT);
return (ENOENT);
}
- state = SCTP_GET_STATE((&stcb->asoc));
+ state = SCTP_GET_STATE(stcb);
if ((state == SCTP_STATE_EMPTY) ||
(state == SCTP_STATE_INUSE)) {
SCTP_TCB_UNLOCK(stcb);
@@ -109,7 +109,7 @@ sctp_do_peeloff(struct socket *head, struct socket *so, sctp_assoc_t assoc_id)
return (ENOTCONN);
}
- state = SCTP_GET_STATE((&stcb->asoc));
+ state = SCTP_GET_STATE(stcb);
if ((state == SCTP_STATE_EMPTY) ||
(state == SCTP_STATE_INUSE)) {
SCTP_TCB_UNLOCK(stcb);
diff --git a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_ss_functions.c b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_ss_functions.c
index f1982572468..59ef9cdfa0a 100755
--- a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_ss_functions.c
+++ b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_ss_functions.c
@@ -30,7 +30,7 @@
#ifdef __FreeBSD__
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/netinet/sctp_ss_functions.c 326180 2017-11-24 19:38:59Z tuexen $");
+__FBSDID("$FreeBSD: head/sys/netinet/sctp_ss_functions.c 345505 2019-03-25 16:40:54Z tuexen $");
#endif
#include <netinet/sctp_pcb.h>
@@ -59,6 +59,9 @@ sctp_ss_default_init(struct sctp_tcb *stcb, struct sctp_association *asoc,
{
uint16_t i;
+ if (holds_lock == 0) {
+ SCTP_TCB_SEND_LOCK(stcb);
+ }
asoc->ss_data.locked_on_sending = NULL;
asoc->ss_data.last_out_stream = NULL;
TAILQ_INIT(&asoc->ss_data.out.wheel);
@@ -71,7 +74,10 @@ sctp_ss_default_init(struct sctp_tcb *stcb, struct sctp_association *asoc,
for (i = 0; i < stcb->asoc.streamoutcnt; i++) {
stcb->asoc.ss_functions.sctp_ss_add_to_stream(stcb, &stcb->asoc,
&stcb->asoc.strmout[i],
- NULL, holds_lock);
+ NULL, 1);
+ }
+ if (holds_lock == 0) {
+ SCTP_TCB_SEND_UNLOCK(stcb);
}
return;
}
@@ -84,8 +90,10 @@ sctp_ss_default_clear(struct sctp_tcb *stcb, struct sctp_association *asoc,
SCTP_TCB_SEND_LOCK(stcb);
}
while (!TAILQ_EMPTY(&asoc->ss_data.out.wheel)) {
- struct sctp_stream_out *strq = TAILQ_FIRST(&asoc->ss_data.out.wheel);
- TAILQ_REMOVE(&asoc->ss_data.out.wheel, TAILQ_FIRST(&asoc->ss_data.out.wheel), ss_params.rr.next_spoke);
+ struct sctp_stream_out *strq;
+
+ strq = TAILQ_FIRST(&asoc->ss_data.out.wheel);
+ TAILQ_REMOVE(&asoc->ss_data.out.wheel, strq, ss_params.rr.next_spoke);
strq->ss_params.rr.next_spoke.tqe_next = NULL;
strq->ss_params.rr.next_spoke.tqe_prev = NULL;
}
@@ -401,11 +409,13 @@ sctp_ss_prio_clear(struct sctp_tcb *stcb, struct sctp_association *asoc,
SCTP_TCB_SEND_LOCK(stcb);
}
while (!TAILQ_EMPTY(&asoc->ss_data.out.wheel)) {
- struct sctp_stream_out *strq = TAILQ_FIRST(&asoc->ss_data.out.wheel);
+ struct sctp_stream_out *strq;
+
+ strq = TAILQ_FIRST(&asoc->ss_data.out.wheel);
if (clear_values) {
strq->ss_params.prio.priority = 0;
}
- TAILQ_REMOVE(&asoc->ss_data.out.wheel, TAILQ_FIRST(&asoc->ss_data.out.wheel), ss_params.prio.next_spoke);
+ TAILQ_REMOVE(&asoc->ss_data.out.wheel, strq, ss_params.prio.next_spoke);
strq->ss_params.prio.next_spoke.tqe_next = NULL;
strq->ss_params.prio.next_spoke.tqe_prev = NULL;
@@ -589,11 +599,13 @@ sctp_ss_fb_clear(struct sctp_tcb *stcb, struct sctp_association *asoc,
SCTP_TCB_SEND_LOCK(stcb);
}
while (!TAILQ_EMPTY(&asoc->ss_data.out.wheel)) {
- struct sctp_stream_out *strq = TAILQ_FIRST(&asoc->ss_data.out.wheel);
+ struct sctp_stream_out *strq;
+
+ strq = TAILQ_FIRST(&asoc->ss_data.out.wheel);
if (clear_values) {
strq->ss_params.fb.rounds = -1;
}
- TAILQ_REMOVE(&asoc->ss_data.out.wheel, TAILQ_FIRST(&asoc->ss_data.out.wheel), ss_params.fb.next_spoke);
+ TAILQ_REMOVE(&asoc->ss_data.out.wheel, strq, ss_params.fb.next_spoke);
strq->ss_params.fb.next_spoke.tqe_next = NULL;
strq->ss_params.fb.next_spoke.tqe_prev = NULL;
}
@@ -763,6 +775,9 @@ sctp_ss_fcfs_init(struct sctp_tcb *stcb, struct sctp_association *asoc,
struct sctp_stream_queue_pending *sp;
uint16_t i;
+ if (holds_lock == 0) {
+ SCTP_TCB_SEND_LOCK(stcb);
+ }
TAILQ_INIT(&asoc->ss_data.out.list);
/*
* If there is data in the stream queues already,
@@ -782,12 +797,15 @@ sctp_ss_fcfs_init(struct sctp_tcb *stcb, struct sctp_association *asoc,
x++;
}
if (sp != NULL) {
- sctp_ss_fcfs_add(stcb, &stcb->asoc, &stcb->asoc.strmout[i], sp, holds_lock);
+ sctp_ss_fcfs_add(stcb, &stcb->asoc, &stcb->asoc.strmout[i], sp, 1);
add_more = 1;
}
}
n++;
}
+ if (holds_lock == 0) {
+ SCTP_TCB_SEND_UNLOCK(stcb);
+ }
return;
}
@@ -795,12 +813,17 @@ static void
sctp_ss_fcfs_clear(struct sctp_tcb *stcb, struct sctp_association *asoc,
int clear_values, int holds_lock)
{
+ struct sctp_stream_queue_pending *sp;
+
if (clear_values) {
if (holds_lock == 0) {
SCTP_TCB_SEND_LOCK(stcb);
}
while (!TAILQ_EMPTY(&asoc->ss_data.out.list)) {
- TAILQ_REMOVE(&asoc->ss_data.out.list, TAILQ_FIRST(&asoc->ss_data.out.list), ss_next);
+ sp = TAILQ_FIRST(&asoc->ss_data.out.list);
+ TAILQ_REMOVE(&asoc->ss_data.out.list, sp, ss_next);
+ sp->ss_next.tqe_next = NULL;
+ sp->ss_next.tqe_prev = NULL;
}
if (holds_lock == 0) {
SCTP_TCB_SEND_UNLOCK(stcb);
@@ -820,6 +843,8 @@ sctp_ss_fcfs_init_stream(struct sctp_tcb *stcb, struct sctp_stream_out *strq, st
stcb->asoc.ss_data.last_out_stream = strq;
}
}
+ strq->ss_params.fb.next_spoke.tqe_next = NULL;
+ strq->ss_params.fb.next_spoke.tqe_prev = NULL;
return;
}
@@ -863,6 +888,8 @@ sctp_ss_fcfs_remove(struct sctp_tcb *stcb, struct sctp_association *asoc,
((sp->ss_next.tqe_next != NULL) ||
(sp->ss_next.tqe_prev != NULL))) {
TAILQ_REMOVE(&asoc->ss_data.out.list, sp, ss_next);
+ sp->ss_next.tqe_next = NULL;
+ sp->ss_next.tqe_prev = NULL;
}
if (holds_lock == 0) {
SCTP_TCB_SEND_UNLOCK(stcb);
diff --git a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_structs.h b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_structs.h
index f49f2c87a77..a7fd665f58f 100755
--- a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_structs.h
+++ b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_structs.h
@@ -34,7 +34,7 @@
#ifdef __FreeBSD__
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/netinet/sctp_structs.h 325370 2017-11-03 20:46:12Z tuexen $");
+__FBSDID("$FreeBSD: head/sys/netinet/sctp_structs.h 345467 2019-03-24 12:13:05Z tuexen $");
#endif
#ifndef _NETINET_SCTP_STRUCTS_H_
@@ -173,7 +173,7 @@ struct sctp_copy_all {
struct sctp_inpcb *inp; /* ep */
struct mbuf *m;
struct sctp_sndrcvinfo sndrcv;
- int sndlen;
+ ssize_t sndlen;
int cnt_sent;
int cnt_failed;
};
diff --git a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_sysctl.c b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_sysctl.c
index 83d2c9a2b83..ba911c3c575 100755
--- a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_sysctl.c
+++ b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_sysctl.c
@@ -34,7 +34,7 @@
#ifdef __FreeBSD__
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/netinet/sctp_sysctl.c 326672 2017-12-07 22:19:08Z tuexen $");
+__FBSDID("$FreeBSD: head/sys/netinet/sctp_sysctl.c 356357 2020-01-04 20:33:12Z tuexen $");
#endif
#include <netinet/sctp_os.h>
@@ -149,6 +149,7 @@ sctp_init_sysctls()
SCTP_BASE_SYSCTL(sctp_steady_step) = SCTPCTL_RTTVAR_STEADYS_DEFAULT;
SCTP_BASE_SYSCTL(sctp_use_dccc_ecn) = SCTPCTL_RTTVAR_DCCCECN_DEFAULT;
SCTP_BASE_SYSCTL(sctp_blackhole) = SCTPCTL_BLACKHOLE_DEFAULT;
+ SCTP_BASE_SYSCTL(sctp_sendall_limit) = SCTPCTL_SENDALL_LIMIT_DEFAULT;
SCTP_BASE_SYSCTL(sctp_diag_info_code) = SCTPCTL_DIAG_INFO_CODE_DEFAULT;
#if defined(SCTP_LOCAL_TRACE_BUF)
#if defined(__Windows__)
@@ -498,6 +499,9 @@ sctp_sysctl_handle_assoclist(SYSCTL_HANDLER_ARGS)
SCTP_LTRACE_ERR_RET(NULL, NULL, NULL, SCTP_FROM_SCTP_SYSCTL, EPERM);
return (EPERM);
}
+ memset(&xinpcb, 0, sizeof(xinpcb));
+ memset(&xstcb, 0, sizeof(xstcb));
+ memset(&xraddr, 0, sizeof(xraddr));
LIST_FOREACH(inp, &SCTP_BASE_INFO(listhead), sctp_list) {
SCTP_INP_RLOCK(inp);
if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) {
@@ -516,7 +520,9 @@ sctp_sysctl_handle_assoclist(SYSCTL_HANDLER_ARGS)
xinpcb.total_recvs = inp->total_recvs;
xinpcb.total_nospaces = inp->total_nospaces;
xinpcb.fragmentation_point = inp->sctp_frag_point;
-#if !(defined(__FreeBSD__) && (__FreeBSD_version < 1001517))
+#if defined(__FreeBSD__)
+ xinpcb.socket = (uintptr_t)inp->sctp_socket;
+#else
xinpcb.socket = inp->sctp_socket;
#endif
so = inp->sctp_socket;
@@ -1319,6 +1325,7 @@ SCTP_UINT_SYSCTL(rttvar_eqret, sctp_rttvar_eqret, SCTPCTL_RTTVAR_EQRET)
SCTP_UINT_SYSCTL(rttvar_steady_step, sctp_steady_step, SCTPCTL_RTTVAR_STEADYS)
SCTP_UINT_SYSCTL(use_dcccecn, sctp_use_dccc_ecn, SCTPCTL_RTTVAR_DCCCECN)
SCTP_UINT_SYSCTL(blackhole, sctp_blackhole, SCTPCTL_BLACKHOLE)
+SCTP_UINT_SYSCTL(sendall_limit, sctp_sendall_limit, SCTPCTL_SENDALL_LIMIT)
SCTP_UINT_SYSCTL(diag_info_code, sctp_diag_info_code, SCTPCTL_DIAG_INFO_CODE)
#ifdef SCTP_DEBUG
SCTP_UINT_SYSCTL(debug, sctp_debug_on, SCTPCTL_DEBUG)
@@ -1417,6 +1424,7 @@ sctp_sysctl_handle_int(SYSCTL_HANDLER_ARGS)
RANGECHK(SCTP_BASE_SYSCTL(sctp_enable_sack_immediately), SCTPCTL_SACK_IMMEDIATELY_ENABLE_MIN, SCTPCTL_SACK_IMMEDIATELY_ENABLE_MAX);
RANGECHK(SCTP_BASE_SYSCTL(sctp_inits_include_nat_friendly), SCTPCTL_NAT_FRIENDLY_INITS_MIN, SCTPCTL_NAT_FRIENDLY_INITS_MAX);
RANGECHK(SCTP_BASE_SYSCTL(sctp_blackhole), SCTPCTL_BLACKHOLE_MIN, SCTPCTL_BLACKHOLE_MAX);
+ RANGECHK(SCTP_BASE_SYSCTL(sctp_sendall_limit), SCTPCTL_SENDALL_LIMIT_MIN, SCTPCTL_SENDALL_LIMIT_MAX);
RANGECHK(SCTP_BASE_SYSCTL(sctp_diag_info_code), SCTPCTL_DIAG_INFO_CODE_MIN, SCTPCTL_DIAG_INFO_CODE_MAX);
#ifdef SCTP_DEBUG
RANGECHK(SCTP_BASE_SYSCTL(sctp_debug_on), SCTPCTL_DEBUG_MIN, SCTPCTL_DEBUG_MAX);
@@ -1429,143 +1437,143 @@ void
sysctl_setup_sctp(void)
{
sysctl_add_oid(&sysctl_oid_top, "sendspace", CTLTYPE_INT|CTLFLAG_RW,
- &SCTP_BASE_SYSCTL(sctp_sendspace), 0, sctp_sysctl_handle_int,
+ &SCTP_BASE_SYSCTL(sctp_sendspace), 0, sctp_sysctl_handle_int,
SCTPCTL_MAXDGRAM_DESC);
sysctl_add_oid(&sysctl_oid_top, "recvspace", CTLTYPE_INT|CTLFLAG_RW,
- &SCTP_BASE_SYSCTL(sctp_recvspace), 0, sctp_sysctl_handle_int,
+ &SCTP_BASE_SYSCTL(sctp_recvspace), 0, sctp_sysctl_handle_int,
SCTPCTL_RECVSPACE_DESC);
sysctl_add_oid(&sysctl_oid_top, "auto_asconf", CTLTYPE_INT|CTLFLAG_RW,
- &SCTP_BASE_SYSCTL(sctp_auto_asconf), 0, sctp_sysctl_handle_int,
+ &SCTP_BASE_SYSCTL(sctp_auto_asconf), 0, sctp_sysctl_handle_int,
SCTPCTL_AUTOASCONF_DESC);
sysctl_add_oid(&sysctl_oid_top, "ecn_enable", CTLTYPE_INT|CTLFLAG_RW,
- &SCTP_BASE_SYSCTL(sctp_ecn_enable), 0, sctp_sysctl_handle_int,
+ &SCTP_BASE_SYSCTL(sctp_ecn_enable), 0, sctp_sysctl_handle_int,
SCTPCTL_ECN_ENABLE_DESC);
sysctl_add_oid(&sysctl_oid_top, "pr_enable", CTLTYPE_INT|CTLFLAG_RW,
- &SCTP_BASE_SYSCTL(sctp_pr_enable), 0, sctp_sysctl_handle_int,
+ &SCTP_BASE_SYSCTL(sctp_pr_enable), 0, sctp_sysctl_handle_int,
SCTPCTL_PR_ENABLE_DESC);
sysctl_add_oid(&sysctl_oid_top, "auth_enable", CTLTYPE_INT|CTLFLAG_RW,
- &SCTP_BASE_SYSCTL(sctp_auth_enable), 0, sctp_sysctl_handle_auth,
+ &SCTP_BASE_SYSCTL(sctp_auth_enable), 0, sctp_sysctl_handle_auth,
SCTPCTL_AUTH_ENABLE_DESC);
sysctl_add_oid(&sysctl_oid_top, "asconf_enable", CTLTYPE_INT|CTLFLAG_RW,
- &SCTP_BASE_SYSCTL(sctp_asconf_enable), 0, sctp_sysctl_handle_asconf,
+ &SCTP_BASE_SYSCTL(sctp_asconf_enable), 0, sctp_sysctl_handle_asconf,
SCTPCTL_ASCONF_ENABLE_DESC);
sysctl_add_oid(&sysctl_oid_top, "reconfig_enable", CTLTYPE_INT|CTLFLAG_RW,
- &SCTP_BASE_SYSCTL(sctp_reconfig_enable), 0, sctp_sysctl_handle_int,
+ &SCTP_BASE_SYSCTL(sctp_reconfig_enable), 0, sctp_sysctl_handle_int,
SCTPCTL_RECONFIG_ENABLE_DESC);
sysctl_add_oid(&sysctl_oid_top, "nrsack_enable", CTLTYPE_INT|CTLFLAG_RW,
- &SCTP_BASE_SYSCTL(sctp_nrsack_enable), 0, sctp_sysctl_handle_int,
+ &SCTP_BASE_SYSCTL(sctp_nrsack_enable), 0, sctp_sysctl_handle_int,
SCTPCTL_NRSACK_ENABLE_DESC);
sysctl_add_oid(&sysctl_oid_top, "pktdrop_enable", CTLTYPE_INT|CTLFLAG_RW,
- &SCTP_BASE_SYSCTL(sctp_pktdrop_enable), 0, sctp_sysctl_handle_int,
+ &SCTP_BASE_SYSCTL(sctp_pktdrop_enable), 0, sctp_sysctl_handle_int,
SCTPCTL_PKTDROP_ENABLE_DESC);
sysctl_add_oid(&sysctl_oid_top, "loopback_nocsum", CTLTYPE_INT|CTLFLAG_RW,
- &SCTP_BASE_SYSCTL(sctp_no_csum_on_loopback), 0, sctp_sysctl_handle_int,
+ &SCTP_BASE_SYSCTL(sctp_no_csum_on_loopback), 0, sctp_sysctl_handle_int,
SCTPCTL_LOOPBACK_NOCSUM_DESC);
sysctl_add_oid(&sysctl_oid_top, "peer_chkoh", CTLTYPE_INT|CTLFLAG_RW,
- &SCTP_BASE_SYSCTL(sctp_peer_chunk_oh), 0, sctp_sysctl_handle_int,
+ &SCTP_BASE_SYSCTL(sctp_peer_chunk_oh), 0, sctp_sysctl_handle_int,
SCTPCTL_PEER_CHKOH_DESC);
sysctl_add_oid(&sysctl_oid_top, "maxburst", CTLTYPE_INT|CTLFLAG_RW,
- &SCTP_BASE_SYSCTL(sctp_max_burst_default), 0, sctp_sysctl_handle_int,
+ &SCTP_BASE_SYSCTL(sctp_max_burst_default), 0, sctp_sysctl_handle_int,
SCTPCTL_MAXBURST_DESC);
sysctl_add_oid(&sysctl_oid_top, "fr_maxburst", CTLTYPE_INT|CTLFLAG_RW,
- &SCTP_BASE_SYSCTL(sctp_fr_max_burst_default), 0, sctp_sysctl_handle_int,
+ &SCTP_BASE_SYSCTL(sctp_fr_max_burst_default), 0, sctp_sysctl_handle_int,
SCTPCTL_FRMAXBURST_DESC);
sysctl_add_oid(&sysctl_oid_top, "maxchunks", CTLTYPE_INT|CTLFLAG_RW,
- &SCTP_BASE_SYSCTL(sctp_max_chunks_on_queue), 0, sctp_sysctl_handle_int,
+ &SCTP_BASE_SYSCTL(sctp_max_chunks_on_queue), 0, sctp_sysctl_handle_int,
SCTPCTL_MAXCHUNKS_DESC);
sysctl_add_oid(&sysctl_oid_top, "tcbhashsize", CTLTYPE_INT|CTLFLAG_RW,
- &SCTP_BASE_SYSCTL(sctp_hashtblsize), 0, sctp_sysctl_handle_int,
+ &SCTP_BASE_SYSCTL(sctp_hashtblsize), 0, sctp_sysctl_handle_int,
SCTPCTL_TCBHASHSIZE_DESC);
sysctl_add_oid(&sysctl_oid_top, "pcbhashsize", CTLTYPE_INT|CTLFLAG_RW,
- &SCTP_BASE_SYSCTL(sctp_pcbtblsize), 0, sctp_sysctl_handle_int,
+ &SCTP_BASE_SYSCTL(sctp_pcbtblsize), 0, sctp_sysctl_handle_int,
SCTPCTL_PCBHASHSIZE_DESC);
sysctl_add_oid(&sysctl_oid_top, "min_split_point", CTLTYPE_INT|CTLFLAG_RW,
- &SCTP_BASE_SYSCTL(sctp_min_split_point), 0, sctp_sysctl_handle_int,
+ &SCTP_BASE_SYSCTL(sctp_min_split_point), 0, sctp_sysctl_handle_int,
SCTPCTL_MIN_SPLIT_POINT_DESC);
sysctl_add_oid(&sysctl_oid_top, "chunkscale", CTLTYPE_INT|CTLFLAG_RW,
- &SCTP_BASE_SYSCTL(sctp_chunkscale), 0, sctp_sysctl_handle_int,
+ &SCTP_BASE_SYSCTL(sctp_chunkscale), 0, sctp_sysctl_handle_int,
SCTPCTL_CHUNKSCALE_DESC);
sysctl_add_oid(&sysctl_oid_top, "delayed_sack_time", CTLTYPE_INT|CTLFLAG_RW,
- &SCTP_BASE_SYSCTL(sctp_delayed_sack_time_default), 0, sctp_sysctl_handle_int,
+ &SCTP_BASE_SYSCTL(sctp_delayed_sack_time_default), 0, sctp_sysctl_handle_int,
SCTPCTL_DELAYED_SACK_TIME_DESC);
sysctl_add_oid(&sysctl_oid_top, "sack_freq", CTLTYPE_INT|CTLFLAG_RW,
- &SCTP_BASE_SYSCTL(sctp_sack_freq_default), 0, sctp_sysctl_handle_int,
+ &SCTP_BASE_SYSCTL(sctp_sack_freq_default), 0, sctp_sysctl_handle_int,
SCTPCTL_SACK_FREQ_DESC);
sysctl_add_oid(&sysctl_oid_top, "sys_resource", CTLTYPE_INT|CTLFLAG_RW,
- &SCTP_BASE_SYSCTL(sctp_system_free_resc_limit), 0, sctp_sysctl_handle_int,
+ &SCTP_BASE_SYSCTL(sctp_system_free_resc_limit), 0, sctp_sysctl_handle_int,
SCTPCTL_SYS_RESOURCE_DESC);
sysctl_add_oid(&sysctl_oid_top, "asoc_resource", CTLTYPE_INT|CTLFLAG_RW,
- &SCTP_BASE_SYSCTL(sctp_asoc_free_resc_limit), 0, sctp_sysctl_handle_int,
+ &SCTP_BASE_SYSCTL(sctp_asoc_free_resc_limit), 0, sctp_sysctl_handle_int,
SCTPCTL_ASOC_RESOURCE_DESC);
sysctl_add_oid(&sysctl_oid_top, "heartbeat_interval", CTLTYPE_INT|CTLFLAG_RW,
- &SCTP_BASE_SYSCTL(sctp_heartbeat_interval_default), 0, sctp_sysctl_handle_int,
+ &SCTP_BASE_SYSCTL(sctp_heartbeat_interval_default), 0, sctp_sysctl_handle_int,
SCTPCTL_HEARTBEAT_INTERVAL_DESC);
sysctl_add_oid(&sysctl_oid_top, "pmtu_raise_time", CTLTYPE_INT|CTLFLAG_RW,
- &SCTP_BASE_SYSCTL(sctp_pmtu_raise_time_default), 0, sctp_sysctl_handle_int,
+ &SCTP_BASE_SYSCTL(sctp_pmtu_raise_time_default), 0, sctp_sysctl_handle_int,
SCTPCTL_PMTU_RAISE_TIME_DESC);
sysctl_add_oid(&sysctl_oid_top, "shutdown_guard_time", CTLTYPE_INT|CTLFLAG_RW,
- &SCTP_BASE_SYSCTL(sctp_shutdown_guard_time_default), 0, sctp_sysctl_handle_int,
+ &SCTP_BASE_SYSCTL(sctp_shutdown_guard_time_default), 0, sctp_sysctl_handle_int,
SCTPCTL_SHUTDOWN_GUARD_TIME_DESC);
sysctl_add_oid(&sysctl_oid_top, "secret_lifetime", CTLTYPE_INT|CTLFLAG_RW,
- &SCTP_BASE_SYSCTL(sctp_secret_lifetime_default), 0, sctp_sysctl_handle_int,
+ &SCTP_BASE_SYSCTL(sctp_secret_lifetime_default), 0, sctp_sysctl_handle_int,
SCTPCTL_SECRET_LIFETIME_DESC);
sysctl_add_oid(&sysctl_oid_top, "rto_max", CTLTYPE_INT|CTLFLAG_RW,
- &SCTP_BASE_SYSCTL(sctp_rto_max_default), 0, sctp_sysctl_handle_int,
+ &SCTP_BASE_SYSCTL(sctp_rto_max_default), 0, sctp_sysctl_handle_int,
SCTPCTL_RTO_MAX_DESC);
sysctl_add_oid(&sysctl_oid_top, "rto_min", CTLTYPE_INT|CTLFLAG_RW,
- &SCTP_BASE_SYSCTL(sctp_rto_min_default), 0, sctp_sysctl_handle_int,
+ &SCTP_BASE_SYSCTL(sctp_rto_min_default), 0, sctp_sysctl_handle_int,
SCTPCTL_RTO_MIN_DESC);
sysctl_add_oid(&sysctl_oid_top, "rto_initial", CTLTYPE_INT|CTLFLAG_RW,
- &SCTP_BASE_SYSCTL(sctp_rto_initial_default), 0, sctp_sysctl_handle_int,
+ &SCTP_BASE_SYSCTL(sctp_rto_initial_default), 0, sctp_sysctl_handle_int,
SCTPCTL_RTO_INITIAL_DESC);
sysctl_add_oid(&sysctl_oid_top, "init_rto_max", CTLTYPE_INT|CTLFLAG_RW,
- &SCTP_BASE_SYSCTL(sctp_init_rto_max_default), 0, sctp_sysctl_handle_int,
+ &SCTP_BASE_SYSCTL(sctp_init_rto_max_default), 0, sctp_sysctl_handle_int,
SCTPCTL_INIT_RTO_MAX_DESC);
sysctl_add_oid(&sysctl_oid_top, "valid_cookie_life", CTLTYPE_INT|CTLFLAG_RW,
- &SCTP_BASE_SYSCTL(sctp_valid_cookie_life_default), 0, sctp_sysctl_handle_int,
+ &SCTP_BASE_SYSCTL(sctp_valid_cookie_life_default), 0, sctp_sysctl_handle_int,
SCTPCTL_VALID_COOKIE_LIFE_DESC);
sysctl_add_oid(&sysctl_oid_top, "init_rtx_max", CTLTYPE_INT|CTLFLAG_RW,
- &SCTP_BASE_SYSCTL(sctp_init_rtx_max_default), 0, sctp_sysctl_handle_int,
+ &SCTP_BASE_SYSCTL(sctp_init_rtx_max_default), 0, sctp_sysctl_handle_int,
SCTPCTL_INIT_RTX_MAX_DESC);
sysctl_add_oid(&sysctl_oid_top, "assoc_rtx_max", CTLTYPE_INT|CTLFLAG_RW,
- &SCTP_BASE_SYSCTL(sctp_assoc_rtx_max_default), 0, sctp_sysctl_handle_int,
+ &SCTP_BASE_SYSCTL(sctp_assoc_rtx_max_default), 0, sctp_sysctl_handle_int,
SCTPCTL_ASSOC_RTX_MAX_DESC);
sysctl_add_oid(&sysctl_oid_top, "path_rtx_max", CTLTYPE_INT|CTLFLAG_RW,
- &SCTP_BASE_SYSCTL(sctp_path_rtx_max_default), 0, sctp_sysctl_handle_int,
+ &SCTP_BASE_SYSCTL(sctp_path_rtx_max_default), 0, sctp_sysctl_handle_int,
SCTPCTL_PATH_RTX_MAX_DESC);
sysctl_add_oid(&sysctl_oid_top, "path_pf_threshold", CTLTYPE_INT|CTLFLAG_RW,
@@ -1573,83 +1581,83 @@ sysctl_setup_sctp(void)
SCTPCTL_PATH_PF_THRESHOLD_DESC);
sysctl_add_oid(&sysctl_oid_top, "add_more_on_output", CTLTYPE_INT|CTLFLAG_RW,
- &SCTP_BASE_SYSCTL(sctp_add_more_threshold), 0, sctp_sysctl_handle_int,
+ &SCTP_BASE_SYSCTL(sctp_add_more_threshold), 0, sctp_sysctl_handle_int,
SCTPCTL_ADD_MORE_ON_OUTPUT_DESC);
sysctl_add_oid(&sysctl_oid_top, "incoming_streams", CTLTYPE_INT|CTLFLAG_RW,
- &SCTP_BASE_SYSCTL(sctp_nr_incoming_streams_default), 0, sctp_sysctl_handle_int,
+ &SCTP_BASE_SYSCTL(sctp_nr_incoming_streams_default), 0, sctp_sysctl_handle_int,
SCTPCTL_INCOMING_STREAMS_DESC);
sysctl_add_oid(&sysctl_oid_top, "outgoing_streams", CTLTYPE_INT|CTLFLAG_RW,
- &SCTP_BASE_SYSCTL(sctp_nr_outgoing_streams_default), 0, sctp_sysctl_handle_int,
+ &SCTP_BASE_SYSCTL(sctp_nr_outgoing_streams_default), 0, sctp_sysctl_handle_int,
SCTPCTL_OUTGOING_STREAMS_DESC);
sysctl_add_oid(&sysctl_oid_top, "cmt_on_off", CTLTYPE_INT|CTLFLAG_RW,
- &SCTP_BASE_SYSCTL(sctp_cmt_on_off), 0, sctp_sysctl_handle_int,
+ &SCTP_BASE_SYSCTL(sctp_cmt_on_off), 0, sctp_sysctl_handle_int,
SCTPCTL_CMT_ON_OFF_DESC);
sysctl_add_oid(&sysctl_oid_top, "cmt_use_dac", CTLTYPE_INT|CTLFLAG_RW,
- &SCTP_BASE_SYSCTL(sctp_cmt_use_dac), 0, sctp_sysctl_handle_int,
+ &SCTP_BASE_SYSCTL(sctp_cmt_use_dac), 0, sctp_sysctl_handle_int,
SCTPCTL_CMT_USE_DAC_DESC);
sysctl_add_oid(&sysctl_oid_top, "cwnd_maxburst", CTLTYPE_INT|CTLFLAG_RW,
- &SCTP_BASE_SYSCTL(sctp_use_cwnd_based_maxburst), 0, sctp_sysctl_handle_int,
+ &SCTP_BASE_SYSCTL(sctp_use_cwnd_based_maxburst), 0, sctp_sysctl_handle_int,
SCTPCTL_CWND_MAXBURST_DESC);
sysctl_add_oid(&sysctl_oid_top, "nat_friendly", CTLTYPE_INT|CTLFLAG_RW,
- &SCTP_BASE_SYSCTL(sctp_nat_friendly), 0, sctp_sysctl_handle_int,
+ &SCTP_BASE_SYSCTL(sctp_nat_friendly), 0, sctp_sysctl_handle_int,
SCTPCTL_NAT_FRIENDLY_DESC);
sysctl_add_oid(&sysctl_oid_top, "abc_l_var", CTLTYPE_INT|CTLFLAG_RW,
- &SCTP_BASE_SYSCTL(sctp_L2_abc_variable), 0, sctp_sysctl_handle_int,
+ &SCTP_BASE_SYSCTL(sctp_L2_abc_variable), 0, sctp_sysctl_handle_int,
SCTPCTL_ABC_L_VAR_DESC);
sysctl_add_oid(&sysctl_oid_top, "max_chained_mbufs", CTLTYPE_INT|CTLFLAG_RW,
- &SCTP_BASE_SYSCTL(sctp_mbuf_threshold_count), 0, sctp_sysctl_handle_int,
+ &SCTP_BASE_SYSCTL(sctp_mbuf_threshold_count), 0, sctp_sysctl_handle_int,
SCTPCTL_MAX_CHAINED_MBUFS_DESC);
sysctl_add_oid(&sysctl_oid_top, "do_sctp_drain", CTLTYPE_INT|CTLFLAG_RW,
- &SCTP_BASE_SYSCTL(sctp_do_drain), 0, sctp_sysctl_handle_int,
+ &SCTP_BASE_SYSCTL(sctp_do_drain), 0, sctp_sysctl_handle_int,
SCTPCTL_DO_SCTP_DRAIN_DESC);
sysctl_add_oid(&sysctl_oid_top, "hb_max_burst", CTLTYPE_INT|CTLFLAG_RW,
- &SCTP_BASE_SYSCTL(sctp_hb_maxburst), 0, sctp_sysctl_handle_int,
+ &SCTP_BASE_SYSCTL(sctp_hb_maxburst), 0, sctp_sysctl_handle_int,
SCTPCTL_HB_MAX_BURST_DESC);
sysctl_add_oid(&sysctl_oid_top, "abort_at_limit", CTLTYPE_INT|CTLFLAG_RW,
- &SCTP_BASE_SYSCTL(sctp_abort_if_one_2_one_hits_limit), 0, sctp_sysctl_handle_int,
+ &SCTP_BASE_SYSCTL(sctp_abort_if_one_2_one_hits_limit), 0, sctp_sysctl_handle_int,
SCTPCTL_ABORT_AT_LIMIT_DESC);
sysctl_add_oid(&sysctl_oid_top, "min_residual", CTLTYPE_INT|CTLFLAG_RW,
- &SCTP_BASE_SYSCTL(sctp_min_residual), 0, sctp_sysctl_handle_int,
+ &SCTP_BASE_SYSCTL(sctp_min_residual), 0, sctp_sysctl_handle_int,
SCTPCTL_MIN_RESIDUAL_DESC);
sysctl_add_oid(&sysctl_oid_top, "max_retran_chunk", CTLTYPE_INT|CTLFLAG_RW,
- &SCTP_BASE_SYSCTL(sctp_max_retran_chunk), 0, sctp_sysctl_handle_int,
+ &SCTP_BASE_SYSCTL(sctp_max_retran_chunk), 0, sctp_sysctl_handle_int,
SCTPCTL_MAX_RETRAN_CHUNK_DESC);
sysctl_add_oid(&sysctl_oid_top, "log_level", CTLTYPE_INT|CTLFLAG_RW,
- &SCTP_BASE_SYSCTL(sctp_logging_level), 0, sctp_sysctl_handle_int,
+ &SCTP_BASE_SYSCTL(sctp_logging_level), 0, sctp_sysctl_handle_int,
SCTPCTL_LOGGING_LEVEL_DESC);
sysctl_add_oid(&sysctl_oid_top, "default_cc_module", CTLTYPE_INT|CTLFLAG_RW,
- &SCTP_BASE_SYSCTL(sctp_default_cc_module), 0, sctp_sysctl_handle_int,
+ &SCTP_BASE_SYSCTL(sctp_default_cc_module), 0, sctp_sysctl_handle_int,
SCTPCTL_DEFAULT_CC_MODULE_DESC);
sysctl_add_oid(&sysctl_oid_top, "default_ss_module", CTLTYPE_INT|CTLFLAG_RW,
- &SCTP_BASE_SYSCTL(sctp_default_ss_module), 0, sctp_sysctl_handle_int,
+ &SCTP_BASE_SYSCTL(sctp_default_ss_module), 0, sctp_sysctl_handle_int,
SCTPCTL_DEFAULT_SS_MODULE_DESC);
sysctl_add_oid(&sysctl_oid_top, "default_frag_interleave", CTLTYPE_INT|CTLFLAG_RW,
- &SCTP_BASE_SYSCTL(sctp_default_frag_interleave), 0, sctp_sysctl_handle_int,
+ &SCTP_BASE_SYSCTL(sctp_default_frag_interleave), 0, sctp_sysctl_handle_int,
SCTPCTL_DEFAULT_FRAG_INTERLEAVE_DESC);
sysctl_add_oid(&sysctl_oid_top, "mobility_base", CTLTYPE_INT|CTLFLAG_RW,
- &SCTP_BASE_SYSCTL(sctp_mobility_base), 0, sctp_sysctl_handle_int,
+ &SCTP_BASE_SYSCTL(sctp_mobility_base), 0, sctp_sysctl_handle_int,
SCTPCTL_MOBILITY_BASE_DESC);
sysctl_add_oid(&sysctl_oid_top, "mobility_fasthandoff", CTLTYPE_INT|CTLFLAG_RW,
- &SCTP_BASE_SYSCTL(sctp_mobility_fasthandoff), 0, sctp_sysctl_handle_int,
+ &SCTP_BASE_SYSCTL(sctp_mobility_fasthandoff), 0, sctp_sysctl_handle_int,
SCTPCTL_MOBILITY_FASTHANDOFF_DESC);
#if defined(SCTP_LOCAL_TRACE_BUF)
@@ -1667,52 +1675,56 @@ sysctl_setup_sctp(void)
SCTPCTL_UDP_TUNNELING_PORT_DESC);
sysctl_add_oid(&sysctl_oid_top, "enable_sack_immediately", CTLTYPE_INT|CTLFLAG_RW,
- &SCTP_BASE_SYSCTL(sctp_enable_sack_immediately), 0, sctp_sysctl_handle_int,
+ &SCTP_BASE_SYSCTL(sctp_enable_sack_immediately), 0, sctp_sysctl_handle_int,
SCTPCTL_SACK_IMMEDIATELY_ENABLE_DESC);
sysctl_add_oid(&sysctl_oid_top, "nat_friendly_init", CTLTYPE_INT|CTLFLAG_RW,
- &SCTP_BASE_SYSCTL(sctp_inits_include_nat_friendly), 0, sctp_sysctl_handle_int,
+ &SCTP_BASE_SYSCTL(sctp_inits_include_nat_friendly), 0, sctp_sysctl_handle_int,
SCTPCTL_NAT_FRIENDLY_DESC);
sysctl_add_oid(&sysctl_oid_top, "vtag_time_wait", CTLTYPE_INT|CTLFLAG_RW,
- &SCTP_BASE_SYSCTL(sctp_vtag_time_wait), 0, sctp_sysctl_handle_int,
+ &SCTP_BASE_SYSCTL(sctp_vtag_time_wait), 0, sctp_sysctl_handle_int,
SCTPCTL_TIME_WAIT_DESC);
sysctl_add_oid(&sysctl_oid_top, "buffer_splitting", CTLTYPE_INT|CTLFLAG_RW,
- &SCTP_BASE_SYSCTL(sctp_buffer_splitting), 0, sctp_sysctl_handle_int,
+ &SCTP_BASE_SYSCTL(sctp_buffer_splitting), 0, sctp_sysctl_handle_int,
SCTPCTL_BUFFER_SPLITTING_DESC);
sysctl_add_oid(&sysctl_oid_top, "initial_cwnd", CTLTYPE_INT|CTLFLAG_RW,
- &SCTP_BASE_SYSCTL(sctp_initial_cwnd), 0, sctp_sysctl_handle_int,
+ &SCTP_BASE_SYSCTL(sctp_initial_cwnd), 0, sctp_sysctl_handle_int,
SCTPCTL_INITIAL_CWND_DESC);
sysctl_add_oid(&sysctl_oid_top, "rttvar_bw", CTLTYPE_INT|CTLFLAG_RW,
- &SCTP_BASE_SYSCTL(sctp_rttvar_bw), 0, sctp_sysctl_handle_int,
+ &SCTP_BASE_SYSCTL(sctp_rttvar_bw), 0, sctp_sysctl_handle_int,
SCTPCTL_RTTVAR_BW_DESC);
sysctl_add_oid(&sysctl_oid_top, "rttvar_rtt", CTLTYPE_INT|CTLFLAG_RW,
- &SCTP_BASE_SYSCTL(sctp_rttvar_rtt), 0, sctp_sysctl_handle_int,
+ &SCTP_BASE_SYSCTL(sctp_rttvar_rtt), 0, sctp_sysctl_handle_int,
SCTPCTL_RTTVAR_RTT_DESC);
sysctl_add_oid(&sysctl_oid_top, "rttvar_eqret", CTLTYPE_INT|CTLFLAG_RW,
- &SCTP_BASE_SYSCTL(sctp_rttvar_eqret), 0, sctp_sysctl_handle_int,
+ &SCTP_BASE_SYSCTL(sctp_rttvar_eqret), 0, sctp_sysctl_handle_int,
SCTPCTL_RTTVAR_EQRET_DESC);
sysctl_add_oid(&sysctl_oid_top, "rttvar_steady_step", CTLTYPE_INT|CTLFLAG_RW,
- &SCTP_BASE_SYSCTL(sctp_steady_step), 0, sctp_sysctl_handle_int,
+ &SCTP_BASE_SYSCTL(sctp_steady_step), 0, sctp_sysctl_handle_int,
SCTPCTL_RTTVAR_STEADYS_DESC);
sysctl_add_oid(&sysctl_oid_top, "use_dcccecn", CTLTYPE_INT|CTLFLAG_RW,
- &SCTP_BASE_SYSCTL(sctp_use_dccc_ecn), 0, sctp_sysctl_handle_int,
+ &SCTP_BASE_SYSCTL(sctp_use_dccc_ecn), 0, sctp_sysctl_handle_int,
SCTPCTL_RTTVAR_DCCCECN_DESC);
sysctl_add_oid(&sysctl_oid_top, "blackhole", CTLTYPE_INT|CTLFLAG_RW,
- &SCTP_BASE_SYSCTL(sctp_blackhole), 0, sctp_sysctl_handle_int,
- SCTPCTL_BLACKHOLE_DESC);
+ &SCTP_BASE_SYSCTL(sctp_blackhole), 0, sctp_sysctl_handle_int,
+ SCTPCTL_BLACKHOLE_DESC);
+
+ sysctl_add_oid(&sysctl_oid_top, "sendall_limit", CTLTYPE_INT|CTLFLAG_RW,
+ &SCTP_BASE_SYSCTL(sctp_sendall_limit), 0, sctp_sysctl_handle_int,
+ SCTPCTL_SENDALL_LIMIT_DESC);
sysctl_add_oid(&sysctl_oid_top, "diag_info_code", CTLTYPE_INT|CTLFLAG_RW,
- &SCTP_BASE_SYSCTL(sctp_diag_info_code), 0, sctp_sysctl_handle_int,
- SCTPCTL_DIAG_INFO_CODE_DESC);
+ &SCTP_BASE_SYSCTL(sctp_diag_info_code), 0, sctp_sysctl_handle_int,
+ SCTPCTL_DIAG_INFO_CODE_DESC);
#ifdef SCTP_DEBUG
sysctl_add_oid(&sysctl_oid_top, "debug", CTLTYPE_INT|CTLFLAG_RW,
diff --git a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_sysctl.h b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_sysctl.h
index 4f10ff67691..3957e619fa8 100755
--- a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_sysctl.h
+++ b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_sysctl.h
@@ -34,7 +34,7 @@
#ifdef __FreeBSD__
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/netinet/sctp_sysctl.h 299543 2016-05-12 16:34:59Z tuexen $");
+__FBSDID("$FreeBSD: head/sys/netinet/sctp_sysctl.h 356357 2020-01-04 20:33:12Z tuexen $");
#endif
#ifndef _NETINET_SCTP_SYSCTL_H_
@@ -125,6 +125,7 @@ struct sctp_sysctl {
uint32_t sctp_buffer_splitting;
uint32_t sctp_initial_cwnd;
uint32_t sctp_blackhole;
+ uint32_t sctp_sendall_limit;
#if defined(SCTP_DEBUG)
uint32_t sctp_debug_on;
#endif
@@ -235,7 +236,7 @@ struct sctp_sysctl {
#define SCTPCTL_MAXBURST_DEFAULT SCTP_DEF_MAX_BURST
/* fr_maxburst: Default max burst for sctp endpoints when fast retransmitting */
-#define SCTPCTL_FRMAXBURST_DESC "Default fr max burst for sctp endpoints"
+#define SCTPCTL_FRMAXBURST_DESC "Default max burst for SCTP endpoints when fast retransmitting"
#define SCTPCTL_FRMAXBURST_MIN 0
#define SCTPCTL_FRMAXBURST_MAX 0xFFFFFFFF
#define SCTPCTL_FRMAXBURST_DEFAULT SCTP_DEF_FRMAX_BURST
@@ -266,7 +267,7 @@ struct sctp_sysctl {
#define SCTPCTL_MIN_SPLIT_POINT_DEFAULT SCTP_DEFAULT_SPLIT_POINT_MIN
/* chunkscale: Tunable for Scaling of number of chunks and messages */
-#define SCTPCTL_CHUNKSCALE_DESC "Tunable for Scaling of number of chunks and messages"
+#define SCTPCTL_CHUNKSCALE_DESC "Tunable for scaling of number of chunks and messages"
#define SCTPCTL_CHUNKSCALE_MIN 1
#define SCTPCTL_CHUNKSCALE_MAX 0xFFFFFFFF
#define SCTPCTL_CHUNKSCALE_DEFAULT SCTP_CHUNKQUEUE_SCALE
@@ -350,7 +351,7 @@ struct sctp_sysctl {
#define SCTPCTL_VALID_COOKIE_LIFE_DEFAULT SCTP_DEFAULT_COOKIE_LIFE
/* init_rtx_max: Default maximum number of retransmission for INIT chunks */
-#define SCTPCTL_INIT_RTX_MAX_DESC "Default maximum number of retransmission for INIT chunks"
+#define SCTPCTL_INIT_RTX_MAX_DESC "Default maximum number of retransmissions for INIT chunks"
#define SCTPCTL_INIT_RTX_MAX_MIN 0
#define SCTPCTL_INIT_RTX_MAX_MAX 0xFFFFFFFF
#define SCTPCTL_INIT_RTX_MAX_DEFAULT SCTP_DEF_MAX_INIT
@@ -403,8 +404,8 @@ struct sctp_sysctl {
#define SCTPCTL_CMT_USE_DAC_MAX 1
#define SCTPCTL_CMT_USE_DAC_DEFAULT 0
-/* cwnd_maxburst: Use a CWND adjusting maxburst */
-#define SCTPCTL_CWND_MAXBURST_DESC "Use a CWND adjusting maxburst"
+/* cwnd_maxburst: Use a CWND adjusting to implement maxburst */
+#define SCTPCTL_CWND_MAXBURST_DESC "Adjust congestion control window to limit maximum burst when sending"
#define SCTPCTL_CWND_MAXBURST_MIN 0
#define SCTPCTL_CWND_MAXBURST_MAX 1
#define SCTPCTL_CWND_MAXBURST_DEFAULT 1
@@ -440,7 +441,7 @@ struct sctp_sysctl {
#define SCTPCTL_HB_MAX_BURST_DEFAULT SCTP_DEF_HBMAX_BURST
/* abort_at_limit: When one-2-one hits qlimit abort */
-#define SCTPCTL_ABORT_AT_LIMIT_DESC "When one-2-one hits qlimit abort"
+#define SCTPCTL_ABORT_AT_LIMIT_DESC "Abort when one-to-one hits qlimit"
#define SCTPCTL_ABORT_AT_LIMIT_MIN 0
#define SCTPCTL_ABORT_AT_LIMIT_MAX 1
#define SCTPCTL_ABORT_AT_LIMIT_DEFAULT 0
@@ -452,7 +453,7 @@ struct sctp_sysctl {
#define SCTPCTL_MIN_RESIDUAL_DEFAULT 1452
/* max_retran_chunk: max chunk retransmissions */
-#define SCTPCTL_MAX_RETRAN_CHUNK_DESC "Maximum times an unlucky chunk can be retran'd before assoc abort"
+#define SCTPCTL_MAX_RETRAN_CHUNK_DESC "Maximum times an unlucky chunk can be retransmitted before assoc abort"
#define SCTPCTL_MAX_RETRAN_CHUNK_MIN 0
#define SCTPCTL_MAX_RETRAN_CHUNK_MAX 65535
#define SCTPCTL_MAX_RETRAN_CHUNK_DEFAULT 30
@@ -504,67 +505,73 @@ struct sctp_sysctl {
#endif
/* Enable sending of the SACK-IMMEDIATELY bit */
-#define SCTPCTL_SACK_IMMEDIATELY_ENABLE_DESC "Enable sending of the SACK-IMMEDIATELY-bit."
+#define SCTPCTL_SACK_IMMEDIATELY_ENABLE_DESC "Enable sending of the SACK-IMMEDIATELY-bit"
#define SCTPCTL_SACK_IMMEDIATELY_ENABLE_MIN 0
#define SCTPCTL_SACK_IMMEDIATELY_ENABLE_MAX 1
#define SCTPCTL_SACK_IMMEDIATELY_ENABLE_DEFAULT SCTPCTL_SACK_IMMEDIATELY_ENABLE_MAX
/* Enable sending of the NAT-FRIENDLY message */
-#define SCTPCTL_NAT_FRIENDLY_INITS_DESC "Enable sending of the nat-friendly SCTP option on INITs."
+#define SCTPCTL_NAT_FRIENDLY_INITS_DESC "Enable sending of the nat-friendly SCTP option on INITs"
#define SCTPCTL_NAT_FRIENDLY_INITS_MIN 0
#define SCTPCTL_NAT_FRIENDLY_INITS_MAX 1
#define SCTPCTL_NAT_FRIENDLY_INITS_DEFAULT SCTPCTL_NAT_FRIENDLY_INITS_MIN
/* Vtag time wait in seconds */
-#define SCTPCTL_TIME_WAIT_DESC "Vtag time wait time in seconds, 0 disables it."
+#define SCTPCTL_TIME_WAIT_DESC "Vtag time wait time in seconds, 0 disables it"
#define SCTPCTL_TIME_WAIT_MIN 0
#define SCTPCTL_TIME_WAIT_MAX 0xffffffff
#define SCTPCTL_TIME_WAIT_DEFAULT SCTP_TIME_WAIT
/* Enable Send/Receive buffer splitting */
-#define SCTPCTL_BUFFER_SPLITTING_DESC "Enable send/receive buffer splitting."
+#define SCTPCTL_BUFFER_SPLITTING_DESC "Enable send/receive buffer splitting"
#define SCTPCTL_BUFFER_SPLITTING_MIN 0
#define SCTPCTL_BUFFER_SPLITTING_MAX 0x3
#define SCTPCTL_BUFFER_SPLITTING_DEFAULT SCTPCTL_BUFFER_SPLITTING_MIN
-/* Initial congestion window in MTU */
-#define SCTPCTL_INITIAL_CWND_DESC "Initial congestion window in MTUs"
+/* Initial congestion window in MTUs */
+#define SCTPCTL_INITIAL_CWND_DESC "Defines the initial congestion window size in MTUs"
#define SCTPCTL_INITIAL_CWND_MIN 0
#define SCTPCTL_INITIAL_CWND_MAX 0xffffffff
#define SCTPCTL_INITIAL_CWND_DEFAULT 3
/* rttvar smooth avg for bw calc */
-#define SCTPCTL_RTTVAR_BW_DESC "Shift amount for bw smoothing on rtt calc"
+#define SCTPCTL_RTTVAR_BW_DESC "Shift amount DCCC uses for bw smoothing on rtt calc"
#define SCTPCTL_RTTVAR_BW_MIN 0
#define SCTPCTL_RTTVAR_BW_MAX 32
#define SCTPCTL_RTTVAR_BW_DEFAULT 4
/* rttvar smooth avg for bw calc */
-#define SCTPCTL_RTTVAR_RTT_DESC "Shift amount for rtt smoothing on rtt calc"
+#define SCTPCTL_RTTVAR_RTT_DESC "Shift amount DCCC uses for rtt smoothing on rtt calc"
#define SCTPCTL_RTTVAR_RTT_MIN 0
#define SCTPCTL_RTTVAR_RTT_MAX 32
#define SCTPCTL_RTTVAR_RTT_DEFAULT 5
-#define SCTPCTL_RTTVAR_EQRET_DESC "What to return when rtt and bw are unchanged"
+#define SCTPCTL_RTTVAR_EQRET_DESC "Whether DCCC increases cwnd when the rtt and bw are unchanged"
#define SCTPCTL_RTTVAR_EQRET_MIN 0
#define SCTPCTL_RTTVAR_EQRET_MAX 1
#define SCTPCTL_RTTVAR_EQRET_DEFAULT 0
-#define SCTPCTL_RTTVAR_STEADYS_DESC "How many the sames it takes to try step down of cwnd"
+#define SCTPCTL_RTTVAR_STEADYS_DESC "Number of identical bw measurements DCCC takes to try step down of cwnd"
#define SCTPCTL_RTTVAR_STEADYS_MIN 0
#define SCTPCTL_RTTVAR_STEADYS_MAX 0xFFFF
#define SCTPCTL_RTTVAR_STEADYS_DEFAULT 20 /* 0 means disable feature */
-#define SCTPCTL_RTTVAR_DCCCECN_DESC "Enable for RTCC CC datacenter ECN"
+#define SCTPCTL_RTTVAR_DCCCECN_DESC "Enable ECN for DCCC."
#define SCTPCTL_RTTVAR_DCCCECN_MIN 0
#define SCTPCTL_RTTVAR_DCCCECN_MAX 1
#define SCTPCTL_RTTVAR_DCCCECN_DEFAULT 1 /* 0 means disable feature */
-#define SCTPCTL_BLACKHOLE_DESC "Enable SCTP blackholing. See blackhole(4) for more details."
+#define SCTPCTL_BLACKHOLE_DESC "Enable SCTP blackholing, see blackhole(4) for more details"
#define SCTPCTL_BLACKHOLE_MIN 0
#define SCTPCTL_BLACKHOLE_MAX 2
#define SCTPCTL_BLACKHOLE_DEFAULT SCTPCTL_BLACKHOLE_MIN
+/* sendall_limit: Maximum message with SCTP_SENDALL */
+#define SCTPCTL_SENDALL_LIMIT_DESC "Maximum size of a message send with SCTP_SENDALL"
+#define SCTPCTL_SENDALL_LIMIT_MIN 0
+#define SCTPCTL_SENDALL_LIMIT_MAX 0xFFFFFFFF
+#define SCTPCTL_SENDALL_LIMIT_DEFAULT 1432
+
#define SCTPCTL_DIAG_INFO_CODE_DESC "Diagnostic information error cause code"
#define SCTPCTL_DIAG_INFO_CODE_MIN 0
#define SCTPCTL_DIAG_INFO_CODE_MAX 65535
@@ -591,7 +598,7 @@ struct sctp_sysctl {
#endif
#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING)
-#define SCTPCTL_OUTPUT_UNLOCKED_DESC "Unlock socket when sending packets down to IP."
+#define SCTPCTL_OUTPUT_UNLOCKED_DESC "Unlock socket when sending packets down to IP"
#define SCTPCTL_OUTPUT_UNLOCKED_MIN 0
#define SCTPCTL_OUTPUT_UNLOCKED_MAX 1
#define SCTPCTL_OUTPUT_UNLOCKED_DEFAULT SCTPCTL_OUTPUT_UNLOCKED_MIN
diff --git a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_timer.c b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_timer.c
index 426ba44aeee..98fafec11c8 100755
--- a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_timer.c
+++ b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_timer.c
@@ -34,7 +34,7 @@
#ifdef __FreeBSD__
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/netinet/sctp_timer.c 317592 2017-04-29 09:57:27Z tuexen $");
+__FBSDID("$FreeBSD: head/sys/netinet/sctp_timer.c 338134 2018-08-21 13:25:32Z tuexen $");
#endif
#define _IP_VHL
@@ -967,7 +967,7 @@ sctp_t3rxt_timer(struct sctp_inpcb *inp,
* Special case for cookie-echo'ed case, we don't do output but must
* await the COOKIE-ACK before retransmission
*/
- if (SCTP_GET_STATE(&stcb->asoc) == SCTP_STATE_COOKIE_ECHOED) {
+ if (SCTP_GET_STATE(stcb) == SCTP_STATE_COOKIE_ECHOED) {
/*
* Here we just reset the timer and start again since we
* have not established the asoc
@@ -1009,7 +1009,7 @@ sctp_t1init_timer(struct sctp_inpcb *inp,
sctp_send_initiate(inp, stcb, SCTP_SO_NOT_LOCKED);
return (0);
}
- if (SCTP_GET_STATE((&stcb->asoc)) != SCTP_STATE_COOKIE_WAIT) {
+ if (SCTP_GET_STATE(stcb) != SCTP_STATE_COOKIE_WAIT) {
return (0);
}
if (sctp_threshold_management(inp, stcb, net,
@@ -1057,7 +1057,7 @@ sctp_cookie_timer(struct sctp_inpcb *inp,
}
}
if (cookie == NULL) {
- if (SCTP_GET_STATE(&stcb->asoc) == SCTP_STATE_COOKIE_ECHOED) {
+ if (SCTP_GET_STATE(stcb) == SCTP_STATE_COOKIE_ECHOED) {
/* FOOBAR! */
struct mbuf *op_err;
@@ -1069,7 +1069,7 @@ sctp_cookie_timer(struct sctp_inpcb *inp,
#ifdef INVARIANTS
panic("Cookie timer expires in wrong state?");
#else
- SCTP_PRINTF("Strange in state %d not cookie-echoed yet c-e timer expires?\n", SCTP_GET_STATE(&stcb->asoc));
+ SCTP_PRINTF("Strange in state %d not cookie-echoed yet c-e timer expires?\n", SCTP_GET_STATE(stcb));
return (0);
#endif
}
@@ -1577,16 +1577,15 @@ sctp_autoclose_timer(struct sctp_inpcb *inp,
* there is nothing queued to send, so I'm
* done...
*/
- if (SCTP_GET_STATE(asoc) != SCTP_STATE_SHUTDOWN_SENT) {
+ if (SCTP_GET_STATE(stcb) != SCTP_STATE_SHUTDOWN_SENT) {
/* only send SHUTDOWN 1st time thru */
struct sctp_nets *netp;
- if ((SCTP_GET_STATE(asoc) == SCTP_STATE_OPEN) ||
- (SCTP_GET_STATE(asoc) == SCTP_STATE_SHUTDOWN_RECEIVED)) {
+ if ((SCTP_GET_STATE(stcb) == SCTP_STATE_OPEN) ||
+ (SCTP_GET_STATE(stcb) == SCTP_STATE_SHUTDOWN_RECEIVED)) {
SCTP_STAT_DECR_GAUGE32(sctps_currestab);
}
- SCTP_SET_STATE(asoc, SCTP_STATE_SHUTDOWN_SENT);
- SCTP_CLEAR_SUBSTATE(asoc, SCTP_STATE_SHUTDOWN_PENDING);
+ SCTP_SET_STATE(stcb, SCTP_STATE_SHUTDOWN_SENT);
sctp_stop_timers_for_shutdown(stcb);
if (stcb->asoc.alternate) {
netp = stcb->asoc.alternate;
diff --git a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_uio.h b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_uio.h
index 9d31aa1590a..ecc74cc494e 100755
--- a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_uio.h
+++ b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_uio.h
@@ -34,7 +34,7 @@
#ifdef __FreeBSD__
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/netinet/sctp_uio.h 326672 2017-12-07 22:19:08Z tuexen $");
+__FBSDID("$FreeBSD: head/sys/netinet/sctp_uio.h 336511 2018-07-19 20:16:33Z tuexen $");
#endif
#ifndef _NETINET_SCTP_UIO_H_
@@ -1136,24 +1136,14 @@ struct sctpstat {
#define SCTP_STAT_DECR_COUNTER64(_x) SCTP_STAT_DECR(_x)
#define SCTP_STAT_DECR_GAUGE32(_x) SCTP_STAT_DECR(_x)
-#if defined(__Userspace__)
union sctp_sockstore {
-#if defined(INET)
struct sockaddr_in sin;
-#endif
-#if defined(INET6)
struct sockaddr_in6 sin6;
-#endif
+#if defined(__Userspace__)
struct sockaddr_conn sconn;
+#endif
struct sockaddr sa;
};
-#else
-union sctp_sockstore {
- struct sockaddr_in sin;
- struct sockaddr_in6 sin6;
- struct sockaddr sa;
-};
-#endif
/***********************************/
@@ -1210,10 +1200,10 @@ struct xsctp_inpcb {
uint16_t qlen;
uint16_t maxqlen;
#endif
-#if defined(__Windows__)
- uint16_t padding;
-#endif
-#if !(defined(__FreeBSD__) && (__FreeBSD_version < 1001517))
+ uint16_t __spare16;
+#if defined(__FreeBSD__)
+ kvaddr_t socket;
+#else
void *socket;
#endif
#if defined(__FreeBSD__) && __FreeBSD_version > 1100096
@@ -1225,19 +1215,7 @@ struct xsctp_inpcb {
#elif defined(__FreeBSD__) && (__FreeBSD_version < 1001517)
uint32_t extra_padding[31]; /* future */
#else
-#if defined(__LP64__)
-#if defined(__FreeBSD__) && __FreeBSD_version > 1100096
- uint32_t extra_padding[27]; /* future */
-#else
- uint32_t extra_padding[29]; /* future */
-#endif
-#else
-#if defined(__FreeBSD__) && __FreeBSD_version > 1100096
- uint32_t extra_padding[28]; /* future */
-#else
- uint32_t extra_padding[30]; /* future */
-#endif
-#endif
+ uint32_t extra_padding[26]; /* future */
#endif
};
diff --git a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_userspace.c b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_userspace.c
index 6fcc08d16d3..28922b6a176 100755
--- a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_userspace.c
+++ b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_userspace.c
@@ -31,8 +31,10 @@
#include <netinet/sctp_pcb.h>
#include <sys/timeb.h>
#include <iphlpapi.h>
+#if !defined(__MINGW32__)
#pragma comment(lib, "IPHLPAPI.lib")
#endif
+#endif
#include <netinet/sctp_os_userspace.h>
#if defined(__Userspace_os_FreeBSD)
#include <pthread_np.h>
@@ -46,6 +48,10 @@
/* Adapter to translate Unix thread start routines to Windows thread start
* routines.
*/
+#if defined(__MINGW32__)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wpedantic"
+#endif
static DWORD WINAPI
sctp_create_thread_adapter(void *arg) {
start_routine_t start_routine = (start_routine_t)arg;
@@ -61,6 +67,11 @@ sctp_userspace_thread_create(userland_thread_t *thread, start_routine_t start_ro
return GetLastError();
return 0;
}
+
+#if defined(__MINGW32__)
+#pragma GCC diagnostic pop
+#endif
+
#else
int
sctp_userspace_thread_create(userland_thread_t *thread, start_routine_t start_routine)
@@ -115,6 +126,19 @@ sctp_userspace_get_mtu_from_ifn(uint32_t if_index, int af)
}
#endif
+#if defined(__Userspace_os_Darwin) || defined(__Userspace_os_DragonFly) || defined(__Userspace_os_Linux) || defined(__Userspace_os_NaCl) || defined(__Userspace_os_NetBSD) || defined(__Userspace_os_Windows) || defined(__Userspace_os_Fuchsia)
+int
+timingsafe_bcmp(const void *b1, const void *b2, size_t n)
+{
+ const unsigned char *p1 = b1, *p2 = b2;
+ int ret = 0;
+
+ for (; n > 0; n--)
+ ret |= *p1++ ^ *p2++;
+ return (ret != 0);
+}
+#endif
+
#ifdef _WIN32
int
sctp_userspace_get_mtu_from_ifn(uint32_t if_index, int af)
diff --git a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_usrreq.c b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_usrreq.c
index bb5ea8e0b00..6a19f62aa08 100755
--- a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_usrreq.c
+++ b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_usrreq.c
@@ -34,7 +34,7 @@
#ifdef __FreeBSD__
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/netinet/sctp_usrreq.c 334725 2018-06-06 19:27:06Z tuexen $");
+__FBSDID("$FreeBSD: head/sys/netinet/sctp_usrreq.c 356270 2020-01-02 13:55:10Z tuexen $");
#endif
#include <netinet/sctp_os.h>
@@ -61,6 +61,9 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_usrreq.c 334725 2018-06-06 19:27:06Z t
#else
#include <netinet/udp.h>
#endif
+#if defined(__FreeBSD__)
+#include <sys/eventhandler.h>
+#endif
#if defined(HAVE_SCTP_PEELOFF_SOCKOPT)
#include <netinet/sctp_peeloff.h>
@@ -77,7 +80,7 @@ void
#if defined(__Userspace__)
sctp_init(uint16_t port,
int (*conn_output)(void *addr, void *buffer, size_t length, uint8_t tos, uint8_t set_df),
- void (*debug_printf)(const char *format, ...))
+ void (*debug_printf)(const char *format, ...), int start_threads)
#elif defined(__APPLE__) && (!defined(APPLE_LEOPARD) && !defined(APPLE_SNOWLEOPARD) &&!defined(APPLE_LION) && !defined(APPLE_MOUNTAINLION))
sctp_init(struct protosw *pp SCTP_UNUSED, struct domain *dp SCTP_UNUSED)
#else
@@ -92,11 +95,19 @@ sctp_init(void)
sctp_init_sysctls();
#if defined(__Userspace__)
#if defined(__Userspace_os_Windows) || defined(__Userspace_os_NaCl)
+#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
+ srand(0);
+#else
srand((unsigned int)time(NULL));
+#endif
+#else
+#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
+ srandom(0);
#else
srandom(getpid()); /* so inp->sctp_ep.random_numbers are truly random... */
#endif
#endif
+#endif
#if defined(__Panda__)
sctp_sendspace = SB_MAX;
sctp_recvspace = SB_MAX;
@@ -151,9 +162,12 @@ sctp_init(void)
SCTP_BASE_VAR(debug_printf) = debug_printf;
SCTP_BASE_VAR(crc32c_offloaded) = 0;
#endif
- sctp_pcb_init();
#if defined(__Userspace__)
- sctp_start_timer();
+ sctp_pcb_init(start_threads);
+ if (start_threads)
+ sctp_start_timer();
+#else
+ sctp_pcb_init();
#endif
#if defined(SCTP_PACKET_LOGGING)
SCTP_BASE_VAR(packet_log_writers) = 0;
@@ -165,6 +179,10 @@ sctp_init(void)
sctp_start_main_timer();
timeout(sctp_delayed_startup, NULL, 1);
#endif
+#if defined(__FreeBSD__)
+ SCTP_BASE_VAR(eh_tag) = EVENTHANDLER_REGISTER(rt_addrmsg,
+ sctp_addr_change_event_handler, NULL, EVENTHANDLER_PRI_FIRST);
+#endif
}
#if defined(__FreeBSD__)
@@ -287,7 +305,10 @@ sctp_pathmtu_adjustment(struct sctp_tcb *stcb, uint16_t nxtsz)
chk->rec.data.tsn);
}
/* Clear any time so NO RTT is being done */
- chk->do_rtt = 0;
+ if (chk->do_rtt == 1) {
+ chk->do_rtt = 0;
+ chk->whoTo->rto_needed = 1;
+ }
}
}
}
@@ -533,6 +554,24 @@ sctp_ctlinput(int cmd, struct sockaddr *sa, void *vip)
inner_ip->ip_len,
#endif
(uint32_t)ntohs(icmp->icmp_nextmtu));
+#if defined(__Userspace__)
+ if (!(stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) &&
+ (stcb->sctp_socket != NULL)) {
+ struct socket *upcall_socket;
+
+ upcall_socket = stcb->sctp_socket;
+ SOCK_LOCK(upcall_socket);
+ soref(upcall_socket);
+ SOCK_UNLOCK(upcall_socket);
+ if ((upcall_socket->so_upcall != NULL) &&
+ (upcall_socket->so_error != 0)) {
+ (*upcall_socket->so_upcall)(upcall_socket, upcall_socket->so_upcallarg, M_NOWAIT);
+ }
+ ACCEPT_LOCK();
+ SOCK_LOCK(upcall_socket);
+ sorele(upcall_socket);
+ }
+#endif
} else {
#if defined(__FreeBSD__) && __FreeBSD_version < 500000
/*
@@ -1052,7 +1091,6 @@ connected_type:
/* now what about control */
if (control) {
if (inp->control) {
- SCTP_PRINTF("huh? control set?\n");
sctp_m_freem(inp->control);
inp->control = NULL;
}
@@ -1138,8 +1176,7 @@ sctp_disconnect(struct socket *so)
(so->so_linger == 0)) ||
(so->so_rcv.sb_cc > 0)) {
#endif
- if (SCTP_GET_STATE(asoc) !=
- SCTP_STATE_COOKIE_WAIT) {
+ if (SCTP_GET_STATE(stcb) != SCTP_STATE_COOKIE_WAIT) {
/* Left with Data unread */
struct mbuf *op_err;
@@ -1148,8 +1185,8 @@ sctp_disconnect(struct socket *so)
SCTP_STAT_INCR_COUNTER32(sctps_aborted);
}
SCTP_INP_RUNLOCK(inp);
- if ((SCTP_GET_STATE(&stcb->asoc) == SCTP_STATE_OPEN) ||
- (SCTP_GET_STATE(&stcb->asoc) == SCTP_STATE_SHUTDOWN_RECEIVED)) {
+ if ((SCTP_GET_STATE(stcb) == SCTP_STATE_OPEN) ||
+ (SCTP_GET_STATE(stcb) == SCTP_STATE_SHUTDOWN_RECEIVED)) {
SCTP_STAT_DECR_GAUGE32(sctps_currestab);
}
(void)sctp_free_assoc(inp, stcb, SCTP_NORMAL_PROC,
@@ -1164,17 +1201,16 @@ sctp_disconnect(struct socket *so)
if ((*asoc->ss_functions.sctp_ss_is_user_msgs_incomplete)(stcb, asoc)) {
goto abort_anyway;
}
- if ((SCTP_GET_STATE(asoc) != SCTP_STATE_SHUTDOWN_SENT) &&
- (SCTP_GET_STATE(asoc) != SCTP_STATE_SHUTDOWN_ACK_SENT)) {
+ if ((SCTP_GET_STATE(stcb) != SCTP_STATE_SHUTDOWN_SENT) &&
+ (SCTP_GET_STATE(stcb) != SCTP_STATE_SHUTDOWN_ACK_SENT)) {
/* only send SHUTDOWN 1st time thru */
struct sctp_nets *netp;
- if ((SCTP_GET_STATE(asoc) == SCTP_STATE_OPEN) ||
- (SCTP_GET_STATE(asoc) == SCTP_STATE_SHUTDOWN_RECEIVED)) {
+ if ((SCTP_GET_STATE(stcb) == SCTP_STATE_OPEN) ||
+ (SCTP_GET_STATE(stcb) == SCTP_STATE_SHUTDOWN_RECEIVED)) {
SCTP_STAT_DECR_GAUGE32(sctps_currestab);
}
- SCTP_SET_STATE(asoc, SCTP_STATE_SHUTDOWN_SENT);
- SCTP_CLEAR_SUBSTATE(asoc, SCTP_STATE_SHUTDOWN_PENDING);
+ SCTP_SET_STATE(stcb, SCTP_STATE_SHUTDOWN_SENT);
sctp_stop_timers_for_shutdown(stcb);
if (stcb->asoc.alternate) {
netp = stcb->asoc.alternate;
@@ -1206,11 +1242,11 @@ sctp_disconnect(struct socket *so)
netp = stcb->asoc.primary_destination;
}
- asoc->state |= SCTP_STATE_SHUTDOWN_PENDING;
+ SCTP_ADD_SUBSTATE(stcb, SCTP_STATE_SHUTDOWN_PENDING);
sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, stcb->sctp_ep, stcb,
netp);
if ((*asoc->ss_functions.sctp_ss_is_user_msgs_incomplete)(stcb, asoc)) {
- asoc->state |= SCTP_STATE_PARTIAL_MSG_LEFT;
+ SCTP_ADD_SUBSTATE(stcb, SCTP_STATE_PARTIAL_MSG_LEFT);
}
if (TAILQ_EMPTY(&asoc->send_queue) &&
TAILQ_EMPTY(&asoc->sent_queue) &&
@@ -1221,8 +1257,8 @@ sctp_disconnect(struct socket *so)
stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_USRREQ + SCTP_LOC_4;
sctp_send_abort_tcb(stcb, op_err, SCTP_SO_LOCKED);
SCTP_STAT_INCR_COUNTER32(sctps_aborted);
- if ((SCTP_GET_STATE(&stcb->asoc) == SCTP_STATE_OPEN) ||
- (SCTP_GET_STATE(&stcb->asoc) == SCTP_STATE_SHUTDOWN_RECEIVED)) {
+ if ((SCTP_GET_STATE(stcb) == SCTP_STATE_OPEN) ||
+ (SCTP_GET_STATE(stcb) == SCTP_STATE_SHUTDOWN_RECEIVED)) {
SCTP_STAT_DECR_GAUGE32(sctps_currestab);
}
SCTP_INP_RUNLOCK(inp);
@@ -1360,9 +1396,9 @@ sctp_shutdown(struct socket *so)
SCTP_INP_RUNLOCK(inp);
return (0);
}
- if ((SCTP_GET_STATE(asoc) != SCTP_STATE_COOKIE_WAIT) &&
- (SCTP_GET_STATE(asoc) != SCTP_STATE_COOKIE_ECHOED) &&
- (SCTP_GET_STATE(asoc) != SCTP_STATE_OPEN)) {
+ if ((SCTP_GET_STATE(stcb) != SCTP_STATE_COOKIE_WAIT) &&
+ (SCTP_GET_STATE(stcb) != SCTP_STATE_COOKIE_ECHOED) &&
+ (SCTP_GET_STATE(stcb) != SCTP_STATE_OPEN)) {
/* If we are not in or before ESTABLISHED, there is
* no protocol action required.
*/
@@ -1375,7 +1411,7 @@ sctp_shutdown(struct socket *so)
} else {
netp = stcb->asoc.primary_destination;
}
- if ((SCTP_GET_STATE(asoc) == SCTP_STATE_OPEN) &&
+ if ((SCTP_GET_STATE(stcb) == SCTP_STATE_OPEN) &&
TAILQ_EMPTY(&asoc->send_queue) &&
TAILQ_EMPTY(&asoc->sent_queue) &&
(asoc->stream_queue_cnt == 0)) {
@@ -1384,8 +1420,7 @@ sctp_shutdown(struct socket *so)
}
/* there is nothing queued to send, so I'm done... */
SCTP_STAT_DECR_GAUGE32(sctps_currestab);
- SCTP_SET_STATE(asoc, SCTP_STATE_SHUTDOWN_SENT);
- SCTP_CLEAR_SUBSTATE(asoc, SCTP_STATE_SHUTDOWN_PENDING);
+ SCTP_SET_STATE(stcb, SCTP_STATE_SHUTDOWN_SENT);
sctp_stop_timers_for_shutdown(stcb);
sctp_send_shutdown(stcb, netp);
sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWN,
@@ -1395,9 +1430,9 @@ sctp_shutdown(struct socket *so)
* We still got (or just got) data to send, so set
* SHUTDOWN_PENDING.
*/
- SCTP_ADD_SUBSTATE(asoc, SCTP_STATE_SHUTDOWN_PENDING);
+ SCTP_ADD_SUBSTATE(stcb, SCTP_STATE_SHUTDOWN_PENDING);
if ((*asoc->ss_functions.sctp_ss_is_user_msgs_incomplete)(stcb, asoc)) {
- SCTP_ADD_SUBSTATE(asoc, SCTP_STATE_PARTIAL_MSG_LEFT);
+ SCTP_ADD_SUBSTATE(stcb, SCTP_STATE_PARTIAL_MSG_LEFT);
}
if (TAILQ_EMPTY(&asoc->send_queue) &&
TAILQ_EMPTY(&asoc->sent_queue) &&
@@ -1406,9 +1441,9 @@ sctp_shutdown(struct socket *so)
abort_anyway:
op_err = sctp_generate_cause(SCTP_CAUSE_USER_INITIATED_ABT, "");
stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_USRREQ + SCTP_LOC_6;
+ SCTP_INP_RUNLOCK(inp);
sctp_abort_an_association(stcb->sctp_ep, stcb,
op_err, SCTP_SO_LOCKED);
- SCTP_INP_RUNLOCK(inp);
return (0);
}
}
@@ -1608,22 +1643,25 @@ sctp_fill_up_addresses_vrf(struct sctp_inpcb *inp,
}
#ifdef INET6
if (sctp_is_feature_on(inp, SCTP_PCB_FLAGS_NEEDS_MAPPED_V4)) {
+ if (actual + sizeof(struct sockaddr_in6) > limit) {
+ return (actual);
+ }
in6_sin_2_v4mapsin6(sin, (struct sockaddr_in6 *)sas);
((struct sockaddr_in6 *)sas)->sin6_port = inp->sctp_lport;
sas = (struct sockaddr_storage *)((caddr_t)sas + sizeof(struct sockaddr_in6));
actual += sizeof(struct sockaddr_in6);
} else {
#endif
- memcpy(sas, sin, sizeof(*sin));
+ if (actual + sizeof(struct sockaddr_in) > limit) {
+ return (actual);
+ }
+ memcpy(sas, sin, sizeof(struct sockaddr_in));
((struct sockaddr_in *)sas)->sin_port = inp->sctp_lport;
- sas = (struct sockaddr_storage *)((caddr_t)sas + sizeof(*sin));
- actual += sizeof(*sin);
+ sas = (struct sockaddr_storage *)((caddr_t)sas + sizeof(struct sockaddr_in));
+ actual += sizeof(struct sockaddr_in);
#ifdef INET6
}
#endif
- if (actual >= limit) {
- return (actual);
- }
} else {
continue;
}
@@ -1684,13 +1722,13 @@ sctp_fill_up_addresses_vrf(struct sctp_inpcb *inp,
(IN6_IS_ADDR_SITELOCAL(&sin6->sin6_addr))) {
continue;
}
- memcpy(sas, sin6, sizeof(*sin6));
- ((struct sockaddr_in6 *)sas)->sin6_port = inp->sctp_lport;
- sas = (struct sockaddr_storage *)((caddr_t)sas + sizeof(*sin6));
- actual += sizeof(*sin6);
- if (actual >= limit) {
+ if (actual + sizeof(struct sockaddr_in6) > limit) {
return (actual);
}
+ memcpy(sas, sin6, sizeof(struct sockaddr_in6));
+ ((struct sockaddr_in6 *)sas)->sin6_port = inp->sctp_lport;
+ sas = (struct sockaddr_storage *)((caddr_t)sas + sizeof(struct sockaddr_in6));
+ actual += sizeof(struct sockaddr_in6);
} else {
continue;
}
@@ -1699,13 +1737,13 @@ sctp_fill_up_addresses_vrf(struct sctp_inpcb *inp,
#if defined(__Userspace__)
case AF_CONN:
if (conn_addr_legal) {
+ if (actual + sizeof(struct sockaddr_conn) > limit) {
+ return (actual);
+ }
memcpy(sas, &sctp_ifa->address.sconn, sizeof(struct sockaddr_conn));
((struct sockaddr_conn *)sas)->sconn_port = inp->sctp_lport;
sas = (struct sockaddr_storage *)((caddr_t)sas + sizeof(struct sockaddr_conn));
actual += sizeof(struct sockaddr_conn);
- if (actual >= limit) {
- return (actual);
- }
} else {
continue;
}
@@ -1718,9 +1756,7 @@ sctp_fill_up_addresses_vrf(struct sctp_inpcb *inp,
}
} else {
struct sctp_laddr *laddr;
-#ifndef HAVE_SA_LEN
- uint32_t sa_len = 0;
-#endif
+ size_t sa_len;
LIST_FOREACH(laddr, &inp->sctp_addr_list, sctp_nxt_addr) {
if (stcb) {
@@ -1728,47 +1764,50 @@ sctp_fill_up_addresses_vrf(struct sctp_inpcb *inp,
continue;
}
}
- if (sctp_fill_user_address(sas, &laddr->ifa->address.sa))
- continue;
+#ifdef HAVE_SA_LEN
+ sa_len = laddr->ifa->address.sa.sa_len;
+#else
switch (laddr->ifa->address.sa.sa_family) {
#ifdef INET
case AF_INET:
- ((struct sockaddr_in *)sas)->sin_port = inp->sctp_lport;
+ sa_len = sizeof(struct sockaddr_in);
break;
#endif
#ifdef INET6
case AF_INET6:
- ((struct sockaddr_in6 *)sas)->sin6_port = inp->sctp_lport;
+ sa_len = sizeof(struct sockaddr_in6);
break;
#endif
#if defined(__Userspace__)
case AF_CONN:
- ((struct sockaddr_conn *)sas)->sconn_port = inp->sctp_lport;
+ sa_len = sizeof(struct sockaddr_conn);
break;
#endif
default:
/* TSNH */
+ sa_len = 0;
break;
}
-#ifdef HAVE_SA_LEN
- sas = (struct sockaddr_storage *)((caddr_t)sas +
- laddr->ifa->address.sa.sa_len);
- actual += laddr->ifa->address.sa.sa_len;
-#else
+#endif
+ if (actual + sa_len > limit) {
+ return (actual);
+ }
+ if (sctp_fill_user_address(sas, &laddr->ifa->address.sa))
+ continue;
switch (laddr->ifa->address.sa.sa_family) {
#ifdef INET
case AF_INET:
- sa_len = sizeof(struct sockaddr_in);
+ ((struct sockaddr_in *)sas)->sin_port = inp->sctp_lport;
break;
#endif
#ifdef INET6
case AF_INET6:
- sa_len = sizeof(struct sockaddr_in6);
+ ((struct sockaddr_in6 *)sas)->sin6_port = inp->sctp_lport;
break;
#endif
#if defined(__Userspace__)
case AF_CONN:
- sa_len = sizeof(struct sockaddr_conn);
+ ((struct sockaddr_conn *)sas)->sconn_port = inp->sctp_lport;
break;
#endif
default:
@@ -1777,10 +1816,6 @@ sctp_fill_up_addresses_vrf(struct sctp_inpcb *inp,
}
sas = (struct sockaddr_storage *)((caddr_t)sas + sa_len);
actual += sa_len;
-#endif
- if (actual >= limit) {
- return (actual);
- }
}
}
return (actual);
@@ -1938,13 +1973,12 @@ static int
sctp_do_connect_x(struct socket *so, struct sctp_inpcb *inp, void *optval,
size_t optsize, void *p, int delay)
{
- int error = 0;
+ int error;
int creat_lock_on = 0;
struct sctp_tcb *stcb = NULL;
struct sockaddr *sa;
unsigned int num_v6 = 0, num_v4 = 0, *totaddrp, totaddr;
uint32_t vrf_id;
- int bad_addresses = 0;
sctp_assoc_t *a_id;
SCTPDBG(SCTP_DEBUG_PCB1, "Connectx called\n");
@@ -1983,17 +2017,12 @@ sctp_do_connect_x(struct socket *so, struct sctp_inpcb *inp, void *optval,
totaddrp = (unsigned int *)optval;
totaddr = *totaddrp;
sa = (struct sockaddr *)(totaddrp + 1);
- stcb = sctp_connectx_helper_find(inp, sa, &totaddr, &num_v4, &num_v6, &error, (unsigned int)(optsize - sizeof(int)), &bad_addresses);
- if ((stcb != NULL) || bad_addresses) {
+ error = sctp_connectx_helper_find(inp, sa, totaddr, &num_v4, &num_v6, (unsigned int)(optsize - sizeof(int)));
+ if (error != 0) {
/* Already have or am bring up an association */
SCTP_ASOC_CREATE_UNLOCK(inp);
creat_lock_on = 0;
- if (stcb)
- SCTP_TCB_UNLOCK(stcb);
- if (bad_addresses == 0) {
- SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EALREADY);
- error = EALREADY;
- }
+ SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, error);
goto out_now;
}
#ifdef INET6
@@ -2004,10 +2033,7 @@ sctp_do_connect_x(struct socket *so, struct sctp_inpcb *inp, void *optval,
}
if ((inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) &&
(num_v4 > 0)) {
- struct in6pcb *inp6;
-
- inp6 = (struct in6pcb *)inp;
- if (SCTP_IPV6_V6ONLY(inp6)) {
+ if (SCTP_IPV6_V6ONLY(inp)) {
/*
* if IPV6_V6ONLY flag, ignore connections destined
* to a v4 addr or v4-mapped addr
@@ -2036,13 +2062,13 @@ sctp_do_connect_x(struct socket *so, struct sctp_inpcb *inp, void *optval,
inp->sctp_ep.pre_open_stream_count,
inp->sctp_ep.port,
#if defined(__FreeBSD__) && __FreeBSD_version >= 500000
- (struct thread *)p
+ (struct thread *)p,
#elif defined(__Windows__)
- (PKTHREAD)p
+ (PKTHREAD)p,
#else
- (struct proc *)p
+ (struct proc *)p,
#endif
- );
+ SCTP_INITIALIZE_AUTH_PARAMS);
if (stcb == NULL) {
/* Gak! no memory */
goto out_now;
@@ -2052,7 +2078,7 @@ sctp_do_connect_x(struct socket *so, struct sctp_inpcb *inp, void *optval,
/* Set the connected flag so we can queue data */
soisconnecting(so);
}
- SCTP_SET_STATE(&stcb->asoc, SCTP_STATE_COOKIE_WAIT);
+ SCTP_SET_STATE(stcb, SCTP_STATE_COOKIE_WAIT);
/* move to second address */
switch (sa->sa_family) {
#ifdef INET
@@ -2073,16 +2099,11 @@ sctp_do_connect_x(struct socket *so, struct sctp_inpcb *inp, void *optval,
sctp_connectx_helper_add(stcb, sa, (totaddr-1), &error);
/* Fill in the return id */
if (error) {
- (void)sctp_free_assoc(inp, stcb, SCTP_PCBFREE_FORCE,
- SCTP_FROM_SCTP_USRREQ + SCTP_LOC_7);
goto out_now;
}
a_id = (sctp_assoc_t *)optval;
*a_id = sctp_get_associd(stcb);
- /* initialize authentication parameters for the assoc */
- sctp_initialize_auth_params(inp, stcb);
-
if (delay) {
/* doing delayed connection */
stcb->asoc.delayed_connection = 1;
@@ -2281,7 +2302,8 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize,
} else {
if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) ||
- (av->assoc_id == SCTP_FUTURE_ASSOC)) {
+ ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ (av->assoc_id == SCTP_FUTURE_ASSOC))) {
SCTP_INP_RLOCK(inp);
if (inp->idata_supported) {
av->assoc_value = 1;
@@ -2311,7 +2333,8 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize,
} else {
if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) ||
- (av->assoc_id == SCTP_FUTURE_ASSOC)) {
+ ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ (av->assoc_id == SCTP_FUTURE_ASSOC))) {
SCTP_INP_RLOCK(inp);
av->assoc_value = inp->sctp_cmt_on_off;
SCTP_INP_RUNLOCK(inp);
@@ -2337,7 +2360,8 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize,
} else {
if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) ||
- (av->assoc_id == SCTP_FUTURE_ASSOC)) {
+ ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ (av->assoc_id == SCTP_FUTURE_ASSOC))) {
SCTP_INP_RLOCK(inp);
av->assoc_value = inp->sctp_ep.sctp_default_cc_module;
SCTP_INP_RUNLOCK(inp);
@@ -2382,7 +2406,8 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize,
} else {
if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) ||
- (av->assoc_id == SCTP_FUTURE_ASSOC)) {
+ ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ (av->assoc_id == SCTP_FUTURE_ASSOC))) {
SCTP_INP_RLOCK(inp);
av->assoc_value = inp->sctp_ep.sctp_default_ss_module;
SCTP_INP_RUNLOCK(inp);
@@ -2523,7 +2548,8 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize,
} else {
if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) ||
- (av->assoc_id == SCTP_FUTURE_ASSOC)) {
+ ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ (av->assoc_id == SCTP_FUTURE_ASSOC))) {
SCTP_INP_RLOCK(inp);
av->assoc_value = inp->sctp_context;
SCTP_INP_RUNLOCK(inp);
@@ -2614,7 +2640,8 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize,
} else {
if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) ||
- (sack->sack_assoc_id == SCTP_FUTURE_ASSOC)) {
+ ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ (sack->sack_assoc_id == SCTP_FUTURE_ASSOC))) {
SCTP_INP_RLOCK(inp);
sack->sack_delay = TICKS_TO_MSEC(inp->sctp_ep.sctp_timeoutticks[SCTP_TIMER_RECV]);
sack->sack_freq = inp->sctp_ep.sctp_sack_freq;
@@ -2675,7 +2702,8 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize,
} else {
if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) ||
- (av->assoc_id == SCTP_FUTURE_ASSOC)) {
+ ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ (av->assoc_id == SCTP_FUTURE_ASSOC))) {
SCTP_INP_RLOCK(inp);
av->assoc_value = inp->sctp_ep.max_burst;
SCTP_INP_RUNLOCK(inp);
@@ -2704,7 +2732,8 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize,
} else {
if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) ||
- (av->assoc_id == SCTP_FUTURE_ASSOC)) {
+ ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ (av->assoc_id == SCTP_FUTURE_ASSOC))) {
SCTP_INP_RLOCK(inp);
if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) {
ovh = SCTP_MED_OVERHEAD;
@@ -2872,8 +2901,8 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize,
SCTP_FIND_STCB(inp, stcb, saddr->sget_assoc_id);
if (stcb) {
- left = (*optsize) - sizeof(struct sctp_getaddresses);
- *optsize = sizeof(struct sctp_getaddresses);
+ left = (*optsize) - sizeof(sctp_assoc_t);
+ *optsize = sizeof(sctp_assoc_t);
sas = (struct sockaddr_storage *)&saddr->addr[0];
TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) {
@@ -2932,7 +2961,7 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize,
}
SCTP_TCB_UNLOCK(stcb);
} else {
- SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, ENOENT);
+ SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, ENOENT);
error = ENOENT;
}
break;
@@ -2952,7 +2981,7 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize,
if (stcb) {
SCTP_TCB_UNLOCK(stcb);
}
- *optsize = sizeof(struct sockaddr_storage) + actual;
+ *optsize = sizeof(sctp_assoc_t) + actual;
break;
}
case SCTP_PEER_ADDR_PARAMS:
@@ -3130,7 +3159,8 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize,
} else {
if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) ||
- (paddrp->spp_assoc_id == SCTP_FUTURE_ASSOC)) {
+ ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ (paddrp->spp_assoc_id == SCTP_FUTURE_ASSOC))) {
/* Use endpoint defaults */
SCTP_INP_RLOCK(inp);
paddrp->spp_pathmaxrxt = inp->sctp_ep.def_net_failure;
@@ -3298,59 +3328,63 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize,
sstat->sstat_instrms = stcb->asoc.streamincnt;
sstat->sstat_outstrms = stcb->asoc.streamoutcnt;
sstat->sstat_fragmentation_point = sctp_get_frag_point(stcb, &stcb->asoc);
+ net = stcb->asoc.primary_destination;
+ if (net != NULL) {
#ifdef HAVE_SA_LEN
- memcpy(&sstat->sstat_primary.spinfo_address,
- &stcb->asoc.primary_destination->ro._l_addr,
- ((struct sockaddr *)(&stcb->asoc.primary_destination->ro._l_addr))->sa_len);
-#else
- if (stcb->asoc.primary_destination->ro._l_addr.sa.sa_family == AF_INET) {
- memcpy(&sstat->sstat_primary.spinfo_address,
- &stcb->asoc.primary_destination->ro._l_addr,
- sizeof(struct sockaddr_in));
- } else {
memcpy(&sstat->sstat_primary.spinfo_address,
&stcb->asoc.primary_destination->ro._l_addr,
- sizeof(struct sockaddr_in6));
- }
+ ((struct sockaddr *)(&stcb->asoc.primary_destination->ro._l_addr))->sa_len);
+#else
+ if (stcb->asoc.primary_destination->ro._l_addr.sa.sa_family == AF_INET) {
+ memcpy(&sstat->sstat_primary.spinfo_address,
+ &stcb->asoc.primary_destination->ro._l_addr,
+ sizeof(struct sockaddr_in));
+ } else {
+ memcpy(&sstat->sstat_primary.spinfo_address,
+ &stcb->asoc.primary_destination->ro._l_addr,
+ sizeof(struct sockaddr_in6));
+ }
#endif
- net = stcb->asoc.primary_destination;
- ((struct sockaddr_in *)&sstat->sstat_primary.spinfo_address)->sin_port = stcb->rport;
- /*
- * Again the user can get info from sctp_constants.h
- * for what the state of the network is.
- */
- if (net->dest_state & SCTP_ADDR_UNCONFIRMED) {
- /* It's unconfirmed */
- sstat->sstat_primary.spinfo_state = SCTP_UNCONFIRMED;
- } else if (net->dest_state & SCTP_ADDR_REACHABLE) {
- /* It's active */
- sstat->sstat_primary.spinfo_state = SCTP_ACTIVE;
- } else {
- /* It's inactive */
- sstat->sstat_primary.spinfo_state = SCTP_INACTIVE;
- }
- sstat->sstat_primary.spinfo_cwnd = net->cwnd;
- sstat->sstat_primary.spinfo_srtt = net->lastsa >> SCTP_RTT_SHIFT;
- sstat->sstat_primary.spinfo_rto = net->RTO;
- sstat->sstat_primary.spinfo_mtu = net->mtu;
- switch (stcb->asoc.primary_destination->ro._l_addr.sa.sa_family) {
+ ((struct sockaddr_in *)&sstat->sstat_primary.spinfo_address)->sin_port = stcb->rport;
+ /*
+ * Again the user can get info from sctp_constants.h
+ * for what the state of the network is.
+ */
+ if (net->dest_state & SCTP_ADDR_UNCONFIRMED) {
+ /* It's unconfirmed */
+ sstat->sstat_primary.spinfo_state = SCTP_UNCONFIRMED;
+ } else if (net->dest_state & SCTP_ADDR_REACHABLE) {
+ /* It's active */
+ sstat->sstat_primary.spinfo_state = SCTP_ACTIVE;
+ } else {
+ /* It's inactive */
+ sstat->sstat_primary.spinfo_state = SCTP_INACTIVE;
+ }
+ sstat->sstat_primary.spinfo_cwnd = net->cwnd;
+ sstat->sstat_primary.spinfo_srtt = net->lastsa >> SCTP_RTT_SHIFT;
+ sstat->sstat_primary.spinfo_rto = net->RTO;
+ sstat->sstat_primary.spinfo_mtu = net->mtu;
+ switch (stcb->asoc.primary_destination->ro._l_addr.sa.sa_family) {
#if defined(INET)
- case AF_INET:
- sstat->sstat_primary.spinfo_mtu -= SCTP_MIN_V4_OVERHEAD;
- break;
+ case AF_INET:
+ sstat->sstat_primary.spinfo_mtu -= SCTP_MIN_V4_OVERHEAD;
+ break;
#endif
#if defined(INET6)
- case AF_INET6:
- sstat->sstat_primary.spinfo_mtu -= SCTP_MIN_OVERHEAD;
- break;
+ case AF_INET6:
+ sstat->sstat_primary.spinfo_mtu -= SCTP_MIN_OVERHEAD;
+ break;
#endif
#if defined(__Userspace__)
- case AF_CONN:
- sstat->sstat_primary.spinfo_mtu -= sizeof(struct sctphdr);
- break;
+ case AF_CONN:
+ sstat->sstat_primary.spinfo_mtu -= sizeof(struct sctphdr);
+ break;
#endif
- default:
- break;
+ default:
+ break;
+ }
+ } else {
+ memset(&sstat->sstat_primary, 0, sizeof(struct sctp_paddrinfo));
}
sstat->sstat_primary.spinfo_assoc_id = sctp_get_associd(stcb);
SCTP_TCB_UNLOCK(stcb);
@@ -3372,7 +3406,8 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize,
} else {
if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) ||
- (srto->srto_assoc_id == SCTP_FUTURE_ASSOC)) {
+ ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ (srto->srto_assoc_id == SCTP_FUTURE_ASSOC))) {
SCTP_INP_RLOCK(inp);
srto->srto_initial = inp->sctp_ep.initial_rto;
srto->srto_max = inp->sctp_ep.sctp_maxrto;
@@ -3428,7 +3463,8 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize,
} else {
if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) ||
- (sasoc->sasoc_assoc_id == SCTP_FUTURE_ASSOC)) {
+ ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ (sasoc->sasoc_assoc_id == SCTP_FUTURE_ASSOC))) {
SCTP_INP_RLOCK(inp);
sasoc->sasoc_cookie_life = TICKS_TO_MSEC(inp->sctp_ep.def_cookie_life);
sasoc->sasoc_asocmaxrxt = inp->sctp_ep.max_send_times;
@@ -3459,7 +3495,8 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize,
} else {
if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) ||
- (s_info->sinfo_assoc_id == SCTP_FUTURE_ASSOC)) {
+ ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ (s_info->sinfo_assoc_id == SCTP_FUTURE_ASSOC))) {
SCTP_INP_RLOCK(inp);
memcpy(s_info, &inp->def_send, sizeof(inp->def_send));
SCTP_INP_RUNLOCK(inp);
@@ -3584,7 +3621,8 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize,
} else {
if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) ||
- (scact->scact_assoc_id == SCTP_FUTURE_ASSOC)) {
+ ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ (scact->scact_assoc_id == SCTP_FUTURE_ASSOC))) {
/* get the endpoint active key */
SCTP_INP_RLOCK(inp);
scact->scact_keynumber = inp->sctp_ep.default_keyid;
@@ -3626,7 +3664,8 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize,
} else {
if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) ||
- (sac->gauth_assoc_id == SCTP_FUTURE_ASSOC)) {
+ ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ (sac->gauth_assoc_id == SCTP_FUTURE_ASSOC))) {
/* get off the endpoint */
SCTP_INP_RLOCK(inp);
chklist = inp->sctp_ep.local_auth_chunks;
@@ -3758,7 +3797,8 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize,
} else {
if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) ||
- (event->se_assoc_id == SCTP_FUTURE_ASSOC)) {
+ ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ (event->se_assoc_id == SCTP_FUTURE_ASSOC))) {
SCTP_INP_RLOCK(inp);
event->se_on = sctp_is_feature_on(inp, event_type);
SCTP_INP_RUNLOCK(inp);
@@ -3831,7 +3871,8 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize,
} else {
if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) ||
- (info->snd_assoc_id == SCTP_FUTURE_ASSOC)) {
+ ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ (info->snd_assoc_id == SCTP_FUTURE_ASSOC))) {
SCTP_INP_RLOCK(inp);
info->snd_sid = inp->def_send.sinfo_stream;
info->snd_flags = inp->def_send.sinfo_flags;
@@ -3863,7 +3904,8 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize,
} else {
if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) ||
- (info->pr_assoc_id == SCTP_FUTURE_ASSOC)) {
+ ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ (info->pr_assoc_id == SCTP_FUTURE_ASSOC))) {
SCTP_INP_RLOCK(inp);
info->pr_policy = PR_SCTP_POLICY(inp->def_send.sinfo_flags);
info->pr_value = inp->def_send.sinfo_timetolive;
@@ -3984,7 +4026,8 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize,
} else {
if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) ||
- (thlds->spt_assoc_id == SCTP_FUTURE_ASSOC)) {
+ ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ (thlds->spt_assoc_id == SCTP_FUTURE_ASSOC))) {
/* Use endpoint defaults */
SCTP_INP_RLOCK(inp);
thlds->spt_pathmaxrxt = inp->sctp_ep.def_net_failure;
@@ -4102,7 +4145,8 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize,
} else {
if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) ||
- (encaps->sue_assoc_id == SCTP_FUTURE_ASSOC)) {
+ ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ (encaps->sue_assoc_id == SCTP_FUTURE_ASSOC))) {
SCTP_INP_RLOCK(inp);
encaps->sue_port = inp->sctp_ep.port;
SCTP_INP_RUNLOCK(inp);
@@ -4129,7 +4173,8 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize,
} else {
if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) ||
- (av->assoc_id == SCTP_FUTURE_ASSOC)) {
+ ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ (av->assoc_id == SCTP_FUTURE_ASSOC))) {
SCTP_INP_RLOCK(inp);
av->assoc_value = inp->ecn_supported;
SCTP_INP_RUNLOCK(inp);
@@ -4156,7 +4201,8 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize,
} else {
if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) ||
- (av->assoc_id == SCTP_FUTURE_ASSOC)) {
+ ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ (av->assoc_id == SCTP_FUTURE_ASSOC))) {
SCTP_INP_RLOCK(inp);
av->assoc_value = inp->prsctp_supported;
SCTP_INP_RUNLOCK(inp);
@@ -4183,7 +4229,8 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize,
} else {
if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) ||
- (av->assoc_id == SCTP_FUTURE_ASSOC)) {
+ ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ (av->assoc_id == SCTP_FUTURE_ASSOC))) {
SCTP_INP_RLOCK(inp);
av->assoc_value = inp->auth_supported;
SCTP_INP_RUNLOCK(inp);
@@ -4210,7 +4257,8 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize,
} else {
if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) ||
- (av->assoc_id == SCTP_FUTURE_ASSOC)) {
+ ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ (av->assoc_id == SCTP_FUTURE_ASSOC))) {
SCTP_INP_RLOCK(inp);
av->assoc_value = inp->asconf_supported;
SCTP_INP_RUNLOCK(inp);
@@ -4237,7 +4285,8 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize,
} else {
if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) ||
- (av->assoc_id == SCTP_FUTURE_ASSOC)) {
+ ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ (av->assoc_id == SCTP_FUTURE_ASSOC))) {
SCTP_INP_RLOCK(inp);
av->assoc_value = inp->reconfig_supported;
SCTP_INP_RUNLOCK(inp);
@@ -4264,7 +4313,8 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize,
} else {
if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) ||
- (av->assoc_id == SCTP_FUTURE_ASSOC)) {
+ ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ (av->assoc_id == SCTP_FUTURE_ASSOC))) {
SCTP_INP_RLOCK(inp);
av->assoc_value = inp->nrsack_supported;
SCTP_INP_RUNLOCK(inp);
@@ -4291,7 +4341,8 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize,
} else {
if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) ||
- (av->assoc_id == SCTP_FUTURE_ASSOC)) {
+ ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ (av->assoc_id == SCTP_FUTURE_ASSOC))) {
SCTP_INP_RLOCK(inp);
av->assoc_value = inp->pktdrop_supported;
SCTP_INP_RUNLOCK(inp);
@@ -4318,7 +4369,8 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize,
} else {
if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) ||
- (av->assoc_id == SCTP_FUTURE_ASSOC)) {
+ ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ (av->assoc_id == SCTP_FUTURE_ASSOC))) {
SCTP_INP_RLOCK(inp);
av->assoc_value = (uint32_t)inp->local_strreset_support;
SCTP_INP_RUNLOCK(inp);
@@ -4420,7 +4472,8 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize,
} else {
if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) ||
- (av->assoc_id == SCTP_FUTURE_ASSOC)) {
+ ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ (av->assoc_id == SCTP_FUTURE_ASSOC))) {
SCTP_INP_RLOCK(inp);
av->assoc_value = inp->max_cwnd;
SCTP_INP_RUNLOCK(inp);
@@ -4460,13 +4513,11 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
uint32_t vrf_id;
if (optval == NULL) {
- SCTP_PRINTF("optval is NULL\n");
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL);
return (EINVAL);
}
inp = (struct sctp_inpcb *)so->so_pcb;
if (inp == NULL) {
- SCTP_PRINTF("inp is NULL?\n");
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL);
return (EINVAL);
}
@@ -4615,7 +4666,8 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
} else {
if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) ||
- (av->assoc_id == SCTP_FUTURE_ASSOC)) {
+ ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ (av->assoc_id == SCTP_FUTURE_ASSOC))) {
SCTP_INP_WLOCK(inp);
if (av->assoc_value == 0) {
inp->idata_supported = 0;
@@ -4654,14 +4706,16 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
} else {
if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) ||
- (av->assoc_id == SCTP_FUTURE_ASSOC) ||
- (av->assoc_id == SCTP_ALL_ASSOC)) {
+ ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ ((av->assoc_id == SCTP_FUTURE_ASSOC) ||
+ (av->assoc_id == SCTP_ALL_ASSOC)))) {
SCTP_INP_WLOCK(inp);
inp->sctp_cmt_on_off = av->assoc_value;
SCTP_INP_WUNLOCK(inp);
}
- if ((av->assoc_id == SCTP_CURRENT_ASSOC) ||
- (av->assoc_id == SCTP_ALL_ASSOC)) {
+ if ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ ((av->assoc_id == SCTP_CURRENT_ASSOC) ||
+ (av->assoc_id == SCTP_ALL_ASSOC))) {
SCTP_INP_RLOCK(inp);
LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) {
SCTP_TCB_LOCK(stcb);
@@ -4703,14 +4757,16 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
} else {
if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) ||
- (av->assoc_id == SCTP_FUTURE_ASSOC) ||
- (av->assoc_id == SCTP_ALL_ASSOC)) {
+ ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ ((av->assoc_id == SCTP_FUTURE_ASSOC) ||
+ (av->assoc_id == SCTP_ALL_ASSOC)))) {
SCTP_INP_WLOCK(inp);
inp->sctp_ep.sctp_default_cc_module = av->assoc_value;
SCTP_INP_WUNLOCK(inp);
}
- if ((av->assoc_id == SCTP_CURRENT_ASSOC) ||
- (av->assoc_id == SCTP_ALL_ASSOC)) {
+ if ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ ((av->assoc_id == SCTP_CURRENT_ASSOC) ||
+ (av->assoc_id == SCTP_ALL_ASSOC))) {
SCTP_INP_RLOCK(inp);
LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) {
SCTP_TCB_LOCK(stcb);
@@ -4735,7 +4791,8 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
SCTP_CHECK_AND_CAST(cc_opt, optval, struct sctp_cc_option, optsize);
SCTP_FIND_STCB(inp, stcb, cc_opt->aid_value.assoc_id);
if (stcb == NULL) {
- if (cc_opt->aid_value.assoc_id == SCTP_CURRENT_ASSOC) {
+ if ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ (cc_opt->aid_value.assoc_id == SCTP_CURRENT_ASSOC)) {
SCTP_INP_RLOCK(inp);
LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) {
SCTP_TCB_LOCK(stcb);
@@ -4776,29 +4833,35 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
}
SCTP_FIND_STCB(inp, stcb, av->assoc_id);
if (stcb) {
+ SCTP_TCB_SEND_LOCK(stcb);
stcb->asoc.ss_functions.sctp_ss_clear(stcb, &stcb->asoc, 1, 1);
stcb->asoc.ss_functions = sctp_ss_functions[av->assoc_value];
stcb->asoc.stream_scheduling_module = av->assoc_value;
stcb->asoc.ss_functions.sctp_ss_init(stcb, &stcb->asoc, 1);
+ SCTP_TCB_SEND_UNLOCK(stcb);
SCTP_TCB_UNLOCK(stcb);
} else {
if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) ||
- (av->assoc_id == SCTP_FUTURE_ASSOC) ||
- (av->assoc_id == SCTP_ALL_ASSOC)) {
+ ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ ((av->assoc_id == SCTP_FUTURE_ASSOC) ||
+ (av->assoc_id == SCTP_ALL_ASSOC)))) {
SCTP_INP_WLOCK(inp);
inp->sctp_ep.sctp_default_ss_module = av->assoc_value;
SCTP_INP_WUNLOCK(inp);
}
- if ((av->assoc_id == SCTP_CURRENT_ASSOC) ||
- (av->assoc_id == SCTP_ALL_ASSOC)) {
+ if ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ ((av->assoc_id == SCTP_CURRENT_ASSOC) ||
+ (av->assoc_id == SCTP_ALL_ASSOC))) {
SCTP_INP_RLOCK(inp);
LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) {
SCTP_TCB_LOCK(stcb);
+ SCTP_TCB_SEND_LOCK(stcb);
stcb->asoc.ss_functions.sctp_ss_clear(stcb, &stcb->asoc, 1, 1);
stcb->asoc.ss_functions = sctp_ss_functions[av->assoc_value];
stcb->asoc.stream_scheduling_module = av->assoc_value;
stcb->asoc.ss_functions.sctp_ss_init(stcb, &stcb->asoc, 1);
+ SCTP_TCB_SEND_UNLOCK(stcb);
SCTP_TCB_UNLOCK(stcb);
}
SCTP_INP_RUNLOCK(inp);
@@ -4821,7 +4884,8 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
}
SCTP_TCB_UNLOCK(stcb);
} else {
- if (av->assoc_id == SCTP_CURRENT_ASSOC) {
+ if ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ (av->assoc_id == SCTP_CURRENT_ASSOC)) {
SCTP_INP_RLOCK(inp);
LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) {
SCTP_TCB_LOCK(stcb);
@@ -4859,14 +4923,16 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
} else {
if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) ||
- (av->assoc_id == SCTP_FUTURE_ASSOC) ||
- (av->assoc_id == SCTP_ALL_ASSOC)) {
+ ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ ((av->assoc_id == SCTP_FUTURE_ASSOC) ||
+ (av->assoc_id == SCTP_ALL_ASSOC)))) {
SCTP_INP_WLOCK(inp);
inp->sctp_context = av->assoc_value;
SCTP_INP_WUNLOCK(inp);
}
- if ((av->assoc_id == SCTP_CURRENT_ASSOC) ||
- (av->assoc_id == SCTP_ALL_ASSOC)) {
+ if ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ ((av->assoc_id == SCTP_CURRENT_ASSOC) ||
+ (av->assoc_id == SCTP_ALL_ASSOC))) {
SCTP_INP_RLOCK(inp);
LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) {
SCTP_TCB_LOCK(stcb);
@@ -5040,8 +5106,9 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
} else {
if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) ||
- (sack->sack_assoc_id == SCTP_FUTURE_ASSOC) ||
- (sack->sack_assoc_id == SCTP_ALL_ASSOC)) {
+ ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ ((sack->sack_assoc_id == SCTP_FUTURE_ASSOC) ||
+ (sack->sack_assoc_id == SCTP_ALL_ASSOC)))) {
SCTP_INP_WLOCK(inp);
if (sack->sack_delay) {
inp->sctp_ep.sctp_timeoutticks[SCTP_TIMER_RECV] = MSEC_TO_TICKS(sack->sack_delay);
@@ -5051,8 +5118,9 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
}
SCTP_INP_WUNLOCK(inp);
}
- if ((sack->sack_assoc_id == SCTP_CURRENT_ASSOC) ||
- (sack->sack_assoc_id == SCTP_ALL_ASSOC)) {
+ if ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ ((sack->sack_assoc_id == SCTP_CURRENT_ASSOC) ||
+ (sack->sack_assoc_id == SCTP_ALL_ASSOC))) {
SCTP_INP_RLOCK(inp);
LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) {
SCTP_TCB_LOCK(stcb);
@@ -5139,8 +5207,9 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
} else {
if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) ||
- (sca->sca_assoc_id == SCTP_FUTURE_ASSOC) ||
- (sca->sca_assoc_id == SCTP_ALL_ASSOC)) {
+ ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ ((sca->sca_assoc_id == SCTP_FUTURE_ASSOC) ||
+ (sca->sca_assoc_id == SCTP_ALL_ASSOC)))) {
SCTP_INP_WLOCK(inp);
shared_keys = &inp->sctp_ep.shared_keys;
/*
@@ -5174,8 +5243,9 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
error = sctp_insert_sharedkey(shared_keys, shared_key);
SCTP_INP_WUNLOCK(inp);
}
- if ((sca->sca_assoc_id == SCTP_CURRENT_ASSOC) ||
- (sca->sca_assoc_id == SCTP_ALL_ASSOC)) {
+ if ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ ((sca->sca_assoc_id == SCTP_CURRENT_ASSOC) ||
+ (sca->sca_assoc_id == SCTP_ALL_ASSOC))) {
SCTP_INP_RLOCK(inp);
LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) {
SCTP_TCB_LOCK(stcb);
@@ -5283,8 +5353,9 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
} else {
if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) ||
- (scact->scact_assoc_id == SCTP_FUTURE_ASSOC) ||
- (scact->scact_assoc_id == SCTP_ALL_ASSOC)) {
+ ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ ((scact->scact_assoc_id == SCTP_FUTURE_ASSOC) ||
+ (scact->scact_assoc_id == SCTP_ALL_ASSOC)))) {
SCTP_INP_WLOCK(inp);
if (sctp_auth_setactivekey_ep(inp, scact->scact_keynumber)) {
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL);
@@ -5292,8 +5363,9 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
}
SCTP_INP_WUNLOCK(inp);
}
- if ((scact->scact_assoc_id == SCTP_CURRENT_ASSOC) ||
- (scact->scact_assoc_id == SCTP_ALL_ASSOC)) {
+ if ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ ((scact->scact_assoc_id == SCTP_CURRENT_ASSOC) ||
+ (scact->scact_assoc_id == SCTP_ALL_ASSOC))) {
SCTP_INP_RLOCK(inp);
LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) {
SCTP_TCB_LOCK(stcb);
@@ -5322,8 +5394,9 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
} else {
if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) ||
- (scdel->scact_assoc_id == SCTP_FUTURE_ASSOC) ||
- (scdel->scact_assoc_id == SCTP_ALL_ASSOC)) {
+ ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ ((scdel->scact_assoc_id == SCTP_FUTURE_ASSOC) ||
+ (scdel->scact_assoc_id == SCTP_ALL_ASSOC)))) {
SCTP_INP_WLOCK(inp);
if (sctp_delete_sharedkey_ep(inp, scdel->scact_keynumber)) {
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL);
@@ -5331,8 +5404,9 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
}
SCTP_INP_WUNLOCK(inp);
}
- if ((scdel->scact_assoc_id == SCTP_CURRENT_ASSOC) ||
- (scdel->scact_assoc_id == SCTP_ALL_ASSOC)) {
+ if ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ ((scdel->scact_assoc_id == SCTP_CURRENT_ASSOC) ||
+ (scdel->scact_assoc_id == SCTP_ALL_ASSOC))) {
SCTP_INP_RLOCK(inp);
LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) {
SCTP_TCB_LOCK(stcb);
@@ -5361,8 +5435,9 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
} else {
if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) ||
- (keyid->scact_assoc_id == SCTP_FUTURE_ASSOC) ||
- (keyid->scact_assoc_id == SCTP_ALL_ASSOC)) {
+ ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ ((keyid->scact_assoc_id == SCTP_FUTURE_ASSOC) ||
+ (keyid->scact_assoc_id == SCTP_ALL_ASSOC)))) {
SCTP_INP_WLOCK(inp);
if (sctp_deact_sharedkey_ep(inp, keyid->scact_keynumber)) {
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL);
@@ -5370,8 +5445,9 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
}
SCTP_INP_WUNLOCK(inp);
}
- if ((keyid->scact_assoc_id == SCTP_CURRENT_ASSOC) ||
- (keyid->scact_assoc_id == SCTP_ALL_ASSOC)) {
+ if ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ ((keyid->scact_assoc_id == SCTP_CURRENT_ASSOC) ||
+ (keyid->scact_assoc_id == SCTP_ALL_ASSOC))) {
SCTP_INP_RLOCK(inp);
LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) {
SCTP_TCB_LOCK(stcb);
@@ -5400,14 +5476,16 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
} else {
if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) ||
- (av->assoc_id == SCTP_FUTURE_ASSOC) ||
- (av->assoc_id == SCTP_ALL_ASSOC)) {
+ ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ ((av->assoc_id == SCTP_FUTURE_ASSOC) ||
+ (av->assoc_id == SCTP_ALL_ASSOC)))) {
SCTP_INP_WLOCK(inp);
inp->local_strreset_support = (uint8_t)av->assoc_value;
SCTP_INP_WUNLOCK(inp);
}
- if ((av->assoc_id == SCTP_CURRENT_ASSOC) ||
- (av->assoc_id == SCTP_ALL_ASSOC)) {
+ if ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ ((av->assoc_id == SCTP_CURRENT_ASSOC) ||
+ (av->assoc_id == SCTP_ALL_ASSOC))) {
SCTP_INP_RLOCK(inp);
LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) {
SCTP_TCB_LOCK(stcb);
@@ -5429,7 +5507,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
SCTP_CHECK_AND_CAST(strrst, optval, struct sctp_reset_streams, optsize);
SCTP_FIND_STCB(inp, stcb, strrst->srs_assoc_id);
if (stcb == NULL) {
- SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, ENOENT);
+ SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, ENOENT);
error = ENOENT;
break;
}
@@ -5442,6 +5520,12 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
SCTP_TCB_UNLOCK(stcb);
break;
}
+ if (SCTP_GET_STATE(stcb) != SCTP_STATE_OPEN) {
+ SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL);
+ error = EINVAL;
+ SCTP_TCB_UNLOCK(stcb);
+ break;
+ }
if (sizeof(struct sctp_reset_streams) +
strrst->srs_number_streams * sizeof(uint16_t) > optsize) {
error = EINVAL;
@@ -5474,13 +5558,13 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
}
for (i = 0; i < strrst->srs_number_streams; i++) {
if ((send_in) &&
- (strrst->srs_stream_list[i] > stcb->asoc.streamincnt)) {
+ (strrst->srs_stream_list[i] >= stcb->asoc.streamincnt)) {
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL);
error = EINVAL;
break;
}
if ((send_out) &&
- (strrst->srs_stream_list[i] > stcb->asoc.streamoutcnt)) {
+ (strrst->srs_stream_list[i] >= stcb->asoc.streamoutcnt)) {
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL);
error = EINVAL;
break;
@@ -5541,7 +5625,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
SCTP_CHECK_AND_CAST(stradd, optval, struct sctp_add_streams, optsize);
SCTP_FIND_STCB(inp, stcb, stradd->sas_assoc_id);
if (stcb == NULL) {
- SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, ENOENT);
+ SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, ENOENT);
error = ENOENT;
break;
}
@@ -5554,6 +5638,12 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
SCTP_TCB_UNLOCK(stcb);
break;
}
+ if (SCTP_GET_STATE(stcb) != SCTP_STATE_OPEN) {
+ SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL);
+ error = EINVAL;
+ SCTP_TCB_UNLOCK(stcb);
+ break;
+ }
if (stcb->asoc.stream_reset_outstanding) {
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EALREADY);
error = EALREADY;
@@ -5621,6 +5711,12 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
SCTP_TCB_UNLOCK(stcb);
break;
}
+ if (SCTP_GET_STATE(stcb) != SCTP_STATE_OPEN) {
+ SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL);
+ error = EINVAL;
+ SCTP_TCB_UNLOCK(stcb);
+ break;
+ }
if (stcb->asoc.stream_reset_outstanding) {
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EALREADY);
error = EALREADY;
@@ -5735,14 +5831,16 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
} else {
if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) ||
- (av->assoc_id == SCTP_FUTURE_ASSOC) ||
- (av->assoc_id == SCTP_ALL_ASSOC)) {
+ ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ ((av->assoc_id == SCTP_FUTURE_ASSOC) ||
+ (av->assoc_id == SCTP_ALL_ASSOC)))) {
SCTP_INP_WLOCK(inp);
inp->sctp_ep.max_burst = av->assoc_value;
SCTP_INP_WUNLOCK(inp);
}
- if ((av->assoc_id == SCTP_CURRENT_ASSOC) ||
- (av->assoc_id == SCTP_ALL_ASSOC)) {
+ if ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ ((av->assoc_id == SCTP_CURRENT_ASSOC) ||
+ (av->assoc_id == SCTP_ALL_ASSOC))) {
SCTP_INP_RLOCK(inp);
LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) {
SCTP_TCB_LOCK(stcb);
@@ -5778,7 +5876,8 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
} else {
if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) ||
- (av->assoc_id == SCTP_FUTURE_ASSOC)) {
+ ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ (av->assoc_id == SCTP_FUTURE_ASSOC))) {
SCTP_INP_WLOCK(inp);
/* FIXME MT: I think this is not in tune with the API ID */
if (av->assoc_value) {
@@ -5983,14 +6082,16 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
} else {
if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) ||
- (s_info->sinfo_assoc_id == SCTP_FUTURE_ASSOC) ||
- (s_info->sinfo_assoc_id == SCTP_ALL_ASSOC)) {
+ ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ ((s_info->sinfo_assoc_id == SCTP_FUTURE_ASSOC) ||
+ (s_info->sinfo_assoc_id == SCTP_ALL_ASSOC)))) {
SCTP_INP_WLOCK(inp);
memcpy(&inp->def_send, s_info, min(optsize, sizeof(inp->def_send)));
SCTP_INP_WUNLOCK(inp);
}
- if ((s_info->sinfo_assoc_id == SCTP_CURRENT_ASSOC) ||
- (s_info->sinfo_assoc_id == SCTP_ALL_ASSOC)) {
+ if ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ ((s_info->sinfo_assoc_id == SCTP_CURRENT_ASSOC) ||
+ (s_info->sinfo_assoc_id == SCTP_ALL_ASSOC))) {
SCTP_INP_RLOCK(inp);
LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) {
SCTP_TCB_LOCK(stcb);
@@ -6109,6 +6210,14 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL);
return (EINVAL);
}
+ if ((paddrp->spp_flags & SPP_PMTUD_DISABLE) &&
+ ((paddrp->spp_pathmtu < SCTP_SMALLEST_PMTU) ||
+ (paddrp->spp_pathmtu > SCTP_LARGEST_PMTU))) {
+ if (stcb)
+ SCTP_TCB_UNLOCK(stcb);
+ SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL);
+ return (EINVAL);
+ }
if (stcb != NULL) {
/************************TCB SPECIFIC SET ******************/
@@ -6134,12 +6243,13 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
net->dest_state &= ~SCTP_ADDR_NOHB;
}
if (paddrp->spp_flags & SPP_HB_DEMAND) {
- /* on demand HB */
- sctp_send_hb(stcb, net, SCTP_SO_LOCKED);
- sctp_chunk_output(inp, stcb, SCTP_OUTPUT_FROM_SOCKOPT, SCTP_SO_LOCKED);
- sctp_timer_start(SCTP_TIMER_TYPE_HEARTBEAT, inp, stcb, net);
+ if (SCTP_GET_STATE(stcb) == SCTP_STATE_OPEN) {
+ sctp_send_hb(stcb, net, SCTP_SO_LOCKED);
+ sctp_chunk_output(inp, stcb, SCTP_OUTPUT_FROM_SOCKOPT, SCTP_SO_LOCKED);
+ sctp_timer_start(SCTP_TIMER_TYPE_HEARTBEAT, inp, stcb, net);
+ }
}
- if ((paddrp->spp_flags & SPP_PMTUD_DISABLE) && (paddrp->spp_pathmtu >= SCTP_SMALLEST_PMTU)) {
+ if (paddrp->spp_flags & SPP_PMTUD_DISABLE) {
if (SCTP_OS_TIMER_PENDING(&net->pmtu_timer.timer)) {
sctp_timer_stop(SCTP_TIMER_TYPE_PATHMTURAISE, inp, stcb, net,
SCTP_FROM_SCTP_USRREQ + SCTP_LOC_11);
@@ -6286,7 +6396,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
}
sctp_stcb_feature_on(inp, stcb, SCTP_PCB_FLAGS_DONOT_HEARTBEAT);
}
- if ((paddrp->spp_flags & SPP_PMTUD_DISABLE) && (paddrp->spp_pathmtu >= SCTP_SMALLEST_PMTU)) {
+ if (paddrp->spp_flags & SPP_PMTUD_DISABLE) {
TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) {
if (SCTP_OS_TIMER_PENDING(&net->pmtu_timer.timer)) {
sctp_timer_stop(SCTP_TIMER_TYPE_PATHMTURAISE, inp, stcb, net,
@@ -6356,7 +6466,8 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
/************************NO TCB, SET TO default stuff ******************/
if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) ||
- (paddrp->spp_assoc_id == SCTP_FUTURE_ASSOC)) {
+ ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ (paddrp->spp_assoc_id == SCTP_FUTURE_ASSOC))) {
SCTP_INP_WLOCK(inp);
/*
* For the TOS/FLOWLABEL stuff you set it
@@ -6388,9 +6499,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
inp->sctp_ep.default_mtu = 0;
sctp_feature_off(inp, SCTP_PCB_FLAGS_DO_NOT_PMTUD);
} else if (paddrp->spp_flags & SPP_PMTUD_DISABLE) {
- if (paddrp->spp_pathmtu >= SCTP_SMALLEST_PMTU) {
- inp->sctp_ep.default_mtu = paddrp->spp_pathmtu;
- }
+ inp->sctp_ep.default_mtu = paddrp->spp_pathmtu;
sctp_feature_on(inp, SCTP_PCB_FLAGS_DO_NOT_PMTUD);
}
if (paddrp->spp_flags & SPP_DSCP) {
@@ -6446,7 +6555,8 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
} else {
if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) ||
- (srto->srto_assoc_id == SCTP_FUTURE_ASSOC)) {
+ ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ (srto->srto_assoc_id == SCTP_FUTURE_ASSOC))) {
SCTP_INP_WLOCK(inp);
if (srto->srto_initial)
new_init = srto->srto_initial;
@@ -6500,7 +6610,8 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
} else {
if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) ||
- (sasoc->sasoc_assoc_id == SCTP_FUTURE_ASSOC)) {
+ ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ (sasoc->sasoc_assoc_id == SCTP_FUTURE_ASSOC))) {
SCTP_INP_WLOCK(inp);
if (sasoc->sasoc_asocmaxrxt)
inp->sctp_ep.max_send_times = sasoc->sasoc_asocmaxrxt;
@@ -6967,8 +7078,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
* so return an error for sender dry events
*/
if ((event_type == SCTP_PCB_FLAGS_DRYEVNT) &&
- ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) == 0) &&
- ((inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) == 0) &&
+ (inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
((event->se_assoc_id == SCTP_ALL_ASSOC) ||
(event->se_assoc_id == SCTP_CURRENT_ASSOC))) {
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, ENOTSUP);
@@ -6977,8 +7087,9 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
}
if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) ||
- (event->se_assoc_id == SCTP_FUTURE_ASSOC) ||
- (event->se_assoc_id == SCTP_ALL_ASSOC)) {
+ ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ ((event->se_assoc_id == SCTP_FUTURE_ASSOC) ||
+ (event->se_assoc_id == SCTP_ALL_ASSOC)))) {
SCTP_INP_WLOCK(inp);
if (event->se_on) {
sctp_feature_on(inp, event_type);
@@ -6987,8 +7098,9 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
}
SCTP_INP_WUNLOCK(inp);
}
- if ((event->se_assoc_id == SCTP_CURRENT_ASSOC) ||
- (event->se_assoc_id == SCTP_ALL_ASSOC)) {
+ if ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ ((event->se_assoc_id == SCTP_CURRENT_ASSOC) ||
+ (event->se_assoc_id == SCTP_ALL_ASSOC))) {
SCTP_INP_RLOCK(inp);
LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) {
SCTP_TCB_LOCK(stcb);
@@ -7002,6 +7114,10 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
SCTP_INP_RUNLOCK(inp);
}
}
+ } else {
+ if (stcb) {
+ SCTP_TCB_UNLOCK(stcb);
+ }
}
break;
}
@@ -7057,8 +7173,9 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
} else {
if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) ||
- (info->snd_assoc_id == SCTP_FUTURE_ASSOC) ||
- (info->snd_assoc_id == SCTP_ALL_ASSOC)) {
+ ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ ((info->snd_assoc_id == SCTP_FUTURE_ASSOC) ||
+ (info->snd_assoc_id == SCTP_ALL_ASSOC)))) {
SCTP_INP_WLOCK(inp);
inp->def_send.sinfo_stream = info->snd_sid;
policy = PR_SCTP_POLICY(inp->def_send.sinfo_flags);
@@ -7068,8 +7185,9 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
inp->def_send.sinfo_context = info->snd_context;
SCTP_INP_WUNLOCK(inp);
}
- if ((info->snd_assoc_id == SCTP_CURRENT_ASSOC) ||
- (info->snd_assoc_id == SCTP_ALL_ASSOC)) {
+ if ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ ((info->snd_assoc_id == SCTP_CURRENT_ASSOC) ||
+ (info->snd_assoc_id == SCTP_ALL_ASSOC))) {
SCTP_INP_RLOCK(inp);
LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) {
SCTP_TCB_LOCK(stcb);
@@ -7096,6 +7214,9 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
SCTP_FIND_STCB(inp, stcb, info->pr_assoc_id);
if (info->pr_policy > SCTP_PR_SCTP_MAX) {
+ if (stcb) {
+ SCTP_TCB_UNLOCK(stcb);
+ }
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL);
error = EINVAL;
break;
@@ -7108,16 +7229,18 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
} else {
if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) ||
- (info->pr_assoc_id == SCTP_FUTURE_ASSOC) ||
- (info->pr_assoc_id == SCTP_ALL_ASSOC)) {
+ ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ ((info->pr_assoc_id == SCTP_FUTURE_ASSOC) ||
+ (info->pr_assoc_id == SCTP_ALL_ASSOC)))) {
SCTP_INP_WLOCK(inp);
inp->def_send.sinfo_flags &= 0xfff0;
inp->def_send.sinfo_flags |= info->pr_policy;
inp->def_send.sinfo_timetolive = info->pr_value;
SCTP_INP_WUNLOCK(inp);
}
- if ((info->pr_assoc_id == SCTP_CURRENT_ASSOC) ||
- (info->pr_assoc_id == SCTP_ALL_ASSOC)) {
+ if ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ ((info->pr_assoc_id == SCTP_CURRENT_ASSOC) ||
+ (info->pr_assoc_id == SCTP_ALL_ASSOC))) {
SCTP_INP_RLOCK(inp);
LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) {
SCTP_TCB_LOCK(stcb);
@@ -7224,6 +7347,9 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
}
}
if (thlds->spt_pathcpthld != 0xffff) {
+ if (stcb != NULL) {
+ SCTP_TCB_UNLOCK(stcb);
+ }
error = EINVAL;
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, error);
break;
@@ -7298,7 +7424,8 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
} else {
if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) ||
- (thlds->spt_assoc_id == SCTP_FUTURE_ASSOC)) {
+ ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ (thlds->spt_assoc_id == SCTP_FUTURE_ASSOC))) {
SCTP_INP_WLOCK(inp);
inp->sctp_ep.def_net_failure = thlds->spt_pathmaxrxt;
inp->sctp_ep.def_net_pf_threshold = thlds->spt_pathpfthld;
@@ -7411,7 +7538,8 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
} else {
if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) ||
- (encaps->sue_assoc_id == SCTP_FUTURE_ASSOC)) {
+ ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ (encaps->sue_assoc_id == SCTP_FUTURE_ASSOC))) {
SCTP_INP_WLOCK(inp);
inp->sctp_ep.port = encaps->sue_port;
SCTP_INP_WUNLOCK(inp);
@@ -7436,7 +7564,8 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
} else {
if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) ||
- (av->assoc_id == SCTP_FUTURE_ASSOC)) {
+ ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ (av->assoc_id == SCTP_FUTURE_ASSOC))) {
SCTP_INP_WLOCK(inp);
if (av->assoc_value == 0) {
inp->ecn_supported = 0;
@@ -7465,7 +7594,8 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
} else {
if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) ||
- (av->assoc_id == SCTP_FUTURE_ASSOC)) {
+ ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ (av->assoc_id == SCTP_FUTURE_ASSOC))) {
SCTP_INP_WLOCK(inp);
if (av->assoc_value == 0) {
inp->prsctp_supported = 0;
@@ -7494,7 +7624,8 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
} else {
if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) ||
- (av->assoc_id == SCTP_FUTURE_ASSOC)) {
+ ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ (av->assoc_id == SCTP_FUTURE_ASSOC))) {
if ((av->assoc_value == 0) &&
(inp->asconf_supported == 1)) {
/* AUTH is required for ASCONF */
@@ -7530,7 +7661,8 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
} else {
if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) ||
- (av->assoc_id == SCTP_FUTURE_ASSOC)) {
+ ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ (av->assoc_id == SCTP_FUTURE_ASSOC))) {
if ((av->assoc_value != 0) &&
(inp->auth_supported == 0)) {
/* AUTH is required for ASCONF */
@@ -7574,7 +7706,8 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
} else {
if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) ||
- (av->assoc_id == SCTP_FUTURE_ASSOC)) {
+ ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ (av->assoc_id == SCTP_FUTURE_ASSOC))) {
SCTP_INP_WLOCK(inp);
if (av->assoc_value == 0) {
inp->reconfig_supported = 0;
@@ -7603,7 +7736,8 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
} else {
if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) ||
- (av->assoc_id == SCTP_FUTURE_ASSOC)) {
+ ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ (av->assoc_id == SCTP_FUTURE_ASSOC))) {
SCTP_INP_WLOCK(inp);
if (av->assoc_value == 0) {
inp->nrsack_supported = 0;
@@ -7632,7 +7766,8 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
} else {
if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) ||
- (av->assoc_id == SCTP_FUTURE_ASSOC)) {
+ ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ (av->assoc_id == SCTP_FUTURE_ASSOC))) {
SCTP_INP_WLOCK(inp);
if (av->assoc_value == 0) {
inp->pktdrop_supported = 0;
@@ -7672,7 +7807,8 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
} else {
if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) ||
- (av->assoc_id == SCTP_FUTURE_ASSOC)) {
+ ((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
+ (av->assoc_id == SCTP_FUTURE_ASSOC))) {
SCTP_INP_WLOCK(inp);
inp->max_cwnd = av->assoc_value;
SCTP_INP_WUNLOCK(inp);
@@ -7732,6 +7868,10 @@ sctp_ctloutput(struct socket *so, struct sockopt *sopt)
return (error);
}
optsize = sopt->sopt_valsize;
+ if (optsize > SCTP_SOCKET_OPTION_LIMIT) {
+ SCTP_LTRACE_ERR_RET(so->so_pcb, NULL, NULL, SCTP_FROM_SCTP_USRREQ, ENOBUFS);
+ return (ENOBUFS);
+ }
if (optsize) {
SCTP_MALLOC(optval, void *, optsize, SCTP_M_SOCKOPT);
if (optval == NULL) {
@@ -7824,7 +7964,7 @@ sctp_connect(struct socket *so, struct mbuf *nam, struct proc *p)
case AF_INET6:
{
#if defined(__FreeBSD__) && __FreeBSD_version >= 800000
- struct sockaddr_in6 *sin6p;
+ struct sockaddr_in6 *sin6;
#endif
if (addr->sa_len != sizeof(struct sockaddr_in6)) {
@@ -7832,8 +7972,8 @@ sctp_connect(struct socket *so, struct mbuf *nam, struct proc *p)
return (EINVAL);
}
#if defined(__FreeBSD__) && __FreeBSD_version >= 800000
- sin6p = (struct sockaddr_in6 *)addr;
- if (p != NULL && (error = prison_remote_ip6(p->td_ucred, &sin6p->sin6_addr)) != 0) {
+ sin6 = (struct sockaddr_in6 *)addr;
+ if (p != NULL && (error = prison_remote_ip6(p->td_ucred, &sin6->sin6_addr)) != 0) {
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, error);
return (error);
}
@@ -7845,7 +7985,7 @@ sctp_connect(struct socket *so, struct mbuf *nam, struct proc *p)
case AF_INET:
{
#if defined(__FreeBSD__) && __FreeBSD_version >= 800000
- struct sockaddr_in *sinp;
+ struct sockaddr_in *sin;
#endif
#if !defined(__Userspace_os_Windows)
@@ -7855,8 +7995,8 @@ sctp_connect(struct socket *so, struct mbuf *nam, struct proc *p)
}
#endif
#if defined(__FreeBSD__) && __FreeBSD_version >= 800000
- sinp = (struct sockaddr_in *)addr;
- if (p != NULL && (error = prison_remote_ip4(p->td_ucred, &sinp->sin_addr)) != 0) {
+ sin = (struct sockaddr_in *)addr;
+ if (p != NULL && (error = prison_remote_ip4(p->td_ucred, &sin->sin_addr)) != 0) {
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, error);
return (error);
}
@@ -7960,7 +8100,8 @@ sctp_connect(struct socket *so, struct mbuf *nam, struct proc *p)
/* We are GOOD to go */
stcb = sctp_aloc_assoc(inp, addr, &error, 0, vrf_id,
inp->sctp_ep.pre_open_stream_count,
- inp->sctp_ep.port, p);
+ inp->sctp_ep.port, p,
+ SCTP_INITIALIZE_AUTH_PARAMS);
if (stcb == NULL) {
/* Gak! no memory */
goto out_now;
@@ -7970,12 +8111,9 @@ sctp_connect(struct socket *so, struct mbuf *nam, struct proc *p)
/* Set the connected flag so we can queue data */
soisconnecting(so);
}
- SCTP_SET_STATE(&stcb->asoc, SCTP_STATE_COOKIE_WAIT);
+ SCTP_SET_STATE(stcb, SCTP_STATE_COOKIE_WAIT);
(void)SCTP_GETTIME_TIMEVAL(&stcb->asoc.time_entered);
- /* initialize authentication parameters for the assoc */
- sctp_initialize_auth_params(inp, stcb);
-
sctp_send_initiate(inp, stcb, SCTP_SO_LOCKED);
SCTP_TCB_UNLOCK(stcb);
out_now:
@@ -8127,7 +8265,8 @@ sctpconn_connect(struct socket *so, struct sockaddr *addr)
/* We are GOOD to go */
stcb = sctp_aloc_assoc(inp, addr, &error, 0, vrf_id,
inp->sctp_ep.pre_open_stream_count,
- inp->sctp_ep.port, p);
+ inp->sctp_ep.port, p,
+ SCTP_INITIALIZE_AUTH_PARAMS);
if (stcb == NULL) {
/* Gak! no memory */
goto out_now;
@@ -8137,12 +8276,9 @@ sctpconn_connect(struct socket *so, struct sockaddr *addr)
/* Set the connected flag so we can queue data */
soisconnecting(so);
}
- SCTP_SET_STATE(&stcb->asoc, SCTP_STATE_COOKIE_WAIT);
+ SCTP_SET_STATE(stcb, SCTP_STATE_COOKIE_WAIT);
(void)SCTP_GETTIME_TIMEVAL(&stcb->asoc.time_entered);
- /* initialize authentication parameters for the assoc */
- sctp_initialize_auth_params(inp, stcb);
-
sctp_send_initiate(inp, stcb, SCTP_SO_LOCKED);
SCTP_TCB_UNLOCK(stcb);
out_now:
@@ -8384,18 +8520,8 @@ sctp_listen(struct socket *so, struct proc *p)
static int sctp_defered_wakeup_cnt = 0;
int
-#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) || defined(__Userspace__)
sctp_accept(struct socket *so, struct sockaddr **addr)
{
-#elif defined(__Panda__)
-sctp_accept(struct socket *so, struct sockaddr *addr, int *namelen,
- void *accept_info, int *accept_info_len)
-{
-#else
-sctp_accept(struct socket *so, struct mbuf *nam)
-{
- struct sockaddr *addr = mtod(nam, struct sockaddr *);
-#endif
struct sctp_tcb *stcb;
struct sctp_inpcb *inp;
union sctp_sockstore store;
@@ -8410,28 +8536,76 @@ sctp_accept(struct socket *so, struct mbuf *nam)
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL);
return (ECONNRESET);
}
- SCTP_INP_RLOCK(inp);
+ SCTP_INP_WLOCK(inp);
if (inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) {
- SCTP_INP_RUNLOCK(inp);
+ SCTP_INP_WUNLOCK(inp);
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EOPNOTSUPP);
return (EOPNOTSUPP);
}
if (so->so_state & SS_ISDISCONNECTED) {
- SCTP_INP_RUNLOCK(inp);
+ SCTP_INP_WUNLOCK(inp);
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, ECONNABORTED);
return (ECONNABORTED);
}
stcb = LIST_FIRST(&inp->sctp_asoc_list);
if (stcb == NULL) {
- SCTP_INP_RUNLOCK(inp);
+ SCTP_INP_WUNLOCK(inp);
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL);
return (ECONNRESET);
}
SCTP_TCB_LOCK(stcb);
- SCTP_INP_RUNLOCK(inp);
store = stcb->asoc.primary_destination->ro._l_addr;
- stcb->asoc.state &= ~SCTP_STATE_IN_ACCEPT_QUEUE;
- SCTP_TCB_UNLOCK(stcb);
+ SCTP_CLEAR_SUBSTATE(stcb, SCTP_STATE_IN_ACCEPT_QUEUE);
+ /* Wake any delayed sleep action */
+ if (inp->sctp_flags & SCTP_PCB_FLAGS_DONT_WAKE) {
+ inp->sctp_flags &= ~SCTP_PCB_FLAGS_DONT_WAKE;
+ if (inp->sctp_flags & SCTP_PCB_FLAGS_WAKEOUTPUT) {
+ inp->sctp_flags &= ~SCTP_PCB_FLAGS_WAKEOUTPUT;
+ SOCKBUF_LOCK(&inp->sctp_socket->so_snd);
+ if (sowriteable(inp->sctp_socket)) {
+#if defined(__Userspace__)
+ /*__Userspace__ calling sowwakup_locked because of SOCKBUF_LOCK above. */
+#endif
+#if defined(__FreeBSD__) || defined(__Windows__) || defined(__Userspace__)
+ sowwakeup_locked(inp->sctp_socket);
+#else
+#if defined(__APPLE__)
+ /* socket is locked */
+#endif
+ sowwakeup(inp->sctp_socket);
+#endif
+ } else {
+ SOCKBUF_UNLOCK(&inp->sctp_socket->so_snd);
+ }
+ }
+ if (inp->sctp_flags & SCTP_PCB_FLAGS_WAKEINPUT) {
+ inp->sctp_flags &= ~SCTP_PCB_FLAGS_WAKEINPUT;
+ SOCKBUF_LOCK(&inp->sctp_socket->so_rcv);
+ if (soreadable(inp->sctp_socket)) {
+ sctp_defered_wakeup_cnt++;
+#if defined(__Userspace__)
+ /*__Userspace__ calling sorwakup_locked because of SOCKBUF_LOCK above */
+#endif
+#if defined(__FreeBSD__) || defined(__Windows__) || defined(__Userspace__)
+ sorwakeup_locked(inp->sctp_socket);
+#else
+#if defined(__APPLE__)
+ /* socket is locked */
+#endif
+ sorwakeup(inp->sctp_socket);
+#endif
+ } else {
+ SOCKBUF_UNLOCK(&inp->sctp_socket->so_rcv);
+ }
+ }
+ }
+ SCTP_INP_WUNLOCK(inp);
+ if (stcb->asoc.state & SCTP_STATE_ABOUT_TO_BE_FREED) {
+ sctp_free_assoc(inp, stcb, SCTP_NORMAL_PROC,
+ SCTP_FROM_SCTP_USRREQ + SCTP_LOC_19);
+ } else {
+ SCTP_TCB_UNLOCK(stcb);
+ }
switch (store.sa.sa_family) {
#ifdef INET
case AF_INET:
@@ -8527,60 +8701,6 @@ sctp_accept(struct socket *so, struct mbuf *nam)
/* TSNH */
break;
}
- /* Wake any delayed sleep action */
- if (inp->sctp_flags & SCTP_PCB_FLAGS_DONT_WAKE) {
- SCTP_INP_WLOCK(inp);
- inp->sctp_flags &= ~SCTP_PCB_FLAGS_DONT_WAKE;
- if (inp->sctp_flags & SCTP_PCB_FLAGS_WAKEOUTPUT) {
- inp->sctp_flags &= ~SCTP_PCB_FLAGS_WAKEOUTPUT;
- SCTP_INP_WUNLOCK(inp);
- SOCKBUF_LOCK(&inp->sctp_socket->so_snd);
- if (sowriteable(inp->sctp_socket)) {
-#if defined(__Userspace__)
- /*__Userspace__ calling sowwakup_locked because of SOCKBUF_LOCK above. */
-#endif
-#if defined(__FreeBSD__) || defined(__Windows__) || defined(__Userspace__)
- sowwakeup_locked(inp->sctp_socket);
-#else
-#if defined(__APPLE__)
- /* socket is locked */
-#endif
- sowwakeup(inp->sctp_socket);
-#endif
- } else {
- SOCKBUF_UNLOCK(&inp->sctp_socket->so_snd);
- }
- SCTP_INP_WLOCK(inp);
- }
- if (inp->sctp_flags & SCTP_PCB_FLAGS_WAKEINPUT) {
- inp->sctp_flags &= ~SCTP_PCB_FLAGS_WAKEINPUT;
- SCTP_INP_WUNLOCK(inp);
- SOCKBUF_LOCK(&inp->sctp_socket->so_rcv);
- if (soreadable(inp->sctp_socket)) {
- sctp_defered_wakeup_cnt++;
-#if defined(__Userspace__)
- /*__Userspace__ calling sorwakup_locked because of SOCKBUF_LOCK above */
-#endif
-#if defined(__FreeBSD__) || defined(__Windows__) || defined(__Userspace__)
- sorwakeup_locked(inp->sctp_socket);
-#else
-#if defined(__APPLE__)
- /* socket is locked */
-#endif
- sorwakeup(inp->sctp_socket);
-#endif
- } else {
- SOCKBUF_UNLOCK(&inp->sctp_socket->so_rcv);
- }
- SCTP_INP_WLOCK(inp);
- }
- SCTP_INP_WUNLOCK(inp);
- }
- if (stcb->asoc.state & SCTP_STATE_ABOUT_TO_BE_FREED) {
- SCTP_TCB_LOCK(stcb);
- sctp_free_assoc(inp, stcb, SCTP_NORMAL_PROC,
- SCTP_FROM_SCTP_USRREQ + SCTP_LOC_19);
- }
return (0);
}
diff --git a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_var.h b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_var.h
index bc4afe95f1f..ead9e9cd61f 100755
--- a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_var.h
+++ b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctp_var.h
@@ -454,7 +454,7 @@ void sctp_drain(void);
#if defined(__Userspace__)
void sctp_init(uint16_t,
int (*)(void *addr, void *buffer, size_t length, uint8_t tos, uint8_t set_df),
- void (*)(const char *, ...));
+ void (*)(const char *, ...), int start_threads);
#elif defined(__FreeBSD__) && __FreeBSD_version < 902000
void sctp_init __P((void));
#elif defined(__APPLE__) && (!defined(APPLE_LEOPARD) && !defined(APPLE_SNOWLEOPARD) &&!defined(APPLE_LION) && !defined(APPLE_MOUNTAINLION))
diff --git a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctputil.c b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctputil.c
index 1134b506578..001a2b37d11 100755
--- a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctputil.c
+++ b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctputil.c
@@ -34,7 +34,7 @@
#ifdef __FreeBSD__
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/netinet/sctputil.c 334286 2018-05-28 13:31:47Z tuexen $");
+__FBSDID("$FreeBSD: head/sys/netinet/sctputil.c 353518 2019-10-14 20:32:11Z tuexen $");
#endif
#include <netinet/sctp_os.h>
@@ -59,6 +59,7 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctputil.c 334286 2018-05-28 13:31:47Z tuex
#include <netinet/sctp_constants.h>
#endif
#if defined(__FreeBSD__)
+#include <netinet/sctp_kdtrace.h>
#if defined(INET6) || defined(INET)
#include <netinet/tcp_var.h>
#endif
@@ -576,7 +577,7 @@ sctp_wakeup_log(struct sctp_tcb *stcb, uint32_t wake_cnt, int from)
}
void
-sctp_log_block(uint8_t from, struct sctp_association *asoc, size_t sendlen)
+sctp_log_block(uint8_t from, struct sctp_association *asoc, ssize_t sendlen)
{
#if defined(SCTP_LOCAL_TRACE_BUF)
struct sctp_cwnd_log sctp_clog;
@@ -912,9 +913,15 @@ sctp_fill_random_store(struct sctp_pcb *m)
* numbers, but thats ok too since that is random as well :->
*/
m->store_at = 0;
+#if defined(__Userspace__) && defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION)
+ for (int i = 0; i < (int) (sizeof(m->random_store) / sizeof(m->random_store[0])); i++) {
+ m->random_store[i] = (uint8_t) rand();
+ }
+#else
(void)sctp_hmac(SCTP_HMAC, (uint8_t *)m->random_numbers,
sizeof(m->random_numbers), (uint8_t *)&m->random_counter,
sizeof(m->random_counter), (uint8_t *)m->random_store);
+#endif
m->random_counter++;
}
@@ -1044,7 +1051,7 @@ sctp_init_asoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
asoc = &stcb->asoc;
/* init all variables to a known value. */
- SCTP_SET_STATE(&stcb->asoc, SCTP_STATE_INUSE);
+ SCTP_SET_STATE(stcb, SCTP_STATE_INUSE);
asoc->max_burst = inp->sctp_ep.max_burst;
asoc->fr_max_burst = inp->sctp_ep.fr_max_burst;
asoc->heart_beat_delay = TICKS_TO_MSEC(inp->sctp_ep.sctp_timeoutticks[SCTP_TIMER_HEARTBEAT]);
@@ -1616,6 +1623,9 @@ sctp_timeout_handler(void *t)
#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING)
struct socket *so;
#endif
+#if defined(__Userspace__)
+ struct socket *upcall_socket = NULL;
+#endif
int did_output;
int type;
@@ -1754,6 +1764,16 @@ sctp_timeout_handler(void *t)
}
SCTP_OS_TIMER_DEACTIVATE(&tmr->timer);
+#if defined(__Userspace__)
+ if ((stcb != NULL) &&
+ !(stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) &&
+ (stcb->sctp_socket != NULL)) {
+ upcall_socket = stcb->sctp_socket;
+ SOCK_LOCK(upcall_socket);
+ soref(upcall_socket);
+ SOCK_UNLOCK(upcall_socket);
+ }
+#endif
/* call the handler for the appropriate timer type */
switch (type) {
case SCTP_TIMER_TYPE_ADDR_WQ:
@@ -2055,6 +2075,17 @@ get_out:
}
out_decr:
+#if defined(__Userspace__)
+ if (upcall_socket != NULL) {
+ if ((upcall_socket->so_upcall != NULL) &&
+ (upcall_socket->so_error != 0)) {
+ (*upcall_socket->so_upcall)(upcall_socket, upcall_socket->so_upcallarg, M_NOWAIT);
+ }
+ ACCEPT_LOCK();
+ SOCK_LOCK(upcall_socket);
+ sorele(upcall_socket);
+ }
+#endif
if (inp) {
SCTP_INP_DECR_REF(inp);
}
@@ -2549,25 +2580,24 @@ sctp_mtu_size_reset(struct sctp_inpcb *inp,
/*
- * given an association and starting time of the current RTT period return
- * RTO in number of msecs net should point to the current network
+ * Given an association and starting time of the current RTT period, update
+ * RTO in number of msecs. net should point to the current network.
+ * Return 1, if an RTO update was performed, return 0 if no update was
+ * performed due to invalid starting point.
*/
-uint32_t
+int
sctp_calculate_rto(struct sctp_tcb *stcb,
struct sctp_association *asoc,
struct sctp_nets *net,
struct timeval *old,
int rtt_from_sack)
{
- /*-
- * given an association and the starting time of the current RTT
- * period (in value1/value2) return RTO in number of msecs.
- */
- int32_t rtt; /* RTT in ms */
+ struct timeval now;
+ uint64_t rtt_us; /* RTT in us */
+ int32_t rtt; /* RTT in ms */
uint32_t new_rto;
int first_measure = 0;
- struct timeval now;
/************************/
/* 1. calculate new RTT */
@@ -2578,10 +2608,19 @@ sctp_calculate_rto(struct sctp_tcb *stcb,
} else {
(void)SCTP_GETTIME_TIMEVAL(&now);
}
+ if ((old->tv_sec > now.tv_sec) ||
+ ((old->tv_sec == now.tv_sec) && (old->tv_sec > now.tv_sec))) {
+ /* The starting point is in the future. */
+ return (0);
+ }
timevalsub(&now, old);
+ rtt_us = (uint64_t)1000000 * (uint64_t)now.tv_sec + (uint64_t)now.tv_usec;
+ if (rtt_us > SCTP_RTO_UPPER_BOUND * 1000) {
+ /* The RTT is larger than a sane value. */
+ return (0);
+ }
/* store the current RTT in us */
- net->rtt = (uint64_t)1000000 * (uint64_t)now.tv_sec +
- (uint64_t)now.tv_usec;
+ net->rtt = rtt_us;
/* compute rtt in ms */
rtt = (int32_t)(net->rtt / 1000);
if ((asoc->cc_functions.sctp_rtt_calculated) && (rtt_from_sack == SCTP_RTT_FROM_DATA)) {
@@ -2610,7 +2649,7 @@ sctp_calculate_rto(struct sctp_tcb *stcb,
* Paper "Congestion Avoidance and Control", Annex A.
*
* (net->lastsa >> SCTP_RTT_SHIFT) is the srtt
- * (net->lastsa >> SCTP_RTT_VAR_SHIFT) is the rttvar
+ * (net->lastsv >> SCTP_RTT_VAR_SHIFT) is the rttvar
*/
if (net->RTO_measured) {
rtt -= (net->lastsa >> SCTP_RTT_SHIFT);
@@ -2651,8 +2690,8 @@ sctp_calculate_rto(struct sctp_tcb *stcb,
if (new_rto > stcb->asoc.maxrto) {
new_rto = stcb->asoc.maxrto;
}
- /* we are now returning the RTO */
- return (new_rto);
+ net->RTO = new_rto;
+ return (1);
}
/*
@@ -2877,7 +2916,7 @@ set_error:
((state == SCTP_COMM_LOST) || (state == SCTP_CANT_STR_ASSOC))) {
SOCK_LOCK(stcb->sctp_socket);
if (from_peer) {
- if (SCTP_GET_STATE(&stcb->asoc) == SCTP_STATE_COOKIE_WAIT) {
+ if (SCTP_GET_STATE(stcb) == SCTP_STATE_COOKIE_WAIT) {
SCTP_LTRACE_ERR_RET(NULL, stcb, NULL, SCTP_FROM_SCTPUTIL, ECONNREFUSED);
stcb->sctp_socket->so_error = ECONNREFUSED;
} else {
@@ -2885,8 +2924,8 @@ set_error:
stcb->sctp_socket->so_error = ECONNRESET;
}
} else {
- if ((SCTP_GET_STATE(&stcb->asoc) == SCTP_STATE_COOKIE_WAIT) ||
- (SCTP_GET_STATE(&stcb->asoc) == SCTP_STATE_COOKIE_ECHOED)) {
+ if ((SCTP_GET_STATE(stcb) == SCTP_STATE_COOKIE_WAIT) ||
+ (SCTP_GET_STATE(stcb) == SCTP_STATE_COOKIE_ECHOED)) {
SCTP_LTRACE_ERR_RET(NULL, stcb, NULL, SCTP_FROM_SCTPUTIL, ETIMEDOUT);
stcb->sctp_socket->so_error = ETIMEDOUT;
} else {
@@ -3800,8 +3839,8 @@ sctp_ulp_notify(uint32_t notification, struct sctp_tcb *stcb,
sctp_unlock_assert(SCTP_INP_SO(stcb->sctp_ep));
}
#endif
- if ((stcb->asoc.state & SCTP_STATE_COOKIE_WAIT) ||
- (stcb->asoc.state & SCTP_STATE_COOKIE_ECHOED)) {
+ if ((SCTP_GET_STATE(stcb) == SCTP_STATE_COOKIE_WAIT) ||
+ (SCTP_GET_STATE(stcb) == SCTP_STATE_COOKIE_ECHOED)) {
if ((notification == SCTP_NOTIFY_INTERFACE_DOWN) ||
(notification == SCTP_NOTIFY_INTERFACE_UP) ||
(notification == SCTP_NOTIFY_INTERFACE_CONFIRMED)) {
@@ -3890,16 +3929,16 @@ sctp_ulp_notify(uint32_t notification, struct sctp_tcb *stcb,
break;
}
case SCTP_NOTIFY_ASSOC_LOC_ABORTED:
- if (((stcb->asoc.state & SCTP_STATE_MASK) == SCTP_STATE_COOKIE_WAIT) ||
- ((stcb->asoc.state & SCTP_STATE_MASK) == SCTP_STATE_COOKIE_ECHOED)) {
+ if ((SCTP_GET_STATE(stcb) == SCTP_STATE_COOKIE_WAIT) ||
+ (SCTP_GET_STATE(stcb) == SCTP_STATE_COOKIE_ECHOED)) {
sctp_notify_assoc_change(SCTP_CANT_STR_ASSOC, stcb, error, data, 0, so_locked);
} else {
sctp_notify_assoc_change(SCTP_COMM_LOST, stcb, error, data, 0, so_locked);
}
break;
case SCTP_NOTIFY_ASSOC_REM_ABORTED:
- if (((stcb->asoc.state & SCTP_STATE_MASK) == SCTP_STATE_COOKIE_WAIT) ||
- ((stcb->asoc.state & SCTP_STATE_MASK) == SCTP_STATE_COOKIE_ECHOED)) {
+ if ((SCTP_GET_STATE(stcb) == SCTP_STATE_COOKIE_WAIT) ||
+ (SCTP_GET_STATE(stcb) == SCTP_STATE_COOKIE_ECHOED)) {
sctp_notify_assoc_change(SCTP_CANT_STR_ASSOC, stcb, error, data, 1, so_locked);
} else {
sctp_notify_assoc_change(SCTP_COMM_LOST, stcb, error, data, 1, so_locked);
@@ -4069,7 +4108,7 @@ sctp_report_all_outbound(struct sctp_tcb *stcb, uint16_t error, int holds_lock,
TAILQ_FOREACH_SAFE(sp, &outs->outqueue, next, nsp) {
atomic_subtract_int(&asoc->stream_queue_cnt, 1);
TAILQ_REMOVE(&outs->outqueue, sp, next);
- stcb->asoc.ss_functions.sctp_ss_remove_from_stream(stcb, asoc, outs, sp, holds_lock);
+ stcb->asoc.ss_functions.sctp_ss_remove_from_stream(stcb, asoc, outs, sp, 1);
sctp_free_spbufspace(stcb, asoc, sp);
if (sp->data) {
sctp_ulp_notify(SCTP_NOTIFY_SPECIAL_SP_FAIL, stcb,
@@ -4125,7 +4164,7 @@ sctp_abort_notification(struct sctp_tcb *stcb, uint8_t from_peer, uint16_t error
return;
}
/* Tell them we lost the asoc */
- sctp_report_all_outbound(stcb, error, 1, so_locked);
+ sctp_report_all_outbound(stcb, error, 0, so_locked);
if (from_peer) {
sctp_ulp_notify(SCTP_NOTIFY_ASSOC_REM_ABORTED, stcb, error, abort, so_locked);
} else {
@@ -4161,7 +4200,7 @@ sctp_abort_association(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
if (stcb != NULL) {
/* We have a TCB to abort, send notification too */
sctp_abort_notification(stcb, 0, 0, NULL, SCTP_SO_NOT_LOCKED);
- stcb->asoc.state |= SCTP_STATE_WAS_ABORTED;
+ SCTP_ADD_SUBSTATE(stcb, SCTP_STATE_WAS_ABORTED);
/* Ok, now lets free it */
#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING)
so = SCTP_INP_SO(inp);
@@ -4172,8 +4211,8 @@ sctp_abort_association(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
atomic_subtract_int(&stcb->asoc.refcnt, 1);
#endif
SCTP_STAT_INCR_COUNTER32(sctps_aborted);
- if ((SCTP_GET_STATE(&stcb->asoc) == SCTP_STATE_OPEN) ||
- (SCTP_GET_STATE(&stcb->asoc) == SCTP_STATE_SHUTDOWN_RECEIVED)) {
+ if ((SCTP_GET_STATE(stcb) == SCTP_STATE_OPEN) ||
+ (SCTP_GET_STATE(stcb) == SCTP_STATE_SHUTDOWN_RECEIVED)) {
SCTP_STAT_DECR_GAUGE32(sctps_currestab);
}
(void)sctp_free_assoc(inp, stcb, SCTP_NORMAL_PROC,
@@ -4288,13 +4327,13 @@ sctp_abort_an_association(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
}
return;
} else {
- stcb->asoc.state |= SCTP_STATE_WAS_ABORTED;
+ SCTP_ADD_SUBSTATE(stcb, SCTP_STATE_WAS_ABORTED);
}
/* notify the peer */
sctp_send_abort_tcb(stcb, op_err, so_locked);
SCTP_STAT_INCR_COUNTER32(sctps_aborted);
- if ((SCTP_GET_STATE(&stcb->asoc) == SCTP_STATE_OPEN) ||
- (SCTP_GET_STATE(&stcb->asoc) == SCTP_STATE_SHUTDOWN_RECEIVED)) {
+ if ((SCTP_GET_STATE(stcb) == SCTP_STATE_OPEN) ||
+ (SCTP_GET_STATE(stcb) == SCTP_STATE_SHUTDOWN_RECEIVED)) {
SCTP_STAT_DECR_GAUGE32(sctps_currestab);
}
/* notify the ulp */
@@ -4923,12 +4962,14 @@ sctp_add_to_readq(struct sctp_inpcb *inp,
if (inp_read_lock_held == 0)
SCTP_INP_READ_LOCK(inp);
if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_CANT_READ) {
- sctp_free_remote_addr(control->whoFrom);
- if (control->data) {
- sctp_m_freem(control->data);
- control->data = NULL;
+ if (!control->on_strm_q) {
+ sctp_free_remote_addr(control->whoFrom);
+ if (control->data) {
+ sctp_m_freem(control->data);
+ control->data = NULL;
+ }
+ sctp_free_a_readq(stcb, control);
}
- sctp_free_a_readq(stcb, control);
if (inp_read_lock_held == 0)
SCTP_INP_READ_UNLOCK(inp);
return;
@@ -4973,8 +5014,10 @@ sctp_add_to_readq(struct sctp_inpcb *inp,
control->tail_mbuf = prev;
} else {
/* Everything got collapsed out?? */
- sctp_free_remote_addr(control->whoFrom);
- sctp_free_a_readq(stcb, control);
+ if (!control->on_strm_q) {
+ sctp_free_remote_addr(control->whoFrom);
+ sctp_free_a_readq(stcb, control);
+ }
if (inp_read_lock_held == 0)
SCTP_INP_READ_UNLOCK(inp);
return;
@@ -5537,9 +5580,8 @@ sctp_user_rcvd(struct sctp_tcb *stcb, uint32_t *freed_so_far, int hold_rlock,
atomic_add_int(&stcb->asoc.refcnt, 1);
- if (stcb->asoc.state & (SCTP_STATE_ABOUT_TO_BE_FREED |
- SCTP_STATE_SHUTDOWN_RECEIVED |
- SCTP_STATE_SHUTDOWN_ACK_SENT)) {
+ if ((SCTP_GET_STATE(stcb) == SCTP_STATE_SHUTDOWN_ACK_SENT) ||
+ (stcb->asoc.state & (SCTP_STATE_ABOUT_TO_BE_FREED | SCTP_STATE_SHUTDOWN_RECEIVED))) {
/* Pre-check If we are freeing no update */
goto no_lock;
}
@@ -5626,8 +5668,9 @@ sctp_sorecvmsg(struct socket *so,
*
*/
struct sctp_inpcb *inp = NULL;
- int my_len = 0;
- int cp_len = 0, error = 0;
+ ssize_t my_len = 0;
+ ssize_t cp_len = 0;
+ int error = 0;
struct sctp_queued_to_read *control = NULL, *ctl = NULL, *nxt = NULL;
struct mbuf *m = NULL;
struct sctp_tcb *stcb = NULL;
@@ -5636,7 +5679,7 @@ sctp_sorecvmsg(struct socket *so,
int out_flags = 0, in_flags = 0;
int block_allowed = 1;
uint32_t freed_so_far = 0;
- uint32_t copied_so_far = 0;
+ ssize_t copied_so_far = 0;
int in_eeor_mode = 0;
int no_rcv_needed = 0;
uint32_t rwnd_req = 0;
@@ -6033,7 +6076,7 @@ sctp_sorecvmsg(struct socket *so,
* we then will go to the sctp_user_rcvd() that will
* not lock until it KNOWs it MUST send a WUP-SACK.
*/
- freed_so_far = stcb->freed_by_sorcv_sincelast;
+ freed_so_far = (uint32_t)stcb->freed_by_sorcv_sincelast;
stcb->freed_by_sorcv_sincelast = 0;
}
}
@@ -6195,14 +6238,14 @@ sctp_sorecvmsg(struct socket *so,
/* Move out all we can */
#if defined(__APPLE__)
#if defined(APPLE_LEOPARD)
- cp_len = (int)uio->uio_resid;
+ cp_len = uio->uio_resid;
#else
- cp_len = (int)uio_resid(uio);
+ cp_len = uio_resid(uio);
#endif
#else
- cp_len = (int)uio->uio_resid;
+ cp_len = uio->uio_resid;
#endif
- my_len = (int)SCTP_BUF_LEN(m);
+ my_len = SCTP_BUF_LEN(m);
if (cp_len > my_len) {
/* not enough in this buf */
cp_len = my_len;
@@ -6215,7 +6258,7 @@ sctp_sorecvmsg(struct socket *so,
SCTP_SOCKET_UNLOCK(so, 0);
#endif
if (cp_len > 0)
- error = uiomove(mtod(m, char *), cp_len, uio);
+ error = uiomove(mtod(m, char *), (int)cp_len, uio);
#if defined(__APPLE__)
SCTP_SOCKET_LOCK(so, 0);
#endif
@@ -6263,7 +6306,7 @@ sctp_sorecvmsg(struct socket *so,
control->do_not_ref_stcb?NULL:stcb, SCTP_LOG_SBRESULT, 0);
}
copied_so_far += cp_len;
- freed_so_far += cp_len;
+ freed_so_far += (uint32_t)cp_len;
freed_so_far += MSIZE;
atomic_subtract_int(&control->length, cp_len);
control->data = sctp_m_free(m);
@@ -6298,9 +6341,9 @@ sctp_sorecvmsg(struct socket *so,
}
if ((in_flags & MSG_PEEK) == 0) {
SCTP_BUF_RESV_UF(m, cp_len);
- SCTP_BUF_LEN(m) -= cp_len;
+ SCTP_BUF_LEN(m) -= (int)cp_len;
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_SB_LOGGING_ENABLE) {
- sctp_sblog(&so->so_rcv, control->do_not_ref_stcb?NULL:stcb, SCTP_LOG_SBFREE, cp_len);
+ sctp_sblog(&so->so_rcv, control->do_not_ref_stcb?NULL:stcb, SCTP_LOG_SBFREE, (int)cp_len);
}
atomic_subtract_int(&so->so_rcv.sb_cc, cp_len);
if ((control->do_not_ref_stcb == 0) &&
@@ -6308,7 +6351,7 @@ sctp_sorecvmsg(struct socket *so,
atomic_subtract_int(&stcb->asoc.sb_cc, cp_len);
}
copied_so_far += cp_len;
- freed_so_far += cp_len;
+ freed_so_far += (uint32_t)cp_len;
freed_so_far += MSIZE;
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_SB_LOGGING_ENABLE) {
sctp_sblog(&so->so_rcv, control->do_not_ref_stcb?NULL:stcb,
@@ -6415,7 +6458,7 @@ sctp_sorecvmsg(struct socket *so,
if ((uio->uio_resid == 0) ||
#endif
((in_eeor_mode) &&
- (copied_so_far >= (uint32_t)max(so->so_rcv.sb_lowat, 1)))) {
+ (copied_so_far >= max(so->so_rcv.sb_lowat, 1)))) {
goto release;
}
/*
@@ -6571,7 +6614,7 @@ sctp_sorecvmsg(struct socket *so,
control->do_not_ref_stcb?NULL:stcb, SCTP_LOG_SBFREE, SCTP_BUF_LEN(m));
}
sctp_sbfree(control, stcb, &so->so_rcv, m);
- freed_so_far += SCTP_BUF_LEN(m);
+ freed_so_far += (uint32_t)SCTP_BUF_LEN(m);
freed_so_far += MSIZE;
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_SB_LOGGING_ENABLE) {
sctp_sblog(&so->so_rcv,
@@ -7103,31 +7146,34 @@ sctp_connectx_helper_add(struct sctp_tcb *stcb, struct sockaddr *addr,
return (added);
}
-struct sctp_tcb *
+int
sctp_connectx_helper_find(struct sctp_inpcb *inp, struct sockaddr *addr,
- unsigned int *totaddr,
- unsigned int *num_v4, unsigned int *num_v6, int *error,
- unsigned int limit, int *bad_addr)
+ unsigned int totaddr,
+ unsigned int *num_v4, unsigned int *num_v6,
+ unsigned int limit)
{
struct sockaddr *sa;
- struct sctp_tcb *stcb = NULL;
+ struct sctp_tcb *stcb;
unsigned int incr, at, i;
at = 0;
sa = addr;
- *error = *num_v6 = *num_v4 = 0;
+ *num_v6 = *num_v4 = 0;
/* account and validate addresses */
- for (i = 0; i < *totaddr; i++) {
+ if (totaddr == 0) {
+ return (EINVAL);
+ }
+ for (i = 0; i < totaddr; i++) {
+ if (at + sizeof(struct sockaddr) > limit) {
+ return (EINVAL);
+ }
switch (sa->sa_family) {
#ifdef INET
case AF_INET:
incr = (unsigned int)sizeof(struct sockaddr_in);
#ifdef HAVE_SA_LEN
if (sa->sa_len != incr) {
- SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTPUTIL, EINVAL);
- *error = EINVAL;
- *bad_addr = 1;
- return (NULL);
+ return (EINVAL);
}
#endif
(*num_v4) += 1;
@@ -7141,18 +7187,12 @@ sctp_connectx_helper_find(struct sctp_inpcb *inp, struct sockaddr *addr,
sin6 = (struct sockaddr_in6 *)sa;
if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) {
/* Must be non-mapped for connectx */
- SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTPUTIL, EINVAL);
- *error = EINVAL;
- *bad_addr = 1;
- return (NULL);
+ return (EINVAL);
}
incr = (unsigned int)sizeof(struct sockaddr_in6);
#ifdef HAVE_SA_LEN
if (sa->sa_len != incr) {
- SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTPUTIL, EINVAL);
- *error = EINVAL;
- *bad_addr = 1;
- return (NULL);
+ return (EINVAL);
}
#endif
(*num_v6) += 1;
@@ -7160,29 +7200,23 @@ sctp_connectx_helper_find(struct sctp_inpcb *inp, struct sockaddr *addr,
}
#endif
default:
- *totaddr = i;
- incr = 0;
- /* we are done */
- break;
+ return (EINVAL);
}
- if (i == *totaddr) {
- break;
+ if ((at + incr) > limit) {
+ return (EINVAL);
}
SCTP_INP_INCR_REF(inp);
stcb = sctp_findassociation_ep_addr(&inp, sa, NULL, NULL, NULL);
if (stcb != NULL) {
- /* Already have or am bring up an association */
- return (stcb);
+ SCTP_TCB_UNLOCK(stcb);
+ return (EALREADY);
} else {
SCTP_INP_DECR_REF(inp);
}
- if ((at + incr) > limit) {
- *totaddr = i;
- break;
- }
+ at += incr;
sa = (struct sockaddr *)((caddr_t)sa + incr);
}
- return ((struct sctp_tcb *)NULL);
+ return (0);
}
/*
@@ -7873,6 +7907,24 @@ sctp_recv_icmp_tunneled_packet(int cmd, struct sockaddr *sa, void *vip, void *ct
sctp_notify(inp, stcb, net, type, code,
ntohs(inner_ip->ip_len),
(uint32_t)ntohs(icmp->icmp_nextmtu));
+#if defined(__Userspace__)
+ if (!(stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) &&
+ (stcb->sctp_socket != NULL)) {
+ struct socket *upcall_socket;
+
+ upcall_socket = stcb->sctp_socket;
+ SOCK_LOCK(upcall_socket);
+ soref(upcall_socket);
+ SOCK_UNLOCK(upcall_socket);
+ if ((upcall_socket->so_upcall != NULL) &&
+ (upcall_socket->so_error != 0)) {
+ (*upcall_socket->so_upcall)(upcall_socket, upcall_socket->so_upcallarg, M_NOWAIT);
+ }
+ ACCEPT_LOCK();
+ SOCK_LOCK(upcall_socket);
+ sorele(upcall_socket);
+ }
+#endif
} else {
#if defined(__FreeBSD__) && __FreeBSD_version < 500000
/*
@@ -8038,11 +8090,28 @@ sctp_recv_icmp6_tunneled_packet(int cmd, struct sockaddr *sa, void *d, void *ctx
}
sctp6_notify(inp, stcb, net, type, code,
ntohl(ip6cp->ip6c_icmp6->icmp6_mtu));
+#if defined(__Userspace__)
+ if (!(stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) &&
+ (stcb->sctp_socket != NULL)) {
+ struct socket *upcall_socket;
+
+ upcall_socket = stcb->sctp_socket;
+ SOCK_LOCK(upcall_socket);
+ soref(upcall_socket);
+ SOCK_UNLOCK(upcall_socket);
+ if ((upcall_socket->so_upcall != NULL) &&
+ (upcall_socket->so_error != 0)) {
+ (*upcall_socket->so_upcall)(upcall_socket, upcall_socket->so_upcallarg, M_NOWAIT);
+ }
+ ACCEPT_LOCK();
+ SOCK_LOCK(upcall_socket);
+ sorele(upcall_socket);
+ }
+#endif
} else {
#if defined(__FreeBSD__) && __FreeBSD_version < 500000
if (PRC_IS_REDIRECT(cmd) && (inp != NULL)) {
- in6_rtchange((struct in6pcb *)inp,
- inet6ctlerrmap[cmd]);
+ in6_rtchange(inp, inet6ctlerrmap[cmd]);
}
#endif
if ((stcb == NULL) && (inp != NULL)) {
@@ -8259,3 +8328,50 @@ sctp_hc_get_mtu(union sctp_sockstore *addr, uint16_t fibnum)
return ((uint32_t)tcp_hc_getmtu(&inc));
}
#endif
+
+void
+sctp_set_state(struct sctp_tcb *stcb, int new_state)
+{
+#if defined(KDTRACE_HOOKS)
+ int old_state = stcb->asoc.state;
+#endif
+
+ KASSERT((new_state & ~SCTP_STATE_MASK) == 0,
+ ("sctp_set_state: Can't set substate (new_state = %x)",
+ new_state));
+ stcb->asoc.state = (stcb->asoc.state & ~SCTP_STATE_MASK) | new_state;
+ if ((new_state == SCTP_STATE_SHUTDOWN_RECEIVED) ||
+ (new_state == SCTP_STATE_SHUTDOWN_SENT) ||
+ (new_state == SCTP_STATE_SHUTDOWN_ACK_SENT)) {
+ SCTP_CLEAR_SUBSTATE(stcb, SCTP_STATE_SHUTDOWN_PENDING);
+ }
+#if defined(KDTRACE_HOOKS)
+ if (((old_state & SCTP_STATE_MASK) != new_state) &&
+ !(((old_state & SCTP_STATE_MASK) == SCTP_STATE_EMPTY) &&
+ (new_state == SCTP_STATE_INUSE))) {
+ SCTP_PROBE6(state__change, NULL, stcb, NULL, stcb, NULL, old_state);
+ }
+#endif
+}
+
+void
+sctp_add_substate(struct sctp_tcb *stcb, int substate)
+{
+#if defined(KDTRACE_HOOKS)
+ int old_state = stcb->asoc.state;
+#endif
+
+ KASSERT((substate & SCTP_STATE_MASK) == 0,
+ ("sctp_add_substate: Can't set state (substate = %x)",
+ substate));
+ stcb->asoc.state |= substate;
+#if defined(KDTRACE_HOOKS)
+ if (((substate & SCTP_STATE_ABOUT_TO_BE_FREED) &&
+ ((old_state & SCTP_STATE_ABOUT_TO_BE_FREED) == 0)) ||
+ ((substate & SCTP_STATE_SHUTDOWN_PENDING) &&
+ ((old_state & SCTP_STATE_SHUTDOWN_PENDING) == 0))) {
+ SCTP_PROBE6(state__change, NULL, stcb, NULL, stcb, NULL, old_state);
+ }
+#endif
+}
+
diff --git a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctputil.h b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctputil.h
index 69fe484981c..2b691cff709 100755
--- a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctputil.h
+++ b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet/sctputil.h
@@ -34,7 +34,7 @@
#ifdef __FreeBSD__
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/netinet/sctputil.h 324615 2017-10-14 10:02:59Z tuexen $");
+__FBSDID("$FreeBSD: head/sys/netinet/sctputil.h 352592 2019-09-22 10:40:15Z tuexen $");
#endif
#ifndef _NETINET_SCTP_UTIL_H_
@@ -144,7 +144,7 @@ uint32_t sctp_get_next_mtu(uint32_t);
void
sctp_timeout_handler(void *);
-uint32_t
+int
sctp_calculate_rto(struct sctp_tcb *, struct sctp_association *,
struct sctp_nets *, struct timeval *, int);
@@ -223,10 +223,9 @@ void sctp_handle_ootb(struct mbuf *, int, int,
int sctp_connectx_helper_add(struct sctp_tcb *stcb, struct sockaddr *addr,
int totaddr, int *error);
-struct sctp_tcb *
-sctp_connectx_helper_find(struct sctp_inpcb *inp, struct sockaddr *addr,
- unsigned int *totaddr, unsigned int *num_v4, unsigned int *num_v6,
- int *error, unsigned int limit, int *bad_addr);
+int
+sctp_connectx_helper_find(struct sctp_inpcb *, struct sockaddr *,
+ unsigned int, unsigned int *, unsigned int *, unsigned int);
int sctp_is_there_an_abort_here(struct mbuf *, int, uint32_t *);
#ifdef INET6
@@ -403,7 +402,7 @@ void sctp_log_closing(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int16_t loc
void sctp_log_lock(struct sctp_inpcb *inp, struct sctp_tcb *stcb, uint8_t from);
void sctp_log_maxburst(struct sctp_tcb *stcb, struct sctp_nets *, int, int, uint8_t);
-void sctp_log_block(uint8_t, struct sctp_association *, size_t);
+void sctp_log_block(uint8_t, struct sctp_association *, ssize_t);
void sctp_log_rwnd(uint8_t, uint32_t, uint32_t, uint32_t);
void sctp_log_rwnd_set(uint8_t, uint32_t, uint32_t, uint32_t, uint32_t);
int sctp_fill_stat_log(void *, size_t *);
@@ -426,5 +425,7 @@ uint32_t sctp_min_mtu(uint32_t, uint32_t, uint32_t);
void sctp_hc_set_mtu(union sctp_sockstore *, uint16_t, uint32_t);
uint32_t sctp_hc_get_mtu(union sctp_sockstore *, uint16_t);
#endif
+void sctp_set_state(struct sctp_tcb *, int);
+void sctp_add_substate(struct sctp_tcb *, int);
#endif /* _KERNEL */
#endif
diff --git a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet6/meson.build b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet6/meson.build
new file mode 100644
index 00000000000..04307df59e0
--- /dev/null
+++ b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet6/meson.build
@@ -0,0 +1 @@
+sources += files('sctp6_usrreq.c')
diff --git a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet6/sctp6_usrreq.c b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet6/sctp6_usrreq.c
index 5a57fd6e7b3..23b1813e7a3 100644
--- a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet6/sctp6_usrreq.c
+++ b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet6/sctp6_usrreq.c
@@ -34,7 +34,7 @@
#ifdef __FreeBSD__
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/netinet6/sctp6_usrreq.c 332273 2018-04-08 12:08:20Z tuexen $");
+__FBSDID("$FreeBSD: head/sys/netinet6/sctp6_usrreq.c 355264 2019-12-01 16:14:44Z tuexen $");
#endif
#include <netinet/sctp_os.h>
@@ -62,13 +62,9 @@ __FBSDID("$FreeBSD: head/sys/netinet6/sctp6_usrreq.c 332273 2018-04-08 12:08:20Z
#include <netinet/icmp6.h>
#include <netinet/udp.h>
#endif
-
#if defined(__APPLE__)
#define APPLE_FILE_NO 9
#endif
-#if !defined(__Userspace__)
-extern struct protosw inetsw[];
-#endif
#if defined(__Panda__) || defined(__Userspace__)
int ip6_v6only=0;
#endif
@@ -109,7 +105,7 @@ in6_sin6_2_sin_in_sock(struct sockaddr *nam)
}
void
-in6_sin_2_v4mapsin6(struct sockaddr_in *sin, struct sockaddr_in6 *sin6)
+in6_sin_2_v4mapsin6(const struct sockaddr_in *sin, struct sockaddr_in6 *sin6)
{
memset(sin6, 0, sizeof(struct sockaddr_in6));
sin6->sin6_family = AF_INET6;
@@ -232,13 +228,15 @@ sctp6_input(struct mbuf **i_pak, int *offp, int proto)
SCTP_STAT_INCR_COUNTER64(sctps_inpackets);
/* Get IP, SCTP, and first chunk header together in the first mbuf. */
offset = iphlen + sizeof(struct sctphdr) + sizeof(struct sctp_chunkhdr);
- ip6 = mtod(m, struct ip6_hdr *);
- IP6_EXTHDR_GET(sh, struct sctphdr *, m, iphlen,
- (int)(sizeof(struct sctphdr) + sizeof(struct sctp_chunkhdr)));
- if (sh == NULL) {
- SCTP_STAT_INCR(sctps_hdrops);
- return (IPPROTO_DONE);
+ if (m->m_len < offset) {
+ m = m_pullup(m, offset);
+ if (m == NULL) {
+ SCTP_STAT_INCR(sctps_hdrops);
+ return (IPPROTO_DONE);
+ }
}
+ ip6 = mtod(m, struct ip6_hdr *);
+ sh = (struct sctphdr *)(mtod(m, caddr_t) + iphlen);
ch = (struct sctp_chunkhdr *)((caddr_t)sh + sizeof(struct sctphdr));
offset -= sizeof(struct sctp_chunkhdr);
memset(&src, 0, sizeof(struct sockaddr_in6));
@@ -407,6 +405,13 @@ sctp6_notify(struct sctp_inpcb *inp,
}
if (net->mtu > next_mtu) {
net->mtu = next_mtu;
+#if defined(__FreeBSD__)
+ if (net->port) {
+ sctp_hc_set_mtu(&net->ro._l_addr, inp->fibnum, next_mtu + sizeof(struct udphdr));
+ } else {
+ sctp_hc_set_mtu(&net->ro._l_addr, inp->fibnum, next_mtu);
+ }
+#endif
}
/* Update the association MTU */
if (stcb->asoc.smallest_mtu > next_mtu) {
@@ -571,11 +576,28 @@ sctp6_ctlinput(int cmd, struct sockaddr *pktdst, void *d)
ip6cp->ip6c_icmp6->icmp6_type,
ip6cp->ip6c_icmp6->icmp6_code,
ntohl(ip6cp->ip6c_icmp6->icmp6_mtu));
+#if defined(__Userspace__)
+ if (!(stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) &&
+ (stcb->sctp_socket != NULL) {
+ struct socket *upcall_socket;
+
+ upcall_socket = stcb->sctp_socket;
+ SOCK_LOCK(upcall_socket);
+ soref(upcall_socket);
+ SOCK_UNLOCK(upcall_socket);
+ if ((upcall_socket->so_upcall != NULL) &&
+ (upcall_socket->so_error != 0)) {
+ (*upcall_socket->so_upcall)(upcall_socket, upcall_socket->so_upcallarg, M_NOWAIT);
+ }
+ ACCEPT_LOCK();
+ SOCK_LOCK(upcall_socket);
+ sorele(upcall_socket);
+ }
+#endif
} else {
#if defined(__FreeBSD__) && __FreeBSD_version < 500000
if (PRC_IS_REDIRECT(cmd) && (inp != NULL)) {
- in6_rtchange((struct in6pcb *)inp,
- inet6ctlerrmap[cmd]);
+ in6_rtchange(inp, inet6ctlerrmap[cmd]);
}
#endif
if ((stcb == NULL) && (inp != NULL)) {
@@ -752,7 +774,6 @@ static int
sctp6_attach(struct socket *so, int proto SCTP_UNUSED, struct proc *p SCTP_UNUSED)
#endif
{
- struct in6pcb *inp6;
int error;
struct sctp_inpcb *inp;
#if !defined(__Panda__) && !defined(__Userspace__)
@@ -776,16 +797,15 @@ sctp6_attach(struct socket *so, int proto SCTP_UNUSED, struct proc *p SCTP_UNUSE
inp = (struct sctp_inpcb *)so->so_pcb;
SCTP_INP_WLOCK(inp);
inp->sctp_flags |= SCTP_PCB_FLAGS_BOUND_V6; /* I'm v6! */
- inp6 = (struct in6pcb *)inp;
#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) || defined(__Userspace__)
- inp6->inp_vflag |= INP_IPV6;
+ inp->ip_inp.inp.inp_vflag |= INP_IPV6;
#else
inp->inp_vflag |= INP_IPV6;
#endif
#if !defined(__Panda__)
- inp6->in6p_hops = -1; /* use kernel default */
- inp6->in6p_cksum = -1; /* just to be sure */
+ inp->ip_inp.inp.in6p_hops = -1; /* use kernel default */
+ inp->ip_inp.inp.in6p_cksum = -1; /* just to be sure */
#endif
#ifdef INET
/*
@@ -793,7 +813,7 @@ sctp6_attach(struct socket *so, int proto SCTP_UNUSED, struct proc *p SCTP_UNUSE
* socket as well, because the socket may be bound to an IPv6
* wildcard address, which may match an IPv4-mapped IPv6 address.
*/
- inp6->inp_ip_ttl = MODULE_GLOBAL(ip_defttl);
+ inp->ip_inp.inp.inp_ip_ttl = MODULE_GLOBAL(ip_defttl);
#endif
SCTP_INP_WUNLOCK(inp);
return (0);
@@ -823,8 +843,8 @@ sctp6_bind(struct socket *so, struct mbuf *nam, struct proc *p)
#endif
struct sctp_inpcb *inp;
- struct in6pcb *inp6;
int error;
+ u_char vflagsav;
inp = (struct sctp_inpcb *)so->so_pcb;
if (inp == NULL) {
@@ -861,22 +881,23 @@ sctp6_bind(struct socket *so, struct mbuf *nam, struct proc *p)
}
}
#endif
- inp6 = (struct in6pcb *)inp;
#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) || defined(__Userspace__)
- inp6->inp_vflag &= ~INP_IPV4;
- inp6->inp_vflag |= INP_IPV6;
+ vflagsav = inp->ip_inp.inp.inp_vflag;
+ inp->ip_inp.inp.inp_vflag &= ~INP_IPV4;
+ inp->ip_inp.inp.inp_vflag |= INP_IPV6;
#else
+ vflagsav = inp->inp_vflag;
inp->inp_vflag &= ~INP_IPV4;
inp->inp_vflag |= INP_IPV6;
#endif
- if ((addr != NULL) && (SCTP_IPV6_V6ONLY(inp6) == 0)) {
+ if ((addr != NULL) && (SCTP_IPV6_V6ONLY(inp) == 0)) {
switch (addr->sa_family) {
#ifdef INET
case AF_INET:
/* binding v4 addr to v6 socket, so reset flags */
#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) || defined(__Userspace__)
- inp6->inp_vflag |= INP_IPV4;
- inp6->inp_vflag &= ~INP_IPV6;
+ inp->ip_inp.inp.inp_vflag |= INP_IPV4;
+ inp->ip_inp.inp.inp_vflag &= ~INP_IPV6;
#else
inp->inp_vflag |= INP_IPV4;
inp->inp_vflag &= ~INP_IPV6;
@@ -892,7 +913,7 @@ sctp6_bind(struct socket *so, struct mbuf *nam, struct proc *p)
if (IN6_IS_ADDR_UNSPECIFIED(&sin6_p->sin6_addr)) {
#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) || defined(__Userspace__)
- inp6->inp_vflag |= INP_IPV4;
+ inp->ip_inp.inp.inp_vflag |= INP_IPV4;
#else
inp->inp_vflag |= INP_IPV4;
#endif
@@ -903,14 +924,14 @@ sctp6_bind(struct socket *so, struct mbuf *nam, struct proc *p)
in6_sin6_2_sin(&sin, sin6_p);
#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) || defined(__Userspace__)
- inp6->inp_vflag |= INP_IPV4;
- inp6->inp_vflag &= ~INP_IPV6;
+ inp->ip_inp.inp.inp_vflag |= INP_IPV4;
+ inp->ip_inp.inp.inp_vflag &= ~INP_IPV6;
#else
inp->inp_vflag |= INP_IPV4;
inp->inp_vflag &= ~INP_IPV6;
#endif
error = sctp_inpcb_bind(so, (struct sockaddr *)&sin, NULL, p);
- return (error);
+ goto out;
}
#endif
break;
@@ -927,7 +948,8 @@ sctp6_bind(struct socket *so, struct mbuf *nam, struct proc *p)
if (addr->sa_family == AF_INET) {
/* can't bind v4 addr to v6 only socket! */
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP6_USRREQ, EINVAL);
- return (EINVAL);
+ error = EINVAL;
+ goto out;
}
#endif
sin6_p = (struct sockaddr_in6 *)addr;
@@ -936,10 +958,18 @@ sctp6_bind(struct socket *so, struct mbuf *nam, struct proc *p)
/* can't bind v4-mapped addrs either! */
/* NOTE: we don't support SIIT */
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP6_USRREQ, EINVAL);
- return (EINVAL);
+ error = EINVAL;
+ goto out;
}
}
error = sctp_inpcb_bind(so, addr, NULL, p);
+out:
+ if (error != 0)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Windows__) || defined(__Userspace__)
+ inp->ip_inp.inp.inp_vflag = vflagsav;
+#else
+ inp->inp_vflag = vflagsav;
+#endif
return (error);
}
@@ -1014,7 +1044,6 @@ sctp6_send(struct socket *so, int flags, struct mbuf *m, struct mbuf *nam,
struct sockaddr *addr = nam ? mtod(nam, struct sockaddr *): NULL;
#endif
struct sctp_inpcb *inp;
- struct in6pcb *inp6;
#ifdef INET
struct sockaddr_in6 *sin6;
@@ -1031,7 +1060,6 @@ sctp6_send(struct socket *so, int flags, struct mbuf *m, struct mbuf *nam,
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP6_USRREQ, EINVAL);
return (EINVAL);
}
- inp6 = (struct in6pcb *)inp;
/*
* For the TCP model we may get a NULL addr, if we are a connected
* socket thats ok.
@@ -1051,7 +1079,7 @@ sctp6_send(struct socket *so, int flags, struct mbuf *m, struct mbuf *nam,
}
#ifdef INET
sin6 = (struct sockaddr_in6 *)addr;
- if (SCTP_IPV6_V6ONLY(inp6)) {
+ if (SCTP_IPV6_V6ONLY(inp)) {
/*
* if IPV6_V6ONLY flag, we discard datagrams destined to a
* v4 addr or v4-mapped addr
@@ -1150,14 +1178,10 @@ sctp6_connect(struct socket *so, struct mbuf *nam, struct proc *p)
struct sctp_inpcb *inp;
struct sctp_tcb *stcb;
#ifdef INET
- struct in6pcb *inp6;
struct sockaddr_in6 *sin6;
union sctp_sockstore store;
#endif
-#ifdef INET
- inp6 = (struct in6pcb *)so->so_pcb;
-#endif
inp = (struct sctp_inpcb *)so->so_pcb;
if (inp == NULL) {
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP6_USRREQ, ECONNRESET);
@@ -1221,7 +1245,7 @@ sctp6_connect(struct socket *so, struct mbuf *nam, struct proc *p)
}
#ifdef INET
sin6 = (struct sockaddr_in6 *)addr;
- if (SCTP_IPV6_V6ONLY(inp6)) {
+ if (SCTP_IPV6_V6ONLY(inp)) {
/*
* if IPV6_V6ONLY flag, ignore connections destined to a v4
* addr or v4-mapped addr
@@ -1275,7 +1299,8 @@ sctp6_connect(struct socket *so, struct mbuf *nam, struct proc *p)
/* We are GOOD to go */
stcb = sctp_aloc_assoc(inp, addr, &error, 0, vrf_id,
inp->sctp_ep.pre_open_stream_count,
- inp->sctp_ep.port, p);
+ inp->sctp_ep.port, p,
+ SCTP_INITIALIZE_AUTH_PARAMS);
SCTP_ASOC_CREATE_UNLOCK(inp);
if (stcb == NULL) {
/* Gak! no memory */
@@ -1286,12 +1311,8 @@ sctp6_connect(struct socket *so, struct mbuf *nam, struct proc *p)
/* Set the connected flag so we can queue data */
soisconnecting(so);
}
- stcb->asoc.state = SCTP_STATE_COOKIE_WAIT;
+ SCTP_SET_STATE(stcb, SCTP_STATE_COOKIE_WAIT);
(void)SCTP_GETTIME_TIMEVAL(&stcb->asoc.time_entered);
-
- /* initialize authentication parameters for the assoc */
- sctp_initialize_auth_params(inp, stcb);
-
sctp_send_initiate(inp, stcb, SCTP_SO_LOCKED);
SCTP_TCB_UNLOCK(stcb);
return (error);
@@ -1564,10 +1585,10 @@ sctp6_in6getaddr(struct socket *so, struct mbuf *nam)
struct sockaddr *addr = mtod(nam, struct sockaddr *);
#endif
#endif
- struct in6pcb *inp6 = sotoin6pcb(so);
+ struct inpcb *inp = sotoinpcb(so);
int error;
- if (inp6 == NULL) {
+ if (inp == NULL) {
SCTP_LTRACE_ERR_RET(NULL, NULL, NULL, SCTP_FROM_SCTP6_USRREQ, EINVAL);
return (EINVAL);
}
@@ -1636,10 +1657,10 @@ sctp6_getpeeraddr(struct socket *so, struct mbuf *nam)
#endif
#endif
- struct in6pcb *inp6 = sotoin6pcb(so);
+ struct inpcb *inp = sotoinpcb(so);
int error;
- if (inp6 == NULL) {
+ if (inp == NULL) {
SCTP_LTRACE_ERR_RET(NULL, NULL, NULL, SCTP_FROM_SCTP6_USRREQ, EINVAL);
return (EINVAL);
}
diff --git a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet6/sctp6_var.h b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet6/sctp6_var.h
index 3c4285d29cb..e10453dae73 100755
--- a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet6/sctp6_var.h
+++ b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/netinet6/sctp6_var.h
@@ -44,7 +44,7 @@ __FBSDID("$FreeBSD: head/sys/netinet6/sctp6_var.h 317457 2017-04-26 19:26:40Z tu
#ifdef INET
extern void in6_sin6_2_sin(struct sockaddr_in *, struct sockaddr_in6 *);
extern void in6_sin6_2_sin_in_sock(struct sockaddr *);
-extern void in6_sin_2_v4mapsin6(struct sockaddr_in *, struct sockaddr_in6 *);
+extern void in6_sin_2_v4mapsin6(const struct sockaddr_in *, struct sockaddr_in6 *);
#endif
#endif
#if defined(_KERNEL)
diff --git a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/user_environment.c b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/user_environment.c
index 767c4ba4d43..cb77a220e69 100755
--- a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/user_environment.c
+++ b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/user_environment.c
@@ -64,6 +64,14 @@ userland_mutex_t atomic_mtx;
* provide _some_ kind of randomness. This should only be used
* inside other RNG's, like arc4random(9).
*/
+#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
+static int
+read_random_phony(void *buf, int count)
+{
+ memset(buf, 'A', count);
+ return (count);
+}
+#else
#if defined(__Userspace_os_FreeBSD) || defined(__Userspace_os_Darwin)
static int
read_random_phony(void *buf, int count)
@@ -92,6 +100,7 @@ read_random_phony(void *buf, int count)
return (count);
}
#endif
+#endif
static int (*read_func)(void *, int) = read_random_phony;
diff --git a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/user_environment.h b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/user_environment.h
index c11ad2c41ff..2b40ceebd07 100755
--- a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/user_environment.h
+++ b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/user_environment.h
@@ -62,7 +62,7 @@ extern int ipport_firstauto, ipport_lastauto;
*/
extern int nmbclusters;
-#if !defined (__Userspace_os_Windows)
+#if !defined(_MSC_VER) && !defined(__MINGW32__)
#define min(a,b) ((a)>(b)?(b):(a))
#define max(a,b) ((a)>(b)?(a):(b))
#endif
@@ -96,7 +96,7 @@ terminate_non_graceful(void) {
#define panic(...) \
do { \
- SCTP_PRINTF("%s(): ", __FUNCTION__);\
+ SCTP_PRINTF("%s(): ", __func__); \
SCTP_PRINTF(__VA_ARGS__); \
SCTP_PRINTF("\n"); \
terminate_non_graceful(); \
diff --git a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/user_inpcb.h b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/user_inpcb.h
index 81b5d212d70..2ac818c7021 100755
--- a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/user_inpcb.h
+++ b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/user_inpcb.h
@@ -35,8 +35,6 @@
#include <user_route.h> /* was <net/route.h> */
-#define in6pcb inpcb /* for KAME src sync over BSD*'s */
-#define in6p_sp inp_sp /* for KAME src sync over BSD*'s */
struct inpcbpolicy;
/*
@@ -326,7 +324,6 @@ struct inpcbinfo {
#define INPLOOKUP_WILDCARD 1
#define sotoinpcb(so) ((struct inpcb *)(so)->so_pcb)
-#define sotoin6pcb(so) sotoinpcb(so) /* for KAME src sync over BSD*'s */
#define INP_SOCKAF(so) so->so_proto->pr_domain->dom_family
diff --git a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/user_malloc.h b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/user_malloc.h
index 73904ca5b47..8d4fe82607b 100755
--- a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/user_malloc.h
+++ b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/user_malloc.h
@@ -41,7 +41,7 @@
#include <strings.h>
#include <stdint.h>
#else
-#if defined(_MSC_VER) && _MSC_VER >= 1600
+#if (defined(_MSC_VER) && _MSC_VER >= 1600) || (defined(__MSVCRT_VERSION__) && __MSVCRT_VERSION__ >= 1400)
#include <stdint.h>
#elif defined(SCTP_STDINT_INCLUDE)
#include SCTP_STDINT_INCLUDE
diff --git a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/user_mbuf.c b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/user_mbuf.c
index a63a889b751..a5037249d68 100755
--- a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/user_mbuf.c
+++ b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/user_mbuf.c
@@ -313,7 +313,7 @@ m_getm2(struct mbuf *m, int len, int how, short type, int flags, int allonebuf)
mb = m_gethdr(how, type);
MCLGET(mb, how);
size = MCLBYTES;
- //SCTP_BUF_LEN(mb) = MCLBYTES;
+ /* SCTP_BUF_LEN(mb) = MCLBYTES; */
} else if (flags & M_PKTHDR) {
mb = m_gethdr(how, type);
if (len < MHLEN) {
@@ -338,7 +338,7 @@ m_getm2(struct mbuf *m, int len, int how, short type, int flags, int allonebuf)
}
if (allonebuf != 0 && size < space_needed) {
- m_freem(m);
+ m_freem(mb);
return (NULL);
}
diff --git a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/user_recv_thread.c b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/user_recv_thread.c
index ea0c10efdf9..ae5e517daf8 100755
--- a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/user_recv_thread.c
+++ b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/user_recv_thread.c
@@ -164,7 +164,7 @@ recv_function_route(void *arg)
}
}
if (ret < 0) {
- if (errno == EAGAIN) {
+ if (errno == EAGAIN || errno == EINTR) {
continue;
} else {
break;
@@ -211,7 +211,7 @@ recv_function_route(void *arg)
len = recvmsg(SCTP_BASE_VAR(userspace_route), &msg, 0);
if (len < 0) {
- if (errno == EAGAIN) {
+ if (errno == EAGAIN || errno == EINTR) {
continue;
} else {
break;
@@ -323,12 +323,10 @@ recv_function_raw(void *arg)
nResult = WSARecvFrom(SCTP_BASE_VAR(userspace_rawsctp), recv_iovec, MAXLEN_MBUF_CHAIN, &ncounter, &flags, (struct sockaddr *)&from, &fromlen, NULL, NULL);
if (nResult != 0) {
m_ErrorCode = WSAGetLastError();
- if (m_ErrorCode == WSAETIMEDOUT) {
- continue;
- }
if ((m_ErrorCode == WSAENOTSOCK) || (m_ErrorCode == WSAEINTR)) {
break;
}
+ continue;
}
n = ncounter;
#else
@@ -341,7 +339,7 @@ recv_function_raw(void *arg)
msg.msg_controllen = 0;
ncounter = n = recvmsg(SCTP_BASE_VAR(userspace_rawsctp), &msg, 0);
if (n < 0) {
- if (errno == EAGAIN) {
+ if (errno == EAGAIN || errno == EINTR) {
continue;
} else {
break;
@@ -432,6 +430,7 @@ recv_function_raw(void *arg)
}
/* free the array itself */
free(recvmbuf);
+ SCTPDBG(SCTP_DEBUG_USR, "%s: Exiting SCTP/IP4 rcv", __func__);
return (NULL);
}
#endif
@@ -450,10 +449,8 @@ recv_function_raw6(void *arg)
#else
WSABUF recv_iovec[MAXLEN_MBUF_CHAIN];
int nResult, m_ErrorCode;
- DWORD flags;
DWORD ncounter = 0;
struct sockaddr_in6 from;
- int fromlen;
GUID WSARecvMsg_GUID = WSAID_WSARECVMSG;
LPFN_WSARECVMSG WSARecvMsg;
WSACMSGHDR *cmsgptr;
@@ -495,9 +492,7 @@ recv_function_raw6(void *arg)
}
to_fill = 0;
#if defined(__Userspace_os_Windows)
- flags = 0;
ncounter = 0;
- fromlen = sizeof(struct sockaddr_in6);
memset(&from, 0, sizeof(struct sockaddr_in6));
nResult = WSAIoctl(SCTP_BASE_VAR(userspace_rawsctp6), SIO_GET_EXTENSION_FUNCTION_POINTER,
&WSARecvMsg_GUID, sizeof WSARecvMsg_GUID,
@@ -515,10 +510,10 @@ recv_function_raw6(void *arg)
}
if (nResult != 0) {
m_ErrorCode = WSAGetLastError();
- if (m_ErrorCode == WSAETIMEDOUT)
- continue;
- if (m_ErrorCode == WSAENOTSOCK || m_ErrorCode == WSAEINTR)
+ if ((m_ErrorCode == WSAENOTSOCK) || (m_ErrorCode == WSAEINTR)) {
break;
+ }
+ continue;
}
n = ncounter;
#else
@@ -531,12 +526,12 @@ recv_function_raw6(void *arg)
msg.msg_iov = recv_iovec;
msg.msg_iovlen = MAXLEN_MBUF_CHAIN;
msg.msg_control = (void *)cmsgbuf;
- msg.msg_controllen = (socklen_t)CMSG_LEN(sizeof (struct in6_pktinfo));
+ msg.msg_controllen = (socklen_t)CMSG_SPACE(sizeof (struct in6_pktinfo));
msg.msg_flags = 0;
ncounter = n = recvmsg(SCTP_BASE_VAR(userspace_rawsctp6), &msg, 0);
if (n < 0) {
- if (errno == EAGAIN) {
+ if (errno == EAGAIN || errno == EINTR) {
continue;
} else {
break;
@@ -620,6 +615,7 @@ recv_function_raw6(void *arg)
}
/* free the array itself */
free(recvmbuf6);
+ SCTPDBG(SCTP_DEBUG_USR, "%s: Exiting SCTP/IP6 rcv", __func__);
return (NULL);
}
#endif
@@ -703,7 +699,7 @@ recv_function_udp(void *arg)
ncounter = n = recvmsg(SCTP_BASE_VAR(userspace_udpsctp), &msg, 0);
if (n < 0) {
- if (errno == EAGAIN) {
+ if (errno == EAGAIN || errno == EINTR) {
continue;
} else {
break;
@@ -726,12 +722,10 @@ recv_function_udp(void *arg)
}
if (nResult != 0) {
m_ErrorCode = WSAGetLastError();
- if (m_ErrorCode == WSAETIMEDOUT) {
- continue;
- }
if ((m_ErrorCode == WSAENOTSOCK) || (m_ErrorCode == WSAEINTR)) {
break;
}
+ continue;
}
n = ncounter;
#endif
@@ -826,6 +820,7 @@ recv_function_udp(void *arg)
}
/* free the array itself */
free(udprecvmbuf);
+ SCTPDBG(SCTP_DEBUG_USR, "%s: Exiting SCTP/UDP/IP4 rcv", __func__);
return (NULL);
}
#endif
@@ -850,10 +845,10 @@ recv_function_udp6(void *arg)
char cmsgbuf[CMSG_SPACE(sizeof (struct in6_pktinfo))];
int compute_crc = 1;
#if !defined(__Userspace_os_Windows)
- unsigned int ncounter;
struct iovec iov[MAXLEN_MBUF_CHAIN];
struct msghdr msg;
struct cmsghdr *cmsgptr;
+ unsigned int ncounter;
#else
GUID WSARecvMsg_GUID = WSAID_WSARECVMSG;
LPFN_WSARECVMSG WSARecvMsg;
@@ -861,8 +856,8 @@ recv_function_udp6(void *arg)
WSABUF iov[MAXLEN_MBUF_CHAIN];
WSAMSG msg;
int nResult, m_ErrorCode;
- DWORD ncounter;
WSACMSGHDR *cmsgptr;
+ DWORD ncounter;
#endif
sctp_userspace_set_threadname("SCTP/UDP/IP6 rcv");
@@ -900,12 +895,12 @@ recv_function_udp6(void *arg)
msg.msg_iov = iov;
msg.msg_iovlen = MAXLEN_MBUF_CHAIN;
msg.msg_control = (void *)cmsgbuf;
- msg.msg_controllen = (socklen_t)CMSG_LEN(sizeof (struct in6_pktinfo));
+ msg.msg_controllen = (socklen_t)CMSG_SPACE(sizeof (struct in6_pktinfo));
msg.msg_flags = 0;
ncounter = n = recvmsg(SCTP_BASE_VAR(userspace_udpsctp6), &msg, 0);
if (n < 0) {
- if (errno == EAGAIN) {
+ if (errno == EAGAIN || errno == EINTR) {
continue;
} else {
break;
@@ -932,12 +927,10 @@ recv_function_udp6(void *arg)
}
if (nResult != 0) {
m_ErrorCode = WSAGetLastError();
- if (m_ErrorCode == WSAETIMEDOUT) {
- continue;
- }
if ((m_ErrorCode == WSAENOTSOCK) || (m_ErrorCode == WSAEINTR)) {
break;
}
+ continue;
}
n = ncounter;
#endif
@@ -1014,6 +1007,7 @@ recv_function_udp6(void *arg)
}
/* free the array itself */
free(udprecvmbuf6);
+ SCTPDBG(SCTP_DEBUG_USR, "%s: Exiting SCTP/UDP/IP6 rcv", __func__);
return (NULL);
}
#endif
diff --git a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/user_socket.c b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/user_socket.c
index 9fe6976a0c7..146a6d9f959 100755
--- a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/user_socket.c
+++ b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/user_socket.c
@@ -39,6 +39,7 @@
#include <netinet/sctp_sysctl.h>
#include <netinet/sctp_input.h>
#include <netinet/sctp_peeloff.h>
+#include <netinet/sctp_callout.h>
#include <netinet/sctp_crc32.h>
#ifdef INET6
#include <netinet6/sctp6_var.h>
@@ -77,11 +78,7 @@ extern int sctp_sosend(struct socket *so, struct sockaddr *addr, struct uio *uio
extern int sctp_attach(struct socket *so, int proto, uint32_t vrf_id);
extern int sctpconn_attach(struct socket *so, int proto, uint32_t vrf_id);
-void
-usrsctp_init(uint16_t port,
- int (*conn_output)(void *addr, void *buffer, size_t length, uint8_t tos, uint8_t set_df),
- void (*debug_printf)(const char *format, ...))
-{
+static void init_sync(void) {
#if defined(__Userspace_os_Windows)
#if defined(INET) || defined(INET6)
WSADATA wsaData;
@@ -104,7 +101,25 @@ usrsctp_init(uint16_t port,
pthread_mutexattr_destroy(&mutex_attr);
pthread_cond_init(&accept_cond, NULL);
#endif
- sctp_init(port, conn_output, debug_printf);
+}
+
+void
+usrsctp_init(uint16_t port,
+ int (*conn_output)(void *addr, void *buffer, size_t length, uint8_t tos, uint8_t set_df),
+ void (*debug_printf)(const char *format, ...))
+{
+ init_sync();
+ sctp_init(port, conn_output, debug_printf, 1);
+}
+
+
+void
+usrsctp_init_nothreads(uint16_t port,
+ int (*conn_output)(void *addr, void *buffer, size_t length, uint8_t tos, uint8_t set_df),
+ void (*debug_printf)(const char *format, ...))
+{
+ init_sync();
+ sctp_init(port, conn_output, debug_printf, 0);
}
@@ -346,21 +361,21 @@ void
soisdisconnecting(struct socket *so)
{
- /*
- * Note: This code assumes that SOCK_LOCK(so) and
- * SOCKBUF_LOCK(&so->so_rcv) are the same.
- */
- SOCKBUF_LOCK(&so->so_rcv);
- so->so_state &= ~SS_ISCONNECTING;
- so->so_state |= SS_ISDISCONNECTING;
- so->so_rcv.sb_state |= SBS_CANTRCVMORE;
- sorwakeup_locked(so);
- SOCKBUF_LOCK(&so->so_snd);
- so->so_snd.sb_state |= SBS_CANTSENDMORE;
- sowwakeup_locked(so);
- wakeup("dummy",so);
- /* requires 2 args but this was in orig */
- /* wakeup(&so->so_timeo); */
+ /*
+ * Note: This code assumes that SOCK_LOCK(so) and
+ * SOCKBUF_LOCK(&so->so_rcv) are the same.
+ */
+ SOCKBUF_LOCK(&so->so_rcv);
+ so->so_state &= ~SS_ISCONNECTING;
+ so->so_state |= SS_ISDISCONNECTING;
+ so->so_rcv.sb_state |= SBS_CANTRCVMORE;
+ sorwakeup_locked(so);
+ SOCKBUF_LOCK(&so->so_snd);
+ so->so_snd.sb_state |= SBS_CANTSENDMORE;
+ sowwakeup_locked(so);
+ wakeup("dummy",so);
+ /* requires 2 args but this was in orig */
+ /* wakeup(&so->so_timeo); */
}
@@ -565,13 +580,13 @@ struct sctp_generic_sendmsg_args {
};
struct sctp_generic_recvmsg_args {
- int sd;
- struct iovec *iov;
- int iovlen;
- struct sockaddr *from;
- socklen_t *fromlenaddr; /* was __socklen_t */
- struct sctp_sndrcvinfo *sinfo;
- int *msg_flags;
+ int sd;
+ struct iovec *iov;
+ int iovlen;
+ struct sockaddr *from;
+ socklen_t *fromlenaddr; /* was __socklen_t */
+ struct sctp_sndrcvinfo *sinfo;
+ int *msg_flags;
};
@@ -950,52 +965,51 @@ userspace_sctp_sendmbuf(struct socket *so,
u_int32_t context)
{
- struct sctp_sndrcvinfo sndrcvinfo, *sinfo = &sndrcvinfo;
- /* struct uio auio;
- struct iovec iov[1]; */
- int error = 0;
- int uflags = 0;
- ssize_t retval;
-
- sinfo->sinfo_ppid = ppid;
- sinfo->sinfo_flags = flags;
- sinfo->sinfo_stream = stream_no;
- sinfo->sinfo_timetolive = timetolive;
- sinfo->sinfo_context = context;
- sinfo->sinfo_assoc_id = 0;
-
- /* Perform error checks on destination (to) */
- if (tolen > SOCK_MAXADDRLEN){
- error = (ENAMETOOLONG);
- goto sendmsg_return;
- }
- if (tolen < (socklen_t)offsetof(struct sockaddr, sa_data)){
- error = (EINVAL);
- goto sendmsg_return;
- }
- /* Adding the following as part of defensive programming, in case the application
- does not do it when preparing the destination address.*/
+ struct sctp_sndrcvinfo sndrcvinfo, *sinfo = &sndrcvinfo;
+ /* struct uio auio;
+ struct iovec iov[1]; */
+ int error = 0;
+ int uflags = 0;
+ ssize_t retval;
+
+ sinfo->sinfo_ppid = ppid;
+ sinfo->sinfo_flags = flags;
+ sinfo->sinfo_stream = stream_no;
+ sinfo->sinfo_timetolive = timetolive;
+ sinfo->sinfo_context = context;
+ sinfo->sinfo_assoc_id = 0;
+
+ /* Perform error checks on destination (to) */
+ if (tolen > SOCK_MAXADDRLEN){
+ error = (ENAMETOOLONG);
+ goto sendmsg_return;
+ }
+ if (tolen < (socklen_t)offsetof(struct sockaddr, sa_data)){
+ error = (EINVAL);
+ goto sendmsg_return;
+ }
+ /* Adding the following as part of defensive programming, in case the application
+ does not do it when preparing the destination address.*/
#ifdef HAVE_SA_LEN
- to->sa_len = tolen;
+ to->sa_len = tolen;
#endif
- error = sctp_lower_sosend(so, to, NULL/*uio*/,
- (struct mbuf *)mbufdata, (struct mbuf *)NULL,
- uflags, sinfo);
+ error = sctp_lower_sosend(so, to, NULL/*uio*/,
+ (struct mbuf *)mbufdata, (struct mbuf *)NULL,
+ uflags, sinfo);
sendmsg_return:
- /* TODO: Needs a condition for non-blocking when error is EWOULDBLOCK */
- if (0 == error)
- retval = len;
- else if (error == EWOULDBLOCK) {
- errno = EWOULDBLOCK;
- retval = -1;
- } else {
- SCTP_PRINTF("%s: error = %d\n", __func__, error);
- errno = error;
- retval = -1;
- }
- return (retval);
-
+ /* TODO: Needs a condition for non-blocking when error is EWOULDBLOCK */
+ if (0 == error)
+ retval = len;
+ else if (error == EWOULDBLOCK) {
+ errno = EWOULDBLOCK;
+ retval = -1;
+ } else {
+ SCTP_PRINTF("%s: error = %d\n", __func__, error);
+ errno = error;
+ retval = -1;
+ }
+ return (retval);
}
@@ -1154,6 +1168,9 @@ usrsctp_recvv(struct socket *so,
errno = 0;
}
}
+ if (errno != 0) {
+ goto out;
+ }
if ((*msg_flags & MSG_NOTIFICATION) == 0) {
struct sctp_inpcb *inp;
@@ -1205,7 +1222,10 @@ usrsctp_recvv(struct socket *so,
*infolen = 0;
}
}
- if ((fromlenp != NULL) && (fromlen > 0) && (from != NULL)) {
+ if ((fromlenp != NULL) &&
+ (fromlen > 0) &&
+ (from != NULL) &&
+ (ulen > auio.uio_resid)) {
switch (from->sa_family) {
#if defined(INET)
case AF_INET:
@@ -1228,6 +1248,7 @@ usrsctp_recvv(struct socket *so,
*fromlenp = fromlen;
}
}
+out:
if (errno == 0) {
/* ready return value */
return (ulen - auio.uio_resid);
@@ -1557,8 +1578,6 @@ sowakeup(struct socket *so, struct sockbuf *sb)
#endif
}
SOCKBUF_UNLOCK(sb);
- /*__Userspace__ what todo about so_upcall?*/
-
}
#else /* kernel version for reference */
/*
@@ -2129,7 +2148,7 @@ done1:
int usrsctp_connect(struct socket *so, struct sockaddr *name, int namelen)
{
- struct sockaddr *sa;
+ struct sockaddr *sa = NULL;
errno = getsockaddr(&sa, (caddr_t)name, namelen);
if (errno)
@@ -2399,6 +2418,20 @@ usrsctp_getsockopt(struct socket *so, int level, int option_name,
*option_len = (socklen_t)sizeof(struct linger);
return (0);
}
+ break;
+ case SO_ERROR:
+ if (*option_len < (socklen_t)sizeof(int)) {
+ errno = EINVAL;
+ return (-1);
+ } else {
+ int *intval;
+
+ intval = (int *)option_value;
+ *intval = so->so_error;
+ *option_len = (socklen_t)sizeof(int);
+ return (0);
+ }
+ break;
default:
errno = EINVAL;
return (-1);
@@ -3131,14 +3164,14 @@ sctp_userspace_ip_output(int *result, struct mbuf *o_pak,
if ((!use_udp_tunneling) && (SCTP_BASE_VAR(userspace_rawsctp) != -1)) {
if (WSASendTo(SCTP_BASE_VAR(userspace_rawsctp), (LPWSABUF) send_iovec, iovcnt, &win_sent_len, win_msg_hdr.dwFlags, win_msg_hdr.name, (int) win_msg_hdr.namelen, NULL, NULL) != 0) {
*result = WSAGetLastError();
- } else if (win_sent_len != send_len) {
+ } else if ((int)win_sent_len != send_len) {
*result = WSAGetLastError();
}
}
if ((use_udp_tunneling) && (SCTP_BASE_VAR(userspace_udpsctp) != -1)) {
if (WSASendTo(SCTP_BASE_VAR(userspace_udpsctp), (LPWSABUF) send_iovec, iovcnt, &win_sent_len, win_msg_hdr.dwFlags, win_msg_hdr.name, (int) win_msg_hdr.namelen, NULL, NULL) != 0) {
*result = WSAGetLastError();
- } else if (win_sent_len != send_len) {
+ } else if ((int)win_sent_len != send_len) {
*result = WSAGetLastError();
}
}
@@ -3285,14 +3318,14 @@ void sctp_userspace_ip6_output(int *result, struct mbuf *o_pak,
if ((!use_udp_tunneling) && (SCTP_BASE_VAR(userspace_rawsctp6) != -1)) {
if (WSASendTo(SCTP_BASE_VAR(userspace_rawsctp6), (LPWSABUF) send_iovec, iovcnt, &win_sent_len, win_msg_hdr.dwFlags, win_msg_hdr.name, (int) win_msg_hdr.namelen, NULL, NULL) != 0) {
*result = WSAGetLastError();
- } else if (win_sent_len != send_len) {
+ } else if ((int)win_sent_len != send_len) {
*result = WSAGetLastError();
}
}
if ((use_udp_tunneling) && (SCTP_BASE_VAR(userspace_udpsctp6) != -1)) {
if (WSASendTo(SCTP_BASE_VAR(userspace_udpsctp6), (LPWSABUF) send_iovec, iovcnt, &win_sent_len, win_msg_hdr.dwFlags, win_msg_hdr.name, (int) win_msg_hdr.namelen, NULL, NULL) != 0) {
*result = WSAGetLastError();
- } else if (win_sent_len != send_len) {
+ } else if ((int)win_sent_len != send_len) {
*result = WSAGetLastError();
}
}
@@ -3371,9 +3404,15 @@ usrsctp_dumppacket(const void *buf, size_t len, int outbound)
#ifdef _WIN32
ftime(&tb);
localtime_s(&t, &tb.time);
+#if defined(__MINGW32__)
+ snprintf(dump_buf, PREAMBLE_LENGTH + 1, PREAMBLE_FORMAT,
+ outbound ? 'O' : 'I',
+ t.tm_hour, t.tm_min, t.tm_sec, (long)(1000 * tb.millitm));
+#else
_snprintf_s(dump_buf, PREAMBLE_LENGTH + 1, PREAMBLE_LENGTH, PREAMBLE_FORMAT,
outbound ? 'O' : 'I',
t.tm_hour, t.tm_min, t.tm_sec, (long)(1000 * tb.millitm));
+#endif
#else
gettimeofday(&tv, NULL);
sec = (time_t)tv.tv_sec;
@@ -3383,7 +3422,7 @@ usrsctp_dumppacket(const void *buf, size_t len, int outbound)
t.tm_hour, t.tm_min, t.tm_sec, (long)tv.tv_usec);
#endif
pos += PREAMBLE_LENGTH;
-#ifdef _WIN32
+#if defined(_WIN32) && !defined(__MINGW32__)
strncpy_s(dump_buf + pos, strlen(HEADER) + 1, HEADER, strlen(HEADER));
#else
strcpy(dump_buf + pos, HEADER);
@@ -3400,7 +3439,7 @@ usrsctp_dumppacket(const void *buf, size_t len, int outbound)
dump_buf[pos++] = low < 10 ? '0' + low : 'a' + (low - 10);
dump_buf[pos++] = ' ';
}
-#ifdef _WIN32
+#if defined(_WIN32) && !defined(__MINGW32__)
strncpy_s(dump_buf + pos, strlen(TRAILER) + 1, TRAILER, strlen(TRAILER));
#else
strcpy(dump_buf + pos, TRAILER);
@@ -3488,6 +3527,54 @@ usrsctp_conninput(void *addr, const void *buffer, size_t length, uint8_t ecn_bit
return;
}
+void usrsctp_handle_timers(uint32_t delta)
+{
+ sctp_handle_tick(delta);
+}
+
+int
+usrsctp_get_events(struct socket *so)
+{
+ int events = 0;
+
+ if (so == NULL) {
+ errno = EBADF;
+ return -1;
+ }
+
+ SOCK_LOCK(so);
+ if (soreadable(so)) {
+ events |= SCTP_EVENT_READ;
+ }
+ if (sowriteable(so)) {
+ events |= SCTP_EVENT_WRITE;
+ }
+ if (so->so_error) {
+ events |= SCTP_EVENT_ERROR;
+ }
+ SOCK_UNLOCK(so);
+
+ return events;
+}
+
+int
+usrsctp_set_upcall(struct socket *so, void (*upcall)(struct socket *, void *, int), void *arg)
+{
+ if (so == NULL) {
+ errno = EBADF;
+ return (-1);
+ }
+
+ SOCK_LOCK(so);
+ so->so_upcall = upcall;
+ so->so_upcallarg = arg;
+ so->so_snd.sb_flags |= SB_UPCALL;
+ so->so_rcv.sb_flags |= SB_UPCALL;
+ SOCK_UNLOCK(so);
+
+ return (0);
+}
+
#define USRSCTP_TUNABLE_SET_DEF(__field, __prefix) \
int usrsctp_tunable_set_ ## __field(uint32_t value) \
{ \
@@ -3518,7 +3605,7 @@ int usrsctp_sysctl_set_ ## __field(uint32_t value) \
} \
}
-#if !defined(__Userspace_os_Windows)
+#if __GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wtype-limits"
#endif
@@ -3591,8 +3678,8 @@ USRSCTP_SYSCTL_SET_DEF(sctp_initial_cwnd, SCTPCTL_INITIAL_CWND)
#ifdef SCTP_DEBUG
USRSCTP_SYSCTL_SET_DEF(sctp_debug_on, SCTPCTL_DEBUG)
#endif
-#if !defined(__Userspace_os_Windows)
-#pragma GCC diagnostic push
+#if __GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || defined(__clang__)
+#pragma GCC diagnostic pop
#endif
#define USRSCTP_SYSCTL_GET_DEF(__field) \
diff --git a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/user_socketvar.h b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/user_socketvar.h
index ffc8270efda..cd235fafef6 100755
--- a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/user_socketvar.h
+++ b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/user_socketvar.h
@@ -72,7 +72,7 @@ enum uio_seg {
#endif
struct proc {
- int stub; /* struct proc is a dummy for __Userspace__ */
+ int stub; /* struct proc is a dummy for __Userspace__ */
};
MALLOC_DECLARE(M_ACCF);
@@ -83,12 +83,12 @@ MALLOC_DECLARE(M_SONAME);
* Removing struct thread *uio_td; owner field
*/
struct uio {
- struct iovec *uio_iov; /* scatter/gather list */
- int uio_iovcnt; /* length of scatter/gather list */
- off_t uio_offset; /* offset in target object */
- ssize_t uio_resid; /* remaining bytes to process */
- enum uio_seg uio_segflg; /* address space */
- enum uio_rw uio_rw; /* operation */
+ struct iovec *uio_iov; /* scatter/gather list */
+ int uio_iovcnt; /* length of scatter/gather list */
+ off_t uio_offset; /* offset in target object */
+ ssize_t uio_resid; /* remaining bytes to process */
+ enum uio_seg uio_segflg; /* address space */
+ enum uio_rw uio_rw; /* operation */
};
@@ -102,7 +102,9 @@ struct uio {
*/
#if defined (__Userspace_os_Windows)
#define AF_ROUTE 17
+#if !defined(__MINGW32__)
typedef __int32 pid_t;
+#endif
typedef unsigned __int32 uid_t;
enum sigType {
SIGNAL = 0,
@@ -365,6 +367,13 @@ extern userland_cond_t accept_cond;
#define SQ_COMP 0x1000 /* unaccepted, complete connection */
/*
+ * Socket event flags
+ */
+#define SCTP_EVENT_READ 0x0001 /* socket is readable */
+#define SCTP_EVENT_WRITE 0x0002 /* socket is writeable */
+#define SCTP_EVENT_ERROR 0x0004 /* socket has an error state */
+
+/*
* Externalized form of struct socket used by the sysctl(3) interface.
*/
struct xsocket {
@@ -719,6 +728,7 @@ void soisconnected(struct socket *so);
struct socket * sonewconn(struct socket *head, int connstatus);
void socantrcvmore(struct socket *so);
void socantsendmore(struct socket *so);
+void sofree(struct socket *so);
diff --git a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/user_uma.h b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/user_uma.h
index 1bdefdb8096..e20d2ada67f 100755
--- a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/user_uma.h
+++ b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/user_uma.h
@@ -46,11 +46,11 @@ typedef struct uma_zone * uma_zone_t;
typedef struct uma_keg * uma_keg_t;
struct uma_cache {
- int stub; /* TODO __Userspace__ */
+ int stub; /* TODO __Userspace__ */
};
struct uma_keg {
- int stub; /* TODO __Userspace__ */
+ int stub; /* TODO __Userspace__ */
};
struct uma_zone {
@@ -90,9 +90,7 @@ uma_zcreate(char *name, size_t size, uma_ctor ctor, uma_dtor dtor,
uma_zone_t
uma_zcreate(char *name, size_t size, uma_ctor ctor, uma_dtor dtor,
- uma_init uminit, uma_fini fini, int align, u_int32_t flags)
-{
- return NULL; /* stub TODO __Userspace__. Also place implementation in a separate .c file */
-
+ uma_init uminit, uma_fini fini, int align, u_int32_t flags) {
+ return NULL; /* stub TODO __Userspace__. Also place implementation in a separate .c file */
}
#endif
diff --git a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/usrsctp.h b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/usrsctp.h
index e933c145efb..37d4828f08b 100644
--- a/chromium/third_party/usrsctp/usrsctplib/usrsctplib/usrsctp.h
+++ b/chromium/third_party/usrsctp/usrsctplib/usrsctplib/usrsctp.h
@@ -72,7 +72,16 @@ extern "C" {
#define int32_t __int32
#endif
-#define ssize_t __int64
+#ifndef ssize_t
+#ifdef _WIN64
+#define ssize_t __int64
+#elif defined _WIN32
+#define ssize_t int
+#else
+#error "Unknown platform!"
+#endif
+#endif
+
#define MSG_EOR 0x8
#ifndef EWOULDBLOCK
#define EWOULDBLOCK WSAEWOULDBLOCK
@@ -127,12 +136,8 @@ struct sockaddr_conn {
#endif
union sctp_sockstore {
-#if defined(INET)
struct sockaddr_in sin;
-#endif
-#if defined(INET6)
struct sockaddr_in6 sin6;
-#endif
struct sockaddr_conn sconn;
struct sockaddr sa;
};
@@ -141,6 +146,10 @@ union sctp_sockstore {
#define SCTP_CURRENT_ASSOC 1
#define SCTP_ALL_ASSOC 2
+#define SCTP_EVENT_READ 0x0001
+#define SCTP_EVENT_WRITE 0x0002
+#define SCTP_EVENT_ERROR 0x0004
+
/*** Structures and definitions to use the socket API ***/
#define SCTP_ALIGN_RESV_PAD 92
@@ -306,7 +315,7 @@ struct sctp_remote_error {
uint32_t sre_length;
uint16_t sre_error;
sctp_assoc_t sre_assoc_id;
- uint8_t sre_data[4];
+ uint8_t sre_data[];
};
/* shutdown event */
@@ -471,6 +480,8 @@ struct sctp_event_subscribe {
/* Flags that go into the sinfo->sinfo_flags field */
+#define SCTP_DATA_LAST_FRAG 0x0001 /* tail part of the message could not be sent */
+#define SCTP_DATA_NOT_FRAG 0x0003 /* complete message could not be sent */
#define SCTP_NOTIFICATION 0x0010 /* next message is a notification */
#define SCTP_COMPLETE 0x0020 /* next message is complete */
#define SCTP_EOF 0x0100 /* Start shutdown procedures */
@@ -540,6 +551,14 @@ struct sctp_event_subscribe {
#define SCTP_DEFAULT_SNDINFO 0x00000021
#define SCTP_DEFAULT_PRINFO 0x00000022
#define SCTP_REMOTE_UDP_ENCAPS_PORT 0x00000024
+#define SCTP_ECN_SUPPORTED 0x00000025
+#define SCTP_PR_SUPPORTED 0x00000026
+#define SCTP_AUTH_SUPPORTED 0x00000027
+#define SCTP_ASCONF_SUPPORTED 0x00000028
+#define SCTP_RECONFIG_SUPPORTED 0x00000029
+#define SCTP_NRSACK_SUPPORTED 0x00000030
+#define SCTP_PKTDROP_SUPPORTED 0x00000031
+#define SCTP_MAX_CWND 0x00000032
#define SCTP_ENABLE_STREAM_RESET 0x00000900 /* struct sctp_assoc_value */
@@ -875,6 +894,11 @@ usrsctp_init(uint16_t,
int (*)(void *addr, void *buffer, size_t length, uint8_t tos, uint8_t set_df),
void (*)(const char *format, ...));
+void
+usrsctp_init_nothreads(uint16_t,
+ int (*)(void *addr, void *buffer, size_t length, uint8_t tos, uint8_t set_df),
+ void (*)(const char *format, ...));
+
struct socket *
usrsctp_socket(int domain, int type, int protocol,
int (*receive_cb)(struct socket *sock, union sctp_sockstore addr, void *data,
@@ -1008,6 +1032,18 @@ usrsctp_deregister_address(void *);
int
usrsctp_set_ulpinfo(struct socket *, void *);
+int
+usrsctp_set_upcall(struct socket *so,
+ void (*upcall)(struct socket *, void *, int),
+ void *arg);
+
+int
+usrsctp_get_events(struct socket *so);
+
+
+void
+usrsctp_handle_timers(uint32_t delta);
+
#define SCTP_DUMP_OUTBOUND 1
#define SCTP_DUMP_INBOUND 0
@@ -1094,6 +1130,7 @@ USRSCTP_SYSCTL_DECL(sctp_udp_tunneling_port)
USRSCTP_SYSCTL_DECL(sctp_enable_sack_immediately)
USRSCTP_SYSCTL_DECL(sctp_vtag_time_wait)
USRSCTP_SYSCTL_DECL(sctp_blackhole)
+USRSCTP_SYSCTL_DECL(sctp_sendall_limit)
USRSCTP_SYSCTL_DECL(sctp_diag_info_code)
USRSCTP_SYSCTL_DECL(sctp_fr_max_burst_default)
USRSCTP_SYSCTL_DECL(sctp_path_pf_threshold)