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

use strict;

package Raritan::RPC::net::PortForwardingInfo;

use Raritan::RPC::net::PortForwardingMasterAddrInfo;
use Raritan::RPC::net::PortForwardingMasterAddrInfo;

sub encode {
    my ($in) = @_;
    my $encoded = {};
    $encoded->{'enabled'} = ($in->{'enabled'}) ? JSON::true : JSON::false;
    $encoded->{'nodeIndexValid'} = ($in->{'nodeIndexValid'}) ? JSON::true : JSON::false;
    $encoded->{'nodeIndex'} = 1 * $in->{'nodeIndex'};
    $encoded->{'slaveConnected'} = ($in->{'slaveConnected'}) ? JSON::true : JSON::false;
    $encoded->{'masterDownstreamIfName'} = "$in->{'masterDownstreamIfName'}";
    $encoded->{'masterIPv4AddrInfos'} = [];
    for (my $i0 = 0; $i0 <= $#{$in->{'masterIPv4AddrInfos'}}; $i0++) {
        $encoded->{'masterIPv4AddrInfos'}->[$i0] = Raritan::RPC::net::PortForwardingMasterAddrInfo::encode($in->{'masterIPv4AddrInfos'}->[$i0]);
    }
    $encoded->{'masterIPv6AddrInfos'} = [];
    for (my $i0 = 0; $i0 <= $#{$in->{'masterIPv6AddrInfos'}}; $i0++) {
        $encoded->{'masterIPv6AddrInfos'}->[$i0] = Raritan::RPC::net::PortForwardingMasterAddrInfo::encode($in->{'masterIPv6AddrInfos'}->[$i0]);
    }
    return $encoded;
}

sub decode {
    my ($agent, $in) = @_;
    my $decoded = {};
    $decoded->{'enabled'} = ($in->{'enabled'}) ? 1 : 0;
    $decoded->{'nodeIndexValid'} = ($in->{'nodeIndexValid'}) ? 1 : 0;
    $decoded->{'nodeIndex'} = $in->{'nodeIndex'};
    $decoded->{'slaveConnected'} = ($in->{'slaveConnected'}) ? 1 : 0;
    $decoded->{'masterDownstreamIfName'} = $in->{'masterDownstreamIfName'};
    $decoded->{'masterIPv4AddrInfos'} = [];
    for (my $i0 = 0; $i0 <= $#{$in->{'masterIPv4AddrInfos'}}; $i0++) {
        $decoded->{'masterIPv4AddrInfos'}->[$i0] = Raritan::RPC::net::PortForwardingMasterAddrInfo::decode($agent, $in->{'masterIPv4AddrInfos'}->[$i0]);
    }
    $decoded->{'masterIPv6AddrInfos'} = [];
    for (my $i0 = 0; $i0 <= $#{$in->{'masterIPv6AddrInfos'}}; $i0++) {
        $decoded->{'masterIPv6AddrInfos'}->[$i0] = Raritan::RPC::net::PortForwardingMasterAddrInfo::decode($agent, $in->{'masterIPv6AddrInfos'}->[$i0]);
    }
    return $decoded;
}

1;
