diff --git a/components/dfs/filesystems/lwip/lwip_netdb.c b/components/dfs/filesystems/lwip/lwip_netdb.c index 68714742514cca0e619dd65ef12ab976cb7c4376..1e14dfb093f112f285db0a8786a416216c235f46 100644 --- a/components/dfs/filesystems/lwip/lwip_netdb.c +++ b/components/dfs/filesystems/lwip/lwip_netdb.c @@ -29,6 +29,7 @@ struct hostent *gethostbyname(const char *name) { return lwip_gethostbyname(name); } +RTM_EXPORT(gethostbyname); int gethostbyname_r(const char *name, struct hostent *ret, char *buf, size_t buflen, struct hostent **result, int *h_errnop) @@ -40,6 +41,7 @@ void freeaddrinfo(struct addrinfo *ai) { lwip_freeaddrinfo(ai); } +RTM_EXPORT(freeaddrinfo); int getaddrinfo(const char *nodename, const char *servname, @@ -48,3 +50,4 @@ int getaddrinfo(const char *nodename, { return lwip_getaddrinfo(nodename, servname, hints, res); } +RTM_EXPORT(getaddrinfo); diff --git a/components/dfs/filesystems/lwip/lwip_select.c b/components/dfs/filesystems/lwip/lwip_select.c index 3477b6f1d6eb594b82652c2146a7d527c1b2061f..31d9190cfceb265a8d723c7017ed6f95fc15679d 100644 --- a/components/dfs/filesystems/lwip/lwip_select.c +++ b/components/dfs/filesystems/lwip/lwip_select.c @@ -118,5 +118,6 @@ select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset, return result; } +RTM_EXPORT(select); #endif diff --git a/components/dfs/filesystems/lwip/lwip_sockets.c b/components/dfs/filesystems/lwip/lwip_sockets.c index 346ef7b266378b84da6916855cf048a822f79fa8..6b68378f7d82ac992102b284d509b471ea3ecc9e 100644 --- a/components/dfs/filesystems/lwip/lwip_sockets.c +++ b/components/dfs/filesystems/lwip/lwip_sockets.c @@ -32,154 +32,167 @@ int accept(int s, struct sockaddr *addr, socklen_t *addrlen) { - int new_client = -1; + int new_client = -1; int sock = dfs_lwip_getsocket(s); new_client = lwip_accept(sock, addr, addrlen); - if (new_client != -1) - { - /* this is a new socket, create it in file system fd */ - int fd; - struct dfs_fd *d; - - /* allocate a fd */ - fd = fd_new(); - if (fd < 0) - { - rt_set_errno(-DFS_STATUS_ENOMEM); - lwip_close(sock); - - printf("no fd yet!\n"); - return -1; - } - d = fd_get(fd); - - /* 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*) new_client; - - /* release the ref-count of fd */ - fd_put(d); - + if (new_client != -1) + { + /* this is a new socket, create it in file system fd */ + int fd; + struct dfs_fd *d; + + /* allocate a fd */ + fd = fd_new(); + if (fd < 0) + { + rt_set_errno(-DFS_STATUS_ENOMEM); + lwip_close(sock); + + rt_kprintf("no fd yet!\n"); + return -1; + } + d = fd_get(fd); + + /* 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 *) new_client; + + /* release the ref-count of fd */ + fd_put(d); + return fd; - } + } - return new_client; + return new_client; } +RTM_EXPORT(accept); int bind(int s, const struct sockaddr *name, socklen_t namelen) { int sock = dfs_lwip_getsocket(s); - + return lwip_bind(sock, name, namelen); } +RTM_EXPORT(bind); int shutdown(int s, int how) { int sock; - struct dfs_fd *d; + struct dfs_fd *d; - d = fd_get(s); - if (d == RT_NULL) - { - rt_set_errno(-DFS_STATUS_EBADF); - - return -1; - } + d = fd_get(s); + if (d == RT_NULL) + { + rt_set_errno(-DFS_STATUS_EBADF); - sock = dfs_lwip_getsocket(s); + return -1; + } + + sock = dfs_lwip_getsocket(s); if (lwip_shutdown(sock, how) == 0) { - /* socket has been closed, delete it from file system fd */ - fd_put(d); - fd_put(d); - - return 0; + /* socket has been closed, delete it from file system fd */ + fd_put(d); + fd_put(d); + + return 0; } - return -1; + return -1; } +RTM_EXPORT(shutdown); -int getpeername (int s, struct sockaddr *name, socklen_t *namelen) +int getpeername(int s, struct sockaddr *name, socklen_t *namelen) { int sock = dfs_lwip_getsocket(s); return lwip_getpeername(sock, name, namelen); } +RTM_EXPORT(getpeername); -int getsockname (int s, struct sockaddr *name, socklen_t *namelen) +int getsockname(int s, struct sockaddr *name, socklen_t *namelen) { int sock = dfs_lwip_getsocket(s); - + return lwip_getsockname(sock, name, namelen); } +RTM_EXPORT(getsockname); -int getsockopt (int s, int level, int optname, void *optval, socklen_t *optlen) +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); } +RTM_EXPORT(getsockopt); -int setsockopt (int s, int level, int optname, const void *optval, socklen_t 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); } +RTM_EXPORT(setsockopt); int connect(int s, const struct sockaddr *name, socklen_t namelen) { int sock = dfs_lwip_getsocket(s); - + return lwip_connect(sock, name, namelen); } +RTM_EXPORT(connect); int listen(int s, int backlog) { int sock = dfs_lwip_getsocket(s); - + return lwip_listen(sock, backlog); } +RTM_EXPORT(listen); int recv(int s, void *mem, size_t len, int flags) { int sock = dfs_lwip_getsocket(s); - + return lwip_recv(sock, mem, len, flags); } +RTM_EXPORT(recv); int recvfrom(int s, void *mem, size_t len, int flags, - struct sockaddr *from, socklen_t *fromlen) + struct sockaddr *from, socklen_t *fromlen) { int sock = dfs_lwip_getsocket(s); - + return lwip_recvfrom(sock, mem, len, flags, from, fromlen); } +RTM_EXPORT(recvfrom); 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); } +RTM_EXPORT(send); int sendto(int s, const void *dataptr, size_t size, int flags, - const struct sockaddr *to, socklen_t tolen) + const struct sockaddr *to, socklen_t tolen) { int sock = dfs_lwip_getsocket(s); - + return lwip_sendto(sock, dataptr, size, flags, to, tolen); } +RTM_EXPORT(sendto); int socket(int domain, int type, int protocol) { @@ -207,13 +220,13 @@ int socket(int domain, int type, int protocol) 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; + d->data = (void *) sock; } /* release the ref-count of fd */ @@ -221,4 +234,4 @@ int socket(int domain, int type, int protocol) return fd; } - +RTM_EXPORT(socket); diff --git a/components/dfs/filesystems/lwip/sys/socket.h b/components/dfs/filesystems/lwip/sys/socket.h index 5317e05e4ce61e53949feb6ebe3a17d9e32354cf..b9608d97edd5fbfaa4e21c932ea3f015574ede97 100644 --- a/components/dfs/filesystems/lwip/sys/socket.h +++ b/components/dfs/filesystems/lwip/sys/socket.h @@ -29,9 +29,11 @@ extern "C" { #endif +#include #include typedef uint16_t sa_family_t; +typedef uint16_t in_port_t; struct sockaddr_storage {