fixup! WIP on emergency: 7a108d1 Makefile: New target for tracking diversions.
[firewall] / base.m4
CommitLineData
bfdc045d 1m4_divert(-1)
1644c76a 2### -*-m4-*-
bfdc045d
MW
3###
4### Failsafe prologue for firewall scripts
5###
6### (c) 2008 Mark Wooding
7###
8
9###----- Licensing notice ---------------------------------------------------
10###
11### This program is free software; you can redistribute it and/or modify
12### it under the terms of the GNU General Public License as published by
13### the Free Software Foundation; either version 2 of the License, or
14### (at your option) any later version.
15###
16### This program is distributed in the hope that it will be useful,
17### but WITHOUT ANY WARRANTY; without even the implied warranty of
18### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19### GNU General Public License for more details.
20###
21### You should have received a copy of the GNU General Public License
22### along with this program; if not, write to the Free Software Foundation,
23### Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24
25m4_changequote(<:, :>)
26m4_changecom(<:##:>)
27
28###--------------------------------------------------------------------------
29### Overall structure.
30###
31### 0 File header: shebang, do-not-edit warning. [base]
32### 5 Configuration. [config]
33### 10 Prologue: command-line parsing and failsafe. [prologue]
34### 20 Function definitions. [functions]
35### 25 Port numbers etc. [numbers]
36### 30 Initialization. [bookends]
37### 30 Clear existing rules. [bookends]
38### 32 Set safe IP options. [bookends]
12ac65a1 39### 34 Error chains. [bookends]
bfdc045d 40### 36 Give loopback traffic a free pass. [bookends]
c70bfbbb 41### 38 Utility chains. [functions]
12ac65a1 42### 40 Address classification. [classify]
bfdc045d
MW
43### 42 Definition of address class policies. [local]
44### 44 Definition of interfaces and addresses. [local]
45### 46 Handling of default interface. [classify]
12ac65a1
MW
46### 50 ICMP filtering. [icmp]
47### 52 Local configuration. [local]
48### 58 Finally accept ICMP, hook onto INPUT and FORWARD. [icmp]
49### 60 Local configuration. [local]
bfdc045d
MW
50### 90 Finishing touches. [bookends]
51### 94 Set final policies. [bookends]
52### 99 File footer: do-not-edit warning. [base]
53
54###--------------------------------------------------------------------------
55### Headers and footers.
56
57m4_divert(0)m4_dnl
58#! /bin/sh
961148a5
MW
59<:###:> Firewall script for FWHOST
60###
61### *** GENERATED FILE: DO NOT EDIT ***
62
85f1a157
MW
63### BEGIN INIT INFO
64# Provides: firewall
b551adaf 65# Required-Start: mountkernfs
85f1a157
MW
66# Required-Stop:
67# X-Start-Before: ifupdown
68# X-Stop-After: ifupdown
69# Default-Start: S
70# Default-Stop: 0 6
71# Description: Provides customized packet filter rules.
72### END INIT INFO
bfdc045d
MW
73
74set -e
75PATH=/bin:/sbin:/usr/bin:/usr/sbin; export PATH
961148a5 76fwhost=FWHOST
bfdc045d
MW
77
78m4_divert(99)m4_dnl
79### *** GENERATED FILE: DO NOT EDIT ***
80m4_divert(-1)
81
82###--------------------------------------------------------------------------
83### Unpleasant m4 hacking.
84
85## dolist(VAR, LIST, BODY)
86##
87## LIST is a parenthesized list of comma-separated items. For each item,
88## set VAR to expand to the item and emit the BODY.
89m4_define(<:dolist:>, <:m4_pushdef(<:$1:>)__loop($@)m4_popdef(<:$1:>):>)
90m4_define(<:__loop:>, <:m4_ifelse(<:$2:>, <:():>, ,m4_dnl
91<:m4_define(<:$1:>, __first$2)$3<::>__loop(<:$1:>,(m4_shift$2),<:$3:>):>):>)
92m4_define(<:__first:>, <:$1:>)
93
94## split(DELIM, TEXT)
95##
96## Split TEXT at characters in DELIM; stash result in positional parameters.
97m4_define(<:split:>, <:IFS=$1; set -- $2; IFS=$STDIFS:>)
98
99## defconf(CONF, DEFAULT)
100##
101## Define config variable CONF, assigning it the DEFAULT value if not
102## overridden by setconf.
103m4_define(<:defconf:>, <:: ${$1=m4_ifdef(<:conf_$1:>, conf_$1, $2)}:>)
104
105## setconf(CONF, VALUE)
106##
107## Set config variable VALUE.
41f87bbc 108m4_define(<:setconf:>, <:m4_define(<:conf_$1:>, <:$2:>):>)
bfdc045d
MW
109
110###----- That's all, folks --------------------------------------------------