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: 88b163f63a20
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: 03212f284359
Choose a head ref
  • 3 commits
  • 9 files changed
  • 1 contributor

Commits on Dec 28, 2016

  1. Copy the full SHA
    6641793 View commit details
  2. Copy the full SHA
    1c54449 View commit details
  3. Copy the full SHA
    03212f2 View commit details
Showing with 26 additions and 18 deletions.
  1. +1 −0 Cargo.toml
  2. +5 −0 README.md
  3. +5 −4 src/iface/arp_cache.rs
  4. +0 −1 src/lib.rs
  5. +5 −5 src/socket/tcp.rs
  6. +1 −1 src/socket/udp.rs
  7. +1 −1 src/wire/ethernet.rs
  8. +6 −4 src/wire/ip.rs
  9. +2 −2 src/wire/ipv4.rs
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ name = "smoltcp"
version = "0.1.0"
authors = ["whitequark <whitequark@whitequark.org>"]
license = "0BSD"
readme-file = "README.md"

[dependencies]
byteorder = { version = "0.5", default-features = false }
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -6,6 +6,11 @@ real-time systems. Its design goals are simplicity and robustness. Its design an
include complicated compile-time computations, such as macro or type tricks, even
at cost of performance degradation.

_smoltcp_ does not need heap allocation *at all*, is [extensively documented][docs],
and compiles on stable Rust.

[docs]: https://m-labs.github.io/smoltcp/smoltcp/index.html

Features
--------

9 changes: 5 additions & 4 deletions src/iface/arp_cache.rs
Original file line number Diff line number Diff line change
@@ -118,17 +118,18 @@ impl<'a> Cache for SliceCache<'a> {

#[cfg(test)]
mod test {
use wire::Ipv4Address;
use super::*;

const HADDR_A: EthernetAddress = EthernetAddress([0, 0, 0, 0, 0, 1]);
const HADDR_B: EthernetAddress = EthernetAddress([0, 0, 0, 0, 0, 2]);
const HADDR_C: EthernetAddress = EthernetAddress([0, 0, 0, 0, 0, 3]);
const HADDR_D: EthernetAddress = EthernetAddress([0, 0, 0, 0, 0, 4]);

const PADDR_A: IpAddress = IpAddress::v4(0, 0, 0, 0);
const PADDR_B: IpAddress = IpAddress::v4(0, 0, 0, 1);
const PADDR_C: IpAddress = IpAddress::v4(0, 0, 0, 2);
const PADDR_D: IpAddress = IpAddress::v4(0, 0, 0, 3);
const PADDR_A: IpAddress = IpAddress::Ipv4(Ipv4Address([0, 0, 0, 0]));
const PADDR_B: IpAddress = IpAddress::Ipv4(Ipv4Address([0, 0, 0, 1]));
const PADDR_C: IpAddress = IpAddress::Ipv4(Ipv4Address([0, 0, 0, 2]));
const PADDR_D: IpAddress = IpAddress::Ipv4(Ipv4Address([0, 0, 0, 3]));

#[test]
fn test_slice_cache() {
1 change: 0 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![feature(associated_consts, const_fn, step_by)]
#![cfg_attr(feature = "use_alloc", feature(alloc))]
#![no_std]

10 changes: 5 additions & 5 deletions src/socket/tcp.rs
Original file line number Diff line number Diff line change
@@ -776,7 +776,7 @@ impl<'a> IpPayload for TcpRepr<'a> {

#[cfg(test)]
mod test {
use wire::IpAddress;
use wire::{IpAddress, Ipv4Address};
use super::*;

#[test]
@@ -807,12 +807,12 @@ mod test {
assert_eq!(buffer.peek(3, 8), &b"bar"[..]);
}

const LOCAL_IP: IpAddress = IpAddress::v4(10, 0, 0, 1);
const REMOTE_IP: IpAddress = IpAddress::v4(10, 0, 0, 2);
const LOCAL_IP: IpAddress = IpAddress::Ipv4(Ipv4Address([10, 0, 0, 1]));
const REMOTE_IP: IpAddress = IpAddress::Ipv4(Ipv4Address([10, 0, 0, 2]));
const LOCAL_PORT: u16 = 80;
const REMOTE_PORT: u16 = 49500;
const LOCAL_END: IpEndpoint = IpEndpoint::new(LOCAL_IP, LOCAL_PORT);
const REMOTE_END: IpEndpoint = IpEndpoint::new(REMOTE_IP, REMOTE_PORT);
const LOCAL_END: IpEndpoint = IpEndpoint { addr: LOCAL_IP, port: LOCAL_PORT };
const REMOTE_END: IpEndpoint = IpEndpoint { addr: REMOTE_IP, port: REMOTE_PORT };
const LOCAL_SEQ: TcpSeqNumber = TcpSeqNumber(10000);
const REMOTE_SEQ: TcpSeqNumber = TcpSeqNumber(-10000);

2 changes: 1 addition & 1 deletion src/socket/udp.rs
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ impl<'a> PacketBuffer<'a> {
pub fn new<T>(payload: T) -> PacketBuffer<'a>
where T: Into<Managed<'a, [u8]>> {
PacketBuffer {
endpoint: IpEndpoint::UNSPECIFIED,
endpoint: IpEndpoint::default(),
size: 0,
payload: payload.into()
}
2 changes: 1 addition & 1 deletion src/wire/ethernet.rs
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@ impl fmt::Display for EtherType {
pub struct Address(pub [u8; 6]);

impl Address {
pub const BROADCAST: Address = Address([0xff; 6]);
// pub const BROADCAST: Address = Address([0xff; 6]);

/// Construct an Ethernet address from a sequence of octets, in big-endian.
///
10 changes: 6 additions & 4 deletions src/wire/ip.rs
Original file line number Diff line number Diff line change
@@ -35,7 +35,7 @@ pub enum Address {

impl Address {
/// Create an address wrapping an IPv4 address with the given octets.
pub const fn v4(a0: u8, a1: u8, a2: u8, a3: u8) -> Address {
pub fn v4(a0: u8, a1: u8, a2: u8, a3: u8) -> Address {
Address::Ipv4(Ipv4Address([a0, a1, a2, a3]))
}

@@ -85,10 +85,10 @@ pub struct Endpoint {
}

impl Endpoint {
pub const UNSPECIFIED: Endpoint = Endpoint { addr: Address::Unspecified, port: 0 };
// pub const UNSPECIFIED: Endpoint = Endpoint { addr: Address::Unspecified, port: 0 };

/// Create an endpoint address from given address and port.
pub const fn new(addr: Address, port: u16) -> Endpoint {
pub fn new(addr: Address, port: u16) -> Endpoint {
Endpoint { addr: addr, port: port }
}
}
@@ -237,14 +237,16 @@ pub mod checksum {
/// Compute an RFC 1071 compliant checksum (without the final complement).
pub fn data(data: &[u8]) -> u16 {
let mut accum: u32 = 0;
for i in (0..data.len()).step_by(2) {
let mut i = 0;
while i < data.len() {
let word;
if i + 2 <= data.len() {
word = NetworkEndian::read_u16(&data[i..i + 2]) as u32
} else {
word = (data[i] as u32) << 8
}
accum += word;
i += 2;
}
propagate_carries(accum)
}
4 changes: 2 additions & 2 deletions src/wire/ipv4.rs
Original file line number Diff line number Diff line change
@@ -11,8 +11,8 @@ pub use super::IpProtocol as Protocol;
pub struct Address(pub [u8; 4]);

impl Address {
pub const UNSPECIFIED: Address = Address([0x00; 4]);
pub const BROADCAST: Address = Address([0xff; 4]);
// pub const UNSPECIFIED: Address = Address([0x00; 4]);
// pub const BROADCAST: Address = Address([0xff; 4]);

/// Construct an IPv4 address from a sequence of octets, in big-endian.
///