xt_sctp.h revision e37d45ce390c2f5a7f1e64742b9100ecef0def54
1cf2cfa174ca878c144e17e9fc60ca8e9070d7dededisonn@google.com#ifndef _XT_SCTP_H_ 2cf2cfa174ca878c144e17e9fc60ca8e9070d7dededisonn@google.com#define _XT_SCTP_H_ 3cf2cfa174ca878c144e17e9fc60ca8e9070d7dededisonn@google.com 4cf2cfa174ca878c144e17e9fc60ca8e9070d7dededisonn@google.com#include <linux/types.h> 5cf2cfa174ca878c144e17e9fc60ca8e9070d7dededisonn@google.com 6cf2cfa174ca878c144e17e9fc60ca8e9070d7dededisonn@google.com#define XT_SCTP_SRC_PORTS 0x01 7cf2cfa174ca878c144e17e9fc60ca8e9070d7dededisonn@google.com#define XT_SCTP_DEST_PORTS 0x02 8cf2cfa174ca878c144e17e9fc60ca8e9070d7dededisonn@google.com#define XT_SCTP_CHUNK_TYPES 0x04 9cf2cfa174ca878c144e17e9fc60ca8e9070d7dededisonn@google.com 108cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com#define XT_SCTP_VALID_FLAGS 0x07 118cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com 128cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.comstruct xt_sctp_flag_info { 138cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com __u8 chunktype; 148cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com __u8 flag; 158cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com __u8 flag_mask; 168cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com}; 178cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com 188cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com#define XT_NUM_SCTP_FLAGS 4 198cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com 208cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.comstruct xt_sctp_info { 218cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com __u16 dpts[2]; /* Min, Max */ 228cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com __u16 spts[2]; /* Min, Max */ 238cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com 248cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com __u32 chunkmap[256 / sizeof (__u32)]; /* Bit mask of chunks to be matched according to RFC 2960 */ 258cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com 268cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com#define SCTP_CHUNK_MATCH_ANY 0x01 /* Match if any of the chunk types are present */ 278cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com#define SCTP_CHUNK_MATCH_ALL 0x02 /* Match if all of the chunk types are present */ 288cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com#define SCTP_CHUNK_MATCH_ONLY 0x04 /* Match if these are the only chunk types present */ 298cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com 308cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com __u32 chunk_match_type; 318cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com struct xt_sctp_flag_info flag_info[XT_NUM_SCTP_FLAGS]; 328cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com int flag_count; 338cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com 348cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com __u32 flags; 358cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com __u32 invflags; 368cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com}; 378cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com 388cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com#define bytes(type) (sizeof(type) * 8) 398cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com 408cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com#define SCTP_CHUNKMAP_SET(chunkmap, type) \ 418cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com do { \ 428cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com (chunkmap)[type / bytes(__u32)] |= \ 438cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com 1 << (type % bytes(__u32)); \ 448cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com } while (0) 458cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com 468cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com#define SCTP_CHUNKMAP_CLEAR(chunkmap, type) \ 478cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com do { \ 488cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com (chunkmap)[type / bytes(__u32)] &= \ 498cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com ~(1 << (type % bytes(__u32))); \ 508cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com } while (0) 518cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com 528cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com#define SCTP_CHUNKMAP_IS_SET(chunkmap, type) \ 538cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com({ \ 548cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com ((chunkmap)[type / bytes (__u32)] & \ 558cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com (1 << (type % bytes (__u32)))) ? 1: 0; \ 568cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com}) 578cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com 588cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com#define SCTP_CHUNKMAP_RESET(chunkmap) \ 598cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com memset((chunkmap), 0, sizeof(chunkmap)) 608cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com 618cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com#define SCTP_CHUNKMAP_SET_ALL(chunkmap) \ 628cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com memset((chunkmap), ~0U, sizeof(chunkmap)) 638cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com 648cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com#define SCTP_CHUNKMAP_COPY(destmap, srcmap) \ 658cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com memcpy((destmap), (srcmap), sizeof(srcmap)) 668cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com 678cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com#define SCTP_CHUNKMAP_IS_CLEAR(chunkmap) \ 688cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com __sctp_chunkmap_is_clear((chunkmap), ARRAY_SIZE(chunkmap)) 698cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.comstatic inline bool 708cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com__sctp_chunkmap_is_clear(const __u32 *chunkmap, unsigned int n) 718cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com{ 728cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com unsigned int i; 738cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com for (i = 0; i < n; ++i) 748cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com if (chunkmap[i]) 758cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com return false; 768cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com return true; 778cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com} 788cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com 798cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com#define SCTP_CHUNKMAP_IS_ALL_SET(chunkmap) \ 808cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com __sctp_chunkmap_is_all_set((chunkmap), ARRAY_SIZE(chunkmap)) 818cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.comstatic inline bool 828cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com__sctp_chunkmap_is_all_set(const __u32 *chunkmap, unsigned int n) 838cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com{ 848cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com unsigned int i; 858cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com for (i = 0; i < n; ++i) 868cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com if (chunkmap[i] != ~0U) 878cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com return false; 888cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com return true; 898cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com} 908cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com 918cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com#endif /* _XT_SCTP_H_ */ 928cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com 938cee797901763ab0922eb9ef484cfdcbc94bee54edisonn@google.com