Skip to content

Commit b25fb59

Browse files
authored
Added documentation comment for protocol type and protocol type family. (#1919)
* Added documentation comment for protocol type and protocol type family. * Lint
1 parent 8e3896b commit b25fb59

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

Packet++/header/ProtocolType.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,28 @@
88
/// @brief The main namespace for the PcapPlusPlus lib
99
namespace pcpp
1010
{
11+
/// @defgroup ProtocolTypes ProtocolType and ProtocolTypeFamily
12+
/// In the PcapPlusPlus library, specific protocols are identified by a `ProtocolType` value, which is an 8-bit
13+
/// unsigned integer. Each Layer class has a ProtocolType that can be used to identify the protocol of that layer.
14+
///
15+
/// As there are some situations where multiple protocols can be grouped together (e.g. IPv4 and IPv6 into IP),
16+
/// PcapPlusPlus also defines ProtocolTypeFamily, which is a group of multiple protocol types. In functions where a
17+
/// ProtocolTypeFamily parameter is expected, a single ProtocolType value can be passed instead. The library will
18+
/// treat it as a family containing only that single protocol.
19+
///
20+
/// @internal
21+
///
22+
/// A ProtocolTypeFamily pack is represented as a 32-bit unsigned integer. Each octet in the 32-bit value is a
23+
/// ProtocolType, allowing for up to 4 protocols to be packed into a single ProtocolTypeFamily value. For example,
24+
/// the ProtocolTypeFamily for IP is represented as 0x203, which contains both IPv4 (0x02) and IPv6 (0x03)
25+
/// protocols. A single ProtocolType casted to ProtocolTypeFamily will result the value '0x000000xx' where 'xx' is
26+
/// the value of the ProtocolType.
27+
///
28+
/// @endinternal
29+
30+
/// @addtogroup ProtocolTypes
31+
/// @{
32+
1133
/// @typedef ProtocolType
1234
/// Representing all protocols supported by PcapPlusPlus
1335
typedef uint8_t ProtocolType;
@@ -229,6 +251,8 @@ namespace pcpp
229251
/// FTP protocol family (FTPControl and FtpData protocols)
230252
const ProtocolTypeFamily FTP = 0x3c29;
231253

254+
/// @}
255+
232256
/// An enum representing OSI model layers
233257
enum OsiModelLayer
234258
{
@@ -256,6 +280,7 @@ namespace pcpp
256280
/// @param family A protocol type family value.
257281
/// @param protocol A protocol type value to check against the family.
258282
/// @return True if the protocol is part of the family, false otherwise.
283+
/// @ingroup ProtocolTypes
259284
constexpr bool protoFamilyContainsProtocol(ProtocolTypeFamily family, ProtocolType protocol)
260285
{
261286
auto const protocolToFamily = static_cast<ProtocolTypeFamily>(protocol);

0 commit comments

Comments
 (0)