/usr/share/zentyal/stubs/dhcp/staticRoutes.mas is in zentyal-dhcp 2.3.8+quantal1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | <%args>
@routes
$defaultGw => undef
</%args>
<%init>
use EBox::NetWrappers;
</%init>
<& .msStaticRoutes, routes => \@routes &>
<& .rfc3442StaticRoutes, routes => \@routes, defaultGw => $defaultGw &>
<%def .msStaticRoutes>
<%args>
@routes
</%args>
option ms-classless-static-routes
% while (my $r = pop @routes) {
% my $last = @routes == 0;
<& .route, destination => $r->{network}, gateway => $r->{gateway}, netmask => $r->{netmask}, last => $last &>
% }
</%def>
<%def .rfc3442StaticRoutes>
<%args>
$defaultGw
@routes
</%args>
option rfc3442-classless-static-routes
% foreach my $r (@routes) {
<& .route, destination => $r->{network}, gateway => $r->{gateway}, netmask => $r->{netmask} &>
% }
<& .route, destination => 'default', gateway => $defaultGw, last => 1&>
</%def>
<%def .route>
<%args>
$destination
$gateway
$netmask => undef
$last => 0
</%args>
<%init>
my $route = '';
if ($destination eq 'default') {
# netmask and destination portion
$route .= '0,';
}
else {
# netmask portion
$route .= EBox::NetWrappers::bits_from_mask( $netmask );
$route .= ',';
# destination portion
$destination =~ s/(\.0)+$//;
$destination =~ tr/\./,/;
$destination .= ',' unless $destination =~ m/,$/;
$route .= $destination ;
}
# gateway portion
$gateway =~ tr/\./,/;
$route .= $gateway;
# add comma or semicolomn depending wether this is the last route or not
if ($last) {
$route .= ';';
}
else {
$route .= ',';
}
</%init>
<% $route %>
</%def>
|