linux/include/linux/netfilter_ipv4/ip_tables.h
<<
>>
Prefs
   1/* SPDX-License-Identifier: GPL-2.0 */
   2/*
   3 * 25-Jul-1998 Major changes to allow for ip chain table
   4 *
   5 * 3-Jan-2000 Named tables to allow packet selection for different uses.
   6 */
   7
   8/*
   9 *      Format of an IP firewall descriptor
  10 *
  11 *      src, dst, src_mask, dst_mask are always stored in network byte order.
  12 *      flags are stored in host byte order (of course).
  13 *      Port numbers are stored in HOST byte order.
  14 */
  15#ifndef _IPTABLES_H
  16#define _IPTABLES_H
  17
  18#include <linux/if.h>
  19#include <linux/in.h>
  20#include <linux/init.h>
  21#include <linux/ip.h>
  22#include <linux/skbuff.h>
  23#include <uapi/linux/netfilter_ipv4/ip_tables.h>
  24
  25int ipt_register_table(struct net *net, const struct xt_table *table,
  26                       const struct ipt_replace *repl,
  27                       const struct nf_hook_ops *ops, struct xt_table **res);
  28void ipt_unregister_table(struct net *net, struct xt_table *table,
  29                          const struct nf_hook_ops *ops);
  30
  31/* Standard entry. */
  32struct ipt_standard {
  33        struct ipt_entry entry;
  34        struct xt_standard_target target;
  35};
  36
  37struct ipt_error {
  38        struct ipt_entry entry;
  39        struct xt_error_target target;
  40};
  41
  42#define IPT_ENTRY_INIT(__size)                                                 \
  43{                                                                              \
  44        .target_offset  = sizeof(struct ipt_entry),                            \
  45        .next_offset    = (__size),                                            \
  46}
  47
  48#define IPT_STANDARD_INIT(__verdict)                                           \
  49{                                                                              \
  50        .entry          = IPT_ENTRY_INIT(sizeof(struct ipt_standard)),         \
  51        .target         = XT_TARGET_INIT(XT_STANDARD_TARGET,                   \
  52                                         sizeof(struct xt_standard_target)),   \
  53        .target.verdict = -(__verdict) - 1,                                    \
  54}
  55
  56#define IPT_ERROR_INIT                                                         \
  57{                                                                              \
  58        .entry          = IPT_ENTRY_INIT(sizeof(struct ipt_error)),            \
  59        .target         = XT_TARGET_INIT(XT_ERROR_TARGET,                      \
  60                                         sizeof(struct xt_error_target)),      \
  61        .target.errorname = "ERROR",                                           \
  62}
  63
  64extern void *ipt_alloc_initial_table(const struct xt_table *);
  65extern unsigned int ipt_do_table(struct sk_buff *skb,
  66                                 const struct nf_hook_state *state,
  67                                 struct xt_table *table);
  68
  69#ifdef CONFIG_COMPAT
  70#include <net/compat.h>
  71
  72struct compat_ipt_entry {
  73        struct ipt_ip ip;
  74        compat_uint_t nfcache;
  75        __u16 target_offset;
  76        __u16 next_offset;
  77        compat_uint_t comefrom;
  78        struct compat_xt_counters counters;
  79        unsigned char elems[];
  80};
  81
  82/* Helper functions */
  83static inline struct xt_entry_target *
  84compat_ipt_get_target(struct compat_ipt_entry *e)
  85{
  86        return (void *)e + e->target_offset;
  87}
  88
  89#endif /* CONFIG_COMPAT */
  90#endif /* _IPTABLES_H */
  91