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: 5bf64586cd29
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: 83eaaf3e0b37
Choose a head ref
  • 2 commits
  • 6 files changed
  • 1 contributor

Commits on Jul 27, 2017

  1. Rework and test UDP sockets.

    Before, errors such as packets not fitting into a buffer would have
    resulted in panics, and errors such as unbound sockets were
    simply ignored.
    whitequark committed Jul 27, 2017
    Copy the full SHA
    492fe3e View commit details
  2. Put the debug_id field first in sockets.

    This has been annoying me far too long.
    whitequark committed Jul 27, 2017
    Copy the full SHA
    83eaaf3 View commit details
Showing with 341 additions and 74 deletions.
  1. +1 −1 examples/server.rs
  2. +2 −2 src/socket/raw.rs
  3. +3 −3 src/socket/tcp.rs
  4. +227 −31 src/socket/udp.rs
  5. +100 −37 src/storage/ring_buffer.rs
  6. +8 −0 src/wire/ip.rs
2 changes: 1 addition & 1 deletion examples/server.rs
Original file line number Diff line number Diff line change
@@ -64,7 +64,7 @@ fn main() {
{
let socket: &mut UdpSocket = sockets.get_mut(udp_handle).as_socket();
if !socket.endpoint().is_specified() {
socket.bind(6969)
socket.bind(6969).unwrap()
}

let client = match socket.recv() {
4 changes: 2 additions & 2 deletions src/socket/raw.rs
Original file line number Diff line number Diff line change
@@ -47,11 +47,11 @@ pub type SocketBuffer<'a, 'b: 'a> = RingBuffer<'a, PacketBuffer<'b>>;
/// transmit and receive packet buffers.
#[derive(Debug)]
pub struct RawSocket<'a, 'b: 'a> {
debug_id: usize,
ip_version: IpVersion,
ip_protocol: IpProtocol,
rx_buffer: SocketBuffer<'a, 'b>,
tx_buffer: SocketBuffer<'a, 'b>,
debug_id: usize,
}

impl<'a, 'b> RawSocket<'a, 'b> {
@@ -61,11 +61,11 @@ impl<'a, 'b> RawSocket<'a, 'b> {
rx_buffer: SocketBuffer<'a, 'b>,
tx_buffer: SocketBuffer<'a, 'b>) -> Socket<'a, 'b> {
Socket::Raw(RawSocket {
debug_id: 0,
ip_version,
ip_protocol,
rx_buffer,
tx_buffer,
debug_id: 0,
})
}

6 changes: 3 additions & 3 deletions src/socket/tcp.rs
Original file line number Diff line number Diff line change
@@ -225,6 +225,7 @@ impl Retransmit {
/// attempts will be reset.
#[derive(Debug)]
pub struct TcpSocket<'a> {
debug_id: usize,
/// State of the socket.
state: State,
/// Address passed to listen(). Listen address is set when listen() is called and
@@ -263,7 +264,6 @@ pub struct TcpSocket<'a> {
time_wait_since: u64,
rx_buffer: SocketBuffer<'a>,
tx_buffer: SocketBuffer<'a>,
debug_id: usize
}

const DEFAULT_MSS: usize = 536;
@@ -280,6 +280,7 @@ impl<'a> TcpSocket<'a> {
}

Socket::Tcp(TcpSocket {
debug_id: 0
state: State::Closed,
listen_address: IpAddress::default(),
local_endpoint: IpEndpoint::default(),
@@ -294,7 +295,6 @@ impl<'a> TcpSocket<'a> {
time_wait_since: 0,
tx_buffer: tx_buffer.into(),
rx_buffer: rx_buffer.into(),
debug_id: 0
})
}

@@ -353,9 +353,9 @@ impl<'a> TcpSocket<'a> {
pub fn listen<T>(&mut self, local_endpoint: T) -> Result<()>
where T: Into<IpEndpoint> {
let local_endpoint = local_endpoint.into();
if local_endpoint.port == 0 { return Err(Error::Unaddressable) }

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

self.reset();
self.listen_address = local_endpoint.addr;
Loading