1 /*
2  * Copyright (c) 2024 Nordic Semiconductor
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 /* Defines for Linux cooked mode capture (SLL) */
8 
9 #include <zephyr/kernel.h>
10 #include <zephyr/types.h>
11 
12 /* Useful information about SLL header format can be found here
13  * https://www.tcpdump.org/linktypes/LINKTYPE_LINUX_SLL.html
14  */
15 
16 #define SLL_HDR_LEN  16 /* Total header length         */
17 #define SLL_ADDRLEN   8 /* Length of the address field */
18 
19 struct sll_header {
20 	uint16_t sll_pkttype;           /* Packet type               */
21 	uint16_t sll_hatype;            /* Link-layer address type   */
22 	uint16_t sll_halen;             /* Link-layer address length */
23 	uint8_t  sll_addr[SLL_ADDRLEN]; /* Link-layer address        */
24 	uint16_t sll_protocol;          /* Protocol                  */
25 };
26 
27 BUILD_ASSERT(sizeof(struct sll_header) == SLL_HDR_LEN);
28 
29 #define SLL2_HDR_LEN 20 /* Total header length         */
30 
31 struct sll2_header {
32 	uint16_t sll2_protocol;          /* Protocol                  */
33 	uint16_t sll2_reserved_mbz;      /* Reserved - must be zero   */
34 	uint32_t sll2_if_index;          /* 1-based interface index   */
35 	uint16_t sll2_hatype;            /* Link-layer address type   */
36 	uint8_t  sll2_pkttype;           /* Packet type               */
37 	uint8_t  sll2_halen;             /* Link-layer address length */
38 	uint8_t  sll2_addr[SLL_ADDRLEN]; /* Link-layer address        */
39 };
40 
41 BUILD_ASSERT(sizeof(struct sll2_header) == SLL2_HDR_LEN);
42 
43 #define SLL_HOST       0 /* packet was sent to us by somebody else */
44 #define SLL_BROADCAST  1 /* packet was broadcast by somebody else */
45 #define SLL_MULTICAST  2 /* packet was multicast, but not broadcast, by somebody else */
46 #define SLL_OTHERHOST  3 /* packet was sent by somebody else to somebody else */
47 #define SLL_OUTGOING   4 /* packet was sent by us */
48