From a9a00baa49bf0ec5be35d493c82f676a83552f37 Mon Sep 17 00:00:00 2001 From: whitequark Date: Wed, 25 Oct 2017 00:20:40 +0000 Subject: [PATCH] =?UTF-8?q?Rename=20Cargo=20features:=20socket-*=20?= =?UTF-8?q?=E2=86=92=20proto-*.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .travis.yml | 16 ++++++++-------- Cargo.toml | 8 ++++---- src/iface/ethernet.rs | 42 +++++++++++++++++++++--------------------- src/lib.rs | 6 +++--- src/socket/mod.rs | 30 +++++++++++++++--------------- src/socket/ref_.rs | 12 ++++++------ src/socket/set.rs | 8 ++++---- 7 files changed, 61 insertions(+), 61 deletions(-) diff --git a/.travis.yml b/.travis.yml index 26ec5da..65e2161 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,21 +10,21 @@ matrix: - rust: nightly env: FEATURES='default' MODE='test' - rust: nightly - env: FEATURES='phy-raw_socket socket-udp' MODE='build' + env: FEATURES='phy-raw_socket proto-udp' MODE='build' - rust: nightly - env: FEATURES='phy-tap_interface socket-udp' MODE='build' + env: FEATURES='phy-tap_interface proto-udp' MODE='build' - rust: nightly - env: FEATURES='socket-raw' MODE='build' + env: FEATURES='proto-raw' MODE='build' - rust: nightly - env: FEATURES='socket-udp' MODE='build' + env: FEATURES='proto-udp' MODE='build' - rust: nightly - env: FEATURES='socket-tcp' MODE='build' + env: FEATURES='proto-tcp' MODE='build' - rust: nightly - env: FEATURES='socket-raw socket-udp socket-tcp' MODE='build' + env: FEATURES='proto-raw proto-udp proto-tcp' MODE='build' - rust: nightly - env: FEATURES='socket-raw socket-udp socket-tcp std' MODE='build' + env: FEATURES='proto-raw proto-udp proto-tcp std' MODE='build' - rust: nightly - env: FEATURES='socket-raw socket-udp socket-tcp alloc' MODE='build' + env: FEATURES='proto-raw proto-udp proto-tcp alloc' MODE='build' script: - cargo "$MODE" --no-default-features --features "$FEATURES" notifications: diff --git a/Cargo.toml b/Cargo.toml index ee6c4f4..f6f1d0e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,12 +28,12 @@ alloc = ["managed/alloc"] verbose = [] "phy-raw_socket" = ["std", "libc"] "phy-tap_interface" = ["std", "libc"] -"socket-raw" = [] -"socket-udp" = [] -"socket-tcp" = [] +"proto-raw" = [] +"proto-udp" = [] +"proto-tcp" = [] default = ["std", "log", "phy-raw_socket", "phy-tap_interface", - "socket-raw", "socket-udp", "socket-tcp"] + "proto-raw", "proto-udp", "proto-tcp"] [[example]] name = "tcpdump" diff --git a/src/iface/ethernet.rs b/src/iface/ethernet.rs index e190754..d9cdad4 100644 --- a/src/iface/ethernet.rs +++ b/src/iface/ethernet.rs @@ -11,12 +11,12 @@ use wire::{IpAddress, IpProtocol, IpRepr, IpCidr}; use wire::{ArpPacket, ArpRepr, ArpOperation}; use wire::{Ipv4Packet, Ipv4Repr}; use wire::{Icmpv4Packet, Icmpv4Repr, Icmpv4DstUnreachable}; -#[cfg(feature = "socket-udp")] use wire::{UdpPacket, UdpRepr}; -#[cfg(feature = "socket-tcp")] use wire::{TcpPacket, TcpRepr, TcpControl}; +#[cfg(feature = "proto-udp")] use wire::{UdpPacket, UdpRepr}; +#[cfg(feature = "proto-tcp")] use wire::{TcpPacket, TcpRepr, TcpControl}; use socket::{Socket, SocketSet, AnySocket}; -#[cfg(feature = "socket-raw")] use socket::RawSocket; -#[cfg(feature = "socket-udp")] use socket::UdpSocket; -#[cfg(feature = "socket-tcp")] use socket::TcpSocket; +#[cfg(feature = "proto-raw")] use socket::RawSocket; +#[cfg(feature = "proto-udp")] use socket::UdpSocket; +#[cfg(feature = "proto-tcp")] use socket::TcpSocket; use super::ArpCache; /// An Ethernet network interface. @@ -36,11 +36,11 @@ enum Packet<'a> { None, Arp(ArpRepr), Icmpv4(Ipv4Repr, Icmpv4Repr<'a>), - #[cfg(feature = "socket-raw")] + #[cfg(feature = "proto-raw")] Raw((IpRepr, &'a [u8])), - #[cfg(feature = "socket-udp")] + #[cfg(feature = "proto-udp")] Udp((IpRepr, UdpRepr<'a>)), - #[cfg(feature = "socket-tcp")] + #[cfg(feature = "proto-tcp")] Tcp((IpRepr, TcpRepr<'a>)) } @@ -203,19 +203,19 @@ impl<'a, 'b, 'c, DeviceT: Device + 'a> Interface<'a, 'b, 'c, DeviceT> { let mut device_result = Ok(()); let socket_result = match *socket { - #[cfg(feature = "socket-raw")] + #[cfg(feature = "proto-raw")] Socket::Raw(ref mut socket) => socket.dispatch(|response| { device_result = self.dispatch(timestamp, Packet::Raw(response)); device_result }, &caps.checksum), - #[cfg(feature = "socket-udp")] + #[cfg(feature = "proto-udp")] Socket::Udp(ref mut socket) => socket.dispatch(|response| { device_result = self.dispatch(timestamp, Packet::Udp(response)); device_result }), - #[cfg(feature = "socket-tcp")] + #[cfg(feature = "proto-tcp")] Socket::Tcp(ref mut socket) => socket.dispatch(timestamp, &caps, |response| { device_result = self.dispatch(timestamp, Packet::Tcp(response)); @@ -322,11 +322,11 @@ impl<'a, 'b, 'c, DeviceT: Device + 'a> Interface<'a, 'b, 'c, DeviceT> { let ip_repr = IpRepr::Ipv4(ipv4_repr); let ip_payload = ipv4_packet.payload(); - #[cfg(feature = "socket-raw")] + #[cfg(feature = "proto-raw")] let mut handled_by_raw_socket = false; // Pass every IP packet to all raw sockets we have registered. - #[cfg(feature = "socket-raw")] + #[cfg(feature = "proto-raw")] for mut raw_socket in sockets.iter_mut().filter_map(RawSocket::downcast) { if !raw_socket.accepts(&ip_repr) { continue } @@ -349,15 +349,15 @@ impl<'a, 'b, 'c, DeviceT: Device + 'a> Interface<'a, 'b, 'c, DeviceT> { IpProtocol::Icmp => self.process_icmpv4(ipv4_repr, ip_payload), - #[cfg(feature = "socket-udp")] + #[cfg(feature = "proto-udp")] IpProtocol::Udp => self.process_udp(sockets, ip_repr, ip_payload), - #[cfg(feature = "socket-tcp")] + #[cfg(feature = "proto-tcp")] IpProtocol::Tcp => self.process_tcp(sockets, _timestamp, ip_repr, ip_payload), - #[cfg(feature = "socket-raw")] + #[cfg(feature = "proto-raw")] _ if handled_by_raw_socket => Ok(Packet::None), @@ -411,7 +411,7 @@ impl<'a, 'b, 'c, DeviceT: Device + 'a> Interface<'a, 'b, 'c, DeviceT> { } } - #[cfg(feature = "socket-udp")] + #[cfg(feature = "proto-udp")] fn process_udp<'frame>(&self, sockets: &mut SocketSet, ip_repr: IpRepr, ip_payload: &'frame [u8]) -> Result> { @@ -454,7 +454,7 @@ impl<'a, 'b, 'c, DeviceT: Device + 'a> Interface<'a, 'b, 'c, DeviceT> { } } - #[cfg(feature = "socket-tcp")] + #[cfg(feature = "proto-tcp")] fn process_tcp<'frame>(&self, sockets: &mut SocketSet, timestamp: u64, ip_repr: IpRepr, ip_payload: &'frame [u8]) -> Result> { @@ -507,13 +507,13 @@ impl<'a, 'b, 'c, DeviceT: Device + 'a> Interface<'a, 'b, 'c, DeviceT> { icmpv4_repr.emit(&mut Icmpv4Packet::new(payload), &checksum_caps); }) } - #[cfg(feature = "socket-raw")] + #[cfg(feature = "proto-raw")] Packet::Raw((ip_repr, raw_packet)) => { self.dispatch_ip(timestamp, ip_repr, |_ip_repr, payload| { payload.copy_from_slice(raw_packet); }) } - #[cfg(feature = "socket-udp")] + #[cfg(feature = "proto-udp")] Packet::Udp((ip_repr, udp_repr)) => { self.dispatch_ip(timestamp, ip_repr, |ip_repr, payload| { udp_repr.emit(&mut UdpPacket::new(payload), @@ -521,7 +521,7 @@ impl<'a, 'b, 'c, DeviceT: Device + 'a> Interface<'a, 'b, 'c, DeviceT> { &checksum_caps); }) } - #[cfg(feature = "socket-tcp")] + #[cfg(feature = "proto-tcp")] Packet::Tcp((ip_repr, mut tcp_repr)) => { let caps = self.device.capabilities(); self.dispatch_ip(timestamp, ip_repr, |ip_repr, payload| { diff --git a/src/lib.rs b/src/lib.rs index 80801de..f6fbbd1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -69,9 +69,9 @@ //! of a packet, it is still logged correctly and in full. /* XXX compiler bug -#![cfg(not(any(feature = "socket-raw", - feature = "socket-udp", - feature = "socket-tcp")))] +#![cfg(not(any(feature = "proto-raw", + feature = "proto-udp", + feature = "proto-tcp")))] compile_error!("at least one socket needs to be enabled"); */ extern crate byteorder; diff --git a/src/socket/mod.rs b/src/socket/mod.rs index 7665f3b..c396a9d 100644 --- a/src/socket/mod.rs +++ b/src/socket/mod.rs @@ -13,23 +13,23 @@ use core::marker::PhantomData; use wire::IpRepr; -#[cfg(feature = "socket-raw")] mod raw; -#[cfg(feature = "socket-udp")] mod udp; -#[cfg(feature = "socket-tcp")] mod tcp; +#[cfg(feature = "proto-raw")] mod raw; +#[cfg(feature = "proto-udp")] mod udp; +#[cfg(feature = "proto-tcp")] mod tcp; mod set; mod ref_; -#[cfg(feature = "socket-raw")] +#[cfg(feature = "proto-raw")] pub use self::raw::{PacketBuffer as RawPacketBuffer, SocketBuffer as RawSocketBuffer, RawSocket}; -#[cfg(feature = "socket-udp")] +#[cfg(feature = "proto-udp")] pub use self::udp::{PacketBuffer as UdpPacketBuffer, SocketBuffer as UdpSocketBuffer, UdpSocket}; -#[cfg(feature = "socket-tcp")] +#[cfg(feature = "proto-tcp")] pub use self::tcp::{SocketBuffer as TcpSocketBuffer, State as TcpState, TcpSocket}; @@ -52,11 +52,11 @@ pub(crate) use self::ref_::Session as SocketSession; /// [SocketSet::get]: struct.SocketSet.html#method.get #[derive(Debug)] pub enum Socket<'a, 'b: 'a> { - #[cfg(feature = "socket-raw")] + #[cfg(feature = "proto-raw")] Raw(RawSocket<'a, 'b>), - #[cfg(feature = "socket-udp")] + #[cfg(feature = "proto-udp")] Udp(UdpSocket<'a, 'b>), - #[cfg(feature = "socket-tcp")] + #[cfg(feature = "proto-tcp")] Tcp(TcpSocket<'a>), #[doc(hidden)] __Nonexhaustive(PhantomData<(&'a (), &'b ())>) @@ -65,11 +65,11 @@ pub enum Socket<'a, 'b: 'a> { macro_rules! dispatch_socket { ($self_:expr, |$socket:ident [$( $mut_:tt )*]| $code:expr) => ({ match $self_ { - #[cfg(feature = "socket-raw")] + #[cfg(feature = "proto-raw")] &$( $mut_ )* Socket::Raw(ref $( $mut_ )* $socket) => $code, - #[cfg(feature = "socket-udp")] + #[cfg(feature = "proto-udp")] &$( $mut_ )* Socket::Udp(ref $( $mut_ )* $socket) => $code, - #[cfg(feature = "socket-tcp")] + #[cfg(feature = "proto-tcp")] &$( $mut_ )* Socket::Tcp(ref $( $mut_ )* $socket) => $code, &$( $mut_ )* Socket::__Nonexhaustive(_) => unreachable!() } @@ -119,9 +119,9 @@ macro_rules! from_socket { } } -#[cfg(feature = "socket-raw")] +#[cfg(feature = "proto-raw")] from_socket!(RawSocket<'a, 'b>, Raw); -#[cfg(feature = "socket-udp")] +#[cfg(feature = "proto-udp")] from_socket!(UdpSocket<'a, 'b>, Udp); -#[cfg(feature = "socket-tcp")] +#[cfg(feature = "proto-tcp")] from_socket!(TcpSocket<'a>, Tcp); diff --git a/src/socket/ref_.rs b/src/socket/ref_.rs index 45b1f07..51e9175 100644 --- a/src/socket/ref_.rs +++ b/src/socket/ref_.rs @@ -1,10 +1,10 @@ use core::ops::{Deref, DerefMut}; -#[cfg(feature = "socket-raw")] +#[cfg(feature = "proto-raw")] use socket::RawSocket; -#[cfg(feature = "socket-udp")] +#[cfg(feature = "proto-udp")] use socket::UdpSocket; -#[cfg(feature = "socket-tcp")] +#[cfg(feature = "proto-tcp")] use socket::TcpSocket; /// A trait for tracking a socket usage session. @@ -17,11 +17,11 @@ pub trait Session { fn finish(&mut self) {} } -#[cfg(feature = "socket-raw")] +#[cfg(feature = "proto-raw")] impl<'a, 'b> Session for RawSocket<'a, 'b> {} -#[cfg(feature = "socket-udp")] +#[cfg(feature = "proto-udp")] impl<'a, 'b> Session for UdpSocket<'a, 'b> {} -#[cfg(feature = "socket-tcp")] +#[cfg(feature = "proto-tcp")] impl<'a> Session for TcpSocket<'a> {} /// A smart pointer to a socket. diff --git a/src/socket/set.rs b/src/socket/set.rs index 78ec018..08a2863 100644 --- a/src/socket/set.rs +++ b/src/socket/set.rs @@ -2,7 +2,7 @@ use core::{fmt, slice}; use managed::ManagedSlice; use super::{Socket, SocketRef, AnySocket}; -#[cfg(feature = "socket-tcp")] use super::TcpState; +#[cfg(feature = "proto-tcp")] use super::TcpState; /// An item of a socket set. /// @@ -140,13 +140,13 @@ impl<'a, 'b: 'a, 'c: 'a + 'b> Set<'a, 'b, 'c> { let mut may_remove = false; if let &mut Some(Item { refs: 0, ref mut socket }) = item { match socket { - #[cfg(feature = "socket-raw")] + #[cfg(feature = "proto-raw")] &mut Socket::Raw(_) => may_remove = true, - #[cfg(feature = "socket-udp")] + #[cfg(feature = "proto-udp")] &mut Socket::Udp(_) => may_remove = true, - #[cfg(feature = "socket-tcp")] + #[cfg(feature = "proto-tcp")] &mut Socket::Tcp(ref mut socket) => if socket.state() == TcpState::Closed { may_remove = true