-
Notifications
You must be signed in to change notification settings - Fork 721
Add discrete FTPControl and FTPData protocol types. #1916
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
Add discrete FTPControl and FTPData protocol types. #1916
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #1916 +/- ##
==========================================
- Coverage 83.47% 83.47% -0.01%
==========================================
Files 298 298
Lines 53949 53950 +1
Branches 11982 11819 -163
==========================================
Hits 45033 45033
+ Misses 7703 7682 -21
- Partials 1213 1235 +22
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
const ProtocolType FTPData = 60; | ||
|
||
/// FTP protocol family (FTPControl and FtpData protocols) | ||
const ProtocolTypeFamily FTP = 0x3c29; |
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.
I wonder why FTP value is 0x3c29?
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.
It follows the convention for other protocol family packs.
Hex 3c = Dec 60 = FTPData
Hex 29 = Dec 41 = FTPControl
A single protocol value is 8 bits, while a family is 32 bits packed 4x 8 bit protocol type values. Essentially being (protocol1, protocol2, protocol3, protocol4)
.
The public API takes 32-bit family packs, so if a single protocol is passed, the value gets zero extended to (unknown protocol, unknown protocol, unknown protocol, protocol value)
.
Ideally, I would have this done with structs and constepxr construction, but we need cpp17 for that to work alongside the current usages inside switch cases. Until then, hard coded magic values it is.
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.
Wow... TBH it's a little hard to get the idea just from the source code. Could you add the comment in the code, thanks!
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 I can try to add documentation on how it works. Will be in a different PR tho.
This PR adds discrete
FTPControl
andFTPData
protocol types, while changingFTP
to protocol family.This is done to be able to better distinguish between FTP data channel and FTP control channel as they are normally on different ports. (relevant to #1881)
Potential breaking change:
42
now refers toFTPControl
instead ofFTP
and will only match control payloads.