auto_init: initialize ng_netdev_eth
This commit is contained in:
parent
2e691cf565
commit
4d9f965159
@ -335,6 +335,11 @@ void auto_init(void)
|
|||||||
auto_init_kw2xrf();
|
auto_init_kw2xrf();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef MODULE_NG_NETDEV_ETH
|
||||||
|
extern void auto_init_ng_netdev_eth(void);
|
||||||
|
auto_init_ng_netdev_eth();
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* MODULE_AUTO_INIT_NG_NETIF */
|
#endif /* MODULE_AUTO_INIT_NG_NETIF */
|
||||||
|
|
||||||
#ifdef MODULE_NG_IPV6_NETIF
|
#ifdef MODULE_NG_IPV6_NETIF
|
||||||
|
|||||||
60
sys/auto_init/netif/auto_init_ng_netdev_eth.c
Normal file
60
sys/auto_init/netif/auto_init_ng_netdev_eth.c
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2015 Kaspar Schleiser <kaspar@schleiser.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.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @ingroup auto_init_ng_netif
|
||||||
|
* @{
|
||||||
|
*
|
||||||
|
* @file
|
||||||
|
* @brief Auto initialization for netdev Ethernet network interfaces
|
||||||
|
*
|
||||||
|
* @author Kaspar Schleiser <kaspar@schleiser.de>
|
||||||
|
* @author Oliver Hahm <oliver.hahm@inria.fr>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef MODULE_NG_NETDEV_ETH
|
||||||
|
|
||||||
|
#include "board.h"
|
||||||
|
#include "net/ng_nomac.h"
|
||||||
|
#include "net/ng_netbase.h"
|
||||||
|
|
||||||
|
#include "net/ng_netdev_eth.h"
|
||||||
|
#include "net/dev_eth.h"
|
||||||
|
#include "dev_eth_tap.h"
|
||||||
|
|
||||||
|
#define ENABLE_DEBUG (0)
|
||||||
|
#include "debug.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Define stack parameters for the MAC layer thread
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define NETDEV_ETH_MAC_STACKSIZE (THREAD_STACKSIZE_DEFAULT)
|
||||||
|
#define NETDEV_ETH_MAC_PRIO (THREAD_PRIORITY_MAIN - 3)
|
||||||
|
|
||||||
|
static char _nomac_stack[NETDEV_ETH_MAC_STACKSIZE];
|
||||||
|
|
||||||
|
void auto_init_ng_netdev_eth(void)
|
||||||
|
{
|
||||||
|
DEBUG("Initializing NETDEV_ETH device\n");
|
||||||
|
int res = ng_netdev_eth_init(&ng_netdev_eth, (dev_eth_t*)&dev_eth_tap);
|
||||||
|
|
||||||
|
if (res < 0) {
|
||||||
|
DEBUG("Error initializing NETDEV_ETH device!");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ng_nomac_init(_nomac_stack, NETDEV_ETH_MAC_STACKSIZE, NETDEV_ETH_MAC_PRIO,
|
||||||
|
"tapnet", (ng_netdev_t *)&ng_netdev_eth);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
typedef int dont_be_pedantic;
|
||||||
|
#endif /* MODULE_NG_NETDEV_ETH */
|
||||||
|
|
||||||
|
/** @} */
|
||||||
@ -8,6 +8,7 @@ USEMODULE += ng_netbase
|
|||||||
USEMODULE += ng_nomac
|
USEMODULE += ng_nomac
|
||||||
USEMODULE += ng_pktdump
|
USEMODULE += ng_pktdump
|
||||||
USEMODULE += ng_netdev_eth
|
USEMODULE += ng_netdev_eth
|
||||||
|
USEMODULE += auto_init_ng_netif
|
||||||
USEMODULE += shell
|
USEMODULE += shell
|
||||||
USEMODULE += shell_commands
|
USEMODULE += shell_commands
|
||||||
|
|
||||||
|
|||||||
@ -38,11 +38,6 @@
|
|||||||
*/
|
*/
|
||||||
#define SHELL_BUFSIZE (64U)
|
#define SHELL_BUFSIZE (64U)
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Stack for the nomac thread
|
|
||||||
*/
|
|
||||||
static char nomac_stack[THREAD_STACKSIZE_DEFAULT];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Read chars from STDIO
|
* @brief Read chars from STDIO
|
||||||
*/
|
*/
|
||||||
@ -64,15 +59,11 @@ void shell_put(int c)
|
|||||||
*/
|
*/
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
int res;
|
|
||||||
shell_t shell;
|
shell_t shell;
|
||||||
ng_netreg_entry_t dump;
|
ng_netreg_entry_t dump;
|
||||||
|
|
||||||
puts("netdev ethernet device driver test");
|
puts("netdev ethernet device driver test");
|
||||||
|
|
||||||
/* initialize network module(s) */
|
|
||||||
ng_netif_init();
|
|
||||||
|
|
||||||
/* initialize and register pktdump */
|
/* initialize and register pktdump */
|
||||||
dump.pid = ng_pktdump_init();
|
dump.pid = ng_pktdump_init();
|
||||||
dump.demux_ctx = NG_NETREG_DEMUX_CTX_ALL;
|
dump.demux_ctx = NG_NETREG_DEMUX_CTX_ALL;
|
||||||
@ -84,18 +75,6 @@ int main(void)
|
|||||||
|
|
||||||
ng_netreg_register(NG_NETTYPE_UNDEF, &dump);
|
ng_netreg_register(NG_NETTYPE_UNDEF, &dump);
|
||||||
|
|
||||||
/* initialize netdev_eth layer */
|
|
||||||
ng_netdev_eth_init(&ng_netdev_eth, (dev_eth_t*)&dev_eth_tap);
|
|
||||||
|
|
||||||
/* start MAC layer */
|
|
||||||
res = ng_nomac_init(nomac_stack, sizeof(nomac_stack), THREAD_PRIORITY_MAIN - 3,
|
|
||||||
"tapnet_l2", (ng_netdev_t *)&ng_netdev_eth);
|
|
||||||
|
|
||||||
if (res < 0) {
|
|
||||||
printf("Error starting nomac thread. res=%i\n", res);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* start the shell */
|
/* start the shell */
|
||||||
shell_init(&shell, NULL, SHELL_BUFSIZE, shell_read, shell_put);
|
shell_init(&shell, NULL, SHELL_BUFSIZE, shell_read, shell_put);
|
||||||
shell_run(&shell);
|
shell_run(&shell);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user