Skip to content

Commit bb5f8eb

Browse files
Martin Lendersmiri64
authored andcommitted
Initial import of SLIP networking module
1 parent 5489eb5 commit bb5f8eb

File tree

7 files changed

+486
-0
lines changed

7 files changed

+486
-0
lines changed

Makefile.dep

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ ifneq (,$(filter sixlowpan,$(USEMODULE)))
3434
USEMODULE += vtimer
3535
endif
3636

37+
ifneq (,$(filter slip,$(USEMODULE)))
38+
USEMODULE += lib
39+
ifeq (,$(filter-out $(BOARD),arduino-due iot-lab_M3 pca10000 pca10005 stm32f0discovery stm32f3discovery stm32f4discovery))
40+
USEMODULE += posix
41+
USEMODULE += uart0
42+
endif
43+
endif
44+
3745
ifneq (,$(filter posix,$(USEMODULE)))
3846
USEMODULE += uart0
3947
USEMODULE += timex

drivers/include/net_dev/base.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ typedef enum {
8686
NET_DEV_PROTO_UDP = 0x0006, /**< UDP */
8787
NET_DEV_PROTO_TCP = 0x0007, /**< TCP */
8888
NET_DEV_PROTO_CCNL = 0x0008, /**< CCN lite */
89+
NET_DEV_PROTO_SLIP = 0x0009, /**< SLIP stream */
8990
} net_dev_proto_t;
9091

9192
/**

sys/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ endif
5252
ifneq (,$(filter basic_mac,$(USEMODULE)))
5353
DIRS += net/link_layer/basic_mac
5454
endif
55+
ifneq (,$(filter slip,$(USEMODULE)))
56+
DIRS += net/link_layer/slip
57+
endif
5558
ifneq (,$(filter destiny,$(USEMODULE)))
5659
DIRS += net/transport_layer/destiny
5760
endif

sys/net/include/slip.h

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/*
2+
* Copyright (C) 2014 Martin Lenders
3+
*
4+
* This file is subject to the terms and conditions of the GNU Lesser General
5+
* Public License. See the file LICENSE in the top level directory for more
6+
* details.
7+
*/
8+
9+
/**
10+
* @defgroup slip SLIP transceiver
11+
* @ingroup net
12+
* @{
13+
*
14+
* @file slip.h
15+
* @brief Provides a SLIP interface over UART.
16+
* @see <a href="https://www.ietf.org/rfc/rfc1055">RFC 1055</a>
17+
*
18+
* @author Martine Lenders <[email protected]>
19+
*
20+
* @}
21+
*/
22+
23+
#ifndef __SLIP_H_
24+
#define __SLIP_H_
25+
26+
#include <stdint.h>
27+
28+
#include "periph/uart.h"
29+
#include "basic_net.h"
30+
31+
#include "ipv6.h"
32+
33+
#if !UART_NUMOF
34+
/**
35+
* @brief Guard type in the case that the board does not implement the new
36+
* driver model
37+
*/
38+
typedef uint8_t uart_t;
39+
#endif
40+
41+
/**
42+
* Initializes a new @ref slip control thread for UART device *uart*. If
43+
* the board does not support the uart_t type it falls back to using
44+
* board_uart0.h
45+
*
46+
* @param[in] uart The (uninitialized) UART device, ignored if UART_NUMOF == 0 or not defined
47+
* @param[in] baudrate Symbole rate for the UART device
48+
* @param[in] in_buf Ringbuffer to store the incoming data from the UART in.
49+
* Must hold at least L3 packet.
50+
*
51+
* @return The PID of the @ref slip control thread
52+
*/
53+
kernel_pid_t slip_init(uart_t uart, uint32_t baudrate, ringbuffer_t *in_buf);
54+
55+
/**
56+
* @brief Send a layer 3 packet over the UART device
57+
*
58+
* @param[in] pid The PID for the @ref slip control thread
59+
* @param[in] upper_layer_hdrs All upper layer headers including layer 3.
60+
* @param[in] data Data (*without* all upper layer headers) to send
61+
* over the UART device
62+
* @param[in] data_len Length of *data*
63+
*/
64+
static inline int slip_send_l3_packet(kernel_pid_t pid, net_dev_hlist_t *upper_layer_hdrs,
65+
void *data, size_t data_len)
66+
{
67+
return basic_net_send_data2(pid, upper_layer_hdrs, NULL, 0, data, data_len);
68+
}
69+
70+
#endif /* __SLIP_H_ */

sys/net/link_layer/slip/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
INCLUDES += -I$(RIOTBASE)/sys/net/include
2+
include $(RIOTBASE)/Makefile.base

sys/net/link_layer/slip/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
SLIP network interface
2+
======================
3+
4+
This module provides access to the [http://tools.ietf.org/html/rfc1055](Serial Line Internet Protocol (SLIP)).
5+
It allows you to send IP and IPv6 packages over the U(S)ART. For this you
6+
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):
7+
8+
```bash
9+
sudo modprobe slip # you do not need this line in Mac OS X
10+
sudo slattach -s <your UART's baudrate, typically 115200> -p slip <your serial device, typically /dev/ttyUSB0>
11+
sudo ifconfig sl0 mtu 1280 # or smaller, for e.g. MSP-430 boards
12+
sudo ifconfig sl0 add fe80::/64
13+
sudo ifconfig sl0 add abcd::/64 # replace with an IPv6 prefix of your choice
14+
sudo ifconfig sl0 up
15+
```
16+
17+
If your RIOT board is configured as an IPv6 router, the rest should happen automatically.

0 commit comments

Comments
 (0)