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
e610fb4f
Commit
e610fb4f
authored
Nov 12, 2008
by
Youness Alaoui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix stund against strict aliasing issues
parent
764065e9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
8 deletions
+13
-8
stun/tools/stund.c
stun/tools/stund.c
+12
-7
stun/tools/stund.h
stun/tools/stund.h
+1
-1
No files found.
stun/tools/stund.c
View file @
e610fb4f
...
@@ -78,10 +78,16 @@ static const uint16_t known_attributes[] = {
...
@@ -78,10 +78,16 @@ static const uint16_t known_attributes[] = {
/**
/**
* Creates a listening socket
* Creates a listening socket
*/
*/
int
listen_socket
(
int
fam
,
int
type
,
int
proto
,
u
int16_
t
port
)
int
listen_socket
(
int
fam
,
int
type
,
int
proto
,
u
nsigned
in
t
port
)
{
{
int
yes
=
1
;
int
yes
=
1
;
int
fd
=
socket
(
fam
,
type
,
proto
);
int
fd
=
socket
(
fam
,
type
,
proto
);
union
{
struct
sockaddr
addr
;
struct
sockaddr_in
in
;
struct
sockaddr_in6
in6
;
struct
sockaddr_storage
storage
;
}
addr
;
if
(
fd
==
-
1
)
if
(
fd
==
-
1
)
{
{
perror
(
"Error opening IP port"
);
perror
(
"Error opening IP port"
);
...
@@ -90,24 +96,23 @@ int listen_socket (int fam, int type, int proto, uint16_t port)
...
@@ -90,24 +96,23 @@ int listen_socket (int fam, int type, int proto, uint16_t port)
if
(
fd
<
3
)
if
(
fd
<
3
)
goto
error
;
goto
error
;
struct
sockaddr_storage
addr
;
memset
(
&
addr
,
0
,
sizeof
(
addr
));
memset
(
&
addr
,
0
,
sizeof
(
addr
));
addr
.
ss_family
=
fam
;
addr
.
s
torage
.
s
s_family
=
fam
;
#ifdef HAVE_SA_LEN
#ifdef HAVE_SA_LEN
addr
.
ss_len
=
sizeof
(
addr
);
addr
.
s
torage
.
s
s_len
=
sizeof
(
addr
);
#endif
#endif
switch
(
fam
)
switch
(
fam
)
{
{
case
AF_INET
:
case
AF_INET
:
((
struct
sockaddr_in
*
)
&
addr
)
->
sin_port
=
port
;
addr
.
in
.
sin_port
=
htons
(
port
)
;
break
;
break
;
case
AF_INET6
:
case
AF_INET6
:
#ifdef IPV6_V6ONLY
#ifdef IPV6_V6ONLY
setsockopt
(
fd
,
SOL_IPV6
,
IPV6_V6ONLY
,
&
yes
,
sizeof
(
yes
));
setsockopt
(
fd
,
SOL_IPV6
,
IPV6_V6ONLY
,
&
yes
,
sizeof
(
yes
));
#endif
#endif
((
struct
sockaddr_in6
*
)
&
addr
)
->
sin6_port
=
port
;
addr
.
in6
.
sin6_port
=
htons
(
port
)
;
break
;
break
;
}
}
...
@@ -271,7 +276,7 @@ static int run (int family, int protocol, unsigned port)
...
@@ -271,7 +276,7 @@ static int run (int family, int protocol, unsigned port)
{
{
StunAgent
oldagent
;
StunAgent
oldagent
;
StunAgent
newagent
;
StunAgent
newagent
;
int
sock
=
listen_socket
(
family
,
SOCK_DGRAM
,
protocol
,
htons
(
port
)
);
int
sock
=
listen_socket
(
family
,
SOCK_DGRAM
,
protocol
,
port
);
if
(
sock
==
-
1
)
if
(
sock
==
-
1
)
return
-
1
;
return
-
1
;
...
...
stun/tools/stund.h
View file @
e610fb4f
...
@@ -36,7 +36,7 @@
...
@@ -36,7 +36,7 @@
#ifndef NICE_STUN_STUND_H
#ifndef NICE_STUN_STUND_H
# define NICE_STUN_STUND_H 1
# define NICE_STUN_STUND_H 1
int
listen_socket
(
int
fam
,
int
type
,
int
proto
,
u
int16_t
port
);
int
listen_socket
(
int
fam
,
int
type
,
int
proto
,
u
nsigned
port
);
ssize_t
send_safe
(
int
fd
,
const
struct
msghdr
*
msg
);
ssize_t
send_safe
(
int
fd
,
const
struct
msghdr
*
msg
);
ssize_t
recv_safe
(
int
fd
,
struct
msghdr
*
msg
);
ssize_t
recv_safe
(
int
fd
,
struct
msghdr
*
msg
);
...
...
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