Skip to content

Commit

Permalink
nativenet: Supply net_dev_t support for nativenet
Browse files Browse the repository at this point in the history
  • Loading branch information
miri64 committed Oct 2, 2014
1 parent ff725aa commit ed5cbe9
Show file tree
Hide file tree
Showing 8 changed files with 511 additions and 35 deletions.
4 changes: 4 additions & 0 deletions Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ ifneq (,$(filter ccn_lite,$(USEMODULE)))
USEMODULE += crypto
endif

ifneq (,$(filter nativenet,$(USEMODULE)))
USEMODULE += netdev_base
endif

ifneq (,$(filter rgbled,$(USEMODULE)))
USEMODULE += color
endif
Expand Down
6 changes: 4 additions & 2 deletions boards/native/Makefile.dep
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
ifneq (,$(filter defaulttransceiver,$(USEMODULE)))
USEMODULE += nativenet
USEMODULE += transceiver
USEMODULE += nativenet
ifeq (,$(filter netdev_base,$(USEMODULE)))
USEMODULE += transceiver
endif
endif
2 changes: 1 addition & 1 deletion boards/native/board_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void config_load(void)
sysconfig.id = _native_id;

#ifdef MODULE_NATIVENET
_native_net_addr = _native_id;
_nativenet_default_dev_more._radio_addr = _native_id;
#endif

return;
Expand Down
20 changes: 19 additions & 1 deletion cpu/native/include/nativenet.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,17 @@
#include <net/ethernet.h>

#include "kernel_types.h"
#include "netdev/base.h"

#define RX_BUF_SIZE (10)
#define TRANSCEIVER_BUFFER_SIZE (3)

/**
* @brief Number of registrable netdev_rcv_data_cb_t callbacks per nativenet
* device
*/
#define NATIVENET_DEV_CB_MAX (128)

#ifndef NATIVE_MAX_DATA_LENGTH
#include "tap.h"
#ifdef MODULE_SIXLOWPAN
Expand All @@ -44,7 +51,18 @@
#endif /* NATIVE_MAX_DATA_LENGTH */

/**
* Initialize transceiver
* @brief Implementation of netdev_driver_t for nativenet
*/
extern const netdev_driver_t nativenet_driver;

/**
* @brief Default device if user uses @ref transceiver module or any other
* way, that does not consider the @ref netdev_base API
*/
extern netdev_t nativenet_default_dev;

/**
* Initialize @ref transceiver and nativenet_default_dev
*
* @param transceiver_pid the pid of the transceiver thread
*/
Expand Down
58 changes: 56 additions & 2 deletions cpu/native/include/nativenet_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,68 @@
#define NNEV_SWTRX 0x0b
#define NNEV_MAXEV 0x0b

#define _NATIVENET_DEV_MORE(dev) ((_nativenet_netdev_more_t *)dev->more)

struct rx_buffer_s {
radio_packet_t packet;
char data[NATIVE_MAX_DATA_LENGTH];
};

extern struct rx_buffer_s _nativenet_rx_buffer[RX_BUF_SIZE];
extern uint64_t _native_net_addr_long;
extern radio_address_t _native_net_addr;

/**
* @brief Definition of network device data.
*/
typedef struct {
/**
* @brief The channel assigned to this device
*
* @note For internal use only, do not change externally!
*
* @internal
*/
uint8_t _channel;

/**
* @brief The PAN ID assigned to this device
*
* @note For internal use only, do not change externally!
* @internal
*/
uint16_t _pan_id;

/**
* @brief The short address assigned to this device
*
* @note For internal use only, do not change externally!
* @internal
*/
radio_address_t _radio_addr;

/**
* @brief The long address assigned to this device
*
* @note For internal use only, do not change externally!
* @internal
*/
uint64_t _long_addr;

/**
* @brief Flag to determine if device is in promiscuous mode
*
* @note For internal use only, do not change externally!
* @internal
*/
uint8_t _is_monitoring;

/**
* @brief Receive data callbacks for this device
*/
netdev_rcv_data_cb_t _callbacks[NATIVENET_DEV_CB_MAX];
} _nativenet_netdev_more_t;

/* internal counterpart to nativenet_default_dev */
extern _nativenet_netdev_more_t _nativenet_default_dev_more;

void _nativenet_handle_packet(radio_packet_t *packet);
int8_t send_buf(radio_packet_t *packet);
Expand Down
Loading

0 comments on commit ed5cbe9

Please sign in to comment.