net: Make si_connect callback optional
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
a97e2523a4
commit
5dd037c599
@ -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_connect(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,
|
||||
@ -74,7 +72,7 @@ const struct sock_intf_s g_can_sockif =
|
||||
NULL, /* si_getsockname */
|
||||
NULL, /* si_getpeername */
|
||||
NULL, /* si_listen */
|
||||
can_connect, /* si_connect */
|
||||
NULL, /* si_connect */
|
||||
can_accept, /* si_accept */
|
||||
can_poll_local, /* si_poll */
|
||||
can_sendmsg, /* si_sendmsg */
|
||||
@ -337,32 +335,6 @@ static int can_bind(FAR struct socket *psock,
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: can_connect
|
||||
*
|
||||
* Description:
|
||||
* Perform a can connection
|
||||
*
|
||||
* Input Parameters:
|
||||
* psock A reference to the socket structure of the socket
|
||||
* to be connected
|
||||
* addr The address of the remote server to connect to
|
||||
* addrlen Length of address buffer
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
* Assumptions:
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int can_connect(FAR struct socket *psock,
|
||||
FAR const struct sockaddr *addr,
|
||||
socklen_t addrlen)
|
||||
{
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: can_accept
|
||||
*
|
||||
|
@ -47,8 +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_connect(FAR struct socket *psock,
|
||||
FAR const struct sockaddr *addr, socklen_t addrlen);
|
||||
static int icmp_accept(FAR struct socket *psock,
|
||||
FAR struct sockaddr *addr, FAR socklen_t *addrlen,
|
||||
FAR struct socket *newsock);
|
||||
@ -69,7 +67,7 @@ const struct sock_intf_s g_icmp_sockif =
|
||||
NULL, /* si_getsockname */
|
||||
NULL, /* si_getpeername */
|
||||
NULL, /* si_listen */
|
||||
icmp_connect, /* si_connect */
|
||||
NULL, /* si_connect */
|
||||
icmp_accept, /* si_accept */
|
||||
icmp_netpoll, /* si_poll */
|
||||
icmp_sendmsg, /* si_sendmsg */
|
||||
@ -184,44 +182,6 @@ static void icmp_addref(FAR struct socket *psock)
|
||||
conn->crefs++;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: icmp_connect
|
||||
*
|
||||
* Description:
|
||||
* icmp_connect() connects the local socket referred to by the structure
|
||||
* 'psock' to the address specified by 'addr'. The addrlen argument
|
||||
* specifies the size of 'addr'. The format of the address in 'addr' is
|
||||
* determined by the address space of the socket 'psock'.
|
||||
*
|
||||
* If the socket 'psock' is of type SOCK_DGRAM then 'addr' is the address
|
||||
* to which datagrams are sent by default, and the only address from which
|
||||
* datagrams are received. If the socket is of type SOCK_STREAM or
|
||||
* SOCK_SEQPACKET, this call attempts to make a connection to the socket
|
||||
* that is bound to the address specified by 'addr'.
|
||||
*
|
||||
* Generally, connection-based protocol sockets may successfully
|
||||
* icmp_connect() only once; connectionless protocol sockets may use
|
||||
* icmp_connect() multiple times to change their association.
|
||||
* Connectionless sockets may dissolve the association by connecting to
|
||||
* an address with the sa_family member of sockaddr set to AF_UNSPEC.
|
||||
*
|
||||
* Input Parameters:
|
||||
* psock Pointer to a socket structure initialized by psock_socket()
|
||||
* addr Server address (form depends on type of socket)
|
||||
* addrlen Length of actual 'addr'
|
||||
*
|
||||
* Returned Value:
|
||||
* 0 on success; a negated errno value on failure. See connect() for the
|
||||
* list of appropriate errno values to be returned.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int icmp_connect(FAR struct socket *psock,
|
||||
FAR const struct sockaddr *addr, socklen_t addrlen)
|
||||
{
|
||||
return -EAFNOSUPPORT;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: icmp_accept
|
||||
*
|
||||
|
@ -47,8 +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_connect(FAR struct socket *psock,
|
||||
FAR const struct sockaddr *addr, socklen_t addrlen);
|
||||
static int icmpv6_accept(FAR struct socket *psock,
|
||||
FAR struct sockaddr *addr, FAR socklen_t *addrlen,
|
||||
FAR struct socket *newsock);
|
||||
@ -69,7 +67,7 @@ const struct sock_intf_s g_icmpv6_sockif =
|
||||
NULL, /* si_getsockname */
|
||||
NULL, /* si_getpeername */
|
||||
NULL, /* si_listen */
|
||||
icmpv6_connect, /* si_connect */
|
||||
NULL, /* si_connect */
|
||||
icmpv6_accept, /* si_accept */
|
||||
icmpv6_netpoll, /* si_poll */
|
||||
icmpv6_sendmsg, /* si_sendmsg */
|
||||
@ -184,44 +182,6 @@ static void icmpv6_addref(FAR struct socket *psock)
|
||||
conn->crefs++;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: icmpv6_connect
|
||||
*
|
||||
* Description:
|
||||
* icmpv6_connect() connects the local socket referred to by the structure
|
||||
* 'psock' to the address specified by 'addr'. The addrlen argument
|
||||
* specifies the size of 'addr'. The format of the address in 'addr' is
|
||||
* determined by the address space of the socket 'psock'.
|
||||
*
|
||||
* If the socket 'psock' is of type SOCK_DGRAM then 'addr' is the address
|
||||
* to which datagrams are sent by default, and the only address from which
|
||||
* datagrams are received. If the socket is of type SOCK_STREAM or
|
||||
* SOCK_SEQPACKET, this call attempts to make a connection to the socket
|
||||
* that is bound to the address specified by 'addr'.
|
||||
*
|
||||
* Generally, connection-based protocol sockets may successfully
|
||||
* icmpv6_connect() only once; connectionless protocol sockets may use
|
||||
* icmpv6_connect() multiple times to change their association.
|
||||
* Connectionless sockets may dissolve the association by connecting to
|
||||
* an address with the sa_family member of sockaddr set to AF_UNSPEC.
|
||||
*
|
||||
* Input Parameters:
|
||||
* psock Pointer to a socket structure initialized by psock_socket()
|
||||
* addr Server address (form depends on type of socket)
|
||||
* addrlen Length of actual 'addr'
|
||||
*
|
||||
* Returned Value:
|
||||
* 0 on success; a negated errno value on failure. See connect() for the
|
||||
* list of appropriate errno values to be returned.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int icmpv6_connect(FAR struct socket *psock,
|
||||
FAR const struct sockaddr *addr, socklen_t addrlen)
|
||||
{
|
||||
return -EAFNOSUPPORT;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: icmpv6_accept
|
||||
*
|
||||
|
@ -52,8 +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_connect(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);
|
||||
@ -74,7 +72,7 @@ const struct sock_intf_s g_pkt_sockif =
|
||||
NULL, /* si_getsockname */
|
||||
NULL, /* si_getpeername */
|
||||
NULL, /* si_listen */
|
||||
pkt_connect, /* si_connect */
|
||||
NULL, /* si_connect */
|
||||
pkt_accept, /* si_accept */
|
||||
pkt_poll_local, /* si_poll */
|
||||
pkt_sendmsg, /* si_sendmsg */
|
||||
@ -205,44 +203,6 @@ static void pkt_addref(FAR struct socket *psock)
|
||||
conn->crefs++;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: pkt_connect
|
||||
*
|
||||
* Description:
|
||||
* pkt_connect() connects the local socket referred to by the structure
|
||||
* 'psock' to the address specified by 'addr'. The addrlen argument
|
||||
* specifies the size of 'addr'. The format of the address in 'addr' is
|
||||
* determined by the address space of the socket 'psock'.
|
||||
*
|
||||
* If the socket 'psock' is of type SOCK_DGRAM then 'addr' is the address
|
||||
* to which datagrams are sent by default, and the only address from which
|
||||
* datagrams are received. If the socket is of type SOCK_STREAM or
|
||||
* SOCK_SEQPACKET, this call attempts to make a connection to the socket
|
||||
* that is bound to the address specified by 'addr'.
|
||||
*
|
||||
* Generally, connection-based protocol sockets may successfully
|
||||
* pkt_connect() only once; connectionless protocol sockets may use
|
||||
* pkt_connect() multiple times to change their association.
|
||||
* Connectionless sockets may dissolve the association by connecting to
|
||||
* an address with the sa_family member of sockaddr set to AF_UNSPEC.
|
||||
*
|
||||
* Input Parameters:
|
||||
* psock Pointer to a socket structure initialized by psock_socket()
|
||||
* addr Server address (form depends on type of socket)
|
||||
* addrlen Length of actual 'addr'
|
||||
*
|
||||
* Returned Value:
|
||||
* 0 on success; a negated errno value on failure. See connect() for the
|
||||
* list of appropriate errno values to be returned.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int pkt_connect(FAR struct socket *psock,
|
||||
FAR const struct sockaddr *addr, socklen_t addrlen)
|
||||
{
|
||||
return -EAFNOSUPPORT;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: pkt_accept
|
||||
*
|
||||
|
@ -134,8 +134,12 @@ int psock_connect(FAR struct socket *psock, FAR const struct sockaddr *addr,
|
||||
|
||||
/* Let the address family's connect() method handle the operation */
|
||||
|
||||
DEBUGASSERT(psock->s_sockif != NULL &&
|
||||
psock->s_sockif->si_connect != NULL);
|
||||
DEBUGASSERT(psock->s_sockif != NULL);
|
||||
if (psock->s_sockif->si_connect == NULL)
|
||||
{
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
ret = psock->s_sockif->si_connect(psock, addr, addrlen);
|
||||
if (ret >= 0)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user