diff options
| author | yangjie11 <[email protected]> | 2018-11-28 19:02:11 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2018-11-28 19:02:11 +0800 |
| commit | 1a7f95f92b84b0a3acd6243cb2a658b4f9b6f1ac (patch) | |
| tree | 3b90c3e4b7ced83ce239ae8df020926eaf74d7de /components/net/sal_socket/include | |
| parent | 4a43d3cdae1b731dcf51d3531048c51fd4142516 (diff) | |
| parent | d4469fe7d83d08913d096dc6d75a750dd854c0cc (diff) | |
Merge pull request #1 from RT-Thread/master
test
Diffstat (limited to 'components/net/sal_socket/include')
| -rw-r--r-- | components/net/sal_socket/include/dfs_net/dfs_net.h | 22 | ||||
| -rw-r--r-- | components/net/sal_socket/include/dfs_net/sys_select/sys/select.h | 18 | ||||
| -rw-r--r-- | components/net/sal_socket/include/sal.h | 83 | ||||
| -rw-r--r-- | components/net/sal_socket/include/sal_ipaddr.h | 22 | ||||
| -rw-r--r-- | components/net/sal_socket/include/sal_netdb.h | 26 | ||||
| -rw-r--r-- | components/net/sal_socket/include/sal_socket.h | 30 | ||||
| -rw-r--r-- | components/net/sal_socket/include/sal_tls.h | 68 | ||||
| -rw-r--r-- | components/net/sal_socket/include/sal_type.h | 26 | ||||
| -rw-r--r-- | components/net/sal_socket/include/socket/arpa/inet.h | 18 | ||||
| -rw-r--r-- | components/net/sal_socket/include/socket/netdb.h | 18 | ||||
| -rw-r--r-- | components/net/sal_socket/include/socket/netinet/in.h | 18 | ||||
| -rw-r--r-- | components/net/sal_socket/include/socket/netinet/tcp.h | 18 | ||||
| -rw-r--r-- | components/net/sal_socket/include/socket/netinet/udp.h | 18 | ||||
| -rw-r--r-- | components/net/sal_socket/include/socket/sys_socket/sys/socket.h | 49 |
14 files changed, 201 insertions, 233 deletions
diff --git a/components/net/sal_socket/include/dfs_net/dfs_net.h b/components/net/sal_socket/include/dfs_net/dfs_net.h index 2a21fe3858..ad28b8ec2a 100644 --- a/components/net/sal_socket/include/dfs_net/dfs_net.h +++ b/components/net/sal_socket/include/dfs_net/dfs_net.h @@ -1,21 +1,7 @@ /* - * File : dfs_net.h - * This file is part of RT-Thread RTOS - * COPYRIGHT (C) 2015-2016, RT-Thread Development Team + * Copyright (c) 2006-2018, 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. + * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes @@ -26,12 +12,12 @@ #ifndef DFS_NET_H__ #define DFS_NET_H__ +#include <dfs_file.h> + #ifdef __cplusplus extern "C" { #endif -#include <dfs_file.h> - const struct dfs_file_ops* dfs_net_get_fops(void); int dfs_net_getsocket(int fd); diff --git a/components/net/sal_socket/include/dfs_net/sys_select/sys/select.h b/components/net/sal_socket/include/dfs_net/sys_select/sys/select.h index c2e2d54d3a..8899daee96 100644 --- a/components/net/sal_socket/include/dfs_net/sys_select/sys/select.h +++ b/components/net/sal_socket/include/dfs_net/sys_select/sys/select.h @@ -1,21 +1,7 @@ /* - * File : select.h - * This file is part of RT-Thread RTOS - * COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team + * Copyright (c) 2006-2018, 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. + * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes diff --git a/components/net/sal_socket/include/sal.h b/components/net/sal_socket/include/sal.h index 8a9dd61b67..17d44eef77 100644 --- a/components/net/sal_socket/include/sal.h +++ b/components/net/sal_socket/include/sal.h @@ -1,21 +1,7 @@ /* - * File : sal.h - * This file is part of RT-Thread RTOS - * COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team + * Copyright (c) 2006-2018, 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. + * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes @@ -25,30 +11,39 @@ #ifndef SAL_H__ #define SAL_H__ -#include <dfs_file.h> #include <rtdevice.h> +#ifdef SAL_USING_POSIX +#include <dfs_file.h> +#endif + +#ifdef __cplusplus +extern "C" { +#endif + #if !defined(socklen_t) && !defined(SOCKLEN_T_DEFINED) typedef uint32_t socklen_t; #endif -/* sal socket magic word */ +/* SAL socket magic word */ #define SAL_SOCKET_MAGIC 0x5A10 /* The maximum number of sockets structure */ +#ifndef SAL_SOCKETS_NUM #define SAL_SOCKETS_NUM DFS_FD_MAX +#endif /* The maximum number of protocol families */ #ifndef SAL_PROTO_FAMILIES_NUM #define SAL_PROTO_FAMILIES_NUM 4 #endif -/* sal socket offset */ +/* SAL socket offset */ #ifndef SAL_SOCKET_OFFSET #define SAL_SOCKET_OFFSET 0 #endif -struct proto_ops +struct sal_socket_ops { int (*socket) (int domain, int type, int protocol); int (*closesocket)(int s); @@ -64,38 +59,58 @@ struct proto_ops int (*getpeername)(int s, struct sockaddr *name, socklen_t *namelen); int (*getsockname)(int s, struct sockaddr *name, socklen_t *namelen); int (*ioctlsocket)(int s, long cmd, void *arg); +#ifdef SAL_USING_POSIX int (*poll) (struct dfs_fd *file, struct rt_pollreq *req); +#endif +}; + +struct sal_proto_ops +{ + 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); + int (*getaddrinfo) (const char *nodename, const char *servname, const struct addrinfo *hints, struct addrinfo **res); + void (*freeaddrinfo) (struct addrinfo *ai); }; struct sal_socket { - uint32_t magic; /* sal socket magic word */ + uint32_t magic; /* SAL socket magic word */ - int socket; /* sal socket descriptor */ + int socket; /* SAL socket descriptor */ int domain; int type; int protocol; - const struct proto_ops *ops; /* socket options */ - void *user_data; /* specific sal socket data */ + const struct sal_socket_ops *ops; /* socket options */ + + void *user_data; /* user-specific data */ +#ifdef SAL_USING_TLS + void *user_data_tls; /* user-specific TLS data */ +#endif }; -struct proto_family +struct sal_proto_family { - int family; /* primary protocol families type*/ - int sec_family; /* secondary protocol families type*/ - int (*create)(struct sal_socket *sal_socket, int type, int protocol); /* register socket options */ + int family; /* primary protocol families type */ + int sec_family; /* secondary protocol families type */ + int (*create)(struct sal_socket *sal_socket, int type, int protocol); /* register socket options */ - 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); + struct sal_proto_ops *ops; /* protocol family options */ }; -/* SAL socket initialization */ +/* SAL(Socket Abstraction Layer) initialize */ int sal_init(void); -int sal_proto_family_register(const struct proto_family *pf); struct sal_socket *sal_get_socket(int sock); +/* SAL protocol family register and unregister operate */ +int sal_proto_family_register(const struct sal_proto_family *pf); +int sal_proto_family_unregister(int family); +rt_bool_t sal_proto_family_is_registered(int family); +struct sal_proto_family *sal_proto_family_find(int family); + +#ifdef __cplusplus +} +#endif + #endif /* SAL_H__ */ diff --git a/components/net/sal_socket/include/sal_ipaddr.h b/components/net/sal_socket/include/sal_ipaddr.h index 814d1d16e9..c0562436f0 100644 --- a/components/net/sal_socket/include/sal_ipaddr.h +++ b/components/net/sal_socket/include/sal_ipaddr.h @@ -1,21 +1,7 @@ /* - * File : sal_ipaddr.h - * This file is part of RT-Thread RTOS - * COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team + * Copyright (c) 2006-2018, 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. + * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes @@ -26,6 +12,10 @@ #include "sal_type.h" +#ifdef __cplusplus +extern "C" { +#endif + /** IPv4 only: set the IP address given as an u32_t */ #define ip4_addr_set_u32(dest_ipaddr, src_u32) ((dest_ipaddr)->addr = (src_u32)) /** IPv4 only: get the IP address as an u32_t */ diff --git a/components/net/sal_socket/include/sal_netdb.h b/components/net/sal_socket/include/sal_netdb.h index 12f7abe6b7..3f70832083 100644 --- a/components/net/sal_socket/include/sal_netdb.h +++ b/components/net/sal_socket/include/sal_netdb.h @@ -1,21 +1,7 @@ /* - * File : sal_netdb.h - * This file is part of RT-Thread RTOS - * COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team + * Copyright (c) 2006-2018, 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. + * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes @@ -26,6 +12,10 @@ #include <sal_socket.h> +#ifdef __cplusplus +extern "C" { +#endif + #define EAI_NONAME 200 #define EAI_SERVICE 201 #define EAI_FAIL 202 @@ -88,4 +78,8 @@ int sal_getaddrinfo(const char *nodename, const struct addrinfo *hints, struct addrinfo **res); +#ifdef __cplusplus +} +#endif + #endif /* SAL_NETDB_H__ */ diff --git a/components/net/sal_socket/include/sal_socket.h b/components/net/sal_socket/include/sal_socket.h index 872fd5ca95..0a8597df6e 100644 --- a/components/net/sal_socket/include/sal_socket.h +++ b/components/net/sal_socket/include/sal_socket.h @@ -1,21 +1,7 @@ /* - * File : sal_socket.h - * This file is part of RT-Thread RTOS - * COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team + * Copyright (c) 2006-2018, 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. + * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes @@ -27,6 +13,10 @@ #include "sal_ipaddr.h" +#ifdef __cplusplus +extern "C" { +#endif + #if !defined(socklen_t) && !defined(SOCKLEN_T_DEFINED) typedef uint32_t socklen_t; #endif @@ -81,13 +71,15 @@ typedef uint16_t in_port_t; #define AF_INET6 10 #define AF_CAN 29 /* Controller Area Network */ #define AF_AT 45 /* AT socket */ +#define AF_WIZ 46 /* WIZnet socket */ #define PF_INET AF_INET #define PF_INET6 AF_INET6 #define PF_UNSPEC AF_UNSPEC #define PF_CAN AF_CAN #define PF_AT AF_AT +#define PF_WIZ AF_WIZ -#define AF_MAX (AF_AT + 1) /* For now.. */ +#define AF_MAX (AF_WIZ + 1) /* For now.. */ #define IPPROTO_IP 0 #define IPPROTO_ICMP 1 @@ -175,4 +167,8 @@ int sal_socket(int domain, int type, int protocol); int sal_closesocket(int socket); int sal_ioctlsocket(int socket, long cmd, void *arg); +#ifdef __cplusplus +} +#endif + #endif /* SAL_SOCKET_H__ */ diff --git a/components/net/sal_socket/include/sal_tls.h b/components/net/sal_socket/include/sal_tls.h new file mode 100644 index 0000000000..7681b313bd --- /dev/null +++ b/components/net/sal_socket/include/sal_tls.h @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2006-2018, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2018-11-10 ChenYong First version + */ +#ifndef __SAL_TLS_H__ +#define __SAL_TLS_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include <rtthread.h> + +/* Protocol level for TLS. + * Here, the same socket protocol level for TLS as in Linux was used. + */ +#define SOL_TLS 282 + +/* Socket options for TLS */ + +/* Socket option to select TLS credentials to use. */ +#define TLS_CRET_LIST 1 +/* Socket option to set select ciphersuites to use. */ +#define TLS_CIPHERSUITE_LIST 2 +/* Socket option to set peer verification level for TLS connection. */ +#define TLS_PEER_VERIFY 3 +/* Socket option to set role for DTLS connection. */ +#define TLS_DTLS_ROLE 4 + +/* Protocol numbers for TLS protocols */ +#define PROTOCOL_TLS 256 +#define PROTOCOL_DTLS 257 + + +struct sal_proto_tls_ops +{ + int (*init)(void); + void* (*socket)(int socket); + int (*connect)(void *sock); + int (*send)(void *sock, const void *data, size_t size); + int (*recv)(void *sock, void *mem, size_t len); + int (*closesocket)(void *sock); + + int (*set_cret_list)(void *sock, const void *cert, size_t size); /* Set TLS credentials */ + int (*set_ciphersurite)(void *sock, const void* ciphersurite, size_t size); /* Set select ciphersuites */ + int (*set_peer_verify)(void *sock, const void* peer_verify, size_t size); /* Set peer verification */ + int (*set_dtls_role)(void *sock, const void *dtls_role, size_t size); /* Set role for DTLS */ +}; + +struct sal_proto_tls +{ + char name[RT_NAME_MAX]; /* TLS protocol name */ + const struct sal_proto_tls_ops *ops; /* SAL TLS protocol options */ +}; + +/* SAL TLS protocol register */ +int sal_proto_tls_register(const struct sal_proto_tls *pt); + +#ifdef __cplusplus +} +#endif + +#endif /* __SAL_TLS_H__ */ diff --git a/components/net/sal_socket/include/sal_type.h b/components/net/sal_socket/include/sal_type.h index 0446d5f4e1..6e107ae126 100644 --- a/components/net/sal_socket/include/sal_type.h +++ b/components/net/sal_socket/include/sal_type.h @@ -1,21 +1,7 @@ /* - * File : sal_type.h - * This file is part of RT-Thread RTOS - * COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team + * Copyright (c) 2006-2018, 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. + * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes @@ -28,6 +14,10 @@ #include <stdlib.h> #include <stdint.h> +#ifdef __cplusplus +extern "C" { +#endif + typedef int8_t err_t; typedef uint8_t u8_t; typedef int8_t s8_t; @@ -37,4 +27,8 @@ typedef uint32_t u32_t; typedef int32_t s32_t; typedef uintptr_t mem_ptr_t; +#ifdef __cplusplus +} +#endif + #endif /* SAL_TYPE_H__ */ diff --git a/components/net/sal_socket/include/socket/arpa/inet.h b/components/net/sal_socket/include/socket/arpa/inet.h index e7d856d434..f477df5c23 100644 --- a/components/net/sal_socket/include/socket/arpa/inet.h +++ b/components/net/sal_socket/include/socket/arpa/inet.h @@ -1,21 +1,7 @@ /* - * File : inet.h - * This file is part of RT-Thread RTOS - * COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team + * Copyright (c) 2006-2018, 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. + * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes diff --git a/components/net/sal_socket/include/socket/netdb.h b/components/net/sal_socket/include/socket/netdb.h index c1ffbb826c..17f83efe00 100644 --- a/components/net/sal_socket/include/socket/netdb.h +++ b/components/net/sal_socket/include/socket/netdb.h @@ -1,21 +1,7 @@ /* - * File : netdb.h - * This file is part of RT-Thread RTOS - * COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team + * Copyright (c) 2006-2018, 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. + * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes diff --git a/components/net/sal_socket/include/socket/netinet/in.h b/components/net/sal_socket/include/socket/netinet/in.h index d01a9b3f89..57c417d7b6 100644 --- a/components/net/sal_socket/include/socket/netinet/in.h +++ b/components/net/sal_socket/include/socket/netinet/in.h @@ -1,21 +1,7 @@ /* - * File : in.h - * This file is part of RT-Thread RTOS - * COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team + * Copyright (c) 2006-2018, 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. + * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes diff --git a/components/net/sal_socket/include/socket/netinet/tcp.h b/components/net/sal_socket/include/socket/netinet/tcp.h index aafb0f15d0..2ac4d6f40d 100644 --- a/components/net/sal_socket/include/socket/netinet/tcp.h +++ b/components/net/sal_socket/include/socket/netinet/tcp.h @@ -1,21 +1,7 @@ /* - * File : tcp.h - * This file is part of RT-Thread RTOS - * COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team + * Copyright (c) 2006-2018, 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. + * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes diff --git a/components/net/sal_socket/include/socket/netinet/udp.h b/components/net/sal_socket/include/socket/netinet/udp.h index 4b84755e68..485d7d142c 100644 --- a/components/net/sal_socket/include/socket/netinet/udp.h +++ b/components/net/sal_socket/include/socket/netinet/udp.h @@ -1,21 +1,7 @@ /* - * File : udp.h - * This file is part of RT-Thread RTOS - * COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team + * Copyright (c) 2006-2018, 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. + * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes diff --git a/components/net/sal_socket/include/socket/sys_socket/sys/socket.h b/components/net/sal_socket/include/socket/sys_socket/sys/socket.h index 2b0357ff81..04470aa84a 100644 --- a/components/net/sal_socket/include/socket/sys_socket/sys/socket.h +++ b/components/net/sal_socket/include/socket/sys_socket/sys/socket.h @@ -1,21 +1,7 @@ /* - * File : socket.h - * This file is part of RT-Thread RTOS - * COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team + * Copyright (c) 2006-2018, 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. + * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes @@ -26,19 +12,24 @@ #ifndef SYS_SOCKET_H_ #define SYS_SOCKET_H_ +#include <rtthread.h> #include <sal_socket.h> +#ifdef SAL_USING_TLS +#include <sal_tls.h> +#endif #ifdef __cplusplus extern "C" { #endif +#ifdef SAL_USING_POSIX 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 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); @@ -50,6 +41,24 @@ int sendto(int s, const void *dataptr, size_t size, int flags, int socket(int domain, int type, int protocol); int closesocket(int s); int ioctlsocket(int s, long cmd, void *arg); +#else +#define accept(s, addr, addrlen) sal_accept(s, addr, addrlen) +#define bind(s, name, namelen) sal_bind(s, name, namelen) +#define shutdown(s, how) sal_shutdown(s, how) +#define getpeername(s, name, namelen) sal_getpeername(s, name, namelen) +#define getsockname(s, name, namelen) sal_getsockname(s, name, namelen) +#define getsockopt(s, level, optname, optval, optlen) sal_getsockopt(s, level, optname, optval, optlen) +#define setsockopt(s, level, optname, optval, optlen) sal_setsockopt(s, level, optname, optval, optlen) +#define connect(s, name, namelen) sal_connect(s, name, namelen) +#define listen(s, backlog) sal_listen(s, backlog) +#define recv(s, mem, len, flags) sal_recvfrom(s, mem, len, flags, NULL, NULL) +#define recvfrom(s, mem, len, flags, from, fromlen) sal_recvfrom(s, mem, len, flags, from, fromlen) +#define send(s, dataptr, size, flags) sal_sendto(s, dataptr, size, flags, NULL, NULL) +#define sendto(s, dataptr, size, flags, to, tolen) sal_sendto(s, dataptr, size, flags, to, tolen) +#define socket(domain, type, protocol) sal_socket(domain, type, protocol) +#define closesocket(s) sal_closesocket(s) +#define ioctlsocket(s, cmd, arg) sal_ioctlsocket(s, cmd, arg) +#endif /* SAL_USING_POSIX */ #ifdef __cplusplus } |
