Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
rt-thread
提交
8dfc80b4
R
rt-thread
项目概览
BaiXuePrincess
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
8dfc80b4
编写于
5月 01, 2015
作者:
B
Bernard Xiong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[DFS] Add lwIP file system interface for DFS
上级
f111495b
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
556 addition
and
0 deletion
+556
-0
components/dfs/filesystems/lwip/SConscript
components/dfs/filesystems/lwip/SConscript
+11
-0
components/dfs/filesystems/lwip/arpa/inet.h
components/dfs/filesystems/lwip/arpa/inet.h
+30
-0
components/dfs/filesystems/lwip/dfs_lwip.c
components/dfs/filesystems/lwip/dfs_lwip.c
+125
-0
components/dfs/filesystems/lwip/dfs_lwip.h
components/dfs/filesystems/lwip/dfs_lwip.h
+41
-0
components/dfs/filesystems/lwip/lwip_sockets.c
components/dfs/filesystems/lwip/lwip_sockets.c
+164
-0
components/dfs/filesystems/lwip/netdb.c
components/dfs/filesystems/lwip/netdb.c
+50
-0
components/dfs/filesystems/lwip/netdb.h
components/dfs/filesystems/lwip/netdb.h
+48
-0
components/dfs/filesystems/lwip/netinet/in.h
components/dfs/filesystems/lwip/netinet/in.h
+30
-0
components/dfs/filesystems/lwip/sys/socket.h
components/dfs/filesystems/lwip/sys/socket.h
+53
-0
components/net/lwip-1.4.1/src/lwipopts.h
components/net/lwip-1.4.1/src/lwipopts.h
+4
-0
未找到文件。
components/dfs/filesystems/lwip/SConscript
0 → 100644
浏览文件 @
8dfc80b4
# RT-Thread building script for component
from
building
import
*
cwd
=
GetCurrentDir
()
src
=
Glob
(
'*.c'
)
CPPPATH
=
[
cwd
]
group
=
DefineGroup
(
'Filesystem'
,
src
,
depend
=
[
'RT_USING_DFS'
,
'RT_USING_DFS_LWIP'
],
CPPPATH
=
CPPPATH
)
Return
(
'group'
)
components/dfs/filesystems/lwip/arpa/inet.h
0 → 100644
浏览文件 @
8dfc80b4
/*
* File : inet.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2015, RT-Thread Development Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
* 2015-02-17 Bernard First version
*/
#ifndef INET_H__
#define INET_H__
#include <lwip/inet.h>
#endif
components/dfs/filesystems/lwip/dfs_lwip.c
0 → 100644
浏览文件 @
8dfc80b4
/*
* File : dfs_lwip.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2015, RT-Thread Development Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
* 2015-02-17 Bernard First version
*/
#include <rtthread.h>
#include <dfs.h>
#include <dfs_fs.h>
#include "dfs_lwip.h"
int
dfs_lwip_getsocket
(
int
fd
)
{
struct
dfs_fd
*
_dfs_fd
;
_dfs_fd
=
fd_get
(
fd
);
if
(
_dfs_fd
==
RT_NULL
)
return
-
1
;
return
0
;
}
int
dfs_lwip_ioctl
(
struct
dfs_fd
*
file
,
int
cmd
,
void
*
args
)
{
return
-
DFS_STATUS_EIO
;
}
int
dfs_lwip_read
(
struct
dfs_fd
*
file
,
void
*
buf
,
rt_size_t
count
)
{
int
sock
;
sock
=
(
int
)
file
->
data
;
count
=
lwip_read
(
sock
,
buf
,
count
);
return
count
;
}
int
dfs_lwip_write
(
struct
dfs_fd
*
file
,
const
void
*
buf
,
rt_size_t
count
)
{
int
sock
;
sock
=
(
int
)
file
->
data
;
count
=
lwip_write
(
sock
,
buf
,
count
);
return
count
;
}
int
dfs_lwip_close
(
struct
dfs_fd
*
file
)
{
int
sock
;
int
result
;
sock
=
(
int
)
file
->
data
;
result
=
lwip_close
(
sock
);
if
(
result
==
0
)
return
DFS_STATUS_OK
;
return
-
result
;
}
static
const
struct
dfs_filesystem_operation
_lwip_fs_ops
=
{
"lwip"
,
DFS_FS_FLAG_DEFAULT
,
RT_NULL
,
/* mount */
RT_NULL
,
/* unmont */
RT_NULL
,
/* mkfs */
RT_NULL
,
/* statfs */
RT_NULL
,
/* open */
dfs_lwip_close
,
dfs_lwip_ioctl
,
dfs_lwip_read
,
dfs_lwip_write
,
RT_NULL
,
RT_NULL
,
/* lseek */
RT_NULL
,
/* getdents */
RT_NULL
,
/* unlink */
RT_NULL
,
/* stat */
RT_NULL
,
/* rename */
};
static
struct
dfs_filesystem
_lwip_fs
=
{
0
,
/* dev_id */
RT_NULL
,
/* path */
&
_lwip_fs_ops
,
RT_NULL
/* data */
};
struct
dfs_filesystem
*
dfs_lwip_get_fs
(
void
)
{
return
&
_lwip_fs
;
}
/*
NOTE: Beause we don't need to mount lwIP file system, the filesystem_ops is not
registered to the system.
int dfs_lwip_system_init(void)
{
dfs_register(&_lwip_fs_ops);
return 0;
}
INIT_FS_EXPORT(dfs_lwip_system_init);
*/
components/dfs/filesystems/lwip/dfs_lwip.h
0 → 100644
浏览文件 @
8dfc80b4
/*
* File : dfs_lwip.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2015, RT-Thread Development Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
* 2015-02-17 Bernard First version
*/
#ifndef DFS_LWIP_H__
#define DFS_LWIP_H__
#ifdef __cplusplus
extern
"C"
{
#endif
struct
dfs_filesystem
*
dfs_lwip_get_fs
(
void
);
int
dfs_lwip_getsocket
(
int
fd
);
int
dfs_lwip_system_init
(
void
);
#ifdef __cplusplus
}
#endif
#endif
components/dfs/filesystems/lwip/lwip_sockets.c
0 → 100644
浏览文件 @
8dfc80b4
/*
* File : lwip_sockets.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2015, RT-Thread Development Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
* 2015-02-17 Bernard First version
*/
#include <dfs.h>
#include <dfs_def.h>
#include <lwip/sockets.h>
#include <sys/socket.h>
#include "dfs_lwip.h"
int
accept
(
int
s
,
struct
sockaddr
*
addr
,
socklen_t
*
addrlen
)
{
int
sock
=
dfs_lwip_getsocket
(
s
);
return
lwip_accept
(
sock
,
addr
,
addrlen
);
}
int
bind
(
int
s
,
const
struct
sockaddr
*
name
,
socklen_t
namelen
)
{
int
sock
=
dfs_lwip_getsocket
(
s
);
return
lwip_bind
(
sock
,
name
,
namelen
);
}
int
shutdown
(
int
s
,
int
how
)
{
int
sock
=
dfs_lwip_getsocket
(
s
);
return
lwip_shutdown
(
s
,
how
);
}
int
getpeername
(
int
s
,
struct
sockaddr
*
name
,
socklen_t
*
namelen
)
{
int
sock
=
dfs_lwip_getsocket
(
s
);
return
lwip_getpeername
(
sock
,
name
,
namelen
);
}
int
getsockname
(
int
s
,
struct
sockaddr
*
name
,
socklen_t
*
namelen
)
{
int
sock
=
dfs_lwip_getsocket
(
s
);
return
lwip_getsockname
(
sock
,
name
,
namelen
);
}
int
getsockopt
(
int
s
,
int
level
,
int
optname
,
void
*
optval
,
socklen_t
*
optlen
)
{
int
sock
=
dfs_lwip_getsocket
(
s
);
return
lwip_getsockopt
(
sock
,
level
,
optname
,
optval
,
optlen
);
}
int
setsockopt
(
int
s
,
int
level
,
int
optname
,
const
void
*
optval
,
socklen_t
optlen
)
{
int
sock
=
dfs_lwip_getsocket
(
s
);
return
lwip_setsockopt
(
sock
,
level
,
optname
,
optval
,
optlen
);
}
int
connect
(
int
s
,
const
struct
sockaddr
*
name
,
socklen_t
namelen
)
{
int
sock
=
dfs_lwip_getsocket
(
s
);
return
lwip_connect
(
sock
,
name
,
namelen
);
}
int
listen
(
int
s
,
int
backlog
)
{
int
sock
=
dfs_lwip_getsocket
(
s
);
return
lwip_listen
(
sock
,
backlog
);
}
int
recv
(
int
s
,
void
*
mem
,
size_t
len
,
int
flags
)
{
int
sock
=
dfs_lwip_getsocket
(
s
);
return
lwip_recv
(
sock
,
mem
,
len
,
flags
);
}
int
recvfrom
(
int
s
,
void
*
mem
,
size_t
len
,
int
flags
,
struct
sockaddr
*
from
,
socklen_t
*
fromlen
)
{
int
sock
=
dfs_lwip_getsocket
(
s
);
return
lwip_recvfrom
(
sock
,
mem
,
len
,
flags
,
from
,
fromlen
);
}
int
send
(
int
s
,
const
void
*
dataptr
,
size_t
size
,
int
flags
)
{
int
sock
=
dfs_lwip_getsocket
(
s
);
return
lwip_send
(
sock
,
dataptr
,
size
,
flags
);
}
int
sendto
(
int
s
,
const
void
*
dataptr
,
size_t
size
,
int
flags
,
const
struct
sockaddr
*
to
,
socklen_t
tolen
)
{
int
sock
=
dfs_lwip_getsocket
(
s
);
return
lwip_sendto
(
sock
,
dataptr
,
size
,
flags
,
to
,
tolen
);
}
int
socket
(
int
domain
,
int
type
,
int
protocol
)
{
/* create a BSD socket */
int
fd
;
int
sock
;
struct
dfs_fd
*
d
;
/* allocate a fd */
fd
=
fd_new
();
if
(
fd
<
0
)
{
rt_set_errno
(
-
DFS_STATUS_ENOMEM
);
return
-
1
;
}
d
=
fd_get
(
fd
);
/* create socket in lwip and then put it to the dfs_fd */
sock
=
lwip_socket
(
domain
,
type
,
protocol
);
if
(
sock
>
0
)
{
/* this is a socket fd */
d
->
type
=
FT_SOCKET
;
d
->
path
=
RT_NULL
;
d
->
fs
=
dfs_lwip_get_fs
();
d
->
flags
=
DFS_O_RDWR
;
/* set flags as read and write */
d
->
size
=
0
;
d
->
pos
=
0
;
/* set socket to the data of dfs_fd */
d
->
data
=
(
void
*
)
sock
;
}
/* release the ref-count of fd */
fd_put
(
d
);
return
fd
;
}
components/dfs/filesystems/lwip/netdb.c
0 → 100644
浏览文件 @
8dfc80b4
/*
* File : netdb.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2015, RT-Thread Development Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
* 2015-02-17 Bernard First version
*/
#include "netdb.h"
#include <lwip/netdb.h>
struct
hostent
*
gethostbyname
(
const
char
*
name
)
{
return
lwip_gethostbyname
(
name
);
}
int
gethostbyname_r
(
const
char
*
name
,
struct
hostent
*
ret
,
char
*
buf
,
size_t
buflen
,
struct
hostent
**
result
,
int
*
h_errnop
)
{
return
lwip_gethostbyname_r
(
name
,
ret
,
buf
,
buflen
,
result
,
h_errnop
);
}
void
freeaddrinfo
(
struct
addrinfo
*
ai
)
{
lwip_freeaddrinfo
(
ai
);
}
int
getaddrinfo
(
const
char
*
nodename
,
const
char
*
servname
,
const
struct
addrinfo
*
hints
,
struct
addrinfo
**
res
)
{
return
lwip_getaddrinfo
(
nodename
,
servname
,
hints
,
res
);
}
components/dfs/filesystems/lwip/netdb.h
0 → 100644
浏览文件 @
8dfc80b4
/*
* File : netdb.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2015, RT-Thread Development Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
* 2015-02-17 Bernard First version
*/
#ifndef NETDB_H__
#define NETDB_H__
#ifdef __cplusplus
extern
"C"
{
#endif
#include <lwip/netdb.h>
struct
hostent
*
gethostbyname
(
const
char
*
name
);
int
gethostbyname_r
(
const
char
*
name
,
struct
hostent
*
ret
,
char
*
buf
,
size_t
buflen
,
struct
hostent
**
result
,
int
*
h_errnop
);
void
freeaddrinfo
(
struct
addrinfo
*
ai
);
int
getaddrinfo
(
const
char
*
nodename
,
const
char
*
servname
,
const
struct
addrinfo
*
hints
,
struct
addrinfo
**
res
);
#ifdef __cplusplus
}
#endif
#endif
components/dfs/filesystems/lwip/netinet/in.h
0 → 100644
浏览文件 @
8dfc80b4
/*
* File : in.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2015, RT-Thread Development Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
* 2015-02-17 Bernard First version
*/
#ifndef IN_H__
#define IN_H__
#include <lwip/sockets.h>
#endif
components/dfs/filesystems/lwip/sys/socket.h
0 → 100644
浏览文件 @
8dfc80b4
/*
* File : netdb.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2015, RT-Thread Development Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
* 2015-02-17 Bernard First version
*/
#ifndef SOCKET_H__
#define SOCKET_H__
#ifdef __cplusplus
extern
"C"
{
#endif
int
accept
(
int
s
,
struct
sockaddr
*
addr
,
socklen_t
*
addrlen
);
int
bind
(
int
s
,
const
struct
sockaddr
*
name
,
socklen_t
namelen
);
int
shutdown
(
int
s
,
int
how
);
int
getpeername
(
int
s
,
struct
sockaddr
*
name
,
socklen_t
*
namelen
);
int
getsockname
(
int
s
,
struct
sockaddr
*
name
,
socklen_t
*
namelen
);
int
getsockopt
(
int
s
,
int
level
,
int
optname
,
void
*
optval
,
socklen_t
*
optlen
);
int
setsockopt
(
int
s
,
int
level
,
int
optname
,
const
void
*
optval
,
socklen_t
optlen
);
int
connect
(
int
s
,
const
struct
sockaddr
*
name
,
socklen_t
namelen
);
int
listen
(
int
s
,
int
backlog
);
int
recv
(
int
s
,
void
*
mem
,
size_t
len
,
int
flags
);
int
recvfrom
(
int
s
,
void
*
mem
,
size_t
len
,
int
flags
,
struct
sockaddr
*
from
,
socklen_t
*
fromlen
);
int
send
(
int
s
,
const
void
*
dataptr
,
size_t
size
,
int
flags
);
int
sendto
(
int
s
,
const
void
*
dataptr
,
size_t
size
,
int
flags
,
const
struct
sockaddr
*
to
,
socklen_t
tolen
);
int
socket
(
int
domain
,
int
type
,
int
protocol
);
#ifdef __cplusplus
}
#endif
#endif
components/net/lwip-1.4.1/src/lwipopts.h
浏览文件 @
8dfc80b4
...
...
@@ -353,4 +353,8 @@
#define LWIP_RAND rand
#endif
#ifdef RT_USING_DFS_LWIP
#define LWIP_COMPAT_SOCKETS 0
#endif
#endif
/* __LWIPOPTS_H__ */
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录