Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
Stunserver
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
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
nanahira
Stunserver
Commits
d6d816e9
Commit
d6d816e9
authored
Jun 22, 2013
by
jselbie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
IPv6 sockets don't get IPv4 bindings
parent
ffe05770
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
1 deletion
+34
-1
networkutils/stunsocket.cpp
networkutils/stunsocket.cpp
+31
-1
networkutils/stunsocket.h
networkutils/stunsocket.h
+3
-0
No files found.
networkutils/stunsocket.cpp
View file @
d6d816e9
...
...
@@ -176,7 +176,6 @@ HRESULT CStunSocket::EnablePktInfo_IPV6(bool fEnable)
return
EnablePktInfoImpl
(
level
,
option1
,
option2
,
fEnable
);
}
HRESULT
CStunSocket
::
EnablePktInfoOption
(
bool
fEnable
)
{
int
family
=
_addrlocal
.
GetFamily
();
...
...
@@ -194,6 +193,27 @@ HRESULT CStunSocket::EnablePktInfoOption(bool fEnable)
return
hr
;
}
HRESULT
CStunSocket
::
SetV6Only
(
int
sock
)
{
int
optname
=
-
1
;
int
result
=
0
;
HRESULT
hr
=
S_OK
;
int
enabled
=
1
;
#ifdef IPV6_BINDV6ONLY
optname
=
IPV6_BINDV6ONLY
;
#elif IPV6_V6ONLY
optname
=
IPV6_V6ONLY
;
#else
return
E_NOTIMPL
;
#endif
result
=
setsockopt
(
sock
,
IPPROTO_IPV6
,
optname
,
(
char
*
)
&
enabled
,
sizeof
(
enabled
));
hr
=
(
result
==
0
)
?
S_OK
:
ERRNOHR
;
return
hr
;
}
HRESULT
CStunSocket
::
SetNonBlocking
(
bool
fEnable
)
{
HRESULT
hr
=
S_OK
;
...
...
@@ -221,6 +241,7 @@ Cleanup:
return
hr
;
}
void
CStunSocket
::
UpdateAddresses
()
{
sockaddr_storage
addrLocal
=
{};
...
...
@@ -263,6 +284,15 @@ HRESULT CStunSocket::InitCommon(int socktype, const CSocketAddress& addrlocal, S
sock
=
socket
(
addrlocal
.
GetFamily
(),
socktype
,
0
);
ChkIf
(
sock
<
0
,
ERRNOHR
);
if
(
addrlocal
.
GetFamily
()
==
AF_INET6
)
{
// Don't allow IPv6 socket to receive binding request from IPv4 client
// Because if we don't then an IPv4 client will get an IPv6 mapped address in the binding response
// I'm pretty sure you have to call this before bind()
// Intentionally ignoring result
(
void
)
SetV6Only
(
sock
);
}
if
(
fSetReuseFlag
)
{
int
fAllow
=
1
;
...
...
networkutils/stunsocket.h
View file @
d6d816e9
...
...
@@ -38,6 +38,8 @@ private:
HRESULT
EnablePktInfo_IPV4
(
bool
fEnable
);
HRESULT
EnablePktInfo_IPV6
(
bool
fEnable
);
HRESULT
SetV6Only
(
int
sock
);
public:
CStunSocket
();
...
...
@@ -60,6 +62,7 @@ public:
HRESULT
EnablePktInfoOption
(
bool
fEnable
);
HRESULT
SetNonBlocking
(
bool
fEnable
);
void
UpdateAddresses
();
HRESULT
UDPInit
(
const
CSocketAddress
&
local
,
SocketRole
role
);
...
...
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