Skip to content

Commit

Permalink
Merge pull request #7 from xmh0511/v2
Browse files Browse the repository at this point in the history
associate mtu with the capacity of ReadBuf for all platforms
  • Loading branch information
xmh0511 authored Jan 17, 2024
2 parents dd57ac0 + 199f675 commit 33c2b12
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/async/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,12 @@ impl AsyncDevice {
}

/// Consumes this AsyncDevice and return a Framed object (unified Stream and Sink interface)
pub fn into_framed(mut self) -> Framed<Self, TunPacketCodec> {
let packet_information = self.get_mut().has_packet_information();
pub fn into_framed(self) -> Framed<Self, TunPacketCodec> {
let packet_information = self.get_ref().has_packet_information();
let mtu = self.inner.get_ref().mtu().unwrap_or(1504);
let codec = TunPacketCodec::new(packet_information, mtu);
Framed::new(self, codec)
// associate mtu with the capacity of ReadBuf
Framed::with_capacity(self, codec, mtu as usize)
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/platform/linux/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ impl Device {
}

/// Return whether the device has packet information
pub fn has_packet_information(&mut self) -> bool {
pub fn has_packet_information(&self) -> bool {
self.queues[0].has_packet_information()
}

Expand Down Expand Up @@ -405,7 +405,7 @@ pub struct Queue {
}

impl Queue {
pub fn has_packet_information(&mut self) -> bool {
pub fn has_packet_information(&self) -> bool {
self.packet_information
}

Expand Down

0 comments on commit 33c2b12

Please sign in to comment.