mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
gnrc_netif: adapt to new netif_t abstraction
This commit is contained in:
parent
77a7aed6e6
commit
8fd0c2b60f
@ -2,12 +2,10 @@ ifneq (,$(filter nhdp,$(USEMODULE)))
|
||||
USEMODULE_INCLUDES += $(RIOTBASE)/sys/net/routing/nhdp
|
||||
endif
|
||||
|
||||
ifneq (,$(filter gnrc_netif,$(USEMODULE)))
|
||||
USEMODULE_INCLUDES += $(RIOTBASE)/sys/net/gnrc/netif/include
|
||||
endif
|
||||
ifneq (,$(filter gnrc_sixlowpan_frag_rb,$(USEMODULE)))
|
||||
USEMODULE_INCLUDES += $(RIOTBASE)/sys/net/gnrc/network_layer/sixlowpan/frag
|
||||
endif
|
||||
|
||||
ifneq (,$(filter gnrc_sock,$(USEMODULE)))
|
||||
USEMODULE_INCLUDES += $(RIOTBASE)/sys/net/gnrc/sock/include
|
||||
ifneq (,$(filter gnrc_ipv6,$(USEMODULE)))
|
||||
|
@ -54,6 +54,7 @@
|
||||
#include "net/netstats.h"
|
||||
#endif
|
||||
#include "rmutex.h"
|
||||
#include "net/netif.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -68,6 +69,7 @@ typedef struct gnrc_netif_ops gnrc_netif_ops_t;
|
||||
* @brief Representation of a network interface
|
||||
*/
|
||||
typedef struct {
|
||||
netif_t netif; /**< network interface descriptor */
|
||||
const gnrc_netif_ops_t *ops; /**< Operations of the network interface */
|
||||
netdev_t *dev; /**< Network device of the network interface */
|
||||
rmutex_t mutex; /**< Mutex of the interface */
|
||||
|
@ -23,64 +23,29 @@
|
||||
|
||||
#include "net/netif.h"
|
||||
|
||||
netif_t netif_iter(netif_t last)
|
||||
int netif_get_name(netif_t *iface, char *name)
|
||||
{
|
||||
gnrc_netif_t *netif;
|
||||
gnrc_netif_t *netif = (gnrc_netif_t*) iface;
|
||||
|
||||
if (last == NETIF_INVALID) {
|
||||
netif = gnrc_netif_iter(NULL);
|
||||
}
|
||||
else if ((netif = gnrc_netif_get_by_pid((kernel_pid_t)last)) != NULL) {
|
||||
netif = gnrc_netif_iter(netif);
|
||||
}
|
||||
if (netif != NULL) {
|
||||
return netif->pid;
|
||||
}
|
||||
else {
|
||||
return NETIF_INVALID;
|
||||
}
|
||||
}
|
||||
|
||||
int netif_get_name(netif_t iface, char *name)
|
||||
{
|
||||
gnrc_netif_t *netif = gnrc_netif_get_by_pid((kernel_pid_t)iface);
|
||||
int res = 0;
|
||||
|
||||
if (netif != NULL) {
|
||||
res += fmt_str(name, "if");
|
||||
res += fmt_u16_dec(&name[res], netif->pid);
|
||||
name[res] = '\0';
|
||||
}
|
||||
res += fmt_str(name, "if");
|
||||
res += fmt_u16_dec(&name[res], netif->pid);
|
||||
name[res] = '\0';
|
||||
return res;
|
||||
}
|
||||
|
||||
netif_t netif_get_by_name(const char *name)
|
||||
{
|
||||
if ((strncmp(name, "if", 2) == 0)) {
|
||||
kernel_pid_t _name_pid = (kernel_pid_t)scn_u32_dec(&name[2], 2);
|
||||
if (_name_pid > 0) {
|
||||
gnrc_netif_t *netif = NULL;
|
||||
|
||||
while ((netif = gnrc_netif_iter(netif)) != NULL) {
|
||||
if (netif->pid == _name_pid) {
|
||||
return netif->pid;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return NETIF_INVALID;
|
||||
}
|
||||
|
||||
int netif_get_opt(netif_t netif, netopt_t opt, uint16_t context,
|
||||
int netif_get_opt(netif_t *netif, netopt_t opt, uint16_t context,
|
||||
void *value, size_t max_len)
|
||||
{
|
||||
return gnrc_netapi_get(netif, opt, context, value, max_len);
|
||||
gnrc_netif_t *iface = (gnrc_netif_t*) netif;
|
||||
return gnrc_netapi_get(iface->pid, opt, context, value, max_len);
|
||||
}
|
||||
|
||||
int netif_set_opt(netif_t netif, netopt_t opt, uint16_t context,
|
||||
int netif_set_opt(netif_t *netif, netopt_t opt, uint16_t context,
|
||||
void *value, size_t value_len)
|
||||
{
|
||||
return gnrc_netapi_set(netif, opt, context, value, value_len);
|
||||
gnrc_netif_t *iface = (gnrc_netif_t*) netif;
|
||||
return gnrc_netapi_set(iface->pid, opt, context, value, value_len);
|
||||
}
|
||||
|
||||
/** @} */
|
||||
|
@ -64,6 +64,7 @@ gnrc_netif_t *gnrc_netif_create(char *stack, int stacksize, char priority,
|
||||
assert(netif != NULL);
|
||||
rmutex_init(&netif->mutex);
|
||||
netif->ops = ops;
|
||||
netif_register((netif_t*) netif);
|
||||
assert(netif->dev == NULL);
|
||||
netif->dev = netdev;
|
||||
res = thread_create(stack, stacksize, priority, THREAD_CREATE_STACKTEST,
|
||||
|
@ -1,36 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2018 Freie Universität Berlin
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup net_netif
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief GNRC-specfic type definitions for @ref net_netif
|
||||
*
|
||||
* @author Martine Lenders <m.lenders@fu-berlin.de>
|
||||
*/
|
||||
#ifndef NETIF_TYPES_H
|
||||
#define NETIF_TYPES_H
|
||||
|
||||
#include "kernel_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define NETIF_INVALID (KERNEL_PID_UNDEF) /**< Invalid interface */
|
||||
|
||||
typedef kernel_pid_t netif_t; /**< GNRC-representation of a network interface */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* NETIF_TYPES_H */
|
||||
/** @} */
|
Loading…
Reference in New Issue
Block a user