summaryrefslogtreecommitdiff
path: root/nuttx/net/local
diff options
context:
space:
mode:
Diffstat (limited to 'nuttx/net/local')
-rw-r--r--nuttx/net/local/local.h5
-rw-r--r--nuttx/net/local/local_fifo.c10
-rw-r--r--nuttx/net/local/local_recvfrom.c2
-rw-r--r--nuttx/net/local/local_sendpacket.c2
-rw-r--r--nuttx/net/local/local_sendto.c18
5 files changed, 24 insertions, 13 deletions
diff --git a/nuttx/net/local/local.h b/nuttx/net/local/local.h
index 44a5b2409..7b5356f37 100644
--- a/nuttx/net/local/local.h
+++ b/nuttx/net/local/local.h
@@ -502,7 +502,8 @@ int local_create_fifos(FAR struct local_conn_s *conn);
*
****************************************************************************/
-int local_create_halfduplex(FAR struct local_conn_s *conn);
+int local_create_halfduplex(FAR struct local_conn_s *conn,
+ FAR const char *path);
/****************************************************************************
* Name: local_destroy_fifos
@@ -582,7 +583,7 @@ int local_open_receiver(FAR struct local_conn_s *conn);
*
****************************************************************************/
-int local_open_sender(FAR struct local_conn_s *conn, FAR char *path);
+int local_open_sender(FAR struct local_conn_s *conn, FAR const char *path);
#undef EXTERN
#ifdef __cplusplus
diff --git a/nuttx/net/local/local_fifo.c b/nuttx/net/local/local_fifo.c
index 24439e1dc..85e2468b0 100644
--- a/nuttx/net/local/local_fifo.c
+++ b/nuttx/net/local/local_fifo.c
@@ -320,14 +320,14 @@ int local_create_fifos(FAR struct local_conn_s *conn)
*
****************************************************************************/
-int local_create_halfduplex(FAR struct local_conn_s *conn)
+int local_create_halfduplex(FAR struct local_conn_s *conn, FAR const char *path)
{
- char path[LOCAL_FULLPATH_LEN];
+ char fullpath[LOCAL_FULLPATH_LEN];
/* Create the half duplex FIFO if it does not already exist. */
- local_hd_name(conn->lc_path, path);
- return local_create_fifo(path);
+ local_hd_name(path, fullpath);
+ return local_create_fifo(fullpath);
}
/****************************************************************************
@@ -490,7 +490,7 @@ int local_open_receiver(FAR struct local_conn_s *conn)
*
****************************************************************************/
-int local_open_sender(FAR struct local_conn_s *conn, FAR char *path)
+int local_open_sender(FAR struct local_conn_s *conn, FAR const char *path)
{
char fullpath[LOCAL_FULLPATH_LEN];
diff --git a/nuttx/net/local/local_recvfrom.c b/nuttx/net/local/local_recvfrom.c
index 731b5cc99..cfcf7f325 100644
--- a/nuttx/net/local/local_recvfrom.c
+++ b/nuttx/net/local/local_recvfrom.c
@@ -266,7 +266,7 @@ psock_dgram_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len,
/* Make sure that half duplex FIFO has been created */
- ret = local_create_halfduplex(conn);
+ ret = local_create_halfduplex(conn, conn->lc_path);
if (ret < 0)
{
ndbg("ERROR: Failed to create FIFO for %s: %d\n",
diff --git a/nuttx/net/local/local_sendpacket.c b/nuttx/net/local/local_sendpacket.c
index 3658175d6..d32a09f34 100644
--- a/nuttx/net/local/local_sendpacket.c
+++ b/nuttx/net/local/local_sendpacket.c
@@ -152,7 +152,7 @@ int local_send_packet(int fd, FAR const uint8_t *buf, size_t len)
len16 = len;
ret = local_fifo_write(fd, (FAR const uint8_t *)&len16, sizeof(uint16_t));
- if(ret == OK)
+ if (ret == OK)
{
/* Send the packet data */
diff --git a/nuttx/net/local/local_sendto.c b/nuttx/net/local/local_sendto.c
index 57871b2d9..9c242c87a 100644
--- a/nuttx/net/local/local_sendto.c
+++ b/nuttx/net/local/local_sendto.c
@@ -95,13 +95,17 @@ ssize_t psock_local_sendto(FAR struct socket *psock, FAR const void *buf,
DEBUGASSERT(buf && len <= UINT16_MAX);
- /* Verify that this is a bound, un-connected peer socket */
+ /* Verify that this is not a connected peer socket. It need not be
+ * bound, however. If unbound, recvfrom will see this as a nameless
+ * connection.
+ */
- if (conn->lc_state != LOCAL_STATE_BOUND)
+ if (conn->lc_state != LOCAL_STATE_UNBOUND &&
+ conn->lc_state != LOCAL_STATE_BOUND)
{
/* Either not bound to address or it is connected */
- ndbg("ERROR: Connected or not bound\n");
+ ndbg("ERROR: Connected state\n");
return -EISCONN;
}
@@ -122,7 +126,7 @@ ssize_t psock_local_sendto(FAR struct socket *psock, FAR const void *buf,
* REVISIT: Or should be just make sure that it already exists?
*/
- ret = local_create_halfduplex(conn);
+ ret = local_create_halfduplex(conn, unaddr->sun_path);
if (ret < 0)
{
ndbg("ERROR: Failed to create FIFO for %s: %d\n",
@@ -147,6 +151,12 @@ ssize_t psock_local_sendto(FAR struct socket *psock, FAR const void *buf,
{
ndbg("ERROR: Failed to send the packet: %d\n", ret);
}
+ else
+ {
+ /* local_send_packet returns 0 if all 'len' bytes were sent */
+
+ nsent = len;
+ }
/* Now we can close the write-only socket descriptor */