netstack.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2010, Swedish Institute of Computer Science.
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  * 1. Redistributions of source code must retain the above copyright
00009  *    notice, this list of conditions and the following disclaimer.
00010  * 2. Redistributions in binary form must reproduce the above copyright
00011  *    notice, this list of conditions and the following disclaimer in the
00012  *    documentation and/or other materials provided with the distribution.
00013  * 3. Neither the name of the Institute nor the names of its contributors
00014  *    may be used to endorse or promote products derived from this software
00015  *    without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
00018  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020  * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
00021  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00022  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00023  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00024  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00025  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00026  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00027  * SUCH DAMAGE.
00028  *
00029  * This file is part of the Contiki operating system.
00030  *
00031  * $Id: netstack.h,v 1.6 2010/10/03 20:37:32 adamdunkels Exp $
00032  */
00033 
00034 /**
00035  * \file
00036  *         Include file for the Contiki low-layer network stack (NETSTACK)
00037  * \author
00038  *         Adam Dunkels <adam@sics.se>
00039  */
00040 
00041 #ifndef NETSTACK_H
00042 #define NETSTACK_H
00043 
00044 #include "contiki-conf.h"
00045 
00046 #ifndef NETSTACK_NETWORK
00047 #ifdef NETSTACK_CONF_NETWORK
00048 #define NETSTACK_NETWORK NETSTACK_CONF_NETWORK
00049 #else /* NETSTACK_CONF_NETWORK */
00050 #define NETSTACK_NETWORK rime_driver
00051 #endif /* NETSTACK_CONF_NETWORK */
00052 #endif /* NETSTACK_NETWORK */
00053 
00054 #ifndef NETSTACK_MAC
00055 #ifdef NETSTACK_CONF_MAC
00056 #define NETSTACK_MAC NETSTACK_CONF_MAC
00057 #else /* NETSTACK_CONF_MAC */
00058 #define NETSTACK_MAC     nullmac_driver
00059 #endif /* NETSTACK_CONF_MAC */
00060 #endif /* NETSTACK_MAC */
00061 
00062 #ifndef NETSTACK_RDC
00063 #ifdef NETSTACK_CONF_RDC
00064 #define NETSTACK_RDC NETSTACK_CONF_RDC
00065 #else /* NETSTACK_CONF_RDC */
00066 #define NETSTACK_RDC     nullrdc_driver
00067 #endif /* NETSTACK_CONF_RDC */
00068 #endif /* NETSTACK_RDC */
00069 
00070 #ifndef NETSTACK_RDC_CHANNEL_CHECK_RATE
00071 #ifdef NETSTACK_CONF_RDC_CHANNEL_CHECK_RATE
00072 #define NETSTACK_RDC_CHANNEL_CHECK_RATE NETSTACK_CONF_RDC_CHANNEL_CHECK_RATE
00073 #else /* NETSTACK_CONF_RDC_CHANNEL_CHECK_RATE */
00074 #define NETSTACK_RDC_CHANNEL_CHECK_RATE 4
00075 #endif /* NETSTACK_CONF_RDC_CHANNEL_CHECK_RATE */
00076 #endif /* NETSTACK_RDC_CHANNEL_CHECK_RATE */
00077 
00078 #if (NETSTACK_RDC_CHANNEL_CHECK_RATE & (NETSTACK_RDC_CHANNEL_CHECK_RATE - 1)) != 0
00079 #error NETSTACK_RDC_CONF_CHANNEL_CHECK_RATE must be a power of two (i.e., 1, 2, 4, 8, 16, 32, 64, ...).
00080 #error Change NETSTACK_RDC_CONF_CHANNEL_CHECK_RATE in contiki-conf.h, project-conf.h or in your Makefile.
00081 #endif
00082 
00083 
00084 #ifndef NETSTACK_RADIO
00085 #ifdef NETSTACK_CONF_RADIO
00086 #define NETSTACK_RADIO NETSTACK_CONF_RADIO
00087 #else /* NETSTACK_CONF_RADIO */
00088 #define NETSTACK_RADIO   nullradio_driver
00089 #endif /* NETSTACK_CONF_RADIO */
00090 #endif /* NETSTACK_RADIO */
00091 
00092 #ifndef NETSTACK_FRAMER
00093 #ifdef NETSTACK_CONF_FRAMER
00094 #define NETSTACK_FRAMER NETSTACK_CONF_FRAMER
00095 #else /* NETSTACK_CONF_FRAMER */
00096 #define NETSTACK_FRAMER   framer_nullmac
00097 #endif /* NETSTACK_CONF_FRAMER */
00098 #endif /* NETSTACK_FRAMER */
00099 
00100 #include "net/mac/mac.h"
00101 #include "net/mac/rdc.h"
00102 #include "net/mac/framer.h"
00103 #include "dev/radio.h"
00104 
00105 /**
00106  * The structure of a network driver in Contiki.
00107  */
00108 struct network_driver {
00109   char *name;
00110 
00111   /** Initialize the network driver */
00112   void (* init)(void);
00113 
00114   /** Callback for getting notified of incoming packet. */
00115   void (* input)(void);
00116 };
00117 
00118 extern const struct network_driver NETSTACK_NETWORK;
00119 extern const struct rdc_driver     NETSTACK_RDC;
00120 extern const struct mac_driver     NETSTACK_MAC;
00121 extern const struct radio_driver   NETSTACK_RADIO;
00122 extern const struct framer         NETSTACK_FRAMER;
00123 
00124 void netstack_init(void);
00125 
00126 #endif /* NETSTACK_H */

Generated on Mon Apr 11 14:23:29 2011 for Contiki 2.5 by  doxygen 1.6.1