[PATCH] w1: Adds a sysfs entry (w1_master_search) that allows you to disable/enable...
[linux-2.6/verdex.git] / include / linux / divert.h
blob6919b09133d47d704435cbf5b86412dd78264cd3
1 /*
2 * Frame Diversion, Benoit Locher <Benoit.Locher@skf.com>
4 * Changes:
5 * 06/09/2000 BL: initial version
6 *
7 */
9 #ifndef _LINUX_DIVERT_H
10 #define _LINUX_DIVERT_H
12 #include <asm/types.h>
14 #define MAX_DIVERT_PORTS 8 /* Max number of ports to divert (tcp, udp) */
16 /* Divertable protocols */
17 #define DIVERT_PROTO_NONE 0x0000
18 #define DIVERT_PROTO_IP 0x0001
19 #define DIVERT_PROTO_ICMP 0x0002
20 #define DIVERT_PROTO_TCP 0x0004
21 #define DIVERT_PROTO_UDP 0x0008
24 * This is an Ethernet Frame Diverter option block
26 struct divert_blk
28 int divert; /* are we active */
29 unsigned int protos; /* protocols */
30 u16 tcp_dst[MAX_DIVERT_PORTS]; /* specific tcp dst ports to divert */
31 u16 tcp_src[MAX_DIVERT_PORTS]; /* specific tcp src ports to divert */
32 u16 udp_dst[MAX_DIVERT_PORTS]; /* specific udp dst ports to divert */
33 u16 udp_src[MAX_DIVERT_PORTS]; /* specific udp src ports to divert */
37 * Diversion control block, for configuration with the userspace tool
38 * divert
41 typedef union _divert_cf_arg
43 s16 int16;
44 u16 uint16;
45 s32 int32;
46 u32 uint32;
47 s64 int64;
48 u64 uint64;
49 void __user *ptr;
50 } divert_cf_arg;
53 struct divert_cf
55 int cmd; /* Command */
56 divert_cf_arg arg1,
57 arg2,
58 arg3;
59 int dev_index; /* device index (eth0=0, etc...) */
63 /* Diversion commands */
64 #define DIVCMD_DIVERT 1 /* ENABLE/DISABLE diversion */
65 #define DIVCMD_IP 2 /* ENABLE/DISABLE whold IP diversion */
66 #define DIVCMD_TCP 3 /* ENABLE/DISABLE whold TCP diversion */
67 #define DIVCMD_TCPDST 4 /* ADD/REMOVE TCP DST port for diversion */
68 #define DIVCMD_TCPSRC 5 /* ADD/REMOVE TCP SRC port for diversion */
69 #define DIVCMD_UDP 6 /* ENABLE/DISABLE whole UDP diversion */
70 #define DIVCMD_UDPDST 7 /* ADD/REMOVE UDP DST port for diversion */
71 #define DIVCMD_UDPSRC 8 /* ADD/REMOVE UDP SRC port for diversion */
72 #define DIVCMD_ICMP 9 /* ENABLE/DISABLE whole ICMP diversion */
73 #define DIVCMD_GETSTATUS 10 /* GET the status of the diverter */
74 #define DIVCMD_RESET 11 /* Reset the diverter on the specified dev */
75 #define DIVCMD_GETVERSION 12 /* Retrieve the diverter code version (char[32]) */
77 /* General syntax of the commands:
79 * DIVCMD_xxxxxx(arg1, arg2, arg3, dev_index)
81 * SIOCSIFDIVERT:
82 * DIVCMD_DIVERT(DIVARG1_ENABLE|DIVARG1_DISABLE, , ,ifindex)
83 * DIVCMD_IP(DIVARG1_ENABLE|DIVARG1_DISABLE, , , ifindex)
84 * DIVCMD_TCP(DIVARG1_ENABLE|DIVARG1_DISABLE, , , ifindex)
85 * DIVCMD_TCPDST(DIVARG1_ADD|DIVARG1_REMOVE, port, , ifindex)
86 * DIVCMD_TCPSRC(DIVARG1_ADD|DIVARG1_REMOVE, port, , ifindex)
87 * DIVCMD_UDP(DIVARG1_ENABLE|DIVARG1_DISABLE, , , ifindex)
88 * DIVCMD_UDPDST(DIVARG1_ADD|DIVARG1_REMOVE, port, , ifindex)
89 * DIVCMD_UDPSRC(DIVARG1_ADD|DIVARG1_REMOVE, port, , ifindex)
90 * DIVCMD_ICMP(DIVARG1_ENABLE|DIVARG1_DISABLE, , , ifindex)
91 * DIVCMD_RESET(, , , ifindex)
93 * SIOGIFDIVERT:
94 * DIVCMD_GETSTATUS(divert_blk, , , ifindex)
95 * DIVCMD_GETVERSION(string[3])
99 /* Possible values for arg1 */
100 #define DIVARG1_ENABLE 0 /* ENABLE something */
101 #define DIVARG1_DISABLE 1 /* DISABLE something */
102 #define DIVARG1_ADD 2 /* ADD something */
103 #define DIVARG1_REMOVE 3 /* REMOVE something */
106 #ifdef __KERNEL__
108 /* diverter functions */
109 #include <linux/skbuff.h>
111 #ifdef CONFIG_NET_DIVERT
112 #include <linux/netdevice.h>
114 int alloc_divert_blk(struct net_device *);
115 void free_divert_blk(struct net_device *);
116 int divert_ioctl(unsigned int cmd, struct divert_cf __user *arg);
117 void divert_frame(struct sk_buff *skb);
118 static inline void handle_diverter(struct sk_buff *skb)
120 /* if diversion is supported on device, then divert */
121 if (skb->dev->divert && skb->dev->divert->divert)
122 divert_frame(skb);
125 #else
126 # define alloc_divert_blk(dev) (0)
127 # define free_divert_blk(dev) do {} while (0)
128 # define divert_ioctl(cmd, arg) (-ENOPKG)
129 # define handle_diverter(skb) do {} while (0)
130 #endif
131 #endif
132 #endif /* _LINUX_DIVERT_H */