root/include/linux/ip_fw.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


   1 /*
   2  *      IP firewalling code. This is taken from 4.4BSD. Please note the 
   3  *      copyright message below. As per the GPL it must be maintained
   4  *      and the licenses thus do not conflict. While this port is subject
   5  *      to the GPL I also place my modifications under the original 
   6  *      license in recognition of the original copyright. 
   7  *
   8  *      Ported from BSD to Linux,
   9  *              Alan Cox 22/Nov/1994.
  10  *      Merged and included the FreeBSD-Current changes at Ugen's request
  11  *      (but hey it's a lot cleaner now). Ugen would prefer in some ways
  12  *      we waited for his final product but since Linux 1.2.0 is about to
  13  *      appear it's not practical - Read: It works, it's not clean but please
  14  *      don't consider it to be his standard of finished work.
  15  *              Alan.
  16  *
  17  *      All the real work was done by .....
  18  */
  19 
  20 /*
  21  * Copyright (c) 1993 Daniel Boulet
  22  * Copyright (c) 1994 Ugen J.S.Antsilevich
  23  *
  24  * Redistribution and use in source forms, with and without modification,
  25  * are permitted provided that this entire comment appears intact.
  26  *
  27  * Redistribution in binary form may occur without any restrictions.
  28  * Obviously, it would be nice if you gave credit where credit is due
  29  * but requiring it would be too onerous.
  30  *
  31  * This software is provided ``AS IS'' without any warranties of any kind.
  32  */
  33 
  34 /*
  35  *      Format of an IP firewall descriptor
  36  *
  37  *      src, dst, src_mask, dst_mask are always stored in network byte order.
  38  *      flags and num_*_ports are stored in host byte order (of course).
  39  *      Port numbers are stored in HOST byte order.
  40  */
  41  
  42 #ifndef _IP_FW_H
  43 #define _IP_FW_H
  44 
  45 struct ip_fw 
  46 {
  47         struct ip_fw  *fw_next;                 /* Next firewall on chain */
  48         struct in_addr fw_src, fw_dst;          /* Source and destination IP addr */
  49         struct in_addr fw_smsk, fw_dmsk;        /* Mask for src and dest IP addr */
  50         struct in_addr fw_via;                  /* IP address of interface "via" */
  51         unsigned short fw_flg;                  /* Flags word */
  52         unsigned short fw_nsp, fw_ndp;          /* N'of src ports and # of dst ports */
  53                                                 /* in ports array (dst ports follow */
  54                                                 /* src ports; max of 10 ports in all; */
  55                                                 /* count of 0 means match all ports) */
  56 #define IP_FW_MAX_PORTS 10                      /* A reasonable maximum */
  57         unsigned short fw_pts[IP_FW_MAX_PORTS]; /* Array of port numbers to match */
  58         unsigned long  fw_pcnt,fw_bcnt;         /* Packet and byte counters */
  59 };
  60 
  61 /*
  62  *      Values for "flags" field .
  63  */
  64 
  65 #define IP_FW_F_ALL     0x000   /* This is a universal packet firewall*/
  66 #define IP_FW_F_TCP     0x001   /* This is a TCP packet firewall      */
  67 #define IP_FW_F_UDP     0x002   /* This is a UDP packet firewall      */
  68 #define IP_FW_F_ICMP    0x003   /* This is a ICMP packet firewall     */
  69 #define IP_FW_F_KIND    0x003   /* Mask to isolate firewall kind      */
  70 #define IP_FW_F_ACCEPT  0x004   /* This is an accept firewall (as     *
  71                                  *         opposed to a deny firewall)*
  72                                  *                                    */
  73 #define IP_FW_F_SRNG    0x008   /* The first two src ports are a min  *
  74                                  * and max range (stored in host byte *
  75                                  * order).                            *
  76                                  *                                    */
  77 #define IP_FW_F_DRNG    0x010   /* The first two dst ports are a min  *
  78                                  * and max range (stored in host byte *
  79                                  * order).                            *
  80                                  * (ports[0] <= port <= ports[1])     *
  81                                  *                                    */
  82 #define IP_FW_F_PRN     0x020   /* In verbose mode print this firewall*/
  83 #define IP_FW_F_BIDIR   0x040   /* For bidirectional firewalls        */
  84 #define IP_FW_F_TCPSYN  0x080   /* For tcp packets-check SYN only     */
  85 #define IP_FW_F_ICMPRPL 0x100   /* Send back icmp unreachable packet  */
  86 #define IP_FW_F_MASK    0x1FF   /* All possible flag bits mask        */
  87 
  88 /*    
  89  *      New IP firewall options for [gs]etsockopt at the RAW IP level.
  90  *      Unlike BSD Linux inherits IP options so you don't have to use
  91  *      a raw socket for this. Instead we check rights in the calls.
  92  */     
  93 
  94 #define IP_FW_BASE_CTL   64
  95 
  96 #define IP_FW_ADD_BLK    (IP_FW_BASE_CTL)
  97 #define IP_FW_ADD_FWD    (IP_FW_BASE_CTL+1)   
  98 #define IP_FW_CHK_BLK    (IP_FW_BASE_CTL+2)
  99 #define IP_FW_CHK_FWD    (IP_FW_BASE_CTL+3)
 100 #define IP_FW_DEL_BLK    (IP_FW_BASE_CTL+4)
 101 #define IP_FW_DEL_FWD    (IP_FW_BASE_CTL+5)
 102 #define IP_FW_FLUSH_BLK  (IP_FW_BASE_CTL+6)
 103 #define IP_FW_FLUSH_FWD  (IP_FW_BASE_CTL+7)
 104 #define IP_FW_ZERO_BLK   (IP_FW_BASE_CTL+8)
 105 #define IP_FW_ZERO_FWD   (IP_FW_BASE_CTL+9)
 106 #define IP_FW_POLICY_BLK (IP_FW_BASE_CTL+10)
 107 #define IP_FW_POLICY_FWD (IP_FW_BASE_CTL+11)
 108 
 109 #define IP_ACCT_ADD      (IP_FW_BASE_CTL+16)
 110 #define IP_ACCT_DEL      (IP_FW_BASE_CTL+17)
 111 #define IP_ACCT_FLUSH    (IP_FW_BASE_CTL+18)
 112 #define IP_ACCT_ZERO     (IP_FW_BASE_CTL+19)
 113 
 114 struct ip_fwpkt
 115 {
 116         struct iphdr fwp_iph;                   /* IP header */
 117         union {
 118                 struct tcphdr fwp_tcph;         /* TCP header or */
 119                 struct udphdr fwp_udph;         /* UDP header */
 120         } fwp_protoh;
 121         struct in_addr fwp_via;                 /* interface address */
 122 };
 123 
 124 /*
 125  *      Main firewall chains definitions and global var's definitions.
 126  */
 127 
 128 #ifdef __KERNEL__
 129 
 130 #include <linux/config.h>
 131 
 132 #ifdef CONFIG_IP_FIREWALL
 133 extern struct ip_fw *ip_fw_blk_chain;
 134 extern struct ip_fw *ip_fw_fwd_chain;
 135 extern int ip_fw_blk_policy;
 136 extern int ip_fw_fwd_policy;
 137 extern int ip_fw_ctl(int, void *, int);
 138 #endif
 139 #ifdef CONFIG_IP_ACCT
 140 extern struct ip_fw *ip_acct_chain;
 141 extern void ip_acct_cnt(struct iphdr *, struct device *, struct ip_fw *);
 142 extern int ip_acct_ctl(int, void *, int);
 143 #endif
 144 extern int ip_fw_chk(struct iphdr *, struct device *rif,struct ip_fw *, int, int);
 145 #endif /* KERNEL */
 146 
 147 #endif /* _IP_FW_H */

/* [previous][next][first][last][top][bottom][index][help] */