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: Initial import of a UART network interface #1454

Closed
wants to merge 17 commits into from
Closed
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
20 changes: 20 additions & 0 deletions Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ ifneq (,$(filter sixlowpan,$(USEMODULE)))
USEMODULE += vtimer
endif

ifneq (,$(filter slip,$(USEMODULE)))
USEMODULE += pktbuf
ifeq (,$(filter $(BOARD),arduino-due iot-lab_M3 pca10000 pca10005 stm32f0discovery stm32f3discovery stm32f4discovery))
USEMODULE += posix
USEMODULE += uart0
endif
endif

ifneq (,$(filter aodvv2,$(USEMODULE)))
USEMODULE += vtimer
USEMODULE += sixlowpan
Expand Down Expand Up @@ -108,10 +116,22 @@ ifneq (,$(filter ccn_lite,$(USEMODULE)))
USEMODULE += crypto
endif

ifneq (,$(filter nomac,$(USEMODULE)))
USEMODULE += pktbuf
endif

ifneq (,$(filter netapi,$(USEMODULE)))
USEMODULE += pkt
endif

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

ifneq (,$(filter pktbuf,$(USEMODULE)))
USEMODULE += pkt
endif

ifneq (,$(filter rgbled,$(USEMODULE)))
USEMODULE += color
endif
Expand Down
5 changes: 3 additions & 2 deletions drivers/include/netdev/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ typedef enum {
* @detail Sends frames as defined by cc110x_packet_t.
*/
NETDEV_PROTO_CC110X = 0x0008,
NETDEV_PROTO_SLIP = 0x0009, /**< Serial line IP. */
} netdev_proto_t;

/**
Expand Down Expand Up @@ -192,7 +193,7 @@ typedef int (*netdev_rcv_data_cb_t)(netdev_t *dev, void *src, size_t src_len,
/**
* @brief Network device API definition.
*
* @details This is a set of functions that must be implemented by any driver
* @details This is a set of functions that must be implemented by any driver
* for a network device.
*/
typedef struct {
Expand Down Expand Up @@ -328,7 +329,7 @@ typedef struct {
*
* @param[in] dev the network device that fired the event.
* @param[in] event_type Event type. Values are free to choose for the
* driver. Must be given in the @ref msg_t::value
* driver. Must be given in the @ref msg_t::content::value
* of the received message
*/
void (*event)(netdev_t *dev, uint32_t event_type);
Expand Down
3 changes: 3 additions & 0 deletions sys/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ endif
ifneq (,$(filter nomac,$(USEMODULE)))
DIRS += net/link_layer/nomac
endif
ifneq (,$(filter slip,$(USEMODULE)))
DIRS += net/link_layer/slip
endif
ifneq (,$(filter transport_layer,$(USEMODULE)))
USEMODULE += udp
USEMODULE += tcp
Expand Down
3 changes: 3 additions & 0 deletions sys/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ endif
ifneq (,$(filter netapi,$(USEMODULE)))
USEMODULE_INCLUDES += $(RIOTBASE)/sys/net/include
endif
ifneq (,$(filter slip,$(USEMODULE)))
USEMODULE_INCLUDES += $(RIOTBASE)/sys/net/include
endif
ifneq (,$(filter net_help,$(USEMODULE)))
USEMODULE_INCLUDES += $(RIOTBASE)/sys/net/include
USEMODULE_INCLUDES += $(RIOTBASE)/drivers/cc110x
Expand Down
38 changes: 17 additions & 21 deletions sys/net/crosslayer/netapi/netapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,18 @@ int netapi_send_command(kernel_pid_t pid, netapi_cmd_t *cmd)
return ack_result;
}

int netapi_send_packet(kernel_pid_t pid, netdev_hlist_t *upper_layer_hdrs,
void *addr, size_t addr_len, void *data, size_t data_len)
int netapi_send_packet(kernel_pid_t pid, void *dest, size_t dest_len,
pkt_t *pkt)
{
netapi_snd_pkt_t pkt;
netapi_pkt_t cmd;

pkt.type = NETAPI_CMD_SND;
cmd.type = NETAPI_CMD_SND;

pkt.ulh = upper_layer_hdrs;
pkt.dest = addr;
pkt.dest_len = addr_len;
pkt.data = data;
pkt.data_len = data_len;
cmd.dest = dest;
cmd.dest_len = dest_len;
cmd.pkt = pkt;

return netapi_send_command(pid, (netapi_cmd_t *)(&pkt));
return netapi_send_command(pid, (netapi_cmd_t *)(&cmd));
}

static unsigned int _get_set_option(kernel_pid_t pid, netapi_cmd_type_t type,
Expand Down Expand Up @@ -125,21 +123,19 @@ int netapi_unregister(kernel_pid_t pid, kernel_pid_t reg_pid)

#ifdef MODULE_NETDEV_DUMMY
int netapi_fire_receive_event(kernel_pid_t pid, void *src, size_t src_len,
void *dest, size_t dest_len, void *data,
size_t data_len)
void *dest, size_t dest_len, pkt_t *pkt)
{
netapi_rcv_pkt_t pkt;
netapi_pkt_t cmd;

pkt.type = NETAPI_CMD_FIRE_RCV;
cmd.type = NETAPI_CMD_FIRE_RCV;

pkt.src = src;
pkt.src_len = src_len;
pkt.dest = dest;
pkt.dest_len = dest_len;
pkt.data = data;
pkt.data_len = data_len;
cmd.src = src;
cmd.src_len = src_len;
cmd.dest = dest;
cmd.dest_len = dest_len;
cmd.pkt = pkt;

return netapi_send_command(pid, (netapi_cmd_t *)(&pkt));
return netapi_send_command(pid, (netapi_cmd_t *)(&cmd));
}
#endif
/**
Expand Down
Loading