Skip to content

Commit

Permalink
src: centrifuge arp
Browse files Browse the repository at this point in the history
  • Loading branch information
krishpranav committed Aug 28, 2021
1 parent 38577c2 commit 584f241
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/centrifuge/arp.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use crate::structs::CentrifugeError;
use crate::structs::arp::ARP;

pub fn extract(remaining: &[u8]) -> Result<ARP, CentrifugeError> {
if let Ok((_remaining, arp_pkt)) = pktparse::arp::parse_arp_pkt(remaining) {
use pktparse::arp::Operation;
match arp_pkt.operation {
Operation::Request => Ok(ARP::Request(arp_pkt)),
Operation::Reply => Ok(ARP::Reply(arp_pkt)),
Operation::Other(_) => Err(CentrifugeError::UnknownProtocol), // TODO
}
} else {
Err(CentrifugeError::InvalidPacket)
}
}

0 comments on commit 584f241

Please sign in to comment.