Skip to content

Commit

Permalink
net: socket: packet: Add EtherCAT protocol support
Browse files Browse the repository at this point in the history
Add EtherCAT protocol support, now applications can
transmit/receive EtherCAT packets via RAW socket.

Signed-off-by: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>
  • Loading branch information
Zhiqiang-Hou authored and carlescufi committed Dec 20, 2021
1 parent 11d9c00 commit 2fafd85
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions include/net/ethernet.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ struct net_eth_addr {
#define NET_ETH_PTYPE_PTP 0x88f7
#define NET_ETH_PTYPE_LLDP 0x88cc
#define NET_ETH_PTYPE_ALL 0x0003 /* from linux/if_ether.h */
#define NET_ETH_PTYPE_ECAT 0x88a4

#if !defined(ETH_P_ALL)
#define ETH_P_ALL NET_ETH_PTYPE_ALL
Expand All @@ -84,6 +85,9 @@ struct net_eth_addr {
#if !defined(ETH_P_TSN)
#define ETH_P_TSN NET_ETH_PTYPE_TSN
#endif
#if !defined(ETH_P_ECAT)
#define ETH_P_ECAT NET_ETH_PTYPE_ECAT
#endif

#define NET_ETH_MINIMAL_FRAME_SIZE 60
#define NET_ETH_MTU 1500
Expand Down
3 changes: 2 additions & 1 deletion subsys/net/lib/sockets/sockets_packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,8 @@ static const struct socket_op_vtable packet_sock_fd_op_vtable = {
static bool packet_is_supported(int family, int type, int proto)
{
if (((type == SOCK_RAW) && (proto == ETH_P_ALL)) ||
((type == SOCK_RAW) && (proto == IPPROTO_RAW)) ||
((type == SOCK_RAW) && (proto == IPPROTO_RAW)) ||
((type == SOCK_RAW) && (proto == ETH_P_ECAT)) ||
((type == SOCK_DGRAM) && (proto > 0))) {
return true;
}
Expand Down

0 comments on commit 2fafd85

Please sign in to comment.