diff --git a/Cargo.toml b/Cargo.toml index 55dd013..99d3292 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,16 +10,16 @@ members = [ ] [workspace.package] -version = "0.23.0" +version = "0.23.1" edition = "2021" authors = ["shellrow "] [workspace.dependencies] -nex-core = { version = "0.23.0", path = "nex-core" } -nex-datalink = { version = "0.23.0", path = "nex-datalink" } -nex-packet = { version = "0.23.0", path = "nex-packet" } -nex-sys = { version = "0.23.0", path = "nex-sys" } -nex-socket = { version = "0.23.0", path = "nex-socket" } +nex-core = { version = "0.23.1", path = "nex-core" } +nex-datalink = { version = "0.23.1", path = "nex-datalink" } +nex-packet = { version = "0.23.1", path = "nex-packet" } +nex-sys = { version = "0.23.1", path = "nex-sys" } +nex-socket = { version = "0.23.1", path = "nex-socket" } serde = { version = "1" } libc = "0.2" netdev = { version = "0.37" } diff --git a/README.md b/README.md index 6793194..852f496 100644 --- a/README.md +++ b/README.md @@ -42,14 +42,14 @@ If you want to focus on network interfaces, you can use the [netdev](https://git `nex-datalink` uses a raw socket which may require elevated privileges depending on your system's configuration. Execute with administrator privileges if necessary. -## for Windows Users +## For Windows Users Please note that in order to send and receive raw packets using `nex-datalink` on Windows, [Npcap](https://npcap.com/#download) is required. 1. Install Npcap, making sure to check Install Npcap in WinPcap API-compatible Mode during the installation. 2. Download the Npcap SDK. Add the SDK's /Lib/x64 (or /Lib) folder to your LIB environment variable. -## for macOS Users -On macOS, managing access to the Berkeley Packet Filter (BPF) devices is necessary for send and receive raw packets using `nex-datalink`. +## For macOS Users +On macOS, managing access to the Berkeley Packet Filter (BPF) devices is necessary to send and receive raw packets using `nex-datalink`. You can use [chmod-bpf](https://github.com/shellrow/chmod-bpf) to automatically manage permissions for BPF devices. Alternatively, of course, you can also use `sudo` to temporarily grant the necessary permissions. diff --git a/nex-core/src/ip.rs b/nex-core/src/ip.rs index b78c6b7..0aecf41 100644 --- a/nex-core/src/ip.rs +++ b/nex-core/src/ip.rs @@ -1,3 +1,5 @@ +//! IP address utilities. + use std::net::{IpAddr, Ipv4Addr, Ipv6Addr}; /// Returns [`true`] if the address appears to be globally routable. diff --git a/nex-datalink/src/async_io/mod.rs b/nex-datalink/src/async_io/mod.rs index 3d95301..71932a3 100644 --- a/nex-datalink/src/async_io/mod.rs +++ b/nex-datalink/src/async_io/mod.rs @@ -1,3 +1,5 @@ +//! Asynchronous data link layer I/O operations. + #[cfg(any(target_os = "linux", target_os = "android"))] pub mod linux; diff --git a/nex-packet/src/tcp.rs b/nex-packet/src/tcp.rs index 86a4e2d..bcb034a 100644 --- a/nex-packet/src/tcp.rs +++ b/nex-packet/src/tcp.rs @@ -598,7 +598,9 @@ impl Packet for TcpPacket { // Add option padding (zero-filled) to reach the padded length let written_opt = bytes.len() - before_opts; let pad = padded_opt_len.saturating_sub(written_opt); - for _ in 0..pad { bytes.put_u8(0); } + for _ in 0..pad { + bytes.put_u8(0); + } // Append payload bytes.extend_from_slice(&self.payload); diff --git a/nex-socket/src/icmp/mod.rs b/nex-socket/src/icmp/mod.rs index 4cc664c..669d04a 100644 --- a/nex-socket/src/icmp/mod.rs +++ b/nex-socket/src/icmp/mod.rs @@ -1,3 +1,7 @@ +//! ICMP socket. +//! +//! Supplies synchronous and asynchronous interfaces for sending and +//! receiving Internet Control Message Protocol packets. mod async_impl; mod config; mod sync_impl; diff --git a/nex-socket/src/tcp/mod.rs b/nex-socket/src/tcp/mod.rs index 4cc664c..9fdaa95 100644 --- a/nex-socket/src/tcp/mod.rs +++ b/nex-socket/src/tcp/mod.rs @@ -1,3 +1,7 @@ +//! TCP socket. +//! +//! Includes synchronous and asynchronous functionality and configuration +//! helpers for TCP sockets. mod async_impl; mod config; mod sync_impl; diff --git a/nex-socket/src/udp/mod.rs b/nex-socket/src/udp/mod.rs index 4cc664c..ff56fc6 100644 --- a/nex-socket/src/udp/mod.rs +++ b/nex-socket/src/udp/mod.rs @@ -1,3 +1,7 @@ +//! UDP socket. +//! +//! Provides synchronous and asynchronous UDP APIs along with +//! configuration utilities for common socket options. mod async_impl; mod config; mod sync_impl; diff --git a/nex-sys/src/lib.rs b/nex-sys/src/lib.rs index 9870937..7b8732f 100644 --- a/nex-sys/src/lib.rs +++ b/nex-sys/src/lib.rs @@ -23,6 +23,7 @@ impl Drop for FileDesc { } } +/// Sends data to a socket, returning the number of bytes sent. pub fn send_to( socket: CSocket, buffer: &[u8], @@ -47,6 +48,7 @@ pub fn send_to( } } +/// Receives data from a socket, returning the number of bytes read. pub fn recv_from( socket: CSocket, buffer: &mut [u8],