Networking: Straighten up use if IPv6/IPv4 in TCP connection logic

This commit is contained in:
Gregory Nutt
2015-01-17 17:07:54 -06:00
parent b187b4f381
commit 86f617cc88
4 changed files with 476 additions and 151 deletions

View File

@@ -74,11 +74,11 @@
#define IFF_CLR_IPv6(f) do { (f) &= ~IFF_IPv6; } while (0) #define IFF_CLR_IPv6(f) do { (f) &= ~IFF_IPv6; } while (0)
#define IFF_CLR_NOARP(f) do { (f) &= ~IFF_NOARP; } while (0) #define IFF_CLR_NOARP(f) do { (f) &= ~IFF_NOARP; } while (0)
#define IFF_IS_DOWN(f) ((f) & IFF_DOWN) != 0) #define IFF_IS_DOWN(f) (((f) & IFF_DOWN) != 0)
#define IFF_IS_UP(f) ((f) & IFF_UP) != 0) #define IFF_IS_UP(f) (((f) & IFF_UP) != 0)
#define IFF_IS_RUNNING(f) ((f) & IFF_RUNNING) != 0) #define IFF_IS_RUNNING(f) (((f) & IFF_RUNNING) != 0)
#define IFF_IS_IPv6(f) ((f) & IFF_IPv6) != 0) #define IFF_IS_IPv6(f) (((f) & IFF_IPv6) != 0)
#define IFF_IS_NOARP(f) ((f) & IFF_NOARP) != 0) #define IFF_IS_NOARP(f) (((f) & IFF_NOARP) != 0)
#define IFF_SET_IPv4(f) IFF_CLR_IPv6(f) #define IFF_SET_IPv4(f) IFF_CLR_IPv6(f)
#define IFF_CLR_IPv4(f) IFF_SET_IPv6(f) #define IFF_CLR_IPv4(f) IFF_SET_IPv6(f)

View File

@@ -146,14 +146,6 @@ int psock_bind(FAR struct socket *psock, const struct sockaddr *addr,
#ifdef CONFIG_NET_PKT #ifdef CONFIG_NET_PKT
FAR const struct sockaddr_ll *lladdr = (const struct sockaddr_ll *)addr; FAR const struct sockaddr_ll *lladdr = (const struct sockaddr_ll *)addr;
#endif #endif
#if defined(CONFIG_NET_TCP) || defined(CONFIG_NET_UDP)
#ifdef CONFIG_NET_IPv6
FAR const struct sockaddr_in6 *inaddr = (const struct sockaddr_in6 *)addr;
#else
FAR const struct sockaddr_in *inaddr = (const struct sockaddr_in *)addr;
#endif
#endif
int err; int err;
int ret = OK; int ret = OK;
@@ -204,7 +196,7 @@ int psock_bind(FAR struct socket *psock, const struct sockaddr *addr,
#ifdef CONFIG_NET_TCP #ifdef CONFIG_NET_TCP
case SOCK_STREAM: case SOCK_STREAM:
ret = tcp_bind(psock->s_conn, inaddr); ret = tcp_bind(psock->s_conn, addr);
psock->s_flags |= _SF_BOUND; psock->s_flags |= _SF_BOUND;
break; break;
#endif #endif

View File

@@ -366,13 +366,7 @@ FAR struct tcp_conn_s *tcp_alloc_accept(FAR struct net_driver_s *dev,
* *
****************************************************************************/ ****************************************************************************/
#ifdef CONFIG_NET_IPv6 int tcp_bind(FAR struct tcp_conn_s *conn, FAR const struct sockaddr *addr);
int tcp_bind(FAR struct tcp_conn_s *conn,
FAR const struct sockaddr_in6 *addr);
#else
int tcp_bind(FAR struct tcp_conn_s *conn,
FAR const struct sockaddr_in *addr);
#endif
/**************************************************************************** /****************************************************************************
* Name: tcp_connect * Name: tcp_connect

File diff suppressed because it is too large Load Diff