diff --git a/configs/sim/udgram/defconfig b/configs/sim/udgram/defconfig index 641c01ecb99..6a2ce0d88e1 100644 --- a/configs/sim/udgram/defconfig +++ b/configs/sim/udgram/defconfig @@ -385,6 +385,8 @@ CONFIG_NET_NACTIVESOCKETS=16 # Unix Domain Socket Support # CONFIG_NET_LOCAL=y +# CONFIG_NET_LOCAL_STREAM is not set +CONFIG_NET_LOCAL_DGRAM=y # # TCP/IP Networking diff --git a/configs/sim/ustream/defconfig b/configs/sim/ustream/defconfig index 7e453bd1beb..37bdcf61a24 100644 --- a/configs/sim/ustream/defconfig +++ b/configs/sim/ustream/defconfig @@ -385,6 +385,8 @@ CONFIG_NET_NACTIVESOCKETS=16 # Unix Domain Socket Support # CONFIG_NET_LOCAL=y +CONFIG_NET_LOCAL_STREAM=y +# CONFIG_NET_LOCAL_DGRAM is not set # # TCP/IP Networking diff --git a/net/local/Kconfig b/net/local/Kconfig index 73d0f80e7a3..6749ec7d225 100644 --- a/net/local/Kconfig +++ b/net/local/Kconfig @@ -14,6 +14,18 @@ config NET_LOCAL if NET_LOCAL +config NET_LOCAL_STREAM + bool "Unix domain stream sockets" + default y + ---help--- + Enable support for Unix domain SOCK_STREAM type sockets + +config NET_LOCAL_DGRAM + bool "Unix domain datagram sockets" + default y + ---help--- + Enable support for Unix domain SOCK_DGRAM type sockets + endif # NET_LOCAL endmenu # Unix Domain Sockets diff --git a/net/local/Make.defs b/net/local/Make.defs index 864af12960b..1d6f0cbd974 100644 --- a/net/local/Make.defs +++ b/net/local/Make.defs @@ -37,9 +37,16 @@ ifeq ($(CONFIG_NET_LOCAL),y) -NET_CSRCS += local_conn.c local_connect.c local_release.c local_bind.c -NET_CSRCS += local_listen.c local_accept.c local_fifo.c local_recvfrom.c -NET_CSRCS += local_send.c local_sendto.c local_sendpacket.c local_recvutils.c +NET_CSRCS += local_conn.c local_release.c local_bind.c local_fifo.c +NET_CSRCS += local_recvfrom.c local_sendpacket.c local_recvutils.c + +ifeq ($(CONFIG_NET_LOCAL_STREAM),y) +NET_CSRCS += local_connect.c local_listen.c local_accept.c local_send.c +endif + +ifeq ($(CONFIG_NET_LOCAL_DGRAM),y) +NET_CSRCS += local_sendto.c +endif ifneq ($(CONFIG_DISABLE_POLL),y) NET_CSRCS += local_netpoll.c diff --git a/net/local/local.h b/net/local/local.h index eaba4d85a18..3c4bb525c94 100644 --- a/net/local/local.h +++ b/net/local/local.h @@ -140,6 +140,7 @@ struct local_conn_s int16_t lc_outfd; /* File descriptor of write-only FIFO (peers) */ char lc_path[UNIX_PATH_MAX]; /* Path assigned by bind() */ +#ifdef CONFIG_NET_LOCAL_STREAM /* SOCK_STREAM fields common to both client and server */ sem_t lc_waitsem; /* Use to wait for a connection to be accepted */ @@ -174,6 +175,7 @@ struct local_conn_s uint16_t lc_remaining; /* Bytes remaining in the incoming stream */ } peer; } u; +#endif /* CONFIG_NET_LOCAL_STREAM */ }; /**************************************************************************** @@ -188,9 +190,11 @@ extern "C" # define EXTERN extern #endif +#ifdef CONFIG_NET_LOCAL_STREAM /* A list of all SOCK_STREAM listener connections */ EXTERN dq_queue_t g_local_listeners; +#endif /**************************************************************************** * Public Function Prototypes @@ -347,8 +351,10 @@ int psock_local_accept(FAR struct socket *psock, FAR struct sockaddr *addr, * ****************************************************************************/ +#ifdef CONFIG_NET_LOCAL_STREAM ssize_t psock_local_send(FAR struct socket *psock, FAR const void *buf, size_t len, int flags); +#endif /**************************************************************************** * Function: psock_local_sendto @@ -375,9 +381,11 @@ ssize_t psock_local_send(FAR struct socket *psock, FAR const void *buf, * ****************************************************************************/ +#ifdef CONFIG_NET_LOCAL_DGRAM ssize_t psock_local_sendto(FAR struct socket *psock, FAR const void *buf, size_t len, int flags, FAR const struct sockaddr *to, socklen_t tolen); +#endif /**************************************************************************** * Name: local_send_packet @@ -497,7 +505,9 @@ int local_sync(int fd); * ****************************************************************************/ +#ifdef CONFIG_NET_LOCAL_STREAM int local_create_fifos(FAR struct local_conn_s *conn); +#endif /**************************************************************************** * Name: local_create_halfduplex @@ -507,8 +517,10 @@ int local_create_fifos(FAR struct local_conn_s *conn); * ****************************************************************************/ +#ifdef CONFIG_NET_LOCAL_DGRAM int local_create_halfduplex(FAR struct local_conn_s *conn, FAR const char *path); +#endif /**************************************************************************** * Name: local_release_fifos @@ -518,7 +530,9 @@ int local_create_halfduplex(FAR struct local_conn_s *conn, * ****************************************************************************/ +#ifdef CONFIG_NET_LOCAL_STREAM int local_release_fifos(FAR struct local_conn_s *conn); +#endif /**************************************************************************** * Name: local_release_halfduplex @@ -528,7 +542,9 @@ int local_release_fifos(FAR struct local_conn_s *conn); * ****************************************************************************/ +#ifdef CONFIG_NET_LOCAL_DGRAM int local_release_halfduplex(FAR struct local_conn_s *conn); +#endif /**************************************************************************** * Name: local_open_client_rx @@ -538,7 +554,9 @@ int local_release_halfduplex(FAR struct local_conn_s *conn); * ****************************************************************************/ +#ifdef CONFIG_NET_LOCAL_STREAM int local_open_client_rx(FAR struct local_conn_s *client, bool nonblock); +#endif /**************************************************************************** * Name: local_open_client_tx @@ -548,7 +566,9 @@ int local_open_client_rx(FAR struct local_conn_s *client, bool nonblock); * ****************************************************************************/ +#ifdef CONFIG_NET_LOCAL_STREAM int local_open_client_tx(FAR struct local_conn_s *client, bool nonblock); +#endif /**************************************************************************** * Name: local_open_server_rx @@ -558,7 +578,9 @@ int local_open_client_tx(FAR struct local_conn_s *client, bool nonblock); * ****************************************************************************/ +#ifdef CONFIG_NET_LOCAL_STREAM int local_open_server_rx(FAR struct local_conn_s *server, bool nonblock); +#endif /**************************************************************************** * Name: local_open_server_tx @@ -568,7 +590,9 @@ int local_open_server_rx(FAR struct local_conn_s *server, bool nonblock); * ****************************************************************************/ +#ifdef CONFIG_NET_LOCAL_STREAM int local_open_server_tx(FAR struct local_conn_s *server, bool nonblock); +#endif /**************************************************************************** * Name: local_open_receiver @@ -578,7 +602,9 @@ int local_open_server_tx(FAR struct local_conn_s *server, bool nonblock); * ****************************************************************************/ +#ifdef CONFIG_NET_LOCAL_DGRAM int local_open_receiver(FAR struct local_conn_s *conn, bool nonblock); +#endif /**************************************************************************** * Name: local_open_sender @@ -588,8 +614,10 @@ int local_open_receiver(FAR struct local_conn_s *conn, bool nonblock); * ****************************************************************************/ +#ifdef CONFIG_NET_LOCAL_DGRAM int local_open_sender(FAR struct local_conn_s *conn, FAR const char *path, bool nonblock); +#endif #undef EXTERN #ifdef __cplusplus diff --git a/net/local/local_accept.c b/net/local/local_accept.c index c7db57fea97..60816640b7a 100644 --- a/net/local/local_accept.c +++ b/net/local/local_accept.c @@ -38,7 +38,7 @@ ****************************************************************************/ #include -#if defined(CONFIG_NET) && defined(CONFIG_NET_LOCAL) +#if defined(CONFIG_NET) && defined(CONFIG_NET_LOCAL_STREAM) #include #include @@ -223,4 +223,4 @@ int psock_local_accept(FAR struct socket *psock, FAR struct sockaddr *addr, } } -#endif /* CONFIG_NET && CONFIG_NET_LOCAL */ +#endif /* CONFIG_NET && CONFIG_NET_LOCAL_STREAM */ diff --git a/net/local/local_conn.c b/net/local/local_conn.c index d3f021f9261..68006f2d76c 100644 --- a/net/local/local_conn.c +++ b/net/local/local_conn.c @@ -66,7 +66,9 @@ void local_initialize(void) { +#ifdef CONFIG_NET_LOCAL_STREAM dq_init(&g_local_listeners); +#endif } /**************************************************************************** @@ -90,7 +92,9 @@ FAR struct local_conn_s *local_alloc(void) conn->lc_infd = -1; conn->lc_outfd = -1; +#ifdef CONFIG_NET_LOCAL_STREAM sem_init(&conn->lc_waitsem, 0, 0); +#endif } return conn; @@ -123,10 +127,12 @@ void local_free(FAR struct local_conn_s *conn) close(conn->lc_outfd); } +#ifdef CONFIG_NET_LOCAL_STREAM /* Destroy all FIFOs associted with the connection */ local_release_fifos(conn); sem_destroy(&conn->lc_waitsem); +#endif /* And free the connection structure */ diff --git a/net/local/local_connect.c b/net/local/local_connect.c index 5d2f3c6f076..bcb819ff969 100644 --- a/net/local/local_connect.c +++ b/net/local/local_connect.c @@ -38,7 +38,7 @@ ****************************************************************************/ #include -#if defined(CONFIG_NET) && defined(CONFIG_NET_LOCAL) +#if defined(CONFIG_NET) && defined(CONFIG_NET_LOCAL_STREAM) #include #include @@ -315,4 +315,4 @@ int psock_local_connect(FAR struct socket *psock, return -EADDRNOTAVAIL; } -#endif /* CONFIG_NET && CONFIG_NET_LOCAL */ +#endif /* CONFIG_NET && CONFIG_NET_LOCAL_STREAM */ diff --git a/net/local/local_fifo.c b/net/local/local_fifo.c index 6e8ebf06608..42a59fa4c03 100644 --- a/net/local/local_fifo.c +++ b/net/local/local_fifo.c @@ -76,6 +76,7 @@ * ****************************************************************************/ +#ifdef CONFIG_NET_LOCAL_STREAM static inline void local_cs_name(FAR struct local_conn_s *conn, FAR char *path) { @@ -83,6 +84,7 @@ static inline void local_cs_name(FAR struct local_conn_s *conn, conn->lc_path); path[LOCAL_FULLPATH_LEN-1] = '\0'; } +#endif /* CONFIG_NET_LOCAL_STREAM */ /**************************************************************************** * Name: local_sc_name @@ -92,6 +94,7 @@ static inline void local_cs_name(FAR struct local_conn_s *conn, * ****************************************************************************/ +#ifdef CONFIG_NET_LOCAL_STREAM static inline void local_sc_name(FAR struct local_conn_s *conn, FAR char *path) { @@ -99,6 +102,7 @@ static inline void local_sc_name(FAR struct local_conn_s *conn, conn->lc_path); path[LOCAL_FULLPATH_LEN-1] = '\0'; } +#endif /* CONFIG_NET_LOCAL_STREAM */ /**************************************************************************** * Name: local_hd_name @@ -108,11 +112,13 @@ static inline void local_sc_name(FAR struct local_conn_s *conn, * ****************************************************************************/ +#ifdef CONFIG_NET_LOCAL_DGRAM static inline void local_hd_name(FAR const char *inpath, FAR char *outpath) { (void)snprintf(outpath, LOCAL_FULLPATH_LEN-1, "%s" LOCAL_HD_SUFFIX, inpath); outpath[LOCAL_FULLPATH_LEN-1] = '\0'; } +#endif /* CONFIG_NET_LOCAL_DGRAM */ /**************************************************************************** * Name: local_fifo_exists @@ -330,6 +336,7 @@ static int local_set_policy(int fd, unsigned long policy) * ****************************************************************************/ +#ifdef CONFIG_NET_LOCAL_STREAM int local_create_fifos(FAR struct local_conn_s *conn) { char path[LOCAL_FULLPATH_LEN]; @@ -349,6 +356,7 @@ int local_create_fifos(FAR struct local_conn_s *conn) return ret; } +#endif /* CONFIG_NET_LOCAL_STREAM */ /**************************************************************************** * Name: local_create_halfduplex @@ -358,6 +366,7 @@ int local_create_fifos(FAR struct local_conn_s *conn) * ****************************************************************************/ +#ifdef CONFIG_NET_LOCAL_DGRAM int local_create_halfduplex(FAR struct local_conn_s *conn, FAR const char *path) { char fullpath[LOCAL_FULLPATH_LEN]; @@ -367,6 +376,7 @@ int local_create_halfduplex(FAR struct local_conn_s *conn, FAR const char *path) local_hd_name(path, fullpath); return local_create_fifo(fullpath); } +#endif /* CONFIG_NET_LOCAL_DGRAM */ /**************************************************************************** * Name: local_release_fifos @@ -376,6 +386,7 @@ int local_create_halfduplex(FAR struct local_conn_s *conn, FAR const char *path) * ****************************************************************************/ +#ifdef CONFIG_NET_LOCAL_STREAM int local_release_fifos(FAR struct local_conn_s *conn) { char path[LOCAL_FULLPATH_LEN]; @@ -396,6 +407,7 @@ int local_release_fifos(FAR struct local_conn_s *conn) return ret1 < 0 ? ret1 : ret2; } +#endif /* CONFIG_NET_LOCAL_STREAM */ /**************************************************************************** * Name: local_release_halfduplex @@ -405,6 +417,7 @@ int local_release_fifos(FAR struct local_conn_s *conn) * ****************************************************************************/ +#ifdef CONFIG_NET_LOCAL_DGRAM int local_release_halfduplex(FAR struct local_conn_s *conn) { char path[LOCAL_FULLPATH_LEN]; @@ -414,6 +427,7 @@ int local_release_halfduplex(FAR struct local_conn_s *conn) local_hd_name(conn->lc_path, path); return local_release_fifo(path); } +#endif /* CONFIG_NET_LOCAL_DGRAM */ /**************************************************************************** * Name: local_open_client_rx @@ -423,6 +437,7 @@ int local_release_halfduplex(FAR struct local_conn_s *conn) * ****************************************************************************/ +#ifdef CONFIG_NET_LOCAL_STREAM int local_open_client_rx(FAR struct local_conn_s *client, bool nonblock) { char path[LOCAL_FULLPATH_LEN]; @@ -444,6 +459,7 @@ int local_open_client_rx(FAR struct local_conn_s *client, bool nonblock) return ret; } +#endif /* CONFIG_NET_LOCAL_STREAM */ /**************************************************************************** * Name: local_open_client_tx @@ -453,6 +469,7 @@ int local_open_client_rx(FAR struct local_conn_s *client, bool nonblock) * ****************************************************************************/ +#ifdef CONFIG_NET_LOCAL_STREAM int local_open_client_tx(FAR struct local_conn_s *client, bool nonblock) { char path[LOCAL_FULLPATH_LEN]; @@ -474,6 +491,7 @@ int local_open_client_tx(FAR struct local_conn_s *client, bool nonblock) return ret; } +#endif /* CONFIG_NET_LOCAL_STREAM */ /**************************************************************************** * Name: local_open_server_rx @@ -483,6 +501,7 @@ int local_open_client_tx(FAR struct local_conn_s *client, bool nonblock) * ****************************************************************************/ +#ifdef CONFIG_NET_LOCAL_STREAM int local_open_server_rx(FAR struct local_conn_s *server, bool nonblock) { char path[LOCAL_FULLPATH_LEN]; @@ -504,6 +523,7 @@ int local_open_server_rx(FAR struct local_conn_s *server, bool nonblock) return ret; } +#endif /* CONFIG_NET_LOCAL_STREAM */ /**************************************************************************** * Name: local_open_server_tx @@ -513,6 +533,7 @@ int local_open_server_rx(FAR struct local_conn_s *server, bool nonblock) * ****************************************************************************/ +#ifdef CONFIG_NET_LOCAL_STREAM int local_open_server_tx(FAR struct local_conn_s *server, bool nonblock) { char path[LOCAL_FULLPATH_LEN]; @@ -534,6 +555,7 @@ int local_open_server_tx(FAR struct local_conn_s *server, bool nonblock) return ret; } +#endif /* CONFIG_NET_LOCAL_STREAM */ /**************************************************************************** * Name: local_open_receiver @@ -543,6 +565,7 @@ int local_open_server_tx(FAR struct local_conn_s *server, bool nonblock) * ****************************************************************************/ +#ifdef CONFIG_NET_LOCAL_DGRAM int local_open_receiver(FAR struct local_conn_s *conn, bool nonblock) { char path[LOCAL_FULLPATH_LEN]; @@ -564,6 +587,7 @@ int local_open_receiver(FAR struct local_conn_s *conn, bool nonblock) return ret; } +#endif /* CONFIG_NET_LOCAL_DGRAM */ /**************************************************************************** * Name: local_open_sender @@ -573,6 +597,7 @@ int local_open_receiver(FAR struct local_conn_s *conn, bool nonblock) * ****************************************************************************/ +#ifdef CONFIG_NET_LOCAL_DGRAM int local_open_sender(FAR struct local_conn_s *conn, FAR const char *path, bool nonblock) { @@ -595,5 +620,6 @@ int local_open_sender(FAR struct local_conn_s *conn, FAR const char *path, return ret; } +#endif /* CONFIG_NET_LOCAL_DGRAM */ #endif /* CONFIG_NET && CONFIG_NET_LOCAL */ diff --git a/net/local/local_listen.c b/net/local/local_listen.c index 1741988be14..69d0b457c48 100644 --- a/net/local/local_listen.c +++ b/net/local/local_listen.c @@ -38,7 +38,7 @@ ****************************************************************************/ #include -#if defined(CONFIG_NET) && defined(CONFIG_NET_LOCAL) +#if defined(CONFIG_NET) && defined(CONFIG_NET_LOCAL_STREAM) #include #include @@ -148,4 +148,4 @@ int local_listen(FAR struct local_conn_s *server, int backlog) return OK; } -#endif /* CONFIG_NET && CONFIG_NET_LOCAL */ +#endif /* CONFIG_NET && CONFIG_NET_LOCAL_STREAM */ diff --git a/net/local/local_recvfrom.c b/net/local/local_recvfrom.c index 3ceac8bd1a3..1197285e5ab 100644 --- a/net/local/local_recvfrom.c +++ b/net/local/local_recvfrom.c @@ -141,6 +141,7 @@ static int psock_fifo_read(FAR struct socket *psock, FAR void *buf, * ****************************************************************************/ +#ifdef CONFIG_NET_LOCAL_STREAM static inline ssize_t psock_stream_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len, int flags, FAR struct sockaddr *from, @@ -212,6 +213,7 @@ psock_stream_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len, return readlen; } +#endif /* CONFIG_NET_LOCAL_STREAM */ /**************************************************************************** * Function: psock_dgram_recvfrom @@ -234,6 +236,7 @@ psock_stream_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len, * ****************************************************************************/ +#ifdef CONFIG_NET_LOCAL_DGRAM static inline ssize_t psock_dgram_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len, int flags, FAR struct sockaddr *from, @@ -377,6 +380,7 @@ errout_with_halfduplex: (void)local_release_halfduplex(conn); return ret; } +#endif /* CONFIG_NET_LOCAL_STREAM */ /**************************************************************************** * Public Functions @@ -418,15 +422,21 @@ ssize_t psock_local_recvfrom(FAR struct socket *psock, FAR void *buf, /* Check for a stream socket */ +#ifdef CONFIG_NET_LOCAL_STREAM if (psock->s_type == SOCK_STREAM) { return psock_stream_recvfrom(psock, buf, len, flags, from, fromlen); } - else if (psock->s_type == SOCK_DGRAM) + else +#endif + +#ifdef CONFIG_NET_LOCAL_DGRAM + if (psock->s_type == SOCK_DGRAM) { return psock_dgram_recvfrom(psock, buf, len, flags, from, fromlen); } else +#endif { DEBUGPANIC(); ndbg("ERROR: Unrecognized socket type: %s\n", psock->s_type); diff --git a/net/local/local_release.c b/net/local/local_release.c index b7e10b23923..29ea65f2f3b 100644 --- a/net/local/local_release.c +++ b/net/local/local_release.c @@ -76,6 +76,7 @@ int local_release(FAR struct local_conn_s *conn) DEBUGASSERT(conn->lc_crefs == 0); state = net_lock(); +#ifdef CONFIG_NET_LOCAL_STREAM /* We should not bet here with state LOCAL_STATE_ACCEPT. That is an * internal state that should be atomic with respect to socket operations. */ @@ -116,6 +117,7 @@ int local_release(FAR struct local_conn_s *conn) dq_rem(&conn->lc_node, &g_local_listeners); } +#endif /* CONFIG_NET_LOCAL_STREAM */ /* For the remaining states (LOCAL_STATE_UNBOUND and LOCAL_STATE_UNBOUND), * we simply free the connection structure. diff --git a/net/local/local_send.c b/net/local/local_send.c index 7910612e498..272120138d3 100644 --- a/net/local/local_send.c +++ b/net/local/local_send.c @@ -38,7 +38,7 @@ ****************************************************************************/ #include -#if defined(CONFIG_NET) && defined(CONFIG_NET_LOCAL) +#if defined(CONFIG_NET) && defined(CONFIG_NET_LOCAL_STREAM) #include #include @@ -101,4 +101,4 @@ ssize_t psock_local_send(FAR struct socket *psock, FAR const void *buf, return ret < 0 ? ret : len; } -#endif /* CONFIG_NET && CONFIG_NET_LOCAL */ +#endif /* CONFIG_NET && CONFIG_NET_LOCAL_STREAM */ diff --git a/net/local/local_sendto.c b/net/local/local_sendto.c index 63937f72093..a4761413ef2 100644 --- a/net/local/local_sendto.c +++ b/net/local/local_sendto.c @@ -38,7 +38,7 @@ ****************************************************************************/ #include -#if defined(CONFIG_NET) && defined(CONFIG_NET_LOCAL) +#if defined(CONFIG_NET) && defined(CONFIG_NET_LOCAL_DGRAM) #include #include @@ -174,4 +174,4 @@ errout_with_halfduplex: return nsent; } -#endif /* CONFIG_NET && CONFIG_NET_LOCAL */ +#endif /* CONFIG_NET && CONFIG_NET_LOCAL_DGRAM */ diff --git a/net/socket/Make.defs b/net/socket/Make.defs index 0859d28a874..ca4dab4d77f 100644 --- a/net/socket/Make.defs +++ b/net/socket/Make.defs @@ -47,7 +47,7 @@ else # Local Unix domain support -ifeq ($(CONFIG_NET_LOCAL),y) +ifeq ($(CONFIG_NET_LOCAL_STREAM),y) SOCK_CSRCS += send.c listen.c accept.c endif endif diff --git a/net/socket/accept.c b/net/socket/accept.c index 25d009bca60..390776d3306 100644 --- a/net/socket/accept.c +++ b/net/socket/accept.c @@ -39,7 +39,7 @@ #include #if defined(CONFIG_NET) && CONFIG_NSOCKET_DESCRIPTORS > 0 && \ - (defined(CONFIG_NET_TCP) || defined(CONFIG_NET_LOCAL)) + (defined(CONFIG_NET_TCP) || defined(CONFIG_NET_LOCAL_STREAM)) #include #include @@ -217,7 +217,7 @@ int accept(int sockfd, FAR struct sockaddr *addr, FAR socklen_t *addrlen) break; #endif /* CONFIG_NET_IPv6 */ -#ifdef CONFIG_NET_LOCAL +#ifdef CONFIG_NET_LOCAL_STREAM case PF_LOCAL: { if (*addrlen < sizeof(sa_family_t)) @@ -261,7 +261,7 @@ int accept(int sockfd, FAR struct sockaddr *addr, FAR socklen_t *addrlen) /* Perform the correct accept operation for this address domain */ -#ifdef CONFIG_NET_LOCAL +#ifdef CONFIG_NET_LOCAL_STREAM #ifdef CONFIG_NET_TCP if (psock->s_domain == PF_LOCAL) #endif @@ -275,10 +275,10 @@ int accept(int sockfd, FAR struct sockaddr *addr, FAR socklen_t *addrlen) goto errout_with_socket; } } -#endif /* CONFIG_NET_LOCAL */ +#endif /* CONFIG_NET_LOCAL_STREAM */ #ifdef CONFIG_NET_TCP -#ifdef CONFIG_NET_LOCAL +#ifdef CONFIG_NET_LOCAL_STREAM else #endif { @@ -318,4 +318,4 @@ errout: return ERROR; } -#endif /* CONFIG_NET && CONFIG_NSOCKET_DESCRIPTORS && (CONFIG_NET_TCP || CONFIG_NET_LOCAL) */ +#endif /* CONFIG_NET && CONFIG_NSOCKET_DESCRIPTORS && (CONFIG_NET_TCP || CONFIG_NET_LOCAL_STREAM) */ diff --git a/net/socket/bind.c b/net/socket/bind.c index 6407c0add0c..c577dd8c26e 100644 --- a/net/socket/bind.c +++ b/net/socket/bind.c @@ -216,10 +216,10 @@ int psock_bind(FAR struct socket *psock, const struct sockaddr *addr, * domain socket. */ -#if defined(CONFIG_NET_TCP) || defined(CONFIG_NET_LOCAL) +#if defined(CONFIG_NET_TCP) || defined(CONFIG_NET_LOCAL_STREAM) case SOCK_STREAM: { -#ifdef CONFIG_NET_LOCAL +#ifdef CONFIG_NET_LOCAL_STREAM #ifdef CONFIG_NET_TCP /* Is this a Unix domain socket? */ @@ -230,10 +230,10 @@ int psock_bind(FAR struct socket *psock, const struct sockaddr *addr, ret = psock_local_bind(psock, addr, addrlen); } -#endif /* CONFIG_NET_LOCAL */ +#endif /* CONFIG_NET_LOCAL_STREAM */ #ifdef CONFIG_NET_TCP -#ifdef CONFIG_NET_LOCAL +#ifdef CONFIG_NET_LOCAL_STREAM else #endif { @@ -251,16 +251,16 @@ int psock_bind(FAR struct socket *psock, const struct sockaddr *addr, } } break; -#endif /* CONFIG_NET_TCP || CONFIG_NET_LOCAL */ +#endif /* CONFIG_NET_TCP || CONFIG_NET_LOCAL_STREAM */ /* Bind a datagram socket which may either be TCP/IP or a local, Unix * domain socket. */ -#if defined(CONFIG_NET_UDP) || defined(CONFIG_NET_LOCAL) +#if defined(CONFIG_NET_UDP) || defined(CONFIG_NET_LOCAL_DGRAM) case SOCK_DGRAM: { -#ifdef CONFIG_NET_LOCAL +#ifdef CONFIG_NET_LOCAL_DGRAM #ifdef CONFIG_NET_UDP /* Is this a Unix domain socket? */ @@ -271,10 +271,10 @@ int psock_bind(FAR struct socket *psock, const struct sockaddr *addr, ret = psock_local_bind(psock, addr, addrlen); } -#endif /* CONFIG_NET_LOCAL */ +#endif /* CONFIG_NET_LOCAL_DGRAM */ #ifdef CONFIG_NET_UDP -#ifdef CONFIG_NET_LOCAL +#ifdef CONFIG_NET_LOCAL_DGRAM else #endif { @@ -292,7 +292,7 @@ int psock_bind(FAR struct socket *psock, const struct sockaddr *addr, } } break; -#endif /* CONFIG_NET_UDP || CONFIG_NET_LOCAL */ +#endif /* CONFIG_NET_UDP || CONFIG_NET_LOCAL_DGRAM */ default: err = EBADF; diff --git a/net/socket/connect.c b/net/socket/connect.c index 993d66c7ad4..88db09a2e60 100644 --- a/net/socket/connect.c +++ b/net/socket/connect.c @@ -525,7 +525,7 @@ int psock_connect(FAR struct socket *psock, FAR const struct sockaddr *addr, switch (psock->s_type) { -#if defined(CONFIG_NET_TCP) || defined(CONFIG_NET_LOCAL) +#if defined(CONFIG_NET_TCP) || defined(CONFIG_NET_LOCAL_STREAM) case SOCK_STREAM: { /* Verify that the socket is not already connected */ @@ -538,7 +538,7 @@ int psock_connect(FAR struct socket *psock, FAR const struct sockaddr *addr, /* It's not ... connect it */ -#ifdef CONFIG_NET_LOCAL +#ifdef CONFIG_NET_LOCAL_STREAM #ifdef CONFIG_NET_TCP if (psock->s_domain == PF_LOCAL) #endif @@ -547,10 +547,10 @@ int psock_connect(FAR struct socket *psock, FAR const struct sockaddr *addr, ret = psock_local_connect(psock, addr); } -#endif /* CONFIG_NET_LOCAL */ +#endif /* CONFIG_NET_LOCAL_STREAM */ #ifdef CONFIG_NET_TCP -#ifdef CONFIG_NET_LOCAL +#ifdef CONFIG_NET_LOCAL_STREAM else #endif { @@ -567,12 +567,12 @@ int psock_connect(FAR struct socket *psock, FAR const struct sockaddr *addr, } } break; -#endif /* CONFIG_NET_TCP || CONFIG_NET_LOCAL */ +#endif /* CONFIG_NET_TCP || CONFIG_NET_LOCAL_STREAM */ -#if defined(CONFIG_NET_UDP) || defined(CONFIG_NET_LOCAL) +#if defined(CONFIG_NET_UDP) || defined(CONFIG_NET_LOCAL_DGRAM) case SOCK_DGRAM: { -#ifdef CONFIG_NET_LOCAL +#ifdef CONFIG_NET_LOCAL_DGRAM #ifdef CONFIG_NET_UDP if (psock->s_domain == PF_LOCAL) #endif @@ -581,10 +581,10 @@ int psock_connect(FAR struct socket *psock, FAR const struct sockaddr *addr, ret = psock_local_connect(psock, addr); } -#endif /* CONFIG_NET_LOCAL */ +#endif /* CONFIG_NET_LOCAL_DGRAM */ #ifdef CONFIG_NET_UDP -#ifdef CONFIG_NET_LOCAL +#ifdef CONFIG_NET_LOCAL_DGRAM else #endif { @@ -599,7 +599,7 @@ int psock_connect(FAR struct socket *psock, FAR const struct sockaddr *addr, } } break; -#endif /* CONFIG_NET_UDP || CONFIG_NET_LOCAL */ +#endif /* CONFIG_NET_UDP || CONFIG_NET_LOCAL_DGRAM */ default: err = EBADF; diff --git a/net/socket/net_close.c b/net/socket/net_close.c index e33853fa7b1..ce87fcc9a49 100644 --- a/net/socket/net_close.c +++ b/net/socket/net_close.c @@ -533,10 +533,10 @@ int psock_close(FAR struct socket *psock) switch (psock->s_type) { -#if defined(CONFIG_NET_TCP) || defined(CONFIG_NET_LOCAL) +#if defined(CONFIG_NET_TCP) || defined(CONFIG_NET_LOCAL_STREAM) case SOCK_STREAM: { -#ifdef CONFIG_NET_LOCAL +#ifdef CONFIG_NET_LOCAL_STREAM #ifdef CONFIG_NET_TCP if (psock->s_domain == PF_LOCAL) #endif @@ -545,10 +545,10 @@ int psock_close(FAR struct socket *psock) local_close(psock); } -#endif /* CONFIG_NET_LOCAL */ +#endif /* CONFIG_NET_LOCAL_STREAM */ #ifdef CONFIG_NET_TCP -#ifdef CONFIG_NET_LOCAL +#ifdef CONFIG_NET_LOCAL_STREAM else #endif { @@ -584,15 +584,15 @@ int psock_close(FAR struct socket *psock) conn->crefs--; } } -#endif /* CONFIG_NET_TCP */ +#endif /* CONFIG_NET_TCP || CONFIG_NET_LOCAL_STREAM */ } break; #endif -#if defined(CONFIG_NET_UDP) || defined(CONFIG_NET_LOCAL) +#if defined(CONFIG_NET_UDP) || defined(CONFIG_NET_LOCAL_DGRAM) case SOCK_DGRAM: { -#ifdef CONFIG_NET_LOCAL +#ifdef CONFIG_NET_LOCAL_DGRAM #ifdef CONFIG_NET_UDP if (psock->s_domain == PF_LOCAL) #endif @@ -601,10 +601,10 @@ int psock_close(FAR struct socket *psock) local_close(psock); } -#endif /* CONFIG_NET_LOCAL */ +#endif /* CONFIG_NET_LOCAL_DGRAM */ #ifdef CONFIG_NET_UDP -#ifdef CONFIG_NET_LOCAL +#ifdef CONFIG_NET_LOCAL_DGRAM else #endif { @@ -628,7 +628,7 @@ int psock_close(FAR struct socket *psock) conn->crefs--; } } -#endif /* CONFIG_NET_UDP */ +#endif /* CONFIG_NET_UDP || CONFIG_NET_LOCAL_DGRAM */ } break; #endif diff --git a/net/socket/net_vfcntl.c b/net/socket/net_vfcntl.c index ce36ffaa701..ac43604e7d0 100644 --- a/net/socket/net_vfcntl.c +++ b/net/socket/net_vfcntl.c @@ -155,7 +155,7 @@ int net_vfcntl(int sockfd, int cmd, va_list ap) */ if ((0 -#ifdef CONFIG_NET_TCP_LOCAL +#ifdef CONFIG_NET_LOCAL || psock->s_domain == PF_LOCAL /* Unix domain stream or datagram */ #endif #ifdef CONFIG_NET_TCP_READAHEAD @@ -190,7 +190,7 @@ int net_vfcntl(int sockfd, int cmd, va_list ap) */ int mode = va_arg(ap, int); -#if defined(CONFIG_NET_LOCAL) || defined(CONFIG_NET_TCP_READAHEAD) +#if defined(CONFIG_NET_LOCAL_STREAM) || defined(CONFIG_NET_TCP_READAHEAD) if (psock->s_type == SOCK_STREAM) /* IP or Unix domain stream */ { if ((mode & O_NONBLOCK) != 0) @@ -204,7 +204,7 @@ int net_vfcntl(int sockfd, int cmd, va_list ap) } else #endif -#if defined(CONFIG_NET_LOCAL) || defined(CONFIG_NET_UDP_READAHEAD) +#if defined(CONFIG_NET_LOCAL_DGRAM) || defined(CONFIG_NET_UDP_READAHEAD) if (psock->s_type == SOCK_DGRAM) /* IP or Unix domain datagram */ { if ((mode & O_NONBLOCK) != 0) diff --git a/net/socket/recvfrom.c b/net/socket/recvfrom.c index 56523b2fc59..7f10853e803 100644 --- a/net/socket/recvfrom.c +++ b/net/socket/recvfrom.c @@ -1803,10 +1803,10 @@ ssize_t psock_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len, break; #endif /* CONFIG_NET_PKT */ -#if defined(CONFIG_NET_TCP) || defined(CONFIG_NET_LOCAL) +#if defined(CONFIG_NET_TCP) || defined(CONFIG_NET_LOCAL_STREAM) case SOCK_STREAM: { -#ifdef CONFIG_NET_LOCAL +#ifdef CONFIG_NET_LOCAL_STREAM #ifdef CONFIG_NET_TCP if (psock->s_domain == PF_LOCAL) #endif @@ -1814,10 +1814,10 @@ ssize_t psock_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len, ret = psock_local_recvfrom(psock, buf, len, flags, from, fromlen); } -#endif /* CONFIG_NET_LOCAL */ +#endif /* CONFIG_NET_LOCAL_STREAM */ #ifdef CONFIG_NET_TCP -#ifdef CONFIG_NET_LOCAL +#ifdef CONFIG_NET_LOCAL_STREAM else #endif { @@ -1826,12 +1826,12 @@ ssize_t psock_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len, #endif /* CONFIG_NET_TCP */ } break; -#endif /* CONFIG_NET_TCP || CONFIG_NET_LOCAL */ +#endif /* CONFIG_NET_TCP || CONFIG_NET_LOCAL_STREAM */ -#if defined(CONFIG_NET_UDP) || defined(CONFIG_NET_LOCAL) +#if defined(CONFIG_NET_UDP) || defined(CONFIG_NET_LOCAL_DGRAM) case SOCK_DGRAM: { -#ifdef CONFIG_NET_LOCAL +#ifdef CONFIG_NET_LOCAL_DGRAM #ifdef CONFIG_NET_UDP if (psock->s_domain == PF_LOCAL) #endif @@ -1839,10 +1839,10 @@ ssize_t psock_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len, ret = psock_local_recvfrom(psock, buf, len, flags, from, fromlen); } -#endif /* CONFIG_NET_LOCAL */ +#endif /* CONFIG_NET_LOCAL_DGRAM */ #ifdef CONFIG_NET_UDP -#ifdef CONFIG_NET_LOCAL +#ifdef CONFIG_NET_LOCAL_DGRAM else #endif { @@ -1851,7 +1851,7 @@ ssize_t psock_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len, #endif /* CONFIG_NET_UDP */ } break; -#endif /* CONFIG_NET_UDP || CONFIG_NET_LOCAL */ +#endif /* CONFIG_NET_UDP || CONFIG_NET_LOCAL_DGRAM */ default: { diff --git a/net/socket/send.c b/net/socket/send.c index 2886955cb1e..771f4e98066 100644 --- a/net/socket/send.c +++ b/net/socket/send.c @@ -38,7 +38,7 @@ ****************************************************************************/ #include -#if defined(CONFIG_NET_TCP) || defined(CONFIG_NET_LOCAL) +#if defined(CONFIG_NET_TCP) || defined(CONFIG_NET_LOCAL_STREAM) #include #include @@ -144,20 +144,20 @@ ssize_t psock_send(FAR struct socket *psock, FAR const void *buf, size_t len, break; #endif -#if defined(CONFIG_NET_TCP) || defined(CONFIG_NET_LOCAL) +#if defined(CONFIG_NET_TCP) || defined(CONFIG_NET_LOCAL_STREAM) case SOCK_STREAM: { -#ifdef CONFIG_NET_LOCAL +#ifdef CONFIG_NET_LOCAL_STREAM #ifdef CONFIG_NET_TCP if (psock->s_domain == PF_LOCAL) #endif { ret = psock_local_send(psock, buf, len, flags); } -#endif /* CONFIG_NET_LOCAL */ +#endif /* CONFIG_NET_LOCAL_STREAM */ #ifdef CONFIG_NET_TCP -#ifdef CONFIG_NET_LOCAL +#ifdef CONFIG_NET_LOCAL_STREAM else #endif { @@ -166,7 +166,7 @@ ssize_t psock_send(FAR struct socket *psock, FAR const void *buf, size_t len, #endif /* CONFIG_NET_TCP */ } break; -#endif /* CONFIG_NET_TCP || CONFIG_NET_LOCAL */ +#endif /* CONFIG_NET_TCP || CONFIG_NET_LOCAL_STREAM */ default: { @@ -251,4 +251,4 @@ ssize_t send(int sockfd, FAR const void *buf, size_t len, int flags) return psock_send(sockfd_socket(sockfd), buf, len, flags); } -#endif /* CONFIG_NET_TCP || CONFIG_NET_LOCAL */ +#endif /* CONFIG_NET_TCP || CONFIG_NET_LOCAL_STREAM */ diff --git a/net/socket/sendto.c b/net/socket/sendto.c index 23e74b8239e..679fdf74e9c 100644 --- a/net/socket/sendto.c +++ b/net/socket/sendto.c @@ -126,7 +126,7 @@ ssize_t psock_sendto(FAR struct socket *psock, FAR const void *buf, socklen_t tolen) { socklen_t minlen; -#if defined(CONFIG_NET_UDP) || defined(CONFIG_NET_LOCAL) +#if defined(CONFIG_NET_UDP) || defined(CONFIG_NET_LOCAL_DGRAM) ssize_t nsent; #endif int err; @@ -137,10 +137,10 @@ ssize_t psock_sendto(FAR struct socket *psock, FAR const void *buf, if (!to || !tolen) { -#ifdef CONFIG_NET_TCP +#if defined(CONFIG_NET_TCP) || defined(CONFIG_NET_LOCAL_STREAM) return psock_send(psock, buf, len, flags); #else - ndbg("ERROR: No to address\n"); + ndbg("ERROR: No 'to' address\n"); err = EINVAL; goto errout; #endif @@ -162,7 +162,7 @@ ssize_t psock_sendto(FAR struct socket *psock, FAR const void *buf, break; #endif -#ifdef CONFIG_NET_LOCAL +#ifdef CONFIG_NET_LOCAL_DGRAM case AF_LOCAL: minlen = sizeof(sa_family_t); break; @@ -199,22 +199,22 @@ ssize_t psock_sendto(FAR struct socket *psock, FAR const void *buf, goto errout; } -#if defined(CONFIG_NET_UDP) || defined(CONFIG_NET_LOCAL) +#if defined(CONFIG_NET_UDP) || defined(CONFIG_NET_LOCAL_DGRAM) /* Now handle the sendto() operation according to the socket domain, * currently either IP or Unix domains. */ -#ifdef CONFIG_NET_LOCAL +#ifdef CONFIG_NET_LOCAL_DGRAM #ifdef CONFIG_NET_UDP if (psock->s_domain == PF_LOCAL) #endif { nsent = psock_local_sendto(psock, buf, len, flags, to, tolen); } -#endif /* CONFIG_NET_LOCAL */ +#endif /* CONFIG_NET_LOCAL_DGRAM */ #ifdef CONFIG_NET_UDP -#ifdef CONFIG_NET_LOCAL +#ifdef CONFIG_NET_LOCAL_DGRAM else #endif { @@ -234,7 +234,7 @@ ssize_t psock_sendto(FAR struct socket *psock, FAR const void *buf, return nsent; #else err = ENOSYS; -#endif /* CONFIG_NET_UDP || CONFIG_NET_LOCAL */ +#endif /* CONFIG_NET_UDP || CONFIG_NET_LOCAL_DGRAM */ errout: set_errno(err); diff --git a/net/socket/socket.c b/net/socket/socket.c index 7682ba043ce..6e2ea303b1a 100644 --- a/net/socket/socket.c +++ b/net/socket/socket.c @@ -296,10 +296,10 @@ int psock_socket(int domain, int type, int protocol, FAR struct socket *psock) switch (type) { -#if defined(CONFIG_NET_TCP) || defined(CONFIG_NET_LOCAL) +#if defined(CONFIG_NET_TCP) || defined(CONFIG_NET_LOCAL_STREAM) case SOCK_STREAM: #ifdef CONFIG_NET_TCP -#ifdef CONFIG_NET_LOCAL +#ifdef CONFIG_NET_LOCAL_STREAM if (ipdomain) #endif { @@ -311,7 +311,7 @@ int psock_socket(int domain, int type, int protocol, FAR struct socket *psock) } #endif /* CONFIG_NET_TCP */ -#ifdef CONFIG_NET_LOCAL +#ifdef CONFIG_NET_LOCAL_STREAM #ifdef CONFIG_NET_TCP else #endif @@ -322,15 +322,15 @@ int psock_socket(int domain, int type, int protocol, FAR struct socket *psock) goto errout; } } -#endif /* CONFIG_NET_LOCAL */ +#endif /* CONFIG_NET_LOCAL_STREAM */ break; -#endif /* CONFIG_NET_TCP || CONFIG_NET_LOCAL */ +#endif /* CONFIG_NET_TCP || CONFIG_NET_LOCAL_STREAM */ -#if defined(CONFIG_NET_UDP) || defined(CONFIG_NET_LOCAL) +#if defined(CONFIG_NET_UDP) || defined(CONFIG_NET_LOCAL_DGRAM) case SOCK_DGRAM: #ifdef CONFIG_NET_UDP -#ifdef CONFIG_NET_LOCAL +#ifdef CONFIG_NET_LOCAL_DGRAM if (ipdomain) #endif { @@ -342,7 +342,7 @@ int psock_socket(int domain, int type, int protocol, FAR struct socket *psock) } #endif /* CONFIG_NET_UDP */ -#ifdef CONFIG_NET_LOCAL +#ifdef CONFIG_NET_LOCAL_DGRAM #ifdef CONFIG_NET_UDP else #endif @@ -353,10 +353,10 @@ int psock_socket(int domain, int type, int protocol, FAR struct socket *psock) goto errout; } } -#endif /* CONFIG_NET_LOCAL */ +#endif /* CONFIG_NET_LOCAL_DGRAM */ break; -#endif /* CONFIG_NET_UDP || CONFIG_NET_LOCAL */ +#endif /* CONFIG_NET_UDP || CONFIG_NET_LOCAL_DGRAM */ #ifdef CONFIG_NET_PKT case SOCK_RAW: @@ -392,11 +392,11 @@ int psock_socket(int domain, int type, int protocol, FAR struct socket *psock) err = ENOMEM; /* Assume failure to allocate connection instance */ switch (type) { -#if defined(CONFIG_NET_TCP) || defined(CONFIG_NET_LOCAL) +#if defined(CONFIG_NET_TCP) || defined(CONFIG_NET_LOCAL_STREAM) case SOCK_STREAM: { #ifdef CONFIG_NET_TCP -#ifdef CONFIG_NET_LOCAL +#ifdef CONFIG_NET_LOCAL_STREAM if (ipdomain) #endif { @@ -406,7 +406,7 @@ int psock_socket(int domain, int type, int protocol, FAR struct socket *psock) } #endif /* CONFIG_NET_TCP */ -#ifdef CONFIG_NET_LOCAL +#ifdef CONFIG_NET_LOCAL_STREAM #ifdef CONFIG_NET_TCP else #endif @@ -415,7 +415,7 @@ int psock_socket(int domain, int type, int protocol, FAR struct socket *psock) ret = psock_local_alloc(psock); } -#endif /* CONFIG_NET_LOCAL */ +#endif /* CONFIG_NET_LOCAL_STREAM */ /* Check for failures to allocate the connection structure. */ @@ -430,11 +430,11 @@ int psock_socket(int domain, int type, int protocol, FAR struct socket *psock) break; #endif -#if defined(CONFIG_NET_UDP) || defined(CONFIG_NET_LOCAL) +#if defined(CONFIG_NET_UDP) || defined(CONFIG_NET_LOCAL_DGRAM) case SOCK_DGRAM: { #ifdef CONFIG_NET_UDP -#ifdef CONFIG_NET_LOCAL +#ifdef CONFIG_NET_LOCAL_DGRAM if (ipdomain) #endif { @@ -444,7 +444,7 @@ int psock_socket(int domain, int type, int protocol, FAR struct socket *psock) } #endif /* CONFIG_NET_UDP */ -#ifdef CONFIG_NET_LOCAL +#ifdef CONFIG_NET_LOCAL_DGRAM #ifdef CONFIG_NET_UDP else #endif @@ -453,7 +453,7 @@ int psock_socket(int domain, int type, int protocol, FAR struct socket *psock) ret = psock_local_alloc(psock); } -#endif /* CONFIG_NET_LOCAL */ +#endif /* CONFIG_NET_LOCAL_DGRAM */ /* Check for failures to allocate the connection structure. */