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

use strict;

package Raritan::RPC::net::EthInfo;

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

sub encode {
    my ($in) = @_;
    my $encoded = {};
    $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->{'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;
