Skip to content

Commit

Permalink
Initial import of SLIP networking module
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Lenders authored and miri64 committed Sep 8, 2014
1 parent 5489eb5 commit bb5f8eb
Show file tree
Hide file tree
Showing 7 changed files with 486 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ ifneq (,$(filter sixlowpan,$(USEMODULE)))
USEMODULE += vtimer
endif

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

ifneq (,$(filter posix,$(USEMODULE)))
USEMODULE += uart0
USEMODULE += timex
Expand Down
1 change: 1 addition & 0 deletions drivers/include/net_dev/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ typedef enum {
NET_DEV_PROTO_UDP = 0x0006, /**< UDP */
NET_DEV_PROTO_TCP = 0x0007, /**< TCP */
NET_DEV_PROTO_CCNL = 0x0008, /**< CCN lite */
NET_DEV_PROTO_SLIP = 0x0009, /**< SLIP stream */
} net_dev_proto_t;

/**
Expand Down
3 changes: 3 additions & 0 deletions sys/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ endif
ifneq (,$(filter basic_mac,$(USEMODULE)))
DIRS += net/link_layer/basic_mac
endif
ifneq (,$(filter slip,$(USEMODULE)))
DIRS += net/link_layer/slip
endif
ifneq (,$(filter destiny,$(USEMODULE)))
DIRS += net/transport_layer/destiny
endif
Expand Down
70 changes: 70 additions & 0 deletions sys/net/include/slip.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* Copyright (C) 2014 Martin Lenders
*
* This file is subject to the terms and conditions of the GNU Lesser General
* Public License. See the file LICENSE in the top level directory for more
* details.
*/

/**
* @defgroup slip SLIP transceiver
* @ingroup net
* @{
*
* @file slip.h
* @brief Provides a SLIP interface over UART.
* @see <a href="https://www.ietf.org/rfc/rfc1055">RFC 1055</a>
*
* @author Martine Lenders <[email protected]>
*
* @}
*/

#ifndef __SLIP_H_
#define __SLIP_H_

#include <stdint.h>

#include "periph/uart.h"
#include "basic_net.h"

#include "ipv6.h"

#if !UART_NUMOF
/**
* @brief Guard type in the case that the board does not implement the new
* driver model
*/
typedef uint8_t uart_t;
#endif

/**
* Initializes a new @ref slip control thread for UART device *uart*. If
* the board does not support the uart_t type it falls back to using
* board_uart0.h
*
* @param[in] uart The (uninitialized) UART device, ignored if UART_NUMOF == 0 or not defined
* @param[in] baudrate Symbole rate for the UART device
* @param[in] in_buf Ringbuffer to store the incoming data from the UART in.
* Must hold at least L3 packet.
*
* @return The PID of the @ref slip control thread
*/
kernel_pid_t slip_init(uart_t uart, uint32_t baudrate, ringbuffer_t *in_buf);

/**
* @brief Send a layer 3 packet over the UART device
*
* @param[in] pid The PID for the @ref slip control thread
* @param[in] upper_layer_hdrs All upper layer headers including layer 3.
* @param[in] data Data (*without* all upper layer headers) to send
* over the UART device
* @param[in] data_len Length of *data*
*/
static inline int slip_send_l3_packet(kernel_pid_t pid, net_dev_hlist_t *upper_layer_hdrs,
void *data, size_t data_len)
{
return basic_net_send_data2(pid, upper_layer_hdrs, NULL, 0, data, data_len);
}

#endif /* __SLIP_H_ */
2 changes: 2 additions & 0 deletions sys/net/link_layer/slip/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
INCLUDES += -I$(RIOTBASE)/sys/net/include
include $(RIOTBASE)/Makefile.base
17 changes: 17 additions & 0 deletions sys/net/link_layer/slip/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
SLIP network interface
======================

This module provides access to the [http://tools.ietf.org/html/rfc1055](Serial Line Internet Protocol (SLIP)).
It allows you to send IP and IPv6 packages over the U(S)ART. For this you
have to initialize your serial device as a network device. In Linux (and Mac OS X) [http://playground.arduino.cc/Code/SerialIP#Connecting_Linux](this is easy):

```bash
sudo modprobe slip # you do not need this line in Mac OS X
sudo slattach -s <your UART's baudrate, typically 115200> -p slip <your serial device, typically /dev/ttyUSB0>
sudo ifconfig sl0 mtu 1280 # or smaller, for e.g. MSP-430 boards
sudo ifconfig sl0 add fe80::/64
sudo ifconfig sl0 add abcd::/64 # replace with an IPv6 prefix of your choice
sudo ifconfig sl0 up
```
If your RIOT board is configured as an IPv6 router, the rest should happen automatically.
Loading

0 comments on commit bb5f8eb

Please sign in to comment.