-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
79 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
use auip_pkt::{layer3, layer4}; | ||
|
||
use crate::{Result, poll_udp}; | ||
|
||
pub fn poll_ipv4(pkt: layer3::ipv4::Packet<&[u8]>) -> Result<()> { | ||
log::debug!("Receive packet: {}", pkt); | ||
|
||
// Drop ttl is 0. | ||
if pkt.ttl() == 0 { | ||
return Ok(()); | ||
} | ||
|
||
// Check is fragment | ||
if pkt.dont_frag() { | ||
// enter upper layer. | ||
let protocol = pkt.protocol(); | ||
|
||
let payload = pkt.payload(); | ||
|
||
match protocol { | ||
layer3::Protocol::Udp => { | ||
let pkt = layer4::udp::Packet::new_checked(payload)?; | ||
|
||
poll_udp(pkt)?; | ||
} | ||
_ => {} | ||
} | ||
} else { | ||
return Ok(()); | ||
} | ||
|
||
if pkt.more_frags() { | ||
// save frag. | ||
} else { | ||
// complete frag. | ||
} | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
use auip_pkt::layer4; | ||
|
||
use crate::Result; | ||
|
||
pub fn poll_udp(pkt: layer4::udp::Packet<&[u8]>) -> Result<()> { | ||
log::debug!("Receive packet: {}", pkt); | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters