-
Notifications
You must be signed in to change notification settings - Fork 64
Add ARP support #103
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
Add ARP support #103
Conversation
|
Hi @lieka1 , I will have a look at your PR this weekend. Thanks in advance. Greets |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #103 +/- ##
==========================================
- Coverage 99.31% 99.25% -0.06%
==========================================
Files 168 177 +9
Lines 29895 31788 +1893
==========================================
+ Hits 29689 31552 +1863
- Misses 206 236 +30 ☔ View full report in Codecov by Sentry. |
JulianSchmid
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @lieka1,
Firstly thanks for the PR, I like the implementation. But I have some issues that would need to be fixed up before I can merge it (see comments).
Concerning the lax implementation, I would say it is needed before I can release the next version. But you don't have to do it, I can also add it after I merged your PR. But let me know if you want to do it, then I don't start on it.
Greets
Julian
etherparse/src/packet_headers.rs
Outdated
| /// Ethernet II header if present. | ||
| pub link: Option<LinkHeader>, | ||
| /// Address Resolution Protocol if present. | ||
| pub arp: Option<ArpHeader>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would move the Arp Header into the net field as a value of the NetHeaders.
etherparse/src/link/arp_payload.rs
Outdated
|
|
||
| let src_hard_addr = HardwareAddr::new( | ||
| header.hw_addr_type, | ||
| &input[offset..(offset + header.hw_addr_size as usize)], | ||
| )?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
&input[offset..(offset + header.hw_addr_size as usize)] will panic if header.hw_addr_size is bigger then the slice. I would add a length check at the start that verifies the overall size of the slice:
| let src_hard_addr = HardwareAddr::new( | |
| header.hw_addr_type, | |
| &input[offset..(offset + header.hw_addr_size as usize)], | |
| )?; | |
| if input.len() < usize::from(header.hw_addr_size)*2 + usize::from(header.proto_addr_size)*2 { | |
| return Err(err::LenError{ | |
| // ... | |
| }); | |
| } | |
| let src_hard_addr = HardwareAddr::new( | |
| header.hw_addr_type, | |
| &input[offset..(offset + header.hw_addr_size as usize)], | |
| )?; |
| }; | ||
| len_error | ||
| }; | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also add arp parsing to from_ether_type?
etherparse/src/packet_headers.rs
Outdated
| result.payload = payload; | ||
| } | ||
| ARP => { | ||
| let (arp, rest) = ArpHeader::from_slice(rest).map_err(Len)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| let (arp, rest) = ArpHeader::from_slice(rest).map_err(Len)?; | |
| let (arp, rest) = ArpHeader::from_slice(rest).map_err(|err| Len(add_offset(err))?; |
|
@JulianSchmid Thank you for your patients, sorry for the bug, i didn't run the test before the pr, my bad. Of course i can do it, i feel good to do some contribution to open source |
|
@JulianSchmid I am not adding any test for it, i barely understand how test is working, i think i just leave it to someone know more about it. may be rename src/err/ip to src/err/net just to be consistant? |
That is fine, I will have a look later if I add one.
Yes, that is fine by me. There might be some really ip specific stuff I would leave in
👍 |
|
Hi! I'm also interested in adding ARP to this library, and I found this PR before starting by myself. I wonder if you guys are still working on it? |
|
Hi @nine-point-eight-p , I started working on it a bit more but did not finish yet. I will try to have another pass this weekend and push the result and then let you know what the state is (if I just push an update and you could have a look or if I am able to finish it). Greets |
|
Hi @nine-point-eight-p , I did further rework on the ARP implementation and pushed it to the branch I think currently it makes no sense if you help there. I still want to change a few fundamental things, but it is not concrete enough that I could write down what would be needed. It is more a "I am looking at code & change things until I am happy with it" . But thanks again for the offer. Greets |
Hi there! i dont' know if you are accepting any pr for arp support
added:
SlicedPacket::from_ethernet is now supporting arp EtherType
PacketBuilderStep is added to build arp header
but LaxSlicedPacket::from_ethernet still cannot parse arp package, i am not sure if is should add it since arp header is quite short