Replace BigEndian with standard endian functions

Replaces usages of `BigEndian::Store*` and `BigEndian::ToHost*`
with the standard `htobe*` and `be*toh` functions for handling byte
order conversions in the NIC VEEPROM accessor implementations and tests.

Tested:
https://fusion2.corp.google.com/invocations/8a6f245e-eeb7-4c78-b707-0ac6661d1a3a/targets
PiperOrigin-RevId: 819817329
Change-Id: I9bbb05cb41469991ef85cb6914304a5d4332713b
diff --git a/tlbmc/hal/nic_veeprom/accessor_base.h b/tlbmc/hal/nic_veeprom/accessor_base.h
index 71d0cb1..229fb3f 100644
--- a/tlbmc/hal/nic_veeprom/accessor_base.h
+++ b/tlbmc/hal/nic_veeprom/accessor_base.h
@@ -1,7 +1,7 @@
 #ifndef THIRD_PARTY_MILOTIC_EXTERNAL_CC_TLBMC_HAL_NIC_VEEPROM_ACCESSOR_BASE_H_
 #define THIRD_PARTY_MILOTIC_EXTERNAL_CC_TLBMC_HAL_NIC_VEEPROM_ACCESSOR_BASE_H_
 
-#include <arpa/inet.h>
+#include <endian.h>
 
 #include <cstddef>
 #include <cstdint>
@@ -85,6 +85,7 @@
     }
     uint16_t version;
     memcpy(&version, buf->data() + offsetof(T, version), sizeof(version));
+    version = be16toh(version);
     if (version != version_) {
       LOG(ERROR) << "VEEPROM V" << version_ << " version mismatch: " << version;
       return;
@@ -93,6 +94,7 @@
     uint32_t header_magic;
     memcpy(&header_magic, buf->data() + offsetof(T, sensor_header_magic),
            sizeof(header_magic));
+    header_magic = be32toh(header_magic);
     if (header_magic != kHeaderMagic) {
       LOG(ERROR) << "VEEPROM V" << version_
                  << " header magic mismatch: " << header_magic;
diff --git a/tlbmc/hal/nic_veeprom/accessor_v1.cc b/tlbmc/hal/nic_veeprom/accessor_v1.cc
index ef11888..dc53faa 100644
--- a/tlbmc/hal/nic_veeprom/accessor_v1.cc
+++ b/tlbmc/hal/nic_veeprom/accessor_v1.cc
@@ -1,5 +1,6 @@
 #include "tlbmc/hal/nic_veeprom/accessor_v1.h"
 
+#include <endian.h>
 #include <memory>
 #include <string>
 
@@ -35,10 +36,10 @@
         absl::ToUnixSeconds(last_refresh_timestamp_));
     switch (name) {
       case NicTelemetryName::NIC_TELEMETRY_NAME_DIORITE_CPU:
-        val->set_reading(data.diorite_cpu);
+        val->set_reading(be32toh(data.diorite_cpu));
         break;
       case NicTelemetryName::NIC_TELEMETRY_NAME_DIORITE_DDR:
-        val->set_reading(data.diorite_ddr);
+        val->set_reading(be32toh(data.diorite_ddr));
         break;
       default:
         return absl::NotFoundError(absl::StrFormat(
diff --git a/tlbmc/hal/nic_veeprom/accessor_v2.cc b/tlbmc/hal/nic_veeprom/accessor_v2.cc
index de13a9d..c111534 100644
--- a/tlbmc/hal/nic_veeprom/accessor_v2.cc
+++ b/tlbmc/hal/nic_veeprom/accessor_v2.cc
@@ -1,5 +1,6 @@
 #include "tlbmc/hal/nic_veeprom/accessor_v2.h"
 
+#include <endian.h>
 #include <memory>
 #include <string>
 
@@ -35,127 +36,127 @@
         absl::ToUnixSeconds(last_refresh_timestamp_));
     switch (name) {
       case NicTelemetryName::NIC_TELEMETRY_NAME_PORT0_SPEED_GBPS:
-        val->set_reading(data.port0_speed_gbps);
+        val->set_reading(be16toh(data.port0_speed_gbps));
         break;
       case NicTelemetryName::NIC_TELEMETRY_NAME_PORT1_SPEED_GBPS:
-        val->set_reading(data.port1_speed_gbps);
+        val->set_reading(be16toh(data.port1_speed_gbps));
         break;
       case NicTelemetryName::NIC_TELEMETRY_NAME_PORT2_SPEED_GBPS:
-        val->set_reading(data.port2_speed_gbps);
+        val->set_reading(be16toh(data.port2_speed_gbps));
         break;
       case NicTelemetryName::NIC_TELEMETRY_NAME_PORT3_SPEED_GBPS:
-        val->set_reading(data.port3_speed_gbps);
+        val->set_reading(be16toh(data.port3_speed_gbps));
         break;
       case NicTelemetryName::NIC_TELEMETRY_NAME_PORT0_FLAP_COUNT:
-        val->set_count(data.port0_flap_count);
+        val->set_count(be16toh(data.port0_flap_count));
         break;
       case NicTelemetryName::NIC_TELEMETRY_NAME_PORT1_FLAP_COUNT:
-        val->set_count(data.port1_flap_count);
+        val->set_count(be16toh(data.port1_flap_count));
         break;
       case NicTelemetryName::NIC_TELEMETRY_NAME_PORT2_FLAP_COUNT:
-        val->set_count(data.port2_flap_count);
+        val->set_count(be16toh(data.port2_flap_count));
         break;
       case NicTelemetryName::NIC_TELEMETRY_NAME_PORT3_FLAP_COUNT:
-        val->set_count(data.port3_flap_count);
+        val->set_count(be16toh(data.port3_flap_count));
         break;
       case NicTelemetryName::NIC_TELEMETRY_NAME_PORT0_FEC_CCW:
-        val->set_count(data.port0_fec_ccw);
+        val->set_count(be64toh(data.port0_fec_ccw));
         break;
       case NicTelemetryName::NIC_TELEMETRY_NAME_PORT0_FEC_UCW:
-        val->set_count(data.port0_fec_ucw);
+        val->set_count(be64toh(data.port0_fec_ucw));
         break;
       case NicTelemetryName::NIC_TELEMETRY_NAME_PORT1_FEC_CCW:
-        val->set_count(data.port1_fec_ccw);
+        val->set_count(be64toh(data.port1_fec_ccw));
         break;
       case NicTelemetryName::NIC_TELEMETRY_NAME_PORT1_FEC_UCW:
-        val->set_count(data.port1_fec_ucw);
+        val->set_count(be64toh(data.port1_fec_ucw));
         break;
       case NicTelemetryName::NIC_TELEMETRY_NAME_PORT2_FEC_CCW:
-        val->set_count(data.port2_fec_ccw);
+        val->set_count(be64toh(data.port2_fec_ccw));
         break;
       case NicTelemetryName::NIC_TELEMETRY_NAME_PORT2_FEC_UCW:
-        val->set_count(data.port2_fec_ucw);
+        val->set_count(be64toh(data.port2_fec_ucw));
         break;
       case NicTelemetryName::NIC_TELEMETRY_NAME_PORT3_FEC_CCW:
-        val->set_count(data.port3_fec_ccw);
+        val->set_count(be64toh(data.port3_fec_ccw));
         break;
       case NicTelemetryName::NIC_TELEMETRY_NAME_PORT3_FEC_UCW:
-        val->set_count(data.port3_fec_ucw);
+        val->set_count(be64toh(data.port3_fec_ucw));
         break;
       case NicTelemetryName::NIC_TELEMETRY_NAME_PORT0_MAC_STAT_TX_BYTES:
-        val->set_count(data.port0_mac_stat_tx_bytes);
+        val->set_count(be64toh(data.port0_mac_stat_tx_bytes));
         break;
       case NicTelemetryName::NIC_TELEMETRY_NAME_PORT0_MAC_STAT_TX_PACKETS:
-        val->set_count(data.port0_mac_stat_tx_packets);
+        val->set_count(be64toh(data.port0_mac_stat_tx_packets));
         break;
       case NicTelemetryName::NIC_TELEMETRY_NAME_PORT0_MAC_STAT_RX_BYTES:
-        val->set_count(data.port0_mac_stat_rx_bytes);
+        val->set_count(be64toh(data.port0_mac_stat_rx_bytes));
         break;
       case NicTelemetryName::NIC_TELEMETRY_NAME_PORT0_MAC_STAT_RX_PACKETS:
-        val->set_count(data.port0_mac_stat_rx_packets);
+        val->set_count(be64toh(data.port0_mac_stat_rx_packets));
         break;
       case NicTelemetryName::NIC_TELEMETRY_NAME_PORT0_MAC_STAT_RX_BAD_PACKETS:
-        val->set_count(data.port0_mac_stat_rx_bad_packets);
+        val->set_count(be64toh(data.port0_mac_stat_rx_bad_packets));
         break;
       case NicTelemetryName::NIC_TELEMETRY_NAME_PORT1_MAC_STAT_TX_BYTES:
-        val->set_count(data.port1_mac_stat_tx_bytes);
+        val->set_count(be64toh(data.port1_mac_stat_tx_bytes));
         break;
       case NicTelemetryName::NIC_TELEMETRY_NAME_PORT1_MAC_STAT_TX_PACKETS:
-        val->set_count(data.port1_mac_stat_tx_packets);
+        val->set_count(be64toh(data.port1_mac_stat_tx_packets));
         break;
       case NicTelemetryName::NIC_TELEMETRY_NAME_PORT1_MAC_STAT_RX_BYTES:
-        val->set_count(data.port1_mac_stat_rx_bytes);
+        val->set_count(be64toh(data.port1_mac_stat_rx_bytes));
         break;
       case NicTelemetryName::NIC_TELEMETRY_NAME_PORT1_MAC_STAT_RX_PACKETS:
-        val->set_count(data.port1_mac_stat_rx_packets);
+        val->set_count(be64toh(data.port1_mac_stat_rx_packets));
         break;
       case NicTelemetryName::NIC_TELEMETRY_NAME_PORT1_MAC_STAT_RX_BAD_PACKETS:
-        val->set_count(data.port1_mac_stat_rx_bad_packets);
+        val->set_count(be64toh(data.port1_mac_stat_rx_bad_packets));
         break;
       case NicTelemetryName::NIC_TELEMETRY_NAME_PORT2_MAC_STAT_TX_BYTES:
-        val->set_count(data.port2_mac_stat_tx_bytes);
+        val->set_count(be64toh(data.port2_mac_stat_tx_bytes));
         break;
       case NicTelemetryName::NIC_TELEMETRY_NAME_PORT2_MAC_STAT_TX_PACKETS:
-        val->set_count(data.port2_mac_stat_tx_packets);
+        val->set_count(be64toh(data.port2_mac_stat_tx_packets));
         break;
       case NicTelemetryName::NIC_TELEMETRY_NAME_PORT2_MAC_STAT_RX_BYTES:
-        val->set_count(data.port2_mac_stat_rx_bytes);
+        val->set_count(be64toh(data.port2_mac_stat_rx_bytes));
         break;
       case NicTelemetryName::NIC_TELEMETRY_NAME_PORT2_MAC_STAT_RX_PACKETS:
-        val->set_count(data.port2_mac_stat_rx_packets);
+        val->set_count(be64toh(data.port2_mac_stat_rx_packets));
         break;
       case NicTelemetryName::NIC_TELEMETRY_NAME_PORT2_MAC_STAT_RX_BAD_PACKETS:
-        val->set_count(data.port2_mac_stat_rx_bad_packets);
+        val->set_count(be64toh(data.port2_mac_stat_rx_bad_packets));
         break;
       case NicTelemetryName::NIC_TELEMETRY_NAME_PORT3_MAC_STAT_TX_BYTES:
-        val->set_count(data.port3_mac_stat_tx_bytes);
+        val->set_count(be64toh(data.port3_mac_stat_tx_bytes));
         break;
       case NicTelemetryName::NIC_TELEMETRY_NAME_PORT3_MAC_STAT_TX_PACKETS:
-        val->set_count(data.port3_mac_stat_tx_packets);
+        val->set_count(be64toh(data.port3_mac_stat_tx_packets));
         break;
       case NicTelemetryName::NIC_TELEMETRY_NAME_PORT3_MAC_STAT_RX_BYTES:
-        val->set_count(data.port3_mac_stat_rx_bytes);
+        val->set_count(be64toh(data.port3_mac_stat_rx_bytes));
         break;
       case NicTelemetryName::NIC_TELEMETRY_NAME_PORT3_MAC_STAT_RX_PACKETS:
-        val->set_count(data.port3_mac_stat_rx_packets);
+        val->set_count(be64toh(data.port3_mac_stat_rx_packets));
         break;
       case NicTelemetryName::NIC_TELEMETRY_NAME_PORT3_MAC_STAT_RX_BAD_PACKETS:
-        val->set_count(data.port3_mac_stat_rx_bad_packets);
+        val->set_count(be64toh(data.port3_mac_stat_rx_bad_packets));
         break;
       case NicTelemetryName::NIC_TELEMETRY_NAME_TX_PACKETS_DROPPED:
-        val->set_count(data.tx_packets_dropped);
+        val->set_count(be64toh(data.tx_packets_dropped));
         break;
       case NicTelemetryName::NIC_TELEMETRY_NAME_RX_PACKETS_DROPPED:
-        val->set_count(data.rx_packets_dropped);
+        val->set_count(be64toh(data.rx_packets_dropped));
         break;
       case NicTelemetryName::NIC_TELEMETRY_NAME_CN0_ETH0_NO_BUFFER_RX_DROPS:
-        val->set_count(data.cn0_eth0_no_buffer_rx_drops);
+        val->set_count(be64toh(data.cn0_eth0_no_buffer_rx_drops));
         break;
       case NicTelemetryName::NIC_TELEMETRY_NAME_DIORITE_ADT:
-        val->set_reading(data.diorite_adt);
+        val->set_reading(be16toh(data.diorite_adt));
         break;
       case NicTelemetryName::NIC_TELEMETRY_NAME_DIORITE_FAN_SPEED:
-        val->set_reading(data.diorite_fan_speed);
+        val->set_reading(be16toh(data.diorite_fan_speed));
         break;
       case NicTelemetryName::NIC_TELEMETRY_NAME_DIORITE_FAN_DUTY_CYCLE:
         val->set_reading(data.diorite_fan_duty_cycle);
@@ -164,16 +165,16 @@
         val->set_reading(data.op_mode);
         break;
       case NicTelemetryName::NIC_TELEMETRY_NAME_PORT_LINK_STATE:
-        val->set_reading(data.port_link_state);
+        val->set_reading(be16toh(data.port_link_state));
         break;
       case NicTelemetryName::NIC_TELEMETRY_NAME_ERROR_CODES:
-        val->set_count(data.error_codes);
+        val->set_count(be64toh(data.error_codes));
         break;
       case NicTelemetryName::NIC_TELEMETRY_NAME_DIORITE_CPU:
-        val->set_reading(data.diorite_cpu);
+        val->set_reading(be32toh(data.diorite_cpu));
         break;
       case NicTelemetryName::NIC_TELEMETRY_NAME_DIORITE_DDR:
-        val->set_reading(data.diorite_ddr);
+        val->set_reading(be32toh(data.diorite_ddr));
         break;
       default:
         return absl::NotFoundError(absl::StrFormat(