Browse Source

sixlowpan: add fragmentation wire representation

Thibaut Vandervelden 3 years ago
parent
commit
d1107f4ead
3 changed files with 573 additions and 251 deletions
  1. 11 8
      src/iface/interface.rs
  2. 5 4
      src/wire/mod.rs
  3. 557 239
      src/wire/sixlowpan.rs

+ 11 - 8
src/iface/interface.rs

@@ -1359,24 +1359,24 @@ impl<'a> InterfaceInner<'a> {
         match iphc_repr.next_header {
             SixlowpanNextHeader::Compressed => {
                 match check!(SixlowpanNhcPacket::dispatch(payload)) {
-                    SixlowpanNhcPacket::ExtensionHeader(_) => {
+                    SixlowpanNhcPacket::ExtHeader => {
                         net_debug!("Extension headers are currently not supported for 6LoWPAN");
                         None
                     }
                     #[cfg(not(feature = "socket-udp"))]
-                    SixlowpanNhcPacket::UdpHeader(_) => {
+                    SixlowpanNhcPacket::UdpHeader => {
                         net_debug!("UDP support is disabled, enable cargo feature `socket-udp`.");
                         None
                     }
                     #[cfg(feature = "socket-udp")]
-                    SixlowpanNhcPacket::UdpHeader(udp_packet) => {
+                    SixlowpanNhcPacket::UdpHeader => {
                         ipv6_repr.next_header = IpProtocol::Udp;
                         // Handle the UDP
-                        let udp_repr = check!(SixlowpanUdpRepr::parse(
+                        let udp_packet = check!(SixlowpanUdpNhcPacket::new_checked(payload));
+                        let udp_repr = check!(SixlowpanUdpNhcRepr::parse(
                             &udp_packet,
                             &iphc_repr.src_addr,
                             &iphc_repr.dst_addr,
-                            udp_packet.checksum(),
                         ));
 
                         // Look for UDP sockets that will accept the UDP packet.
@@ -2550,6 +2550,9 @@ impl<'a> InterfaceInner<'a> {
                     ll_dst_addr: Some(dst_hardware_addr),
                     next_header,
                     hop_limit,
+                    ecn: None,
+                    dscp: None,
+                    flow_label: None,
                 };
 
                 tx_len += ieee_repr.buffer_len();
@@ -2559,7 +2562,7 @@ impl<'a> InterfaceInner<'a> {
                 match &packet {
                     #[cfg(feature = "socket-udp")]
                     IpPacket::Udp((_, udp_repr, payload)) => {
-                        let udp_repr = SixlowpanUdpRepr(*udp_repr);
+                        let udp_repr = SixlowpanUdpNhcRepr(*udp_repr);
                         tx_len += udp_repr.header_len() + payload.len();
                     }
                     IpPacket::Icmpv6((_, icmp)) => {
@@ -2587,9 +2590,9 @@ impl<'a> InterfaceInner<'a> {
                         IpPacket::Udp((_, udp_repr, payload)) => {
                             // 3. Create the header for 6LoWPAN UDP
                             let mut udp_packet =
-                                SixlowpanUdpPacket::new_unchecked(&mut tx_buffer[start..tx_len]);
+                                SixlowpanUdpNhcPacket::new_unchecked(&mut tx_buffer[start..tx_len]);
 
-                            SixlowpanUdpRepr(udp_repr).emit(
+                            SixlowpanUdpNhcRepr(udp_repr).emit(
                                 &mut udp_packet,
                                 &iphc_repr.src_addr,
                                 &iphc_repr.dst_addr,

+ 5 - 4
src/wire/mod.rs

@@ -144,13 +144,14 @@ pub use self::arp::{
 
 #[cfg(all(feature = "proto-sixlowpan", feature = "medium-ieee802154"))]
 pub use self::sixlowpan::{
+    frag::{Key as SixlowpanFragKey, Packet as SixlowpanFragPacket, Repr as SixlowpanFragRepr},
     iphc::{Packet as SixlowpanIphcPacket, Repr as SixlowpanIphcRepr},
     nhc::{
-        ExtensionHeaderPacket as SixlowpanExtHeaderPacket,
-        ExtensionHeaderRepr as SixlowpanExtHeaderRepr, Packet as SixlowpanNhcPacket,
-        UdpNhcRepr as SixlowpanUdpRepr, UdpPacket as SixlowpanUdpPacket,
+        ExtHeaderPacket as SixlowpanExtHeaderPacket, ExtHeaderRepr as SixlowpanExtHeaderRepr,
+        NhcPacket as SixlowpanNhcPacket, UdpNhcPacket as SixlowpanUdpNhcPacket,
+        UdpNhcRepr as SixlowpanUdpNhcRepr,
     },
-    NextHeader as SixlowpanNextHeader,
+    NextHeader as SixlowpanNextHeader, SixlowpanPacket,
 };
 
 #[cfg(feature = "medium-ieee802154")]

File diff suppressed because it is too large
+ 557 - 239
src/wire/sixlowpan.rs


Some files were not shown because too many files changed in this diff