-
Notifications
You must be signed in to change notification settings - Fork 684
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
Allow gratuitous ARP requests. #1684
base: dev
Are you sure you want to change the base?
Conversation
… / reply. - NB: Removed zeroing of MAC address if the ArpLayer contains a opcode ARP_REQUEST. - Added new structs with only required data to construct a certain packet.
679bdbd
to
d0a507a
Compare
- Added a new private constructor to handle populating the header. The old constructor is forwarded to this one with the caveat that the target MAC address is ignored and zeroed if a request is to be made.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev #1684 +/- ##
==========================================
+ Coverage 83.11% 83.15% +0.03%
==========================================
Files 277 277
Lines 48207 48315 +108
Branches 10192 9959 -233
==========================================
+ Hits 40069 40174 +105
- Misses 7243 7258 +15
+ Partials 895 883 -12
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
@Dimi1010 the main issue I see with this approach is that it's quite strict and limits users to specific options to create ARP messages. Creating a non-standard ARP message is not possible unless they use the deprecated c'tor. My suggestion here keeps the existing c'tor which gives the most freedom while creating another c'tor for gratuitous ARP requests which AFAIK are quite rarely used (no one requested it until now, even though ARP exists for many years in PcapPlusPlus) |
Deprecating the current ctor is not really a requirement, I deprecated it because people might have been relying on the zeroing the target MAC functionality. The new private ctor can also be exposed to allow ppl to construct whatever packets they want, which would probably work better, as the MAC addr wont be zeroed out under their feet if they dont want it. |
When I think about it, maybe we can just remove zeroing out We probably need to update some tests and examples that use ARP (like Arping) which assume an ARP request always has a |
I can make the Also a standard ARP request should have the target mac zeroed. It is in the spec. |
You convinced me 🙂 |
…e type of ARP message.
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.
There are also ARP layers generated in 3 places in ArpSpoofing that we can modify: https://github.com/seladb/PcapPlusPlus/blob/feba0b7124a4536ec2a0a947bc96c146ada099d7/Examples/ArpSpoofing/main.cpp
} | ||
|
||
{ | ||
// TODO: Add an actual packet to test against. |
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.
You can use ArpResponsePacket.dat
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.
Sure, but why is the packet size 60 in EthAndArpPacketParsing
? 14 (EthLayer
) +28 (ArpLayer
) makes 42, no?
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.
Good question, the extra is Ethernet trailer, as you can see in ArpResponsePacket.pcap
. But it is still a valid ARP response packet
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.
ARP response can have random length padding at the end, which also confused me before.
…ssage structure based constructors.
This PR is a potential implementation of #1682.
Specific header constructors
ArpLayer
has been expanded with constructors accepting the following structures that build a respective ARP header inside the layer.