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 
92 int gnrc_netif_ipv6_addr_add_internal(gnrc_netif_t *netif,
93  const ipv6_addr_t *addr,
94  unsigned pfx_len, uint8_t flags);
95 
106 void gnrc_netif_ipv6_addr_remove_internal(gnrc_netif_t *netif,
107  const ipv6_addr_t *addr);
108 
109 
126 int gnrc_netif_ipv6_addr_idx(gnrc_netif_t *netif,
127  const ipv6_addr_t *addr);
128 
137 static inline uint8_t gnrc_netif_ipv6_addr_get_state(const gnrc_netif_t *netif,
138  int idx)
139 {
141 }
142 
153 static inline uint8_t gnrc_netif_ipv6_addr_dad_trans(const gnrc_netif_t *netif,
154  int idx)
155 {
157 }
158 
177 int gnrc_netif_ipv6_addr_match(gnrc_netif_t *netif,
178  const ipv6_addr_t *addr);
179 
206 ipv6_addr_t *gnrc_netif_ipv6_addr_best_src(gnrc_netif_t *netif,
207  const ipv6_addr_t *dst,
208  bool ll_only);
209 
221 gnrc_netif_t *gnrc_netif_get_by_ipv6_addr(const ipv6_addr_t *addr);
222 
232 gnrc_netif_t *gnrc_netif_get_by_prefix(const ipv6_addr_t *prefix);
233 
248 int gnrc_netif_ipv6_group_join_internal(gnrc_netif_t *netif,
249  const ipv6_addr_t *addr);
250 
261 void gnrc_netif_ipv6_group_leave_internal(gnrc_netif_t *netif,
262  const ipv6_addr_t *addr);
263 
280 int gnrc_netif_ipv6_group_idx(gnrc_netif_t *netif,
281  const ipv6_addr_t *addr);
282 
293 int gnrc_netif_ipv6_get_iid(gnrc_netif_t *netif, eui64_t *eui64);
294 #endif /* MODULE_GNRC_IPV6 */
295 
310 #if defined(MODULE_GNRC_IPV6_ROUTER) || defined(DOXYGEN)
311 static inline bool gnrc_netif_is_rtr(const gnrc_netif_t *netif)
312 {
313  return (netif->flags & GNRC_NETIF_FLAGS_IPV6_FORWARDING);
314 }
315 #else
316 #define gnrc_netif_is_rtr(netif) (false)
317 #endif
318 
332 #if defined(MODULE_GNRC_IPV6_ROUTER) || defined(DOXYGEN)
333 static inline bool gnrc_netif_is_rtr_adv(const gnrc_netif_t *netif)
334 {
335  return (netif->flags & GNRC_NETIF_FLAGS_IPV6_RTR_ADV);
336 }
337 #else
338 #define gnrc_netif_is_rtr_adv(netif) (false)
339 #endif
340 
358 #if (GNRC_NETIF_NUMOF > 1) || !defined(MODULE_GNRC_SIXLOWPAN) || defined(DOXYGEN)
359 bool gnrc_netif_is_6ln(const gnrc_netif_t *netif);
360 #elif GNRC_IPV6_NIB_CONF_6LN
361 #define gnrc_netif_is_6ln(netif) (true)
362 #else
363 #define gnrc_netif_is_6ln(netif) (false)
364 #endif
365 
380 #if (GNRC_IPV6_NIB_CONF_6LR && \
381  /* if flag checkers even evaluate, otherwise just assume their result */ \
382  (defined(MODULE_GNRC_IPV6_ROUTER) || \
383  (GNRC_NETIF_NUMOF > 1) || !defined(MODULE_GNRC_SIXLOWPAN))) || \
384  defined(DOXYGEN)
385 static inline bool gnrc_netif_is_6lr(const gnrc_netif_t *netif)
386 {
387  return gnrc_netif_is_rtr(netif) && gnrc_netif_is_6ln(netif);
388 }
389 #else
390 #define gnrc_netif_is_6lr(netif) (false)
391 #endif
392 
407 #if GNRC_IPV6_NIB_CONF_6LBR
408 static inline bool gnrc_netif_is_6lbr(const gnrc_netif_t *netif)
409 {
410  return (netif->flags & GNRC_NETIF_FLAGS_6LO_ABR) &&
411  gnrc_netif_is_6lr(netif);
412 }
413 #else
414 #define gnrc_netif_is_6lbr(netif) (false)
415 #endif
416 
417 #ifdef __cplusplus
418 }
419 #endif
420 
421 #endif /* NET_GNRC_NETIF_INTERNAL_H */
422 
#define GNRC_NETIF_IPV6_ADDRS_FLAGS_STATE_TENTATIVE
Tentative states (with encoded DAD retransmissions)
uint32_t flags
Flags for the interface.
Definition: 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
Definition for GNRC's network interfaces.
Configuration macro definitions for neighbor information base.
gnrc_netif_ipv6_t ipv6
IPv6 component.
Definition: 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: netif.h:62
#define GNRC_NETIF_IPV6_ADDRS_FLAGS_STATE_MASK
Mask for the address' state.
Data type to represent an IPv6 address.
Definition: ipv6/addr.h:74
Data type to represent an EUI-64.
Definition: eui64.h:37