Contiki 2.5
netstack.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010, 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  * $Id: netstack.h,v 1.6 2010/10/03 20:37:32 adamdunkels Exp $
32  */
33 
34 /**
35  * \file
36  * Include file for the Contiki low-layer network stack (NETSTACK)
37  * \author
38  * Adam Dunkels <adam@sics.se>
39  */
40 
41 #ifndef NETSTACK_H
42 #define NETSTACK_H
43 
44 #include "contiki-conf.h"
45 
46 #ifndef NETSTACK_NETWORK
47 #ifdef NETSTACK_CONF_NETWORK
48 #define NETSTACK_NETWORK NETSTACK_CONF_NETWORK
49 #else /* NETSTACK_CONF_NETWORK */
50 #define NETSTACK_NETWORK rime_driver
51 #endif /* NETSTACK_CONF_NETWORK */
52 #endif /* NETSTACK_NETWORK */
53 
54 #ifndef NETSTACK_MAC
55 #ifdef NETSTACK_CONF_MAC
56 #define NETSTACK_MAC NETSTACK_CONF_MAC
57 #else /* NETSTACK_CONF_MAC */
58 #define NETSTACK_MAC nullmac_driver
59 #endif /* NETSTACK_CONF_MAC */
60 #endif /* NETSTACK_MAC */
61 
62 #ifndef NETSTACK_RDC
63 #ifdef NETSTACK_CONF_RDC
64 #define NETSTACK_RDC NETSTACK_CONF_RDC
65 #else /* NETSTACK_CONF_RDC */
66 #define NETSTACK_RDC nullrdc_driver
67 #endif /* NETSTACK_CONF_RDC */
68 #endif /* NETSTACK_RDC */
69 
70 #ifndef NETSTACK_RDC_CHANNEL_CHECK_RATE
71 #ifdef NETSTACK_CONF_RDC_CHANNEL_CHECK_RATE
72 #define NETSTACK_RDC_CHANNEL_CHECK_RATE NETSTACK_CONF_RDC_CHANNEL_CHECK_RATE
73 #else /* NETSTACK_CONF_RDC_CHANNEL_CHECK_RATE */
74 #define NETSTACK_RDC_CHANNEL_CHECK_RATE 8
75 #endif /* NETSTACK_CONF_RDC_CHANNEL_CHECK_RATE */
76 #endif /* NETSTACK_RDC_CHANNEL_CHECK_RATE */
77 
78 #if (NETSTACK_RDC_CHANNEL_CHECK_RATE & (NETSTACK_RDC_CHANNEL_CHECK_RATE - 1)) != 0
79 #error NETSTACK_RDC_CONF_CHANNEL_CHECK_RATE must be a power of two (i.e., 1, 2, 4, 8, 16, 32, 64, ...).
80 #error Change NETSTACK_RDC_CONF_CHANNEL_CHECK_RATE in contiki-conf.h, project-conf.h or in your Makefile.
81 #endif
82 
83 
84 #ifndef NETSTACK_RADIO
85 #ifdef NETSTACK_CONF_RADIO
86 #define NETSTACK_RADIO NETSTACK_CONF_RADIO
87 #else /* NETSTACK_CONF_RADIO */
88 #define NETSTACK_RADIO nullradio_driver
89 #endif /* NETSTACK_CONF_RADIO */
90 #endif /* NETSTACK_RADIO */
91 
92 #ifndef NETSTACK_FRAMER
93 #ifdef NETSTACK_CONF_FRAMER
94 #define NETSTACK_FRAMER NETSTACK_CONF_FRAMER
95 #else /* NETSTACK_CONF_FRAMER */
96 #define NETSTACK_FRAMER framer_nullmac
97 #endif /* NETSTACK_CONF_FRAMER */
98 #endif /* NETSTACK_FRAMER */
99 
100 #include "net/mac/mac.h"
101 #include "net/mac/rdc.h"
102 #include "net/mac/framer.h"
103 #include "dev/radio.h"
104 
105 /**
106  * The structure of a network driver in Contiki.
107  */
109  char *name;
110 
111  /** Initialize the network driver */
112  void (* init)(void);
113 
114  /** Callback for getting notified of incoming packet. */
115  void (* input)(void);
116 };
117 
118 extern const struct network_driver NETSTACK_NETWORK;
119 extern const struct rdc_driver NETSTACK_RDC;
120 extern const struct mac_driver NETSTACK_MAC;
121 extern const struct radio_driver NETSTACK_RADIO;
122 extern const struct framer NETSTACK_FRAMER;
123 
124 void netstack_init(void);
125 
126 #endif /* NETSTACK_H */