Make a rawrtc example actually build
We were missing a lot of things that the linker caught when building an
example.
Change-Id: Ic3ea2a1dd0bfa88569023b47b603ec25f337f54c
diff --git a/third_party/rawrtc/rawrtc-data-channel/BUILD b/third_party/rawrtc/rawrtc-data-channel/BUILD
index 096024a..500ad8b 100644
--- a/third_party/rawrtc/rawrtc-data-channel/BUILD
+++ b/third_party/rawrtc/rawrtc-data-channel/BUILD
@@ -25,6 +25,10 @@
"-Wno-cast-qual",
"-Wno-cast-align",
"-Wno-missing-braces",
+ "-DUSE_OPENSSL",
+ "-DHAVE_INET6",
+ "-DHAVE_STDBOOL_H",
+ "-DHAVE_INTTYPES_H",
],
defines = [
"RAWRTCDC_HAVE_SCTP_REDIRECT_TRANSPORT=0",
@@ -34,6 +38,6 @@
visibility = ["//visibility:public"],
deps = [
"@com_github_rawrtc_rawrtc_common//:rawrtcc",
- "@com_github_rawrtc_usrsctp//:usrsctp_crc32",
+ "@com_github_rawrtc_usrsctp//:usrsctp",
],
)
diff --git a/third_party/rawrtc/rawrtc/BUILD b/third_party/rawrtc/rawrtc/BUILD
index df14384..77416d8 100644
--- a/third_party/rawrtc/rawrtc/BUILD
+++ b/third_party/rawrtc/rawrtc/BUILD
@@ -21,6 +21,11 @@
"-Wno-cast-qual",
"-Wno-missing-braces",
"-Iexternal/com_github_rawrtc_rawrtc/",
+ "-DUSE_OPENSSL",
+ #"-DUSE_ZLIB",
+ "-DHAVE_INET6",
+ "-DHAVE_STDBOOL_H",
+ "-DHAVE_INTTYPES_H",
],
includes = ["include/"],
local_defines = [
@@ -32,3 +37,29 @@
"@com_github_rawrtc_rawrtc_data_channel//:rawrtcdc",
],
)
+
+cc_binary(
+ name = "peer-connection",
+ srcs = [
+ "tools/helper/common.c",
+ "tools/helper/common.h",
+ "tools/helper/handler.c",
+ "tools/helper/handler.h",
+ "tools/helper/parameters.c",
+ "tools/helper/parameters.h",
+ "tools/helper/utils.c",
+ "tools/helper/utils.h",
+ "tools/peer-connection.c",
+ ],
+ copts = [
+ "-Wno-missing-braces",
+ "-Wno-incompatible-pointer-types-discards-qualifiers",
+ ] + compiler_select({
+ "clang": [],
+ "gcc": [
+ "-Wno-discarded-qualifiers",
+ ],
+ }),
+ includes = ["tools"],
+ deps = [":rawrtc"],
+)
diff --git a/third_party/rawrtc/re/BUILD b/third_party/rawrtc/re/BUILD
index af720c5..63efff7 100644
--- a/third_party/rawrtc/re/BUILD
+++ b/third_party/rawrtc/re/BUILD
@@ -13,7 +13,9 @@
"src/hmac/apple/**",
"src/hmac/hmac.c",
"src/mqueue/win32/**",
- "src/tls/openssl/**",
+ "src/sha/**",
+ "src/md5/**",
+ "src/ice/ice.c",
"src/dns/win32/**",
"src/mod/win32/**",
"src/lock/lock.c",
@@ -27,6 +29,7 @@
copts = compiler_select({
"clang": [
"-Wno-incompatible-pointer-types-discards-qualifiers",
+ "-Wno-macro-redefined",
],
"gcc": [
"-Wno-discarded-qualifiers",
@@ -40,6 +43,38 @@
"-Wno-cast-qual",
"-Wno-cast-align",
"-Wno-implicit-function-declaration",
+ "-DUSE_OPENSSL",
+ "-DUSE_TLS",
+ "-DUSE_OPENSSL_DTLS",
+ "-DUSE_DTLS",
+ "-DUSE_OPENSSL_SRTP",
+ "-DUSE_DTLS_SRTP",
+ #"-DUSE_ZLIB",
+ "-DHAVE_INET6",
+ "-DHAVE_SELECT",
+ "-DHAVE_STDBOOL_H",
+ "-DHAVE_INTTYPES_H",
+ "-DHAVE_NET_ROUTE_H",
+ "-DHAVE_SYS_SYSCTL_H",
+ "-DHAVE_FORK",
+ "-DHAVE_INET_NTOP",
+ "-DHAVE_PWD_H",
+ "-DHAVE_SELECT_H",
+ "-DHAVE_SETRLIMIT",
+ "-DHAVE_SIGNAL",
+ "-DHAVE_STRERROR_R",
+ "-DHAVE_STRINGS_H",
+ "-DHAVE_SYS_TIME_H",
+ "-DHAVE_UNAME",
+ "-DHAVE_UNISTD_H",
+ "-DHAVE_PTHREAD",
+ "-DHAVE_GETIFADDRS",
+ "-DHAVE_DLFCN",
+ "-DHAVE_EPOLL",
+ "-DHAVE_RESOLV",
+ "-DHAVE_POLL",
+ "-DHAVE_INET_PTON",
+ "-DHAVE_ROUTE_LIST",
],
defines = ["HAVE_INTTYPES_H"],
includes = ["include/"],
diff --git a/third_party/rawrtc/re/src/tls/openssl/tls.h b/third_party/rawrtc/re/src/tls/openssl/tls.h
index 2c621d5..c0c4d51 100644
--- a/third_party/rawrtc/re/src/tls/openssl/tls.h
+++ b/third_party/rawrtc/re/src/tls/openssl/tls.h
@@ -20,9 +20,11 @@
#if OPENSSL_VERSION_NUMBER >= 0x10100000L && \
!defined(LIBRESSL_VERSION_NUMBER)
+#ifndef OPENSSL_IS_BORINGSSL
#define SSL_state SSL_get_state
#define SSL_ST_OK TLS_ST_OK
#endif
+#endif
struct tls {
diff --git a/third_party/rawrtc/usrsctp/BUILD b/third_party/rawrtc/usrsctp/BUILD
index 7704bb9..654d29b 100644
--- a/third_party/rawrtc/usrsctp/BUILD
+++ b/third_party/rawrtc/usrsctp/BUILD
@@ -1,21 +1,63 @@
-# usrsctp is only actually being used for the CRC function, and getting
-# the entire library building was being obnoxious.
+load("@//tools/build_rules:select.bzl", "compiler_select")
+
cc_library(
- name = "usrsctp_crc32",
- srcs = ["usrsctplib/netinet/sctp_crc32.c"],
+ name = "usrsctp",
+ srcs = [
+ "usrsctplib/netinet/sctp_asconf.c",
+ "usrsctplib/netinet/sctp_auth.c",
+ "usrsctplib/netinet/sctp_bsd_addr.c",
+ "usrsctplib/netinet/sctp_callout.c",
+ "usrsctplib/netinet/sctp_cc_functions.c",
+ "usrsctplib/netinet/sctp_crc32.c",
+ "usrsctplib/netinet/sctp_indata.c",
+ "usrsctplib/netinet/sctp_input.c",
+ "usrsctplib/netinet/sctp_output.c",
+ "usrsctplib/netinet/sctp_pcb.c",
+ "usrsctplib/netinet/sctp_peeloff.c",
+ "usrsctplib/netinet/sctp_sha1.c",
+ "usrsctplib/netinet/sctp_ss_functions.c",
+ "usrsctplib/netinet/sctp_sysctl.c",
+ "usrsctplib/netinet/sctp_timer.c",
+ "usrsctplib/netinet/sctp_userspace.c",
+ "usrsctplib/netinet/sctp_usrreq.c",
+ "usrsctplib/netinet/sctputil.c",
+ "usrsctplib/netinet6/sctp6_usrreq.c",
+ "usrsctplib/user_environment.c",
+ "usrsctplib/user_mbuf.c",
+ "usrsctplib/user_recv_thread.c",
+ "usrsctplib/user_socket.c",
+ ],
hdrs = glob(["usrsctplib/**/*.h"]),
copts = [
"-Wno-cast-qual",
"-Wno-cast-align",
"-Wno-unused-parameter",
"-Wno-incompatible-pointer-types-discards-qualifiers",
+ "-D__Userspace_os_Linux",
+ "-D__Userspace__",
+ "-D_GNU_SOURCE",
+ "-DSCTP_DEBUG",
+ "-DSCTP_SIMPLE_ALLOCATOR",
+ "-DINET",
+ "-DINET6",
+ "-DSCTP_PROCESS_LEVEL_LOCKS",
+ "-DHAVE_SYS_QUEUE_H",
+ "-DHAVE_STDATOMIC_H",
+ "-DHAVE_NETINET_IP_ICMP_H",
+ "-DHAVE_LINUX_RTNETLINK_H",
+ "-DHAVE_LINUX_IF_ADDR_H",
+ "-Wno-address-of-packed-member",
+ ] + compiler_select({
+ "clang": [],
+ "gcc": [
+ "-Wno-discarded-qualifiers",
+ ],
+ }),
+ includes = [
+ "usrsctplib/",
+ "usrsctplib/netinet",
+ "usrsctplib/netinet6",
],
- defines = [
- "__Userspace_os_Linux",
- "__Userspace__",
- "SCTP_SIMPLE_ALLOCATOR",
- ],
- includes = ["usrsctplib/"],
target_compatible_with = ["@platforms//os:linux"],
visibility = ["//visibility:public"],
)
diff --git a/third_party/rawrtc/usrsctp/usrsctplib/netinet/sctp_constants.h b/third_party/rawrtc/usrsctp/usrsctplib/netinet/sctp_constants.h
index e275dd9..57240cd 100755
--- a/third_party/rawrtc/usrsctp/usrsctplib/netinet/sctp_constants.h
+++ b/third_party/rawrtc/usrsctp/usrsctplib/netinet/sctp_constants.h
@@ -778,7 +778,7 @@
#define SCTP_DEFAULT_SPLIT_POINT_MIN 2904
/* Maximum length of diagnostic information in error causes */
-#define SCTP_DIAG_INFO_LEN 64
+#define SCTP_DIAG_INFO_LEN 128
/* ABORT CODES and other tell-tale location
* codes are generated by adding the below
diff --git a/third_party/rawrtc/usrsctp/usrsctplib/netinet/sctp_pcb.c b/third_party/rawrtc/usrsctp/usrsctplib/netinet/sctp_pcb.c
index ec3ff6d..ca84395 100755
--- a/third_party/rawrtc/usrsctp/usrsctplib/netinet/sctp_pcb.c
+++ b/third_party/rawrtc/usrsctp/usrsctplib/netinet/sctp_pcb.c
@@ -6845,7 +6845,7 @@
TAILQ_INIT(&SCTP_BASE_INFO(callqueue));
#endif
#if defined(__Userspace__)
- mbuf_init(NULL);
+ usrsctpmbuf_init(NULL);
atomic_init();
#if defined(THREAD_SUPPORT) && (defined(INET) || defined(INET6))
recv_thread_init();
diff --git a/third_party/rawrtc/usrsctp/usrsctplib/netinet/sctputil.c b/third_party/rawrtc/usrsctp/usrsctplib/netinet/sctputil.c
index 87e7774..5ac93d5 100755
--- a/third_party/rawrtc/usrsctp/usrsctplib/netinet/sctputil.c
+++ b/third_party/rawrtc/usrsctp/usrsctplib/netinet/sctputil.c
@@ -5013,7 +5013,7 @@
*/
struct mbuf *
-sctp_generate_cause(uint16_t code, char *info)
+sctp_generate_cause(uint16_t code, const char *info)
{
struct mbuf *m;
struct sctp_gen_error_cause *cause;
diff --git a/third_party/rawrtc/usrsctp/usrsctplib/netinet/sctputil.h b/third_party/rawrtc/usrsctp/usrsctplib/netinet/sctputil.h
index 7746d54..1babe19 100755
--- a/third_party/rawrtc/usrsctp/usrsctplib/netinet/sctputil.h
+++ b/third_party/rawrtc/usrsctp/usrsctplib/netinet/sctputil.h
@@ -281,7 +281,7 @@
#endif
);
-struct mbuf *sctp_generate_cause(uint16_t, char *);
+struct mbuf *sctp_generate_cause(uint16_t, const char *);
struct mbuf *sctp_generate_no_user_data_cause(uint32_t);
void sctp_bindx_add_address(struct socket *so, struct sctp_inpcb *inp,
diff --git a/third_party/rawrtc/usrsctp/usrsctplib/user_mbuf.c b/third_party/rawrtc/usrsctp/usrsctplib/user_mbuf.c
index 9a82746..232d74e 100755
--- a/third_party/rawrtc/usrsctp/usrsctplib/user_mbuf.c
+++ b/third_party/rawrtc/usrsctp/usrsctplib/user_mbuf.c
@@ -121,7 +121,7 @@
mbuf_mb_args.type = type;
#endif
/* Mbuf master zone, zone_mbuf, has already been
- * created in mbuf_init() */
+ * created in usrsctpmbuf_init() */
mret = SCTP_ZONE_GET(zone_mbuf, struct mbuf);
#if defined(SCTP_SIMPLE_ALLOCATOR)
mb_ctor_mbuf(mret, &mbuf_mb_args, 0);
@@ -328,11 +328,11 @@
/************ End functions to substitute umem_cache_alloc and umem_cache_free **************/
/* __Userspace__
- * TODO: mbuf_init must be called in the initialization routines
+ * TODO: usrsctpmbuf_init must be called in the initialization routines
* of userspace stack.
*/
void
-mbuf_init(void *dummy)
+usrsctpmbuf_init(void *dummy)
{
/*
diff --git a/third_party/rawrtc/usrsctp/usrsctplib/user_mbuf.h b/third_party/rawrtc/usrsctp/usrsctplib/user_mbuf.h
index 7893ea9..64a0ac3 100755
--- a/third_party/rawrtc/usrsctp/usrsctplib/user_mbuf.h
+++ b/third_party/rawrtc/usrsctp/usrsctplib/user_mbuf.h
@@ -58,7 +58,7 @@
/* mbuf initialization function */
-void mbuf_init(void *);
+void usrsctpmbuf_init(void *);
#define M_MOVE_PKTHDR(to, from) m_move_pkthdr((to), (from))
#define MGET(m, how, type) ((m) = m_get((how), (type)))