Files
telecom-platform/apps/packet-gateway/src/ip_utils.rs
T
nutcas3 f90882b4b2 refactor: Extract health checks and utility modules from packet-gateway ebpf module
- 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
2026-04-25 03:51:23 +03:00

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))
}