mirror of
				https://github.com/edera-dev/krata.git
				synced 2025-11-03 23:29:39 +00:00 
			
		
		
		
	network: implement icmp nat support
This commit is contained in:
		
							
								
								
									
										21
									
								
								network/examples/ping.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								network/examples/ping.rs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,21 @@
 | 
			
		||||
use std::{net::Ipv6Addr, str::FromStr, time::Duration};
 | 
			
		||||
 | 
			
		||||
use anyhow::Result;
 | 
			
		||||
use hyphanet::icmp::{IcmpClient, IcmpProtocol};
 | 
			
		||||
 | 
			
		||||
#[tokio::main]
 | 
			
		||||
async fn main() -> Result<()> {
 | 
			
		||||
    let client = IcmpClient::new(IcmpProtocol::Icmp6)?;
 | 
			
		||||
    let payload: [u8; 4] = [12u8, 14u8, 16u8, 32u8];
 | 
			
		||||
    let result = client
 | 
			
		||||
        .ping6(
 | 
			
		||||
            Ipv6Addr::from_str("2606:4700:4700::1111")?,
 | 
			
		||||
            0,
 | 
			
		||||
            1,
 | 
			
		||||
            &payload,
 | 
			
		||||
            Duration::from_secs(10),
 | 
			
		||||
        )
 | 
			
		||||
        .await?;
 | 
			
		||||
    println!("reply: {:?}", result);
 | 
			
		||||
    Ok(())
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user