summaryrefslogtreecommitdiff
path: root/src/xsl/show_firewall_detail.xsl
blob: ea388e05e4cda3bd9289c2d140b4d59c87ecde44 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
<?xml version="1.0"?>
<!DOCTYPE stylesheet [
<!ENTITY newln "&#10;">
]>

<!-- /*
      *  Copyright 2006, Vyatta, Inc.
      *
      *  GNU General Public License
      *
      *  This program is free software; you can redistribute it and/or modify
      *  it under the terms of the GNU General Public License, version 2,
      *  as published by the Free Software Foundation.
      *
      *  This program is distributed in the hope that it will be useful,
      *  but WITHOUT ANY WARRANTY; without even the implied warranty of
      *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      *  GNU General Public License for more details.
      *
      *  You should have received a copy of the GNU General Public License
      *  along with this program; if not, write to the Free Software
      *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
      *  02110-1301 USA
      *
      * Module: show_firewall_detail.xsl 
      *
      * Author: Mike Horn
      * Date: 2006
      *
      */ -->

<!--XSL Template for formatting the "show firewall <name> detail" command-->

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output omit-xml-declaration="yes" />

<xsl:variable name="pad10" select="'           '"/>
<xsl:variable name="pad10_len" select="string-length($pad10)"/>
<xsl:variable name="pad20" select="'                    '"/>
<xsl:variable name="pad20_len" select="string-length($pad20)"/>
<xsl:variable name="pad22" select="'                      '"/>
<xsl:variable name="pad22_len" select="string-length($pad22)"/>
<xsl:variable name="pad34" select="'                                 '"/>
<xsl:variable name="pad34_len" select="string-length($pad34)"/>

<xsl:template match="opcommand">

<xsl:text>&newln;</xsl:text>
<xsl:text>&newln;</xsl:text>

<xsl:for-each select="format/row">

<xsl:text>Rule: </xsl:text>
<xsl:value-of select="rule_number"/>
<xsl:text>&newln;</xsl:text>

<xsl:text>Packets: </xsl:text>
<xsl:value-of select="pkts"/>
<xsl:value-of select="substring($pad10,1,$pad10_len - string-length(pkts))"/>

<xsl:text>Bytes: </xsl:text>
<xsl:value-of select="bytes"/>
<xsl:text>&newln;</xsl:text>

<xsl:text>Action: </xsl:text>
<xsl:value-of select="action"/>
<xsl:text>&newln;</xsl:text>

<xsl:text>Protocol: </xsl:text>
<xsl:value-of select="protocol"/>
<xsl:text>&newln;</xsl:text>

<xsl:text>State: </xsl:text>
  <xsl:choose>
    <xsl:when test="contains(state, 'established%2C')">
      <xsl:text>E,</xsl:text>
    </xsl:when>
    <xsl:when test="contains(state, 'established')">
      <xsl:text>E</xsl:text>
    </xsl:when>
  </xsl:choose>
  <xsl:choose>
    <xsl:when test="contains(state, 'new%2C')">
      <xsl:text>N,</xsl:text>
    </xsl:when>
    <xsl:when test="contains(state, 'new')">
      <xsl:text>N</xsl:text>
    </xsl:when>
  </xsl:choose>
  <xsl:choose>
    <xsl:when test="contains(state, 'related%2C')">
      <xsl:text>R,</xsl:text>
    </xsl:when>
    <xsl:when test="contains(state, 'related')">
      <xsl:text>R</xsl:text>
    </xsl:when>
  </xsl:choose>
  <xsl:choose>
    <xsl:when test="contains(state, 'invalid%2C')">
      <xsl:text>I,</xsl:text>
    </xsl:when>
    <xsl:when test="contains(state, 'invalid')">
      <xsl:text>I</xsl:text>
    </xsl:when>
  </xsl:choose>
  <xsl:choose>
    <xsl:when test="state=''">
      <xsl:text>any</xsl:text>
    </xsl:when>
  </xsl:choose>
<xsl:text>&newln;</xsl:text>

<xsl:text>Source</xsl:text>
<xsl:text>&newln;</xsl:text>
<xsl:text>  Address: </xsl:text>
  <xsl:choose>
    <xsl:when test="src_addr!='' and src_addr!='0.0.0.0'">
      <xsl:value-of select="src_addr"/>
    </xsl:when>

    <xsl:when test="src_net!='' and src_net!='0.0.0.0/0'">
      <xsl:value-of select="src_net"/>
    </xsl:when>

    <xsl:when test="src_addr_start!='' and src_addr_start!='0.0.0.0'">
      <xsl:value-of select="src_addr_start"/>
      <xsl:text> - </xsl:text>
      <xsl:value-of select="src_addr_stop"/>
    </xsl:when>

    <xsl:otherwise>
      <xsl:text>0.0.0.0/0</xsl:text>
    </xsl:otherwise>
  </xsl:choose>
<xsl:text>&newln;</xsl:text>
<xsl:text>  Ports: </xsl:text>

  <xsl:choose>
    <xsl:when test="src_port!=''">
      <xsl:value-of select="src_port"/>
    </xsl:when>

    <xsl:otherwise>
      <xsl:text>all</xsl:text>
    </xsl:otherwise>
  </xsl:choose>

<xsl:text>&newln;</xsl:text>
<xsl:text>Destination</xsl:text>
<xsl:text>&newln;</xsl:text>
<xsl:text>  Address: </xsl:text>
  <xsl:choose>
    <xsl:when test="dst_addr!='' and dst_addr!='0.0.0.0'">
      <xsl:value-of select="dst_addr"/>
    </xsl:when>

    <xsl:when test="dst_net!='' and dst_net!='0.0.0.0/0'">
      <xsl:value-of select="dst_net"/>
    </xsl:when>

    <xsl:when test="dst_addr_start!='' and dst_addr_start!='0.0.0.0'">
      <xsl:value-of select="dst_addr_start"/>
      <xsl:text> - </xsl:text>
      <xsl:value-of select="dst_addr_stop"/>
    </xsl:when>

    <xsl:otherwise>
      <xsl:text>0.0.0.0/0</xsl:text>
    </xsl:otherwise>
  </xsl:choose>
<xsl:text>&newln;</xsl:text>
<xsl:text>  Ports: </xsl:text>

  <xsl:choose>
    <xsl:when test="dst_port!=''">
      <xsl:value-of select="dst_port"/>
    </xsl:when>

    <xsl:otherwise>
      <xsl:text>all</xsl:text>
    </xsl:otherwise>
  </xsl:choose>

<xsl:text>&newln;</xsl:text>

<xsl:text>ICMP Code: </xsl:text>
  <xsl:if test="icmp_code=''">
    <xsl:text>-</xsl:text>
  </xsl:if> 
  <xsl:if test="icmp_code!=''">
    <xsl:value-of select="icmp_code"/>
  </xsl:if> 

<xsl:text>&newln;</xsl:text>

<xsl:text>ICMP Type: </xsl:text>
  <xsl:if test="icmp_type=''">
    <xsl:text>-</xsl:text>
  </xsl:if> 
  <xsl:if test="icmp_type!=''">
    <xsl:value-of select="icmp_type"/>
  </xsl:if> 

<xsl:text>&newln;</xsl:text>
<xsl:text>Logging: </xsl:text>
<xsl:value-of select="log"/>

<xsl:text>&newln;</xsl:text>
  <xsl:if test="rule_number!='10000'">
    <xsl:text>------------------------</xsl:text>
    <xsl:text>&newln;</xsl:text>
  </xsl:if>

</xsl:for-each>
</xsl:template>

</xsl:stylesheet>