From 35a99841224fac9c0d25388fe2c371d591e24195 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Tue, 16 May 2017 21:38:02 +0200 Subject: [PATCH] Removing the need for nullrdc-noframer --- core/net/mac/nullrdc-noframer.c | 112 ------------------------ core/net/mac/nullrdc-noframer.h | 48 ---------- examples/ipv6/slip-radio/no-framer.c | 6 ++ examples/ipv6/slip-radio/project-conf.h | 2 +- examples/ipv6/slip-radio/slip-radio.c | 5 +- 5 files changed, 10 insertions(+), 163 deletions(-) delete mode 100644 core/net/mac/nullrdc-noframer.c delete mode 100644 core/net/mac/nullrdc-noframer.h diff --git a/core/net/mac/nullrdc-noframer.c b/core/net/mac/nullrdc-noframer.c deleted file mode 100644 index 562b5cbca..000000000 --- a/core/net/mac/nullrdc-noframer.c +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (c) 2007, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ - -/** - * \file - * A MAC protocol that does not do anything. - * \author - * Adam Dunkels - */ - -#include "net/mac/nullrdc-noframer.h" -#include "net/packetbuf.h" -#include "net/queuebuf.h" -#include "net/netstack.h" -#include - -/*---------------------------------------------------------------------------*/ -static void -send_packet(mac_callback_t sent, void *ptr) -{ - int ret; - if(NETSTACK_RADIO.send(packetbuf_hdrptr(), packetbuf_totlen()) == RADIO_TX_OK) { - ret = MAC_TX_OK; - } else { - ret = MAC_TX_ERR; - } - mac_call_sent_callback(sent, ptr, ret, 1); -} -/*---------------------------------------------------------------------------*/ -static void -send_list(mac_callback_t sent, void *ptr, struct rdc_buf_list *buf_list) -{ - if(buf_list != NULL) { - queuebuf_to_packetbuf(buf_list->buf); - send_packet(sent, ptr); - } -} -/*---------------------------------------------------------------------------*/ -static void -packet_input(void) -{ - NETSTACK_MAC.input(); -} -/*---------------------------------------------------------------------------*/ -static int -on(void) -{ - return NETSTACK_RADIO.on(); -} -/*---------------------------------------------------------------------------*/ -static int -off(int keep_radio_on) -{ - if(keep_radio_on) { - return NETSTACK_RADIO.on(); - } else { - return NETSTACK_RADIO.off(); - } -} -/*---------------------------------------------------------------------------*/ -static unsigned short -channel_check_interval(void) -{ - return 0; -} -/*---------------------------------------------------------------------------*/ -static void -init(void) -{ - on(); -} -/*---------------------------------------------------------------------------*/ -const struct rdc_driver nullrdc_noframer_driver = { - "nullrdc-noframer", - init, - send_packet, - send_list, - packet_input, - on, - off, - channel_check_interval, -}; -/*---------------------------------------------------------------------------*/ diff --git a/core/net/mac/nullrdc-noframer.h b/core/net/mac/nullrdc-noframer.h deleted file mode 100644 index fd66a37e5..000000000 --- a/core/net/mac/nullrdc-noframer.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2007, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - * - */ - -/** - * \file - * A MAC protocol implementation that does not do anything. - * \author - * Adam Dunkels - */ - -#ifndef NULLRDC_NOFRAMER_H_ -#define NULLRDC_NOFRAMER_H_ - -#include "net/mac/rdc.h" -#include "dev/radio.h" - -extern const struct rdc_driver nullrdc_noframer_driver; - -#endif /* NULLRDC_NOFRAMER_H_ */ diff --git a/examples/ipv6/slip-radio/no-framer.c b/examples/ipv6/slip-radio/no-framer.c index 8d0ba9af4..58b43f786 100644 --- a/examples/ipv6/slip-radio/no-framer.c +++ b/examples/ipv6/slip-radio/no-framer.c @@ -91,6 +91,12 @@ create(void) /*---------------------------------------------------------------------------*/ static int parse(void) +{ + return 0; +} +/*---------------------------------------------------------------------------*/ +int +no_framer_parse_802154_frame(void) { frame802154_t frame; int len; diff --git a/examples/ipv6/slip-radio/project-conf.h b/examples/ipv6/slip-radio/project-conf.h index 7ef16407a..1d59baf01 100644 --- a/examples/ipv6/slip-radio/project-conf.h +++ b/examples/ipv6/slip-radio/project-conf.h @@ -60,7 +60,7 @@ #define NETSTACK_CONF_MAC nullmac_driver #undef NETSTACK_CONF_RDC -#define NETSTACK_CONF_RDC nullrdc_noframer_driver +#define NETSTACK_CONF_RDC nullrdc_driver #undef NETSTACK_CONF_NETWORK #define NETSTACK_CONF_NETWORK slipnet_driver diff --git a/examples/ipv6/slip-radio/slip-radio.c b/examples/ipv6/slip-radio/slip-radio.c index 05b5eb697..6f56591e7 100644 --- a/examples/ipv6/slip-radio/slip-radio.c +++ b/examples/ipv6/slip-radio/slip-radio.c @@ -53,7 +53,8 @@ extern const struct slip_radio_sensors SLIP_RADIO_CONF_SENSORS; #endif void slip_send_packet(const uint8_t *ptr, int len); - +void no_framer_parse_802154_frame(void); + /* max 16 packets at the same time??? */ uint8_t packet_ids[16]; int packet_pos; @@ -124,7 +125,7 @@ slip_radio_cmd_handler(const uint8_t *data, int len) data[2], packetbuf_datalen()); /* parse frame before sending to get addresses, etc. */ - no_framer.parse(); + no_framer_parse_802154_frame(); NETSTACK_MAC.send(packet_sent, &packet_ids[packet_pos]); packet_pos++;