+/*
+ * Size of buffer that can contain any pktap header
+ * followed by the optional 4 bytes protocol field
+ * or 16 bytes link layer header
+ */
+union pktap_header_extra {
+ uint8_t llhdr[16];
+ uint32_t proto;
+};
+
+/*
+ * Version 2 version of the header
+ *
+ * The field pth_flags is at the same offset as the orignal pktap_header and
+ * the flag PTH_FLAG_V2_HDR allows to differentiate the header version.
+ */
+
+#define PKTAP_MAX_COMM_SIZE (MAXCOMLEN + 1)
+
+struct pktap_v2_hdr {
+ uint8_t pth_length; /* length of this header */
+ uint8_t pth_uuid_offset; /* max size: sizeof(uuid_t) */
+ uint8_t pth_e_uuid_offset; /* max size: sizeof(uuid_t) */
+ uint8_t pth_ifname_offset; /* max size: PKTAP_IFXNAMESIZE*/
+ uint8_t pth_comm_offset; /* max size: PKTAP_MAX_COMM_SIZE */
+ uint8_t pth_e_comm_offset; /* max size: PKTAP_MAX_COMM_SIZE */
+ uint16_t pth_dlt; /* DLT of packet */
+ uint16_t pth_frame_pre_length;
+ uint16_t pth_frame_post_length;
+ uint16_t pth_iftype;
+ uint16_t pth_ipproto;
+ uint32_t pth_protocol_family;
+ uint32_t pth_svc; /* service class */
+ uint32_t pth_flowid;
+ pid_t pth_pid; /* process ID */
+ pid_t pth_e_pid; /* effective process ID */
+ uint32_t pth_flags; /* flags */
+};
+
+struct pktap_v2_hdr_space {
+ struct pktap_v2_hdr pth_hdr;
+ uint8_t pth_uuid[sizeof(uuid_t)];
+ uint8_t pth_e_uuid[sizeof(uuid_t)];
+ uint8_t pth_ifname[PKTAP_IFXNAMESIZE];
+ uint8_t pth_comm[PKTAP_MAX_COMM_SIZE];
+ uint8_t pth_e_comm[PKTAP_MAX_COMM_SIZE];
+};
+
+struct pktap_buffer_v2_hdr_extra {
+ struct pktap_v2_hdr_space hdr_space;
+ union pktap_header_extra extra;
+};
+
+#define COPY_PKTAP_COMMON_FIELDS_TO_V2(pktap_v2_hdr_dst, pktap_header_src) { \
+ (pktap_v2_hdr_dst)->pth_length = sizeof(struct pktap_v2_hdr); \
+ (pktap_v2_hdr_dst)->pth_uuid_offset = 0; \
+ (pktap_v2_hdr_dst)->pth_e_uuid_offset = 0; \
+ (pktap_v2_hdr_dst)->pth_ifname_offset = 0; \
+ (pktap_v2_hdr_dst)->pth_comm_offset = 0; \
+ (pktap_v2_hdr_dst)->pth_e_comm_offset = 0; \
+ (pktap_v2_hdr_dst)->pth_dlt = (pktap_header_src)->pth_dlt; \
+ (pktap_v2_hdr_dst)->pth_frame_pre_length = (pktap_header_src)->pth_frame_pre_length; \
+ (pktap_v2_hdr_dst)->pth_frame_post_length = (pktap_header_src)->pth_frame_post_length; \
+ (pktap_v2_hdr_dst)->pth_iftype = (pktap_header_src)->pth_iftype; \
+ (pktap_v2_hdr_dst)->pth_ipproto = (pktap_header_src)->pth_ipproto; \
+ (pktap_v2_hdr_dst)->pth_protocol_family = (pktap_header_src)->pth_protocol_family; \
+ (pktap_v2_hdr_dst)->pth_svc = (pktap_header_src)->pth_svc; \
+ (pktap_v2_hdr_dst)->pth_flowid = (pktap_header_src)->pth_flowid; \
+ (pktap_v2_hdr_dst)->pth_pid = (pktap_header_src)->pth_pid; \
+ (pktap_v2_hdr_dst)->pth_e_pid = (pktap_header_src)->pth_epid; \
+ (pktap_v2_hdr_dst)->pth_flags = (pktap_header_src)->pth_flags; \
+ (pktap_v2_hdr_dst)->pth_flags |= PTH_FLAG_V2_HDR; \
+}
+
+/*
+ * Values for field pth_flags
+ */
+#define PTH_FLAG_DIR_IN 0x00000001 /* Outgoing packet */
+#define PTH_FLAG_DIR_OUT 0x00000002 /* Incoming packet */
+#define PTH_FLAG_PROC_DELEGATED 0x00000004 /* Process delegated */
+#define PTH_FLAG_IF_DELEGATED 0x00000008 /* Interface delegated */