netif/internal.h
1 /*
2  * Copyright (C) 2017 Freie Universit├Ąt Berlin
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
21 #ifndef NET_GNRC_NETIF_INTERNAL_H
22 #define NET_GNRC_NETIF_INTERNAL_H
23 
24 #include "net/gnrc/netif.h"
25 
26 #ifdef MODULE_GNRC_IPV6_NIB
27 #include "net/gnrc/ipv6/nib/conf.h"
28 #endif
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
37 #define NETDEV_MSG_TYPE_EVENT (0x1234)
38 
46 void gnrc_netif_acquire(gnrc_netif_t *netif);
47 
55 void gnrc_netif_release(gnrc_netif_t *netif);
56 
57 #if defined(MODULE_GNRC_IPV6) || DOXYGEN
58 
93 int gnrc_netif_ipv6_addr_add_internal(gnrc_netif_t *netif,
94  const ipv6_addr_t *addr,
95  unsigned pfx_len, uint8_t flags);
96 
107 void gnrc_netif_ipv6_addr_remove_internal(gnrc_netif_t *netif,
108  const ipv6_addr_t *addr);
109 
110 
127 int gnrc_netif_ipv6_addr_idx(gnrc_netif_t *netif,
128  const ipv6_addr_t *addr);
129 
138 static inline uint8_t gnrc_netif_ipv6_addr_get_state(const gnrc_netif_t *netif,
139  int idx)
140 {
142 }
143 
154 static inline uint8_t gnrc_netif_ipv6_addr_dad_trans(const gnrc_netif_t *netif,
155  int idx)
156 {
158 }
159 
178 int gnrc_netif_ipv6_addr_match(gnrc_netif_t *netif,
179  const ipv6_addr_t *addr);
180 
207 ipv6_addr_t *gnrc_netif_ipv6_addr_best_src(gnrc_netif_t *netif,
208  const ipv6_addr_t *dst,
209  bool ll_only);
210 
222 gnrc_netif_t *gnrc_netif_get_by_ipv6_addr(const ipv6_addr_t *addr);
223 
233 gnrc_netif_t *gnrc_netif_get_by_prefix(const ipv6_addr_t *prefix);
234 
249 int gnrc_netif_ipv6_group_join_internal(gnrc_netif_t *netif,
250  const ipv6_addr_t *addr);
251 
262 void gnrc_netif_ipv6_group_leave_internal(gnrc_netif_t *netif,
263  const ipv6_addr_t *addr);
264 
281 int gnrc_netif_ipv6_group_idx(gnrc_netif_t *netif,
282  const ipv6_addr_t *addr);
283 
294 int gnrc_netif_ipv6_get_iid(gnrc_netif_t *netif, eui64_t *eui64);
295 #endif /* MODULE_GNRC_IPV6 */
296 
311 #if defined(MODULE_GNRC_IPV6_ROUTER) || defined(DOXYGEN)
312 static inline bool gnrc_netif_is_rtr(const gnrc_netif_t *netif)
313 {
314  return (netif->flags & GNRC_NETIF_FLAGS_IPV6_FORWARDING);
315 }
316 #else
317 #define gnrc_netif_is_rtr(netif) (false)
318 #endif
319 
333 #if defined(MODULE_GNRC_IPV6_ROUTER) || defined(DOXYGEN)
334 static inline bool gnrc_netif_is_rtr_adv(const gnrc_netif_t *netif)
335 {
336  return (netif->flags & GNRC_NETIF_FLAGS_IPV6_RTR_ADV);
337 }
338 #else
339 #define gnrc_netif_is_rtr_adv(netif) (false)
340 #endif
341 
359 #if (GNRC_NETIF_NUMOF > 1) || !defined(MODULE_GNRC_SIXLOWPAN) || defined(DOXYGEN)
360 bool gnrc_netif_is_6ln(const gnrc_netif_t *netif);
361 #elif GNRC_IPV6_NIB_CONF_6LN
362 #define gnrc_netif_is_6ln(netif) (true)
363 #else
364 #define gnrc_netif_is_6ln(netif) (false)
365 #endif
366 
381 #if (GNRC_IPV6_NIB_CONF_6LR && \
382  /* if flag checkers even evaluate, otherwise just assume their result */ \
383  (defined(MODULE_GNRC_IPV6_ROUTER) || \
384  (GNRC_NETIF_NUMOF > 1) || !defined(MODULE_GNRC_SIXLOWPAN))) || \
385  defined(DOXYGEN)
386 static inline bool gnrc_netif_is_6lr(const gnrc_netif_t *netif)
387 {
388  return gnrc_netif_is_rtr(netif) && gnrc_netif_is_6ln(netif);
389 }
390 #else
391 #define gnrc_netif_is_6lr(netif) (false)
392 #endif
393 
408 #if GNRC_IPV6_NIB_CONF_6LBR
409 static inline bool gnrc_netif_is_6lbr(const gnrc_netif_t *netif)
410 {
411  return (netif->flags & GNRC_NETIF_FLAGS_6LO_ABR) &&
412  gnrc_netif_is_6lr(netif);
413 }
414 #else
415 #define gnrc_netif_is_6lbr(netif) (false)
416 #endif
417 
418 #ifdef __cplusplus
419 }
420 #endif
421 
422 #endif /* NET_GNRC_NETIF_INTERNAL_H */
423 
#define GNRC_NETIF_IPV6_ADDRS_FLAGS_STATE_TENTATIVE
Tentative states (with encoded DAD retransmissions)
uint32_t flags
Flags for the interface.
Definition: gnrc/netif.h:77
#define GNRC_NETIF_FLAGS_6LO_ABR
This interface acts as a 6Lo border router to the LLN.
Definition: flags.h:103
#define GNRC_NETIF_FLAGS_IPV6_RTR_ADV
Network interface advertises itself as an IPv6 router (implies GNRC_NETIF_FLAGS_IPV6_FORWARDING to be...
Definition: flags.h:58
Configuration macro definitions for neighbor information base.
gnrc_netif_ipv6_t ipv6
IPv6 component.
Definition: gnrc/netif.h:67
#define GNRC_NETIF_FLAGS_IPV6_FORWARDING
Network interface is enabled for IPv6 forwarding.
Definition: flags.h:52
uint8_t addrs_flags[GNRC_NETIF_IPV6_ADDRS_NUMOF]
Flags for gnrc_netif_t::ipv6_addrs.
Representation of a network interface.
Definition: gnrc/netif.h:62
#define GNRC_NETIF_IPV6_ADDRS_FLAGS_STATE_MASK
Mask for the address' state.
Definition for GNRC's network interfaces.
Data type to represent an IPv6 address.
Definition: ipv6/addr.h:74
Data type to represent an EUI-64.
Definition: eui64.h:37