Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Mbedtls
提交
1a5db09e
T
Third Party Mbedtls
项目概览
OpenHarmony
/
Third Party Mbedtls
大约 2 年 前同步成功
通知
0
Star
19
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party Mbedtls
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
1a5db09e
编写于
8月 15, 2023
作者:
M
maosiping
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
use lwip
Signed-off-by:
N
maosiping
<
maosiping@huawei.com
>
上级
4d734a94
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
88 addition
and
5 deletion
+88
-5
library/net_sockets.c
library/net_sockets.c
+39
-5
mbedtls.gni
mbedtls.gni
+9
-0
port/config/compat_lwip/socket_compat.h
port/config/compat_lwip/socket_compat.h
+21
-0
port/config/compat_posix/socket_compat.h
port/config/compat_posix/socket_compat.h
+19
-0
未找到文件。
library/net_sockets.c
浏览文件 @
1a5db09e
...
@@ -111,10 +111,9 @@ static int wsa_init_done = 0;
...
@@ -111,10 +111,9 @@ static int wsa_init_done = 0;
#include <stdint.h>
#include <stdint.h>
#ifdef LITEOS_VERSION
#include "socket_compat.h"
#ifdef USE_LWIP
#include "lwip/sockets.h"
#include "lwip/sockets.h"
#define close(fd) lwip_close(fd)
#define shutdown(fd, how) lwip_shutdown(fd, how)
#endif
#endif
/*
/*
...
@@ -220,7 +219,11 @@ int mbedtls_net_connect( mbedtls_net_context *ctx, const char *host,
...
@@ -220,7 +219,11 @@ int mbedtls_net_connect( mbedtls_net_context *ctx, const char *host,
break
;
break
;
}
}
#ifdef USE_LWIP
lwip_close
(
ctx
->
fd
);
#else
close
(
ctx
->
fd
);
close
(
ctx
->
fd
);
#endif
ret
=
MBEDTLS_ERR_NET_CONNECT_FAILED
;
ret
=
MBEDTLS_ERR_NET_CONNECT_FAILED
;
}
}
...
@@ -267,14 +270,22 @@ int mbedtls_net_bind( mbedtls_net_context *ctx, const char *bind_ip, const char
...
@@ -267,14 +270,22 @@ int mbedtls_net_bind( mbedtls_net_context *ctx, const char *bind_ip, const char
if
(
setsockopt
(
ctx
->
fd
,
SOL_SOCKET
,
SO_REUSEADDR
,
if
(
setsockopt
(
ctx
->
fd
,
SOL_SOCKET
,
SO_REUSEADDR
,
(
const
char
*
)
&
n
,
sizeof
(
n
)
)
!=
0
)
(
const
char
*
)
&
n
,
sizeof
(
n
)
)
!=
0
)
{
{
#ifdef USE_LWIP
lwip_close
(
ctx
->
fd
);
#else
close
(
ctx
->
fd
);
close
(
ctx
->
fd
);
#endif
ret
=
MBEDTLS_ERR_NET_SOCKET_FAILED
;
ret
=
MBEDTLS_ERR_NET_SOCKET_FAILED
;
continue
;
continue
;
}
}
if
(
bind
(
ctx
->
fd
,
cur
->
ai_addr
,
MSVC_INT_CAST
cur
->
ai_addrlen
)
!=
0
)
if
(
bind
(
ctx
->
fd
,
cur
->
ai_addr
,
MSVC_INT_CAST
cur
->
ai_addrlen
)
!=
0
)
{
{
#ifdef USE_LWIP
lwip_close
(
ctx
->
fd
);
#else
close
(
ctx
->
fd
);
close
(
ctx
->
fd
);
#endif
ret
=
MBEDTLS_ERR_NET_BIND_FAILED
;
ret
=
MBEDTLS_ERR_NET_BIND_FAILED
;
continue
;
continue
;
}
}
...
@@ -284,7 +295,11 @@ int mbedtls_net_bind( mbedtls_net_context *ctx, const char *bind_ip, const char
...
@@ -284,7 +295,11 @@ int mbedtls_net_bind( mbedtls_net_context *ctx, const char *bind_ip, const char
{
{
if
(
listen
(
ctx
->
fd
,
MBEDTLS_NET_LISTEN_BACKLOG
)
!=
0
)
if
(
listen
(
ctx
->
fd
,
MBEDTLS_NET_LISTEN_BACKLOG
)
!=
0
)
{
{
#ifdef USE_LWIP
lwip_close
(
ctx
->
fd
);
#else
close
(
ctx
->
fd
);
close
(
ctx
->
fd
);
#endif
ret
=
MBEDTLS_ERR_NET_LISTEN_FAILED
;
ret
=
MBEDTLS_ERR_NET_LISTEN_FAILED
;
continue
;
continue
;
}
}
...
@@ -326,8 +341,12 @@ static int net_would_block( const mbedtls_net_context *ctx )
...
@@ -326,8 +341,12 @@ static int net_would_block( const mbedtls_net_context *ctx )
/*
/*
* Never return 'WOULD BLOCK' on a blocking socket
* Never return 'WOULD BLOCK' on a blocking socket
*/
*/
#ifdef USE_LWIP
if
((
lwip_fcntl
(
ctx
->
fd
,
F_GETFL
,
0
)
&
O_NONBLOCK
)
!=
O_NONBLOCK
)
{
#else
if
(
(
fcntl
(
ctx
->
fd
,
F_GETFL
)
&
O_NONBLOCK
)
!=
O_NONBLOCK
)
if
(
(
fcntl
(
ctx
->
fd
,
F_GETFL
)
&
O_NONBLOCK
)
!=
O_NONBLOCK
)
{
{
#endif
errno
=
err
;
errno
=
err
;
return
(
0
);
return
(
0
);
}
}
...
@@ -474,8 +493,12 @@ int mbedtls_net_set_block( mbedtls_net_context *ctx )
...
@@ -474,8 +493,12 @@ int mbedtls_net_set_block( mbedtls_net_context *ctx )
!defined(EFI32)
!defined(EFI32)
u_long
n
=
0
;
u_long
n
=
0
;
return
(
ioctlsocket
(
ctx
->
fd
,
FIONBIO
,
&
n
)
);
return
(
ioctlsocket
(
ctx
->
fd
,
FIONBIO
,
&
n
)
);
#else
#ifdef USE_LWIP
return
lwip_fcntl
(
ctx
->
fd
,
F_SETFL
,
lwip_fcntl
(
ctx
->
fd
,
F_GETFL
,
0
)
&
~
O_NONBLOCK
);
#else
#else
return
(
fcntl
(
ctx
->
fd
,
F_SETFL
,
fcntl
(
ctx
->
fd
,
F_GETFL
)
&
~
O_NONBLOCK
)
);
return
(
fcntl
(
ctx
->
fd
,
F_SETFL
,
fcntl
(
ctx
->
fd
,
F_GETFL
)
&
~
O_NONBLOCK
)
);
#endif // USE_LWIP
#endif
#endif
}
}
...
@@ -485,8 +508,12 @@ int mbedtls_net_set_nonblock( mbedtls_net_context *ctx )
...
@@ -485,8 +508,12 @@ int mbedtls_net_set_nonblock( mbedtls_net_context *ctx )
!defined(EFI32)
!defined(EFI32)
u_long
n
=
1
;
u_long
n
=
1
;
return
(
ioctlsocket
(
ctx
->
fd
,
FIONBIO
,
&
n
)
);
return
(
ioctlsocket
(
ctx
->
fd
,
FIONBIO
,
&
n
)
);
#else
#ifdef USE_LWIP
return
lwip_fcntl
(
ctx
->
fd
,
F_SETFL
,
lwip_fcntl
(
ctx
->
fd
,
F_GETFL
,
0
)
|
O_NONBLOCK
);
#else
#else
return
(
fcntl
(
ctx
->
fd
,
F_SETFL
,
fcntl
(
ctx
->
fd
,
F_GETFL
)
|
O_NONBLOCK
)
);
return
(
fcntl
(
ctx
->
fd
,
F_SETFL
,
fcntl
(
ctx
->
fd
,
F_GETFL
)
|
O_NONBLOCK
)
);
#endif // USE_LWIP
#endif
#endif
}
}
...
@@ -712,8 +739,11 @@ void mbedtls_net_close( mbedtls_net_context *ctx )
...
@@ -712,8 +739,11 @@ void mbedtls_net_close( mbedtls_net_context *ctx )
{
{
if
(
ctx
->
fd
==
-
1
)
if
(
ctx
->
fd
==
-
1
)
return
;
return
;
#ifdef USE_LWIP
lwip_close
(
ctx
->
fd
);
#else
close
(
ctx
->
fd
);
close
(
ctx
->
fd
);
#endif
ctx
->
fd
=
-
1
;
ctx
->
fd
=
-
1
;
}
}
...
@@ -725,9 +755,13 @@ void mbedtls_net_free( mbedtls_net_context *ctx )
...
@@ -725,9 +755,13 @@ void mbedtls_net_free( mbedtls_net_context *ctx )
{
{
if
(
ctx
->
fd
==
-
1
)
if
(
ctx
->
fd
==
-
1
)
return
;
return
;
#ifdef USE_LWIP
lwip_shutdown
(
ctx
->
fd
,
2
);
lwip_close
(
ctx
->
fd
);
#else
shutdown
(
ctx
->
fd
,
2
);
shutdown
(
ctx
->
fd
,
2
);
close
(
ctx
->
fd
);
close
(
ctx
->
fd
);
#endif
ctx
->
fd
=
-
1
;
ctx
->
fd
=
-
1
;
}
}
...
...
mbedtls.gni
浏览文件 @
1a5db09e
...
@@ -139,3 +139,12 @@ if (defined(ohos_lite)) {
...
@@ -139,3 +139,12 @@ if (defined(ohos_lite)) {
MBEDTLS_INLCUDE_DIRS += [ "$MBEDTLSDIR/port/include" ]
MBEDTLS_INLCUDE_DIRS += [ "$MBEDTLSDIR/port/include" ]
}
}
if (product_name == "generic_m55_arm_32_bes_aurora_wear_mini_application") {
MBEDTLS_INLCUDE_DIRS += [ "$MBEDTLSDIR/port/config/compat_lwip" ]
} else if (product_name ==
"generic_m55_arm_32_bes_phoinix_wear_mini_application") {
MBEDTLS_INLCUDE_DIRS += [ "$MBEDTLSDIR/port/config/compat_lwip" ]
} else {
MBEDTLS_INLCUDE_DIRS += [ "$MBEDTLSDIR/port/config/compat_posix" ]
}
port/config/compat_lwip/socket_compat.h
0 → 100644
浏览文件 @
1a5db09e
/*
* Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef MBED_TLS_SOCKET_COMPAT_H
#define MBED_TLS_SOCKET_COMPAT_H
#define USE_LWIP 1
#endif
/* MBED_TLS_SOCKET_COMPAT_H */
port/config/compat_posix/socket_compat.h
0 → 100644
浏览文件 @
1a5db09e
/*
* Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef MBED_TLS_SOCKET_COMPAT_H
#define MBED_TLS_SOCKET_COMPAT_H
#endif
/* MBED_TLS_SOCKET_COMPAT_H */
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录