network: Move USRSOCK specific code from from inet_sockif to usrsock_sockif

This commit is contained in:
Jussi Kivilinna
2017-07-31 09:33:59 -06:00
committed by Gregory Nutt
parent 00d8dd3912
commit 7dfb01dbce
14 changed files with 105 additions and 315 deletions
+31 -1
View File
@@ -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);