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

Feature/add-ptp-protocol #4640

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

satveerbrar
Copy link
Contributor

@satveerbrar satveerbrar commented Jan 12, 2025

@polybassa @gpotter2
Here is the draft PR to add PTP protocol.

Currently this includes basic PTP header and Sync message type.

Planned additions in future commits:

  1. post_build function to calculate and insert message length field.
  2. Classes for the remaining PTP message types.
  3. Unit tests

Let me know if I have followed the correct approach.

fixes #4637

@satveerbrar satveerbrar marked this pull request as draft January 12, 2025 08:12
scapy/layers/ptp_v2.py Outdated Show resolved Hide resolved
Copy link
Member

@gpotter2 gpotter2 left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!
A few comments. It's a good start !

ByteField("logMessageInterval", 0)
]

def guess_payload_class(self, payload): # type: (bytes) -> Type[Packet]
Copy link
Member

Choose a reason for hiding this comment

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

We typically reserve guess_payloaf for complex cases. Here a simpler approach with bind_layers is enough, and it also handles building.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed classes for individual message types and integrated their fields directly as a Conditional Field. Because all these fields are part of the PTP layer rather than being separate layers

"""


class FollowUp(Packet):
Copy link
Member

Choose a reason for hiding this comment

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

If the packets really are empty, you don't need to include them. Having an enum in the parent that shows this type is enough.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, it's not empty., I have to implement fields in those packets.

scapy/layers/ptp_v2.py Outdated Show resolved Hide resolved
Copy link

codecov bot commented Jan 13, 2025

Codecov Report

Attention: Patch coverage is 0% with 18 lines in your changes missing coverage. Please review.

Project coverage is 81.62%. Comparing base (92925da) to head (7bf9906).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
scapy/layers/ptp_v2.py 0.00% 18 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4640      +/-   ##
==========================================
+ Coverage   80.71%   81.62%   +0.90%     
==========================================
  Files         359      360       +1     
  Lines       86052    86253     +201     
==========================================
+ Hits        69461    70404     +943     
+ Misses      16591    15849     -742     
Files with missing lines Coverage Δ
scapy/layers/ptp_v2.py 0.00% <0.00%> (ø)

... and 25 files with indirect coverage changes

@satveerbrar satveerbrar marked this pull request as ready for review January 18, 2025 01:07
@satveerbrar satveerbrar force-pushed the feature/add-ptp-protocol branch from 4eb7a14 to 3c72f1a Compare January 18, 2025 01:23
@satveerbrar satveerbrar requested a review from gpotter2 January 18, 2025 01:26
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.

Request for Support for Precision Time Protocol (PTPv2)
2 participants