mirror of
https://github.com/apache/nuttx.git
synced 2026-05-30 21:36:28 +08:00
6loWPAN: Remove the PAN ID from the 6loWPAN data structure. This is owned by the radio driver. Rather, use an IOCTL to obtain the PAN ID from the downstream radio driver.
This commit is contained in:
@@ -79,7 +79,7 @@ struct sockaddr; /* Forward reference */
|
||||
void sixlowpan_initialize(void);
|
||||
|
||||
/****************************************************************************
|
||||
* Function: psock_6lowpan_tcp_send
|
||||
* Name: psock_6lowpan_tcp_send
|
||||
*
|
||||
* Description:
|
||||
* psock_6lowpan_tcp_send() call may be used only when the TCP socket is in a
|
||||
@@ -107,7 +107,7 @@ ssize_t psock_6lowpan_tcp_send(FAR struct socket *psock, FAR const void *buf,
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Function: sixlowpan_tcp_send
|
||||
* Name: sixlowpan_tcp_send
|
||||
*
|
||||
* Description:
|
||||
* TCP output comes through three different mechansims. Either from:
|
||||
@@ -139,7 +139,7 @@ ssize_t psock_6lowpan_tcp_send(FAR struct socket *psock, FAR const void *buf,
|
||||
void sixlowpan_tcp_send(FAR struct net_driver_s *dev);
|
||||
|
||||
/****************************************************************************
|
||||
* Function: psock_6lowpan_udp_send
|
||||
* Name: psock_6lowpan_udp_send
|
||||
*
|
||||
* Description:
|
||||
* psock_6lowpan_udp_send() call may be used with connectionlesss UDP
|
||||
@@ -167,7 +167,7 @@ ssize_t psock_6lowpan_udp_send(FAR struct socket *psock, FAR const void *buf,
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Function: psock_6lowpan_udp_sendto
|
||||
* Name: psock_6lowpan_udp_sendto
|
||||
*
|
||||
* Description:
|
||||
* If sendto() is used on a connection-mode (SOCK_STREAM, SOCK_SEQPACKET)
|
||||
|
||||
@@ -217,6 +217,7 @@ int sixlowpan_queue_frames(FAR struct ieee802154_driver_s *ieee,
|
||||
struct rimeaddr_s bcastmac;
|
||||
uint16_t pktlen;
|
||||
uint16_t paysize;
|
||||
uint16_t dest_panid;
|
||||
#ifdef CONFIG_NET_6LOWPAN_FRAG
|
||||
uint16_t outlen = 0;
|
||||
#endif
|
||||
@@ -286,9 +287,18 @@ int sixlowpan_queue_frames(FAR struct ieee802154_driver_s *ieee,
|
||||
rimeaddr_copy(&g_pktaddrs[PACKETBUF_ADDR_SENDER], &ieee->i_nodeaddr);
|
||||
rimeaddr_copy(&g_pktaddrs[PACKETBUF_ADDR_RECEIVER], destmac);
|
||||
|
||||
/* Get the destination PAN ID.
|
||||
*
|
||||
* REVISIT: For now I am assuming that the source and destination
|
||||
* PAN IDs are the same.
|
||||
*/
|
||||
|
||||
dest_panid = 0xffff;
|
||||
(void)sixlowpan_src_panid(ieee, &dest_panid);
|
||||
|
||||
/* Pre-calculate frame header length. */
|
||||
|
||||
framer_hdrlen = sixlowpan_send_hdrlen(ieee, ieee->i_panid);
|
||||
framer_hdrlen = sixlowpan_send_hdrlen(ieee, dest_panid);
|
||||
if (framer_hdrlen < 0)
|
||||
{
|
||||
/* Failed to determine the size of the header failed. */
|
||||
@@ -349,7 +359,7 @@ int sixlowpan_queue_frames(FAR struct ieee802154_driver_s *ieee,
|
||||
/* Create 1st Fragment */
|
||||
/* Add the frame header using the pre-allocated IOB. */
|
||||
|
||||
verify = sixlowpan_framecreate(ieee, iob, ieee->i_panid);
|
||||
verify = sixlowpan_framecreate(ieee, iob, dest_panid);
|
||||
DEBUGASSERT(verify == framer_hdrlen);
|
||||
UNUSED(verify);
|
||||
|
||||
@@ -513,7 +523,7 @@ int sixlowpan_queue_frames(FAR struct ieee802154_driver_s *ieee,
|
||||
|
||||
/* Add the frame header to the preallocated IOB. */
|
||||
|
||||
verify = sixlowpan_framecreate(ieee, iob, ieee->i_panid);
|
||||
verify = sixlowpan_framecreate(ieee, iob, dest_panid);
|
||||
DEBUGASSERT(verify == framer_hdrlen);
|
||||
UNUSED(verify);
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ struct field_length_s
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Function: sixlowpan_addrlen
|
||||
* Name: sixlowpan_addrlen
|
||||
*
|
||||
* Description:
|
||||
* Return the address length associated with a 2-bit address mode
|
||||
@@ -109,7 +109,7 @@ static inline uint8_t sixlowpan_addrlen(uint8_t addrmode)
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Function: sixlowpan_addrnull
|
||||
* Name: sixlowpan_addrnull
|
||||
*
|
||||
* Description:
|
||||
* If the output address is NULL in the Rime buf, then it is broadcast
|
||||
@@ -140,7 +140,7 @@ static bool sixlowpan_addrnull(FAR uint8_t *addr)
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Function: sixlowpan_fieldlengths
|
||||
* Name: sixlowpan_fieldlengths
|
||||
*
|
||||
* Description:
|
||||
* Return the lengths associated fields of the IEEE802.15.4 header.
|
||||
@@ -228,7 +228,7 @@ static void sixlowpan_fieldlengths(FAR struct frame802154_s *finfo,
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Function: sixlowpan_fieldlengths
|
||||
* Name: sixlowpan_fieldlengths
|
||||
*
|
||||
* Description:
|
||||
* Return the lengths associated fields of the IEEE802.15.4 header.
|
||||
@@ -249,7 +249,7 @@ static int sixlowpan_flen_hdrlen(FAR const struct field_length_s *flen)
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Function: sixlowpan_802154_hdrlen
|
||||
* Name: sixlowpan_802154_hdrlen
|
||||
*
|
||||
* Description:
|
||||
* Calculates the length of the frame header. This function is meant to
|
||||
@@ -272,7 +272,7 @@ static int sixlowpan_802154_hdrlen(FAR struct frame802154_s *finfo)
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Function: sixlowpan_setup_params
|
||||
* Name: sixlowpan_setup_params
|
||||
*
|
||||
* Description:
|
||||
* Configure frame parmeters structure.
|
||||
@@ -293,6 +293,7 @@ static void sixlowpan_setup_params(FAR struct ieee802154_driver_s *ieee,
|
||||
uint16_t dest_panid,
|
||||
FAR struct frame802154_s *params)
|
||||
{
|
||||
uint16_t src_panid;
|
||||
bool rcvrnull;
|
||||
|
||||
/* Initialize all prameters to all zero */
|
||||
@@ -331,9 +332,14 @@ static void sixlowpan_setup_params(FAR struct ieee802154_driver_s *ieee,
|
||||
}
|
||||
|
||||
/* Complete the addressing fields. */
|
||||
/* Get the source PAN ID from the IEEE802.15.4 radio driver */
|
||||
|
||||
src_panid = 0xffff;
|
||||
(void)sixlowpan_src_panid(ieee, &src_panid);
|
||||
|
||||
/* Set the source and destination PAN ID. */
|
||||
|
||||
params->src_pid = ieee->i_panid;
|
||||
params->src_pid = src_panid;
|
||||
params->dest_pid = dest_panid;
|
||||
|
||||
/* If the output address is NULL in the Rime buf, then it is broadcast
|
||||
@@ -382,7 +388,7 @@ static void sixlowpan_setup_params(FAR struct ieee802154_driver_s *ieee,
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Function: sixlowpan_send_hdrlen
|
||||
* Name: sixlowpan_send_hdrlen
|
||||
*
|
||||
* Description:
|
||||
* This function is before the first frame has been sent in order to
|
||||
@@ -415,7 +421,7 @@ int sixlowpan_send_hdrlen(FAR struct ieee802154_driver_s *ieee,
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Function: sixlowpan_802154_framecreate
|
||||
* Name: sixlowpan_802154_framecreate
|
||||
*
|
||||
* Description:
|
||||
* Creates a frame for transmission over the air. This function is meant
|
||||
@@ -514,7 +520,7 @@ int sixlowpan_802154_framecreate(FAR struct frame802154_s *finfo,
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Function: sixlowpan_framecreate
|
||||
* Name: sixlowpan_framecreate
|
||||
*
|
||||
* Description:
|
||||
* This function is called after eiether (1) the IEEE802.15.4 MAC driver
|
||||
|
||||
@@ -680,7 +680,7 @@ static int sixlowpan_frame_process(FAR struct ieee802154_driver_s *ieee,
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Function: sixlowpan_dispatch
|
||||
* Name: sixlowpan_dispatch
|
||||
*
|
||||
* Description:
|
||||
* Inject the packet in d_buf into the network for normal packet processing.
|
||||
|
||||
@@ -344,7 +344,7 @@ int sixlowpan_send(FAR struct net_driver_s *dev,
|
||||
uint16_t timeout);
|
||||
|
||||
/****************************************************************************
|
||||
* Function: sixlowpan_send_hdrlen
|
||||
* Name: sixlowpan_send_hdrlen
|
||||
*
|
||||
* Description:
|
||||
* This function is before the first frame has been sent in order to
|
||||
@@ -366,7 +366,7 @@ int sixlowpan_send_hdrlen(FAR struct ieee802154_driver_s *ieee,
|
||||
uint16_t dest_panid);
|
||||
|
||||
/****************************************************************************
|
||||
* Function: sixlowpan_framecreate
|
||||
* Name: sixlowpan_framecreate
|
||||
*
|
||||
* Description:
|
||||
* This function is called after the IEEE802.15.4 MAC driver polls for
|
||||
@@ -606,5 +606,23 @@ void sixlowpan_rimefromip(const net_ipv6addr_t ipaddr,
|
||||
bool sixlowpan_ismacbased(const net_ipv6addr_t ipaddr,
|
||||
FAR const struct rimeaddr_s *rime);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: sixlowpan_src_panid
|
||||
*
|
||||
* Description:
|
||||
* Get the source PAN ID from the IEEE802.15.4 radio.
|
||||
*
|
||||
* Input parameters:
|
||||
* ieee - A reference IEEE802.15.4 MAC network device structure.
|
||||
* panid - The location in which to return the PAN ID. 0xfff may be
|
||||
* returned if the device is not associated.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int sixlowpan_src_panid(FAR struct ieee802154_driver_s *ieee,
|
||||
FAR uint16_t *panid);
|
||||
#endif /* CONFIG_NET_6LOWPAN */
|
||||
#endif /* _NET_SIXLOWPAN_SIXLOWPAN_INTERNAL_H */
|
||||
|
||||
@@ -93,7 +93,7 @@ struct sixlowpan_send_s
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Function: send_timeout
|
||||
* Name: send_timeout
|
||||
*
|
||||
* Description:
|
||||
* Check for send timeout.
|
||||
@@ -134,7 +134,7 @@ static inline bool send_timeout(FAR struct sixlowpan_send_s *sinfo)
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Function: send_interrupt
|
||||
* Name: send_interrupt
|
||||
*
|
||||
* Description:
|
||||
* This function is called from the interrupt level to perform the actual
|
||||
|
||||
@@ -136,7 +136,7 @@ static uint16_t sixlowpan_tcp_chksum(FAR struct ipv6tcp_hdr_s *ipv6tcp,
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Function: psock_6lowpan_tcp_send
|
||||
* Name: psock_6lowpan_tcp_send
|
||||
*
|
||||
* Description:
|
||||
* psock_6lowpan_tcp_send() call may be used only when the TCP socket is in a
|
||||
@@ -348,7 +348,7 @@ ssize_t psock_6lowpan_tcp_send(FAR struct socket *psock, FAR const void *buf,
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Function: sixlowpan_tcp_send
|
||||
* Name: sixlowpan_tcp_send
|
||||
*
|
||||
* Description:
|
||||
* TCP output comes through three different mechansims. Either from:
|
||||
|
||||
@@ -125,7 +125,7 @@ static uint16_t sixlowpan_udp_chksum(FAR struct ipv6udp_hdr_s *ipv6udp,
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Function: psock_6lowpan_udp_sendto
|
||||
* Name: psock_6lowpan_udp_sendto
|
||||
*
|
||||
* Description:
|
||||
* If sendto() is used on a connection-mode (SOCK_STREAM, SOCK_SEQPACKET)
|
||||
@@ -323,7 +323,7 @@ ssize_t psock_6lowpan_udp_sendto(FAR struct socket *psock,
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Function: psock_6lowpan_udp_send
|
||||
* Name: psock_6lowpan_udp_send
|
||||
*
|
||||
* Description:
|
||||
* psock_6lowpan_udp_send() call may be used with connectionlesss UDP
|
||||
|
||||
@@ -54,8 +54,10 @@
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/net/sixlowpan.h>
|
||||
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
|
||||
|
||||
#include "sixlowpan/sixlowpan_internal.h"
|
||||
|
||||
@@ -156,4 +158,39 @@ bool sixlowpan_ismacbased(const net_ipv6addr_t ipaddr,
|
||||
#endif
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: sixlowpan_src_panid
|
||||
*
|
||||
* Description:
|
||||
* Get the source PAN ID from the IEEE802.15.4 radio.
|
||||
*
|
||||
* Input parameters:
|
||||
* ieee - A reference IEEE802.15.4 MAC network device structure.
|
||||
* panid - The location in which to return the PAN ID. 0xfff may be
|
||||
* returned if the device is not associated.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int sixlowpan_src_panid(FAR struct ieee802154_driver_s *ieee,
|
||||
FAR uint16_t *panid)
|
||||
{
|
||||
FAR struct net_driver_s *dev = &ieee->i_dev;
|
||||
struct ieee802154_netradio_s arg;
|
||||
int ret;
|
||||
|
||||
memcpy(arg.ifr_name, ieee->i_dev.d_ifname, IFNAMSIZ);
|
||||
ret = dev->d_ioctl(dev, PHY802154IOC_GET_PANID, (unsigned long)((uintptr_t)&arg));
|
||||
if (ret < 0)
|
||||
{
|
||||
wlerr("ERROR: PHY802154IOC_GET_PANID failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
*panid = arg.u.panid;
|
||||
return OK;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_NET_6LOWPAN */
|
||||
|
||||
Reference in New Issue
Block a user