diff --git a/sys/Makefile b/sys/Makefile index 2f3500c967bcc8c5e154e59312ec7ba472db081a..7a30b1539f08ed899c884e57844af90c20f3cbd4 100644 --- a/sys/Makefile +++ b/sys/Makefile @@ -98,6 +98,9 @@ endif ifneq (,$(filter ng_sixlowpan_ctx,$(USEMODULE))) DIRS += net/network_layer/ng_sixlowpan/ctx endif +ifneq (,$(filter ng_sixlowpan_netif,$(USEMODULE))) + DIRS += net/network_layer/ng_sixlowpan/netif +endif ifneq (,$(filter netapi,$(USEMODULE))) DIRS += net/crosslayer/netapi endif diff --git a/sys/include/net/ng_sixlowpan/netif.h b/sys/include/net/ng_sixlowpan/netif.h new file mode 100644 index 0000000000000000000000000000000000000000..11d845eb4331bf9a0a981de10321656899fd68e5 --- /dev/null +++ b/sys/include/net/ng_sixlowpan/netif.h @@ -0,0 +1,72 @@ +/* + * 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_ng_sixlowpan_netif 6LoWPAN network interfaces + * @ingroup net_ng_sixlowpan + * @brief 6LoWPAN specific information on @ref net_ng_netif + * @{ + * + * @file + * @brief Definitions for 6LoWPAN specific information of network interfaces. + * + * @author Martine Lenders <mlenders@inf.fu-berlin.de> + */ +#ifndef NG_SIXLOWPAN_NETIF_H_ +#define NG_SIXLOWPAN_NETIF_H_ + +#include "kernel_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Definition of 6LoWPAN interface type. + */ +typedef struct { + kernel_pid_t pid; /**< PID of the interface */ + uint16_t max_frag_size; /**< Maximum fragment size for this interface */ +} ng_sixlowpan_netif_t; + +/** + * @brief Initializes the module + */ +void ng_sixlowpan_netif_init(void); + +/** + * @brief Add interface to 6LoWPAN. + * + * @param[in] pid The PID to the interface. + * @param[in] max_frag_size The maximum fragment size for this interface. + */ +void ng_sixlowpan_netif_add(kernel_pid_t pid, uint16_t max_frag_size); + +/** + * @brief REmove interface from 6LoWPAN. + * + * @param[in] pid The PID to the interface. + */ +void ng_sixlowpan_netif_remove(kernel_pid_t pid); + +/** + * @brief Get interface. + * + * @param[in] pid The PID to the interface + * + * @return The interface describing structure, on success. + * @return NULL, if there is no interface with PID @p pid. + */ +ng_sixlowpan_netif_t *ng_sixlowpan_netif_get(kernel_pid_t pid); + +#ifdef __cplusplus +} +#endif + +#endif /* NG_SIXLOWPAN_NETIF_H_ */ +/** @} */ diff --git a/sys/net/network_layer/ng_sixlowpan/netif/Makefile b/sys/net/network_layer/ng_sixlowpan/netif/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..b86f9e154cbe4085418e392a0ae02c11d4c5dd87 --- /dev/null +++ b/sys/net/network_layer/ng_sixlowpan/netif/Makefile @@ -0,0 +1,3 @@ +MODULE = ng_sixlowpan_netif + +include $(RIOTBASE)/Makefile.base diff --git a/sys/net/network_layer/ng_sixlowpan/netif/ng_sixlowpan_netif.c b/sys/net/network_layer/ng_sixlowpan/netif/ng_sixlowpan_netif.c new file mode 100644 index 0000000000000000000000000000000000000000..0428106c5f8159a2b9562134e0e300a45ab07a4f --- /dev/null +++ b/sys/net/network_layer/ng_sixlowpan/netif/ng_sixlowpan_netif.c @@ -0,0 +1,63 @@ +/* + * 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. + */ + +/** + * @{ + * + * @file + */ + +#include "kernel_types.h" + +#include "net/ng_netif.h" +#include "net/ng_sixlowpan/netif.h" + +static ng_sixlowpan_netif_t sixlow_ifs[NG_NETIF_NUMOF]; + +void ng_sixlowpan_netif_init(void) +{ + for (int i = 0; i < NG_NETIF_NUMOF; i++) { + sixlow_ifs[i].pid = KERNEL_PID_UNDEF; + sixlow_ifs[i].max_frag_size = 0; + } +} + +void ng_sixlowpan_netif_add(kernel_pid_t pid, uint16_t max_frag_size) +{ + for (int i = 0; i < NG_NETIF_NUMOF; i++) { + if (sixlow_ifs[i].pid == pid) { + return; + } + + if (sixlow_ifs[i].pid == KERNEL_PID_UNDEF) { + sixlow_ifs[i].pid = pid; + sixlow_ifs[i].max_frag_size = max_frag_size; + return; + } + } +} + +void ng_sixlowpan_netif_remove(kernel_pid_t pid) +{ + ng_sixlowpan_netif_t *entry = ng_sixlowpan_netif_get(pid); + + entry->pid = KERNEL_PID_UNDEF; +} + +ng_sixlowpan_netif_t *ng_sixlowpan_netif_get(kernel_pid_t pid) +{ + for (int i = 0; i < NG_NETIF_NUMOF; i++) { + if (sixlow_ifs[i].pid == pid) { + return sixlow_ifs + i; + } + } + + return NULL; +} + +/** @} */