Skip to content

Commit

Permalink
Limit SO_BINDTODEVICE to just Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
pdepaulis committed Jul 18, 2023
1 parent 8b405d0 commit 43d6d21
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 6 additions & 3 deletions libsofia-sip-ua/tport/tport.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,13 @@ typedef struct tport_nat_s tport_nat_t;
#include <sofia-sip/rbtree.h>

#include "tport_internal.h"
#if defined (__linux__)
#include <ifaddrs.h>
#if HAVE_NET_IF_H
#include <net/if.h>
#endif
#include <sys/ioctl.h>
#endif

#if HAVE_FUNC
#elif HAVE_FUNCTION
Expand Down Expand Up @@ -801,14 +803,15 @@ int tport_bind_socket(int socket,
}
}
#endif

#if defined(__linux__)
if (tport_bind_socket_iface(socket, su, ai) < 0) {
return -1;
}

#endif
return 0;
}

#if defined(__linux__)
int tport_bind_socket_iface(int s,
su_sockaddr_t *su,
su_addrinfo_t *ai)
Expand Down Expand Up @@ -849,7 +852,7 @@ int tport_bind_socket_iface(int s,
/* Technically it's not a "failure" */
return 0;
}

#endif

/** Indicate stack that a transport has been updated */
void tport_has_been_updated(tport_t *self)
Expand Down
2 changes: 2 additions & 0 deletions libsofia-sip-ua/tport/tport_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -440,9 +440,11 @@ void tport_base_timer(tport_t *self, su_time_t now);
int tport_bind_socket(int socket,
su_addrinfo_t *ai,
char const **return_culprit);
#if defined(__linux__)
int tport_bind_socket_iface(int s,
su_sockaddr_t *su,
su_addrinfo_t *ai);
#endif
void tport_close(tport_t *self);
int tport_shutdown0(tport_t *self, int how);

Expand Down

0 comments on commit 43d6d21

Please sign in to comment.