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

use strict;

package Raritan::RPC::net::EthInfo_1_0_1;

use Raritan::RPC::net::EthLinkMode;
use Raritan::RPC::net::EthLinkMode;

sub encode {
    my ($in) = @_;
    my $encoded = {};
    $encoded->{'eapStatus'} = 1 * $in->{'eapStatus'};
    $encoded->{'linkMode'} = Raritan::RPC::net::EthLinkMode::encode($in->{'linkMode'});
    $encoded->{'linkModeValid'} = ($in->{'linkModeValid'}) ? JSON::true : JSON::false;
    $encoded->{'autonegEnabled'} = ($in->{'autonegEnabled'}) ? JSON::true : JSON::false;
    $encoded->{'linkDetected'} = ($in->{'linkDetected'}) ? JSON::true : JSON::false;
    $encoded->{'supportedLinkModes'} = [];
    for (my $i0 = 0; $i0 <= $#{$in->{'supportedLinkModes'}}; $i0++) {
        $encoded->{'supportedLinkModes'}->[$i0] = Raritan::RPC::net::EthLinkMode::encode($in->{'supportedLinkModes'}->[$i0]);
    }
    return $encoded;
}

sub decode {
    my ($agent, $in) = @_;
    my $decoded = {};
    $decoded->{'eapStatus'} = $in->{'eapStatus'};
    $decoded->{'linkMode'} = Raritan::RPC::net::EthLinkMode::decode($agent, $in->{'linkMode'});
    $decoded->{'linkModeValid'} = ($in->{'linkModeValid'}) ? 1 : 0;
    $decoded->{'autonegEnabled'} = ($in->{'autonegEnabled'}) ? 1 : 0;
    $decoded->{'linkDetected'} = ($in->{'linkDetected'}) ? 1 : 0;
    $decoded->{'supportedLinkModes'} = [];
    for (my $i0 = 0; $i0 <= $#{$in->{'supportedLinkModes'}}; $i0++) {
        $decoded->{'supportedLinkModes'}->[$i0] = Raritan::RPC::net::EthLinkMode::decode($agent, $in->{'supportedLinkModes'}->[$i0]);
    }
    return $decoded;
}

1;
