net: Make si_accept callback optional
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
5dd037c599
commit
c39be172da
@ -59,9 +59,6 @@ static int bluetooth_getpeername(FAR struct socket *psock,
|
||||
FAR struct sockaddr *addr, FAR socklen_t *addrlen);
|
||||
static int bluetooth_connect(FAR struct socket *psock,
|
||||
FAR const struct sockaddr *addr, socklen_t addrlen);
|
||||
static int bluetooth_accept(FAR struct socket *psock,
|
||||
FAR struct sockaddr *addr, FAR socklen_t *addrlen,
|
||||
FAR struct socket *newsock);
|
||||
static int bluetooth_poll_local(FAR struct socket *psock,
|
||||
FAR struct pollfd *fds, bool setup);
|
||||
static int bluetooth_close(FAR struct socket *psock);
|
||||
@ -88,7 +85,7 @@ const struct sock_intf_s g_bluetooth_sockif =
|
||||
bluetooth_getpeername, /* si_getpeername */
|
||||
NULL, /* si_listen */
|
||||
bluetooth_connect, /* si_connect */
|
||||
bluetooth_accept, /* si_accept */
|
||||
NULL, /* si_accept */
|
||||
bluetooth_poll_local, /* si_poll */
|
||||
bluetooth_sendmsg, /* si_sendmsg */
|
||||
bluetooth_recvmsg, /* si_recvmsg */
|
||||
@ -289,58 +286,6 @@ static int bluetooth_connect(FAR struct socket *psock,
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: bluetooth_accept
|
||||
*
|
||||
* Description:
|
||||
* The bluetooth_accept function is used with connection-based socket types
|
||||
* (SOCK_STREAM, SOCK_SEQPACKET and SOCK_RDM). It extracts the first
|
||||
* connection request on the queue of pending connections, creates a new
|
||||
* connected socket with mostly the same properties as 'sockfd', and
|
||||
* allocates a new socket descriptor for the socket, which is returned. The
|
||||
* newly created socket is no longer in the listening state. The original
|
||||
* socket 'sockfd' is unaffected by this call. Per file descriptor flags
|
||||
* are not inherited across an bluetooth_accept.
|
||||
*
|
||||
* The 'sockfd' argument is a socket descriptor that has been created with
|
||||
* socket(), bound to a local address with bind(), and is listening for
|
||||
* connections after a call to listen().
|
||||
*
|
||||
* On return, the 'addr' structure is filled in with the address of the
|
||||
* connecting entity. The 'addrlen' argument initially contains the size
|
||||
* of the structure pointed to by 'addr'; on return it will contain the
|
||||
* actual length of the address returned.
|
||||
*
|
||||
* If no pending connections are present on the queue, and the socket is
|
||||
* not marked as non-blocking, bluetooth_accept blocks the caller until a
|
||||
* connection is present. If the socket is marked non-blocking and no
|
||||
* pending connections are present on the queue, bluetooth_accept returns
|
||||
* EAGAIN.
|
||||
*
|
||||
* Input Parameters:
|
||||
* psock Reference to the listening socket structure
|
||||
* addr Receives the address of the connecting client
|
||||
* addrlen Input: allocated size of 'addr',
|
||||
* Return: returned size of 'addr'
|
||||
* newsock Location to return the accepted socket information.
|
||||
*
|
||||
* Returned Value:
|
||||
* Returns 0 (OK) on success. On failure, it returns a negated errno
|
||||
* value. See accept() for a description of the appropriate error value.
|
||||
*
|
||||
* Assumptions:
|
||||
* The network is locked.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int bluetooth_accept(FAR struct socket *psock,
|
||||
FAR struct sockaddr *addr,
|
||||
FAR socklen_t *addrlen,
|
||||
FAR struct socket *newsock)
|
||||
{
|
||||
return -EAFNOSUPPORT;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: bluetooth_bind
|
||||
*
|
||||
|
@ -53,8 +53,6 @@ static sockcaps_t can_sockcaps(FAR struct socket *psock);
|
||||
static void can_addref(FAR struct socket *psock);
|
||||
static int can_bind(FAR struct socket *psock,
|
||||
FAR const struct sockaddr *addr, socklen_t addrlen);
|
||||
static int can_accept(FAR struct socket *psock, FAR struct sockaddr *addr,
|
||||
FAR socklen_t *addrlen, FAR struct socket *newsock);
|
||||
static int can_poll_local(FAR struct socket *psock, FAR struct pollfd *fds,
|
||||
bool setup);
|
||||
static int can_close(FAR struct socket *psock);
|
||||
@ -73,7 +71,7 @@ const struct sock_intf_s g_can_sockif =
|
||||
NULL, /* si_getpeername */
|
||||
NULL, /* si_listen */
|
||||
NULL, /* si_connect */
|
||||
can_accept, /* si_accept */
|
||||
NULL, /* si_accept */
|
||||
can_poll_local, /* si_poll */
|
||||
can_sendmsg, /* si_sendmsg */
|
||||
can_recvmsg, /* si_recvmsg */
|
||||
@ -335,56 +333,6 @@ static int can_bind(FAR struct socket *psock,
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: can_accept
|
||||
*
|
||||
* Description:
|
||||
* The can_accept function is used with connection-based socket
|
||||
* types (SOCK_STREAM, SOCK_SEQPACKET and SOCK_RDM). It extracts the first
|
||||
* connection request on the queue of pending connections, creates a new
|
||||
* connected socket with mostly the same properties as 'sockfd', and
|
||||
* allocates a new socket descriptor for the socket, which is returned. The
|
||||
* newly created socket is no longer in the listening state. The original
|
||||
* socket 'sockfd' is unaffected by this call. Per file descriptor flags
|
||||
* are not inherited across an inet_accept.
|
||||
*
|
||||
* The 'sockfd' argument is a socket descriptor that has been created with
|
||||
* socket(), bound to a local address with bind(), and is listening for
|
||||
* connections after a call to listen().
|
||||
*
|
||||
* On return, the 'addr' structure is filled in with the address of the
|
||||
* connecting entity. The 'addrlen' argument initially contains the size
|
||||
* of the structure pointed to by 'addr'; on return it will contain the
|
||||
* actual length of the address returned.
|
||||
*
|
||||
* If no pending connections are present on the queue, and the socket is
|
||||
* not marked as non-blocking, inet_accept blocks the caller until a
|
||||
* connection is present. If the socket is marked non-blocking and no
|
||||
* pending connections are present on the queue, inet_accept returns
|
||||
* EAGAIN.
|
||||
*
|
||||
* Input Parameters:
|
||||
* psock Reference to the listening socket structure
|
||||
* addr Receives the address of the connecting client
|
||||
* addrlen Input: Allocated size of 'addr'
|
||||
* Return: Actual size returned size of 'addr'
|
||||
* newsock Location to return the accepted socket information.
|
||||
*
|
||||
* Returned Value:
|
||||
* Returns 0 (OK) on success. On failure, it returns a negated errno
|
||||
* value. See accept() for a description of the appropriate error value.
|
||||
*
|
||||
* Assumptions:
|
||||
* The network is locked.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int can_accept(FAR struct socket *psock, FAR struct sockaddr *addr,
|
||||
FAR socklen_t *addrlen, FAR struct socket *newsock)
|
||||
{
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: can_poll_local
|
||||
*
|
||||
|
@ -47,9 +47,6 @@
|
||||
static int icmp_setup(FAR struct socket *psock);
|
||||
static sockcaps_t icmp_sockcaps(FAR struct socket *psock);
|
||||
static void icmp_addref(FAR struct socket *psock);
|
||||
static int icmp_accept(FAR struct socket *psock,
|
||||
FAR struct sockaddr *addr, FAR socklen_t *addrlen,
|
||||
FAR struct socket *newsock);
|
||||
static int icmp_netpoll(FAR struct socket *psock,
|
||||
FAR struct pollfd *fds, bool setup);
|
||||
static int icmp_close(FAR struct socket *psock);
|
||||
@ -68,7 +65,7 @@ const struct sock_intf_s g_icmp_sockif =
|
||||
NULL, /* si_getpeername */
|
||||
NULL, /* si_listen */
|
||||
NULL, /* si_connect */
|
||||
icmp_accept, /* si_accept */
|
||||
NULL, /* si_accept */
|
||||
icmp_netpoll, /* si_poll */
|
||||
icmp_sendmsg, /* si_sendmsg */
|
||||
icmp_recvmsg, /* si_recvmsg */
|
||||
@ -182,56 +179,6 @@ static void icmp_addref(FAR struct socket *psock)
|
||||
conn->crefs++;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: icmp_accept
|
||||
*
|
||||
* Description:
|
||||
* The icmp_accept function is used with connection-based socket types
|
||||
* (SOCK_STREAM, SOCK_SEQPACKET and SOCK_RDM). It extracts the first
|
||||
* connection request on the queue of pending connections, creates a new
|
||||
* connected socket with mostly the same properties as 'sockfd', and
|
||||
* allocates a new socket descriptor for the socket, which is returned. The
|
||||
* newly created socket is no longer in the listening state. The original
|
||||
* socket 'sockfd' is unaffected by this call. Per file descriptor flags
|
||||
* are not inherited across an icmp_accept.
|
||||
*
|
||||
* The 'sockfd' argument is a socket descriptor that has been created with
|
||||
* socket(), bound to a local address with bind(), and is listening for
|
||||
* connections after a call to listen().
|
||||
*
|
||||
* On return, the 'addr' structure is filled in with the address of the
|
||||
* connecting entity. The 'addrlen' argument initially contains the size
|
||||
* of the structure pointed to by 'addr'; on return it will contain the
|
||||
* actual length of the address returned.
|
||||
*
|
||||
* If no pending connections are present on the queue, and the socket is
|
||||
* not marked as non-blocking, icmp_accept blocks the caller until a
|
||||
* connection is present. If the socket is marked non-blocking and no
|
||||
* pending connections are present on the queue, icmp_accept returns
|
||||
* EAGAIN.
|
||||
*
|
||||
* Input Parameters:
|
||||
* psock Reference to the listening socket structure
|
||||
* addr Receives the address of the connecting client
|
||||
* addrlen Input: allocated size of 'addr',
|
||||
* Return: returned size of 'addr'
|
||||
* newsock Location to return the accepted socket information.
|
||||
*
|
||||
* Returned Value:
|
||||
* Returns 0 (OK) on success. On failure, it returns a negated errno
|
||||
* value. See accept() for a description of the appropriate error value.
|
||||
*
|
||||
* Assumptions:
|
||||
* The network is locked.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int icmp_accept(FAR struct socket *psock, FAR struct sockaddr *addr,
|
||||
FAR socklen_t *addrlen, FAR struct socket *newsock)
|
||||
{
|
||||
return -EAFNOSUPPORT;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: icmp_netpoll
|
||||
*
|
||||
|
@ -47,9 +47,6 @@
|
||||
static int icmpv6_setup(FAR struct socket *psock);
|
||||
static sockcaps_t icmpv6_sockcaps(FAR struct socket *psock);
|
||||
static void icmpv6_addref(FAR struct socket *psock);
|
||||
static int icmpv6_accept(FAR struct socket *psock,
|
||||
FAR struct sockaddr *addr, FAR socklen_t *addrlen,
|
||||
FAR struct socket *newsock);
|
||||
static int icmpv6_netpoll(FAR struct socket *psock,
|
||||
FAR struct pollfd *fds, bool setup);
|
||||
static int icmpv6_close(FAR struct socket *psock);
|
||||
@ -68,7 +65,7 @@ const struct sock_intf_s g_icmpv6_sockif =
|
||||
NULL, /* si_getpeername */
|
||||
NULL, /* si_listen */
|
||||
NULL, /* si_connect */
|
||||
icmpv6_accept, /* si_accept */
|
||||
NULL, /* si_accept */
|
||||
icmpv6_netpoll, /* si_poll */
|
||||
icmpv6_sendmsg, /* si_sendmsg */
|
||||
icmpv6_recvmsg, /* si_recvmsg */
|
||||
@ -182,56 +179,6 @@ static void icmpv6_addref(FAR struct socket *psock)
|
||||
conn->crefs++;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: icmpv6_accept
|
||||
*
|
||||
* Description:
|
||||
* The icmpv6_accept function is used with connection-based socket types
|
||||
* (SOCK_STREAM, SOCK_SEQPACKET and SOCK_RDM). It extracts the first
|
||||
* connection request on the queue of pending connections, creates a new
|
||||
* connected socket with mostly the same properties as 'sockfd', and
|
||||
* allocates a new socket descriptor for the socket, which is returned. The
|
||||
* newly created socket is no longer in the listening state. The original
|
||||
* socket 'sockfd' is unaffected by this call. Per file descriptor flags
|
||||
* are not inherited across an icmpv6_accept.
|
||||
*
|
||||
* The 'sockfd' argument is a socket descriptor that has been created with
|
||||
* socket(), bound to a local address with bind(), and is listening for
|
||||
* connections after a call to listen().
|
||||
*
|
||||
* On return, the 'addr' structure is filled in with the address of the
|
||||
* connecting entity. The 'addrlen' argument initially contains the size
|
||||
* of the structure pointed to by 'addr'; on return it will contain the
|
||||
* actual length of the address returned.
|
||||
*
|
||||
* If no pending connections are present on the queue, and the socket is
|
||||
* not marked as non-blocking, icmpv6_accept blocks the caller until a
|
||||
* connection is present. If the socket is marked non-blocking and no
|
||||
* pending connections are present on the queue, icmpv6_accept returns
|
||||
* EAGAIN.
|
||||
*
|
||||
* Input Parameters:
|
||||
* psock Reference to the listening socket structure
|
||||
* addr Receives the address of the connecting client
|
||||
* addrlen Input: allocated size of 'addr',
|
||||
* Return: returned size of 'addr'
|
||||
* newsock Location to return the accepted socket information.
|
||||
*
|
||||
* Returned Value:
|
||||
* Returns 0 (OK) on success. On failure, it returns a negated errno
|
||||
* value. See accept() for a description of the appropriate error value.
|
||||
*
|
||||
* Assumptions:
|
||||
* The network is locked.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int icmpv6_accept(FAR struct socket *psock, FAR struct sockaddr *addr,
|
||||
FAR socklen_t *addrlen, FAR struct socket *newsock)
|
||||
{
|
||||
return -EAFNOSUPPORT;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: icmpv6_netpoll
|
||||
*
|
||||
|
@ -57,9 +57,6 @@ static int ieee802154_getpeername(FAR struct socket *psock,
|
||||
FAR struct sockaddr *addr, FAR socklen_t *addrlen);
|
||||
static int ieee802154_connect(FAR struct socket *psock,
|
||||
FAR const struct sockaddr *addr, socklen_t addrlen);
|
||||
static int ieee802154_accept(FAR struct socket *psock,
|
||||
FAR struct sockaddr *addr, FAR socklen_t *addrlen,
|
||||
FAR struct socket *newsock);
|
||||
static int ieee802154_poll_local(FAR struct socket *psock,
|
||||
FAR struct pollfd *fds, bool setup);
|
||||
static int ieee802154_close(FAR struct socket *psock);
|
||||
@ -78,7 +75,7 @@ const struct sock_intf_s g_ieee802154_sockif =
|
||||
ieee802154_getpeername, /* si_getpeername */
|
||||
NULL, /* si_listen */
|
||||
ieee802154_connect, /* si_connect */
|
||||
ieee802154_accept, /* si_accept */
|
||||
NULL, /* si_accept */
|
||||
ieee802154_poll_local, /* si_poll */
|
||||
ieee802154_sendmsg, /* si_sendmsg */
|
||||
ieee802154_recvmsg, /* si_recvmsg */
|
||||
@ -278,58 +275,6 @@ static int ieee802154_connect(FAR struct socket *psock,
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ieee802154_accept
|
||||
*
|
||||
* Description:
|
||||
* The ieee802154_accept function is used with connection-based socket
|
||||
* types (SOCK_STREAM, SOCK_SEQPACKET and SOCK_RDM). It extracts the first
|
||||
* connection request on the queue of pending connections, creates a new
|
||||
* connected socket with mostly the same properties as 'sockfd', and
|
||||
* allocates a new socket descriptor for the socket, which is returned. The
|
||||
* newly created socket is no longer in the listening state. The original
|
||||
* socket 'sockfd' is unaffected by this call. Per file descriptor flags
|
||||
* are not inherited across an ieee802154_accept.
|
||||
*
|
||||
* The 'sockfd' argument is a socket descriptor that has been created with
|
||||
* socket(), bound to a local address with bind(), and is listening for
|
||||
* connections after a call to listen().
|
||||
*
|
||||
* On return, the 'addr' structure is filled in with the address of the
|
||||
* connecting entity. The 'addrlen' argument initially contains the size
|
||||
* of the structure pointed to by 'addr'; on return it will contain the
|
||||
* actual length of the address returned.
|
||||
*
|
||||
* If no pending connections are present on the queue, and the socket is
|
||||
* not marked as non-blocking, ieee802154_accept blocks the caller until a
|
||||
* connection is present. If the socket is marked non-blocking and no
|
||||
* pending connections are present on the queue, ieee802154_accept returns
|
||||
* EAGAIN.
|
||||
*
|
||||
* Input Parameters:
|
||||
* psock Reference to the listening socket structure
|
||||
* addr Receives the address of the connecting client
|
||||
* addrlen Input: allocated size of 'addr',
|
||||
* Return: returned size of 'addr'
|
||||
* newsock Location to return the accepted socket information.
|
||||
*
|
||||
* Returned Value:
|
||||
* Returns 0 (OK) on success. On failure, it returns a negated errno
|
||||
* value. See accept() for a description of the appropriate error value.
|
||||
*
|
||||
* Assumptions:
|
||||
* The network is locked.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int ieee802154_accept(FAR struct socket *psock,
|
||||
FAR struct sockaddr *addr,
|
||||
FAR socklen_t *addrlen,
|
||||
FAR struct socket *newsock)
|
||||
{
|
||||
return -EAFNOSUPPORT;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ieee802154_bind
|
||||
*
|
||||
|
@ -58,11 +58,6 @@ static int local_getpeername(FAR struct socket *psock,
|
||||
FAR struct sockaddr *addr, FAR socklen_t *addrlen);
|
||||
static int local_connect(FAR struct socket *psock,
|
||||
FAR const struct sockaddr *addr, socklen_t addrlen);
|
||||
#ifndef CONFIG_NET_LOCAL_STREAM
|
||||
static int local_accept(FAR struct socket *psock,
|
||||
FAR struct sockaddr *addr, FAR socklen_t *addrlen,
|
||||
FAR struct socket *newsock);
|
||||
#endif
|
||||
static int local_poll(FAR struct socket *psock,
|
||||
FAR struct pollfd *fds, bool setup);
|
||||
static int local_close(FAR struct socket *psock);
|
||||
@ -95,7 +90,11 @@ const struct sock_intf_s g_local_sockif =
|
||||
NULL, /* si_listen */
|
||||
#endif
|
||||
local_connect, /* si_connect */
|
||||
#ifdef CONFIG_NET_LOCAL_STREAM
|
||||
local_accept, /* si_accept */
|
||||
#else
|
||||
NULL, /* si_accept */
|
||||
#endif
|
||||
local_poll, /* si_poll */
|
||||
local_sendmsg, /* si_sendmsg */
|
||||
local_recvmsg, /* si_recvmsg */
|
||||
@ -639,58 +638,6 @@ static int local_connect(FAR struct socket *psock,
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: local_accept
|
||||
*
|
||||
* Description:
|
||||
* The pkt_accept function is used with connection-based socket types
|
||||
* (SOCK_STREAM, SOCK_SEQPACKET and SOCK_RDM). It extracts the first
|
||||
* connection request on the queue of pending connections, creates a new
|
||||
* connected socket with mostly the same properties as 'sockfd', and
|
||||
* allocates a new socket descriptor for the socket, which is returned. The
|
||||
* newly created socket is no longer in the listening state. The original
|
||||
* socket 'sockfd' is unaffected by this call. Per file descriptor flags
|
||||
* are not inherited across an pkt_accept.
|
||||
*
|
||||
* The 'sockfd' argument is a socket descriptor that has been created with
|
||||
* socket(), bound to a local address with bind(), and is listening for
|
||||
* connections after a call to listen().
|
||||
*
|
||||
* On return, the 'addr' structure is filled in with the address of the
|
||||
* connecting entity. The 'addrlen' argument initially contains the size
|
||||
* of the structure pointed to by 'addr'; on return it will contain the
|
||||
* actual length of the address returned.
|
||||
*
|
||||
* If no pending connections are present on the queue, and the socket is
|
||||
* not marked as non-blocking, pkt_accept blocks the caller until a
|
||||
* connection is present. If the socket is marked non-blocking and no
|
||||
* pending connections are present on the queue, pkt_accept returns
|
||||
* EAGAIN.
|
||||
*
|
||||
* Input Parameters:
|
||||
* psock Reference to the listening socket structure
|
||||
* addr Receives the address of the connecting client
|
||||
* addrlen Input: allocated size of 'addr',
|
||||
* Return: returned size of 'addr'
|
||||
* newsock Location to return the accepted socket information.
|
||||
*
|
||||
* Returned Value:
|
||||
* Returns 0 (OK) on success. On failure, it returns a negated errno
|
||||
* value. See accept() for a description of the appropriate error value.
|
||||
*
|
||||
* Assumptions:
|
||||
* The network is locked.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_NET_LOCAL_STREAM
|
||||
static int local_accept(FAR struct socket *psock, FAR struct sockaddr *addr,
|
||||
FAR socklen_t *addrlen, FAR struct socket *newsock)
|
||||
{
|
||||
return -EAFNOSUPPORT;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: local_poll
|
||||
*
|
||||
|
@ -58,9 +58,6 @@ static int netlink_getpeername(FAR struct socket *psock,
|
||||
FAR struct sockaddr *addr, FAR socklen_t *addrlen);
|
||||
static int netlink_connect(FAR struct socket *psock,
|
||||
FAR const struct sockaddr *addr, socklen_t addrlen);
|
||||
static int netlink_accept(FAR struct socket *psock,
|
||||
FAR struct sockaddr *addr, FAR socklen_t *addrlen,
|
||||
FAR struct socket *newsock);
|
||||
static int netlink_poll(FAR struct socket *psock, FAR struct pollfd *fds,
|
||||
bool setup);
|
||||
static ssize_t netlink_sendmsg(FAR struct socket *psock,
|
||||
@ -83,7 +80,7 @@ const struct sock_intf_s g_netlink_sockif =
|
||||
netlink_getpeername, /* si_getpeername */
|
||||
NULL, /* si_listen */
|
||||
netlink_connect, /* si_connect */
|
||||
netlink_accept, /* si_accept */
|
||||
NULL, /* si_accept */
|
||||
netlink_poll, /* si_poll */
|
||||
netlink_sendmsg, /* si_sendmsg */
|
||||
netlink_recvmsg, /* si_recvmsg */
|
||||
@ -403,57 +400,6 @@ static int netlink_connect(FAR struct socket *psock,
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: netlink_accept
|
||||
*
|
||||
* Description:
|
||||
* The netlink_accept function is used with connection-based socket
|
||||
* types (SOCK_STREAM, SOCK_SEQPACKET and SOCK_RDM). It extracts the first
|
||||
* connection request on the queue of pending connections, creates a new
|
||||
* connected socket with mostly the same properties as 'sockfd', and
|
||||
* allocates a new socket descriptor for the socket, which is returned. The
|
||||
* newly created socket is no longer in the listening state. The original
|
||||
* socket 'sockfd' is unaffected by this call. Per file descriptor flags
|
||||
* are not inherited across an inet_accept.
|
||||
*
|
||||
* The 'sockfd' argument is a socket descriptor that has been created with
|
||||
* socket(), bound to a local address with bind(), and is listening for
|
||||
* connections after a call to listen().
|
||||
*
|
||||
* On return, the 'addr' structure is filled in with the address of the
|
||||
* connecting entity. The 'addrlen' argument initially contains the size
|
||||
* of the structure pointed to by 'addr'; on return it will contain the
|
||||
* actual length of the address returned.
|
||||
*
|
||||
* If no pending connections are present on the queue, and the socket is
|
||||
* not marked as non-blocking, accept blocks the caller until a
|
||||
* connection is present. If the socket is marked non-blocking and no
|
||||
* pending connections are present on the queue, inet_accept returns
|
||||
* EAGAIN.
|
||||
*
|
||||
* Input Parameters:
|
||||
* psock Reference to the listening socket structure
|
||||
* addr Receives the address of the connecting client
|
||||
* addrlen Input: Allocated size of 'addr'
|
||||
* Return: Actual size returned size of 'addr'
|
||||
* newsock Location to return the accepted socket information.
|
||||
*
|
||||
* Returned Value:
|
||||
* Returns 0 (OK) on success. On failure, it returns a negated errno
|
||||
* value. See accept() for a description of the appropriate error value.
|
||||
*
|
||||
* Assumptions:
|
||||
* The network is locked.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int netlink_accept(FAR struct socket *psock,
|
||||
FAR struct sockaddr *addr, FAR socklen_t *addrlen,
|
||||
FAR struct socket *newsock)
|
||||
{
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: netlink_response_available
|
||||
*
|
||||
|
@ -52,9 +52,6 @@ static sockcaps_t pkt_sockcaps(FAR struct socket *psock);
|
||||
static void pkt_addref(FAR struct socket *psock);
|
||||
static int pkt_bind(FAR struct socket *psock,
|
||||
FAR const struct sockaddr *addr, socklen_t addrlen);
|
||||
static int pkt_accept(FAR struct socket *psock,
|
||||
FAR struct sockaddr *addr, FAR socklen_t *addrlen,
|
||||
FAR struct socket *newsock);
|
||||
static int pkt_poll_local(FAR struct socket *psock,
|
||||
FAR struct pollfd *fds, bool setup);
|
||||
static int pkt_close(FAR struct socket *psock);
|
||||
@ -73,7 +70,7 @@ const struct sock_intf_s g_pkt_sockif =
|
||||
NULL, /* si_getpeername */
|
||||
NULL, /* si_listen */
|
||||
NULL, /* si_connect */
|
||||
pkt_accept, /* si_accept */
|
||||
NULL, /* si_accept */
|
||||
pkt_poll_local, /* si_poll */
|
||||
pkt_sendmsg, /* si_sendmsg */
|
||||
pkt_recvmsg, /* si_recvmsg */
|
||||
@ -203,56 +200,6 @@ static void pkt_addref(FAR struct socket *psock)
|
||||
conn->crefs++;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: pkt_accept
|
||||
*
|
||||
* Description:
|
||||
* The pkt_accept function is used with connection-based socket types
|
||||
* (SOCK_STREAM, SOCK_SEQPACKET and SOCK_RDM). It extracts the first
|
||||
* connection request on the queue of pending connections, creates a new
|
||||
* connected socket with mostly the same properties as 'sockfd', and
|
||||
* allocates a new socket descriptor for the socket, which is returned. The
|
||||
* newly created socket is no longer in the listening state. The original
|
||||
* socket 'sockfd' is unaffected by this call. Per file descriptor flags
|
||||
* are not inherited across an pkt_accept.
|
||||
*
|
||||
* The 'sockfd' argument is a socket descriptor that has been created with
|
||||
* socket(), bound to a local address with bind(), and is listening for
|
||||
* connections after a call to listen().
|
||||
*
|
||||
* On return, the 'addr' structure is filled in with the address of the
|
||||
* connecting entity. The 'addrlen' argument initially contains the size
|
||||
* of the structure pointed to by 'addr'; on return it will contain the
|
||||
* actual length of the address returned.
|
||||
*
|
||||
* If no pending connections are present on the queue, and the socket is
|
||||
* not marked as non-blocking, pkt_accept blocks the caller until a
|
||||
* connection is present. If the socket is marked non-blocking and no
|
||||
* pending connections are present on the queue, pkt_accept returns
|
||||
* EAGAIN.
|
||||
*
|
||||
* Input Parameters:
|
||||
* psock Reference to the listening socket structure
|
||||
* addr Receives the address of the connecting client
|
||||
* addrlen Input: allocated size of 'addr', Return: returned size of
|
||||
* 'addr'
|
||||
* newsock Location to return the accepted socket information.
|
||||
*
|
||||
* Returned Value:
|
||||
* Returns 0 (OK) on success. On failure, it returns a negated errno
|
||||
* value. See accept() for a description of the appropriate error value.
|
||||
*
|
||||
* Assumptions:
|
||||
* The network is locked.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int pkt_accept(FAR struct socket *psock, FAR struct sockaddr *addr,
|
||||
FAR socklen_t *addrlen, FAR struct socket *newsock)
|
||||
{
|
||||
return -EAFNOSUPPORT;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: pkt_bind
|
||||
*
|
||||
|
@ -139,7 +139,11 @@ int psock_accept(FAR struct socket *psock, FAR struct sockaddr *addr,
|
||||
|
||||
/* Let the address family's accept() method handle the operation */
|
||||
|
||||
DEBUGASSERT(psock->s_sockif != NULL && psock->s_sockif->si_accept != NULL);
|
||||
DEBUGASSERT(psock->s_sockif != NULL);
|
||||
if (psock->s_sockif->si_accept == NULL)
|
||||
{
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
net_lock();
|
||||
ret = psock->s_sockif->si_accept(psock, addr, addrlen, newsock);
|
||||
|
Loading…
x
Reference in New Issue
Block a user