Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
libnice
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
libnice
Commits
3f3b9d15
Commit
3f3b9d15
authored
Jul 22, 2022
by
Olivier Crête
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
udp-bsd: Explicitly bind to the interface when creating a socket
parent
a667957f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
0 deletions
+28
-0
socket/udp-bsd.c
socket/udp-bsd.c
+28
-0
No files found.
socket/udp-bsd.c
View file @
3f3b9d15
...
@@ -51,6 +51,7 @@
...
@@ -51,6 +51,7 @@
#include "udp-bsd.h"
#include "udp-bsd.h"
#include "agent-priv.h"
#include "agent-priv.h"
#include "interfaces.h"
#ifndef G_OS_WIN32
#ifndef G_OS_WIN32
#include <unistd.h>
#include <unistd.h>
...
@@ -119,6 +120,33 @@ nice_udp_bsd_socket_new (NiceAddress *addr, GError **error)
...
@@ -119,6 +120,33 @@ nice_udp_bsd_socket_new (NiceAddress *addr, GError **error)
return
NULL
;
return
NULL
;
}
}
#if defined(IP_UNICAST_IF) && defined(IPV6_UNICAST_IF)
if
(
addr
)
{
guint
if_index
=
nice_interfaces_get_if_index_by_addr
(
addr
);
if
(
if_index
)
{
guint
level
,
optname
;
GError
*
gerr
=
NULL
;
if
(
nice_address_ip_version
(
addr
)
==
6
)
{
level
=
IPPROTO_IPV6
;
optname
=
IPV6_UNICAST_IF
;
}
else
{
level
=
IPPROTO_IP
;
optname
=
IP_UNICAST_IF
;
}
if_index
=
htonl
(
if_index
);
if
(
!
g_socket_set_option
(
gsock
,
level
,
optname
,
if_index
,
&
gerr
))
{
nice_debug
(
"Could not bind socket to specific interface: %s"
,
gerr
->
message
);
g_clear_error
(
&
gerr
);
}
}
}
#endif
/* GSocket: All socket file descriptors are set to be close-on-exec. */
/* GSocket: All socket file descriptors are set to be close-on-exec. */
g_socket_set_blocking
(
gsock
,
false
);
g_socket_set_blocking
(
gsock
,
false
);
gaddr
=
g_socket_address_new_from_native
(
&
name
.
addr
,
sizeof
(
name
));
gaddr
=
g_socket_address_new_from_native
(
&
name
.
addr
,
sizeof
(
name
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment