Skip to content

Commit e66cdf4

Browse files
bors[bot]thvdveld
andauthored
Merge #687
687: Add address context information for resolving 6LoWPAN addresses r=thvdveld a=thvdveld Implements [3.1.2. Context Identifier Extension](https://www.rfc-editor.org/rfc/rfc6282#section-3.1.2) Co-authored-by: Thibaut Vandervelden <thvdveld@vub.be>
2 parents fc69cdb + d2e8e99 commit e66cdf4

File tree

4 files changed

+218
-77
lines changed

4 files changed

+218
-77
lines changed

fuzz/fuzz_targets/sixlowpan_packet.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ fuzz_target!(|fuzz: SixlowpanPacketFuzzer| {
4343
&frame,
4444
fuzz.ll_src_addr.map(Into::into),
4545
fuzz.ll_dst_addr.map(Into::into),
46+
&[],
4647
) {
4748
let mut buffer = vec![0; iphc_repr.buffer_len()];
4849
let mut iphc_frame = SixlowpanIphcPacket::new_unchecked(&mut buffer[..]);

src/iface/interface.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,8 @@ pub struct InterfaceInner<'a> {
247247
pan_id: Option<Ieee802154Pan>,
248248
#[cfg(feature = "proto-ipv4-fragmentation")]
249249
ipv4_id: u16,
250+
#[cfg(feature = "proto-sixlowpan")]
251+
sixlowpan_address_context: &'a [SixlowpanAddressContext<'a>],
250252
#[cfg(feature = "proto-sixlowpan-fragmentation")]
251253
tag: u16,
252254
ip_addrs: ManagedSlice<'a, IpCidr>,
@@ -289,6 +291,9 @@ pub struct InterfaceBuilder<'a> {
289291
sixlowpan_reassembly_buffer_timeout: Duration,
290292
#[cfg(feature = "proto-sixlowpan-fragmentation")]
291293
sixlowpan_out_buffer: ManagedSlice<'a, u8>,
294+
295+
#[cfg(feature = "proto-sixlowpan")]
296+
sixlowpan_address_context: &'a [SixlowpanAddressContext<'a>],
292297
}
293298

294299
impl<'a> InterfaceBuilder<'a> {
@@ -362,6 +367,9 @@ let iface = builder.finalize(&mut device);
362367
sixlowpan_reassembly_buffer_timeout: Duration::from_secs(60),
363368
#[cfg(feature = "proto-sixlowpan-fragmentation")]
364369
sixlowpan_out_buffer: ManagedSlice::Borrowed(&mut [][..]),
370+
371+
#[cfg(feature = "proto-sixlowpan")]
372+
sixlowpan_address_context: &[],
365373
}
366374
}
367375

@@ -473,12 +481,14 @@ let iface = builder.finalize(&mut device);
473481
self
474482
}
475483

484+
/// Set the IPv4 reassembly buffer the interface will use.
476485
#[cfg(feature = "proto-ipv4-fragmentation")]
477486
pub fn ipv4_reassembly_buffer(mut self, storage: PacketAssemblerSet<'a, Ipv4FragKey>) -> Self {
478487
self.ipv4_fragments = storage;
479488
self
480489
}
481490

491+
/// Set the IPv4 fragments buffer the interface will use.
482492
#[cfg(feature = "proto-ipv4-fragmentation")]
483493
pub fn ipv4_fragmentation_buffer<T>(mut self, storage: T) -> Self
484494
where
@@ -488,6 +498,17 @@ let iface = builder.finalize(&mut device);
488498
self
489499
}
490500

501+
/// Set the address contexts the interface will use.
502+
#[cfg(feature = "proto-sixlowpan")]
503+
pub fn sixlowpan_address_context(
504+
mut self,
505+
sixlowpan_address_context: &'a [SixlowpanAddressContext<'a>],
506+
) -> Self {
507+
self.sixlowpan_address_context = sixlowpan_address_context;
508+
self
509+
}
510+
511+
/// Set the 6LoWPAN reassembly buffer the interface will use.
491512
#[cfg(feature = "proto-sixlowpan-fragmentation")]
492513
pub fn sixlowpan_reassembly_buffer(
493514
mut self,
@@ -497,6 +518,7 @@ let iface = builder.finalize(&mut device);
497518
self
498519
}
499520

521+
/// Set the timeout value the 6LoWPAN reassembly buffer will use.
500522
#[cfg(feature = "proto-sixlowpan-fragmentation")]
501523
pub fn sixlowpan_reassembly_buffer_timeout(mut self, timeout: Duration) -> Self {
502524
if timeout > Duration::from_secs(60) {
@@ -506,6 +528,7 @@ let iface = builder.finalize(&mut device);
506528
self
507529
}
508530

531+
/// Set the 6LoWPAN fragments buffer the interface will use.
509532
#[cfg(feature = "proto-sixlowpan-fragmentation")]
510533
pub fn sixlowpan_fragmentation_buffer<T>(mut self, storage: T) -> Self
511534
where
@@ -651,6 +674,8 @@ let iface = builder.finalize(&mut device);
651674
tag,
652675
#[cfg(feature = "proto-ipv4-fragmentation")]
653676
ipv4_id,
677+
#[cfg(feature = "proto-sixlowpan")]
678+
sixlowpan_address_context: &[],
654679
rand,
655680
},
656681
}
@@ -1534,6 +1559,9 @@ impl<'a> InterfaceInner<'a> {
15341559
#[cfg(feature = "proto-sixlowpan-fragmentation")]
15351560
tag: 1,
15361561

1562+
#[cfg(feature = "proto-sixlowpan")]
1563+
sixlowpan_address_context: &[],
1564+
15371565
#[cfg(feature = "proto-ipv4-fragmentation")]
15381566
ipv4_id: 1,
15391567

@@ -1804,6 +1832,7 @@ impl<'a> InterfaceInner<'a> {
18041832
&iphc,
18051833
ieee802154_repr.src_addr,
18061834
ieee802154_repr.dst_addr,
1835+
self.sixlowpan_address_context
18071836
));
18081837

18091838
// The uncompressed header size always starts with 40, since this is the size
@@ -1888,6 +1917,7 @@ impl<'a> InterfaceInner<'a> {
18881917
&iphc_packet,
18891918
ieee802154_repr.src_addr,
18901919
ieee802154_repr.dst_addr,
1920+
self.sixlowpan_address_context,
18911921
));
18921922

18931923
let payload = iphc_packet.payload();

src/wire/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ pub use self::sixlowpan::{
151151
NhcPacket as SixlowpanNhcPacket, UdpNhcPacket as SixlowpanUdpNhcPacket,
152152
UdpNhcRepr as SixlowpanUdpNhcRepr,
153153
},
154-
NextHeader as SixlowpanNextHeader, SixlowpanPacket,
154+
AddressContext as SixlowpanAddressContext, NextHeader as SixlowpanNextHeader, SixlowpanPacket,
155155
};
156156

157157
#[cfg(feature = "medium-ieee802154")]

0 commit comments

Comments
 (0)