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