summaryrefslogtreecommitdiff
path: root/components/net/sal_socket/include
diff options
context:
space:
mode:
authorBernard Xiong <[email protected]>2018-08-27 11:04:48 +0800
committerGitHub <[email protected]>2018-08-27 11:04:48 +0800
commit9fdd46fa8be1c453455cb68e2563d426607e841f (patch)
tree35dde3e0a332287e54b78902d0b4ef6957c30718 /components/net/sal_socket/include
parent6bde1c520d2d92fd8505ab85be80b7284efc985c (diff)
parentfc73538153ff2e1b775b0357b0f8df6010a70493 (diff)
Merge pull request #1737 from chenyong111/master
Add query and unregistered protocol family functions,format code
Diffstat (limited to 'components/net/sal_socket/include')
-rw-r--r--components/net/sal_socket/include/dfs_net/dfs_net.h4
-rw-r--r--components/net/sal_socket/include/sal.h21
-rw-r--r--components/net/sal_socket/include/sal_ipaddr.h4
-rw-r--r--components/net/sal_socket/include/sal_netdb.h8
-rw-r--r--components/net/sal_socket/include/sal_socket.h8
-rw-r--r--components/net/sal_socket/include/sal_type.h8
6 files changed, 47 insertions, 6 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..242d3c5334 100644
--- a/components/net/sal_socket/include/dfs_net/dfs_net.h
+++ b/components/net/sal_socket/include/dfs_net/dfs_net.h
@@ -26,12 +26,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/sal.h b/components/net/sal_socket/include/sal.h
index 8a9dd61b67..62ffaa303e 100644
--- a/components/net/sal_socket/include/sal.h
+++ b/components/net/sal_socket/include/sal.h
@@ -28,6 +28,10 @@
#include <dfs_file.h>
#include <rtdevice.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#if !defined(socklen_t) && !defined(SOCKLEN_T_DEFINED)
typedef uint32_t socklen_t;
#endif
@@ -82,8 +86,9 @@ struct sal_socket
struct proto_family
{
- int family; /* primary protocol families type*/
- int sec_family; /* secondary protocol families type*/
+ char name[RT_NAME_MAX];
+ 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);
@@ -92,10 +97,18 @@ struct proto_family
int (*getaddrinfo) (const char *nodename, const char *servname, const struct addrinfo *hints, struct addrinfo **res);
};
-/* 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);
+/* protocol family register and unregister operate */
+int sal_proto_family_register(const struct proto_family *pf);
+int sal_proto_family_unregister(const struct proto_family *pf);
+struct proto_family *sal_proto_family_find(const char *name);
+
+#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..c40fc18374 100644
--- a/components/net/sal_socket/include/sal_ipaddr.h
+++ b/components/net/sal_socket/include/sal_ipaddr.h
@@ -26,6 +26,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..0a31f26fae 100644
--- a/components/net/sal_socket/include/sal_netdb.h
+++ b/components/net/sal_socket/include/sal_netdb.h
@@ -26,6 +26,10 @@
#include <sal_socket.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#define EAI_NONAME 200
#define EAI_SERVICE 201
#define EAI_FAIL 202
@@ -88,4 +92,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..477112392c 100644
--- a/components/net/sal_socket/include/sal_socket.h
+++ b/components/net/sal_socket/include/sal_socket.h
@@ -27,6 +27,10 @@
#include "sal_ipaddr.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#if !defined(socklen_t) && !defined(SOCKLEN_T_DEFINED)
typedef uint32_t socklen_t;
#endif
@@ -175,4 +179,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_type.h b/components/net/sal_socket/include/sal_type.h
index 0446d5f4e1..907b3d02b4 100644
--- a/components/net/sal_socket/include/sal_type.h
+++ b/components/net/sal_socket/include/sal_type.h
@@ -28,6 +28,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 +41,8 @@ typedef uint32_t u32_t;
typedef int32_t s32_t;
typedef uintptr_t mem_ptr_t;
+#ifdef __cplusplus
+}
+#endif
+
#endif /* SAL_TYPE_H__ */