00001 /* 00002 * This is a module which is used for queueing IPv4 packets and 00003 * communicating with userspace via netlink. 00004 * 00005 * (C) 2000 James Morris, this code is GPL. 00006 */ 00007 #ifndef _IP_QUEUE_H 00008 #define _IP_QUEUE_H 00009 00010 00011 00012 00013 #include <linux/module.h> 00014 #include <linux/skbuff.h> 00015 #include <linux/init.h> 00016 #include <linux/ip.h> 00017 #include <linux/notifier.h> 00018 #include <linux/netdevice.h> 00019 #include <linux/netfilter.h> 00020 #include <linux/spinlock.h> 00021 #include <linux/rtnetlink.h> 00022 #include <linux/sysctl.h> 00023 #include <linux/proc_fs.h> 00024 #include <net/route.h> 00025 #include <net/sock.h> 00026 #include <linux/netfilter_ipv4/ip_tables.h> 00027 00028 00029 00030 00031 00032 00033 #ifdef __KERNEL__ 00034 #ifdef DEBUG_IPQ 00035 #define QDEBUG(x...) printk(KERN_DEBUG ## x) 00036 #else 00037 #define QDEBUG(x...) 00038 #endif /* DEBUG_IPQ */ 00039 #else 00040 #include <net/if.h> 00041 #endif /* ! __KERNEL__ */ 00042 00043 /* Messages sent from kernel */ 00044 typedef struct ipq_packet_msg { 00045 unsigned long packet_id; /* ID of queued packet */ 00046 unsigned long mark; /* Netfilter mark value */ 00047 long timestamp_sec; /* Packet arrival time (seconds) */ 00048 long timestamp_usec; /* Packet arrvial time (+useconds) */ 00049 unsigned int hook; /* Netfilter hook we rode in on */ 00050 char indev_name[IFNAMSIZ]; /* Name of incoming interface */ 00051 char outdev_name[IFNAMSIZ]; /* Name of outgoing interface */ 00052 unsigned short hw_protocol; /* Hardware protocol (network order) */ 00053 unsigned short hw_type; /* Hardware type */ 00054 unsigned char hw_addrlen; /* Hardware address length */ 00055 unsigned char hw_addr[8]; /* Hardware address */ 00056 size_t data_len; /* Length of packet data */ 00057 unsigned char payload[0]; /* Optional packet data */ 00058 } ipq_packet_msg_t; 00059 00060 /* Messages sent from userspace */ 00061 typedef struct ipq_mode_msg { 00062 unsigned char value; /* Requested mode */ 00063 size_t range; /* Optional range of packet requested */ 00064 } ipq_mode_msg_t; 00065 00066 typedef struct ipq_verdict_msg { 00067 unsigned int value; /* Verdict to hand to netfilter */ 00068 unsigned long id; /* Packet ID for this verdict */ 00069 size_t data_len; /* Length of replacement data */ 00070 unsigned char payload[0]; /* Optional replacement packet */ 00071 } ipq_verdict_msg_t; 00072 00073 00074 #define IPQ_COPY_MAX IPQ_COPY_PACKET 00075 00076 void ipq_send_ip(u_int32_t ip); 00077 void ipq_drop_ip(u_int32_t ip); 00078 int ipq_insert_packet(struct sk_buff *skb,struct nf_info *info); 00079 int init_packet_queue(void); 00080 void cleanup_packet_queue(void); 00081 #endif /*_IP_QUEUE_H*/ 00082