16f52b16cSGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 20b2e6644SGerard Garcia #ifndef _UAPI_VSOCKMON_H 30b2e6644SGerard Garcia #define _UAPI_VSOCKMON_H 40b2e6644SGerard Garcia 50b2e6644SGerard Garcia #include <linux/virtio_vsock.h> 60b2e6644SGerard Garcia 70b2e6644SGerard Garcia /* 80b2e6644SGerard Garcia * vsockmon is the AF_VSOCK packet capture device. Packets captured have the 90b2e6644SGerard Garcia * following layout: 100b2e6644SGerard Garcia * 110b2e6644SGerard Garcia * +-----------------------------------+ 120b2e6644SGerard Garcia * | vsockmon header | 130b2e6644SGerard Garcia * | (struct af_vsockmon_hdr) | 140b2e6644SGerard Garcia * +-----------------------------------+ 150b2e6644SGerard Garcia * | transport header | 160b2e6644SGerard Garcia * | (af_vsockmon_hdr->len bytes long) | 170b2e6644SGerard Garcia * +-----------------------------------+ 180b2e6644SGerard Garcia * | payload | 190b2e6644SGerard Garcia * | (until end of packet) | 200b2e6644SGerard Garcia * +-----------------------------------+ 210b2e6644SGerard Garcia * 220b2e6644SGerard Garcia * The vsockmon header is a transport-independent description of the packet. 230b2e6644SGerard Garcia * It duplicates some of the information from the transport header so that 240b2e6644SGerard Garcia * no transport-specific knowledge is necessary to process packets. 250b2e6644SGerard Garcia * 260b2e6644SGerard Garcia * The transport header is useful for low-level transport-specific packet 270b2e6644SGerard Garcia * analysis. Transport type is given in af_vsockmon_hdr->transport and 280b2e6644SGerard Garcia * transport header length is given in af_vsockmon_hdr->len. 290b2e6644SGerard Garcia * 300b2e6644SGerard Garcia * If af_vsockmon_hdr->op is AF_VSOCK_OP_PAYLOAD then the payload follows the 310b2e6644SGerard Garcia * transport header. Other ops do not have a payload. 320b2e6644SGerard Garcia */ 330b2e6644SGerard Garcia 340b2e6644SGerard Garcia struct af_vsockmon_hdr { 350b2e6644SGerard Garcia __le64 src_cid; 360b2e6644SGerard Garcia __le64 dst_cid; 370b2e6644SGerard Garcia __le32 src_port; 380b2e6644SGerard Garcia __le32 dst_port; 390b2e6644SGerard Garcia __le16 op; /* enum af_vsockmon_op */ 400b2e6644SGerard Garcia __le16 transport; /* enum af_vsockmon_transport */ 410b2e6644SGerard Garcia __le16 len; /* Transport header length */ 420b2e6644SGerard Garcia __u8 reserved[2]; 430b2e6644SGerard Garcia }; 440b2e6644SGerard Garcia 450b2e6644SGerard Garcia enum af_vsockmon_op { 460b2e6644SGerard Garcia AF_VSOCK_OP_UNKNOWN = 0, 470b2e6644SGerard Garcia AF_VSOCK_OP_CONNECT = 1, 480b2e6644SGerard Garcia AF_VSOCK_OP_DISCONNECT = 2, 490b2e6644SGerard Garcia AF_VSOCK_OP_CONTROL = 3, 500b2e6644SGerard Garcia AF_VSOCK_OP_PAYLOAD = 4, 510b2e6644SGerard Garcia }; 520b2e6644SGerard Garcia 530b2e6644SGerard Garcia enum af_vsockmon_transport { 540b2e6644SGerard Garcia AF_VSOCK_TRANSPORT_UNKNOWN = 0, 550b2e6644SGerard Garcia AF_VSOCK_TRANSPORT_NO_INFO = 1, /* No transport information */ 560b2e6644SGerard Garcia 570b2e6644SGerard Garcia /* Transport header type: struct virtio_vsock_hdr */ 580b2e6644SGerard Garcia AF_VSOCK_TRANSPORT_VIRTIO = 2, 590b2e6644SGerard Garcia }; 600b2e6644SGerard Garcia 610b2e6644SGerard Garcia #endif 62