mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-12 13:55:32 +00:00
![Harald Welte](/assets/img/avatar_default.png)
This monster-patch tries to do the best job for unifying the data structures and backend interfaces for the three evil clones ip_tables, ip6_tables and arp_tables. In an ideal world we would never have allowed this kind of copy+paste programming... but well, our world isn't (yet?) ideal. o introduce a new x_tables module o {ip,arp,ip6}_tables depend on this x_tables module o registration functions for tables, matches and targets are only wrappers around x_tables provided functions o all matches/targets that are used from ip_tables and ip6_tables are now implemented as xt_FOOBAR.c files and provide module aliases to ipt_FOOBAR and ip6t_FOOBAR o header files for xt_matches are in include/linux/netfilter/, include/linux/netfilter_{ipv4,ipv6} contains compatibility wrappers around the xt_FOOBAR.h headers Based on this patchset we're going to further unify the code, gradually getting rid of all the layer 3 specific assumptions. Signed-off-by: Harald Welte <laforge@netfilter.org> Signed-off-by: David S. Miller <davem@davemloft.net>
107 lines
2.4 KiB
C
107 lines
2.4 KiB
C
#ifndef _XT_SCTP_H_
|
|
#define _XT_SCTP_H_
|
|
|
|
#define XT_SCTP_SRC_PORTS 0x01
|
|
#define XT_SCTP_DEST_PORTS 0x02
|
|
#define XT_SCTP_CHUNK_TYPES 0x04
|
|
|
|
#define XT_SCTP_VALID_FLAGS 0x07
|
|
|
|
#define ELEMCOUNT(x) (sizeof(x)/sizeof(x[0]))
|
|
|
|
|
|
struct xt_sctp_flag_info {
|
|
u_int8_t chunktype;
|
|
u_int8_t flag;
|
|
u_int8_t flag_mask;
|
|
};
|
|
|
|
#define XT_NUM_SCTP_FLAGS 4
|
|
|
|
struct xt_sctp_info {
|
|
u_int16_t dpts[2]; /* Min, Max */
|
|
u_int16_t spts[2]; /* Min, Max */
|
|
|
|
u_int32_t chunkmap[256 / sizeof (u_int32_t)]; /* Bit mask of chunks to be matched according to RFC 2960 */
|
|
|
|
#define SCTP_CHUNK_MATCH_ANY 0x01 /* Match if any of the chunk types are present */
|
|
#define SCTP_CHUNK_MATCH_ALL 0x02 /* Match if all of the chunk types are present */
|
|
#define SCTP_CHUNK_MATCH_ONLY 0x04 /* Match if these are the only chunk types present */
|
|
|
|
u_int32_t chunk_match_type;
|
|
struct xt_sctp_flag_info flag_info[XT_NUM_SCTP_FLAGS];
|
|
int flag_count;
|
|
|
|
u_int32_t flags;
|
|
u_int32_t invflags;
|
|
};
|
|
|
|
#define bytes(type) (sizeof(type) * 8)
|
|
|
|
#define SCTP_CHUNKMAP_SET(chunkmap, type) \
|
|
do { \
|
|
chunkmap[type / bytes(u_int32_t)] |= \
|
|
1 << (type % bytes(u_int32_t)); \
|
|
} while (0)
|
|
|
|
#define SCTP_CHUNKMAP_CLEAR(chunkmap, type) \
|
|
do { \
|
|
chunkmap[type / bytes(u_int32_t)] &= \
|
|
~(1 << (type % bytes(u_int32_t))); \
|
|
} while (0)
|
|
|
|
#define SCTP_CHUNKMAP_IS_SET(chunkmap, type) \
|
|
({ \
|
|
(chunkmap[type / bytes (u_int32_t)] & \
|
|
(1 << (type % bytes (u_int32_t)))) ? 1: 0; \
|
|
})
|
|
|
|
#define SCTP_CHUNKMAP_RESET(chunkmap) \
|
|
do { \
|
|
int i; \
|
|
for (i = 0; i < ELEMCOUNT(chunkmap); i++) \
|
|
chunkmap[i] = 0; \
|
|
} while (0)
|
|
|
|
#define SCTP_CHUNKMAP_SET_ALL(chunkmap) \
|
|
do { \
|
|
int i; \
|
|
for (i = 0; i < ELEMCOUNT(chunkmap); i++) \
|
|
chunkmap[i] = ~0; \
|
|
} while (0)
|
|
|
|
#define SCTP_CHUNKMAP_COPY(destmap, srcmap) \
|
|
do { \
|
|
int i; \
|
|
for (i = 0; i < ELEMCOUNT(chunkmap); i++) \
|
|
destmap[i] = srcmap[i]; \
|
|
} while (0)
|
|
|
|
#define SCTP_CHUNKMAP_IS_CLEAR(chunkmap) \
|
|
({ \
|
|
int i; \
|
|
int flag = 1; \
|
|
for (i = 0; i < ELEMCOUNT(chunkmap); i++) { \
|
|
if (chunkmap[i]) { \
|
|
flag = 0; \
|
|
break; \
|
|
} \
|
|
} \
|
|
flag; \
|
|
})
|
|
|
|
#define SCTP_CHUNKMAP_IS_ALL_SET(chunkmap) \
|
|
({ \
|
|
int i; \
|
|
int flag = 1; \
|
|
for (i = 0; i < ELEMCOUNT(chunkmap); i++) { \
|
|
if (chunkmap[i] != ~0) { \
|
|
flag = 0; \
|
|
break; \
|
|
} \
|
|
} \
|
|
flag; \
|
|
})
|
|
|
|
#endif /* _XT_SCTP_H_ */
|
|
|