mirror of
https://github.com/apache/nuttx.git
synced 2026-05-25 01:39:44 +08:00
network: Move USRSOCK specific code from from inet_sockif to usrsock_sockif
This commit is contained in:
committed by
Gregory Nutt
parent
00d8dd3912
commit
7dfb01dbce
+31
-1
@@ -44,6 +44,7 @@
|
||||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include "usrsock/usrsock.h"
|
||||
#include "socket/socket.h"
|
||||
|
||||
#ifdef CONFIG_NET
|
||||
@@ -95,7 +96,7 @@ int psock_socket(int domain, int type, int protocol, FAR struct socket *psock)
|
||||
FAR const struct sock_intf_s *sockif = NULL;
|
||||
int errcode;
|
||||
int ret;
|
||||
|
||||
|
||||
/* Initialize the socket structure */
|
||||
|
||||
psock->s_domain = domain;
|
||||
@@ -105,6 +106,35 @@ int psock_socket(int domain, int type, int protocol, FAR struct socket *psock)
|
||||
psock->s_sndcb = NULL;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NET_USRSOCK
|
||||
if (domain != PF_LOCAL && domain != PF_UNSPEC)
|
||||
{
|
||||
/* Handle special setup for USRSOCK sockets (user-space networking
|
||||
* stack).
|
||||
*/
|
||||
|
||||
ret = g_usrsock_sockif.si_setup(psock, protocol);
|
||||
if (ret == -ENETDOWN)
|
||||
{
|
||||
/* -ENETDOWN means that USRSOCK daemon is not running. Attempt to
|
||||
* open socket with kernel networking stack.
|
||||
*/
|
||||
}
|
||||
else
|
||||
{
|
||||
psock->s_sockif = &g_usrsock_sockif;
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
errcode = -ret;
|
||||
goto errout;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG_NET_USRSOCK */
|
||||
|
||||
/* Get the socket interface */
|
||||
|
||||
sockif = net_sockif(domain);
|
||||
|
||||
Reference in New Issue
Block a user