1 /* 2 * This is a module which is used for queueing IPv4 packets and 3 * communicating with userspace via netlink. 4 * 5 * (C) 2000 James Morris, this code is GPL. 6 */ 7 #ifndef _IP_QUEUE_H 8 #define _IP_QUEUE_H 9 10 #include <net/if.h> 11 12 /* Messages sent from kernel */ 13 typedef struct ipq_packet_msg { 14 unsigned long packet_id; /* ID of queued packet */ 15 unsigned long mark; /* Netfilter mark value */ 16 long timestamp_sec; /* Packet arrival time (seconds) */ 17 long timestamp_usec; /* Packet arrvial time (+useconds) */ 18 unsigned int hook; /* Netfilter hook we rode in on */ 19 char indev_name[IFNAMSIZ]; /* Name of incoming interface */ 20 char outdev_name[IFNAMSIZ]; /* Name of outgoing interface */ 21 __be16 hw_protocol; /* Hardware protocol (network order) */ 22 unsigned short hw_type; /* Hardware type */ 23 unsigned char hw_addrlen; /* Hardware address length */ 24 unsigned char hw_addr[8]; /* Hardware address */ 25 size_t data_len; /* Length of packet data */ 26 unsigned char payload[0]; /* Optional packet data */ 27 } ipq_packet_msg_t; 28 29 /* Messages sent from userspace */ 30 typedef struct ipq_mode_msg { 31 unsigned char value; /* Requested mode */ 32 size_t range; /* Optional range of packet requested */ 33 } ipq_mode_msg_t; 34 35 typedef struct ipq_verdict_msg { 36 unsigned int value; /* Verdict to hand to netfilter */ 37 unsigned long id; /* Packet ID for this verdict */ 38 size_t data_len; /* Length of replacement data */ 39 unsigned char payload[0]; /* Optional replacement packet */ 40 } ipq_verdict_msg_t; 41 42 typedef struct ipq_peer_msg { 43 union { 44 ipq_verdict_msg_t verdict; 45 ipq_mode_msg_t mode; 46 } msg; 47 } ipq_peer_msg_t; 48 49 /* Packet delivery modes */ 50 enum { 51 IPQ_COPY_NONE, /* Initial mode, packets are dropped */ 52 IPQ_COPY_META, /* Copy metadata */ 53 IPQ_COPY_PACKET /* Copy metadata + packet (range) */ 54 }; 55 #define IPQ_COPY_MAX IPQ_COPY_PACKET 56 57 /* Types of messages */ 58 #define IPQM_BASE 0x10 /* standard netlink messages below this */ 59 #define IPQM_MODE (IPQM_BASE + 1) /* Mode request from peer */ 60 #define IPQM_VERDICT (IPQM_BASE + 2) /* Verdict from peer */ 61 #define IPQM_PACKET (IPQM_BASE + 3) /* Packet from kernel */ 62 #define IPQM_MAX (IPQM_BASE + 4) 63 64 #endif /*_IP_QUEUE_H*/ 65