diff --git a/Makefile.dep b/Makefile.dep index 83ea7641843582698d291639eca6578d7bdc6f5b..69353c2216df08a47b9127fc553f8d23ffe5501a 100644 --- a/Makefile.dep +++ b/Makefile.dep @@ -10,7 +10,7 @@ ifneq (,$(filter ccn-lite,$(USEPKG))) export CFLAGS += -DCCNL_RIOT endif -ifneq (,$(filter gnrc_csma_sender,$(USEMODULE))) +ifneq (,$(filter csma_sender,$(USEMODULE))) USEMODULE += random USEMODULE += xtimer endif diff --git a/sys/Makefile b/sys/Makefile index c6ffeb132adcf37a81149fbc754ef80f26c9d6e9..6f53b2bdaa05811b6b37a44e293c4aa90193a992 100644 --- a/sys/Makefile +++ b/sys/Makefile @@ -1,3 +1,6 @@ +ifneq (,$(filter csma_sender,$(USEMODULE))) + DIRS += net/link_layer/csma_sender +endif ifneq (,$(filter posix_semaphore,$(USEMODULE))) DIRS += posix/semaphore endif diff --git a/sys/include/net/gnrc/csma_sender.h b/sys/include/net/csma_sender.h similarity index 83% rename from sys/include/net/gnrc/csma_sender.h rename to sys/include/net/csma_sender.h index e322bc37dd05dc88a35b07a81f8cbec78b4cb050..00d22783074cace90a4293dd1f18cba3cb22f5ff 100644 --- a/sys/include/net/gnrc/csma_sender.h +++ b/sys/include/net/csma_sender.h @@ -7,8 +7,8 @@ */ /** - * @defgroup net_gnrc_csma_sender CSMA/CA helper - * @ingroup net_gnrc + * @defgroup net_csma_sender CSMA/CA helper + * @ingroup net * @brief This interface allows code from layer 2 (MAC) or higher * to send packets with CSMA/CA, whatever the abilities and/or * configuration of a given radio transceiver device are. @@ -20,11 +20,12 @@ * @author Kévin Roussel <Kevin.Roussel@inria.fr> */ -#ifndef GNRC_CSMA_SENDER_H_ -#define GNRC_CSMA_SENDER_H_ +#ifndef CSMA_SENDER_H_ +#define CSMA_SENDER_H_ + #include <stdint.h> -#include "net/gnrc.h" +#include "net/netdev2.h" #ifdef __cplusplus @@ -84,9 +85,8 @@ void csma_sender_set_max_backoffs(uint8_t val); * CSMA/CA, this feature is used. Otherwise, a software procedure is used. * * @param[in] dev netdev device, needs to be already initialized - * @param[in] pkt pointer to the data in the packet buffer; - * it must be a complete 802.15.4-compliant frame, - * ready to be sent to the radio transceiver + * @param[in] vector pointer to the data + * @param[in] count number of elements in @p vector * * @return number of bytes that were actually send out * @return -ENODEV if @p dev is invalid @@ -97,7 +97,8 @@ void csma_sender_set_max_backoffs(uint8_t val); * @return -EBUSY if radio medium never was available * to send the given data */ -int csma_sender_csma_ca_send(gnrc_netdev_t *dev, gnrc_pktsnip_t *pkt); +int csma_sender_csma_ca_send(netdev2_t *dev, struct iovec *vector, + unsigned count); /** * @brief Sends a 802.15.4 frame when medium is avaiable. @@ -114,9 +115,8 @@ int csma_sender_csma_ca_send(gnrc_netdev_t *dev, gnrc_pktsnip_t *pkt); * @ref csma_sender_csma_ca_send(). * * @param[in] dev netdev device, needs to be already initialized - * @param[in] pkt pointer to the data in the packet buffer; - * it must be a complete 802.15.4-compliant frame, - * ready to be sent to the radio transceiver + * @param[in] vector pointer to the data + * @param[in] count number of elements in @p vector * * @return number of bytes that were actually send out * @return -ENODEV if @p dev is invalid @@ -127,13 +127,13 @@ int csma_sender_csma_ca_send(gnrc_netdev_t *dev, gnrc_pktsnip_t *pkt); * @return -EBUSY if radio medium was not available * to send the given data */ -int csma_sender_cca_send(gnrc_netdev_t *dev, gnrc_pktsnip_t *pkt); +int csma_sender_cca_send(netdev2_t *dev, struct iovec *vector, unsigned count); #ifdef __cplusplus } #endif -#endif /* GNRC_CSMA_SENDER_H_ */ +#endif /* CSMA_SENDER_H_ */ /** @} */ diff --git a/sys/net/gnrc/Makefile b/sys/net/gnrc/Makefile index d011157b43f1bb4ff7380371517cec1fe6f9f4a1..a4b69955ff01a060914103bb24ed56087544e2ad 100644 --- a/sys/net/gnrc/Makefile +++ b/sys/net/gnrc/Makefile @@ -7,9 +7,6 @@ endif ifneq (,$(filter gnrc_conn_udp,$(USEMODULE))) DIRS += conn/udp endif -ifneq (,$(filter gnrc_csma_sender,$(USEMODULE))) - DIRS += link_layer/csma_sender -endif ifneq (,$(filter gnrc_icmpv6,$(USEMODULE))) DIRS += network_layer/icmpv6 endif diff --git a/sys/net/gnrc/link_layer/csma_sender/Makefile b/sys/net/link_layer/csma_sender/Makefile similarity index 54% rename from sys/net/gnrc/link_layer/csma_sender/Makefile rename to sys/net/link_layer/csma_sender/Makefile index b2cfa41e9434ecef79808419d25b3cfa925dfd69..48422e909a47d7cd428d10fa73825060ccc8d8c2 100644 --- a/sys/net/gnrc/link_layer/csma_sender/Makefile +++ b/sys/net/link_layer/csma_sender/Makefile @@ -1,3 +1 @@ -MODULE := gnrc_csma_sender - include $(RIOTBASE)/Makefile.base diff --git a/sys/net/gnrc/link_layer/csma_sender/gnrc_csma_sender.c b/sys/net/link_layer/csma_sender/csma_sender.c similarity index 88% rename from sys/net/gnrc/link_layer/csma_sender/gnrc_csma_sender.c rename to sys/net/link_layer/csma_sender/csma_sender.c index e1bb0bb4d17f5150d473ed4ebac7b998bca9817c..ca88023c6df77c77ee353c26bebcfe6e3b0dea99 100644 --- a/sys/net/gnrc/link_layer/csma_sender/gnrc_csma_sender.c +++ b/sys/net/link_layer/csma_sender/csma_sender.c @@ -21,10 +21,11 @@ #include "xtimer.h" #include "random.h" -#include "net/gnrc/csma_sender.h" -#include "net/gnrc.h" +#include "net/netdev2.h" #include "net/netopt.h" +#include "net/csma_sender.h" + #define ENABLE_DEBUG (0) #include "debug.h" @@ -77,18 +78,17 @@ static inline uint32_t choose_backoff_period(int be) * @brief Perform a CCA and send the given packet if medium is available * * @param[in] device netdev device, needs to be already initialized - * @param[in] data pointer to the data in the packet buffer; - * it must be a complete 802.15.4-compliant frame, - * ready to be sent to the radio transceiver + * @param[in] vector pointer to the data + * @param[in] count number of elements in @p vector * * @return the return value of device driver's - * gnrc_netdev_driver_t::send_data() - * function if medium was available + * netdev2_driver_t::send() function if medium was + * available * @return -ECANCELED if an internal driver error occurred * @return -EBUSY if radio medium was not available * to send the given data */ -static int send_if_cca(gnrc_netdev_t *device, gnrc_pktsnip_t *data) +static int send_if_cca(netdev2_t *device, struct iovec *vector, unsigned count) { netopt_enable_t hwfeat; @@ -107,7 +107,7 @@ static int send_if_cca(gnrc_netdev_t *device, gnrc_pktsnip_t *data) /* if medium is clear, send the packet and return */ if (hwfeat == NETOPT_ENABLE) { DEBUG("csma: Radio medium available: sending packet.\n"); - return device->driver->send_data(device, data); + return device->driver->send(device, vector, count); } /* if we arrive here, medium was not available for transmission */ @@ -133,7 +133,8 @@ void csma_sender_set_max_backoffs(uint8_t val) } -int csma_sender_csma_ca_send(gnrc_netdev_t *dev, gnrc_pktsnip_t *pkt) +int csma_sender_csma_ca_send(netdev2_t *dev, struct iovec *vector, + unsigned count) { netopt_enable_t hwfeat; @@ -163,7 +164,7 @@ int csma_sender_csma_ca_send(gnrc_netdev_t *dev, gnrc_pktsnip_t *pkt) if (ok) { /* device does CSMA/CA all by itself: let it do its job */ DEBUG("csma: Network device does hardware CSMA/CA\n"); - return dev->driver->send_data(dev, pkt); + return dev->driver->send(dev, vector, count); } /* if we arrive here, then we must perform the CSMA/CA procedure @@ -179,7 +180,7 @@ int csma_sender_csma_ca_send(gnrc_netdev_t *dev, gnrc_pktsnip_t *pkt) xtimer_usleep(bp); /* try to send after a CCA */ - res = send_if_cca(dev, pkt); + res = send_if_cca(dev, vector, count); if (res >= 0) { /* TX done */ return res; @@ -205,7 +206,7 @@ int csma_sender_csma_ca_send(gnrc_netdev_t *dev, gnrc_pktsnip_t *pkt) } -int csma_sender_cca_send(gnrc_netdev_t *dev, gnrc_pktsnip_t *pkt) +int csma_sender_cca_send(netdev2_t *dev, struct iovec *vector, unsigned count) { netopt_enable_t hwfeat; @@ -235,12 +236,12 @@ int csma_sender_cca_send(gnrc_netdev_t *dev, gnrc_pktsnip_t *pkt) if (ok) { /* device does auto-CCA: let him do its job */ DEBUG("csma: Network device does auto-CCA checking.\n"); - return dev->driver->send_data(dev, pkt); + return dev->driver->send(dev, vector, count); } /* if we arrive here, we must do CCA ourselves to see if radio medium is clear before sending */ - res = send_if_cca(dev, pkt); + res = send_if_cca(dev, vector, count); if (res == -EBUSY) { DEBUG("csma: Transmission cancelled!\n"); }