Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

packet: add DHCP support #581

Merged
merged 3 commits into from Feb 3, 2023
Merged

packet: add DHCP support #581

merged 3 commits into from Feb 3, 2023

Conversation

Martichou
Copy link
Contributor

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
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
Contributor Author

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

Done :)

(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
Contributor

mrmonday commented Feb 3, 2023

Looks good, thanks!

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

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.

None yet

4 participants