Skip to content
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: 6 additions & 0 deletions boards/native/Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,9 @@ ifneq (,$(filter can,$(USEMODULE)))
CFLAGS += -DCAN_DLL_NUMOF=2
endif
endif

ifneq (,$(filter socket_zep,$(USEMODULE)))
USEMODULE += netdev_ieee802154
USEMODULE += checksum
USEMODULE += random
endif
5 changes: 5 additions & 0 deletions cpu/native/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ DIRS += vfs
ifneq (,$(filter netdev_tap,$(USEMODULE)))
DIRS += netdev_tap
endif

ifneq (,$(filter socket_zep,$(USEMODULE)))
DIRS += socket_zep
endif

ifneq (,$(filter mtd_native,$(USEMODULE)))
DIRS += mtd
endif
Expand Down
2 changes: 2 additions & 0 deletions cpu/native/include/native_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ extern void (*real_srandom)(unsigned int seed);
extern int (*real_accept)(int socket, ...);
/* The ... is a hack to save includes: */
extern int (*real_bind)(int socket, ...);
extern int (*real_connect)(int socket, ...);
extern int (*real_chdir)(const char *path);
extern int (*real_close)(int);
extern int (*real_fcntl)(int, int, ...);
Expand All @@ -108,6 +109,7 @@ extern int (*real_fork)(void);
extern int (*real_getaddrinfo)(const char *node, ...);
extern int (*real_getifaddrs)(struct ifaddrs **ifap);
extern int (*real_getpid)(void);
extern int (*real_gettimeofday)(struct timeval *t, ...);
extern int (*real_ioctl)(int fildes, int request, ...);
extern int (*real_listen)(int socket, int backlog);
extern int (*real_open)(const char *path, int oflag, ...);
Expand Down
84 changes: 84 additions & 0 deletions cpu/native/include/socket_zep.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*
* Copyright (C) 2016 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.
*/

/**
* @defgroup netdev_socket_zep Socket-based ZEP
* @ingroup netdev
* @brief UDP socket-based IEEE 802.15.4 device over ZEP
* @{
*
* @file
* @brief Socket ZEP definitions
*
* @author Martine Lenders <[email protected]>
*/
#ifndef SOCKET_ZEP_H
#define SOCKET_ZEP_H

#include <netdb.h>
#include "net/netdev.h"
#include "net/netdev/ieee802154.h"
#include "net/zep.h"

#ifdef __cplusplus
extern "C" {
#endif

/* 127 - 25 as in at86rf2xx */
#define SOCKET_ZEP_FRAME_PAYLOAD_LEN (102) /**< maximum possible payload size */

/**
* @brief ZEP device state
*/
typedef struct {
netdev_ieee802154_t netdev; /**< netdev internal member */
int sock_fd; /**< socket fd */
netdev_event_t last_event; /**< event triggered */
uint32_t seq; /**< ZEP sequence number */
/**
* @brief Receive buffer
*/
uint8_t rcv_buf[sizeof(zep_v2_data_hdr_t) + IEEE802154_FRAME_LEN_MAX];
/**
* @brief Buffer for send header
*/
uint8_t snd_hdr_buf[sizeof(zep_v2_data_hdr_t)];
uint16_t chksum_buf; /**< buffer for send checksum calculation */
} socket_zep_t;

/**
* @brief ZEP device initialization parameters
*/
typedef struct {
char *local_addr; /**< local address string */
char *local_port; /**< local address string */
char *remote_addr; /**< remote address string */
char *remote_port; /**< local address string */
} socket_zep_params_t;

/**
* @brief Setup socket_zep_t structure
*
* @param[in] dev the preallocated socket_zep_t device handle to setup
* @param[in] params initialization parameters
*/
void socket_zep_setup(socket_zep_t *dev, const socket_zep_params_t *params);

/**
* @brief Cleanup socket resources
*
* @param dev the socket_zep device handle to cleanup
*/
void socket_zep_cleanup(socket_zep_t *dev);

#ifdef __cplusplus
}
#endif

#endif /* SOCKET_ZEP_H */
/** @} */
54 changes: 54 additions & 0 deletions cpu/native/include/socket_zep_params.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright (C) 2016 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 netdev_socket_zep
* @{
*
* @file
* @brief Configuration parameters for the @ref netdev_socket_zep driver
*
* @author Martine Lenders <[email protected]>
*/
#ifndef SOCKET_ZEP_PARAMS_H
#define SOCKET_ZEP_PARAMS_H

#include "socket_zep.h"

#ifdef __cplusplus
extern "C" {
#endif

/**
* @brief Number of allocated parameters at @ref socket_zep_params
*
* @note This was desided to only be confiruable on compile-time to be
* more similar to actual boards
*/
#ifndef SOCKET_ZEP_MAX
#define SOCKET_ZEP_MAX (1)
#endif

/**
* @name Default parameters for native argument parsing
* @{
*/
#define SOCKET_ZEP_PORT_DEFAULT "17754" /**< default port */
#define SOCKET_ZEP_LOCAL_ADDR_DEFAULT "::" /**< default local address */
/**
* @}
*/

extern socket_zep_params_t socket_zep_params[SOCKET_ZEP_MAX];

#ifdef __cplusplus
}
#endif

#endif /* SOCKET_ZEP_PARAMS_H */
/** @} */
3 changes: 3 additions & 0 deletions cpu/native/socket_zep/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
include $(RIOTBASE)/Makefile.base

INCLUDES = $(NATIVEINCLUDES)
Loading