Update to Rust 2018. Fixes #271
parent
1d5a329155
commit
88256dbdcf
|
@ -16,8 +16,8 @@ to most specific, but it's not very important.
|
|||
```rust
|
||||
use core::cell::RefCell;
|
||||
|
||||
use {Error, Result};
|
||||
use phy::{self, DeviceCapabilities, Device};
|
||||
use crate::{Error, Result};
|
||||
use crate::phy::{self, DeviceCapabilities, Device};
|
||||
```
|
||||
|
||||
## Wrapping function calls
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
[package]
|
||||
name = "smoltcp"
|
||||
version = "0.6.0"
|
||||
edition = "2018"
|
||||
authors = ["whitequark <whitequark@whitequark.org>"]
|
||||
description = "A TCP/IP stack designed for bare-metal, real-time systems without a heap."
|
||||
documentation = "https://docs.rs/smoltcp/"
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
#![feature(test)]
|
||||
|
||||
extern crate test;
|
||||
extern crate smoltcp;
|
||||
|
||||
mod wire {
|
||||
use test;
|
||||
#[cfg(feature = "proto-ipv6")]
|
||||
|
|
|
@ -1,11 +1,3 @@
|
|||
#[cfg(feature = "log")]
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
#[cfg(feature = "log")]
|
||||
extern crate env_logger;
|
||||
extern crate getopts;
|
||||
extern crate smoltcp;
|
||||
|
||||
mod utils;
|
||||
|
||||
use std::cmp;
|
||||
|
@ -15,6 +7,8 @@ use std::thread;
|
|||
use std::io::{Read, Write};
|
||||
use std::net::TcpStream;
|
||||
use std::os::unix::io::AsRawFd;
|
||||
use log::debug;
|
||||
|
||||
use smoltcp::phy::wait as phy_wait;
|
||||
use smoltcp::wire::{EthernetAddress, IpAddress, IpCidr};
|
||||
use smoltcp::iface::{NeighborCache, EthernetInterfaceBuilder};
|
||||
|
|
|
@ -1,14 +1,10 @@
|
|||
#[macro_use]
|
||||
extern crate log;
|
||||
extern crate env_logger;
|
||||
extern crate getopts;
|
||||
extern crate smoltcp;
|
||||
|
||||
mod utils;
|
||||
|
||||
use std::str::{self, FromStr};
|
||||
use std::collections::BTreeMap;
|
||||
use std::os::unix::io::AsRawFd;
|
||||
use log::debug;
|
||||
|
||||
use smoltcp::phy::wait as phy_wait;
|
||||
use smoltcp::wire::{EthernetAddress, Ipv4Address, IpAddress, IpCidr};
|
||||
use smoltcp::iface::{NeighborCache, EthernetInterfaceBuilder, Routes};
|
||||
|
|
|
@ -1,9 +1,3 @@
|
|||
#[macro_use]
|
||||
extern crate log;
|
||||
extern crate env_logger;
|
||||
extern crate getopts;
|
||||
extern crate smoltcp;
|
||||
|
||||
mod utils;
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
|
|
|
@ -1,17 +1,11 @@
|
|||
#[macro_use]
|
||||
extern crate log;
|
||||
extern crate env_logger;
|
||||
extern crate getopts;
|
||||
extern crate rand;
|
||||
extern crate url;
|
||||
extern crate smoltcp;
|
||||
|
||||
mod utils;
|
||||
|
||||
use std::str::{self, FromStr};
|
||||
use std::collections::BTreeMap;
|
||||
use std::os::unix::io::AsRawFd;
|
||||
use url::Url;
|
||||
use log::debug;
|
||||
|
||||
use smoltcp::phy::wait as phy_wait;
|
||||
use smoltcp::wire::{EthernetAddress, Ipv4Address, Ipv6Address, IpAddress, IpCidr};
|
||||
use smoltcp::iface::{NeighborCache, EthernetInterfaceBuilder, Routes};
|
||||
|
|
|
@ -1,21 +1,13 @@
|
|||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
#![allow(unused_mut)]
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
use std as core;
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
extern crate smoltcp;
|
||||
#[cfg(feature = "std")]
|
||||
extern crate env_logger;
|
||||
#[cfg(feature = "std")]
|
||||
extern crate getopts;
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
#[allow(dead_code)]
|
||||
mod utils;
|
||||
|
||||
use core::str;
|
||||
use log::{info, debug, error};
|
||||
|
||||
use smoltcp::phy::Loopback;
|
||||
use smoltcp::wire::{EthernetAddress, IpAddress, IpCidr};
|
||||
use smoltcp::iface::{NeighborCache, EthernetInterfaceBuilder};
|
||||
|
|
|
@ -1,14 +1,9 @@
|
|||
#[macro_use]
|
||||
extern crate log;
|
||||
extern crate env_logger;
|
||||
extern crate getopts;
|
||||
extern crate smoltcp;
|
||||
extern crate byteorder;
|
||||
|
||||
mod utils;
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
use std::os::unix::io::AsRawFd;
|
||||
use log::debug;
|
||||
|
||||
use smoltcp::phy::wait as phy_wait;
|
||||
use smoltcp::wire::{EthernetAddress, IpVersion, IpProtocol, IpAddress, IpCidr, Ipv4Address,
|
||||
Ipv4Packet, IgmpPacket, IgmpRepr};
|
||||
|
|
|
@ -1,16 +1,13 @@
|
|||
#[macro_use]
|
||||
extern crate log;
|
||||
extern crate env_logger;
|
||||
extern crate getopts;
|
||||
extern crate smoltcp;
|
||||
extern crate byteorder;
|
||||
|
||||
mod utils;
|
||||
|
||||
use std::str::FromStr;
|
||||
use std::collections::BTreeMap;
|
||||
use std::cmp;
|
||||
use std::os::unix::io::AsRawFd;
|
||||
use std::collections::HashMap;
|
||||
use log::debug;
|
||||
use byteorder::{ByteOrder, NetworkEndian};
|
||||
|
||||
use smoltcp::time::{Duration, Instant};
|
||||
use smoltcp::phy::Device;
|
||||
use smoltcp::phy::wait as phy_wait;
|
||||
|
@ -19,8 +16,6 @@ use smoltcp::wire::{EthernetAddress, IpAddress, IpCidr,
|
|||
Ipv4Address, Icmpv4Repr, Icmpv4Packet};
|
||||
use smoltcp::iface::{NeighborCache, EthernetInterfaceBuilder, Routes};
|
||||
use smoltcp::socket::{SocketSet, IcmpSocket, IcmpSocketBuffer, IcmpPacketMetadata, IcmpEndpoint};
|
||||
use std::collections::HashMap;
|
||||
use byteorder::{ByteOrder, NetworkEndian};
|
||||
|
||||
macro_rules! send_icmp_ping {
|
||||
( $repr_type:ident, $packet_type:ident, $ident:expr, $seq_no:expr,
|
||||
|
|
|
@ -1,15 +1,11 @@
|
|||
#[macro_use]
|
||||
extern crate log;
|
||||
extern crate env_logger;
|
||||
extern crate getopts;
|
||||
extern crate smoltcp;
|
||||
|
||||
mod utils;
|
||||
|
||||
use std::str;
|
||||
use std::collections::BTreeMap;
|
||||
use std::fmt::Write;
|
||||
use std::os::unix::io::AsRawFd;
|
||||
use log::debug;
|
||||
|
||||
use smoltcp::phy::wait as phy_wait;
|
||||
use smoltcp::wire::{EthernetAddress, IpAddress, IpCidr};
|
||||
use smoltcp::iface::{NeighborCache, EthernetInterfaceBuilder};
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
extern crate smoltcp;
|
||||
|
||||
use std::env;
|
||||
use std::os::unix::io::AsRawFd;
|
||||
use smoltcp::phy::wait as phy_wait;
|
||||
|
|
|
@ -9,7 +9,7 @@ use std::time::{SystemTime, UNIX_EPOCH};
|
|||
use std::env;
|
||||
use std::process;
|
||||
#[cfg(feature = "log")]
|
||||
use log::{Level, LevelFilter};
|
||||
use log::{Level, LevelFilter, trace};
|
||||
#[cfg(feature = "log")]
|
||||
use env_logger::Builder;
|
||||
use getopts::{Options, Matches};
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
use {Result, Error};
|
||||
use wire::{IpVersion, IpProtocol, IpEndpoint, IpAddress,
|
||||
use crate::{Result, Error};
|
||||
use crate::wire::{IpVersion, IpProtocol, IpEndpoint, IpAddress,
|
||||
Ipv4Cidr, Ipv4Address, Ipv4Packet, Ipv4Repr,
|
||||
UdpPacket, UdpRepr,
|
||||
DhcpPacket, DhcpRepr, DhcpMessageType};
|
||||
use wire::dhcpv4::field as dhcpv4_field;
|
||||
use socket::{SocketSet, SocketHandle, RawSocket, RawSocketBuffer};
|
||||
use phy::{Device, ChecksumCapabilities};
|
||||
use iface::EthernetInterface as Interface;
|
||||
use time::{Instant, Duration};
|
||||
use crate::wire::dhcpv4::field as dhcpv4_field;
|
||||
use crate::socket::{SocketSet, SocketHandle, RawSocket, RawSocketBuffer};
|
||||
use crate::phy::{Device, ChecksumCapabilities};
|
||||
use crate::iface::EthernetInterface as Interface;
|
||||
use crate::time::{Instant, Duration};
|
||||
use super::{UDP_SERVER_PORT, UDP_CLIENT_PORT};
|
||||
|
||||
const DISCOVER_TIMEOUT: u64 = 10;
|
||||
|
|
|
@ -7,50 +7,50 @@ use managed::{ManagedSlice, ManagedMap};
|
|||
#[cfg(not(feature = "proto-igmp"))]
|
||||
use core::marker::PhantomData;
|
||||
|
||||
use {Error, Result};
|
||||
use phy::{Device, DeviceCapabilities, RxToken, TxToken};
|
||||
use time::{Duration, Instant};
|
||||
use wire::pretty_print::PrettyPrinter;
|
||||
use wire::{EthernetAddress, EthernetProtocol, EthernetFrame};
|
||||
use wire::{IpAddress, IpProtocol, IpRepr, IpCidr};
|
||||
use crate::{Error, Result};
|
||||
use crate::phy::{Device, DeviceCapabilities, RxToken, TxToken};
|
||||
use crate::time::{Duration, Instant};
|
||||
use crate::wire::pretty_print::PrettyPrinter;
|
||||
use crate::wire::{EthernetAddress, EthernetProtocol, EthernetFrame};
|
||||
use crate::wire::{IpAddress, IpProtocol, IpRepr, IpCidr};
|
||||
#[cfg(feature = "proto-ipv6")]
|
||||
use wire::{Ipv6Address, Ipv6Packet, Ipv6Repr, IPV6_MIN_MTU};
|
||||
use crate::wire::{Ipv6Address, Ipv6Packet, Ipv6Repr, IPV6_MIN_MTU};
|
||||
#[cfg(feature = "proto-ipv4")]
|
||||
use wire::{Ipv4Address, Ipv4Packet, Ipv4Repr, IPV4_MIN_MTU};
|
||||
use crate::wire::{Ipv4Address, Ipv4Packet, Ipv4Repr, IPV4_MIN_MTU};
|
||||
#[cfg(feature = "proto-ipv4")]
|
||||
use wire::{ArpPacket, ArpRepr, ArpOperation};
|
||||
use crate::wire::{ArpPacket, ArpRepr, ArpOperation};
|
||||
#[cfg(feature = "proto-ipv4")]
|
||||
use wire::{Icmpv4Packet, Icmpv4Repr, Icmpv4DstUnreachable};
|
||||
use crate::wire::{Icmpv4Packet, Icmpv4Repr, Icmpv4DstUnreachable};
|
||||
#[cfg(feature = "proto-igmp")]
|
||||
use wire::{IgmpPacket, IgmpRepr, IgmpVersion};
|
||||
use crate::wire::{IgmpPacket, IgmpRepr, IgmpVersion};
|
||||
#[cfg(feature = "proto-ipv6")]
|
||||
use wire::{Icmpv6Packet, Icmpv6Repr, Icmpv6ParamProblem};
|
||||
use crate::wire::{Icmpv6Packet, Icmpv6Repr, Icmpv6ParamProblem};
|
||||
#[cfg(all(feature = "socket-icmp", any(feature = "proto-ipv4", feature = "proto-ipv6")))]
|
||||
use wire::IcmpRepr;
|
||||
use crate::wire::IcmpRepr;
|
||||
#[cfg(feature = "proto-ipv6")]
|
||||
use wire::{Ipv6HopByHopHeader, Ipv6HopByHopRepr};
|
||||
use crate::wire::{Ipv6HopByHopHeader, Ipv6HopByHopRepr};
|
||||
#[cfg(feature = "proto-ipv6")]
|
||||
use wire::{Ipv6OptionRepr, Ipv6OptionFailureType};
|
||||
use crate::wire::{Ipv6OptionRepr, Ipv6OptionFailureType};
|
||||
#[cfg(feature = "proto-ipv6")]
|
||||
use wire::{NdiscNeighborFlags, NdiscRepr};
|
||||
use crate::wire::{NdiscNeighborFlags, NdiscRepr};
|
||||
#[cfg(all(feature = "proto-ipv6", feature = "socket-udp"))]
|
||||
use wire::Icmpv6DstUnreachable;
|
||||
use crate::wire::Icmpv6DstUnreachable;
|
||||
#[cfg(feature = "socket-udp")]
|
||||
use wire::{UdpPacket, UdpRepr};
|
||||
use crate::wire::{UdpPacket, UdpRepr};
|
||||
#[cfg(feature = "socket-tcp")]
|
||||
use wire::{TcpPacket, TcpRepr, TcpControl};
|
||||
use crate::wire::{TcpPacket, TcpRepr, TcpControl};
|
||||
|
||||
use socket::{Socket, SocketSet, AnySocket, PollAt};
|
||||
use crate::socket::{Socket, SocketSet, AnySocket, PollAt};
|
||||
#[cfg(feature = "socket-raw")]
|
||||
use socket::RawSocket;
|
||||
use crate::socket::RawSocket;
|
||||
#[cfg(all(feature = "socket-icmp", any(feature = "proto-ipv4", feature = "proto-ipv6")))]
|
||||
use socket::IcmpSocket;
|
||||
use crate::socket::IcmpSocket;
|
||||
#[cfg(feature = "socket-udp")]
|
||||
use socket::UdpSocket;
|
||||
use crate::socket::UdpSocket;
|
||||
#[cfg(feature = "socket-tcp")]
|
||||
use socket::TcpSocket;
|
||||
use super::{NeighborCache, NeighborAnswer};
|
||||
use super::Routes;
|
||||
use crate::socket::TcpSocket;
|
||||
use crate::iface::{NeighborCache, NeighborAnswer};
|
||||
use crate::iface::Routes;
|
||||
|
||||
/// An Ethernet network interface.
|
||||
///
|
||||
|
@ -1722,37 +1722,37 @@ mod test {
|
|||
#[cfg(feature = "proto-igmp")]
|
||||
use std::vec::Vec;
|
||||
use std::collections::BTreeMap;
|
||||
use {Result, Error};
|
||||
|
||||
use crate::{Result, Error};
|
||||
use super::InterfaceBuilder;
|
||||
use iface::{NeighborCache, EthernetInterface};
|
||||
use phy::{self, Loopback, ChecksumCapabilities};
|
||||
use crate::iface::{NeighborCache, EthernetInterface};
|
||||
use crate::phy::{self, Loopback, ChecksumCapabilities};
|
||||
#[cfg(feature = "proto-igmp")]
|
||||
use phy::{Device, RxToken, TxToken};
|
||||
use time::Instant;
|
||||
use socket::SocketSet;
|
||||
use crate::phy::{Device, RxToken, TxToken};
|
||||
use crate::time::Instant;
|
||||
use crate::socket::SocketSet;
|
||||
#[cfg(feature = "proto-ipv4")]
|
||||
use wire::{ArpOperation, ArpPacket, ArpRepr};
|
||||
use wire::{EthernetAddress, EthernetFrame, EthernetProtocol};
|
||||
use wire::{IpAddress, IpCidr, IpProtocol, IpRepr};
|
||||
use crate::wire::{ArpOperation, ArpPacket, ArpRepr};
|
||||
use crate::wire::{EthernetAddress, EthernetFrame, EthernetProtocol};
|
||||
use crate::wire::{IpAddress, IpCidr, IpProtocol, IpRepr};
|
||||
#[cfg(feature = "proto-ipv4")]
|
||||
use wire::{Ipv4Address, Ipv4Repr};
|
||||
use crate::wire::{Ipv4Address, Ipv4Repr};
|
||||
#[cfg(feature = "proto-igmp")]
|
||||
use wire::Ipv4Packet;
|
||||
use crate::wire::Ipv4Packet;
|
||||
#[cfg(feature = "proto-ipv4")]
|
||||
use wire::{Icmpv4Repr, Icmpv4DstUnreachable};
|
||||
use crate::wire::{Icmpv4Repr, Icmpv4DstUnreachable};
|
||||
#[cfg(feature = "proto-igmp")]
|
||||
use wire::{IgmpPacket, IgmpRepr, IgmpVersion};
|
||||
use crate::wire::{IgmpPacket, IgmpRepr, IgmpVersion};
|
||||
#[cfg(all(feature = "socket-udp", any(feature = "proto-ipv4", feature = "proto-ipv6")))]
|
||||
use wire::{UdpPacket, UdpRepr};
|
||||
use crate::wire::{UdpPacket, UdpRepr};
|
||||
#[cfg(feature = "proto-ipv6")]
|
||||
use wire::{Ipv6Address, Ipv6Repr};
|
||||
use crate::wire::{Ipv6Address, Ipv6Repr};
|
||||
#[cfg(feature = "proto-ipv6")]
|
||||
use wire::{Icmpv6Packet, Icmpv6Repr, Icmpv6ParamProblem};
|
||||
use crate::wire::{Icmpv6Packet, Icmpv6Repr, Icmpv6ParamProblem};
|
||||
#[cfg(feature = "proto-ipv6")]
|
||||
use wire::{NdiscNeighborFlags, NdiscRepr};
|
||||
use crate::wire::{NdiscNeighborFlags, NdiscRepr};
|
||||
#[cfg(feature = "proto-ipv6")]
|
||||
use wire::{Ipv6HopByHopHeader, Ipv6Option, Ipv6OptionRepr};
|
||||
use crate::wire::{Ipv6HopByHopHeader, Ipv6Option, Ipv6OptionRepr};
|
||||
|
||||
use super::Packet;
|
||||
|
||||
|
@ -2003,8 +2003,8 @@ mod test {
|
|||
#[test]
|
||||
#[cfg(feature = "socket-udp")]
|
||||
fn test_handle_udp_broadcast() {
|
||||
use socket::{UdpSocket, UdpSocketBuffer, UdpPacketMetadata};
|
||||
use wire::IpEndpoint;
|
||||
use crate::socket::{UdpSocket, UdpSocketBuffer, UdpPacketMetadata};
|
||||
use crate::wire::IpEndpoint;
|
||||
|
||||
static UDP_PAYLOAD: [u8; 5] = [0x48, 0x65, 0x6c, 0x6c, 0x6f];
|
||||
|
||||
|
@ -2075,7 +2075,7 @@ mod test {
|
|||
#[test]
|
||||
#[cfg(feature = "proto-ipv4")]
|
||||
fn test_handle_ipv4_broadcast() {
|
||||
use wire::{Ipv4Packet, Icmpv4Repr, Icmpv4Packet};
|
||||
use crate::wire::{Ipv4Packet, Icmpv4Repr, Icmpv4Packet};
|
||||
|
||||
let (mut iface, mut socket_set) = create_loopback();
|
||||
|
||||
|
@ -2134,11 +2134,11 @@ mod test {
|
|||
#[cfg(feature = "socket-udp")]
|
||||
fn test_icmp_reply_size() {
|
||||
#[cfg(all(feature = "proto-ipv4", not(feature = "proto-ipv6")))]
|
||||
use wire::IPV4_MIN_MTU as MIN_MTU;
|
||||
use crate::wire::IPV4_MIN_MTU as MIN_MTU;
|
||||
#[cfg(feature = "proto-ipv6")]
|
||||
use wire::Icmpv6DstUnreachable;
|
||||
use crate::wire::Icmpv6DstUnreachable;
|
||||
#[cfg(feature = "proto-ipv6")]
|
||||
use wire::IPV6_MIN_MTU as MIN_MTU;
|
||||
use crate::wire::IPV6_MIN_MTU as MIN_MTU;
|
||||
|
||||
#[cfg(all(feature = "proto-ipv4", not(feature = "proto-ipv6")))]
|
||||
const MAX_PAYLOAD_LEN: usize = 528;
|
||||
|
@ -2371,8 +2371,8 @@ mod test {
|
|||
#[test]
|
||||
#[cfg(all(feature = "socket-icmp", feature = "proto-ipv4"))]
|
||||
fn test_icmpv4_socket() {
|
||||
use socket::{IcmpSocket, IcmpEndpoint, IcmpSocketBuffer, IcmpPacketMetadata};
|
||||
use wire::Icmpv4Packet;
|
||||
use crate::socket::{IcmpSocket, IcmpEndpoint, IcmpSocketBuffer, IcmpPacketMetadata};
|
||||
use crate::wire::Icmpv4Packet;
|
||||
|
||||
let (iface, mut socket_set) = create_loopback();
|
||||
|
||||
|
@ -2613,8 +2613,8 @@ mod test {
|
|||
#[test]
|
||||
#[cfg(all(feature = "proto-ipv4", feature = "socket-raw"))]
|
||||
fn test_raw_socket_no_reply() {
|
||||
use socket::{RawSocket, RawSocketBuffer, RawPacketMetadata};
|
||||
use wire::{IpVersion, Ipv4Packet, UdpPacket, UdpRepr};
|
||||
use crate::socket::{RawSocket, RawSocketBuffer, RawPacketMetadata};
|
||||
use crate::wire::{IpVersion, Ipv4Packet, UdpPacket, UdpRepr};
|
||||
|
||||
let (mut iface, mut socket_set) = create_loopback();
|
||||
|
||||
|
@ -2669,8 +2669,8 @@ mod test {
|
|||
#[test]
|
||||
#[cfg(all(feature = "proto-ipv4", feature = "socket-raw"))]
|
||||
fn test_raw_socket_truncated_packet() {
|
||||
use socket::{RawSocket, RawSocketBuffer, RawPacketMetadata};
|
||||
use wire::{IpVersion, Ipv4Packet, UdpPacket, UdpRepr};
|
||||
use crate::socket::{RawSocket, RawSocketBuffer, RawPacketMetadata};
|
||||
use crate::wire::{IpVersion, Ipv4Packet, UdpPacket, UdpRepr};
|
||||
|
||||
let (mut iface, mut socket_set) = create_loopback();
|
||||
|
||||
|
@ -2730,9 +2730,9 @@ mod test {
|
|||
#[test]
|
||||
#[cfg(all(feature = "proto-ipv4", feature = "socket-raw", feature = "socket-udp"))]
|
||||
fn test_raw_socket_with_udp_socket() {
|
||||
use socket::{UdpSocket, UdpSocketBuffer, UdpPacketMetadata,
|
||||
use crate::socket::{UdpSocket, UdpSocketBuffer, UdpPacketMetadata,
|
||||
RawSocket, RawSocketBuffer, RawPacketMetadata};
|
||||
use wire::{IpVersion, IpEndpoint, Ipv4Packet, UdpPacket, UdpRepr};
|
||||
use crate::wire::{IpVersion, IpEndpoint, Ipv4Packet, UdpPacket, UdpRepr};
|
||||
|
||||
static UDP_PAYLOAD: [u8; 5] = [0x48, 0x65, 0x6c, 0x6c, 0x6f];
|
||||
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
|
||||
use managed::ManagedMap;
|
||||
|
||||
use wire::{EthernetAddress, IpAddress};
|
||||
use time::{Duration, Instant};
|
||||
use crate::wire::{EthernetAddress, IpAddress};
|
||||
use crate::time::{Duration, Instant};
|
||||
|
||||
/// A cached neighbor.
|
||||
///
|
||||
|
@ -194,7 +194,7 @@ impl<'a> Cache<'a> {
|
|||
mod test {
|
||||
use super::*;
|
||||
use std::collections::BTreeMap;
|
||||
use wire::ip::test::{MOCK_IP_ADDR_1, MOCK_IP_ADDR_2, MOCK_IP_ADDR_3, MOCK_IP_ADDR_4};
|
||||
use crate::wire::ip::test::{MOCK_IP_ADDR_1, MOCK_IP_ADDR_2, MOCK_IP_ADDR_3, MOCK_IP_ADDR_4};
|
||||
|
||||
|
||||
const HADDR_A: EthernetAddress = EthernetAddress([0, 0, 0, 0, 0, 1]);
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
use managed::ManagedMap;
|
||||
use time::Instant;
|
||||
use crate::time::Instant;
|
||||
use core::ops::Bound;
|
||||
|
||||
use {Error, Result};
|
||||
use wire::{IpCidr, IpAddress};
|
||||
use crate::{Error, Result};
|
||||
use crate::wire::{IpCidr, IpAddress};
|
||||
#[cfg(feature = "proto-ipv4")]
|
||||
use wire::{Ipv4Address, Ipv4Cidr};
|
||||
use crate::wire::{Ipv4Address, Ipv4Cidr};
|
||||
#[cfg(feature = "proto-ipv6")]
|
||||
use wire::{Ipv6Address, Ipv6Cidr};
|
||||
use crate::wire::{Ipv6Address, Ipv6Cidr};
|
||||
|
||||
/// A prefix of addresses that should be routed via a router
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
|
|
16
src/lib.rs
16
src/lib.rs
|
@ -1,5 +1,4 @@
|
|||
#![cfg_attr(feature = "alloc", feature(alloc))]
|
||||
#![no_std]
|
||||
#![cfg_attr(not(any(test, feature = "std")), no_std)]
|
||||
#![deny(unsafe_code)]
|
||||
#![cfg_attr(all(any(feature = "proto-ipv4", feature = "proto-ipv6"), feature = "ethernet"), deny(unused))]
|
||||
|
||||
|
@ -91,21 +90,8 @@ compile_error!("at least one socket needs to be enabled"); */
|
|||
// FIXME(dlrobertson): clippy fails with this lint
|
||||
#![cfg_attr(feature = "cargo-clippy", allow(if_same_then_else))]
|
||||
|
||||
#[cfg(all(feature = "proto-ipv6", feature = "ethernet"))]
|
||||
#[macro_use]
|
||||
extern crate bitflags;
|
||||
extern crate byteorder;
|
||||
extern crate managed;
|
||||
#[cfg(any(test, feature = "std"))]
|
||||
#[macro_use]
|
||||
extern crate std;
|
||||
#[cfg(any(feature = "phy-raw_socket", feature = "phy-tap_interface"))]
|
||||
extern crate libc;
|
||||
#[cfg(feature = "alloc")]
|
||||
extern crate alloc;
|
||||
#[cfg(feature = "log")]
|
||||
#[macro_use(trace, debug)]
|
||||
extern crate log;
|
||||
|
||||
use core::fmt;
|
||||
|
||||
|
|
|
@ -1,18 +1,14 @@
|
|||
|
||||
#[cfg(feature = "log")]
|
||||
#[macro_use]
|
||||
mod log {
|
||||
macro_rules! net_log {
|
||||
(trace, $($arg:expr),*) => { trace!($($arg),*); };
|
||||
(debug, $($arg:expr),*) => { debug!($($arg),*); };
|
||||
}
|
||||
macro_rules! net_log {
|
||||
(trace, $($arg:expr),*) => { log::trace!($($arg),*); };
|
||||
(debug, $($arg:expr),*) => { log::debug!($($arg),*); };
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "log"))]
|
||||
#[macro_use]
|
||||
mod log {
|
||||
macro_rules! net_log {
|
||||
($level:ident, $($arg:expr),*) => { $( let _ = $arg; )* }
|
||||
}
|
||||
macro_rules! net_log {
|
||||
($level:ident, $($arg:expr),*) => { $( let _ = $arg; )* }
|
||||
}
|
||||
|
||||
macro_rules! net_trace {
|
||||
|
|
|
@ -4,12 +4,12 @@ use core::str::FromStr;
|
|||
use core::result;
|
||||
|
||||
#[cfg(feature = "ethernet")]
|
||||
use wire::EthernetAddress;
|
||||
use wire::{IpAddress, IpCidr, IpEndpoint};
|
||||
use crate::wire::EthernetAddress;
|
||||
use crate::wire::{IpAddress, IpCidr, IpEndpoint};
|
||||
#[cfg(feature = "proto-ipv4")]
|
||||
use wire::{Ipv4Address, Ipv4Cidr};
|
||||
use crate::wire::{Ipv4Address, Ipv4Cidr};
|
||||
#[cfg(feature = "proto-ipv6")]
|
||||
use wire::{Ipv6Address, Ipv6Cidr};
|
||||
use crate::wire::{Ipv6Address, Ipv6Cidr};
|
||||
|
||||
type Result<T> = result::Result<T, ()>;
|
||||
|
||||
|
@ -44,7 +44,7 @@ impl<'a> Parser<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
fn try<F, T>(&mut self, f: F) -> Option<T>
|
||||
fn try_do<F, T>(&mut self, f: F) -> Option<T>
|
||||
where F: FnOnce(&mut Parser<'a>) -> Result<T> {
|
||||
let pos = self.pos;
|
||||
match f(self) {
|
||||
|
@ -103,7 +103,7 @@ impl<'a> Parser<'a> {
|
|||
hex: bool) -> Result<u32> {
|
||||
let mut value = self.accept_digit(hex)? as u32;
|
||||
for _ in 1..max_digits {
|
||||
match self.try(|p| p.accept_digit(hex)) {
|
||||
match self.try_do(|p| p.accept_digit(hex)) {
|
||||
Some(digit) => {
|
||||
value *= if hex { 16 } else { 10 };
|
||||
value += digit as u32;
|
||||
|
@ -132,10 +132,10 @@ impl<'a> Parser<'a> {
|
|||
|
||||
#[cfg(feature = "ethernet")]
|
||||
fn accept_mac(&mut self) -> Result<EthernetAddress> {
|
||||
if let Some(mac) = self.try(|p| p.accept_mac_joined_with(b'-')) {
|
||||
if let Some(mac) = self.try_do(|p| p.accept_mac_joined_with(b'-')) {
|
||||
return Ok(mac)
|
||||
}
|
||||
if let Some(mac) = self.try(|p| p.accept_mac_joined_with(b':')) {
|
||||
if let Some(mac) = self.try_do(|p| p.accept_mac_joined_with(b':')) {
|
||||
return Ok(mac)
|
||||
}
|
||||
Err(())
|
||||
|
@ -157,7 +157,7 @@ impl<'a> Parser<'a> {
|
|||
fn accept_ipv6_part(&mut self, (head, tail): (&mut [u16; 8], &mut [u16; 6]),
|
||||
(head_idx, tail_idx): (&mut usize, &mut usize),
|
||||
mut use_tail: bool, is_cidr: bool) -> Result<()> {
|
||||
let double_colon = match self.try(|p| p.accept_str(b"::")) {
|
||||
let double_colon = match self.try_do(|p| p.accept_str(b"::")) {
|
||||
Some(_) if !use_tail && *head_idx < 7 => {
|
||||
// Found a double colon. Start filling out the
|
||||
// tail and set the double colon flag in case
|
||||
|
@ -180,14 +180,14 @@ impl<'a> Parser<'a> {
|
|||
}
|
||||
};
|
||||
|
||||
match self.try(|p| p.accept_number(4, 0x10000, true)) {
|
||||
match self.try_do(|p| p.accept_number(4, 0x10000, true)) {
|
||||
Some(part) if !use_tail && *head_idx < 8 => {
|
||||
// Valid u16 to be added to the address
|
||||
head[*head_idx] = part as u16;
|
||||
*head_idx += 1;
|
||||
|
||||
if *head_idx == 6 && head[0..*head_idx] == [0, 0, 0, 0, 0, 0xffff] {
|
||||
self.try(|p| {
|
||||
self.try_do(|p| {
|
||||
p.accept_char(b':')?;
|
||||
p.accept_ipv4_mapped_ipv6_part(head, head_idx)
|
||||
});
|
||||
|
@ -201,7 +201,7 @@ impl<'a> Parser<'a> {
|
|||
|
||||
if *tail_idx == 1 && tail[0] == 0xffff
|
||||
&& head[0..8] == [0, 0, 0, 0, 0, 0, 0, 0] {
|
||||
self.try(|p| {
|
||||
self.try_do(|p| {
|
||||
p.accept_char(b':')?;
|
||||
p.accept_ipv4_mapped_ipv6_part(tail, tail_idx)
|
||||
});
|
||||
|
@ -287,13 +287,13 @@ impl<'a> Parser<'a> {
|
|||
|
||||
fn accept_ip(&mut self) -> Result<IpAddress> {
|
||||
#[cfg(feature = "proto-ipv4")]
|
||||
match self.try(|p| p.accept_ipv4()) {
|
||||
match self.try_do(|p| p.accept_ipv4()) {
|
||||
Some(ipv4) => return Ok(IpAddress::Ipv4(ipv4)),
|
||||
None => ()
|
||||
}
|
||||
|
||||
#[cfg(feature = "proto-ipv6")]
|
||||
match self.try(|p| p.accept_ipv6(false)) {
|
||||
match self.try_do(|p| p.accept_ipv6(false)) {
|
||||
Some(ipv6) => return Ok(IpAddress::Ipv6(ipv6)),
|
||||
None => ()
|
||||
}
|
||||
|
@ -333,13 +333,13 @@ impl<'a> Parser<'a> {
|
|||
|
||||
fn accept_ip_endpoint(&mut self) -> Result<IpEndpoint> {
|
||||
#[cfg(feature = "proto-ipv4")]
|
||||
match self.try(|p| p.accept_ipv4_endpoint()) {
|
||||
match self.try_do(|p| p.accept_ipv4_endpoint()) {
|
||||
Some(ipv4) => return Ok(ipv4),
|
||||
None => ()
|
||||
}
|
||||
|
||||
#[cfg(feature = "proto-ipv6")]
|
||||
match self.try(|p| p.accept_ipv6_endpoint()) {
|
||||
match self.try_do(|p| p.accept_ipv6_endpoint()) {
|
||||
Some(ipv6) => return Ok(ipv6),
|
||||
None => ()
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use core::cell::RefCell;
|
||||
|
||||
use {Error, Result};
|
||||
use phy::{self, DeviceCapabilities, Device};
|
||||
use time::{Duration, Instant};
|
||||
use crate::{Error, Result};
|
||||
use crate::phy::{self, DeviceCapabilities, Device};
|
||||
use crate::time::{Duration, Instant};
|
||||
|
||||
// We use our own RNG to stay compatible with #![no_std].
|
||||
// The use of the RNG below has a slight bias, but it doesn't matter.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use Result;
|
||||
use phy::{self, DeviceCapabilities, Device};
|
||||
use time::Instant;
|
||||
use crate::Result;
|
||||
use crate::phy::{self, DeviceCapabilities, Device};
|
||||
use crate::time::Instant;
|
||||
|
||||
// This could be fixed once associated consts are stable.
|
||||
const MTU: usize = 1536;
|
||||
|
|
|
@ -9,9 +9,9 @@ use alloc::collections::VecDeque;
|
|||
#[cfg(all(feature = "alloc", feature = "rust-1_28"))]
|
||||
use alloc::VecDeque;
|
||||
|
||||
use Result;
|
||||
use phy::{self, Device, DeviceCapabilities};
|
||||
use time::Instant;
|
||||
use crate::Result;
|
||||
use crate::phy::{self, Device, DeviceCapabilities};
|
||||
use crate::time::Instant;
|
||||
|
||||
/// A loopback device.
|
||||
#[derive(Debug)]
|
||||
|
|
|
@ -84,8 +84,8 @@ impl<'a> phy::TxToken for StmPhyTxToken<'a> {
|
|||
```
|
||||
*/
|
||||
|
||||
use Result;
|
||||
use time::Instant;
|
||||
use crate::Result;
|
||||
use crate::time::Instant;
|
||||
|
||||
#[cfg(all(any(feature = "phy-raw_socket", feature = "phy-tap_interface"), unix))]
|
||||
mod sys;
|
||||
|
|
|
@ -4,9 +4,9 @@ use std::cell::RefCell;
|
|||
use std::io::Write;
|
||||
use byteorder::{ByteOrder, NativeEndian};
|
||||
|
||||
use Result;
|
||||
use phy::{self, DeviceCapabilities, Device};
|
||||
use time::Instant;
|
||||
use crate::Result;
|
||||
use crate::phy::{self, DeviceCapabilities, Device};
|
||||
use crate::time::Instant;
|
||||
|
||||
enum_with_unknown! {
|
||||
/// Captured packet header type.
|
||||
|
|
|
@ -4,9 +4,9 @@ use std::rc::Rc;
|
|||
use std::io;
|
||||
use std::os::unix::io::{RawFd, AsRawFd};
|
||||
|
||||
use Result;
|
||||
use phy::{self, sys, DeviceCapabilities, Device};
|
||||
use time::Instant;
|
||||
use crate::Result;
|
||||
use crate::phy::{self, sys, DeviceCapabilities, Device};
|
||||
use crate::time::Instant;
|
||||
|
||||
/// A socket that captures or transmits the complete frame.
|
||||
#[derive(Debug)]
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
use libc;
|
||||
use std::{mem, ptr, io};
|
||||
use std::os::unix::io::RawFd;
|
||||
use time::Duration;
|
||||
use crate::time::Duration;
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
#[path = "linux.rs"]
|
||||
|
|
|
@ -4,9 +4,9 @@ use std::rc::Rc;
|
|||
use std::io;
|
||||
use std::os::unix::io::{RawFd, AsRawFd};
|
||||
|
||||
use Result;
|
||||
use phy::{self, sys, DeviceCapabilities, Device};
|
||||
use time::Instant;
|
||||
use crate::Result;
|
||||
use crate::phy::{self, sys, DeviceCapabilities, Device};
|
||||
use crate::time::Instant;
|
||||
|
||||
/// A virtual Ethernet interface.
|
||||
#[derive(Debug)]
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use Result;
|
||||
use wire::pretty_print::{PrettyPrint, PrettyPrinter};
|
||||
use phy::{self, DeviceCapabilities, Device};
|
||||
use time::Instant;
|
||||
use crate::Result;
|
||||
use crate::wire::pretty_print::{PrettyPrint, PrettyPrinter};
|
||||
use crate::phy::{self, DeviceCapabilities, Device};
|
||||
use crate::time::Instant;
|
||||
|
||||
/// A tracer device.
|
||||
///
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
use core::cmp;
|
||||
|
||||
use {Error, Result};
|
||||
use phy::{ChecksumCapabilities, DeviceCapabilities};
|
||||
use socket::{Socket, SocketMeta, SocketHandle, PollAt};
|
||||
use storage::{PacketBuffer, PacketMetadata};
|
||||
use wire::{IpAddress, IpEndpoint, IpProtocol, IpRepr};
|
||||
#[cfg(feature = "async")]
|
||||
use socket::WakerRegistration;
|
||||
#[cfg(feature = "async")]
|
||||
use core::task::Waker;
|
||||
|
||||
use crate::{Error, Result};
|
||||
use crate::phy::{ChecksumCapabilities, DeviceCapabilities};
|
||||
use crate::socket::{Socket, SocketMeta, SocketHandle, PollAt};
|
||||
use crate::storage::{PacketBuffer, PacketMetadata};
|
||||
#[cfg(feature = "async")]
|
||||
use crate::socket::WakerRegistration;
|
||||
|
||||
#[cfg(feature = "proto-ipv4")]
|
||||
use wire::{Ipv4Address, Ipv4Repr, Icmpv4Packet, Icmpv4Repr};
|
||||
use crate::wire::{Ipv4Address, Ipv4Repr, Icmpv4Packet, Icmpv4Repr};
|
||||
#[cfg(feature = "proto-ipv6")]
|
||||
use wire::{Ipv6Address, Ipv6Repr, Icmpv6Packet, Icmpv6Repr};
|
||||
use wire::IcmpRepr;
|
||||
use wire::{UdpPacket, UdpRepr};
|
||||
use crate::wire::{Ipv6Address, Ipv6Repr, Icmpv6Packet, Icmpv6Repr};
|
||||
use crate::wire::IcmpRepr;
|
||||
use crate::wire::{UdpPacket, UdpRepr};
|
||||
use crate::wire::{IpAddress, IpEndpoint, IpProtocol, IpRepr};
|
||||
|
||||
/// Type of endpoint to bind the ICMP socket to. See [IcmpSocket::bind] for
|
||||
/// more details.
|
||||
|
@ -463,8 +463,8 @@ impl<'a, 'b> Into<Socket<'a, 'b>> for IcmpSocket<'a, 'b> {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests_common {
|
||||
pub use phy::DeviceCapabilities;
|
||||
pub use wire::IpAddress;
|
||||
pub use crate::phy::DeviceCapabilities;
|
||||
pub use crate::wire::IpAddress;
|
||||
pub use super::*;
|
||||
|
||||
pub fn buffer(packets: usize) -> IcmpSocketBuffer<'static, 'static> {
|
||||
|
@ -489,7 +489,7 @@ mod tests_common {
|
|||
mod test_ipv4 {
|
||||
use super::tests_common::*;
|
||||
|
||||
use wire::Icmpv4DstUnreachable;
|
||||
use crate::wire::Icmpv4DstUnreachable;
|
||||
|
||||
const REMOTE_IPV4: Ipv4Address = Ipv4Address([0x7f, 0x00, 0x00, 0x02]);
|
||||
const LOCAL_IPV4: Ipv4Address = Ipv4Address([0x7f, 0x00, 0x00, 0x01]);
|
||||
|
@ -687,7 +687,7 @@ mod test_ipv4 {
|
|||
mod test_ipv6 {
|
||||
use super::tests_common::*;
|
||||
|
||||
use wire::Icmpv6DstUnreachable;
|
||||
use crate::wire::Icmpv6DstUnreachable;
|
||||
|
||||
const REMOTE_IPV6: Ipv6Address = Ipv6Address([0xfe, 0x80, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 1]);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use wire::IpAddress;
|
||||
use super::{SocketHandle, PollAt};
|
||||
use time::{Duration, Instant};
|
||||
use crate::wire::IpAddress;
|
||||
use crate::socket::{SocketHandle, PollAt};
|
||||
use crate::time::{Duration, Instant};
|
||||
|
||||
/// Neighbor dependency.
|
||||
///
|
||||
|
|
|
@ -12,7 +12,7 @@ size for a buffer, allocate it, and let the networking stack use it.
|
|||
*/
|
||||
|
||||
use core::marker::PhantomData;
|
||||
use time::Instant;
|
||||
use crate::time::Instant;
|
||||
|
||||
mod meta;
|
||||
#[cfg(feature = "socket-raw")]
|
||||
|
|
|
@ -1,19 +1,20 @@
|
|||
use core::cmp::min;
|
||||
|
||||
use {Error, Result};
|
||||
use phy::ChecksumCapabilities;
|
||||
use socket::{Socket, SocketMeta, SocketHandle, PollAt};
|
||||
use storage::{PacketBuffer, PacketMetadata};
|
||||
use wire::{IpVersion, IpRepr, IpProtocol};
|
||||
#[cfg(feature = "proto-ipv4")]
|
||||
use wire::{Ipv4Repr, Ipv4Packet};
|
||||
#[cfg(feature = "proto-ipv6")]
|
||||
use wire::{Ipv6Repr, Ipv6Packet};
|
||||
#[cfg(feature = "async")]
|
||||
use socket::WakerRegistration;
|
||||
#[cfg(feature = "async")]
|
||||
use core::task::Waker;
|
||||
|
||||
use crate::{Error, Result};
|
||||
use crate::phy::ChecksumCapabilities;
|
||||
use crate::socket::{Socket, SocketMeta, SocketHandle, PollAt};
|
||||
use crate::storage::{PacketBuffer, PacketMetadata};
|
||||
#[cfg(feature = "async")]
|
||||
use crate::socket::WakerRegistration;
|
||||
|
||||
use crate::wire::{IpVersion, IpRepr, IpProtocol};
|
||||
#[cfg(feature = "proto-ipv4")]
|
||||
use crate::wire::{Ipv4Repr, Ipv4Packet};
|
||||
#[cfg(feature = "proto-ipv6")]
|
||||
use crate::wire::{Ipv6Repr, Ipv6Packet};
|
||||
|
||||
/// A UDP packet metadata.
|
||||
pub type RawPacketMetadata = PacketMetadata<()>;
|
||||
|
||||
|
@ -304,11 +305,11 @@ impl<'a, 'b> Into<Socket<'a, 'b>> for RawSocket<'a, 'b> {
|
|||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use wire::IpRepr;
|
||||
use crate::wire::IpRepr;
|
||||
#[cfg(feature = "proto-ipv4")]
|
||||
use wire::{Ipv4Address, Ipv4Repr};
|
||||
use crate::wire::{Ipv4Address, Ipv4Repr};
|
||||
#[cfg(feature = "proto-ipv6")]
|
||||
use wire::{Ipv6Address, Ipv6Repr};
|
||||
use crate::wire::{Ipv6Address, Ipv6Repr};
|
||||
use super::*;
|
||||
|
||||
fn buffer(packets: usize) -> RawSocketBuffer<'static, 'static> {
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
use core::ops::{Deref, DerefMut};
|
||||
|
||||
#[cfg(feature = "socket-raw")]
|
||||
use socket::RawSocket;
|
||||
use crate::socket::RawSocket;
|
||||
#[cfg(all(feature = "socket-icmp", any(feature = "proto-ipv4", feature = "proto-ipv6")))]
|
||||
use socket::IcmpSocket;
|
||||
use crate::socket::IcmpSocket;
|
||||
#[cfg(feature = "socket-udp")]
|
||||
use socket::UdpSocket;
|
||||
use crate::socket::UdpSocket;
|
||||
#[cfg(feature = "socket-tcp")]
|
||||
use socket::TcpSocket;
|
||||
use crate::socket::TcpSocket;
|
||||
|
||||
/// A trait for tracking a socket usage session.
|
||||
///
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
use core::{fmt, slice};
|
||||
use managed::ManagedSlice;
|
||||
|
||||
use super::{Socket, SocketRef, AnySocket};
|
||||
use crate::socket::{Socket, SocketRef, AnySocket};
|
||||
#[cfg(feature = "socket-tcp")]
|
||||
use super::TcpState;
|
||||
use crate::socket::TcpState;
|
||||
|
||||
/// An item of a socket set.
|
||||
///
|
||||
|
|
|
@ -3,18 +3,18 @@
|
|||
// a new feature.
|
||||
|
||||
use core::{cmp, fmt, mem};
|
||||
|
||||
use {Error, Result};
|
||||
use phy::DeviceCapabilities;
|
||||
use time::{Duration, Instant};
|
||||
use socket::{Socket, SocketMeta, SocketHandle, PollAt};
|
||||
use storage::{Assembler, RingBuffer};
|
||||
use wire::{IpProtocol, IpRepr, IpAddress, IpEndpoint, TcpSeqNumber, TcpRepr, TcpControl};
|
||||
#[cfg(feature = "async")]
|
||||
use socket::WakerRegistration;
|
||||
#[cfg(feature = "async")]
|
||||
use core::task::Waker;
|
||||
|
||||
use crate::{Error, Result};
|
||||
use crate::phy::DeviceCapabilities;
|
||||
use crate::time::{Duration, Instant};
|
||||
use crate::socket::{Socket, SocketMeta, SocketHandle, PollAt};
|
||||
use crate::storage::{Assembler, RingBuffer};
|
||||
#[cfg(feature = "async")]
|
||||
use crate::socket::WakerRegistration;
|
||||
use crate::wire::{IpProtocol, IpRepr, IpAddress, IpEndpoint, TcpSeqNumber, TcpRepr, TcpControl};
|
||||
|
||||
/// A TCP socket ring buffer.
|
||||
pub type SocketBuffer<'a> = RingBuffer<'a, u8>;
|
||||
|
||||
|
@ -1802,8 +1802,8 @@ impl<'a> fmt::Write for TcpSocket<'a> {
|
|||
mod test {
|
||||
use core::i32;
|
||||
use std::vec::Vec;
|
||||
use wire::{IpAddress, IpRepr, IpCidr};
|
||||
use wire::ip::test::{MOCK_IP_ADDR_1, MOCK_IP_ADDR_2, MOCK_IP_ADDR_3, MOCK_UNSPECIFIED};
|
||||
use crate::wire::{IpAddress, IpRepr, IpCidr};
|
||||
use crate::wire::ip::test::{MOCK_IP_ADDR_1, MOCK_IP_ADDR_2, MOCK_IP_ADDR_3, MOCK_UNSPECIFIED};
|
||||
use super::*;
|
||||
|
||||
// =========================================================================================//
|
||||
|
@ -1950,8 +1950,6 @@ mod test {
|
|||
|
||||
#[cfg(feature = "log")]
|
||||
fn init_logger() {
|
||||
extern crate log;
|
||||
|
||||
struct Logger;
|
||||
static LOGGER: Logger = Logger;
|
||||
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
use core::cmp::min;
|
||||
|
||||
use {Error, Result};
|
||||
use socket::{Socket, SocketMeta, SocketHandle, PollAt};
|
||||
use storage::{PacketBuffer, PacketMetadata};
|
||||
use wire::{IpProtocol, IpRepr, IpEndpoint, UdpRepr};
|
||||
#[cfg(feature = "async")]
|
||||
use socket::WakerRegistration;
|
||||
#[cfg(feature = "async")]
|
||||
use core::task::Waker;
|
||||
|
||||
use crate::{Error, Result};
|
||||
use crate::socket::{Socket, SocketMeta, SocketHandle, PollAt};
|
||||
use crate::storage::{PacketBuffer, PacketMetadata};
|
||||
use crate::wire::{IpProtocol, IpRepr, IpEndpoint, UdpRepr};
|
||||
#[cfg(feature = "async")]
|
||||
use crate::socket::WakerRegistration;
|
||||
|
||||
/// A UDP packet metadata.
|
||||
pub type UdpPacketMetadata = PacketMetadata<IpEndpoint>;
|
||||
|
||||
|
@ -344,12 +344,12 @@ impl<'a, 'b> Into<Socket<'a, 'b>> for UdpSocket<'a, 'b> {
|
|||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use wire::{IpAddress, IpRepr, UdpRepr};
|
||||
use crate::wire::{IpAddress, IpRepr, UdpRepr};
|
||||
#[cfg(feature = "proto-ipv4")]
|
||||
use wire::Ipv4Repr;
|
||||
use crate::wire::Ipv4Repr;
|
||||
#[cfg(feature = "proto-ipv6")]
|
||||
use wire::Ipv6Repr;
|
||||
use wire::ip::test::{MOCK_IP_ADDR_1, MOCK_IP_ADDR_2, MOCK_IP_ADDR_3};
|
||||
use crate::wire::Ipv6Repr;
|
||||
use crate::wire::ip::test::{MOCK_IP_ADDR_1, MOCK_IP_ADDR_2, MOCK_IP_ADDR_3};
|
||||
use super::*;
|
||||
|
||||
fn buffer(packets: usize) -> UdpSocketBuffer<'static, 'static> {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use managed::ManagedSlice;
|
||||
|
||||
use {Error, Result};
|
||||
use super::RingBuffer;
|
||||
use crate::{Error, Result};
|
||||
use crate::storage::RingBuffer;
|
||||
|
||||
/// Size and header of a packet.
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
use core::cmp;
|
||||
use managed::ManagedSlice;
|
||||
|
||||
use {Error, Result};
|
||||
use super::Resettable;
|
||||
use crate::{Error, Result};
|
||||
use crate::storage::Resettable;
|
||||
|
||||
/// A ring buffer.
|
||||
///
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use core::fmt;
|
||||
use byteorder::{ByteOrder, NetworkEndian};
|
||||
|
||||
use {Error, Result};
|
||||
use crate::{Error, Result};
|
||||
|
||||
pub use super::EthernetProtocol as Protocol;
|
||||
|
||||
|
@ -29,7 +29,7 @@ pub struct Packet<T: AsRef<[u8]>> {
|
|||
mod field {
|
||||
#![allow(non_snake_case)]
|
||||
|
||||
use wire::field::*;
|
||||
use crate::wire::field::*;
|
||||
|
||||
pub const HTYPE: Field = 0..2;
|
||||
pub const PTYPE: Field = 2..4;
|
||||
|
@ -248,7 +248,7 @@ impl<T: AsRef<[u8]>> AsRef<[u8]> for Packet<T> {
|
|||
}
|
||||
}
|
||||
|
||||
use super::{EthernetAddress, Ipv4Address};
|
||||
use crate::wire::{EthernetAddress, Ipv4Address};
|
||||
|
||||
/// A high-level representation of an Address Resolution Protocol packet.
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
|
||||
|
@ -356,7 +356,7 @@ impl fmt::Display for Repr {
|
|||
}
|
||||
}
|
||||
|
||||
use super::pretty_print::{PrettyPrint, PrettyIndent};
|
||||
use crate::wire::pretty_print::{PrettyPrint, PrettyIndent};
|
||||
|
||||
impl<T: AsRef<[u8]>> PrettyPrint for Packet<T> {
|
||||
fn pretty_print(buffer: &dyn AsRef<[u8]>, f: &mut fmt::Formatter,
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
use byteorder::{ByteOrder, NetworkEndian};
|
||||
|
||||
use {Error, Result};
|
||||
use super::{EthernetAddress, Ipv4Address};
|
||||
use super::arp::Hardware;
|
||||
use crate::{Error, Result};
|
||||
use crate::wire::{EthernetAddress, Ipv4Address};
|
||||
use crate::wire::arp::Hardware;
|
||||
|
||||
const DHCP_MAGIC_NUMBER: u32 = 0x63825363;
|
||||
|
||||
|
@ -199,7 +199,7 @@ pub(crate) mod field {
|
|||
#![allow(non_snake_case)]
|
||||
#![allow(unused)]
|
||||
|
||||
use wire::field::*;
|
||||
use crate::wire::field::*;
|
||||
|
||||
pub const OP: usize = 0;
|
||||
pub const HTYPE: usize = 1;
|
||||
|
@ -836,7 +836,7 @@ impl<'a> Repr<'a> {
|
|||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use wire::Ipv4Address;
|
||||
use crate::wire::Ipv4Address;
|
||||
use super::*;
|
||||
|
||||
const MAGIC_COOKIE: u32 = 0x63825363;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use core::fmt;
|
||||
use byteorder::{ByteOrder, NetworkEndian};
|
||||
|
||||
use {Error, Result};
|
||||
use crate::{Error, Result};
|
||||
|
||||
enum_with_unknown! {
|
||||
/// Ethernet protocol type.
|
||||
|
@ -83,7 +83,7 @@ pub struct Frame<T: AsRef<[u8]>> {
|
|||
}
|
||||
|
||||
mod field {
|
||||
use wire::field::*;
|
||||
use crate::wire::field::*;
|
||||
|
||||
pub const DESTINATION: Field = 0..6;
|
||||
pub const SOURCE: Field = 6..12;
|
||||
|
@ -209,7 +209,7 @@ impl<T: AsRef<[u8]>> fmt::Display for Frame<T> {
|
|||
}
|
||||
}
|
||||
|
||||
use super::pretty_print::{PrettyPrint, PrettyIndent};
|
||||
use crate::wire::pretty_print::{PrettyPrint, PrettyIndent};
|
||||
|
||||
impl<T: AsRef<[u8]>> PrettyPrint for Frame<T> {
|
||||
fn pretty_print(buffer: &dyn AsRef<[u8]>, f: &mut fmt::Formatter,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#[cfg(feature = "proto-ipv4")]
|
||||
use super::icmpv4;
|
||||
use crate::wire::icmpv4;
|
||||
#[cfg(feature = "proto-ipv6")]
|
||||
use super::icmpv6;
|
||||
use crate::wire::icmpv6;
|
||||
|
||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||
pub enum Repr<'a> {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
use core::{cmp, fmt};
|
||||
use byteorder::{ByteOrder, NetworkEndian};
|
||||
|
||||
use {Error, Result};
|
||||
use phy::ChecksumCapabilities;
|
||||
use super::ip::checksum;
|
||||
use super::{Ipv4Packet, Ipv4Repr};
|
||||
use crate::{Error, Result};
|
||||
use crate::phy::ChecksumCapabilities;
|
||||
use crate::wire::ip::checksum;
|
||||
use crate::wire::{Ipv4Packet, Ipv4Repr};
|
||||
|
||||
enum_with_unknown! {
|
||||
/// Internet protocol control message type.
|
||||
|
@ -172,7 +172,7 @@ pub struct Packet<T: AsRef<[u8]>> {
|
|||
}
|
||||
|
||||
mod field {
|
||||
use wire::field::*;
|
||||
use crate::wire::field::*;
|
||||
|
||||
pub const TYPE: usize = 0;
|
||||
pub const CODE: usize = 1;
|
||||
|
@ -531,7 +531,7 @@ impl<'a> fmt::Display for Repr<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
use super::pretty_print::{PrettyPrint, PrettyIndent};
|
||||
use crate::wire::pretty_print::{PrettyPrint, PrettyIndent};
|
||||
|
||||
impl<T: AsRef<[u8]>> PrettyPrint for Packet<T> {
|
||||
fn pretty_print(buffer: &dyn AsRef<[u8]>, f: &mut fmt::Formatter,
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
use core::{cmp, fmt};
|
||||
use byteorder::{ByteOrder, NetworkEndian};
|
||||
|
||||
use {Error, Result};
|
||||
use phy::ChecksumCapabilities;
|
||||
use super::ip::checksum;
|
||||
use super::{IpAddress, IpProtocol, Ipv6Packet, Ipv6Repr};
|
||||
use super::MldRepr;
|
||||
use crate::{Error, Result};
|
||||
use crate::phy::ChecksumCapabilities;
|
||||
use crate::wire::ip::checksum;
|
||||
use crate::wire::{IpAddress, IpProtocol, Ipv6Packet, Ipv6Repr};
|
||||
use crate::wire::MldRepr;
|
||||
#[cfg(feature = "ethernet")]
|
||||
use super::NdiscRepr;
|
||||
use crate::wire::NdiscRepr;
|
||||
|
||||
enum_with_unknown! {
|
||||
/// Internet protocol control message type.
|
||||
|
@ -197,7 +197,7 @@ pub struct Packet<T: AsRef<[u8]>> {
|
|||
|
||||
// Ranges and constants describing key boundaries in the ICMPv6 header.
|
||||
pub(super) mod field {
|
||||
use wire::field::*;
|
||||
use crate::wire::field::*;
|
||||
|
||||
// ICMPv6: See https://tools.ietf.org/html/rfc4443
|
||||
pub const TYPE: usize = 0;
|
||||
|
@ -739,8 +739,8 @@ impl<'a> Repr<'a> {
|
|||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use wire::{Ipv6Address, Ipv6Repr, IpProtocol};
|
||||
use wire::ip::test::{MOCK_IP_ADDR_1, MOCK_IP_ADDR_2};
|
||||
use crate::wire::{Ipv6Address, Ipv6Repr, IpProtocol};
|
||||
use crate::wire::ip::test::{MOCK_IP_ADDR_1, MOCK_IP_ADDR_2};
|
||||
use super::*;
|
||||
|
||||
static ECHO_PACKET_BYTES: [u8; 12] =
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
use core::fmt;
|
||||
use byteorder::{ByteOrder, NetworkEndian};
|
||||
|
||||
use {Error, Result};
|
||||
use super::ip::checksum;
|
||||
use time::Duration;
|
||||
use crate::{Error, Result};
|
||||
use crate::wire::ip::checksum;
|
||||
use crate::time::Duration;
|
||||
|
||||
use wire::Ipv4Address;
|
||||
use crate::wire::Ipv4Address;
|
||||
|
||||
enum_with_unknown! {
|
||||
/// Internet Group Management Protocol v1/v2 message version/type.
|
||||
|
@ -28,7 +28,7 @@ pub struct Packet<T: AsRef<[u8]>> {
|
|||
}
|
||||
|
||||
mod field {
|
||||
use wire::field::*;
|
||||
use crate::wire::field::*;
|
||||
|
||||
pub const TYPE: usize = 0;
|
||||
pub const MAX_RESP_CODE: usize = 1;
|
||||
|
@ -355,7 +355,7 @@ impl<'a> fmt::Display for Repr {
|
|||
}
|
||||
}
|
||||
|
||||
use super::pretty_print::{PrettyIndent, PrettyPrint};
|
||||
use crate::wire::pretty_print::{PrettyIndent, PrettyPrint};
|
||||
|
||||
impl<T: AsRef<[u8]>> PrettyPrint for Packet<T> {
|
||||
fn pretty_print(buffer: &dyn AsRef<[u8]>,
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use core::fmt;
|
||||
use core::convert::From;
|
||||
|
||||
use {Error, Result};
|
||||
use phy::ChecksumCapabilities;
|
||||
use crate::{Error, Result};
|
||||
use crate::phy::ChecksumCapabilities;
|
||||
#[cfg(feature = "proto-ipv4")]
|
||||
use super::{Ipv4Address, Ipv4Packet, Ipv4Repr, Ipv4Cidr};
|
||||
use crate::wire::{Ipv4Address, Ipv4Packet, Ipv4Repr, Ipv4Cidr};
|
||||
#[cfg(feature = "proto-ipv6")]
|
||||
use super::{Ipv6Address, Ipv6Cidr, Ipv6Packet, Ipv6Repr};
|
||||
use crate::wire::{Ipv6Address, Ipv6Cidr, Ipv6Packet, Ipv6Repr};
|
||||
|
||||
/// Internet protocol version.
|
||||
#[derive(Debug, Hash, PartialEq, Eq, PartialOrd, Ord, Clone, Copy)]
|
||||
|
@ -862,16 +862,16 @@ pub mod checksum {
|
|||
}
|
||||
}
|
||||
|
||||
use super::pretty_print::PrettyIndent;
|
||||
use crate::wire::pretty_print::PrettyIndent;
|
||||
|
||||
pub fn pretty_print_ip_payload<T: Into<Repr>>(f: &mut fmt::Formatter, indent: &mut PrettyIndent,
|
||||
ip_repr: T, payload: &[u8]) -> fmt::Result {
|
||||
#[cfg(feature = "proto-ipv4")]
|
||||
use wire::Icmpv4Packet;
|
||||
use crate::wire::Icmpv4Packet;
|
||||
#[cfg(feature = "proto-ipv4")]
|
||||
use super::pretty_print::PrettyPrint;
|
||||
use wire::{TcpPacket, TcpRepr, UdpPacket, UdpRepr};
|
||||
use wire::ip::checksum::format_checksum;
|
||||
use crate::wire::{TcpPacket, TcpRepr, UdpPacket, UdpRepr};
|
||||
use crate::wire::ip::checksum::format_checksum;
|
||||
|
||||
let checksum_caps = ChecksumCapabilities::ignored();
|
||||
let repr = ip_repr.into();
|
||||
|
@ -953,9 +953,9 @@ pub(crate) mod test {
|
|||
|
||||
|
||||
use super::*;
|
||||
use wire::{IpAddress, IpProtocol,IpCidr};
|
||||
use crate::wire::{IpAddress, IpProtocol,IpCidr};
|
||||
#[cfg(feature = "proto-ipv4")]
|
||||
use wire::{Ipv4Address, Ipv4Repr};
|
||||
use crate::wire::{Ipv4Address, Ipv4Repr};
|
||||
|
||||
macro_rules! generate_common_tests {
|
||||
($name:ident, $repr:ident, $ip_repr:path, $ip_addr:path,
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
use core::fmt;
|
||||
use byteorder::{ByteOrder, NetworkEndian};
|
||||
|
||||
use {Error, Result};
|
||||
use phy::ChecksumCapabilities;
|
||||
use super::ip::{checksum, pretty_print_ip_payload};
|
||||
use crate::{Error, Result};
|
||||
use crate::phy::ChecksumCapabilities;
|
||||
use crate::wire::ip::{checksum, pretty_print_ip_payload};
|
||||
|
||||
pub use super::IpProtocol as Protocol;
|
||||
|
||||
|
@ -231,7 +231,7 @@ pub struct Packet<T: AsRef<[u8]>> {
|
|||
}
|
||||
|
||||
mod field {
|
||||
use wire::field::*;
|
||||
use crate::wire::field::*;
|
||||
|
||||
pub const VER_IHL: usize = 0;
|
||||
pub const DSCP_ECN: usize = 1;
|
||||
|
@ -662,12 +662,12 @@ impl fmt::Display for Repr {
|
|||
}
|
||||
}
|
||||
|
||||
use super::pretty_print::{PrettyPrint, PrettyIndent};
|
||||
use crate::wire::pretty_print::{PrettyPrint, PrettyIndent};
|
||||
|
||||
impl<T: AsRef<[u8]>> PrettyPrint for Packet<T> {
|
||||
fn pretty_print(buffer: &dyn AsRef<[u8]>, f: &mut fmt::Formatter,
|
||||
indent: &mut PrettyIndent) -> fmt::Result {
|
||||
use wire::ip::checksum::format_checksum;
|
||||
use crate::wire::ip::checksum::format_checksum;
|
||||
|
||||
let checksum_caps = ChecksumCapabilities::ignored();
|
||||
|
||||
|
|
|
@ -3,9 +3,12 @@
|
|||
use core::fmt;
|
||||
use byteorder::{ByteOrder, NetworkEndian};
|
||||
|
||||
use {Error, Result};
|
||||
use crate::{Error, Result};
|
||||
use crate::wire::ip::pretty_print_ip_payload;
|
||||
#[cfg(feature = "proto-ipv4")]
|
||||
use crate::wire::ipv4;
|
||||
|
||||
pub use super::IpProtocol as Protocol;
|
||||
use super::ip::pretty_print_ip_payload;
|
||||
|
||||
/// Minimum MTU required of all links supporting IPv6. See [RFC 8200 § 5].
|
||||
///
|
||||
|
@ -144,9 +147,9 @@ impl Address {
|
|||
|
||||
#[cfg(feature = "proto-ipv4")]
|
||||
/// Convert an IPv4 mapped IPv6 address to an IPv4 address.
|
||||
pub fn as_ipv4(&self) -> Option<::wire::ipv4::Address> {
|
||||
pub fn as_ipv4(&self) -> Option<ipv4::Address> {
|
||||
if self.is_ipv4_mapped() {
|
||||
Some(::wire::ipv4::Address::new(self.0[12], self.0[13], self.0[14], self.0[15]))
|
||||
Some(ipv4::Address::new(self.0[12], self.0[13], self.0[14], self.0[15]))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
@ -254,8 +257,8 @@ impl fmt::Display for Address {
|
|||
|
||||
#[cfg(feature = "proto-ipv4")]
|
||||
/// Convert the given IPv4 address into a IPv4-mapped IPv6 address
|
||||
impl From<::wire::ipv4::Address> for Address {
|
||||
fn from(address: ::wire::ipv4::Address) -> Self {
|
||||
impl From<ipv4::Address> for Address {
|
||||
fn from(address: ipv4::Address) -> Self {
|
||||
let octets = address.0;
|
||||
Address([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff,
|
||||
octets[0], octets[1], octets[2], octets[3]])
|
||||
|
@ -356,7 +359,7 @@ pub struct Packet<T: AsRef<[u8]>> {
|
|||
//
|
||||
// See https://tools.ietf.org/html/rfc2460#section-3 for details.
|
||||
mod field {
|
||||
use wire::field::*;
|
||||
use crate::wire::field::*;
|
||||
// 4-bit version number, 8-bit traffic class, and the
|
||||
// 20-bit flow label.
|
||||
pub const VER_TC_FLOW: Field = 0..4;
|
||||
|
@ -647,7 +650,7 @@ impl fmt::Display for Repr {
|
|||
}
|
||||
}
|
||||
|
||||
use super::pretty_print::{PrettyPrint, PrettyIndent};
|
||||
use crate::wire::pretty_print::{PrettyPrint, PrettyIndent};
|
||||
|
||||
// TODO: This is very similar to the implementation for IPv4. Make
|
||||
// a way to have less copy and pasted code here.
|
||||
|
@ -673,13 +676,13 @@ impl<T: AsRef<[u8]>> PrettyPrint for Packet<T> {
|
|||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use Error;
|
||||
use crate::Error;
|
||||
use super::{Address, Cidr};
|
||||
use super::{Packet, Protocol, Repr};
|
||||
use wire::pretty_print::{PrettyPrinter};
|
||||
use crate::wire::pretty_print::{PrettyPrinter};
|
||||
|
||||
#[cfg(feature = "proto-ipv4")]
|
||||
use wire::ipv4::Address as Ipv4Address;
|
||||
use crate::wire::ipv4::Address as Ipv4Address;
|
||||
|
||||
static LINK_LOCAL_ADDR: Address = Address([0xfe, 0x80, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use core::fmt;
|
||||
use {Error, Result};
|
||||
use crate::{Error, Result};
|
||||
|
||||
use byteorder::{ByteOrder, NetworkEndian};
|
||||
|
||||
|
@ -21,7 +21,7 @@ pub struct Header<T: AsRef<[u8]>> {
|
|||
//
|
||||
// See https://tools.ietf.org/html/rfc8200#section-4.5 for details.
|
||||
mod field {
|
||||
use wire::field::*;
|
||||
use crate::wire::field::*;
|
||||
|
||||
// 8-bit identifier of the header immediately following this header.
|
||||
pub const NXT_HDR: usize = 0;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use core::fmt;
|
||||
use {Error, Result};
|
||||
use crate::{Error, Result};
|
||||
|
||||
use super::ipv6option::Ipv6OptionsIterator;
|
||||
use crate::wire::ipv6option::Ipv6OptionsIterator;
|
||||
pub use super::IpProtocol as Protocol;
|
||||
|
||||
/// A read/write wrapper around an IPv6 Hop-by-Hop Options Header.
|
||||
|
@ -27,7 +27,7 @@ pub struct Header<T: AsRef<[u8]>> {
|
|||
mod field {
|
||||
#![allow(non_snake_case)]
|
||||
|
||||
use wire::field::*;
|
||||
use crate::wire::field::*;
|
||||
|
||||
// Minimum size of the header.
|
||||
pub const MIN_HEADER_SIZE: usize = 8;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use core::fmt;
|
||||
use {Error, Result};
|
||||
use crate::{Error, Result};
|
||||
|
||||
enum_with_unknown! {
|
||||
/// IPv6 Extension Header Option Type
|
||||
|
@ -73,7 +73,7 @@ pub struct Ipv6Option<T: AsRef<[u8]>> {
|
|||
mod field {
|
||||
#![allow(non_snake_case)]
|
||||
|
||||
use wire::field::*;
|
||||
use crate::wire::field::*;
|
||||
|
||||
// 8-bit identifier of the type of option.
|
||||
pub const TYPE: usize = 0;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use core::fmt;
|
||||
use {Error, Result};
|
||||
use crate::{Error, Result};
|
||||
|
||||
use super::IpProtocol as Protocol;
|
||||
use super::Ipv6Address as Address;
|
||||
use crate::wire::IpProtocol as Protocol;
|
||||
use crate::wire::Ipv6Address as Address;
|
||||
|
||||
enum_with_unknown! {
|
||||
/// IPv6 Extension Routing Header Routing Type
|
||||
|
@ -72,7 +72,7 @@ pub struct Header<T: AsRef<[u8]>> {
|
|||
mod field {
|
||||
#![allow(non_snake_case)]
|
||||
|
||||
use wire::field::*;
|
||||
use crate::wire::field::*;
|
||||
|
||||
// Minimum size of the header.
|
||||
pub const MIN_HEADER_SIZE: usize = 4;
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
|
||||
use byteorder::{ByteOrder, NetworkEndian};
|
||||
|
||||
use {Error, Result};
|
||||
use super::icmpv6::{field, Message, Packet};
|
||||
use super::Ipv6Address;
|
||||
use crate::{Error, Result};
|
||||
use crate::wire::icmpv6::{field, Message, Packet};
|
||||
use crate::wire::Ipv6Address;
|
||||
|
||||
enum_with_unknown! {
|
||||
/// MLDv2 Multicast Listener Report Record Type. See [RFC 3810 § 5.2.12] for
|
||||
|
@ -383,9 +383,9 @@ impl<'a> Repr<'a> {
|
|||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use phy::ChecksumCapabilities;
|
||||
use wire::Icmpv6Repr;
|
||||
use wire::icmpv6::Message;
|
||||
use crate::phy::ChecksumCapabilities;
|
||||
use crate::wire::Icmpv6Repr;
|
||||
use crate::wire::icmpv6::Message;
|
||||
use super::*;
|
||||
|
||||
static QUERY_PACKET_BYTES: [u8; 44] =
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
use byteorder::{ByteOrder, NetworkEndian};
|
||||
use bitflags::bitflags;
|
||||
|
||||
use {Error, Result};
|
||||
use super::icmpv6::{field, Message, Packet};
|
||||
use wire::{EthernetAddress, Ipv6Repr, Ipv6Packet};
|
||||
use wire::{NdiscOption, NdiscOptionRepr, NdiscOptionType};
|
||||
use wire::{NdiscPrefixInformation, NdiscRedirectedHeader};
|
||||
use time::Duration;
|
||||
use super::Ipv6Address;
|
||||
use crate::{Error, Result};
|
||||
use crate::wire::icmpv6::{field, Message, Packet};
|
||||
use crate::wire::{EthernetAddress, Ipv6Repr, Ipv6Packet};
|
||||
use crate::wire::{NdiscOption, NdiscOptionRepr, NdiscOptionType};
|
||||
use crate::wire::{NdiscPrefixInformation, NdiscRedirectedHeader};
|
||||
use crate::time::Duration;
|
||||
use crate::wire::Ipv6Address;
|
||||
|
||||
bitflags! {
|
||||
pub struct RouterFlags: u8 {
|
||||
|
@ -462,10 +463,10 @@ impl<'a> Repr<'a> {
|
|||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use phy::ChecksumCapabilities;
|
||||
use crate::phy::ChecksumCapabilities;
|
||||
use super::*;
|
||||
use wire::Icmpv6Repr;
|
||||
use wire::ip::test::{MOCK_IP_ADDR_1, MOCK_IP_ADDR_2};
|
||||
use crate::wire::Icmpv6Repr;
|
||||
use crate::wire::ip::test::{MOCK_IP_ADDR_1, MOCK_IP_ADDR_2};
|
||||
|
||||
static ROUTER_ADVERT_BYTES: [u8; 24] =
|
||||
[0x86, 0x00, 0xa9, 0xde,
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
use core::fmt;
|
||||
use byteorder::{NetworkEndian, ByteOrder};
|
||||
use bitflags::bitflags;
|
||||
|
||||
use {Error, Result};
|
||||
use time::Duration;
|
||||
use wire::{EthernetAddress, Ipv6Address, Ipv6Packet, Ipv6Repr};
|
||||
use crate::{Error, Result};
|
||||
use crate::time::Duration;
|
||||
use crate::wire::{EthernetAddress, Ipv6Address, Ipv6Packet, Ipv6Repr};
|
||||
|
||||
enum_with_unknown! {
|
||||
/// NDISC Option Type
|
||||
|
@ -61,7 +62,7 @@ pub struct NdiscOption<T: AsRef<[u8]>> {
|
|||
mod field {
|
||||
#![allow(non_snake_case)]
|
||||
|
||||
use wire::field::*;
|
||||
use crate::wire::field::*;
|
||||
|
||||
// 8-bit identifier of the type of option.
|
||||
pub const TYPE: usize = 0;
|
||||
|
@ -587,7 +588,7 @@ impl<'a> fmt::Display for Repr<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
use super::pretty_print::{PrettyPrint, PrettyIndent};
|
||||
use crate::wire::pretty_print::{PrettyPrint, PrettyIndent};
|
||||
|
||||
impl<T: AsRef<[u8]>> PrettyPrint for NdiscOption<T> {
|
||||
fn pretty_print(buffer: &dyn AsRef<[u8]>, f: &mut fmt::Formatter,
|
||||
|
@ -608,9 +609,9 @@ impl<T: AsRef<[u8]>> PrettyPrint for NdiscOption<T> {
|
|||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use Error;
|
||||
use time::Duration;
|
||||
use wire::{EthernetAddress, Ipv6Address};
|
||||
use crate::Error;
|
||||
use crate::time::Duration;
|
||||
use crate::wire::{EthernetAddress, Ipv6Address};
|
||||
use super::{NdiscOption, Type, PrefixInfoFlags, PrefixInformation, Repr};
|
||||
|
||||
static PREFIX_OPT_BYTES: [u8; 32] = [
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
use core::{i32, ops, cmp, fmt};
|
||||
use byteorder::{ByteOrder, NetworkEndian};
|
||||
|
||||
use {Error, Result};
|
||||
use phy::ChecksumCapabilities;
|
||||
use super::{IpProtocol, IpAddress};
|
||||
use super::ip::checksum;
|
||||
use crate::{Error, Result};
|
||||
use crate::phy::ChecksumCapabilities;
|
||||
use crate::wire::{IpProtocol, IpAddress};
|
||||
use crate::wire::ip::checksum;
|
||||
|
||||
/// A TCP sequence number.
|
||||
///
|
||||
|
@ -74,7 +74,7 @@ pub struct Packet<T: AsRef<[u8]>> {
|
|||
mod field {
|
||||
#![allow(non_snake_case)]
|
||||
|
||||
use wire::field::*;
|
||||
use crate::wire::field::*;
|
||||
|
||||
pub const SRC_PORT: Field = 0..2;
|
||||
pub const DST_PORT: Field = 2..4;
|
||||
|
@ -1009,7 +1009,7 @@ impl<'a> fmt::Display for Repr<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
use super::pretty_print::{PrettyPrint, PrettyIndent};
|
||||
use crate::wire::pretty_print::{PrettyPrint, PrettyIndent};
|
||||
|
||||
impl<T: AsRef<[u8]>> PrettyPrint for Packet<T> {
|
||||
fn pretty_print(buffer: &dyn AsRef<[u8]>, f: &mut fmt::Formatter,
|
||||
|
@ -1024,7 +1024,7 @@ impl<T: AsRef<[u8]>> PrettyPrint for Packet<T> {
|
|||
#[cfg(test)]
|
||||
mod test {
|
||||
#[cfg(feature = "proto-ipv4")]
|
||||
use wire::Ipv4Address;
|
||||
use crate::wire::Ipv4Address;
|
||||
use super::*;
|
||||
|
||||
#[cfg(feature = "proto-ipv4")]
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
use core::fmt;
|
||||
use byteorder::{ByteOrder, NetworkEndian};
|
||||
|
||||
use {Error, Result};
|
||||
use phy::ChecksumCapabilities;
|
||||
use super::{IpProtocol, IpAddress};
|
||||
use super::ip::checksum;
|
||||
use crate::{Error, Result};
|
||||
use crate::phy::ChecksumCapabilities;
|
||||
use crate::wire::{IpProtocol, IpAddress};
|
||||
use crate::wire::ip::checksum;
|
||||
|
||||
/// A read/write wrapper around an User Datagram Protocol packet buffer.
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
|
@ -15,7 +15,7 @@ pub struct Packet<T: AsRef<[u8]>> {
|
|||
mod field {
|
||||
#![allow(non_snake_case)]
|
||||
|
||||
use wire::field::*;
|
||||
use crate::wire::field::*;
|
||||
|
||||
pub const SRC_PORT: Field = 0..2;
|
||||
pub const DST_PORT: Field = 2..4;
|
||||
|
@ -272,7 +272,7 @@ impl<'a> fmt::Display for Repr<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
use super::pretty_print::{PrettyPrint, PrettyIndent};
|
||||
use crate::wire::pretty_print::{PrettyPrint, PrettyIndent};
|
||||
|
||||
impl<T: AsRef<[u8]>> PrettyPrint for Packet<T> {
|
||||
fn pretty_print(buffer: &dyn AsRef<[u8]>, f: &mut fmt::Formatter,
|
||||
|
@ -287,7 +287,7 @@ impl<T: AsRef<[u8]>> PrettyPrint for Packet<T> {
|
|||
#[cfg(test)]
|
||||
mod test {
|
||||
#[cfg(feature = "proto-ipv4")]
|
||||
use wire::Ipv4Address;
|
||||
use crate::wire::Ipv4Address;
|
||||
use super::*;
|
||||
|
||||
#[cfg(feature = "proto-ipv4")]
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
extern crate smoltcp;
|
||||
extern crate getopts;
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::io::{self, Read, Write};
|
||||
use std::path::Path;
|
||||
|
|
Loading…
Reference in New Issue