net/: Add basic IEEE 802.15-4 socket support
This commit is contained in:
parent
6af9b23df5
commit
0b441ff1f4
@ -11523,4 +11523,6 @@
|
||||
data buffers (2016-02-22).
|
||||
* fs/fat: Add an option to force all transfers to be performed indirectly
|
||||
using the FAT file system's internal sector buffers (2016-02-22).
|
||||
* net/: Add basic support for IEEE 802.15-4 sockets. Compiles but still
|
||||
missing a few things (2016-02-25).
|
||||
|
||||
|
2
configs
2
configs
@ -1 +1 @@
|
||||
Subproject commit b5ee35523986bd879009b829723b1c85e1b4662e
|
||||
Subproject commit 3f48fbde14b07c116c06411209767def1056a9bb
|
@ -8,12 +8,41 @@ menu "IEEE802.15-4 Configuration"
|
||||
config NET_IEEE802154
|
||||
bool "IEEE802.15-4 support"
|
||||
default n
|
||||
depends on EXPERIMENTAL
|
||||
depends on EXPERIMENTAL && NET_IPv6
|
||||
---help---
|
||||
Enable IEEE802.15-4 protocol socket support
|
||||
|
||||
if NET_IEEE802154
|
||||
|
||||
config NET_IEEE802154_MTU
|
||||
int "IEEE 802.15-4 packet buffer size (MTU)"
|
||||
default 1294 if NET_IPv6
|
||||
default 590 if !NET_IPv6
|
||||
depends on NET_ETHERNET
|
||||
range 590 1518
|
||||
---help---
|
||||
Packet buffer size. This size includes the TCP/UDP payload plus the
|
||||
size of TCP/UDP header, the IP header, and the IEEE 802.15-4 header.
|
||||
This value is normally referred to as the MTU (Maximum Transmission
|
||||
Unit); the payload is the MSS (Maximum Segment Size).
|
||||
|
||||
IPv4 hosts are required to be able to handle an MSS of at least
|
||||
536 octets, resulting in a minimum buffer size of 536+20+20+xx =
|
||||
xx. REVISIT!
|
||||
|
||||
IPv6 hosts are required to be able to handle an MSS of 1220 octets,
|
||||
resulting in a minimum buffer size of of 1220+20+40+xx = xx. REVISIT!
|
||||
|
||||
config IEEE802154_TCP_RECVWNDO
|
||||
int "EEE 802.15-4 TCP receive window size"
|
||||
default 1220 if NET_IPv6
|
||||
default 536 if !NET_IPv6
|
||||
depends on NET_ETHERNET && NET_TCP
|
||||
---help---
|
||||
The size of the advertised receiver's window. Should be set low
|
||||
(i.e., to the size of the MSS) if the application is slow to process
|
||||
incoming data, or high (32768 bytes) if the application processes
|
||||
data quickly. REVISIT!
|
||||
|
||||
endif # NET_IEEE802154
|
||||
endmenu # IEEE802.15-4 Configuration
|
||||
|
@ -39,7 +39,7 @@ ifeq ($(CONFIG_NET_IEEE802154),y)
|
||||
|
||||
# Include IEEE802.15-4 file in the build
|
||||
|
||||
# NET_CSRCS +=
|
||||
# NET_CSRCS +=
|
||||
|
||||
# Include the ieee802154 directory in the build
|
||||
|
||||
|
@ -61,23 +61,22 @@
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define NETDEV_ETH_FORMAT "eth%d"
|
||||
#define NETDEV_LO_FORMAT "lo"
|
||||
#define NETDEV_SLIP_FORMAT "sl%d"
|
||||
#define NETDEV_TUN_FORMAT "tun%d"
|
||||
#define NETDEV_ETH_FORMAT "eth%d"
|
||||
#define NETDEV_LO_FORMAT "lo"
|
||||
#define NETDEV_IEEE802154_FORMAT "wpan%d"
|
||||
#define NETDEV_SLIP_FORMAT "sl%d"
|
||||
#define NETDEV_TUN_FORMAT "tun%d"
|
||||
|
||||
#if defined(CONFIG_NET_SLIP)
|
||||
# define NETDEV_DEFAULT_FORMAT NETDEV_SLIP_FORMAT
|
||||
#elif defined(CONFIG_NET_ETHERNET)
|
||||
# define NETDEV_DEFAULT_FORMAT NETDEV_ETH_FORMAT
|
||||
#elif defined(CONFIG_NET_IEEE802154)
|
||||
# define NETDEV_DEFAULT_FORMAT NETDEV_IEEE802154_FORMAT
|
||||
#else /* if defined(CONFIG_NET_LOOPBACK) */
|
||||
# define NETDEV_DEFAULT_FORMAT NETDEV_LO_FORMAT
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
@ -217,8 +216,14 @@ int netdev_register(FAR struct net_driver_s *dev, enum net_lltype_e lltype)
|
||||
|
||||
#ifdef CONFIG_NET_IEEE802154
|
||||
case NET_LL_IEEE802154: /* IEEE802.15-4 */
|
||||
nlldbg("ERROR: IEEE 802.15-4 not yet supported\n");
|
||||
return -ENOSYS;
|
||||
# warning Missing IEEE 802.15-4 logic: Header length
|
||||
//dev->d_llhdrlen = ???;
|
||||
dev->d_mtu = CONFIG_NET_IEEE802154_MTU;
|
||||
#ifdef CONFIG_NET_TCP
|
||||
dev->d_recvwndo = CONFIG_NET_IEEE802154_TCP_RECVWNDO;
|
||||
#endif
|
||||
devfmt = NETDEV_IEEE802154_FORMAT;
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NET_SLIP
|
||||
|
@ -301,12 +301,12 @@ static inline void netclose_txnotify(FAR struct socket *psock,
|
||||
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
#ifdef CONFIG_NET_IPv4
|
||||
else /* if (psock->s_domain == PF_INET6) */
|
||||
else /* if (psock->s_domain == PF_INET6 || psock->s_domain == PF_IEEE802154) */
|
||||
#endif /* CONFIG_NET_IPv4 */
|
||||
{
|
||||
/* Notify the device driver that send data is available */
|
||||
|
||||
DEBUGASSERT(psock->s_domain == PF_INET6);
|
||||
DEBUGASSERT(psock->s_domain == PF_INET6 || psock->s_domain == PF_IEEE802154);
|
||||
#ifdef CONFIG_NETDEV_MULTINIC
|
||||
netdev_ipv6_txnotify(conn->u.ipv6.laddr, conn->u.ipv6.raddr);
|
||||
#else
|
||||
|
@ -175,7 +175,8 @@ static uint16_t ack_interrupt(FAR struct net_driver_s *dev, FAR void *pvconn,
|
||||
if (IFF_IS_IPv6(dev->d_flags))
|
||||
#endif
|
||||
{
|
||||
DEBUGASSERT(pstate->snd_sock == PF_INET6);
|
||||
DEBUGASSERT(pstate->snd_sock == PF_INET6 ||
|
||||
pstate->snd_sock == PF_IEEE802154);
|
||||
tcp = TCPIPv6BUF;
|
||||
}
|
||||
#endif /* CONFIG_NET_IPv6 */
|
||||
@ -514,12 +515,14 @@ static inline void sendfile_txnotify(FAR struct socket *psock,
|
||||
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
#ifdef CONFIG_NET_IPv4
|
||||
else /* if (psock->s_domain == PF_INET6) */
|
||||
else /* if (psock->s_domain == PF_INET6 || psock->s_domain == PF_IEEE802154) */
|
||||
#endif /* CONFIG_NET_IPv4 */
|
||||
{
|
||||
/* Notify the device driver that send data is available */
|
||||
|
||||
DEBUGASSERT(psock->s_domain == PF_INET6);
|
||||
DEBUGASSERT(psock->s_domain == PF_INET6 ||
|
||||
psock->s_domain == PF_IEEE802154);
|
||||
|
||||
#ifdef CONFIG_NETDEV_MULTINIC
|
||||
netdev_ipv6_txnotify(conn->u.ipv6.laddr, conn->u.ipv6.raddr);
|
||||
#else
|
||||
|
@ -1024,7 +1024,7 @@ static inline void recvfrom_udpsender(struct net_driver_s *dev, struct recvfrom_
|
||||
* class of addresses, the IPv4-mapped IPv6 addresses.
|
||||
*/
|
||||
|
||||
if (conn->domain == PF_INET6)
|
||||
if (conn->domain == PF_INET6 || conn->domain == PF_IEEE802154)
|
||||
{
|
||||
FAR struct sockaddr_in6 *infrom6 = (FAR struct sockaddr_in6 *)infrom;
|
||||
FAR socklen_t *fromlen = pstate->rf_fromlen;
|
||||
@ -1350,12 +1350,12 @@ static inline void recvfrom_udp_rxnotify(FAR struct socket *psock,
|
||||
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
#ifdef CONFIG_NET_IPv4
|
||||
else /* if (psock->s_domain == PF_INET6) */
|
||||
else /* if (psock->s_domain == PF_INET6 || psock->s_domain == PF_INET6) */
|
||||
#endif /* CONFIG_NET_IPv4 */
|
||||
{
|
||||
/* Notify the device driver of the receive ready */
|
||||
|
||||
DEBUGASSERT(psock->s_domain == PF_INET6);
|
||||
DEBUGASSERT(psock->s_domain == PF_INET6 || psock->s_domain == PF_INET6);
|
||||
#ifdef CONFIG_NETDEV_MULTINIC
|
||||
netdev_ipv6_rxnotify(conn->u.ipv6.laddr, conn->u.ipv6.raddr);
|
||||
#else
|
||||
@ -1892,6 +1892,9 @@ ssize_t psock_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len,
|
||||
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
case PF_INET6:
|
||||
#ifdef CONFIG_NET_IEEE802145
|
||||
case PF_IEEE802154:
|
||||
#endif
|
||||
{
|
||||
minlen = sizeof(struct sockaddr_in6);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* net/socket/socket.c
|
||||
*
|
||||
* Copyright (C) 2007-2009, 2012, 2014-2015 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007-2009, 2012, 2014-2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -250,7 +250,7 @@ int psock_socket(int domain, int type, int protocol, FAR struct socket *psock)
|
||||
int ret;
|
||||
int err;
|
||||
|
||||
/* Only PF_INET, PF_INET6 or PF_PACKET domains supported */
|
||||
/* Only PF_INET, PF_INET6, PF_PACKET, PF_IEEE802154 domains supported */
|
||||
|
||||
switch (domain)
|
||||
{
|
||||
@ -265,6 +265,9 @@ int psock_socket(int domain, int type, int protocol, FAR struct socket *psock)
|
||||
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
case PF_INET6:
|
||||
#ifdef CONFIG_NET_IEEE802154
|
||||
case PF_IEEE802154:
|
||||
#endif
|
||||
#ifdef CONFIG_NET_LOCAL
|
||||
ipdomain = true;
|
||||
#endif
|
||||
|
@ -149,7 +149,7 @@ struct tcp_conn_s
|
||||
uint8_t sndseq[4]; /* The sequence number that was last sent by us */
|
||||
uint8_t crefs; /* Reference counts on this instance */
|
||||
#if defined(CONFIG_NET_IPv4) && defined(CONFIG_NET_IPv6)
|
||||
uint8_t domain; /* IP domain: PF_INET or PF_INET6 */
|
||||
uint8_t domain; /* IP domain: PF_INET, PF_INET6, or PF_IEEE802154 */
|
||||
#endif
|
||||
uint8_t sa; /* Retransmission time-out calculation state
|
||||
* variable */
|
||||
|
@ -139,7 +139,9 @@ static inline void accept_tcpsender(FAR struct socket *psock,
|
||||
{
|
||||
FAR struct sockaddr_in6 *inaddr = (FAR struct sockaddr_in6 *)addr;
|
||||
|
||||
DEBUGASSERT(psock->s_domain == PF_INET6);
|
||||
DEBUGASSERT(psock->s_domain == PF_INET6 ||
|
||||
psock->s_domain == PF_IEEE802154);
|
||||
|
||||
inaddr->sin6_family = AF_INET6;
|
||||
inaddr->sin6_port = conn->rport;
|
||||
net_ipv6addr_copy(inaddr->sin6_addr.s6_addr, conn->u.ipv6.raddr);
|
||||
|
@ -977,6 +977,8 @@ FAR struct tcp_conn_s *tcp_alloc_accept(FAR struct net_driver_s *dev,
|
||||
domain = ipv6 ? PF_INET6 : PF_INET;
|
||||
#elif defined(CONFIG_NET_IPv4)
|
||||
domain = PF_INET;
|
||||
#elif defined(CONFIG_NET_IEEE802154)
|
||||
domain = PF_IEEE80254;
|
||||
#else /* defined(CONFIG_NET_IPv6) */
|
||||
domain = PF_INET6;
|
||||
#endif
|
||||
|
@ -241,11 +241,13 @@ static inline void send_ipselect(FAR struct net_driver_s *dev,
|
||||
|
||||
tcp_ipv4_select(dev);
|
||||
}
|
||||
else /* if (psock->s_domain == PF_INET6) */
|
||||
else /* if (psock->s_domain == PF_INET6 || psock->s_domain == PF_IEEE802154) */
|
||||
{
|
||||
/* Select the IPv6 domain */
|
||||
|
||||
DEBUGASSERT(psock->s_domain == PF_INET6);
|
||||
DEBUGASSERT(psock->s_domain == PF_INET6 ||
|
||||
psock->s_domain == PF_IEEE802154);
|
||||
|
||||
tcp_ipv4_select(dev);
|
||||
}
|
||||
}
|
||||
@ -857,12 +859,14 @@ static inline void send_txnotify(FAR struct socket *psock,
|
||||
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
#ifdef CONFIG_NET_IPv4
|
||||
else /* if (psock->s_domain == PF_INET6) */
|
||||
else /* if (psock->s_domain == PF_INET6 || psock->s_domain == PF_IEEE802154) */
|
||||
#endif /* CONFIG_NET_IPv4 */
|
||||
{
|
||||
/* Notify the device driver that send data is available */
|
||||
|
||||
DEBUGASSERT(psock->s_domain == PF_INET6);
|
||||
DEBUGASSERT(psock->s_domain == PF_INET6 ||
|
||||
psock->s_domain == PF_IEEE802154);
|
||||
|
||||
#ifdef CONFIG_NETDEV_MULTINIC
|
||||
netdev_ipv6_txnotify(conn->u.ipv6.laddr, conn->u.ipv6.raddr);
|
||||
#else
|
||||
|
@ -190,11 +190,13 @@ static inline void tcpsend_ipselect(FAR struct net_driver_s *dev,
|
||||
|
||||
tcp_ipv4_select(dev);
|
||||
}
|
||||
else /* if (psock->s_domain == PF_INET6) */
|
||||
else /* if (psock->s_domain == PF_INET6 || psock->s_domain == PF_IEEE802154) */
|
||||
{
|
||||
/* Select the IPv6 domain */
|
||||
|
||||
DEBUGASSERT(psock->s_domain == PF_INET6);
|
||||
DEBUGASSERT(psock->s_domain == PF_INET6 ||
|
||||
psock->s_domain == PF_IEEE802154);
|
||||
|
||||
tcp_ipv4_select(dev);
|
||||
}
|
||||
}
|
||||
@ -637,12 +639,14 @@ static inline void send_txnotify(FAR struct socket *psock,
|
||||
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
#ifdef CONFIG_NET_IPv4
|
||||
else /* if (psock->s_domain == PF_INET6) */
|
||||
else /* if (psock->s_domain == PF_INET6 || psock->s_domain == PF_IEEE802154) */
|
||||
#endif /* CONFIG_NET_IPv4 */
|
||||
{
|
||||
/* Notify the device driver that send data is available */
|
||||
|
||||
DEBUGASSERT(psock->s_domain == PF_INET6);
|
||||
DEBUGASSERT(psock->s_domain == PF_INET6 ||
|
||||
psock->s_domain == PF_IEEE802154);
|
||||
|
||||
#ifdef CONFIG_NETDEV_MULTINIC
|
||||
netdev_ipv6_txnotify(conn->u.ipv6.laddr, conn->u.ipv6.raddr);
|
||||
#else
|
||||
|
@ -85,7 +85,7 @@ struct udp_conn_s
|
||||
union ip_binding_u u; /* IP address binding */
|
||||
uint16_t lport; /* Bound local port number (network byte order) */
|
||||
uint16_t rport; /* Remote port number (network byte order) */
|
||||
uint8_t domain; /* IP domain: PF_INET or PF_INET6 */
|
||||
uint8_t domain; /* IP domain: PF_INET, PF_INET6, or PF_IEEE802145 */
|
||||
uint8_t ttl; /* Default time-to-live */
|
||||
uint8_t crefs; /* Reference counts on this instance */
|
||||
|
||||
|
@ -134,7 +134,7 @@ static uint16_t udp_datahandler(FAR struct net_driver_s *dev, FAR struct udp_con
|
||||
* class of addresses, the IPv4-mapped IPv6 addresses.
|
||||
*/
|
||||
|
||||
if (conn->domain == PF_INET6)
|
||||
if (conn->domain == PF_INET6 || conn->domain == PF_IEEE802154)
|
||||
{
|
||||
FAR struct udp_hdr_s *udp = UDPIPv6BUF;
|
||||
FAR struct ipv6_hdr_s *ipv6 = IPv6BUF;
|
||||
|
@ -188,11 +188,13 @@ static inline void sendto_ipselect(FAR struct net_driver_s *dev,
|
||||
|
||||
udp_ipv4_select(dev);
|
||||
}
|
||||
else /* if (psock->s_domain == PF_INET6) */
|
||||
else /* if (psock->s_domain == PF_INET6 || psock->s_domain == PF_IEEE802154) */
|
||||
{
|
||||
/* Select the IPv6 domain */
|
||||
|
||||
DEBUGASSERT(psock->s_domain == PF_INET6);
|
||||
DEBUGASSERT(psock->s_domain == PF_INET6 ||
|
||||
psock->s_domain == PF_IEEE802154);
|
||||
|
||||
udp_ipv4_select(dev);
|
||||
}
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ void udp_send(FAR struct net_driver_s *dev, FAR struct udp_conn_s *conn)
|
||||
#ifdef CONFIG_NET_IPv4
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
if (conn->domain == PF_INET ||
|
||||
(conn->domain == PF_INET6 &&
|
||||
((conn->domain == PF_INET6 || conn->domain == PF_IEEE802154) &&
|
||||
ip6_is_ipv4addr((FAR struct in6_addr *)conn->u.ipv6.raddr)))
|
||||
#endif
|
||||
{
|
||||
@ -147,7 +147,7 @@ void udp_send(FAR struct net_driver_s *dev, FAR struct udp_conn_s *conn)
|
||||
net_ipv4addr_hdrcopy(ipv4->srcipaddr, &dev->d_ipaddr);
|
||||
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
if (conn->domain == PF_INET6 &&
|
||||
if ((conn->domain == PF_INET6 || conn->domain == PF_IEEE802154) &&
|
||||
ip6_is_ipv4addr((FAR struct in6_addr *)conn->u.ipv6.raddr))
|
||||
{
|
||||
in_addr_t raddr = ip6_get_ipv4addr((FAR struct in6_addr *)conn->u.ipv6.raddr);
|
||||
@ -241,7 +241,7 @@ void udp_send(FAR struct net_driver_s *dev, FAR struct udp_conn_s *conn)
|
||||
#ifdef CONFIG_NET_IPv4
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
if (conn->domain == PF_INET ||
|
||||
(conn->domain == PF_INET6 &&
|
||||
((conn->domain == PF_INET6 || conn->domain == PF_IEEE802154) &&
|
||||
ip6_is_ipv4addr((FAR struct in6_addr *)conn->u.ipv6.raddr)))
|
||||
#endif
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user