Blame view

RIOT/sys/include/net/gnrc/ipv6.h 4.62 KB
a752c7ab   elopes   add first test an...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
  /*
   * Copyright (C) 2015 Martine Lenders <mlenders@inf.fu-berlin.de>
   *
   * This file is subject to the terms and conditions of the GNU Lesser General
   * Public License v2.1. See the file LICENSE in the top level directory for
   * more details.
   */
  
  /**
   * @defgroup    net_gnrc_ipv6 IPv6
   * @ingroup     net_gnrc
   * @brief       GNRC's IPv6 implementation
   *
   * The IPv6 control thread understands messages of type
   *
   *  * @ref GNRC_NETAPI_MSG_TYPE_RCV, and
   *  * @ref GNRC_NETAPI_MSG_TYPE_SND,
   *
   * @{
   *
   * @file
   * @brief       Definitions for GNRC's IPv6 implementation
   *
   * @author      Martine Lenders <mlenders@inf.fu-berlin.de>
   * @author      Oliver Hahm <oliver.hahm@inria.fr>
   */
  
  
  #ifndef NET_GNRC_IPV6_H
  #define NET_GNRC_IPV6_H
  
  #include "kernel_types.h"
  #include "net/gnrc.h"
  #include "thread.h"
  
  #include "net/ipv6.h"
  #include "net/gnrc/ipv6/ext.h"
  #include "net/gnrc/ipv6/hdr.h"
  #ifndef MODULE_GNRC_IPV6_NIB
  #include "net/gnrc/ipv6/nc.h"
  #endif
  #include "net/gnrc/ipv6/netif.h"
  
  #ifdef MODULE_FIB
  #include "net/fib.h"
  #endif
  
  #ifdef __cplusplus
  extern "C" {
  #endif
  
  /**
   * @brief   Default stack size to use for the IPv6 thread
   */
  #ifndef GNRC_IPV6_STACK_SIZE
  #define GNRC_IPV6_STACK_SIZE        (THREAD_STACKSIZE_DEFAULT)
  #endif
  
  /**
   * @brief   Default priority for the IPv6 thread
   */
  #ifndef GNRC_IPV6_PRIO
  #define GNRC_IPV6_PRIO              (THREAD_PRIORITY_MAIN - 3)
  #endif
  
  /**
   * @brief   Default message queue size to use for the IPv6 thread.
   */
  #ifndef GNRC_IPV6_MSG_QUEUE_SIZE
  #define GNRC_IPV6_MSG_QUEUE_SIZE    (8U)
  #endif
  
  #ifdef DOXYGEN
  /**
   * @brief   Add a static IPv6 link local address to any network interface
   *
   * This macro allows to specify a certain link local IPv6 address to be assigned
   * to a network interface on startup, which might be handy for testing.
   * Note: a) a interface will keep its auto-generated link local address, too
   *       b) the address is incremented by 1, if multiple interfaces are present
   *
   * To use the macro just add it to `CFLAGS` in the application's Makefile, like:
   *
   * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.mk}
   * IPV6_STATIC_LLADDR ?= '"fe80::cafe:cafe:cafe:1"'
   * CFLAGS += -DGNRC_IPV6_STATIC_LLADDR=$(STATIC_IPV6_LLADDR)
   * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   */
  #define GNRC_IPV6_STATIC_LLADDR
  #endif /* DOXYGEN */
  
  /**
   * @brief   The PID to the IPv6 thread.
   *
   * @note    Use @ref gnrc_ipv6_init() to initialize. **Do not set by hand**.
   *
   * @details This variable is preferred for IPv6 internal communication *only*.
   *          Please use @ref net_gnrc_netreg for external communication.
   */
  extern kernel_pid_t gnrc_ipv6_pid;
  
  #ifdef MODULE_FIB
  
  /**
   * @brief   Maximum number of entries in the IPv6 FIB table.
   */
  #ifndef GNRC_IPV6_FIB_TABLE_SIZE
  #   ifdef MODULE_GNRC_RPL
  #       define GNRC_IPV6_FIB_TABLE_SIZE     (20)
  #   else
  #       define GNRC_IPV6_FIB_TABLE_SIZE     (5)
  #   endif
  #endif
  
  /**
   * @brief   The forwarding information base (FIB) for the IPv6 stack.
   *
   * @see @ref net_fib
   */
  extern fib_table_t gnrc_ipv6_fib_table;
  #endif
  
  /**
   * @brief   Initialization of the IPv6 thread.
   *
   * @return  The PID to the IPv6 thread, on success.
   * @return  a negative errno on error.
   * @return  -EOVERFLOW, if there are too many threads running already
   * @return  -EEXIST, if IPv6 was already initialized.
   */
  kernel_pid_t gnrc_ipv6_init(void);
  
  /**
   * @brief   Demultiplexes a packet according to @p nh.
   *
   * @internal
   *
   * **Do not use outside this module or its submodules!!!**
   * Public access needed for Extension Headers.
   *
   * About `current` and `pkt`:
   *
   *                     current     pkt
   *                     |           |
   *                     v           v
   * IPv6 <- IPv6_EXT <- IPv6_EXT <- UNDEF
   *
   * This situation may happen when the packet has a source routing extension
   * header (RFC 6554), and the packet is forwarded from an interface to another.
   *
   * @param[in] iface     The receiving interface.
   * @param[in] current   A snip to process.
   * @param[in] pkt       A packet.
   * @param[in] nh        A protocol number (see @ref net_protnum) of the current snip.
   */
  void gnrc_ipv6_demux(kernel_pid_t iface, gnrc_pktsnip_t *current, gnrc_pktsnip_t *pkt, uint8_t nh);
  
  /**
   * @brief   Get the IPv6 header from a given list of @ref gnrc_pktsnip_t
   *
   *          This function may be used with e.g. a pointer to a (full) UDP datagram.
   *
   * @param[in] pkt    The pointer to the first @ref gnrc_pktsnip_t of the
   *                   packet.
   *
   * @return A pointer to the @ref ipv6_hdr_t of the packet.
   * @return NULL if the packet does not contain an IPv6 header.
   */
  ipv6_hdr_t *gnrc_ipv6_get_header(gnrc_pktsnip_t *pkt);
  
  #ifdef __cplusplus
  }
  #endif
  
  #endif /* NET_GNRC_IPV6_H */
  /**
   * @}
   */