Contiki-NG
Toggle main menu visibility
Loading...
Searching...
No Matches
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
55
typedef
void (* mac_callback_t)(
void
*ptr,
int
status,
int
transmissions);
56
57
static
inline
void
58
mac_call_sent_callback(mac_callback_t sent,
void
*ptr,
int
status,
int
num_tx)
59
{
60
if
(sent) {
61
sent(ptr, status, num_tx);
62
}
63
}
64
65
/**
66
* The structure of a MAC protocol driver in Contiki.
67
*/
68
struct
mac_driver
{
69
char
*name;
70
71
/** Initialize the MAC driver */
72
void (*
init
)(void);
73
74
/** Send a packet from the packetbuf */
75
void (*
send
)(mac_callback_t sent_callback,
void
*ptr);
76
77
/** Callback for getting notified of incoming packet. */
78
void (*
input
)(void);
79
80
/** Turn the MAC layer on. */
81
int (*
on
)(void);
82
83
/** Turn the MAC layer off. */
84
int (*
off
)(void);
85
86
/** Read out estimated max payload size based on payload in packetbuf */
87
int (*
max_payload
)(void);
88
};
89
90
/* Generic MAC return values. */
91
enum
{
92
/**< The MAC layer transmission was OK. */
93
MAC_TX_OK
,
94
95
/**< The MAC layer transmission could not be performed due to a
96
collision. */
97
MAC_TX_COLLISION
,
98
99
/**< The MAC layer did not get an acknowledgement for the packet. */
100
MAC_TX_NOACK
,
101
102
/**< The MAC layer deferred the transmission for a later time. */
103
MAC_TX_DEFERRED
,
104
105
/**< The MAC layer transmission could not be performed because of an
106
error. The upper layer may try again later. */
107
MAC_TX_ERR
,
108
109
/**< The MAC layer transmission could not be performed because of a
110
fatal error. The upper layer does not need to try again, as the
111
error will be fatal then as well. */
112
MAC_TX_ERR_FATAL
,
113
114
/**< The MAC layer transmission could not be performed because of
115
insufficient queue space, failure to allocate a neighbor,
116
or insufficient packet memory space. The upper layer may try again later. */
117
MAC_TX_QUEUE_FULL,
118
};
119
120
#endif
/* MAC_H_ */
MAC_TX_COLLISION
@ MAC_TX_COLLISION
The MAC layer did not get an acknowledgement for the packet.
Definition
mac.h:97
MAC_TX_DEFERRED
@ MAC_TX_DEFERRED
The MAC layer transmission could not be performed because of an error.
Definition
mac.h:103
MAC_TX_OK
@ MAC_TX_OK
The MAC layer transmission was OK.
Definition
mac.h:93
MAC_TX_NOACK
@ MAC_TX_NOACK
The MAC layer deferred the transmission for a later time.
Definition
mac.h:100
MAC_TX_ERR_FATAL
@ MAC_TX_ERR_FATAL
The MAC layer transmission could not be performed because of insufficient queue space,...
Definition
mac.h:112
MAC_TX_ERR
@ MAC_TX_ERR
The MAC layer transmission could not be performed because of a fatal error.
Definition
mac.h:107
radio.h
Header file for the radio API.
mac_driver
The structure of a MAC protocol driver in Contiki.
Definition
mac.h:68
mac_driver::on
int(* on)(void)
Turn the MAC layer on.
Definition
mac.h:81
mac_driver::max_payload
int(* max_payload)(void)
Read out estimated max payload size based on payload in packetbuf.
Definition
mac.h:87
mac_driver::off
int(* off)(void)
Turn the MAC layer off.
Definition
mac.h:84
mac_driver::init
void(* init)(void)
Initialize the MAC driver.
Definition
mac.h:72
mac_driver::input
void(* input)(void)
Callback for getting notified of incoming packet.
Definition
mac.h:78
mac_driver::send
void(* send)(mac_callback_t sent_callback, void *ptr)
Send a packet from the packetbuf.
Definition
mac.h:75
os
net
mac
mac.h
Generated on
for Contiki-NG by
1.17.0