Unix domain: Various fixes to get apps/examplex/udgram working
This commit is contained in:
parent
e5f820a2cd
commit
0deca5b039
@ -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
|
* 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
|
#undef EXTERN
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -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. */
|
/* Create the half duplex FIFO if it does not already exist. */
|
||||||
|
|
||||||
local_hd_name(conn->lc_path, path);
|
local_hd_name(path, fullpath);
|
||||||
return local_create_fifo(path);
|
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];
|
char fullpath[LOCAL_FULLPATH_LEN];
|
||||||
|
|
||||||
|
@ -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 */
|
/* 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)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
ndbg("ERROR: Failed to create FIFO for %s: %d\n",
|
ndbg("ERROR: Failed to create FIFO for %s: %d\n",
|
||||||
|
@ -152,7 +152,7 @@ int local_send_packet(int fd, FAR const uint8_t *buf, size_t len)
|
|||||||
|
|
||||||
len16 = len;
|
len16 = len;
|
||||||
ret = local_fifo_write(fd, (FAR const uint8_t *)&len16, sizeof(uint16_t));
|
ret = local_fifo_write(fd, (FAR const uint8_t *)&len16, sizeof(uint16_t));
|
||||||
if(ret == OK)
|
if (ret == OK)
|
||||||
{
|
{
|
||||||
/* Send the packet data */
|
/* Send the packet data */
|
||||||
|
|
||||||
|
@ -95,13 +95,17 @@ ssize_t psock_local_sendto(FAR struct socket *psock, FAR const void *buf,
|
|||||||
|
|
||||||
DEBUGASSERT(buf && len <= UINT16_MAX);
|
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 */
|
/* Either not bound to address or it is connected */
|
||||||
|
|
||||||
ndbg("ERROR: Connected or not bound\n");
|
ndbg("ERROR: Connected state\n");
|
||||||
return -EISCONN;
|
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?
|
* 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)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
ndbg("ERROR: Failed to create FIFO for %s: %d\n",
|
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);
|
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 */
|
/* Now we can close the write-only socket descriptor */
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ ssize_t psock_sendto(FAR struct socket *psock, FAR const void *buf,
|
|||||||
{
|
{
|
||||||
socklen_t minlen;
|
socklen_t minlen;
|
||||||
#if defined(CONFIG_NET_UDP) || defined(CONFIG_NET_LOCAL)
|
#if defined(CONFIG_NET_UDP) || defined(CONFIG_NET_LOCAL)
|
||||||
int ret;
|
ssize_t nsent;
|
||||||
#endif
|
#endif
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
@ -209,7 +209,7 @@ ssize_t psock_sendto(FAR struct socket *psock, FAR const void *buf,
|
|||||||
if (psock->s_domain == PF_LOCAL)
|
if (psock->s_domain == PF_LOCAL)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
ret = psock_local_sendto(psock, buf, len, flags, to, tolen);
|
nsent = psock_local_sendto(psock, buf, len, flags, to, tolen);
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_NET_LOCAL */
|
#endif /* CONFIG_NET_LOCAL */
|
||||||
|
|
||||||
@ -218,20 +218,20 @@ ssize_t psock_sendto(FAR struct socket *psock, FAR const void *buf,
|
|||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
ret = psock_udp_sendto(psock, buf, len, flags, to, tolen);
|
nsent = psock_udp_sendto(psock, buf, len, flags, to, tolen);
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_NET_UDP */
|
#endif /* CONFIG_NET_UDP */
|
||||||
|
|
||||||
/* Check if the domain-specific sendto() logic failed */
|
/* Check if the domain-specific sendto() logic failed */
|
||||||
|
|
||||||
if (ret < 0)
|
if (nsent < 0)
|
||||||
{
|
{
|
||||||
ndbg("ERROR: Domain sendto() failed: %d\n", ret);
|
ndbg("ERROR: Unix domain sendto() failed: %d\n", ret);
|
||||||
err = -ret;
|
err = -nsent;
|
||||||
goto errout;
|
goto errout;
|
||||||
}
|
}
|
||||||
|
|
||||||
return OK;
|
return nsent;
|
||||||
#else
|
#else
|
||||||
err = ENOSYS;
|
err = ENOSYS;
|
||||||
#endif /* CONFIG_NET_UDP || CONFIG_NET_LOCAL */
|
#endif /* CONFIG_NET_UDP || CONFIG_NET_LOCAL */
|
||||||
|
Loading…
Reference in New Issue
Block a user