Contiki 3.x
nullrdc-noframer.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2007, Swedish Institute of Computer Science.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * 3. Neither the name of the Institute nor the names of its contributors
14  * may be used to endorse or promote products derived from this software
15  * without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  *
29  * This file is part of the Contiki operating system.
30  *
31  */
32 
33 /**
34  * \file
35  * A MAC protocol that does not do anything.
36  * \author
37  * Adam Dunkels <adam@sics.se>
38  */
39 
41 #include "net/packetbuf.h"
42 #include "net/queuebuf.h"
43 #include "net/netstack.h"
44 #include <string.h>
45 
46 /*---------------------------------------------------------------------------*/
47 static void
48 send_packet(mac_callback_t sent, void *ptr)
49 {
50  int ret;
51  if(NETSTACK_RADIO.send(packetbuf_hdrptr(), packetbuf_totlen()) == RADIO_TX_OK) {
52  ret = MAC_TX_OK;
53  } else {
54  ret = MAC_TX_ERR;
55  }
56  mac_call_sent_callback(sent, ptr, ret, 1);
57 }
58 /*---------------------------------------------------------------------------*/
59 static void
60 send_list(mac_callback_t sent, void *ptr, struct rdc_buf_list *buf_list)
61 {
62  if(buf_list != NULL) {
63  queuebuf_to_packetbuf(buf_list->buf);
64  send_packet(sent, ptr);
65  }
66 }
67 /*---------------------------------------------------------------------------*/
68 static void
69 packet_input(void)
70 {
71  NETSTACK_MAC.input();
72 }
73 /*---------------------------------------------------------------------------*/
74 static int
75 on(void)
76 {
77  return NETSTACK_RADIO.on();
78 }
79 /*---------------------------------------------------------------------------*/
80 static int
81 off(int keep_radio_on)
82 {
83  if(keep_radio_on) {
84  return NETSTACK_RADIO.on();
85  } else {
86  return NETSTACK_RADIO.off();
87  }
88 }
89 /*---------------------------------------------------------------------------*/
90 static unsigned short
92 {
93  return 0;
94 }
95 /*---------------------------------------------------------------------------*/
96 static void
97 init(void)
98 {
99  on();
100 }
101 /*---------------------------------------------------------------------------*/
102 const struct rdc_driver nullrdc_noframer_driver = {
103  "nullrdc-noframer",
104  init,
105  send_packet,
106  send_list,
107  packet_input,
108  on,
109  off,
111 };
112 /*---------------------------------------------------------------------------*/
unsigned short(* channel_check_interval)(void)
Returns the channel check interval, expressed in clock_time_t ticks.
Definition: mac.h:73
Header file for the Rime buffer (packetbuf) management
#define NULL
The null pointer.
int(* off)(int keep_radio_on)
Turn the MAC layer off.
Definition: mac.h:70
The MAC layer transmission could not be performed because of a fatal error.
Definition: mac.h:93
A MAC protocol implementation that does not do anything.
uint16_t packetbuf_totlen(void)
Get the total length of the header and data in the packetbuf.
Definition: packetbuf.c:260
void * packetbuf_hdrptr(void)
Get a pointer to the header in the packetbuf, for outbound packets.
Definition: packetbuf.c:213
int(* on)(void)
Turn the MAC layer on.
Definition: mac.h:67
int(* off)(int keep_radio_on)
Turn the MAC layer off.
Definition: rdc.h:86
Header file for the Rime queue buffer management
void(* init)(void)
Initialize the MAC driver.
Definition: mac.h:58
unsigned short(* channel_check_interval)(void)
Returns the channel check interval, expressed in clock_time_t ticks.
Definition: rdc.h:89
The structure of a RDC (radio duty cycling) driver in Contiki.
Definition: rdc.h:67
void(* init)(void)
Initialize the RDC driver.
Definition: rdc.h:71
The MAC layer transmission was OK.
Definition: mac.h:79
int(* on)(void)
Turn the MAC layer on.
Definition: rdc.h:83
void(* send_list)(mac_callback_t sent_callback, void *ptr, struct rdc_buf_list *list)
Send a packet list.
Definition: rdc.h:77
Include file for the Contiki low-layer network stack (NETSTACK)