More sensible naming for examples.

v0.7.x
whitequark 2016-12-28 00:18:10 +00:00
parent 19e6ab5619
commit 22b0406c59
3 changed files with 10 additions and 12 deletions

View File

@ -112,30 +112,30 @@ sudo ip link set tap0 up
sudo ip addr add 192.168.69.100/24 dev tap0
```
### smoltcpdump
### examples/tcpdump.rs
_smoltcpdump_ is a tiny clone of the _tcpdump_ utility.
_examples/tcpdump.rs_ is a tiny clone of the _tcpdump_ utility.
Unlike the rest of the examples, it uses raw sockets, and so it can be used on regular interfaces,
e.g. `eth0` or `wlan0`, as well as the `tap0` interface we've created above.
Read its [source code](/examples/smoltcpdump.rs), then run it as:
Read its [source code](/examples/tcpdump.rs), then run it as:
```sh
cargo build --example smoltcpdump
sudo ./target/debug/smoltcpdump eth0
cargo build --example tcpdump
sudo ./target/debug/tcpdump eth0
```
### smoltcpserver
### examples/server.rs
_smoltcpserver_ emulates a network host that can serve requests.
_examples/server.rs_ emulates a network host that can serve requests.
The host is assigned the hardware address `02-00-00-00-00-01` and IPv4 address `192.168.69.1`.
Read its [source code](/examples/smoltcpserver.rs), then run it as:
Read its [source code](/examples/server.rs), then run it as:
```sh
cargo run --example smoltcpserver -- tap0
cargo run --example server -- tap0
```
It responds to:

View File

@ -1,4 +1,3 @@
#![feature(associated_consts, type_ascription)]
#[macro_use]
extern crate log;
extern crate env_logger;
@ -56,8 +55,7 @@ fn main() {
let tcp_rx_buffer = TcpSocketBuffer::new(vec![0; 64]);
let tcp_tx_buffer = TcpSocketBuffer::new(vec![0; 128]);
let mut tcp_socket = TcpSocket::new(tcp_rx_buffer, tcp_tx_buffer);
(tcp_socket.as_socket() : &mut TcpSocket).listen(endpoint).unwrap();
let tcp_socket = TcpSocket::new(tcp_rx_buffer, tcp_tx_buffer);
let hardware_addr = EthernetAddress([0x02, 0x00, 0x00, 0x00, 0x00, 0x01]);
let protocol_addrs = [IpAddress::v4(192, 168, 69, 1)];