From 5cf3b83733af1e6374d0705f94570de0e9a9100b Mon Sep 17 00:00:00 2001 From: adamdunkels Date: Thu, 18 Feb 2010 23:15:26 +0000 Subject: [PATCH] Common initialization code for the netstack --- Makefile.include | 6 ++++-- core/net/netstack.c | 51 +++++++++++++++++++++++++++++++++++++++++++++ core/net/netstack.h | 4 +++- 3 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 core/net/netstack.c diff --git a/Makefile.include b/Makefile.include index 71a93461b..14afba6c9 100644 --- a/Makefile.include +++ b/Makefile.include @@ -54,16 +54,18 @@ THREADS = mt.c LIBS = memb.c mmem.c timer.c list.c etimer.c energest.c rtimer.c stimer.c \ print-stats.c ifft.c crc16.c random.c checkpoint.c ringbuf.c +NET = netstack.c + ifdef UIP_CONF_IPV6 CFLAGS += -DUIP_CONF_IPV6 UIP = uip6.c tcpip.c psock.c uip-udp-packet.c uip-split.c \ resolv.c tcpdump.c uiplib.c - NET = $(UIP) uip-icmp6.c uip-nd6.c uip-nd6-io.c uip-netif.c sicslowpan.c + NET += $(UIP) uip-icmp6.c uip-nd6.c uip-nd6-io.c uip-netif.c sicslowpan.c else # UIP_CONF_IPV6 UIP = uip.c uiplib.c resolv.c tcpip.c psock.c hc.c uip-split.c uip-fw.c \ uip-fw-drv.c uip_arp.c tcpdump.c uip-neighbor.c uip-udp-packet.c \ uip-over-mesh.c dhcpc.c #rawpacket-udp.c - NET = $(UIP) uaodv.c uaodv-rt.c + NET += $(UIP) uaodv.c uaodv-rt.c endif # UIP_CONF_IPV6 CTK = ctk.c diff --git a/core/net/netstack.c b/core/net/netstack.c new file mode 100644 index 000000000..c5f6e4060 --- /dev/null +++ b/core/net/netstack.c @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2010, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is part of the Contiki operating system. + * + * $Id: netstack.c,v 1.1 2010/02/18 23:15:26 adamdunkels Exp $ + */ + +/** + * \file + * Initialiation file for the Contiki low-layer network stack (NETSTACK) + * \author + * Adam Dunkels + */ + +#include "net/netstack.h" +/*---------------------------------------------------------------------------*/ +void +netstack_init(void) +{ + NETSTACK_RADIO.init(); + NETSTACK_RDC.init(); + NETSTACK_MAC.init(); + NETSTACK_NETWORK.init(); +} +/*---------------------------------------------------------------------------*/ diff --git a/core/net/netstack.h b/core/net/netstack.h index 9c44e03e7..1b43260d8 100644 --- a/core/net/netstack.h +++ b/core/net/netstack.h @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * $Id: netstack.h,v 1.1 2010/02/18 21:50:33 adamdunkels Exp $ + * $Id: netstack.h,v 1.2 2010/02/18 23:15:26 adamdunkels Exp $ */ /** @@ -83,4 +83,6 @@ extern const struct mac_driver NETSTACK_RDC; extern const struct mac_driver NETSTACK_MAC; extern const struct radio_driver NETSTACK_RADIO; +void netstack_init(void); + #endif /* NETSTACK_H */