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

nativenet: Port nativenet for netdev #1732

Merged
merged 3 commits into from
Oct 9, 2014
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
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
19 changes: 18 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,17 @@
#endif /* NATIVE_MAX_DATA_LENGTH */

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

/**
* @brief Default @netdev API device
*/
extern netdev_t nativenet_default_dev;

/**
* Initialize @ref sys_transceiver and @ref 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