Contiki-NG
Toggle main menu visibility
Loading...
Searching...
No Matches
nullframer.c
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2009, 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
*/
30
31
/**
32
* \file
33
* MAC framer that does nothing...
34
* \author
35
* Niclas Finne <nfi@sics.se>
36
* Joakim Eriksson <joakime@sics.se>
37
*/
38
#include "
net/mac/framer/framer.h
"
39
#include "
net/mac/framer/frame802154.h
"
40
#include "
net/packetbuf.h
"
41
42
#ifdef NULLFRAMER_CONF_PARSE_802154
43
#define NULLFRAMER_PARSE_802154 NULLFRAMER_CONF_PARSE_802154
44
#else
45
/* defaults to parsing of the 802154 header as that is used for Slip-Radio */
46
#define NULLFRAMER_PARSE_802154 1
47
#endif
48
49
/*---------------------------------------------------------------------------*/
50
#if NULLFRAMER_PARSE_802154
51
static
int
52
is_broadcast_addr(uint8_t mode,
const
uint8_t *
addr
)
53
{
54
int
i = mode == FRAME802154_SHORTADDRMODE ? 2 : 8;
55
while
(i-- > 0) {
56
if
(
addr
[i] != 0xff) {
57
return
0;
58
}
59
}
60
return
1;
61
}
62
#endif
/* NULLFRAMER_PARSE_802154 */
63
/*---------------------------------------------------------------------------*/
64
static
int
65
hdr_length(
void
)
66
{
67
/* never adds any header */
68
return
0;
69
}
70
/*---------------------------------------------------------------------------*/
71
static
int
72
create(
void
)
73
{
74
/* nothing extra... */
75
return
0;
76
}
77
/*---------------------------------------------------------------------------*/
78
static
int
79
parse(
void
)
80
{
81
#if NULLFRAMER_PARSE_802154
82
frame802154_t
frame;
83
int
len;
84
len =
packetbuf_datalen
();
85
if
(
frame802154_parse
(
packetbuf_dataptr
(), len, &frame)) {
86
if
(frame.
fcf
.
dest_addr_mode
) {
87
if
(!is_broadcast_addr(frame.
fcf
.
dest_addr_mode
, frame.
dest_addr
)) {
88
packetbuf_set_addr(PACKETBUF_ADDR_RECEIVER, (linkaddr_t *)&frame.
dest_addr
);
89
}
90
}
91
packetbuf_set_addr(PACKETBUF_ADDR_SENDER, (linkaddr_t *)&frame.
src_addr
);
92
packetbuf_set_attr(PACKETBUF_ATTR_MAC_SEQNO, frame.
seq
);
93
packetbuf_set_attr(PACKETBUF_ATTR_MAC_ACK, frame.
fcf
.
ack_required
);
94
}
95
#endif
96
return
0;
97
}
98
/*---------------------------------------------------------------------------*/
99
const
struct
framer no_framer = {
100
hdr_length,
101
create,
102
parse
103
};
frame802154.h
802.15.4 frame creation and parsing functions
framer.h
A MAC framer is responsible for constructing and parsing the header in MAC frames.
frame802154_parse
int frame802154_parse(uint8_t *data, int len, frame802154_t *pf)
Parses an input frame.
Definition
frame802154.c:563
packetbuf_dataptr
void * packetbuf_dataptr(void)
Get a pointer to the data in the packetbuf.
Definition
packetbuf.c:143
packetbuf_datalen
uint16_t packetbuf_datalen(void)
Get the length of the data in the packetbuf.
Definition
packetbuf.c:155
packetbuf.h
Header file for the Packet buffer (packetbuf) management.
frame802154_fcf_t::ack_required
uint8_t ack_required
1 bit.
Definition
frame802154.h:158
frame802154_fcf_t::dest_addr_mode
uint8_t dest_addr_mode
2 bit.
Definition
frame802154.h:163
frame802154_t
Parameters used by the frame802154_create() function.
Definition
frame802154.h:201
frame802154_t::seq
uint8_t seq
Sequence number.
Definition
frame802154.h:208
frame802154_t::dest_addr
uint8_t dest_addr[8]
Destination address.
Definition
frame802154.h:205
frame802154_t::src_addr
uint8_t src_addr[8]
Source address.
Definition
frame802154.h:206
frame802154_t::fcf
frame802154_fcf_t fcf
Frame control field.
Definition
frame802154.h:207
addr
static uip_ds6_addr_t * addr
Pointer to a nbr cache entry.
Definition
uip-nd6.c:107
os
net
mac
framer
nullframer.c
Generated on
for Contiki-NG by
1.17.0