1 /** @file
2  * @brief Packet Sockets related functions
3  */
4 
5 /*
6  * Copyright (c) 2019 Intel Corporation
7  *
8  * SPDX-License-Identifier: Apache-2.0
9  */
10 
11 #include <zephyr/logging/log.h>
12 LOG_MODULE_REGISTER(net_sockets_raw, CONFIG_NET_SOCKETS_LOG_LEVEL);
13 
14 #include <errno.h>
15 #include <zephyr/net/net_pkt.h>
16 #include <zephyr/net/net_context.h>
17 #include <zephyr/net/ethernet.h>
18 #include <zephyr/net/dsa.h>
19 
20 #include "connection.h"
21 #include "packet_socket.h"
22 
net_packet_socket_input(struct net_pkt * pkt,uint8_t proto)23 enum net_verdict net_packet_socket_input(struct net_pkt *pkt, uint8_t proto)
24 {
25 	sa_family_t orig_family;
26 	enum net_verdict net_verdict;
27 
28 #if defined(CONFIG_NET_DSA)
29 	/*
30 	 * For DSA the master port is not supporting raw packets. Only the
31 	 * lan1..3 are working with them.
32 	 */
33 	if (dsa_is_port_master(net_pkt_iface(pkt))) {
34 		return NET_CONTINUE;
35 	}
36 #endif
37 
38 	orig_family = net_pkt_family(pkt);
39 
40 	net_pkt_set_family(pkt, AF_PACKET);
41 
42 	net_verdict = net_conn_input(pkt, NULL, proto, NULL);
43 
44 	net_pkt_set_family(pkt, orig_family);
45 
46 	if (net_verdict == NET_DROP) {
47 		return NET_CONTINUE;
48 	} else {
49 		return net_verdict;
50 	}
51 }
52