Skip to content

Commit fe26f46

Browse files
thvdveldDirbaio
authored andcommitted
Better names for buffers (#653)
1 parent 297d90b commit fe26f46

File tree

7 files changed

+44
-44
lines changed

7 files changed

+44
-44
lines changed

examples/client.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::str::{self, FromStr};
99
feature = "proto-sixlowpan-fragmentation",
1010
feature = "proto-ipv4-fragmentation"
1111
))]
12-
use smoltcp::iface::FragmentsCache;
12+
use smoltcp::iface::ReassemblyBuffer;
1313

1414
use smoltcp::iface::{InterfaceBuilder, NeighborCache, Routes, SocketSet};
1515
use smoltcp::phy::{wait as phy_wait, Device, Medium};
@@ -55,20 +55,20 @@ fn main() {
5555
let mut ipv4_out_packet_cache = [0u8; 1280];
5656
#[cfg(feature = "proto-ipv4-fragmentation")]
5757
{
58-
let ipv4_frag_cache = FragmentsCache::new(vec![], BTreeMap::new());
58+
let ipv4_frag_cache = ReassemblyBuffer::new(vec![], BTreeMap::new());
5959
builder = builder
60-
.ipv4_fragments_cache(ipv4_frag_cache)
61-
.ipv4_out_packet_cache(&mut ipv4_out_packet_cache[..]);
60+
.ipv4_reassembly_buffer(ipv4_frag_cache)
61+
.ipv4_fragmentation_buffer(&mut ipv4_out_packet_cache[..]);
6262
}
6363

6464
#[cfg(feature = "proto-sixlowpan-fragmentation")]
6565
let mut sixlowpan_out_packet_cache = [0u8; 1280];
6666
#[cfg(feature = "proto-sixlowpan-fragmentation")]
6767
{
68-
let sixlowpan_frag_cache = FragmentsCache::new(vec![], BTreeMap::new());
68+
let sixlowpan_frag_cache = ReassemblyBuffer::new(vec![], BTreeMap::new());
6969
builder = builder
70-
.sixlowpan_fragments_cache(sixlowpan_frag_cache)
71-
.sixlowpan_out_packet_cache(&mut sixlowpan_out_packet_cache[..]);
70+
.sixlowpan_reassembly_buffer(sixlowpan_frag_cache)
71+
.sixlowpan_fragmentation_buffer(&mut sixlowpan_out_packet_cache[..]);
7272
}
7373

7474
if medium == Medium::Ethernet {

examples/server.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::os::unix::io::AsRawFd;
99
feature = "proto-sixlowpan-fragmentation",
1010
feature = "proto-ipv4-fragmentation"
1111
))]
12-
use smoltcp::iface::FragmentsCache;
12+
use smoltcp::iface::ReassemblyBuffer;
1313
use smoltcp::iface::{InterfaceBuilder, NeighborCache, SocketSet};
1414
use smoltcp::phy::{wait as phy_wait, Device, Medium};
1515
use smoltcp::socket::{tcp, udp};
@@ -78,20 +78,20 @@ fn main() {
7878
let mut ipv4_out_packet_cache = [0u8; 10_000];
7979
#[cfg(feature = "proto-ipv4-fragmentation")]
8080
{
81-
let ipv4_frag_cache = FragmentsCache::new(vec![], BTreeMap::new());
81+
let ipv4_frag_cache = ReassemblyBuffer::new(vec![], BTreeMap::new());
8282
builder = builder
83-
.ipv4_fragments_cache(ipv4_frag_cache)
84-
.ipv4_out_packet_cache(&mut ipv4_out_packet_cache[..]);
83+
.ipv4_reassembly_buffer(ipv4_frag_cache)
84+
.ipv4_fragmentation_buffer(&mut ipv4_out_packet_cache[..]);
8585
}
8686

8787
#[cfg(feature = "proto-sixlowpan-fragmentation")]
8888
let mut sixlowpan_out_packet_cache = [0u8; 1280];
8989
#[cfg(feature = "proto-sixlowpan-fragmentation")]
9090
{
91-
let sixlowpan_frag_cache = FragmentsCache::new(vec![], BTreeMap::new());
91+
let sixlowpan_frag_cache = ReassemblyBuffer::new(vec![], BTreeMap::new());
9292
builder = builder
93-
.sixlowpan_fragments_cache(sixlowpan_frag_cache)
94-
.sixlowpan_out_packet_cache(&mut sixlowpan_out_packet_cache[..]);
93+
.sixlowpan_reassembly_buffer(sixlowpan_frag_cache)
94+
.sixlowpan_fragmentation_buffer(&mut sixlowpan_out_packet_cache[..]);
9595
}
9696

9797
if medium == Medium::Ethernet {

examples/sixlowpan.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ use std::collections::BTreeMap;
4747
use std::os::unix::io::AsRawFd;
4848
use std::str;
4949

50-
use smoltcp::iface::{FragmentsCache, InterfaceBuilder, NeighborCache, SocketSet};
50+
use smoltcp::iface::{InterfaceBuilder, NeighborCache, ReassemblyBuffer, SocketSet};
5151
use smoltcp::phy::{wait as phy_wait, Medium, RawSocket};
5252
use smoltcp::socket::tcp;
5353
use smoltcp::socket::udp;
@@ -95,18 +95,18 @@ fn main() {
9595

9696
#[cfg(feature = "proto-ipv4-fragmentation")]
9797
{
98-
let ipv4_frag_cache = FragmentsCache::new(vec![], BTreeMap::new());
99-
builder = builder.ipv4_fragments_cache(ipv4_frag_cache);
98+
let ipv4_frag_cache = ReassemblyBuffer::new(vec![], BTreeMap::new());
99+
builder = builder.ipv4_reassembly_buffer(ipv4_frag_cache);
100100
}
101101

102102
#[cfg(feature = "proto-sixlowpan-fragmentation")]
103103
let mut out_packet_buffer = [0u8; 1280];
104104
#[cfg(feature = "proto-sixlowpan-fragmentation")]
105105
{
106-
let sixlowpan_frag_cache = FragmentsCache::new(vec![], BTreeMap::new());
106+
let sixlowpan_frag_cache = ReassemblyBuffer::new(vec![], BTreeMap::new());
107107
builder = builder
108-
.sixlowpan_fragments_cache(sixlowpan_frag_cache)
109-
.sixlowpan_out_packet_cache(&mut out_packet_buffer[..]);
108+
.sixlowpan_reassembly_buffer(sixlowpan_frag_cache)
109+
.sixlowpan_fragmentation_buffer(&mut out_packet_buffer[..]);
110110
}
111111

112112
let mut iface = builder.finalize(&mut device);

examples/sixlowpan_benchmark.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ use std::collections::BTreeMap;
4848
use std::os::unix::io::AsRawFd;
4949
use std::str;
5050

51-
use smoltcp::iface::{FragmentsCache, InterfaceBuilder, NeighborCache, SocketSet};
51+
use smoltcp::iface::{InterfaceBuilder, NeighborCache, ReassemblyBuffer, SocketSet};
5252
use smoltcp::phy::{wait as phy_wait, Medium, RawSocket};
5353
use smoltcp::socket::tcp;
5454
use smoltcp::wire::{Ieee802154Pan, IpAddress, IpCidr};
@@ -166,16 +166,16 @@ fn main() {
166166
64,
167167
)];
168168

169-
let cache = FragmentsCache::new(vec![], BTreeMap::new());
169+
let cache = ReassemblyBuffer::new(vec![], BTreeMap::new());
170170

171171
let mut builder = InterfaceBuilder::new()
172172
.ip_addrs(ip_addrs)
173173
.pan_id(Ieee802154Pan(0xbeef));
174174
builder = builder
175175
.hardware_addr(ieee802154_addr.into())
176176
.neighbor_cache(neighbor_cache)
177-
.sixlowpan_fragments_cache(cache)
178-
.sixlowpan_out_packet_cache(vec![]);
177+
.sixlowpan_reassembly_buffer(cache)
178+
.sixlowpan_fragmentation_buffer(vec![]);
179179
let mut iface = builder.finalize(&mut device);
180180

181181
let mut sockets = SocketSet::new(vec![]);

src/iface/interface.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ pub struct InterfaceBuilder<'a> {
286286
#[cfg(feature = "proto-sixlowpan-fragmentation")]
287287
sixlowpan_fragments: PacketAssemblerSet<'a, SixlowpanFragKey>,
288288
#[cfg(feature = "proto-sixlowpan-fragmentation")]
289-
sixlowpan_fragments_cache_timeout: Duration,
289+
sixlowpan_reassembly_buffer_timeout: Duration,
290290
#[cfg(feature = "proto-sixlowpan-fragmentation")]
291291
sixlowpan_out_buffer: ManagedSlice<'a, u8>,
292292
}
@@ -325,8 +325,8 @@ let builder = InterfaceBuilder::new()
325325
326326
# #[cfg(feature = "proto-ipv4-fragmentation")]
327327
let builder = builder
328-
.ipv4_fragments_cache(ipv4_frag_cache)
329-
.ipv4_out_packet_cache(vec![]);
328+
.ipv4_reassembly_buffer(ipv4_frag_cache)
329+
.ipv4_fragmentation_buffer(vec![]);
330330
331331
let iface = builder.finalize(&mut device);
332332
```
@@ -359,7 +359,7 @@ let iface = builder.finalize(&mut device);
359359
#[cfg(feature = "proto-sixlowpan-fragmentation")]
360360
sixlowpan_fragments: PacketAssemblerSet::new(&mut [][..], &mut [][..]),
361361
#[cfg(feature = "proto-sixlowpan-fragmentation")]
362-
sixlowpan_fragments_cache_timeout: Duration::from_secs(60),
362+
sixlowpan_reassembly_buffer_timeout: Duration::from_secs(60),
363363
#[cfg(feature = "proto-sixlowpan-fragmentation")]
364364
sixlowpan_out_buffer: ManagedSlice::Borrowed(&mut [][..]),
365365
}
@@ -474,13 +474,13 @@ let iface = builder.finalize(&mut device);
474474
}
475475

476476
#[cfg(feature = "proto-ipv4-fragmentation")]
477-
pub fn ipv4_fragments_cache(mut self, storage: PacketAssemblerSet<'a, Ipv4FragKey>) -> Self {
477+
pub fn ipv4_reassembly_buffer(mut self, storage: PacketAssemblerSet<'a, Ipv4FragKey>) -> Self {
478478
self.ipv4_fragments = storage;
479479
self
480480
}
481481

482482
#[cfg(feature = "proto-ipv4-fragmentation")]
483-
pub fn ipv4_out_packet_cache<T>(mut self, storage: T) -> Self
483+
pub fn ipv4_fragmentation_buffer<T>(mut self, storage: T) -> Self
484484
where
485485
T: Into<ManagedSlice<'a, u8>>,
486486
{
@@ -489,7 +489,7 @@ let iface = builder.finalize(&mut device);
489489
}
490490

491491
#[cfg(feature = "proto-sixlowpan-fragmentation")]
492-
pub fn sixlowpan_fragments_cache(
492+
pub fn sixlowpan_reassembly_buffer(
493493
mut self,
494494
storage: PacketAssemblerSet<'a, SixlowpanFragKey>,
495495
) -> Self {
@@ -498,16 +498,16 @@ let iface = builder.finalize(&mut device);
498498
}
499499

500500
#[cfg(feature = "proto-sixlowpan-fragmentation")]
501-
pub fn sixlowpan_fragments_cache_timeout(mut self, timeout: Duration) -> Self {
501+
pub fn sixlowpan_reassembly_buffer_timeout(mut self, timeout: Duration) -> Self {
502502
if timeout > Duration::from_secs(60) {
503503
net_debug!("RFC 4944 specifies that the reassembly timeout MUST be set to a maximum of 60 seconds");
504504
}
505-
self.sixlowpan_fragments_cache_timeout = timeout;
505+
self.sixlowpan_reassembly_buffer_timeout = timeout;
506506
self
507507
}
508508

509509
#[cfg(feature = "proto-sixlowpan-fragmentation")]
510-
pub fn sixlowpan_out_packet_cache<T>(mut self, storage: T) -> Self
510+
pub fn sixlowpan_fragmentation_buffer<T>(mut self, storage: T) -> Self
511511
where
512512
T: Into<ManagedSlice<'a, u8>>,
513513
{
@@ -611,7 +611,7 @@ let iface = builder.finalize(&mut device);
611611
#[cfg(feature = "proto-sixlowpan-fragmentation")]
612612
sixlowpan_fragments: self.sixlowpan_fragments,
613613
#[cfg(feature = "proto-sixlowpan-fragmentation")]
614-
sixlowpan_fragments_cache_timeout: self.sixlowpan_fragments_cache_timeout,
614+
sixlowpan_fragments_cache_timeout: self.sixlowpan_reassembly_buffer_timeout,
615615

616616
#[cfg(not(any(
617617
feature = "proto-ipv4-fragmentation",
@@ -3817,8 +3817,8 @@ mod test {
38173817

38183818
#[cfg(feature = "proto-ipv4-fragmentation")]
38193819
let iface_builder = iface_builder
3820-
.ipv4_fragments_cache(PacketAssemblerSet::new(vec![], BTreeMap::new()))
3821-
.ipv4_out_packet_cache(vec![]);
3820+
.ipv4_reassembly_buffer(PacketAssemblerSet::new(vec![], BTreeMap::new()))
3821+
.ipv4_fragmentation_buffer(vec![]);
38223822

38233823
#[cfg(feature = "proto-igmp")]
38243824
let iface_builder = iface_builder.ipv4_multicast_groups(BTreeMap::new());
@@ -3847,13 +3847,13 @@ mod test {
38473847

38483848
#[cfg(feature = "proto-sixlowpan-fragmentation")]
38493849
let iface_builder = iface_builder
3850-
.sixlowpan_fragments_cache(PacketAssemblerSet::new(vec![], BTreeMap::new()))
3851-
.sixlowpan_out_packet_cache(vec![]);
3850+
.sixlowpan_reassembly_buffer(PacketAssemblerSet::new(vec![], BTreeMap::new()))
3851+
.sixlowpan_fragmentation_buffer(vec![]);
38523852

38533853
#[cfg(feature = "proto-ipv4-fragmentation")]
38543854
let iface_builder = iface_builder
3855-
.ipv4_fragments_cache(PacketAssemblerSet::new(vec![], BTreeMap::new()))
3856-
.ipv4_out_packet_cache(vec![]);
3855+
.ipv4_reassembly_buffer(PacketAssemblerSet::new(vec![], BTreeMap::new()))
3856+
.ipv4_fragmentation_buffer(vec![]);
38573857

38583858
#[cfg(feature = "proto-igmp")]
38593859
let iface_builder = iface_builder.ipv4_multicast_groups(BTreeMap::new());

src/iface/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ pub use self::route::{Route, Routes};
2323
pub use socket_set::{SocketHandle, SocketSet, SocketStorage};
2424

2525
#[cfg(any(feature = "proto-ipv4", feature = "proto-sixlowpan"))]
26-
pub use self::fragmentation::{PacketAssembler, PacketAssemblerSet as FragmentsCache};
26+
pub use self::fragmentation::{PacketAssembler, PacketAssemblerSet as ReassemblyBuffer};
2727

2828
pub use self::interface::{Interface, InterfaceBuilder, InterfaceInner as Context};

src/wire/sixlowpan.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2067,14 +2067,14 @@ mod test {
20672067

20682068
#[test]
20692069
fn sixlowpan_three_fragments() {
2070-
use crate::iface::FragmentsCache;
2070+
use crate::iface::ReassemblyBuffer;
20712071
use crate::time::Instant;
20722072
use crate::wire::ieee802154::Frame as Ieee802154Frame;
20732073
use crate::wire::ieee802154::Repr as Ieee802154Repr;
20742074
use crate::wire::Ieee802154Address;
20752075
use std::collections::BTreeMap;
20762076

2077-
let mut frags_cache = FragmentsCache::new(vec![], BTreeMap::new());
2077+
let mut frags_cache = ReassemblyBuffer::new(vec![], BTreeMap::new());
20782078

20792079
let frame1: &[u8] = &[
20802080
0x41, 0xcc, 0x92, 0xef, 0xbe, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x0b, 0x1a, 0xd9,

0 commit comments

Comments
 (0)