Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sys: net: add gnrc netdev2 support #3683

Merged
merged 3 commits into from
Sep 4, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,10 @@ ifneq (,$(filter gnrc,$(USEMODULE)))
USEMODULE += gnrc_pktbuf
endif

ifneq (,$(filter gnrc_netdev2,$(USEMODULE)))
USEMODULE += netopt
endif

ifneq (,$(filter hih6130,$(USEMODULE)))
USEMODULE += vtimer
endif
5 changes: 2 additions & 3 deletions boards/native/Makefile.dep
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
ifneq (,$(filter gnrc_netif_default,$(USEMODULE)))
USEMODULE += dev_eth_tap
USEMODULE += gnrc_netdev_eth
USEMODULE += gnrc_nomac
USEMODULE += netdev2_tap
USEMODULE += gnrc_netdev2
endif
2 changes: 1 addition & 1 deletion boards/native/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export LINKFLAGS += -ldl
endif

# set the tap interface for term/valgrind
ifneq (,$(filter dev_eth_tap,$(USEMODULE)))
ifneq (,$(filter netdev2_tap,$(USEMODULE)))
export PORT ?= tap0
else
export PORT =
Expand Down
4 changes: 2 additions & 2 deletions cpu/native/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ MODULE = cpu

DIRS += periph

ifneq (,$(filter dev_eth_tap,$(USEMODULE)))
DIRS += dev_eth_tap
ifneq (,$(filter netdev2_tap,$(USEMODULE)))
DIRS += netdev2_tap
endif

include $(RIOTBASE)/Makefile.base
Expand Down
3 changes: 3 additions & 0 deletions cpu/native/include/native_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
#include <time.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <sys/uio.h>

#include "kernel_types.h"

Expand Down Expand Up @@ -123,6 +124,7 @@ extern long int (*real_random)(void);
extern const char* (*real_gai_strerror)(int errcode);
extern FILE* (*real_fopen)(const char *path, const char *mode);
extern mode_t (*real_umask)(mode_t cmask);
extern ssize_t (*real_writev)(int fildes, const struct iovec *iov, int iovcnt);

#ifdef __MACH__
#else
Expand Down Expand Up @@ -160,6 +162,7 @@ extern fd_set _native_rfds;

ssize_t _native_read(int fd, void *buf, size_t count);
ssize_t _native_write(int fd, const void *buf, size_t count);
ssize_t _native_writev(int fildes, const struct iovec *iov, int iovcnt);

/**
* register interrupt handler handler for interrupt sig
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,66 +7,67 @@
*/

/**
* @defgroup dev_eth_tap Ethernet driver for TAP interfaces
* @ingroup native_cpu
* @ingroup netdev2
* @brief Low-level ethernet driver for native tap interfaces
* @{
*
* @file
* @brief Definitions for @ref net_dev_eth driver for host system's
* @brief Definitions for @ref netdev2 ethernet driver for host system's
* TAP interfaces
*
* @author Kaspar Schleiser <kaspar@schleiser.de>
*/
#ifndef DEV_ETH_TAP_H
#define DEV_ETH_TAP_H
#ifndef NETDEV2_TAP_H
#define NETDEV2_TAP_H

#ifdef __cplusplus
extern "C" {
#endif

#include <stdint.h>
#include "net/dev_eth.h"
#include "net/netdev2.h"

#include "net/if.h"
#include "net/ethernet/hdr.h"

#ifdef __MACH__
#include "net/if_var.h"
#else
#include "net/if.h"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't these includes be in <...> instead of "..." because they are system headers?

#endif

/**
* @brief tap interface state
*/
typedef struct dev_eth_tap {
dev_eth_t ethdev; /**< dev_eth internal member */
typedef struct netdev2_tap {
netdev2_t netdev; /**< netdev2 internal member */
char tap_name[IFNAMSIZ]; /**< host dev file name */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IFNAMSIZ is undeclared, according to gcc.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even with the latest commit (f5f0392)?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have to admit I have no clue why this broke.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yes, the remote wasn't up to date. Sorry for the noise.

int tap_fd; /**< host file descriptor for the TAP */
uint8_t addr[ETHERNET_ADDR_LEN]; /**< The MAC address of the TAP */
uint8_t promiscous; /**< Flag for promiscous mode */
} dev_eth_tap_t;
} netdev2_tap_t;

/**
* @brief global device struct. driver only supports one tap device as of now.
*/
extern dev_eth_tap_t dev_eth_tap;
extern netdev2_tap_t netdev2_tap;

/**
* @brief Setup dev_eth_tap_t structure.
* @brief Setup netdev2_tap_t structure.
*
* @param dev the preallocated dev_eth_tap device handle to setup
* @param dev the preallocated netdev2_tap device handle to setup
* @param name Name of the host system's tap inteface to bind to.
*/
void dev_eth_tap_setup(dev_eth_tap_t *dev, const char *name);
void netdev2_tap_setup(netdev2_tap_t *dev, const char *name);

/**
* @brief Cleanup dev_eth_tap_t structure.
* @brief Cleanup tap resources
*
* @param dev the dev_eth_tap device handle to cleanup
* @param dev the netdev2_tap device handle to cleanup
*/
void dev_eth_tap_cleanup(dev_eth_tap_t *dev);
void netdev2_tap_cleanup(netdev2_tap_t *dev);

#ifdef __cplusplus
}
#endif
/** @} */
#endif /* DEV_ETH_TAP_H */
#endif /* NETDEV2_TAP_H */
10 changes: 5 additions & 5 deletions cpu/native/native_cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@
#include "cpu.h"
#include "cpu_conf.h"

#ifdef MODULE_DEV_ETH_TAP
#include "dev_eth_tap.h"
extern dev_eth_tap_t dev_eth_tap;
#ifdef MODULE_NETDEV2_TAP
#include "netdev2_tap.h"
extern netdev2_tap_t netdev2_tap;
#endif

#include "native_internal.h"
Expand All @@ -75,8 +75,8 @@ int reboot_arch(int mode)
/* TODO: close stdio fds */
#endif

#ifdef MODULE_DEV_ETH_TAP
dev_eth_tap_cleanup(&dev_eth_tap);
#ifdef MODULE_NETDEV2_TAP
netdev2_tap_cleanup(&netdev2_tap);
#endif

if (real_execve(_native_argv[0], _native_argv, NULL) == -1) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
MODULE = dev_eth_tap

include $(RIOTBASE)/Makefile.base

INCLUDES = $(NATIVEINCLUDES)
Loading