Skip to content

Conversation

@lieka1
Copy link
Contributor

@lieka1 lieka1 commented Jul 2, 2024

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

@JulianSchmid
Copy link
Owner

Hi @lieka1 ,

I will have a look at your PR this weekend. Thanks in advance.

Greets
Julian

@codecov
Copy link

codecov bot commented Jul 6, 2024

Codecov Report

Attention: Patch coverage is 95.36560% with 90 lines in your changes missing coverage. Please review.

Project coverage is 99.25%. Comparing base (93c7f0b) to head (80f5ddf).
Report is 20 commits behind head on master.

Files with missing lines Patch % Lines
etherparse/src/lax_sliced_packet.rs 0.00% 13 Missing ⚠️
etherparse/src/lax_packet_headers.rs 85.52% 11 Missing ⚠️
etherparse/src/lax_sliced_packet_cursor.rs 8.33% 11 Missing ⚠️
etherparse/src/sliced_packet.rs 92.61% 11 Missing ⚠️
etherparse/src/packet_headers.rs 16.66% 10 Missing ⚠️
etherparse/src/packet_builder.rs 97.05% 9 Missing ⚠️
etherparse/src/compositions_tests.rs 89.61% 8 Missing ⚠️
etherparse/src/net/net_headers.rs 80.00% 4 Missing ⚠️
etherparse/src/net/net_slice.rs 0.00% 4 Missing ⚠️
etherparse/src/err/layer.rs 0.00% 2 Missing ⚠️
... and 6 more
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.
📢 Have feedback on the report? Share it here.

Copy link
Owner

@JulianSchmid JulianSchmid left a 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

/// Ethernet II header if present.
pub link: Option<LinkHeader>,
/// Address Resolution Protocol if present.
pub arp: Option<ArpHeader>,
Copy link
Owner

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.

Comment on lines 86 to 90

let src_hard_addr = HardwareAddr::new(
header.hw_addr_type,
&input[offset..(offset + header.hw_addr_size as usize)],
)?;
Copy link
Owner

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:

Suggested change
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
};

Copy link
Owner

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?

result.payload = payload;
}
ARP => {
let (arp, rest) = ArpHeader::from_slice(rest).map_err(Len)?;
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
let (arp, rest) = ArpHeader::from_slice(rest).map_err(Len)?;
let (arp, rest) = ArpHeader::from_slice(rest).map_err(|err| Len(add_offset(err))?;

@lieka1
Copy link
Contributor Author

lieka1 commented Jul 10, 2024

@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

@lieka1
Copy link
Contributor Author

lieka1 commented Jul 11, 2024

@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?
i also not moving src/link/arp_header.rs and src/link/arp_payload.rs to src/net

@JulianSchmid
Copy link
Owner

@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.

That is fine, I will have a look later if I add one.

may be rename src/err/ip to src/err/net just to be consistant?

Yes, that is fine by me. There might be some really ip specific stuff I would leave in ip. But that is not really important right now. I will have a look later, there anyways is some work that needs to be done there.

i also not moving src/link/arp_header.rs and src/link/arp_payload.rs to src/net

👍

@nine-point-eight-p
Copy link

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?

@JulianSchmid
Copy link
Owner

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
Julian

@JulianSchmid
Copy link
Owner

JulianSchmid commented Nov 11, 2024

Hi @nine-point-eight-p ,

I did further rework on the ARP implementation and pushed it to the branch arp-followup https://github.com/JulianSchmid/etherparse/tree/arp-followup . It is still not finished and I think it would need a few more passes.

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
Julian

@JulianSchmid JulianSchmid changed the title add arp support Add arp support Jan 13, 2025
@JulianSchmid JulianSchmid changed the title Add arp support Add ARP support Jan 13, 2025
@JulianSchmid JulianSchmid changed the title Add ARP support Add ARP Support Jan 13, 2025
@JulianSchmid JulianSchmid changed the title Add ARP Support Add ARP support Jan 13, 2025
@JulianSchmid JulianSchmid merged commit 55307c4 into JulianSchmid:master Jan 13, 2025
9 of 11 checks passed
@JulianSchmid JulianSchmid added this to the v0.17.0 milestone Jan 13, 2025
This was referenced Jan 14, 2025
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.

3 participants