]>
git.ipfire.org Git - ipfire-2.x.git/blob - config/firewall/rules.pl
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2013 Alexander Marx <amarx@ipfire.org> #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
24 no warnings
'uninitialized' ;
26 # enable only the following on debugging purpose
28 #use CGI::Carp 'fatalsToBrowser';
31 my %defaultNetworks =();
41 my %configoutgoingfw =();
46 require '/var/ipfire/general-functions.pl' ;
47 require "${General::swroot}/lang.pl" ;
48 require "/usr/lib/firewall/firewall-lib.pl" ;
50 my $configfwdfw = "${General::swroot}/firewall/config" ;
51 my $configinput = "${General::swroot}/firewall/input" ;
52 my $configoutgoing = "${General::swroot}/firewall/outgoing" ;
53 my $p2pfile = "${General::swroot}/firewall/p2protocols" ;
54 my $configgrp = "${General::swroot}/fwhosts/customgroups" ;
55 my $netsettings = "${General::swroot}/ethernet/settings" ;
56 my $errormessage = '' ;
60 my ( $TYPE , $PROT , $SPROT , $DPROT , $SPORT , $DPORT , $TIME , $TIMEFROM , $TIMETILL , $SRC_TGT );
61 my $CHAIN = "FORWARDFW" ;
62 my $conexists = 'off' ;
63 my $command = 'iptables --wait -A' ;
67 & General
:: readhash
( "${General::swroot}/firewall/settings" , \
%fwdfwsettings );
68 & General
:: readhash
( " $netsettings " , \
%defaultNetworks );
69 & General
:: readhasharray
( $configfwdfw , \
%configfwdfw );
70 & General
:: readhasharray
( $configinput , \
%configinputfw );
71 & General
:: readhasharray
( $configoutgoing , \
%configoutgoingfw );
72 & General
:: readhasharray
( $configgrp , \
%customgrp );
73 & General
:: get_aliases
( \
%aliases );
75 #check if we have an internetconnection
76 open ( CONN
, "/var/ipfire/red/iface" );
79 if (- f
"/var/ipfire/red/active" ){
82 open ( CONN1
, "/var/ipfire/red/local-ipaddress" );
88 my $MODE = 0 ; # 0 - normal operation
89 # 1 - print configline and rules to console
94 if ( $param eq 'flush' ){
96 print " Flushing chains... \n " ;
101 print " Flushing chains... \n " ;
105 print " Preparing rules... \n " ;
109 if ( $fwdfwsettings { 'POLICY' } eq 'MODE1' ){
111 system ( "/usr/sbin/firewall-policy" );
112 } elsif ( $fwdfwsettings { 'POLICY' } eq 'MODE2' ){
114 system ( "/usr/sbin/firewall-policy" );
120 system ( "iptables --wait -F FORWARDFW" );
121 system ( "iptables --wait -F INPUTFW" );
122 system ( "iptables --wait -F OUTGOINGFW" );
123 system ( "iptables --wait -t nat -F NAT_DESTINATION" );
124 system ( "iptables --wait -t nat -F NAT_SOURCE" );
128 if (! - z
"${General::swroot}/firewall/config" ){
129 & buildrules
( \
%configfwdfw );
131 if (! - z
"${General::swroot}/firewall/input" ){
132 & buildrules
( \
%configinputfw );
134 if (! - z
"${General::swroot}/firewall/outgoing" ){
135 & buildrules
( \
%configoutgoingfw );
149 foreach my $key ( sort { $a <=> $b } keys % $hash ){
150 next if (($ $hash { $key }[ 6 ] eq 'RED' || $ $hash { $key }[ 6 ] eq 'RED1' ) && $conexists eq 'off' );
151 $command = "iptables --wait -A" ;
152 if ($ $hash { $key }[ 28 ] eq 'ON' ){
153 $command = 'iptables --wait -t nat -A' ;
154 $natip =& get_nat_ip
($ $hash { $key }[ 29 ],$ $hash { $key }[ 31 ]);
155 if ($ $hash { $key }[ 31 ] eq 'dnat' ){
157 if ($ $hash { $key }[ 30 ] =~ /\|/ ){
158 $ $hash { $key }[ 30 ]=~ tr/|/,/ ;
159 $fireport = '-m multiport --dport ' .$ $hash { $key }[ 30 ];
161 $fireport = '--dport ' .$ $hash { $key }[ 30 ] if ($ $hash { $key }[ 30 ]> 0 );
168 if ($ $hash { $key }[ 2 ] eq 'ON' ){
170 if ($ $hash { $key }[ 3 ] eq 'cust_grp_src' ){
171 foreach my $grp ( sort { $a <=> $b } keys %customgrp ){
172 if ( $customgrp { $grp }[ 0 ] eq $ $hash { $key }[ 4 ]){
173 & get_address
( $customgrp { $grp }[ 3 ], $customgrp { $grp }[ 2 ], "src" );
177 & get_address
($ $hash { $key }[ 3 ],$ $hash { $key }[ 4 ], "src" );
180 if ($ $hash { $key }[ 5 ] eq 'cust_grp_tgt' ){
181 foreach my $grp ( sort { $a <=> $b } keys %customgrp ){
182 if ( $customgrp { $grp }[ 0 ] eq $ $hash { $key }[ 6 ]){
183 & get_address
( $customgrp { $grp }[ 3 ], $customgrp { $grp }[ 2 ], "tgt" );
186 } elsif ($ $hash { $key }[ 5 ] eq 'ipfire' ){
187 if ($ $hash { $key }[ 6 ] eq 'GREEN' ){
188 $targethash { $key }[ 0 ]= $defaultNetworks { 'GREEN_ADDRESS' };
190 if ($ $hash { $key }[ 6 ] eq 'BLUE' ){
191 $targethash { $key }[ 0 ]= $defaultNetworks { 'BLUE_ADDRESS' };
193 if ($ $hash { $key }[ 6 ] eq 'ORANGE' ){
194 $targethash { $key }[ 0 ]= $defaultNetworks { 'ORANGE_ADDRESS' };
196 if ($ $hash { $key }[ 6 ] eq 'ALL' ){
197 $targethash { $key }[ 0 ]= '0.0.0.0/0' ;
199 if ($ $hash { $key }[ 6 ] eq 'RED' || $ $hash { $key }[ 6 ] eq 'RED1' ){
200 open ( FILE
, "/var/ipfire/red/local-ipaddress" ) or die "Couldn't open local-ipaddress" ;
201 $targethash { $key }[ 0 ]= < FILE
>;
204 foreach my $alias ( sort keys %aliases ){
205 if ($ $hash { $key }[ 6 ] eq $alias ){
206 $targethash { $key }[ 0 ]= $aliases { $alias }{ 'IPT' };
211 & get_address
($ $hash { $key }[ 5 ],$ $hash { $key }[ 6 ], "tgt" );
213 ##get source prot and port
215 $SPORT = & get_port
( $hash , $key );
218 ##get target prot and port
219 $DPROT =& get_prot
( $hash , $key );
221 if ( $DPROT eq '' ){ $DPROT = ' ' ;}
222 @DPROT = split ( "," , $DPROT );
225 if ($ $hash { $key }[ 18 ] eq 'ON' ){
226 my ( $time1 , $time2 , $daylight );
227 my $daylight =$ $hash { $key }[ 28 ];
228 $time1 =& get_time
($ $hash { $key }[ 26 ], $daylight );
229 $time2 =& get_time
($ $hash { $key }[ 27 ], $daylight );
230 if ($ $hash { $key }[ 19 ] ne '' ){ push ( @timeframe , "Mon" );}
231 if ($ $hash { $key }[ 20 ] ne '' ){ push ( @timeframe , "Tue" );}
232 if ($ $hash { $key }[ 21 ] ne '' ){ push ( @timeframe , "Wed" );}
233 if ($ $hash { $key }[ 22 ] ne '' ){ push ( @timeframe , "Thu" );}
234 if ($ $hash { $key }[ 23 ] ne '' ){ push ( @timeframe , "Fri" );}
235 if ($ $hash { $key }[ 24 ] ne '' ){ push ( @timeframe , "Sat" );}
236 if ($ $hash { $key }[ 25 ] ne '' ){ push ( @timeframe , "Sun" );}
237 $TIME = join ( "," , @timeframe );
239 $TIMEFROM = "--timestart $time1 " ;
240 $TIMETILL = "--timestop $time2 " ;
241 $TIME = "-m time --weekdays $TIME $TIMEFROM $TIMETILL " ;
243 foreach my $DPROT ( @DPROT ){
244 $DPORT = & get_port
( $hash , $key , $DPROT );
246 $PROT = "-p $PROT " if ( $PROT ne '' && $PROT ne ' ' );
247 if ( $DPROT ne 'TCP' && $DPROT ne 'UDP' && $DPROT ne 'ICMP' ){
250 foreach my $a ( sort keys %sourcehash ){
251 foreach my $b ( sort keys %targethash ){
252 if (! $sourcehash { $a }[ 0 ] || ! $targethash { $b }[ 0 ] || ( $natip eq '-d ' && $ $hash { $key }[ 28 ] eq 'ON' ) || (! $natip && $ $hash { $key }[ 28 ] eq 'ON' )){
253 #Skip rules when no RED IP is set (DHCP,DSL)
256 next if ( $targethash { $b }[ 0 ] eq 'none' );
258 if ( $sourcehash { $a }[ 0 ] ne $targethash { $b }[ 0 ] && $targethash { $b }[ 0 ] ne 'none' || $sourcehash { $a }[ 0 ] eq '0.0.0.0/0.0.0.0' ){
260 if ( substr ( $sourcehash { $a }[ 0 ], 3 , 3 ) ne 'mac' && $sourcehash { $a }[ 0 ] ne '' ){ $STAG = "-s" ;}
262 if ( substr ( $DPORT , 2 , 4 ) eq 'icmp' ){
263 my @icmprule = split ( "," , substr ( $DPORT , 12 ,));
265 $icmptype = "--icmp-type " ;
270 if ($ $hash { $key }[ 17 ] eq 'ON' ){
271 system ( " $command $ $hash { $key }[1] $PROT $STAG $sourcehash { $a }[0] $SPORT -d $targethash { $b }[0] $icmptype $_ $TIME -j LOG" );
273 system ( " $command $ $hash { $key }[1] $PROT $STAG $sourcehash { $a }[0] $SPORT -d $targethash { $b }[0] $icmptype $_ $TIME -j $ $hash { $key }[0]" );
275 #PROCESS DNAT RULE (Portforward)
276 } elsif ($ $hash { $key }[ 28 ] eq 'ON' && $ $hash { $key }[ 31 ] eq 'dnat' ){
277 $natchain = 'NAT_DESTINATION' ;
278 if ($ $hash { $key }[ 17 ] eq 'ON' ){
279 system " $command $natchain $PROT $STAG $sourcehash { $a }[0] $SPORT $natip $fireport $TIME -j LOG --log-prefix 'DNAT' \n " ;
281 my ( $ip , $sub ) = split ( "/" , $targethash { $b }[ 0 ]);
282 #Process NAT with servicegroup used
283 if ($ $hash { $key }[ 28 ] eq 'ON' && $ $hash { $key }[ 31 ] eq 'dnat' && $ $hash { $key }[ 14 ] eq 'cust_srvgrp' ){
284 system " $command $natchain $PROT $STAG $sourcehash { $a }[0] $SPORT $natip $fireport $TIME -j $nat --to-destination $ip $DPORT \n " ;
285 $fwaccessdport = $DPORT ;
287 system " $command $natchain $PROT $STAG $sourcehash { $a }[0] $SPORT $natip $fireport $TIME -j $nat --to-destination $ip $DPORT \n " ;
290 $fwaccessdport = "--dport " . substr ( $DPORT , 1 ,);
291 } elsif (! $DPORT && $ $hash { $key }[ 30 ] ne '' ){
292 if ($ $hash { $key }[ 30 ]=~ m/|/i ){
293 $ $hash { $key }[ 30 ] =~ s/\|/,/g ;
294 $fwaccessdport = "-m multiport --dport $ $hash { $key }[30]" ;
296 $fwaccessdport = "--dport $ $hash { $key }[30]" ;
300 system "iptables --wait -A FORWARDFW $PROT $STAG $sourcehash { $a }[0] -d $ip $fwaccessdport $TIME -j $ $hash { $key }[0] \n " ;
303 } elsif ($ $hash { $key }[ 28 ] eq 'ON' && $ $hash { $key }[ 31 ] eq 'snat' ){
304 $natchain = 'NAT_SOURCE' ;
305 if ($ $hash { $key }[ 17 ] eq 'ON' ){
306 system " $command $natchain $PROT $STAG $sourcehash { $a }[0] $SPORT -d $targethash { $b }[0] $DPORT $TIME -j LOG --log-prefix 'SNAT' \n " ;
308 system " $command $natchain $PROT $STAG $sourcehash { $a }[0] $SPORT -d $targethash { $b }[0] $DPORT $TIME -j $nat --to-source $natip \n " ;
310 #PROCESS EVERY OTHER RULE (If NOT ICMP, else the rule would be applied double)
311 if ( $PROT ne '-p ICMP' ){
312 if ($ $hash { $key }[ 17 ] eq 'ON' && $ $hash { $key }[ 28 ] ne 'ON' ){
313 system " $command $ $hash { $key }[1] $PROT $STAG $sourcehash { $a }[0] $SPORT -d $targethash { $b }[0] $DPORT $TIME -j LOG \n " ;
315 system "iptables --wait -A $ $hash { $key }[1] $PROT $STAG $sourcehash { $a }[0] $SPORT -d $targethash { $b }[0] $DPORT $TIME -j $ $hash { $key }[0] \n " ;
317 #PROCESS Prot ICMP and type = All ICMP-Types
318 if ( $PROT eq '-p ICMP' && $ $hash { $key }[ 9 ] eq 'All ICMP-Types' ){
319 if ($ $hash { $key }[ 17 ] eq 'ON' && $ $hash { $key }[ 28 ] ne 'ON' ){
320 system " $command $ $hash { $key }[1] $PROT $STAG $sourcehash { $a }[0] $SPORT -d $targethash { $b }[0] $DPORT $TIME -j LOG \n " ;
322 system "iptables --wait -A $ $hash { $key }[1] $PROT $STAG $sourcehash { $a }[0] $SPORT -d $targethash { $b }[0] $DPORT $TIME -j $ $hash { $key }[0] \n " ;
343 if ( $val eq 'RED' || $val eq 'GREEN' || $val eq 'ORANGE' || $val eq 'BLUE' ){
344 $result = $defaultNetworks { $val . '_ADDRESS' };
345 } elsif ( $val eq 'ALL' ){
347 } elsif ( $val eq 'Default IP' && $type eq 'dnat' ){
348 $result = '-d ' . $redip ;
349 } elsif ( $val eq 'Default IP' && $type eq 'snat' ){
352 foreach my $al ( sort keys %aliases ){
353 if ( $val eq $al && $type eq 'dnat' ){
354 $result = '-d ' . $aliases { $al }{ 'IPT' };
355 } elsif ( $val eq $al && $type eq 'snat' ){
356 $result = $aliases { $al }{ 'IPT' };
369 $minutes = & utcmin
( $val );
370 $ruletime = $minutes + & time_get_utc
( $val );
371 if ( $ruletime < 0 ){ $ruletime += 1440 ;}
372 if ( $ruletime > 1440 ){ $ruletime -= 1440 ;}
373 $time = sprintf " %02d : %02d " , $ruletime / 60 , $ruletime % 60 ;
378 # Calculates the UTCtime from a given time
380 my @localtime = localtime ( time );
381 my @gmtime = gmtime ( time );
382 my $diff = ( $gmtime [ 2 ]* 60 + $gmtime [ 1 ] %60 )-( $localtime [ 2 ]* 60 + $localtime [ 1 ] %60 );
388 my ( $hrs , $min ) = split ( ":" , $ruletime );
389 my $newtime = $hrs * 60 + $min ;
396 open ( FILE
, "< $p2pfile " ) or die "Unable to read $p2pfile " ;
399 my $CMD = "-m ipp2p" ;
400 foreach my $p2pentry ( sort @p2ps ) {
401 my @p2pline = split ( /\;/ , $p2pentry );
402 if ( $fwdfwsettings { 'POLICY' } eq 'MODE1' ) {
404 if ( " $p2pline [2]" eq "on" ) {
405 $P2PSTRING = " $P2PSTRING -- $p2pline [1]" ;
409 if ( " $p2pline [2]" eq "off" ) {
410 $P2PSTRING = " $P2PSTRING -- $p2pline [1]" ;
416 print "/sbin/iptables --wait -A FORWARDFW $CMD $P2PSTRING -j $DO \n " ;
420 system ( "/sbin/iptables --wait -A FORWARDFW $CMD $P2PSTRING -j $DO " );
426 my $base = shift ; #source of checking ($configfwdfw{$key}[x] or groupkey
428 my $type = shift ; #src or tgt
435 my $key = & General
:: findhasharraykey
( $hash );
436 if ( $base eq 'src_addr' || $base eq 'tgt_addr' ){
437 if (& General
:: validmac
( $base2 )){
438 $ $hash { $key }[ 0 ] = "-m mac --mac-source $base2 " ;
440 $ $hash { $key }[ 0 ] = $base2 ;
442 } elsif ( $base eq 'std_net_src' || $base eq 'std_net_tgt' || $base eq 'Standard Network' ){
443 $ $hash { $key }[ 0 ]=& fwlib
:: get_std_net_ip
( $base2 , $con );
444 } elsif ( $base eq 'cust_net_src' || $base eq 'cust_net_tgt' || $base eq 'Custom Network' ){
445 $ $hash { $key }[ 0 ]=& fwlib
:: get_net_ip
( $base2 );
446 } elsif ( $base eq 'cust_host_src' || $base eq 'cust_host_tgt' || $base eq 'Custom Host' ){
447 $ $hash { $key }[ 0 ]=& fwlib
:: get_host_ip
( $base2 , $type );
448 } elsif ( $base eq 'ovpn_net_src' || $base eq 'ovpn_net_tgt' || $base eq 'OpenVPN static network' ){
449 $ $hash { $key }[ 0 ]=& fwlib
:: get_ovpn_net_ip
( $base2 , 1 );
450 } elsif ( $base eq 'ovpn_host_src' || $base eq 'ovpn_host_tgt' || $base eq 'OpenVPN static host' ){
451 $ $hash { $key }[ 0 ]=& fwlib
:: get_ovpn_host_ip
( $base2 , 33 );
452 } elsif ( $base eq 'ovpn_n2n_src' || $base eq 'ovpn_n2n_tgt' || $base eq 'OpenVPN N-2-N' ){
453 $ $hash { $key }[ 0 ]=& fwlib
:: get_ovpn_n2n_ip
( $base2 , 11 );
454 } elsif ( $base eq 'ipsec_net_src' || $base eq 'ipsec_net_tgt' || $base eq 'IpSec Network' ){
455 $ $hash { $key }[ 0 ]=& fwlib
:: get_ipsec_net_ip
( $base2 , 11 );
456 } elsif ( $base eq 'ipfire_src' ){
457 if ( $base2 eq 'GREEN' ){
458 $ $hash { $key }[ 0 ]= $defaultNetworks { 'GREEN_ADDRESS' };
460 if ( $base2 eq 'BLUE' ){
461 $ $hash { $key }[ 0 ]= $defaultNetworks { 'BLUE_ADDRESS' };
463 if ( $base2 eq 'ORANGE' ){
464 $ $hash { $key }[ 0 ]= $defaultNetworks { 'ORANGE_ADDRESS' };
467 $ $hash { $key }[ 0 ]= '0.0.0.0/0' ;
469 if ( $base2 eq 'RED' || $base2 eq 'RED1' ){
470 open ( FILE
, "/var/ipfire/red/local-ipaddress" );
471 $ $hash { $key }[ 0 ]= < FILE
>;
474 foreach my $alias ( sort keys %aliases ){
475 if ( $base2 eq $alias ){
476 $ $hash { $key }[ 0 ]= $aliases { $alias }{ 'IPT' };
486 #check AH,GRE,ESP or ICMP
487 if ($ $hash { $key }[ 7 ] ne 'ON' && $ $hash { $key }[ 11 ] ne 'ON' ){
488 return "$ $hash { $key }[8]" ;
490 if ($ $hash { $key }[ 7 ] eq 'ON' || $ $hash { $key }[ 11 ] eq 'ON' ){
491 #check if servicegroup or service
492 if ($ $hash { $key }[ 14 ] eq 'cust_srv' ){
493 return & fwlib
:: get_srv_prot
($ $hash { $key }[ 15 ]);
494 } elsif ($ $hash { $key }[ 14 ] eq 'cust_srvgrp' ){
495 return & fwlib
:: get_srvgrp_prot
($ $hash { $key }[ 15 ]);
496 } elsif (($ $hash { $key }[ 10 ] ne '' || $ $hash { $key }[ 15 ] ne '' ) && $ $hash { $key }[ 8 ] eq '' ){ #when ports are used and prot set to "all"
498 } elsif (($ $hash { $key }[ 10 ] ne '' || $ $hash { $key }[ 15 ] ne '' ) && ($ $hash { $key }[ 8 ] eq 'TCP' || $ $hash { $key }[ 8 ] eq 'UDP' )){ #when ports are used and prot set to "tcp" or "udp"
499 return "$ $hash { $key }[8]" ;
500 } elsif (($ $hash { $key }[ 10 ] eq '' && $ $hash { $key }[ 15 ] eq '' ) && $ $hash { $key }[ 8 ] ne 'ICMP' ){ #when ports are NOT used and prot NOT set to "ICMP"
501 return "$ $hash { $key }[8]" ;
503 return "$ $hash { $key }[8]" ;
507 if ( $SRC_TGT eq '' && $ $hash { $key }[ 31 ] eq 'dnat' && $ $hash { $key }[ 11 ] eq '' && $ $hash { $key }[ 12 ] ne '' ){
508 return "$ $hash { $key }[8]" ;
516 #Get manual defined Ports from SOURCE
517 if ($ $hash { $key }[ 7 ] eq 'ON' && $SRC_TGT eq 'SRC' ){
518 if ($ $hash { $key }[ 10 ] ne '' ){
519 $ $hash { $key }[ 10 ] =~ s/\|/,/g ;
520 if ( index ($ $hash { $key }[ 10 ], "," ) > 0 ){
521 return "-m multiport --sport $ $hash { $key }[10] " ;
523 if ($ $hash { $key }[ 28 ] ne 'ON' || ($ $hash { $key }[ 28 ] eq 'ON' && $ $hash { $key }[ 31 ] eq 'snat' ) ||($ $hash { $key }[ 28 ] eq 'ON' && $ $hash { $key }[ 31 ] eq 'dnat' ) ){
524 return "--sport $ $hash { $key }[10] " ;
526 return ":$ $hash { $key }[10]" ;
530 #Get manual ports from TARGET
531 } elsif ($ $hash { $key }[ 11 ] eq 'ON' && $SRC_TGT eq '' ){
532 if ($ $hash { $key }[ 14 ] eq 'TGT_PORT' ){
533 if ($ $hash { $key }[ 15 ] ne '' ){
534 $ $hash { $key }[ 15 ] =~ s/\|/,/g ;
535 if ( index ($ $hash { $key }[ 15 ], "," ) > 0 ){
536 return "-m multiport --dport $ $hash { $key }[15] " ;
538 if ($ $hash { $key }[ 28 ] ne 'ON' || ($ $hash { $key }[ 28 ] eq 'ON' && $ $hash { $key }[ 31 ] eq 'snat' ) ){
539 return "--dport $ $hash { $key }[15] " ;
541 $ $hash { $key }[ 15 ] =~ s/\:/-/g ;
542 return ":$ $hash { $key }[15]" ;
546 #Get ports defined in custom Service (firewall-groups)
547 } elsif ($ $hash { $key }[ 14 ] eq 'cust_srv' ){
548 if ( $prot ne 'ICMP' ){
549 if ($ $hash { $key }[ 31 ] eq 'dnat' && $ $hash { $key }[ 28 ] eq 'ON' ){
550 my $ports =& fwlib
:: get_srv_port
($ $hash { $key }[ 15 ], 1 , $prot );
554 return "--dport " .& fwlib
:: get_srv_port
($ $hash { $key }[ 15 ], 1 , $prot );
556 } elsif ( $prot eq 'ICMP' && $ $hash { $key }[ 11 ] eq 'ON' ){ #When PROT is ICMP and "use targetport is checked, this is an icmp-service
557 return "--icmp-type " .& fwlib
:: get_srv_port
($ $hash { $key }[ 15 ], 3 , $prot );
559 #Get ports from services which are used in custom servicegroups (firewall-groups)
560 } elsif ($ $hash { $key }[ 14 ] eq 'cust_srvgrp' ){
561 if ( $prot ne 'ICMP' ){
562 return & fwlib
:: get_srvgrp_port
($ $hash { $key }[ 15 ], $prot );
564 elsif ( $prot eq 'ICMP' ){
565 return & fwlib
:: get_srvgrp_port
($ $hash { $key }[ 15 ], $prot );
570 if ($ $hash { $key }[ 7 ] ne 'ON' && $ $hash { $key }[ 11 ] ne 'ON' && $SRC_TGT eq '' ){
571 if ($ $hash { $key }[ 9 ] ne '' && $ $hash { $key }[ 9 ] ne 'All ICMP-Types' ){
572 return "--icmp-type $ $hash { $key }[9] " ;
573 } elsif ($ $hash { $key }[ 9 ] eq 'All ICMP-Types' ){