| [2] | 1 | /* |
|---|
| 2 | * Frame Diversion, Benoit Locher <Benoit.Locher@skf.com> |
|---|
| 3 | * |
|---|
| 4 | * Changes: |
|---|
| 5 | * 06/09/2000 BL: initial version |
|---|
| 6 | * |
|---|
| 7 | */ |
|---|
| 8 | |
|---|
| 9 | #ifndef _LINUX_DIVERT_H |
|---|
| 10 | #define _LINUX_DIVERT_H |
|---|
| 11 | |
|---|
| 12 | #include <asm/types.h> |
|---|
| 13 | |
|---|
| 14 | #define MAX_DIVERT_PORTS 8 /* Max number of ports to divert (tcp, udp) */ |
|---|
| 15 | |
|---|
| 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 |
|---|
| 22 | |
|---|
| 23 | /* |
|---|
| 24 | * This is an Ethernet Frame Diverter option block |
|---|
| 25 | */ |
|---|
| 26 | struct divert_blk |
|---|
| 27 | { |
|---|
| 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 */ |
|---|
| 34 | }; |
|---|
| 35 | |
|---|
| 36 | /* |
|---|
| 37 | * Diversion control block, for configuration with the userspace tool |
|---|
| 38 | * divert |
|---|
| 39 | */ |
|---|
| 40 | |
|---|
| 41 | typedef union _divert_cf_arg |
|---|
| 42 | { |
|---|
| 43 | __s16 int16; |
|---|
| 44 | __u16 uint16; |
|---|
| 45 | __s32 int32; |
|---|
| 46 | __u32 uint32; |
|---|
| 47 | __s64 int64; |
|---|
| 48 | __u64 uint64; |
|---|
| 49 | void *ptr; |
|---|
| 50 | } divert_cf_arg; |
|---|
| 51 | |
|---|
| 52 | |
|---|
| 53 | struct divert_cf |
|---|
| 54 | { |
|---|
| 55 | int cmd; /* Command */ |
|---|
| 56 | divert_cf_arg arg1, |
|---|
| 57 | arg2, |
|---|
| 58 | arg3; |
|---|
| 59 | int dev_index; /* device index (eth0=0, etc...) */ |
|---|
| 60 | }; |
|---|
| 61 | |
|---|
| 62 | |
|---|
| 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]) */ |
|---|
| 76 | |
|---|
| 77 | /* General syntax of the commands: |
|---|
| 78 | * |
|---|
| 79 | * DIVCMD_xxxxxx(arg1, arg2, arg3, dev_index) |
|---|
| 80 | * |
|---|
| 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) |
|---|
| 92 | * |
|---|
| 93 | * SIOGIFDIVERT: |
|---|
| 94 | * DIVCMD_GETSTATUS(divert_blk, , , ifindex) |
|---|
| 95 | * DIVCMD_GETVERSION(string[3]) |
|---|
| 96 | */ |
|---|
| 97 | |
|---|
| 98 | |
|---|
| 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 */ |
|---|
| 104 | |
|---|
| 105 | |
|---|
| 106 | #endif /* _LINUX_DIVERT_H */ |
|---|