-
Notifications
You must be signed in to change notification settings - Fork 4
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
1 parent
51a8765
commit 38e22b7
Showing
1 changed file
with
44 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
use serde::Serialize; | ||
use std::net::Ipv4Addr; | ||
|
||
#[derive(Debug, PartialEq, Serialize)] | ||
pub enum DHCP { | ||
ACK(Packet), | ||
DECLINE(Packet), | ||
DISCOVER(Packet), | ||
INFORM(Packet), | ||
NAK(Packet), | ||
OFFER(Packet), | ||
RELEASE(Packet), | ||
REQUEST(Packet), | ||
UNKNOWN(Packet), | ||
} | ||
|
||
#[derive(Debug, PartialEq, Serialize)] | ||
pub struct Packet { | ||
pub ciaddr: Ipv4Addr, | ||
pub yiaddr: Ipv4Addr, | ||
pub siaddr: Ipv4Addr, | ||
pub chaddr: [u8; 6], | ||
|
||
pub hostname: Option<String>, | ||
pub requested_ip_address: Option<Ipv4Addr>, | ||
pub router: Option<Vec<Ipv4Addr>>, | ||
pub domain_name_server: Option<Vec<Ipv4Addr>>, | ||
} | ||
|
||
impl Packet { | ||
pub fn new(ciaddr: Ipv4Addr, yiaddr: Ipv4Addr, siaddr: Ipv4Addr, chaddr: [u8; 6]) -> Packet { | ||
Packet { | ||
ciaddr, | ||
yiaddr, | ||
siaddr, | ||
chaddr, | ||
|
||
hostname: None, | ||
requested_ip_address: None, | ||
router: None, | ||
domain_name_server: None, | ||
} | ||
} | ||
} |