zephyr/subsys/net/ip/canbus_socket.c
Robert Lubos 32f3ce396f net: connection: Split net_conn_input()
The current implementation of net_conn_input() can accept different
packet types, with completely different processing code, resulting in a
function which is pretty bloated, sliced with conditionally enabled code
and hard to understand and therefore maintain.

This commit splits that function into smaller ones, specialized for
different packet types (and entry levels). The following functions have
been extracted from the original one:
  - net_conn_packet_input() for early packet processing (covering
    AF_PACKET family sockets)
  - net_conn_raw_ip_input() for raw IP packets processing (covering
    AF_INET(6)/SOCK_RAW sockets)
  - net_conn_can_input() for CAN packets processing (covering AF_CAN
    family sockets)

The net_conn_input() function stripped from above cases now only takes
care of packets that have been processed by respective L4 and are
intended for regular TCP/UDP sockets.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-04-23 11:48:33 +02:00

31 lines
651 B
C

/** @file
* @brief CANBUS Sockets related functions
*/
/*
* Copyright (c) 2019 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(net_sockets_can, CONFIG_NET_SOCKETS_LOG_LEVEL);
#include <errno.h>
#include <zephyr/net/net_pkt.h>
#include <zephyr/net/net_context.h>
#include <zephyr/net/socketcan.h>
#include "connection.h"
enum net_verdict net_canbus_socket_input(struct net_pkt *pkt)
{
__ASSERT_NO_MSG(net_pkt_family(pkt) == AF_CAN);
if (net_if_l2(net_pkt_iface(pkt)) == &NET_L2_GET_NAME(CANBUS_RAW)) {
return net_conn_can_input(pkt, CAN_RAW);
}
return NET_CONTINUE;
}