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

[WIP] dhcp protocol update #1254

Draft
wants to merge 62 commits into
base: master
Choose a base branch
from
Draft

[WIP] dhcp protocol update #1254

wants to merge 62 commits into from

Conversation

svinota
Copy link
Owner

@svinota svinota commented Jan 21, 2025

Bug-Url: #1250

@svinota
Copy link
Owner Author

svinota commented Jan 21, 2025

@etene moved the branch and created a new PR for that.

@svinota svinota marked this pull request as draft January 21, 2025 22:44
@svinota
Copy link
Owner Author

svinota commented Jan 21, 2025

@etene I will not diverge the code on the branch without letting you know, so you can safely use git push --force on this branch.

@etene etene self-assigned this Jan 22, 2025
@etene etene linked an issue Jan 22, 2025 that may be closed by this pull request
@etene etene force-pushed the p10-dhcp-protocol branch from 022d4eb to 4b855c8 Compare January 23, 2025 09:15
'''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]
Copy link
Owner Author

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:

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)

Copy link
Collaborator

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

Copy link
Owner Author

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)

@@ -1,4 +1,4 @@
from enum import IntEnum
from enum import EnumType, IntEnum
Copy link
Owner Author

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.

Copy link
Collaborator

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 !

@etene etene force-pushed the p10-dhcp-protocol branch from 9fa4d33 to b713e5c Compare January 29, 2025 09:21
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
Copy link
Owner Author

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 :)

@svinota
Copy link
Owner Author

svinota commented Jan 29, 2025

Gentlemen, it is with great pleasure to inform you that the CI is green again

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.

DHCP client
3 participants