Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Multipath TCP (MPTCP) support #23

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/belle_sip_resolver.c
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,11 @@ static void *_resolver_getaddrinfo_thread(void *ptr) {
snprintf(serv, sizeof(serv), "%i", ctx->port);
hints.ai_family = ctx->family;
hints.ai_flags = AI_NUMERICSERV;
#ifdef IPPROTO_MPTCP
hints.ai_protocol = strstr(ctx->name, "udp") ? IPPROTO_UDP : IPPROTO_MPTCP;
#else
hints.ai_protocol = strstr(ctx->name, "udp") ? IPPROTO_UDP : IPPROTO_TCP;
#endif
err = getaddrinfo(ctx->name, serv, &hints, &res);
if (err != 0) {
belle_sip_error("getaddrinfo DNS resolution of %s failed: %s", ctx->name, gai_strerror(err));
Expand Down
8 changes: 8 additions & 0 deletions src/transports/stream_channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,15 @@ int stream_channel_connect(belle_sip_stream_channel_t *obj, const struct addrinf
tmp = 1;

obj->base.ai_family = ai->ai_family;
#ifdef IPPROTO_MPTCP
sock = bctbx_socket(ai->ai_family, SOCK_STREAM, IPPROTO_MPTCP);
if (sock == (belle_sip_socket_t)-1) {
// fallback to TCP if MPTCP encounter an error
sock = bctbx_socket(ai->ai_family, SOCK_STREAM, IPPROTO_TCP);
}
#else
sock = bctbx_socket(ai->ai_family, SOCK_STREAM, IPPROTO_TCP);
#endif

if (sock == (belle_sip_socket_t)-1) {
belle_sip_error("Could not create socket: %s", belle_sip_get_socket_error_string());
Expand Down
4 changes: 4 additions & 0 deletions src/transports/stream_listeningpoint.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ BELLE_SIP_INSTANCIATE_CUSTOM_VPTR_BEGIN(belle_sip_stream_listening_point_t){
snprintf(portnum, sizeof(portnum), "%i", *port);
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
#ifdef IPPROTO_MPTCP
hints.ai_protocol = IPPROTO_MPTCP;
#else
hints.ai_protocol = IPPROTO_TCP;
#endif
hints.ai_flags = AI_NUMERICSERV;
err = getaddrinfo(addr, portnum, &hints, &res);
if (err != 0) {
Expand Down