net: canbus: Rename canbus to canbus_raw

Rename the socket_can implementation from CANBUS to CANBUS_RAW.
This is a preperation for 6LoCAN which is a CANBUS L2 for IPv6.

Signed-off-by: Alexander Wachter <alexander.wachter@student.tugraz.at>
This commit is contained in:
Alexander Wachter 2019-08-06 16:08:01 +02:00 committed by Jukka Rissanen
parent 5ef7eea6e2
commit c8c5f3bbf3
7 changed files with 60 additions and 11 deletions

View file

@ -211,7 +211,7 @@ NET_DEVICE_INIT(socket_can_loopback_1, SOCKET_CAN_NAME_1, socket_can_init_1,
&socket_can_context_1, NULL,
CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
&socket_can_api,
CANBUS_L2, NET_L2_GET_CTX_TYPE(CANBUS_L2), CAN_MTU);
CANBUS_RAW_L2, NET_L2_GET_CTX_TYPE(CANBUS_RAW_L2), CAN_MTU);
#endif /* CONFIG_NET_SOCKETS_CAN */

View file

@ -957,7 +957,7 @@ NET_DEVICE_INIT(socket_can_stm32_1, SOCKET_CAN_NAME_1, socket_can_init_1,
&socket_can_context_1, NULL,
CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
&socket_can_api,
CANBUS_L2, NET_L2_GET_CTX_TYPE(CANBUS_L2), CAN_MTU);
CANBUS_RAW_L2, NET_L2_GET_CTX_TYPE(CANBUS_RAW_L2), CAN_MTU);
#endif /* CONFIG_NET_SOCKETS_CAN */

View file

@ -114,11 +114,11 @@ NET_L2_DECLARE_PUBLIC(BLUETOOTH_L2);
NET_L2_DECLARE_PUBLIC(OPENTHREAD_L2);
#endif /* CONFIG_NET_L2_OPENTHREAD */
#ifdef CONFIG_NET_L2_CANBUS
#define CANBUS_L2 CANBUS
#define CANBUS_L2_CTX_TYPE void*
NET_L2_DECLARE_PUBLIC(CANBUS_L2);
#endif /* CONFIG_NET_L2_CANBUS */
#ifdef CONFIG_NET_L2_CANBUS_RAW
#define CANBUS_RAW_L2 CANBUS_RAW
#define CANBUS_RAW_L2_CTX_TYPE void*
NET_L2_DECLARE_PUBLIC(CANBUS_RAW_L2);
#endif /* CONFIG_NET_L2_CANBUS_RAW */
#define NET_L2_INIT(_name, _recv_fn, _send_fn, _enable_fn, _get_flags_fn) \
const struct net_l2 (NET_L2_GET_NAME(_name)) __used \

View file

@ -56,7 +56,7 @@ enum net_link_type {
/** Dummy link address. Used in testing apps and loopback support. */
NET_LINK_DUMMY,
/** CANBUS link address. */
NET_LINK_CANBUS,
NET_LINK_CANBUS_RAW,
} __packed;
/**

View file

@ -0,0 +1,49 @@
/*
* Copyright (c) 2019 Intel Corporation.
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <logging/log.h>
LOG_MODULE_REGISTER(net_l2_canbus, LOG_LEVEL_NONE);
#include <net/net_core.h>
#include <net/net_l2.h>
#include <net/net_if.h>
#include <net/net_pkt.h>
#include <net/socket_can.h>
static inline enum net_verdict canbus_recv(struct net_if *iface,
struct net_pkt *pkt)
{
net_pkt_lladdr_src(pkt)->addr = NULL;
net_pkt_lladdr_src(pkt)->len = 0U;
net_pkt_lladdr_src(pkt)->type = NET_LINK_CANBUS_RAW;
net_pkt_lladdr_dst(pkt)->addr = NULL;
net_pkt_lladdr_dst(pkt)->len = 0U;
net_pkt_lladdr_dst(pkt)->type = NET_LINK_CANBUS_RAW;
net_pkt_set_family(pkt, AF_CAN);
return NET_CONTINUE;
}
static inline int canbus_send(struct net_if *iface, struct net_pkt *pkt)
{
const struct canbus_api *api = net_if_get_device(iface)->driver_api;
int ret;
if (!api) {
return -ENOENT;
}
ret = api->send(net_if_get_device(iface), pkt);
if (!ret) {
ret = net_pkt_get_len(pkt);
net_pkt_unref(pkt);
}
return ret;
}
NET_L2_INIT(CANBUS_RAW_L2, canbus_recv, canbus_send, NULL, NULL);

View file

@ -129,7 +129,7 @@ config NET_SOCKETS_PACKET
config NET_SOCKETS_CAN
bool "Enable socket CAN support [EXPERIMENTAL]"
select NET_L2_CANBUS
select NET_L2_CANBUS_RAW
help
The value depends on your network needs.

View file

@ -95,7 +95,7 @@ CONFIG_NET_L2_IEEE802154_SECURITY=y
CONFIG_NET_L2_IEEE802154_SECURITY_CRYPTO_DEV_NAME="CRYPTO-DEV"
CONFIG_NET_L2_DUMMY=y
CONFIG_NET_L2_ETHERNET=y
CONFIG_NET_L2_CANBUS=y
CONFIG_NET_L2_CANBUS_RAW=y
CONFIG_NET_L2_ETHERNET_MGMT=y
CONFIG_NET_L2_IEEE802154_RADIO_DFLT_TX_POWER=2
CONFIG_NET_L2_IEEE802154_SUB_GHZ=y
@ -368,7 +368,7 @@ CONFIG_NET_SOCKETS_TLS_MAX_CREDENTIALS=10
# Network interface defaults
CONFIG_NET_DEFAULT_IF_BLUETOOTH=y
CONFIG_NET_DEFAULT_IF_CANBUS=y
CONFIG_NET_DEFAULT_IF_CANBUS_RAW=y
CONFIG_NET_DEFAULT_IF_DUMMY=y
CONFIG_NET_DEFAULT_IF_ETHERNET=y
CONFIG_NET_DEFAULT_IF_FIRST=y