mirror of
https://github.com/andwati/telecom-platform.git
synced 2026-10-28 07:32:15 +00:00
- Extract health check handlers to new health.rs module (health, liveness, readiness, metrics endpoints) - Extract IP conversion utilities to new ip_utils.rs module (u32_to_ipv4_string, ipv4_string_to_u32) - Extract Redis synchronization logic to new redis_sync.rs module (RedisSyncer with sync_packet_stats, sync_credit_info, sync_credits_from_redis, sync_blocked_from_redis, sync_batch_entry methods) - Refactor EbpfManager
16 lines
441 B
Rust
16 lines
441 B
Rust
use anyhow::{Context, Result};
|
|
use std::net::Ipv4Addr;
|
|
|
|
/// Converts a u32 IP address to an IPv4 string
|
|
pub fn u32_to_ipv4_string(ip: u32) -> String {
|
|
let ip_addr = Ipv4Addr::from(ip);
|
|
ip_addr.to_string()
|
|
}
|
|
|
|
/// Converts an IPv4 string to a u32 IP address
|
|
pub fn ipv4_string_to_u32(ip_str: &str) -> Result<u32> {
|
|
let ip_addr: Ipv4Addr = ip_str.parse()
|
|
.context("Invalid IP address format")?;
|
|
Ok(u32::from(ip_addr))
|
|
}
|