Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mongoose
Project
Project
Details
Activity
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
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
esp
mongoose
Commits
7e927b43
Commit
7e927b43
authored
Feb 23, 2016
by
Deomid Ryabkov
Committed by
rojer
Feb 25, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial support for SSL in TCPUART 2
PUBLISHED_FROM=93cb3cf49ce9173a7361af17c1bd47858bb2602e
parent
9eea072f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
17 deletions
+24
-17
mongoose.c
mongoose.c
+14
-12
mongoose.h
mongoose.h
+10
-5
No files found.
mongoose.c
View file @
7e927b43
...
...
@@ -2560,12 +2560,9 @@ const char *mg_set_ssl(struct mg_connection *nc, const char *cert,
}
#endif
/* MG_ENABLE_SSL */
struct
mg_connection
*
mg_if_accept_tcp_cb
(
struct
mg_connection
*
lc
,
union
socket_address
*
sa
,
size_t
sa_len
)
{
struct
mg_connection
*
mg_if_accept_new_conn
(
struct
mg_connection
*
lc
)
{
struct
mg_add_sock_opts
opts
;
struct
mg_connection
*
nc
;
(
void
)
sa_len
;
memset
(
&
opts
,
0
,
sizeof
(
opts
));
nc
=
mg_create_connection
(
lc
->
mgr
,
lc
->
handler
,
opts
);
if
(
nc
==
NULL
)
return
NULL
;
...
...
@@ -2574,17 +2571,19 @@ struct mg_connection *mg_if_accept_tcp_cb(struct mg_connection *lc,
nc
->
proto_handler
=
lc
->
proto_handler
;
nc
->
user_data
=
lc
->
user_data
;
nc
->
recv_mbuf_limit
=
lc
->
recv_mbuf_limit
;
nc
->
sa
=
*
sa
;
mg_add_conn
(
nc
->
mgr
,
nc
);
if
(
lc
->
ssl_ctx
==
NULL
)
{
/* For non-SSL connections deliver MG_EV_ACCEPT right away. */
mg_call
(
nc
,
NULL
,
MG_EV_ACCEPT
,
&
nc
->
sa
);
}
DBG
((
"%p %p %d %d, %p %p"
,
lc
,
nc
,
nc
->
sock
,
(
int
)
nc
->
flags
,
lc
->
ssl_ctx
,
nc
->
ssl
));
return
nc
;
}
void
mg_if_accept_tcp_cb
(
struct
mg_connection
*
nc
,
union
socket_address
*
sa
,
size_t
sa_len
)
{
(
void
)
sa_len
;
nc
->
sa
=
*
sa
;
mg_call
(
nc
,
NULL
,
MG_EV_ACCEPT
,
&
nc
->
sa
);
}
void
mg_send
(
struct
mg_connection
*
nc
,
const
void
*
buf
,
int
len
)
{
nc
->
last_io_time
=
mg_time
();
if
(
nc
->
flags
&
MG_F_UDP
)
{
...
...
@@ -3102,7 +3101,7 @@ static void mg_accept_conn(struct mg_connection *lc) {
DBG
((
"%p: failed to accept: %d"
,
lc
,
errno
));
return
;
}
nc
=
mg_if_accept_
tcp_cb
(
lc
,
&
sa
,
sa_len
);
nc
=
mg_if_accept_
new_conn
(
lc
);
if
(
nc
==
NULL
)
{
closesocket
(
sock
);
return
;
...
...
@@ -3115,8 +3114,11 @@ static void mg_accept_conn(struct mg_connection *lc) {
DBG
((
"SSL error"
));
mg_close_conn
(
nc
);
}
}
}
else
#endif
{
mg_if_accept_tcp_cb
(
nc
,
&
sa
,
sa_len
);
}
}
/* 'sa' must be an initialized address to bind to */
...
...
@@ -3331,7 +3333,7 @@ static void mg_ssl_begin(struct mg_connection *nc) {
socklen_t
sa_len
=
sizeof
(
sa
);
/* In case port was set to 0, get the real port number */
(
void
)
getsockname
(
nc
->
sock
,
&
sa
.
sa
,
&
sa_len
);
mg_
call
(
nc
,
NULL
,
MG_EV_ACCEPT
,
&
sa
);
mg_
if_accept_tcp_cb
(
nc
,
&
sa
,
sa_len
);
}
else
{
mg_if_connect_cb
(
nc
,
0
);
}
...
...
mongoose.h
View file @
7e927b43
...
...
@@ -1454,10 +1454,15 @@ void mg_if_connect_cb(struct mg_connection *nc, int err);
/* Set up a listening TCP socket on a given address. rv = 0 -> ok. */
int
mg_if_listen_tcp
(
struct
mg_connection
*
nc
,
union
socket_address
*
sa
);
/* Deliver a new TCP connection. Returns NULL in case on error (unable to
* create connection, in which case interface state should be discarded. */
struct
mg_connection
*
mg_if_accept_tcp_cb
(
struct
mg_connection
*
lc
,
union
socket_address
*
sa
,
/*
* Deliver a new TCP connection. Returns NULL in case on error (unable to
* create connection, in which case interface state should be discarded.
* This is phase 1 of the two-phase process - MG_EV_ACCEPT will be delivered
* when mg_if_accept_tcp_cb is invoked.
*/
struct
mg_connection
*
mg_if_accept_new_conn
(
struct
mg_connection
*
lc
);
void
mg_if_accept_tcp_cb
(
struct
mg_connection
*
nc
,
union
socket_address
*
sa
,
size_t
sa_len
);
/* Request that a "listening" UDP socket be created. */
...
...
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