Contiki-Inga 3.x
Main Page
Related Pages
Modules
Data Structures
Files
Examples
File List
Globals
core
net
rime
broadcast.h
Go to the documentation of this file.
1
/**
2
* \addtogroup rime
3
* @{
4
*/
5
6
/**
7
* \defgroup rimeibc Best-effort local area broadcast
8
* @{
9
*
10
* The broadcast module sends packets to all local area neighbors with an a
11
* header that identifies the sender.
12
*
13
* The broadcast module sends a packet to all local neighbors. The
14
* module adds the single-hop sender address as a packet attribute to
15
* outgoing packets. All Rime primitives that need the identity of
16
* the sender in the outgoing packets use the broadcast primitive,
17
* either directly or indirectly through any of the other
18
* communication primitives that are based on the broadcast primitive.
19
*
20
* \section channels Channels
21
*
22
* The broadcast module uses 1 channel.
23
*
24
*/
25
26
/*
27
* Copyright (c) 2006, Swedish Institute of Computer Science.
28
* All rights reserved.
29
*
30
* Redistribution and use in source and binary forms, with or without
31
* modification, are permitted provided that the following conditions
32
* are met:
33
* 1. Redistributions of source code must retain the above copyright
34
* notice, this list of conditions and the following disclaimer.
35
* 2. Redistributions in binary form must reproduce the above copyright
36
* notice, this list of conditions and the following disclaimer in the
37
* documentation and/or other materials provided with the distribution.
38
* 3. Neither the name of the Institute nor the names of its contributors
39
* may be used to endorse or promote products derived from this software
40
* without specific prior written permission.
41
*
42
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
43
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
44
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
45
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
46
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
47
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
48
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
49
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
50
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
51
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
52
* SUCH DAMAGE.
53
*
54
* This file is part of the Contiki operating system.
55
*
56
*/
57
58
/**
59
* \file
60
* Header file for identified best-effort local area broadcast
61
* \author
62
* Adam Dunkels <adam@sics.se>
63
*/
64
65
#ifndef BROADCAST_H_
66
#define BROADCAST_H_
67
68
#include "
net/rime/abc.h
"
69
#include "
net/linkaddr.h
"
70
71
struct
broadcast_conn;
72
73
#define BROADCAST_ATTRIBUTES { PACKETBUF_ADDR_SENDER, PACKETBUF_ADDRSIZE }, \
74
ABC_ATTRIBUTES
75
76
/**
77
* \brief Callback structure for broadcast
78
*
79
*/
80
struct
broadcast_callbacks
{
81
/** Called when a packet has been received by the broadcast module. */
82
void (*
recv
)(
struct
broadcast_conn *ptr,
const
linkaddr_t *sender);
83
void (* sent)(
struct
broadcast_conn *ptr,
int
status,
int
num_tx);
84
};
85
86
struct
broadcast_conn {
87
struct
abc_conn c;
88
const
struct
broadcast_callbacks
*u;
89
};
90
91
/**
92
* \brief Set up an identified best-effort broadcast connection
93
* \param c A pointer to a struct broadcast_conn
94
* \param channel The channel on which the connection will operate
95
* \param u A struct broadcast_callbacks with function pointers to functions that will be called when a packet has been received
96
*
97
* This function sets up a broadcast connection on the
98
* specified channel. The caller must have allocated the
99
* memory for the struct broadcast_conn, usually by declaring it
100
* as a static variable.
101
*
102
* The struct broadcast_callbacks pointer must point to a structure
103
* containing a pointer to a function that will be called
104
* when a packet arrives on the channel.
105
*
106
*/
107
void
broadcast_open
(
struct
broadcast_conn *c, uint16_t channel,
108
const
struct
broadcast_callbacks
*u);
109
110
/**
111
* \brief Close a broadcast connection
112
* \param c A pointer to a struct broadcast_conn
113
*
114
* This function closes a broadcast connection that has
115
* previously been opened with broadcast_open().
116
*
117
* This function typically is called as an exit handler.
118
*
119
*/
120
void
broadcast_close
(
struct
broadcast_conn *c);
121
122
/**
123
* \brief Send an identified best-effort broadcast packet
124
* \param c The broadcast connection on which the packet should be sent
125
* \retval Non-zero if the packet could be sent, zero otherwise
126
*
127
* This function sends an identified best-effort broadcast
128
* packet. The packet must be present in the packetbuf
129
* before this function is called.
130
*
131
* The parameter c must point to a broadcast connection that
132
* must have previously been set up with broadcast_open().
133
*
134
*/
135
int
broadcast_send
(
struct
broadcast_conn *c);
136
137
#endif
/* BROADCAST_H_ */
138
/** @} */
139
/** @} */
Generated on Thu Apr 24 2014 16:26:12 for Contiki-Inga 3.x by
1.8.3.1