nplab / DTLS-Examples

Examples for DTLS via SCTP and UDP using OpenSSL

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Failed to build SCTP programs against Linux 5.0 kernel headers

liuqun opened this issue · comments

On Ubuntu 19.04 with Linux 5.0 kernel,
the kernel header file /usr/include/linux/sctp.h added the following line:

#define SCTP_EVENT      127

This breaks the following code that rely on the SCTP_EVENT micro which were disabled in the past (Linux 4.18 kernel).

#ifdef SCTP_EVENT
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 (setsockopt(fd, IPPROTO_SCTP, SCTP_EVENT, &event, sizeof(event)) < 0) {
perror("setsockopt");
}
}
#else
memset(&event, 1, sizeof(event));
if (setsockopt(fd, IPPROTO_SCTP, SCTP_EVENTS, &event, sizeof(event)) != 0) {
perror("set event failed");
}
#endif

On Ubuntu 19.04 I got such gcc error:

$ make
cc -std=c99 -pedantic -Wall -g -Wextra -Wno-unused-parameter -Wno-unused-function -Wno-overlength-strings -I/usr/local/include -o dtls_sctp_chargen dtls_sctp_chargen.c -L/usr/local/lib -lssl -lcrypto -pthread -lm -ldl
dtls_sctp_chargen.c: In function ‘start_server’:
dtls_sctp_chargen.c:586:23: error: ‘SCTP_FUTURE_ASSOC’ undeclared (first use in this function); did you mean ‘SCTP_RESET_ASSOC’?
   event.se_assoc_id = SCTP_FUTURE_ASSOC;
                       ^~~~~~~~~~~~~~~~~
                       SCTP_RESET_ASSOC
dtls_sctp_chargen.c:586:23: note: each undeclared identifier is reported only once for each function it appears in
...
$ uname -a
Linux vmware 5.0.0-15-generic #16-Ubuntu SMP Mon May 6 17:41:33 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

header file /usr/include/netinet/sctp.h provided by libsctp-dev relies on /usr/include/linux/sctp.h.

And there is NO definition of SCTP_FUTURE_ASSOC in any version of Linux kernel headers (4.18.x-5.0.x).

I guess the SCTP_FUTURE_ASSOC only came with freebsd kernel...

Thanks for the report.

You're right, the defines for SCTP_FUTURE_ASSOC, SCTP_CURRENT_ASSOC and SCTP_ALL_ASSOC are missing in Linux Kernel 5.0.
They are defined in version 5.1.

We'll evaluate the issue and report back.