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