-
Notifications
You must be signed in to change notification settings - Fork 706
Attempt to flatten the BgpLayer
inheritance chain.
#1820
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
base: dev
Are you sure you want to change the base?
Attempt to flatten the BgpLayer
inheritance chain.
#1820
Conversation
…perations on them.
…ata in BgpLayer as a specific BGP message.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev #1820 +/- ##
==========================================
- Coverage 84.10% 81.89% -2.21%
==========================================
Files 272 285 +13
Lines 47578 49691 +2113
Branches 10344 10548 +204
==========================================
+ Hits 40015 40695 +680
- Misses 6518 8209 +1691
+ Partials 1045 787 -258
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:
|
…r for quick instantiation. - Added internal::nocheck_t tag and a nocheck helper value. - Replaced duplicated code from mutable views with instantiation of a const view and call to the respective function.
@seladb @tigercosmos @clementperon @egecetin Can I get some first impressions on the idea of this draft? |
@Dimi1010 is it worth it to rewrite |
@Dimi1010 Is it possible to split this PR? It seems the PR is too large to review. |
Possibly, but this is still a WIP. |
Overview
This PR is a draft attempt to flatten the inheritance chain of
BgpLayer
and separate the protocol layer parsing logic from the message payload parsing logic.In the current implementation each BGP message has a dedicated derived BGP layer class. This introduces limitations where the message payload cannot be switched to a different type without destroying the layer object and creating a new one, requiring the layer to be extracted from the stack and then readded to it.
This PR aims to simplify the following operations by providing the following objects:
BgpLayer
that parse the payload as a specific message.They exist in two flavors "View" and "ConstView" with the former allowing in-place data modifications and the latter being read-only.
BgpLayer
's constructor or a dedicated method to completely replace the underlying message with a message of a different type. Similar to the ArpLayer's helper structs.The "View" object
The view object is a thin wrapper over a
BgpLayer
that holds a reference to the layer it has been created from. It provides accessors and mutators for reading and writing message specific data directly to the underlying buffer. Each view is intended to be passed by value and should be no larger than a pointer (the reference to theBgpLayer
), if possible.Each view should maintain message integrity. During construction the View should validate a minimally viable message of the type can be parsed from the buffer. Full validation can be deferred until use of accessors and/or mutators of the view object.
BGP Layer Enhancements
Improved support of full length update message path attributes.
The previous version supported path attributes with data up to 32 bytes. The new
PathAttribute
class supports the full spectrum of variable data lengths a path attribute block can contain specified by RFC 4271 Section 4.3.The attribute can support a data buffer of:
Other enhancements
Addition of utility functions for
enum class
flags.This PR adds the header
EnumFlagUtils.h
to theCommon++
package. The header provides operators for bitwise operators and helper functions ofenum class
objects when they satisfy the traitEnableBitMaskOperators
.In addition the header defines the following macros:
PCPP_DECLARE_ENUM_FLAG
- to enable the operators to be used for a class.PCPP_USING_ENUM_FLAG_OPERATORS
- to declare aliases to all templated operators in the scope this macro is used to satisfy ADL.