-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial import of SLIP networking module
- Loading branch information
Showing
7 changed files
with
486 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
INCLUDES += -I$(RIOTBASE)/sys/net/include | ||
include $(RIOTBASE)/Makefile.base |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
Oops, something went wrong.