Skip to content

Commit

Permalink
net: inet.h match inet_sockif.c definition
Browse files Browse the repository at this point in the history
Fixes psock_socket: ERROR: socket address family unsupported: 2
When using the minimal CONFIG_NET configuration typically used for
SocketCAN

Update net/inet/inet.h

Co-authored-by: Xiang Xiao <[email protected]>

Update net/inet/inet.h

Co-authored-by: Xiang Xiao <[email protected]>
  • Loading branch information
PetervdPerk-NXP and xiaoxiang781216 committed Nov 4, 2024
1 parent 3c4053a commit c371afc
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
7 changes: 4 additions & 3 deletions include/nuttx/net/netconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
* include/nuttx/net/netconfig.h
*
* SPDX-License-Identifier: BSD-3-Clause
* SPDX-FileCopyrightText: 2007, 2011, 2014-2015, 2017-2019 Gregory Nutt. All rights reserved.
* SPDX-FileCopyrightText: 2007, 2011, 2014-2015, 2017-2019 Gregory Nutt.
* All rights reserved.
* SPDX-FileCopyrightText: 2001-2003, Adam Dunkels. All rights reserved.
* SPDX-FileContributor: Gregory Nutt <[email protected]>
* SPDX-FileContributor: Adam Dunkels <[email protected]>
Expand Down Expand Up @@ -67,9 +68,9 @@
* matter. It should, however, be valid in the current configuration.
*/

#if defined(CONFIG_NET_IPv4)
#if defined(HAVE_PFINET_SOCKETS)
# define NET_SOCK_FAMILY AF_INET
#elif defined(CONFIG_NET_IPv6)
#elif defined(HAVE_PFINET6_SOCKETS)
# define NET_SOCK_FAMILY AF_INET6
#elif defined(CONFIG_NET_LOCAL)
# define NET_SOCK_FAMILY AF_LOCAL
Expand Down
1 change: 1 addition & 0 deletions libs/libc/net/lib_indextoname.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <string.h>
#include <unistd.h>

#include <netinet/in.h>
#include <nuttx/net/netconfig.h>

/****************************************************************************
Expand Down
1 change: 1 addition & 0 deletions libs/libc/net/lib_nametoindex.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <string.h>
#include <unistd.h>

#include <netinet/in.h>
#include <nuttx/net/netconfig.h>

/****************************************************************************
Expand Down
6 changes: 4 additions & 2 deletions net/inet/inet.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,13 @@
#if defined(CONFIG_NET_IPv4) || defined(CONFIG_NET_IPv6)
# define HAVE_INET_SOCKETS

# if defined(CONFIG_NET_IPv4)
# if (defined(CONFIG_NET_IPv4) && (defined(NET_UDP_HAVE_STACK) || \
defined(NET_TCP_HAVE_STACK))) || defined(CONFIG_NET_ICMP_SOCKET)
# define HAVE_PFINET_SOCKETS
# endif

# if defined(CONFIG_NET_IPv6)
# if (defined(CONFIG_NET_IPv6) && (defined(NET_UDP_HAVE_STACK) || \
defined(NET_TCP_HAVE_STACK))) || defined(CONFIG_NET_ICMPv6_SOCKET)
# define HAVE_PFINET6_SOCKETS
# endif
#endif
Expand Down
2 changes: 1 addition & 1 deletion net/socket/net_sockif.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ net_sockif(sa_family_t family, int type, int protocol)

switch (family)
{
#ifdef HAVE_INET_SOCKETS
#if defined(HAVE_PFINET_SOCKETS) || defined(HAVE_PFINET6_SOCKETS)
# ifdef HAVE_PFINET_SOCKETS
case PF_INET:
# endif
Expand Down

0 comments on commit c371afc

Please sign in to comment.