ng_sixlowpan_netif: initial import
This commit is contained in:
parent
8e4edf2b72
commit
07e2dbaf7e
@ -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
|
||||
|
||||
72
sys/include/net/ng_sixlowpan/netif.h
Normal file
72
sys/include/net/ng_sixlowpan/netif.h
Normal file
@ -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_ */
|
||||
/** @} */
|
||||
3
sys/net/network_layer/ng_sixlowpan/netif/Makefile
Normal file
3
sys/net/network_layer/ng_sixlowpan/netif/Makefile
Normal file
@ -0,0 +1,3 @@
|
||||
MODULE = ng_sixlowpan_netif
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
||||
@ -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;
|
||||
}
|
||||
|
||||
/** @} */
|
||||
Loading…
x
Reference in New Issue
Block a user