net: slip: Add slip driver for testing purposes
This slip driver is needed for sending packets outside of qemu. Change-Id: Ifc37181094ddebce08d97ae889f3a58c03d01ae1 Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
parent
6421d6eba8
commit
3e4d890d72
|
@ -102,7 +102,8 @@ ifeq ($(CONFIG_NETWORKING_WITH_15_4),)
|
|||
endif
|
||||
|
||||
obj-$(CONFIG_NETWORKING_UART) += contiki/os/dev/slip.o \
|
||||
contiki/os/dev/slip-arch.o
|
||||
contiki/os/dev/slip-arch.o \
|
||||
net_driver_slip.o
|
||||
|
||||
# workaround for include file location
|
||||
CREATE_INCLUDE_LINK_net := $(shell ln -s ${ZEPHYR_BASE}/net/ip/contiki ${ZEPHYR_BASE}/net/ip/contiki/net > /dev/null 2>&1)
|
||||
|
|
76
net/ip/net_driver_slip.c
Normal file
76
net/ip/net_driver_slip.c
Normal file
|
@ -0,0 +1,76 @@
|
|||
/* net_driver_slip.c - Slip (serial line IP) driver */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2015 Intel Corporation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1) Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2) Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3) Neither the name of Intel Corporation nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <nanokernel.h>
|
||||
#include <toolchain.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#if defined(CONFIG_STDOUT_CONSOLE)
|
||||
#include <stdio.h>
|
||||
#define PRINT printf
|
||||
#else
|
||||
#include <misc/printk.h>
|
||||
#define PRINT printk
|
||||
#endif
|
||||
|
||||
#include <net/net_core.h>
|
||||
#include <net/net_buf.h>
|
||||
|
||||
#include "contiki/os/dev/slip.h"
|
||||
|
||||
static int net_driver_slip_open(void)
|
||||
{
|
||||
NET_DBG("Initialized slip driver\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int net_driver_slip_send(struct net_buf *buf)
|
||||
{
|
||||
NET_DBG("Sending %d bytes\n", buf->len);
|
||||
|
||||
return slip_send(buf);
|
||||
}
|
||||
|
||||
static struct net_driver net_driver_slip = {
|
||||
.head_reserve = 0,
|
||||
.open = net_driver_slip_open,
|
||||
.send = net_driver_slip_send,
|
||||
};
|
||||
|
||||
int net_driver_slip_init(void)
|
||||
{
|
||||
net_register_driver(&net_driver_slip);
|
||||
|
||||
return 0;
|
||||
}
|
6
net/ip/net_driver_slip.h
Normal file
6
net/ip/net_driver_slip.h
Normal file
|
@ -0,0 +1,6 @@
|
|||
|
||||
#ifdef CONFIG_NETWORKING_UART
|
||||
int net_driver_slip_init(void);
|
||||
#else
|
||||
#define net_driver_slip_init()
|
||||
#endif
|
|
@ -51,6 +51,7 @@
|
|||
#include <net/net_socket.h>
|
||||
|
||||
#include "net_driver_15_4.h"
|
||||
#include "net_driver_slip.h"
|
||||
|
||||
#include "contiki/os/sys/process.h"
|
||||
#include "contiki/os/sys/etimer.h"
|
||||
|
@ -615,5 +616,7 @@ int net_init(void)
|
|||
net_driver_15_4_init();
|
||||
#endif
|
||||
|
||||
net_driver_slip_init();
|
||||
|
||||
return network_initialization();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue