Skip to content

packet: add DHCP support#581

Merged
mrmonday merged 3 commits intolibpnet:masterfrom
Martichou:dhcp
Feb 3, 2023
Merged

packet: add DHCP support#581
mrmonday merged 3 commits intolibpnet:masterfrom
Martichou:dhcp

Conversation

@Martichou
Copy link
Copy Markdown

Hi !

In a recent project I ended up needing DHCP packet and found this PR (#386).
With the previous PR closed and the comment from a maintainer that one should reopen a new one if needed, that is what I'm doing right now.

I've used the base of alexander-clarke and adapted it to fit what the RFC 2131 says.
Any feedback is welcome !

Copy link
Copy Markdown
Contributor

@stappersg stappersg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The list of pub mods should be kept sorted alphabetically, the new

   pub mod dhcp;

should go in between

   pub mod arp;
   pub mod ethernet;

@Martichou
Copy link
Copy Markdown
Author

The list of pub mods should be kept sorted alphabetically, the new

Done :)

Martin Andre added 3 commits September 2, 2022 10:06
(see libpnet#386)

Signed-off-by: Martin André <martin.andre@tessares.net>
Signed-off-by: Martin André <martin.andre@tessares.net>
Signed-off-by: Martin André <martin.andre@tessares.net>
@Martichou Martichou changed the title DHCP: Add support packet: add DHCP support Sep 12, 2022
@mrmonday
Copy link
Copy Markdown
Contributor

mrmonday commented Feb 3, 2023

Looks good, thanks!

@mrmonday mrmonday merged commit 8a74b3b into libpnet:master Feb 3, 2023
@eli-front
Copy link
Copy Markdown

anyone seen this error come up?

thread 'main' panicked at 'slice index starts at 108 but ends at 69', /Users/me/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pnet_packet-0.34.0/src/dhcp.rs:70:1
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

my code is this (packet comes from datalink)
I've tested the same code with ipv4 & arp, which both work

let packet = pnet::packet::ethernet::EthernetPacket::new(packet).unwrap();

match pnet::packet::dhcp::DhcpPacket::new(packet.payload()) {
                    Some(dhcp_packet) => {
                        println!("DhcpPacket: {:?}", dhcp_packet);
                    }
                    None => {
                        println!("Not a DhcpPacket");
                        continue;
                    }
                }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants