Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
BC
public
external
sofia-sip
Commits
09c1e857
Commit
09c1e857
authored
Jan 14, 2006
by
Martti Mela
Browse files
stun works with nua_cli
darcs-hash:20060114155429-1b897-f3082016b825b35da22f59de7b1cfcdd99f9d1f7.gz
parent
b57b4816
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
11 deletions
+18
-11
libsofia-sip-ua/stun/stun.c
libsofia-sip-ua/stun/stun.c
+15
-9
libsofia-sip-ua/stun/stunc.c
libsofia-sip-ua/stun/stunc.c
+1
-1
libsofia-sip-ua/tport/tport.c
libsofia-sip-ua/tport/tport.c
+2
-1
No files found.
libsofia-sip-ua/stun/stun.c
View file @
09c1e857
...
...
@@ -655,7 +655,7 @@ static int get_localinfo(su_localinfo_t *clientinfo)
int
i
,
error
,
found
=
0
;
char
ipaddr
[
SU_ADDRSIZE
+
2
]
=
{
0
};
/*
hints->li_family = AF_INET;
*/
hints
->
li_family
=
AF_INET
;
if
((
error
=
su_getlocalinfo
(
hints
,
&
res
))
==
0
)
{
/* try to bind to the first available address */
...
...
@@ -667,7 +667,7 @@ static int get_localinfo(su_localinfo_t *clientinfo)
clientinfo
->
li_addrlen
=
li
->
li_addrlen
;
sa
=
clientinfo
->
li_addr
;
memcpy
(
sa
,
li
->
li_addr
,
sizeof
(
su_addr
info
_t
));
memcpy
(
sa
,
li
->
li_addr
,
sizeof
(
su_
sock
addr_t
));
SU_DEBUG_3
((
"%s: local address found to be %s.
\n
"
,
__func__
,
inet_ntop
(
clientinfo
->
li_family
,
SU_ADDR
(
sa
),
...
...
@@ -732,8 +732,8 @@ int stun_handle_bind(stun_handle_t *sh,
stun_discovery_t
*
sd
=
NULL
;
ta_list
ta
;
stun_action_t
action
=
stun_action_binding_request
;
s
truct
sockaddr
*
sa
;
int
err
;
s
u_
sockaddr
_t
*
sa
;
int
err
,
index
;
SU_DEBUG_7
((
"%s: entering.
\n
"
,
__func__
));
...
...
@@ -753,7 +753,7 @@ int stun_handle_bind(stun_handle_t *sh,
return
errno
=
EINVAL
,
-
1
;
}
if
(
assign_socket
(
sh
,
s
)
<
0
)
if
(
(
index
=
assign_socket
(
sh
,
s
)
)
<
0
)
return
-
1
;
bind_len
=
sizeof
bind_addr
;
...
...
@@ -762,7 +762,7 @@ int stun_handle_bind(stun_handle_t *sh,
bind_len
=
sizeof
bind_addr
;
memset
(
sa
,
0
,
sizeof
(
bind_addr
));
/* if bound check the error */
err
=
getsockname
(
s
,
sa
,
&
bind_len
);
err
=
getsockname
(
s
,
(
struct
sockaddr
*
)
sa
,
&
bind_len
);
if
(
err
<
0
&&
errno
==
SOCKET_ERROR
)
{
STUN_ERROR
(
errno
,
getsockname
);
return
-
1
;
...
...
@@ -779,9 +779,10 @@ int stun_handle_bind(stun_handle_t *sh,
}
else
{
/* Not bound - bind it */
get_localinfo
(
clientinfo
);
//
get_localinfo(clientinfo);
if
(
err
=
bind
(
s
,
(
struct
sockaddr
*
)
&
clientinfo
->
li_addr
,
bind_len
)
<
0
)
{
clientinfo
->
li_family
=
AF_INET6
;
if
((
err
=
bind
(
s
,
(
struct
sockaddr
*
)
sa
,
bind_len
))
<
0
)
{
STUN_ERROR
(
errno
,
bind
);
SU_DEBUG_3
((
"%s: Error binding to %s:%u
\n
"
,
__func__
,
inet_ntop
(
clientinfo
->
li_family
,
SU_ADDR
(
clientinfo
->
li_addr
),
...
...
@@ -805,6 +806,7 @@ int stun_handle_bind(stun_handle_t *sh,
sd
=
stun_discovery_create
(
sh
,
action
);
sd
->
sd_socket
=
s
;
sd
->
sd_index
=
index
;
req
=
stun_request_create
(
sd
);
...
...
@@ -939,6 +941,7 @@ int stun_handle_get_nattype(stun_handle_t *sh,
sd
=
stun_discovery_create
(
sh
,
stun_action_get_nattype
);
sd
->
sd_socket
=
s
;
sd
->
sd_index
=
index
;
/* If no server given, use default address from stun_handle_create() */
if
(
!
server
)
{
...
...
@@ -2243,6 +2246,7 @@ int stun_handle_get_lifetime(stun_handle_t *sh,
sd
=
stun_discovery_create
(
sh
,
stun_action_get_lifetime
);
sd
->
sd_socket
=
s
;
sd
->
sd_index
=
index
;
/* If no server given, use default address from stun_handle_create() */
if
(
!
server
)
{
...
...
@@ -2404,7 +2408,9 @@ int stun_handle_release(stun_handle_t *sh, su_socket_t s)
continue
;
/* Index has same value as sockfd, right? */
su_root_deregister
(
sh
->
sh_root
,
sd
->
sd_socket
);
su_root_deregister
(
sh
->
sh_root
,
sd
->
sd_index
);
SU_DEBUG_3
((
"%s: socket deregistered from STUN
\n
"
,
__func__
));
return
0
;
}
...
...
libsofia-sip-ua/stun/stunc.c
View file @
09c1e857
...
...
@@ -163,7 +163,7 @@ int main(int argc, char *argv[])
return
-
1
;
}
s
=
su_socket
(
AF_INET
,
SOCK_DGRAM
,
0
);
s
=
su_socket
(
AF_INET
6
,
SOCK_DGRAM
,
0
);
if
(
s
==
-
1
)
{
SU_DEBUG_0
((
"%s: %s failed: %s
\n
"
,
__func__
,
"stun_socket_create()"
,
su_gli_strerror
(
errno
)));
return
-
1
;
...
...
libsofia-sip-ua/tport/tport.c
View file @
09c1e857
...
...
@@ -6870,7 +6870,7 @@ void tport_stun_cb(tport_master_t *mr, stun_handle_t *sh,
break
;
case
stun_action_binding_request
:
if
(
event
!=
stun_bind_done
||
event
!=
stun_bind_timeout
)
if
(
event
!=
stun_bind_done
&&
event
!=
stun_bind_timeout
)
break
;
sa
=
stun_discovery_get_address
(
sd
);
...
...
@@ -7006,6 +7006,7 @@ int tport_nat_stun_bind(struct tport_nat_s *nat,
su_root_step
(
mr
->
mr_root
,
1000
);
}
stun_handle_release
(
nat
->
stun
,
s
);
SU_DEBUG_9
((
"%s: stun_bind() ok
\n
"
,
__func__
));
memcpy
(
su
,
&
nat
->
sockaddr
,
sizeof
(
su
));
...
...
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