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: 2b92dfcf95c8
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: a67ee07922b0
Choose a head ref
  • 1 commit
  • 5 files changed
  • 1 contributor

Commits on Nov 5, 2019

  1. Copy the full SHA
    a67ee07 View commit details
Showing with 94 additions and 0 deletions.
  1. +24 −0 src/socket/icmp.rs
  2. +24 −0 src/socket/raw.rs
  3. +12 −0 src/socket/tcp.rs
  4. +24 −0 src/socket/udp.rs
  5. +10 −0 src/storage/packet_buffer.rs
24 changes: 24 additions & 0 deletions src/socket/icmp.rs
Original file line number Diff line number Diff line change
@@ -189,6 +189,30 @@ impl<'a, 'b> IcmpSocket<'a, 'b> {
!self.rx_buffer.is_empty()
}

/// Return the maximum number packets the socket can receive.
#[inline]
pub fn packet_recv_capacity(&self) -> usize {
self.rx_buffer.packet_capacity()
}

/// Return the maximum number packets the socket can transmit.
#[inline]
pub fn packet_send_capacity(&self) -> usize {
self.tx_buffer.packet_capacity()
}

/// Return the maximum number of bytes inside the recv buffer.
#[inline]
pub fn payload_recv_capacity(&self) -> usize {
self.rx_buffer.payload_capacity()
}

/// Return the maximum number of bytes inside the transmit buffer.
#[inline]
pub fn payload_send_capacity(&self) -> usize {
self.tx_buffer.payload_capacity()
}

/// Check whether the socket is open.
#[inline]
pub fn is_open(&self) -> bool {
24 changes: 24 additions & 0 deletions src/socket/raw.rs
Original file line number Diff line number Diff line change
@@ -74,6 +74,30 @@ impl<'a, 'b> RawSocket<'a, 'b> {
!self.rx_buffer.is_empty()
}

/// Return the maximum number packets the socket can receive.
#[inline]
pub fn packet_recv_capacity(&self) -> usize {
self.rx_buffer.packet_capacity()
}

/// Return the maximum number packets the socket can transmit.
#[inline]
pub fn packet_send_capacity(&self) -> usize {
self.tx_buffer.packet_capacity()
}

/// Return the maximum number of bytes inside the recv buffer.
#[inline]
pub fn payload_recv_capacity(&self) -> usize {
self.rx_buffer.payload_capacity()
}

/// Return the maximum number of bytes inside the transmit buffer.
#[inline]
pub fn payload_send_capacity(&self) -> usize {
self.tx_buffer.payload_capacity()
}

/// Enqueue a packet to send, and return a pointer to its payload.
///
/// This function returns `Err(Error::Exhausted)` if the transmit buffer is full,
12 changes: 12 additions & 0 deletions src/socket/tcp.rs
Original file line number Diff line number Diff line change
@@ -640,6 +640,18 @@ impl<'a> TcpSocket<'a> {
!self.tx_buffer.is_full()
}

/// Return the maximum number of bytes inside the recv buffer.
#[inline]
pub fn recv_capacity(&self) -> usize {
self.rx_buffer.capacity()
}

/// Return the maximum number of bytes inside the transmit buffer.
#[inline]
pub fn send_capacity(&self) -> usize {
self.tx_buffer.capacity()
}

/// Check whether the receive half of the full-duplex connection buffer is open
/// (see [may_recv](#method.may_recv), and the receive buffer is not empty.
#[inline]
24 changes: 24 additions & 0 deletions src/socket/udp.rs
Original file line number Diff line number Diff line change
@@ -110,6 +110,30 @@ impl<'a, 'b> UdpSocket<'a, 'b> {
!self.rx_buffer.is_empty()
}

/// Return the maximum number packets the socket can receive.
#[inline]
pub fn packet_recv_capacity(&self) -> usize {
self.rx_buffer.packet_capacity()
}

/// Return the maximum number packets the socket can transmit.
#[inline]
pub fn packet_send_capacity(&self) -> usize {
self.tx_buffer.packet_capacity()
}

/// Return the maximum number of bytes inside the recv buffer.
#[inline]
pub fn payload_recv_capacity(&self) -> usize {
self.rx_buffer.payload_capacity()
}

/// Return the maximum number of bytes inside the transmit buffer.
#[inline]
pub fn payload_send_capacity(&self) -> usize {
self.tx_buffer.payload_capacity()
}

/// Enqueue a packet to be sent to a given remote endpoint, and return a pointer
/// to its payload.
///
10 changes: 10 additions & 0 deletions src/storage/packet_buffer.rs
Original file line number Diff line number Diff line change
@@ -168,6 +168,16 @@ impl<'a, 'b, H> PacketBuffer<'a, 'b, H> {
Err(Error::Exhausted)
}
}

/// Return the maximum number packets that can be stored.
pub fn packet_capacity(&self) -> usize {
self.metadata_ring.capacity()
}

/// Return the maximum number of bytes in the payload ring buffer.
pub fn payload_capacity(&self) -> usize {
self.payload_ring.capacity()
}
}

#[cfg(test)]