blob: 4898b4273239c16d5fc2022722bcb90eb1635e73 [file] [log] [blame]
adamdunkelsa2f3c422004-09-12 20:24:53 +00001/*
2 * Copyright (c) 2004, 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 * Author: Adam Dunkels <adam@sics.se>
32 *
adamdunkels4bbc0c32005-02-07 07:06:59 +000033 * $Id: uip-fw-service.c,v 1.4 2005/02/07 07:06:59 adamdunkels Exp $
adamdunkelsa2f3c422004-09-12 20:24:53 +000034 */
adamdunkels2ae42d82004-07-04 16:59:52 +000035
36#include "packet-service.h"
37
38#include "uip-fw.h"
39
40static void output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen);
41
42static const struct packet_service_state state =
43 {
44 PACKET_SERVICE_VERSION,
45 output
46 };
47
48EK_EVENTHANDLER(eventhandler, ev, data);
49EK_POLLHANDLER(pollhandler);
adamdunkels4bbc0c32005-02-07 07:06:59 +000050EK_PROCESS(proc, PACKET_SERVICE_NAME ": IP forwarding", EK_PRIO_NORMAL,
51 eventhandler, NULL, (void *)&state);
adamdunkels2ae42d82004-07-04 16:59:52 +000052
53/*---------------------------------------------------------------------------*/
54EK_PROCESS_INIT(uip_fw_service_init, arg)
adamdunkels4bbc0c32005-02-07 07:06:59 +000055{
adamdunkels2ae42d82004-07-04 16:59:52 +000056 ek_service_start(PACKET_SERVICE_NAME, &proc);
57}
58/*---------------------------------------------------------------------------*/
59static void
60output(u8_t *hdr, u16_t hdrlen, u8_t *data, u16_t datalen)
61{
62 uip_fw_output();
63}
64/*---------------------------------------------------------------------------*/
65EK_EVENTHANDLER(eventhandler, ev, data)
66{
67 switch(ev) {
68 case EK_EVENT_INIT:
adamdunkelsaf6f2ef2004-09-09 21:49:45 +000069 case EK_EVENT_REPLACE:
adamdunkels2ae42d82004-07-04 16:59:52 +000070 break;
71 case EK_EVENT_REQUEST_REPLACE:
72 ek_replace((struct ek_proc *)data, NULL);
73 LOADER_UNLOAD();
74 break;
75 case EK_EVENT_REQUEST_EXIT:
76 ek_exit();
77 LOADER_UNLOAD();
78 break;
79 default:
80 break;
81 }
82
83}
84/*---------------------------------------------------------------------------*/