# SPDX-License-Identifier: BSD-3-Clause
#
# Copyright 2020 Raritan Inc. All rights reserved.
#
# This file was generated by IdlC from Security.idl.

use strict;

package Raritan::RPC::security::IpFw_2_0_0;

use Raritan::RPC::security::IpfwRule;
use Raritan::RPC::security::IpfwRule;

sub encode {
    my ($in) = @_;
    my $encoded = {};
    $encoded->{'enabled'} = ($in->{'enabled'}) ? JSON::true : JSON::false;
    $encoded->{'defaultPolicyIn'} = $in->{'defaultPolicyIn'};
    $encoded->{'defaultPolicyOut'} = $in->{'defaultPolicyOut'};
    $encoded->{'ruleSetIn'} = [];
    for (my $i0 = 0; $i0 <= $#{$in->{'ruleSetIn'}}; $i0++) {
        $encoded->{'ruleSetIn'}->[$i0] = Raritan::RPC::security::IpfwRule::encode($in->{'ruleSetIn'}->[$i0]);
    }
    $encoded->{'ruleSetOut'} = [];
    for (my $i0 = 0; $i0 <= $#{$in->{'ruleSetOut'}}; $i0++) {
        $encoded->{'ruleSetOut'}->[$i0] = Raritan::RPC::security::IpfwRule::encode($in->{'ruleSetOut'}->[$i0]);
    }
    return $encoded;
}

sub decode {
    my ($agent, $in) = @_;
    my $decoded = {};
    $decoded->{'enabled'} = ($in->{'enabled'}) ? 1 : 0;
    $decoded->{'defaultPolicyIn'} = $in->{'defaultPolicyIn'};
    $decoded->{'defaultPolicyOut'} = $in->{'defaultPolicyOut'};
    $decoded->{'ruleSetIn'} = [];
    for (my $i0 = 0; $i0 <= $#{$in->{'ruleSetIn'}}; $i0++) {
        $decoded->{'ruleSetIn'}->[$i0] = Raritan::RPC::security::IpfwRule::decode($agent, $in->{'ruleSetIn'}->[$i0]);
    }
    $decoded->{'ruleSetOut'} = [];
    for (my $i0 = 0; $i0 <= $#{$in->{'ruleSetOut'}}; $i0++) {
        $decoded->{'ruleSetOut'}->[$i0] = Raritan::RPC::security::IpfwRule::decode($agent, $in->{'ruleSetOut'}->[$i0]);
    }
    return $decoded;
}

1;
