Contiki-NG
mac.h
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 * MAC driver header file
36 * \author
37 * Adam Dunkels <adam@sics.se>
38 */
39
40#ifndef MAC_H_
41#define MAC_H_
42
43#include "contiki.h"
44#include "dev/radio.h"
45
46/**
47 *\brief The default channel for IEEE 802.15.4 networks.
48 */
49#ifdef IEEE802154_CONF_DEFAULT_CHANNEL
50#define IEEE802154_DEFAULT_CHANNEL IEEE802154_CONF_DEFAULT_CHANNEL
51#else /* IEEE802154_CONF_DEFAULT_CHANNEL */
52#define IEEE802154_DEFAULT_CHANNEL 26
53#endif /* IEEE802154_CONF_DEFAULT_CHANNEL */
54
55typedef void (* mac_callback_t)(void *ptr, int status, int transmissions);
56
57void mac_call_sent_callback(mac_callback_t sent, void *ptr, int status, int num_tx);
58
59/**
60 * The structure of a MAC protocol driver in Contiki.
61 */
62struct mac_driver {
63 char *name;
64
65 /** Initialize the MAC driver */
66 void (* init)(void);
67
68 /** Send a packet from the packetbuf */
69 void (* send)(mac_callback_t sent_callback, void *ptr);
70
71 /** Callback for getting notified of incoming packet. */
72 void (* input)(void);
73
74 /** Turn the MAC layer on. */
75 int (* on)(void);
76
77 /** Turn the MAC layer off. */
78 int (* off)(void);
79
80 /** Read out estimated max payload size based on payload in packetbuf */
81 int (* max_payload)(void);
82};
83
84/* Generic MAC return values. */
85enum {
86 /**< The MAC layer transmission was OK. */
88
89 /**< The MAC layer transmission could not be performed due to a
90 collision. */
92
93 /**< The MAC layer did not get an acknowledgement for the packet. */
95
96 /**< The MAC layer deferred the transmission for a later time. */
98
99 /**< The MAC layer transmission could not be performed because of an
100 error. The upper layer may try again later. */
102
103 /**< The MAC layer transmission could not be performed because of a
104 fatal error. The upper layer does not need to try again, as the
105 error will be fatal then as well. */
107
108 /**< The MAC layer transmission could not be performed because of
109 insufficient queue space, failure to allocate a neighbor,
110 or insufficient packet memory space. The upper layer may try again later. */
111 MAC_TX_QUEUE_FULL,
112};
113
114#endif /* MAC_H_ */
@ MAC_TX_COLLISION
The MAC layer did not get an acknowledgement for the packet.
Definition: mac.h:91
@ MAC_TX_DEFERRED
The MAC layer transmission could not be performed because of an error.
Definition: mac.h:97
@ MAC_TX_OK
The MAC layer transmission was OK.
Definition: mac.h:87
@ MAC_TX_NOACK
The MAC layer deferred the transmission for a later time.
Definition: mac.h:94
@ MAC_TX_ERR_FATAL
The MAC layer transmission could not be performed because of insufficient queue space,...
Definition: mac.h:106
@ MAC_TX_ERR
The MAC layer transmission could not be performed because of a fatal error.
Definition: mac.h:101
Header file for the radio API.
The structure of a MAC protocol driver in Contiki.
Definition: mac.h:62
int(* on)(void)
Turn the MAC layer on.
Definition: mac.h:75
int(* max_payload)(void)
Read out estimated max payload size based on payload in packetbuf.
Definition: mac.h:81
int(* off)(void)
Turn the MAC layer off.
Definition: mac.h:78
void(* init)(void)
Initialize the MAC driver.
Definition: mac.h:66
void(* input)(void)
Callback for getting notified of incoming packet.
Definition: mac.h:72
void(* send)(mac_callback_t sent_callback, void *ptr)
Send a packet from the packetbuf
Definition: mac.h:69