-
-
Notifications
You must be signed in to change notification settings - Fork 249
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
[WIP] dhcp protocol update #1254
base: master
Are you sure you want to change the base?
Conversation
add an async dhcp client Bug-Url: #1250
@etene moved the branch and created a new PR for that. |
@etene I will not diverge the code on the branch without letting you know, so you can safely use |
022d4eb
to
4b855c8
Compare
as defined in the RFC
'''Decode a simple DHCP handshake using AsyncDHCP4Socket.''' | ||
def parse_pcap( | ||
pcap: PcapFile, expected_packets: int | ||
) -> list[ReceivedDHCPMessage]: | ||
decoded_dhcp_messages = [AsyncDHCP4Socket._decode_msg(i) for i in pcap] |
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.
Just wondering, how does it work with pcap header.
See also:
pyroute2/pyroute2/decoder/loader.py
Lines 258 to 266 in 3d0d36f
def __init__(self, data, cls, key, data_offset, script): | |
with open(data, 'rb') as f: | |
self.raw = f.read() | |
self.metadata = PcapMetaData(*struct.unpack("IHHiIII", self.raw[:24])) | |
self.offset = 24 | |
self.key = key | |
self.data_offset = data_offset | |
self.cls = cls | |
self.matcher = Matcher(script) |
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.
Oh, i had not noticed it ! I put together a quick test fixture without seeing it, i'll see how i can use this code instead
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.
If you need any changes in the decoder, pls let me know or feel free to fix
(and I have to document this part at least)
…ments Add hooks and other improvements
pyroute2/dhcp/enums/dhcp.py
Outdated
@@ -1,4 +1,4 @@ | |||
from enum import IntEnum | |||
from enum import EnumType, IntEnum |
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.
EnumType
was added in Python 3.11, while we declare compatibility up to 3.9.
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.
Found a way to do without !
9fa4d33
to
b713e5c
Compare
self.decoded_requests: list[SentDHCPMessage] = [] | ||
# save the event_loop fixture, 'cause pytest-asyncio on Python < 3.10 | ||
# drops the loop in the middle of the test | ||
self.loop = event_loop |
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.
@etene that did the trick
I've learned something new during this brainstorm :)
Gentlemen, it is with great pleasure to inform you that the CI is green again |
Bug-Url: #1250