Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
sofia-sip
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
External Wiki
External Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
BC
public
external
sofia-sip
Commits
14056de7
Commit
14056de7
authored
Jan 17, 2006
by
Martti Mela
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed bugs in STUN tls
darcs-hash:20060117160712-1b897-e1bceba082326215e2d880ad11869ca970dd276c.gz
parent
85828aac
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
41 deletions
+22
-41
stun.c
libsofia-sip-ua/stun/stun.c
+22
-41
No files found.
libsofia-sip-ua/stun/stun.c
View file @
14056de7
...
...
@@ -173,8 +173,6 @@ struct stun_handle_s
su_localinfo_t
sh_localinfo
;
/**< local addrinfo */
su_sockaddr_t
sh_local_addr
[
1
];
/**< local address */
su_socket_t
sh_tls_socket
;
/**< outbound socket */
SSL_CTX
*
sh_ctx
;
/**< SSL context for TLS */
SSL
*
sh_ssl
;
/**< SSL handle for TLS */
stun_msg_t
sh_tls_request
;
...
...
@@ -188,7 +186,7 @@ struct stun_handle_s
stun_buffer_t
sh_passwd
;
int
sh_use_msgint
;
/**< use message integrity? */
int
sh_state
;
/**< Progress states */
/* int sh_state; */
/**< Progress states */
};
...
...
@@ -478,21 +476,11 @@ int stun_handle_request_shared_secret(stun_handle_t *sh)
sd
->
sd_socket
=
s
;
req
=
stun_request_create
(
sd
);
sh
->
sh_tls_socket
=
s
;
#if 1
if
(
su_wait_create
(
wait
,
s
,
events
)
==
-
1
)
STUN_ERROR
(
errno
,
su_wait_create
);
events
=
SU_WAIT_CONNECT
|
SU_WAIT_ERR
;
su_root_eventmask
(
sh
->
sh_root
,
sh
->
sh_root_index
,
s
,
events
);
#else
events
=
SU_WAIT_CONNECT
|
SU_WAIT_ERR
;
if
(
su_wait_create
(
wait
,
s
,
events
)
==
-
1
)
STUN_ERROR
(
errno
,
su_wait_create
);
#endif
if
((
sd
->
sd_index
=
su_root_register
(
sh
->
sh_root
,
wait
,
stun_tls_callback
,
sh
,
0
))
==
-
1
)
{
...
...
@@ -591,11 +579,6 @@ void stun_handle_destroy(stun_handle_t *sh)
enter
;
#if 0
if (sh->sh_tls_socket > 0)
su_close(sh->sh_tls_socket);
#endif
/* There can be several discoveries using the same socket. It is
still enough to deregister the socket in first of them */
for
(
sd
=
sh
->
sh_discoveries
;
sd
;
)
{
...
...
@@ -1111,7 +1094,7 @@ int stun_tls_callback(su_root_magic_t *m, su_wait_t *w, stun_handle_t *self)
ssl
=
SSL_new
(
ctx
);
self
->
sh_ssl
=
ssl
;
if
(
SSL_set_fd
(
ssl
,
s
elf
->
sh_tls
_socket
)
==
0
)
{
if
(
SSL_set_fd
(
ssl
,
s
d
->
sd
_socket
)
==
0
)
{
STUN_ERROR
(
err
,
connect
);
stun_free_buffer
(
&
msg_req
->
enc_buf
);
return
-
1
;
...
...
@@ -1123,37 +1106,38 @@ int stun_tls_callback(su_root_magic_t *m, su_wait_t *w, stun_handle_t *self)
case
stun_tls_ssl_connecting
:
events
=
SU_WAIT_ERR
|
SU_WAIT_IN
;
su_root_eventmask
(
self
->
sh_root
,
s
elf
->
sh_root
_index
,
s
elf
->
sh_tls
_socket
,
events
);
su_root_eventmask
(
self
->
sh_root
,
s
d
->
sd
_index
,
s
d
->
sd
_socket
,
events
);
z
=
SSL_connect
(
ssl
);
err
=
SSL_get_error
(
ssl
,
z
);
if
(
z
<
1
&&
(
err
==
SSL_ERROR_WANT_READ
||
err
==
SSL_ERROR_WANT_WRITE
))
{
s
elf
->
sh
_state
=
stun_tls_ssl_connecting
;
s
d
->
sd
_state
=
stun_tls_ssl_connecting
;
return
0
;
}
else
if
(
z
<
1
)
{
stun_free_buffer
(
&
msg_req
->
enc_buf
);
self
->
sh_state
=
stun_tls_ssl_connect_failed
;
self
->
sh_callback
(
self
->
sh_context
,
self
,
NULL
,
NULL
,
stun_action_no_action
,
self
->
sh_state
);
sd
->
sd_state
=
stun_tls_ssl_connect_failed
;
self
->
sh_callback
(
self
->
sh_context
,
self
,
NULL
,
sd
,
sd
->
sd_action
,
sd
->
sd_state
);
return
-
1
;
}
/* Inform application about the progress */
s
elf
->
sh
_state
=
stun_tls_writing
;
s
d
->
sd
_state
=
stun_tls_writing
;
/* self->sh_callback(self->sh_context, self, self->sh_state); */
events
=
SU_WAIT_ERR
|
SU_WAIT_OUT
;
su_root_eventmask
(
self
->
sh_root
,
s
elf
->
sh_root
_index
,
s
elf
->
sh_tls
_socket
,
events
);
su_root_eventmask
(
self
->
sh_root
,
s
d
->
sd
_index
,
s
d
->
sd
_socket
,
events
);
break
;
case
stun_tls_writing
:
events
=
SU_WAIT_ERR
|
SU_WAIT_IN
;
su_root_eventmask
(
self
->
sh_root
,
s
elf
->
sh_root
_index
,
s
elf
->
sh_tls
_socket
,
events
);
su_root_eventmask
(
self
->
sh_root
,
s
d
->
sd
_index
,
s
d
->
sd
_socket
,
events
);
SU_DEBUG_3
((
"TLS connection using %s
\n
"
,
SSL_get_cipher
(
ssl
)));
...
...
@@ -1176,14 +1160,14 @@ int stun_tls_callback(su_root_magic_t *m, su_wait_t *w, stun_handle_t *self)
return
-
1
;
}
}
s
elf
->
sh
_state
=
stun_tls_reading
;
s
d
->
sd
_state
=
stun_tls_reading
;
break
;
case
stun_tls_reading
:
events
=
SU_WAIT_ERR
|
SU_WAIT_OUT
;
su_root_eventmask
(
self
->
sh_root
,
s
elf
->
sh_root
_index
,
s
elf
->
sh_tls
_socket
,
events
);
su_root_eventmask
(
self
->
sh_root
,
s
d
->
sd
_index
,
s
d
->
sd
_socket
,
events
);
SU_DEBUG_5
((
"Shared Secret Request sent to server:
\n
"
));
debug_print
(
&
msg_req
->
enc_buf
);
...
...
@@ -1209,12 +1193,12 @@ int stun_tls_callback(su_root_magic_t *m, su_wait_t *w, stun_handle_t *self)
/* closed TLS connection */
SSL_shutdown
(
ssl
);
s
elf
->
sh
_state
=
stun_tls_closing
;
s
d
->
sd
_state
=
stun_tls_closing
;
break
;
case
stun_tls_closing
:
su_close
(
s
elf
->
sh_tls
_socket
);
su_close
(
s
d
->
sd
_socket
);
SSL_free
(
self
->
sh_ssl
),
ssl
=
NULL
;
SSL_CTX_free
(
self
->
sh_ctx
),
ctx
=
NULL
;
...
...
@@ -1253,11 +1237,12 @@ int stun_tls_callback(su_root_magic_t *m, su_wait_t *w, stun_handle_t *self)
}
su_wait_destroy
(
w
);
su_root_deregister
(
self
->
sh_root
,
s
elf
->
sh_root
_index
);
su_root_deregister
(
self
->
sh_root
,
s
d
->
sd
_index
);
self
->
sh_use_msgint
=
1
;
self
->
sh_state
=
stun_tls_done
;
self
->
sh_callback
(
self
->
sh_context
,
self
,
NULL
,
NULL
,
stun_action_no_action
,
self
->
sh_state
);
sd
->
sd_state
=
stun_tls_done
;
self
->
sh_callback
(
self
->
sh_context
,
self
,
NULL
,
sd
,
sd
->
sd_action
,
sd
->
sd_state
);
break
;
...
...
@@ -1381,11 +1366,7 @@ int stun_bind_callback(stun_magic_t *m, su_wait_t *w, stun_handle_t *self)
su_sockaddr_t
recv
;
socklen_t
recv_len
;
su_socket_t
s
=
su_wait_socket
(
w
);
#if 0
int events = su_wait_events(w, self->sh_tls_socket);
#else
int
events
=
su_wait_events
(
w
,
s
);
#endif
enter
;
...
...
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