Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: smoltcp-rs/smoltcp
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: a98a80e5d348
Choose a base ref
...
head repository: smoltcp-rs/smoltcp
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 265e6f6cb70b
Choose a head ref
  • 2 commits
  • 9 files changed
  • 1 contributor

Commits on Jul 30, 2017

  1. Remove unused imports.

    whitequark committed Jul 30, 2017
    Copy the full SHA
    9525e32 View commit details
  2. Copy the full SHA
    265e6f6 View commit details
Showing with 21 additions and 12 deletions.
  1. +2 −1 README.md
  2. +1 −1 examples/server.rs
  3. +1 −1 src/phy/mod.rs
  4. +1 −1 src/phy/pcap_writer.rs
  5. +1 −1 src/phy/raw_socket.rs
  6. +1 −1 src/phy/tracer.rs
  7. +1 −1 src/socket/mod.rs
  8. +3 −2 src/socket/tcp.rs
  9. +10 −3 src/socket/udp.rs
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -208,7 +208,8 @@ It responds to:
* TCP packets on port 6971 (`cat /dev/urandom | socat stdio tcp4-connect:192.168.69.1:6971`),
which will be ignored.

The buffers are only 64 bytes long, for convenience of testing resource exhaustion conditions.
Except for the socket on port 6971. the buffers are only 64 bytes long, for convenience
of testing resource exhaustion conditions.

### examples/client.rs

2 changes: 1 addition & 1 deletion examples/server.rs
Original file line number Diff line number Diff line change
@@ -63,7 +63,7 @@ fn main() {
// udp:6969: respond "yo dawg"
{
let socket: &mut UdpSocket = sockets.get_mut(udp_handle).as_socket();
if !socket.endpoint().is_specified() {
if !socket.is_open() {
socket.bind(6969).unwrap()
}

2 changes: 1 addition & 1 deletion src/phy/mod.rs
Original file line number Diff line number Diff line change
@@ -104,7 +104,7 @@ impl Drop for EthernetTxBuffer {
```
*/

use {Error, Result};
use Result;

#[cfg(any(feature = "raw_socket", feature = "tap_interface"))]
mod sys;
2 changes: 1 addition & 1 deletion src/phy/pcap_writer.rs
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ use core::cell::RefCell;
use std::io::Write;
use byteorder::{ByteOrder, NativeEndian};

use {Error, Result};
use Result;
use super::{DeviceLimits, Device};

enum_with_unknown! {
2 changes: 1 addition & 1 deletion src/phy/raw_socket.rs
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ use std::vec::Vec;
use std::rc::Rc;
use std::io;

use {Error, Result};
use Result;
use super::{sys, DeviceLimits, Device};

/// A socket that captures or transmits the complete frame.
2 changes: 1 addition & 1 deletion src/phy/tracer.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use {Error, Result};
use Result;
use wire::pretty_print::{PrettyPrint, PrettyPrinter};
use super::{DeviceLimits, Device};

2 changes: 1 addition & 1 deletion src/socket/mod.rs
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@
//! The interface implemented by this module uses explicit buffering: you decide on the good
//! size for a buffer, allocate it, and let the networking stack use it.
use {Error, Result};
use Result;
use phy::DeviceLimits;
use wire::IpRepr;

5 changes: 3 additions & 2 deletions src/socket/tcp.rs
Original file line number Diff line number Diff line change
@@ -348,8 +348,9 @@ impl<'a> TcpSocket<'a> {

/// Start listening on the given endpoint.
///
/// This function returns an error if the socket was open; see [is_open](#method.is_open).
/// It also returns an error if the specified port is zero.
/// This function returns `Err(Error::Illegal)` if the socket was already open
/// (see [is_open](#method.is_open)), and `Err(Error::Unaddressable)`
/// if the port in the given endpoint is zero.
pub fn listen<T>(&mut self, local_endpoint: T) -> Result<()>
where T: Into<IpEndpoint> {
let local_endpoint = local_endpoint.into();
13 changes: 10 additions & 3 deletions src/socket/udp.rs
Original file line number Diff line number Diff line change
@@ -101,18 +101,25 @@ impl<'a, 'b> UdpSocket<'a, 'b> {

/// Bind the socket to the given endpoint.
///
/// Returns `Err(Error::Illegal)` if the socket is already bound,
/// and `Err(Error::Unaddressable)` if the port is unspecified.
/// This function returns `Err(Error::Illegal)` if the socket was open
/// (see [is_open](#method.is_open)), and `Err(Error::Unaddressable)`
/// if the port in the given endpoint is zero.
pub fn bind<T: Into<IpEndpoint>>(&mut self, endpoint: T) -> Result<()> {
let endpoint = endpoint.into();
if endpoint.port == 0 { return Err(Error::Unaddressable) }

if self.endpoint.port != 0 { return Err(Error::Illegal) }
if self.is_open() { return Err(Error::Illegal) }

self.endpoint = endpoint;
Ok(())
}

/// Check whether the socket is open.
#[inline]
pub fn is_open(&self) -> bool {
self.endpoint.port != 0
}

/// Check whether the transmit buffer is full.
#[inline]
pub fn can_send(&self) -> bool {