Contiki-NG
Toggle main menu visibility
Loading...
Searching...
No Matches
netstack.c
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
* Initialiation file for the Contiki low-layer network stack (NETSTACK)
36
* \author
37
* Adam Dunkels <adam@sics.se>
38
*/
39
40
#include "
net/netstack.h
"
41
#include "
lib/list.h
"
42
43
/* The list of IP processors that will process IP packets before uip or after */
44
LIST
(ip_processor_list);
45
46
/* Note: localdest is only used for the output callback */
47
enum
netstack_ip_action
48
netstack_process_ip_callback(uint8_t type,
const
linkaddr_t *localdest)
49
{
50
enum
netstack_ip_action action = NETSTACK_IP_PROCESS;
51
struct
netstack_ip_packet_processor *p;
52
for
(p =
list_head
(ip_processor_list);
53
p != NULL;
54
p =
list_item_next
(p)) {
55
if
(type == NETSTACK_IP_OUTPUT) {
56
if
(p->process_output != NULL) {
57
action = p->process_output(localdest);
58
}
59
}
else
if
(type == NETSTACK_IP_INPUT) {
60
if
(p->process_input != NULL) {
61
action = p->process_input();
62
}
63
}
64
/* if not NETSTACK_IP_PROCESS - quit and return the desired action */
65
if
(action != NETSTACK_IP_PROCESS)
66
return
action;
67
}
68
return
action;
69
}
70
/*---------------------------------------------------------------------------*/
71
void
72
netstack_ip_packet_processor_add(
struct
netstack_ip_packet_processor *p)
73
{
74
if
(p != NULL) {
75
list_add
(ip_processor_list, p);
76
}
77
}
78
/*---------------------------------------------------------------------------*/
79
void
80
uip_ds6_ip_packet_processor_rm(
struct
netstack_ip_packet_processor *p)
81
{
82
list_remove
(ip_processor_list, p);
83
}
84
/*---------------------------------------------------------------------------*/
LIST
#define LIST(name)
Declare a linked list.
Definition
list.h:90
list_item_next
static void * list_item_next(const void *item)
Get the next item following this item.
Definition
list.h:294
list_add
void list_add(list_t list, void *item)
Add an item at the end of a list.
Definition
list.c:71
list_remove
void list_remove(list_t list, const void *item)
Remove a specific element from a list.
Definition
list.c:134
list_head
static void * list_head(const_list_t list)
Get a pointer to the first element of a list.
Definition
list.h:169
list.h
Linked list manipulation routines.
netstack.h
Include file for the Contiki low-layer network stack (NETSTACK).
os
net
netstack.c
Generated on
for Contiki-NG by
1.17.0